Skip to content

Commit 9227d59

Browse files
committed
Merge remote-tracking branch 'upstream/next' into Issue5109_Consolidate_copy_command_logic
2 parents 4666115 + 80948b8 commit 9227d59

File tree

75 files changed

+3954
-3163
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+3954
-3163
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,4 @@ Rubberduck.CodeAnalysis.xml
189189

190190
#Gradle
191191
/.gradle/
192+
/Rubberduck.CodeAnalysis/Rubberduck.CodeAnalysis.xml

Rubberduck.CodeAnalysis/Inspections/Concrete/AssignedByValParameterInspection.cs

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -48,43 +48,12 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
4848
.Cast<ParameterDeclaration>()
4949
.Where(item => !item.IsByRef
5050
&& !item.IsIgnoringInspectionResultFor(AnnotationName)
51-
&& item.References.Any(IsAssignmentToDeclaration));
51+
&& item.References.Any(reference => reference.IsAssignment));
5252

5353
return parameters
5454
.Select(param => new DeclarationInspectionResult(this,
5555
string.Format(InspectionResults.AssignedByValParameterInspection, param.IdentifierName),
5656
param));
5757
}
58-
59-
private static bool IsAssignmentToDeclaration(IdentifierReference reference)
60-
{
61-
//Todo: Review whether this is still needed once parameterless default member assignments are resolved correctly.
62-
63-
if (!reference.IsAssignment)
64-
{
65-
return false;
66-
}
67-
68-
if (reference.IsSetAssignment)
69-
{
70-
return true;
71-
}
72-
73-
var declaration = reference.Declaration;
74-
if (declaration == null)
75-
{
76-
return false;
77-
}
78-
79-
if (declaration.IsObject)
80-
{
81-
//This can only be legal with a default member access.
82-
return false;
83-
}
84-
85-
//This is not perfect in case the referenced declaration is an unbound Variant.
86-
//In that case, a default member access might occur after the run-time resolution.
87-
return true;
88-
}
8958
}
9059
}

Rubberduck.CodeAnalysis/Inspections/Concrete/ImplicitDefaultMemberAssignmentInspection.cs

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
using System.Collections.Generic;
2-
using System.Diagnostics;
32
using System.Linq;
43
using Rubberduck.Inspections.Abstract;
54
using Rubberduck.Inspections.Results;
6-
using Rubberduck.Parsing;
7-
using Rubberduck.Parsing.Grammar;
85
using Rubberduck.Parsing.Inspections.Abstract;
96
using Rubberduck.Resources.Inspections;
107
using Rubberduck.Parsing.Symbols;
@@ -40,28 +37,42 @@ public ImplicitDefaultMemberAssignmentInspection(RubberduckParserState state)
4037

4138
protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
4239
{
43-
var interestingDeclarations =
44-
State.AllDeclarations.Where(item =>
45-
item.AsTypeDeclaration != null
46-
&& ClassModuleDeclaration.HasDefaultMember(item.AsTypeDeclaration));
40+
var boundDefaultMemberAssignments = State.DeclarationFinder
41+
.AllIdentifierReferences()
42+
.Where(IsRelevantReference);
4743

48-
var interestingReferences = interestingDeclarations
49-
.SelectMany(declaration => declaration.References)
50-
.Where(reference =>
51-
{
52-
var letStmtContext = reference.Context.GetAncestor<VBAParser.LetStmtContext>();
53-
return reference.IsAssignment
54-
&& letStmtContext != null
55-
&& letStmtContext.LET() == null
56-
&& !reference.IsIgnoringInspectionResultFor(AnnotationName);
57-
});
44+
var boundIssues = boundDefaultMemberAssignments
45+
.Select(reference => new IdentifierReferenceInspectionResult(
46+
this,
47+
string.Format(
48+
InspectionResults.ImplicitDefaultMemberAssignmentInspection,
49+
reference.Context.GetText(),
50+
reference.Declaration.IdentifierName,
51+
reference.Declaration.QualifiedModuleName.ToString()),
52+
State,
53+
reference));
5854

59-
return interestingReferences.Select(reference => new IdentifierReferenceInspectionResult(this,
60-
string.Format(InspectionResults.ImplicitDefaultMemberAssignmentInspection,
61-
reference.Declaration.IdentifierName,
62-
reference.Declaration.AsTypeDeclaration.IdentifierName),
63-
State,
64-
reference));
55+
var unboundDefaultMemberAssignments = State.DeclarationFinder
56+
.AllUnboundDefaultMemberAccesses()
57+
.Where(IsRelevantReference);
58+
59+
var unboundIssues = unboundDefaultMemberAssignments
60+
.Select(reference => new IdentifierReferenceInspectionResult(
61+
this,
62+
string.Format(
63+
InspectionResults.ImplicitDefaultMemberAssignmentInspection_Unbound,
64+
reference.Context.GetText()),
65+
State,
66+
reference));
67+
68+
return boundIssues.Concat(unboundIssues);
69+
}
70+
71+
private bool IsRelevantReference(IdentifierReference reference)
72+
{
73+
return reference.IsAssignment
74+
&& reference.IsNonIndexedDefaultMemberAccess
75+
&& !reference.IsIgnoringInspectionResultFor(AnnotationName);
6576
}
6677
}
6778
}

0 commit comments

Comments
 (0)