Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 11 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ Our Ducky has come quite the long way and is intimidatingly large for a first-ti
To make it easier to find something you can do, all issues with that label are additionally labelled with a difficulty.
That difficulty level is a best-guess by the dev-team how complex or evil an issue will be.

If you're new to C#, we recommend you start with \[difficulty-01-duckling\]. The next step \[difficulty-02-ducky\] requires some knowledge about C#, but not so much about how Rubberduck works - 02/ducky issues usually make a good introduction to using Rubberduck's internal API.
If you're new to C#, we recommend you start with \[difficulty-01-duckling\]. The next step \[difficulty-02-ducky\] requires some knowledge about C#, but not so much about how Rubberduck works

Then there's \[difficulty-03-duck\] which requires a good handle on C# and how the components of Rubberduck play toghether.
Then there's \[difficulty-03-duck\] which requires a good handle on C# and at least an idea of how the components of Rubberduck play toghether.
And finally there's \[difficulty-04-quackhead\] for when you really want to bang your head against the wall.
They require both good knowledge of C# and a deep understanding of how not only Rubberduck, but also COM and well, the VBE, works.
They require both good knowledge of C# and a deep understanding of how Rubberduck works.

In addition to this, a few people have put together some helpful resources about how Rubberduck works internally and help contributors tell left from right in the ~250k Lines of Code.

