Skip to content

Commit b3613d2

Browse files
committed
Fixes #1162; also fixes broken resx keys in inspections window, and ensures ProcedureNotUsedInspection accounts for @ignore annotations
1 parent 75034e3 commit b3613d2

File tree

7 files changed

+23
-21
lines changed

7 files changed

+23
-21
lines changed

RetailCoder.VBE/Inspections/InspectionsUI.Designer.cs

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

RetailCoder.VBE/Inspections/InspectionsUI.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,4 +497,7 @@
497497
<data name="VariableNotAssignedInspectionResultFormat" xml:space="preserve">
498498
<value>Variable '{0}' is never assigned</value>
499499
</data>
500+
<data name="DisableThisInspection" xml:space="preserve">
501+
<value>Disable this inspection</value>
502+
</data>
500503
</root>

RetailCoder.VBE/Inspections/ProcedureNotUsedInspection.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
4242
handlers.AddRange(forms.SelectMany(form => declarations.FindFormEventHandlers(form)));
4343
}
4444

45-
var issues = declarations
46-
.Where(item => !IsIgnoredDeclaration(declarations, item, handlers, classes, modules))
47-
.Select(issue => new IdentifierNotUsedInspectionResult(this, issue, issue.Context, issue.QualifiedName.QualifiedModuleName));
45+
var items = declarations
46+
.Where(item => !IsIgnoredDeclaration(declarations, item, handlers, classes, modules)
47+
&& !item.IsInspectionDisabled(AnnotationName)).ToList();
48+
var issues = items.Select(issue => new IdentifierNotUsedInspectionResult(this, issue, issue.Context, issue.QualifiedName.QualifiedModuleName));
4849

4950
issues = DocumentNames.DocumentEventHandlerPrefixes.Aggregate(issues, (current, item) => current.Where(issue => !issue.Description.Contains("'" + item)));
5051

RetailCoder.VBE/UI/CodeInspections/InspectionResultsControl.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,15 +434,15 @@
434434
<Button Style="{StaticResource LinkButton}" Margin="4"
435435
Visibility="{Binding CanExecuteQuickFixInModule, Converter={StaticResource BoolToVisibility}}"
436436
Command="{Binding QuickFixInModuleCommand}"
437-
Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=QuickFix_ThisModule}" />
437+
Content="{Resx ResxName=Rubberduck.Inspections.InspectionsUI, Key=QuickFix_ThisModule}" />
438438
<Button Style="{StaticResource LinkButton}" Margin="4"
439439
Visibility="{Binding CanExecuteQuickFixInProject, Converter={StaticResource BoolToVisibility}}"
440440
Command="{Binding QuickFixInProjectCommand}"
441-
Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=QuickFix_ThisProject}" />
441+
Content="{Resx ResxName=Rubberduck.Inspections.InspectionsUI, Key=QuickFix_ThisProject}" />
442442
<Button Style="{StaticResource LinkButton}" Margin="4"
443443
Visibility="{Binding CanDisableInspection, Converter={StaticResource BoolToVisibility}}"
444444
Command="{Binding DisableInspectionCommand}"
445-
Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=DisableThisInspection}" />
445+
Content="{Resx ResxName=Rubberduck.Inspections.InspectionsUI, Key=DisableThisInspection}" />
446446
</WrapPanel>
447447
</StackPanel>
448448
</Border>

RetailCoder.VBE/UI/RubberduckUI.Designer.cs

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

RetailCoder.VBE/UI/RubberduckUI.resx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -971,9 +971,6 @@ Are you sure you want to proceed with this rename?</value>
971971
<data name="RegexSearchReplace_SearchLabel" xml:space="preserve">
972972
<value>Search:</value>
973973
</data>
974-
<data name="DisableThisInspection" xml:space="preserve">
975-
<value>Disable this inspection</value>
976-
</data>
977974
<data name="ParserProgress_ShowDetails" xml:space="preserve">
978975
<value>Details</value>
979976
</data>

Rubberduck.Parsing/VBA/RubberduckParser.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ private void ParseInternal(VBComponent vbComponent, string code, CancellationTok
234234

235235
token.ThrowIfCancellationRequested();
236236

237+
// comments must be in the parser state before we start walking for declarations:
238+
var comments = ParseComments(qualifiedName, commentListener.Comments, commentListener.RemComments);
239+
_state.SetModuleComments(vbComponent, comments);
240+
237241
// cannot locate declarations in one pass *the way it's currently implemented*,
238242
// because the context in EnterSubStmt() doesn't *yet* have child nodes when the context enters.
239243
// so we need to EnterAmbiguousIdentifier() and evaluate the parent instead - this *might* work.
@@ -248,9 +252,6 @@ private void ParseInternal(VBComponent vbComponent, string code, CancellationTok
248252
walker.Walk(declarationsListener, tree);
249253
declarationsListener.NewDeclaration -= declarationsListener_NewDeclaration;
250254

251-
var comments = ParseComments(qualifiedName, commentListener.Comments, commentListener.RemComments);
252-
_state.SetModuleComments(vbComponent, comments);
253-
254255
_state.ObsoleteCallContexts = obsoleteCallsListener.Contexts.Select(context => new QualifiedContext(qualifiedName, context));
255256
_state.ObsoleteLetContexts = obsoleteLetListener.Contexts.Select(context => new QualifiedContext(qualifiedName, context));
256257
_state.EmptyStringLiterals = emptyStringLiteralListener.Contexts.Select(context => new QualifiedContext(qualifiedName, context));

0 commit comments

Comments
 (0)