Skip to content

Commit

Permalink
Merge branch 'next' of https://github.com/rubberduck-vba/rubberduck i…
Browse files Browse the repository at this point in the history
…nto Issue4159
  • Loading branch information
IvenBach committed Jul 20, 2018
2 parents 28a7c42 + 9d5f49a commit 1b27d57
Show file tree
Hide file tree
Showing 9 changed files with 453 additions and 52 deletions.
Expand Up @@ -2,6 +2,7 @@
using System.Linq;
using Rubberduck.Inspections.Abstract;
using Rubberduck.Inspections.Results;
using Rubberduck.Parsing.Grammar;
using Rubberduck.Parsing.Inspections.Abstract;
using Rubberduck.Resources.Inspections;
using Rubberduck.Parsing.Symbols;
Expand All @@ -23,12 +24,19 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
decl.AsTypeDeclaration.DeclarationType.HasFlag(DeclarationType.ClassModule) &&
((ClassModuleDeclaration)decl.AsTypeDeclaration).IsExtensible)
.SelectMany(decl => decl.References).ToList();
return from access in unresolved
let callingContext = targets.FirstOrDefault(usage => usage.Context.Equals(access.CallingContext))
where callingContext != null
select new DeclarationInspectionResult(this,
string.Format(InspectionResults.MemberNotOnInterfaceInspection, access.IdentifierName, callingContext.Declaration.AsTypeDeclaration.IdentifierName),
access);
return unresolved
.Select(access => new
{
access,
callingContext = targets.FirstOrDefault(usage => usage.Context.Equals(access.CallingContext)
|| (access.CallingContext is VBAParser.NewExprContext &&
usage.Context.Parent.Parent.Equals(access.CallingContext))
)
})
.Where(memberAccess => memberAccess.callingContext != null)
.Select(memberAccess => new DeclarationInspectionResult(this,
string.Format(InspectionResults.MemberNotOnInterfaceInspection, memberAccess.access.IdentifierName,
memberAccess.callingContext.Declaration.AsTypeDeclaration.IdentifierName), memberAccess.access));
}
}
}
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Rubberduck.Common;
using Rubberduck.Inspections.Abstract;
Expand Down Expand Up @@ -91,6 +92,9 @@ private IEnumerable<IInspectionResult> GetResults(Declaration[] declarations, De

for (var i = 0; i < parameters.Count; i++)
{
//If you hit this assert, congratulations! you've found a test case for https://github.com/rubberduck-vba/Rubberduck/issues/3906
//Please examine the code, and if possible, either fix the indexing on this or upload your failing code to the GitHub issue.
Debug.Assert(parametersAreByRef.Count == parameters.Count);
parametersAreByRef[i] = parametersAreByRef[i] &&
!IsUsedAsByRefParam(declarations, parameters[i]) &&
((VBAParser.ArgContext) parameters[i].Context).BYVAL() == null &&
Expand Down
9 changes: 7 additions & 2 deletions Rubberduck.Parsing/Grammar/VBALexer.g4
Expand Up @@ -301,9 +301,14 @@ UNDERSCORE : '_';
WS : [ \t];
GUIDLITERAL : '{' [0-9A-F]+ '-' [0-9A-F]+ '-' [0-9A-F]+ '-' [0-9A-F]+ '-' [0-9A-F]+ '}';
IDENTIFIER : ~[[\](){}\r\n\t.,'"|!@#$%^&*\-+:=; 0-9-/\\-] ~[[\](){}\r\n\t.,'"|!@#$%^&*\-+:=; -]*;
LINE_CONTINUATION : [ \t]* UNDERSCORE [ \t]* '\r'? '\n';
LINE_CONTINUATION : [ \t]+ UNDERSCORE [ \t]* '\r'? '\n' WS_NOT_FOLLOWED_BY_LINE_CONTINUATION*;
// The following rule is needed in order to capture hex literals without format prefixes which start with a digit. Needed for VBForm resources.
BARE_HEX_LITERAL : [0-9] [0-9a-fA-F]*;
BARE_HEX_LITERAL : [0-9] [0-9a-fA-F]*;
fragment WS_NOT_FOLLOWED_BY_LINE_CONTINUATION : [ \t] {(char)_input.La(1) != '_'
|| ((char)_input.La(2) != '\r'
&& (char)_input.La(2) != '\n'
&& (char)_input.La(2) != '\t'
&& (char)_input.La(2) != ' ')}?;
fragment LETTER : [a-zA-Z_äöüÄÖÜ];
fragment DIGIT : [0-9];
fragment LETTERORDIGIT : [a-zA-Z0-9_äöüÄÖÜ];
Expand Down
2 changes: 1 addition & 1 deletion Rubberduck.Parsing/Grammar/VBAParser.g4
Expand Up @@ -601,7 +601,7 @@ complexType :
fieldLength : MULT whiteSpace? (numberLiteral | identifierValue);

//Statement labels can only appear at the start of a line.
statementLabelDefinition : {_input.La(-1) == NEWLINE}? (combinedLabels | identifierStatementLabel | standaloneLineNumberLabel);
statementLabelDefinition : {_input.La(-1) == NEWLINE || _input.La(-1) == LINE_CONTINUATION}? (combinedLabels | identifierStatementLabel | standaloneLineNumberLabel);
identifierStatementLabel : legalLabelIdentifier whiteSpace? COLON;
standaloneLineNumberLabel :
lineNumberLabel whiteSpace? COLON
Expand Down
12 changes: 12 additions & 0 deletions Rubberduck.sln
Expand Up @@ -55,6 +55,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rubberduck.RegexAssistant",
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rubberduck.CodeAnalysis", "Rubberduck.CodeAnalysis\Rubberduck.CodeAnalysis.csproj", "{DEF2FB9D-6E62-49D6-8E26-9983AC025768}"
ProjectSection(ProjectDependencies) = postProject
{F83B6746-49A6-4CFD-9A29-3D7BBD4F0323} = {F83B6746-49A6-4CFD-9A29-3D7BBD4F0323}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rubberduck.Main", "Rubberduck.Main\Rubberduck.Main.csproj", "{E8AB5D93-2D0F-423D-BC15-5EE118673E48}"
ProjectSection(ProjectDependencies) = postProject
Expand Down Expand Up @@ -96,10 +99,19 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RubberduckTestsCodeAnalysis", "RubberduckTestsCodeAnalysis\RubberduckTestsCodeAnalysis.csproj", "{E9FC6518-F9E8-4E57-BD28-583A9EA69297}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rubberduck.Resources", "Rubberduck.Resources\Rubberduck.Resources.csproj", "{1B84B387-F7C4-4876-9BDF-C644C365359A}"
ProjectSection(ProjectDependencies) = postProject
{F83B6746-49A6-4CFD-9A29-3D7BBD4F0323} = {F83B6746-49A6-4CFD-9A29-3D7BBD4F0323}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rubberduck.Refactorings", "Rubberduck.Refactorings\Rubberduck.Refactorings.csproj", "{D4B6A510-14E1-420A-A8D5-6A09890FD7D8}"
ProjectSection(ProjectDependencies) = postProject
{F83B6746-49A6-4CFD-9A29-3D7BBD4F0323} = {F83B6746-49A6-4CFD-9A29-3D7BBD4F0323}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rubberduck.Interaction", "Rubberduck.Interaction\Rubberduck.Interaction.csproj", "{AC54B7FB-170D-4DA6-A30B-8CAD182F0E6B}"
ProjectSection(ProjectDependencies) = postProject
{F83B6746-49A6-4CFD-9A29-3D7BBD4F0323} = {F83B6746-49A6-4CFD-9A29-3D7BBD4F0323}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down

0 comments on commit 1b27d57

Please sign in to comment.