Skip to content

Commit 4a82792

Browse files
authored
Merge pull request #3252 from rkapka/rkapka-master
Introducing ShadowedDeclarationInspection
2 parents 5a743db + d937b86 commit 4a82792

File tree

9 files changed

+4133
-13
lines changed

9 files changed

+4133
-13
lines changed

Rubberduck.Inspections/Concrete/IntegerDataTypeInspection.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ public override IEnumerable<IInspectionResult> GetInspectionResults()
4040
.Select(issue =>
4141
new DeclarationInspectionResult(this,
4242
string.Format(InspectionsUI.IntegerDataTypeInspectionResultFormat,
43-
RubberduckUI.ResourceManager.GetString("DeclarationType_" + issue.DeclarationType,
44-
CultureInfo.CurrentUICulture),
45-
issue.IdentifierName),
43+
RubberduckUI.ResourceManager.GetString("DeclarationType_" + issue.DeclarationType, CultureInfo.CurrentUICulture), issue.IdentifierName),
4644
issue));
4745

4846
return result;

Rubberduck.Inspections/Concrete/ShadowedDeclarationInspection.cs

Lines changed: 628 additions & 0 deletions
Large diffs are not rendered by default.

Rubberduck.Inspections/QuickFixes/ChangeIntegerToLongQuickFix.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ public void Fix(IInspectionResult result)
6868
rewriter.Replace(
6969
userDefinedTypeMemberContext.reservedNameMemberDeclaration().asTypeClause().type(),
7070
Tokens.Long);
71-
7271
}
7372
else
7473
{
@@ -87,9 +86,7 @@ public void Fix(IInspectionResult result)
8786
switch (result.Target.DeclarationType)
8887
{
8988
case DeclarationType.Parameter:
90-
matchingInterfaceMemberContext =
91-
interfaceMembers.Select(member => member.Context)
92-
.FirstOrDefault(c => c == result.Context.Parent.Parent);
89+
matchingInterfaceMemberContext = interfaceMembers.Select(member => member.Context).FirstOrDefault(c => c == result.Context.Parent.Parent);
9390

9491
if (matchingInterfaceMemberContext != null)
9592
{
@@ -127,9 +124,7 @@ public void Fix(IInspectionResult result)
127124
}
128125
break;
129126
case DeclarationType.Function:
130-
matchingInterfaceMemberContext =
131-
interfaceMembers.Select(member => member.Context)
132-
.FirstOrDefault(c => c == result.Context);
127+
matchingInterfaceMemberContext = interfaceMembers.Select(member => member.Context).FirstOrDefault(c => c == result.Context);
133128

134129
if (matchingInterfaceMemberContext != null)
135130
{
@@ -156,9 +151,7 @@ public void Fix(IInspectionResult result)
156151
}
157152
break;
158153
case DeclarationType.PropertyGet:
159-
matchingInterfaceMemberContext =
160-
interfaceMembers.Select(member => member.Context)
161-
.FirstOrDefault(c => c == result.Context);
154+
matchingInterfaceMemberContext = interfaceMembers.Select(member => member.Context).FirstOrDefault(c => c == result.Context);
162155

163156
if (matchingInterfaceMemberContext != null)
164157
{

Rubberduck.Inspections/Rubberduck.Inspections.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
<Compile Include="Concrete\StopKeywordInspection.cs" />
7070
<Compile Include="Concrete\LineLabelNotUsedInspection.cs" />
7171
<Compile Include="Concrete\IntegerDataTypeInspection.cs" />
72+
<Compile Include="Concrete\ShadowedDeclarationInspection.cs" />
7273
<Compile Include="ParseTreeListeners\AttributeAnnotationListener.cs" />
7374
<Compile Include="Concrete\ConstantNotUsedInspection.cs" />
7475
<Compile Include="Concrete\DefaultProjectNameInspection.cs" />

Rubberduck.Parsing/Inspections/Resources/InspectionsUI.resx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,4 +848,13 @@ If the parameter can be null, ignore this inspection result; passing a null valu
848848
<data name="EmptyWhileWendBlockInspectionName" xml:space="preserve">
849849
<value>Empty While-Wend block</value>
850850
</data>
851+
<data name="ShadowedDeclarationInspectionMeta" xml:space="preserve">
852+
<value>Two declarations are in scope and have the same identifier name. This means that only one of them will be available to use.</value>
853+
</data>
854+
<data name="ShadowedDeclarationInspectionName" xml:space="preserve">
855+
<value>Shadowed declaration</value>
856+
</data>
857+
<data name="ShadowedDeclarationInspectionResultFormat" xml:space="preserve">
858+
<value>{0} '{1}' hides {2} '{3}'</value>
859+
</data>
851860
</root>

Rubberduck.Parsing/Inspections/Resources/InspectionsUI1.Designer.cs

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Rubberduck.Parsing/Symbols/DeclarationSymbolsListener.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,11 @@ public override void EnterEnumerationStmt_Constant(VBAParser.EnumerationStmt_Con
865865
null));
866866
}
867867

868+
public override void EnterOptionPrivateModuleStmt(VBAParser.OptionPrivateModuleStmtContext context)
869+
{
870+
((ProceduralModuleDeclaration) _moduleDeclaration).IsPrivateModule = true;
871+
}
872+
868873
private void AddDeclaration(Declaration declaration)
869874
{
870875
_createdDeclarations.Add(declaration);

0 commit comments

Comments
 (0)