You can find their work in the [GitHub wiki](https://github.com/rubberduck-vba/Rubberduck/wiki). If something in there doesn't quite seem to match, it's probably because nobody got around to updating it yet. You're very welcome to **improve** the wiki by adding and correcting information. (see right above)
You can find their work in the [github wiki](https://github.com/rubberduck-vba/Rubberduck/wiki). If something in there doesn't quite seem to match, it's probably because nobody got around to updating it yet. You're very welcome to **improve** the wiki by adding and correcting information. (see right above)

In case this doesn't quite help you or the information you need hasn't been added to the wiki, you can **always** ask questions.
Please do so in the ["War room"](https://chat.stackexchange.com/rooms/14929).
Expand All @@ -79,21 +79,21 @@ Other than that, you can also open an issue with the label \[support\], but it m
In that room the core team talks about the duck and whatever else comes up.
N.B.: The rules of the Stack Exchange Network apply to everything you say in that room. But basically those are the same rules as those in the [CoC](#Code_of_Conduct).

Whether you create an issue or a pull request, please avoid using `[` square brackets `]` in the title, and try to be as descriptive (but succinct) as possible. Square brackets in titles confuse our chat-bot, and end up rendering in weird broken ways in SE chat. Avoid riddles, bad puns and other would-be funny (or NSFW) titles that don't really *describe the issue or PR*.
Whether you create an issue or a pull request, please avoid using `[` square brackets `]` in the title, and try to be as descriptive (but succinct) as possible. Square brackets in titles confuse our chat-bot, and end up rendering in weird broken ways in SE chat. Avoid riddles, bad puns and other would-be funny (or NSFW) titles that don't really describe the issue or PR.

### Translations

Rubberduck is localized in multiple languages.
Rubberduck is Localized in multiple languages.
All these translations have been provided by volunteers.
We welcome both new translations as well as improvements to current translations very much.

The resource files are RESX/XML files easily editable in any text editor, but our recommendation goes to the [ResXManager](https://marketplace.visualstudio.com/items?itemName=TomEnglert.ResXManager) Visual Studio plug-in:
The resource files are RESX/XML files easily editable in any text editor, but comparing resource keys across languages/translations is much easier done with @Vogel612's [Translation Helper](https://github.com/Vogel612/TranslationHelper) tool, which automatically adds missing keys and highlights entries that need a new translation.

![ResXManager in Visual Studio](https://user-images.githubusercontent.com/5751684/48683625-1a07f000-eb7c-11e8-914a-10ed80e85e29.png)

If you contribute a translation for a brand new previously unsupported language, please keep in touch with the dev team so that new resource keys can be translated when a new release is coming up; abandoned languages/translations will end up getting dropped.
If you contribute a translation for a brand new previously unsupported language, keep in touch with the dev team so that new resource keys can be translated when a new release is coming up; abandoned languages/translations will end up getting dropped.

## What comes out of it for me?

Well... the eternal gratitude of all Rubberduck users for one :wink:
Well ... the eternal gratitude of all Rubberduck users for one :wink:
Aside from that, all contributors are explicitly listed by name (or alias) in the "About Rubberduck" window.

We ran a [fundraiser](https://gofundme.com/rubberduckvba) last summer, and had t-sihrts, mugs, pens, and stickers made - the goods are now unfortunately depleted; we'll probably run another campaign next year!
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<img alt="Rubberduck Open-Source VBE Add-In - VBA6 | VBA7 x86/x64 | VB6" src="https://user-images.githubusercontent.com/5751684/48656196-a507af80-e9ef-11e8-9c09-1ce3c619c019.png" />
<img src="https://user-images.githubusercontent.com/5751684/46327997-aeb98d00-c5d2-11e8-9de5-ba6f9cd1eea3.png" />

<!-- campaign is no longer accepting donations
### Donate!

Expand Down
2 changes: 1 addition & 1 deletion Rubberduck.API/Rubberduck.API.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Sunburst.NET.Sdk.WPF/1.0.47">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Product>Rubberduck.API</Product>
<Description>Rubberduck Reflection API</Description>
Expand Down
24 changes: 14 additions & 10 deletions Rubberduck.API/VBA/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using Rubberduck.Common;
using Rubberduck.Parsing.ComReflection;
using Rubberduck.Parsing.PreProcessing;
using Rubberduck.Parsing.Rewriter;
using Rubberduck.Parsing.Symbols.DeclarationLoaders;
using Rubberduck.Parsing.VBA;
using Rubberduck.Parsing.Symbols;
using Rubberduck.Parsing.UIContext;
using Rubberduck.Parsing.VBA.ComReferenceLoading;
using Rubberduck.Parsing.VBA.DeclarationCaching;
Expand Down Expand Up @@ -67,10 +69,10 @@ public interface IParserEvents
]
public sealed class Parser : IParser, IDisposable
{
private readonly RubberduckParserState _state;
private readonly SynchronousParseCoordinator _parser;
private readonly IVBE _vbe;
private readonly IVBEEvents _vbeEvents;
private RubberduckParserState _state;
private SynchronousParseCoordinator _parser;
private IVBE _vbe;
private IVBEEvents _vbeEvents;
private readonly IUiDispatcher _dispatcher;
private readonly CancellationTokenSource _tokenSource;

Expand All @@ -96,6 +98,8 @@ internal Parser(object vbe) : this()
var projectRepository = new ProjectsRepository(_vbe);
_state = new RubberduckParserState(_vbe, projectRepository, declarationFinderFactory, _vbeEvents);
_state.StateChanged += _state_StateChanged;

var sourceFileHandler = _vbe.TempSourceFileHandler;
var vbeVersion = double.Parse(_vbe.Version, CultureInfo.InvariantCulture);
var predefinedCompilationConstants = new VBAPredefinedCompilationConstants(vbeVersion);
var typeLibProvider = new TypeLibWrapperProvider(projectRepository);
Expand All @@ -108,6 +112,7 @@ internal Parser(object vbe) : this()
var mainTokenStreamParser = new VBATokenStreamParser(mainParseErrorListenerFactory, mainParseErrorListenerFactory);
var tokenStreamProvider = new SimpleVBAModuleTokenStreamProvider();
var stringParser = new TokenStreamParserStringParserAdapterWithPreprocessing(tokenStreamProvider, mainTokenStreamParser, preprocessor);
var attributesSourceCodeHandler = new SourceFileHandlerSourceCodeHandlerAdapter(sourceFileHandler, projectRepository);
var projectManager = new RepositoryProjectManager(projectRepository);
var moduleToModuleReferenceManager = new ModuleToModuleReferenceManager();
var parserStateManager = new ParserStateManager(_state);
Expand All @@ -128,12 +133,14 @@ internal Parser(object vbe) : this()
}
);
var codePaneSourceCodeHandler = new CodePaneSourceCodeHandler(projectRepository);
var sourceFileHandler = _vbe.TempSourceFileHandler;
var attributesSourceCodeHandler = new SourceFileHandlerSourceCodeHandlerAdapter(sourceFileHandler, projectRepository);
var moduleRewriterFactory = new ModuleRewriterFactory(
codePaneSourceCodeHandler,
attributesSourceCodeHandler);
var moduleParser = new ModuleParser(
codePaneSourceCodeHandler,
attributesSourceCodeHandler,
stringParser);
stringParser,
moduleRewriterFactory);
var parseRunner = new ParseRunner(
_state,
parserStateManager,
Expand Down Expand Up @@ -228,9 +235,6 @@ public void Dispose()
}

_disposed = true;
_parser?.Dispose();
_vbe?.Dispose();
_tokenSource.Dispose();
}
}
}
7 changes: 2 additions & 5 deletions Rubberduck.CodeAnalysis/Inspections/Abstract/QuickFixBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
using System.Linq;
using NLog;
using Rubberduck.Parsing.Inspections.Abstract;
using Rubberduck.Parsing.Rewriter;
using Rubberduck.Parsing.VBA;
using Rubberduck.Parsing.VBA.Extensions;
using Rubberduck.Parsing.VBA.Parsing;

namespace Rubberduck.Inspections.Abstract
{
Expand Down Expand Up @@ -40,9 +39,7 @@ public void RemoveInspections(params Type[] inspections)
_supportedInspections = _supportedInspections.Except(inspections).ToHashSet();
}

public virtual CodeKind TargetCodeKind => CodeKind.CodePaneCode;

public abstract void Fix(IInspectionResult result, IRewriteSession rewriteSession);
public abstract void Fix(IInspectionResult result);
public abstract string Description(IInspectionResult result);

public abstract bool CanFixInProcedure { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
using Rubberduck.Inspections.CodePathAnalysis.Extensions;
using System.Linq;
using Rubberduck.Inspections.Results;
using Rubberduck.Parsing;
using Rubberduck.Parsing.Grammar;

namespace Rubberduck.Inspections.Concrete
{
Expand All @@ -23,9 +21,7 @@ public AssignmentNotUsedInspection(RubberduckParserState state, Walker walker)

protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
{
var variables = State.DeclarationFinder
.UserDeclarations(DeclarationType.Variable)
.Where(d => !d.IsArray);
var variables = State.DeclarationFinder.UserDeclarations(DeclarationType.Variable);

var nodes = new List<IdentifierReference>();
foreach (var variable in variables)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
var interfaceImplementationMembers = State.DeclarationFinder.FindAllInterfaceImplementingMembers();
var functions = State.DeclarationFinder
.UserDeclarations(DeclarationType.Function)
.Where(item => !IsIgnoringInspectionResultFor(item, AnnotationName) &&
item.References.Any(r => !IsReturnStatement(item, r) && !r.IsAssignment))
.Where(item => !IsIgnoringInspectionResultFor(item, AnnotationName))
.ToList();
var interfaceMemberIssues = GetInterfaceMemberIssues(interfaceMembers);
var nonInterfaceFunctions = functions.Except(interfaceMembers.Union(interfaceImplementationMembers));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ public IllegalAnnotationInspection(RubberduckParserState state)

protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
{
var illegalAnnotations = new List<IAnnotation>();

var userDeclarations = State.DeclarationFinder.AllUserDeclarations.ToList();
var identifierReferences = State.DeclarationFinder.AllIdentifierReferences().ToList();
var annotations = State.AllAnnotations;

var illegalAnnotations = UnboundAnnotations(annotations, userDeclarations, identifierReferences)
.Where(annotation => !annotation.AnnotationType.HasFlag(AnnotationType.GeneralAnnotation));
illegalAnnotations.AddRange(UnboundAnnotations(annotations, userDeclarations, identifierReferences));
illegalAnnotations.AddRange(NonIdentifierAnnotationsOnIdentifiers(identifierReferences));
illegalAnnotations.AddRange(NonModuleAnnotationsOnModules(userDeclarations));
illegalAnnotations.AddRange(NonMemberAnnotationsOnMembers(userDeclarations));
illegalAnnotations.AddRange(NonVariableAnnotationsOnVariables(userDeclarations));
illegalAnnotations.AddRange(NonGeneralAnnotationsWhereOnlyGeneralAnnotationsBelong(userDeclarations));

return illegalAnnotations.Select(annotation =>
new QualifiedContextInspectionResult(
Expand All @@ -44,5 +50,64 @@ private static ICollection<IAnnotation> UnboundAnnotations(IEnumerable<IAnnotati

return annotations.Where(annotation => !boundAnnotationsSelections.Contains(annotation.QualifiedSelection)).ToList();
}

private static ICollection<IAnnotation> NonIdentifierAnnotationsOnIdentifiers(IEnumerable<IdentifierReference> identifierReferences)
{
return identifierReferences
.SelectMany(reference => reference.Annotations)
.Where(annotation => !annotation.AnnotationType.HasFlag(AnnotationType.IdentifierAnnotation))
.ToList();
}

private static ICollection<IAnnotation> NonModuleAnnotationsOnModules(IEnumerable<Declaration> userDeclarations)
{
return userDeclarations
.Where(declaration => declaration.DeclarationType.HasFlag(DeclarationType.Module))
.SelectMany(moduleDeclaration => moduleDeclaration.Annotations)
.Where(annotation => !annotation.AnnotationType.HasFlag(AnnotationType.ModuleAnnotation))
.ToList();
}

private static ICollection<IAnnotation> NonMemberAnnotationsOnMembers(IEnumerable<Declaration> userDeclarations)
{
return userDeclarations
.Where(declaration => declaration.DeclarationType.HasFlag(DeclarationType.Member))
.SelectMany(member => member.Annotations)
.Where(annotation => !annotation.AnnotationType.HasFlag(AnnotationType.MemberAnnotation))
.ToList();
}

private static ICollection<IAnnotation> NonVariableAnnotationsOnVariables(IEnumerable<Declaration> userDeclarations)
{
return userDeclarations
.Where(declaration => VariableAnnotationDeclarationTypes.Contains(declaration.DeclarationType))
.SelectMany(declaration => declaration.Annotations)
.Where(annotation => !annotation.AnnotationType.HasFlag(AnnotationType.VariableAnnotation))
.ToList();
}

private static readonly HashSet<DeclarationType> VariableAnnotationDeclarationTypes = new HashSet<DeclarationType>()
{
DeclarationType.Variable,
DeclarationType.Control,
DeclarationType.Constant,
DeclarationType.Enumeration,
DeclarationType.EnumerationMember,
DeclarationType.UserDefinedType,
DeclarationType.UserDefinedType,
DeclarationType.UserDefinedTypeMember
};

private static ICollection<IAnnotation> NonGeneralAnnotationsWhereOnlyGeneralAnnotationsBelong(IEnumerable<Declaration> userDeclarations)
{
return userDeclarations
.Where(declaration => !declaration.DeclarationType.HasFlag(DeclarationType.Module)
&& !declaration.DeclarationType.HasFlag(DeclarationType.Member)
&& !VariableAnnotationDeclarationTypes.Contains(declaration.DeclarationType)
&& declaration.DeclarationType != DeclarationType.Project)
.SelectMany(member => member.Annotations)
.Where(annotation => !annotation.AnnotationType.HasFlag(AnnotationType.GeneralAnnotation))
.ToList();
}
}
}
Loading