Skip to content

Commit a53b886

Browse files
committed
Merge remote-tracking branch 'origin/Issue5109_Consolidate_copy_command_logic' into nextIntoIssue5109
2 parents d4c3f2b + 9227d59 commit a53b886

File tree

177 files changed

+4208
-1260
lines changed

Some content is hidden

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

177 files changed

+4208
-1260
lines changed

Rubberduck.CodeAnalysis/Inspections/Abstract/IdentifierReferenceInspectionBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
2727
var results = new List<IInspectionResult>();
2828
foreach (var moduleDeclaration in State.DeclarationFinder.UserDeclarations(DeclarationType.Module))
2929
{
30-
if (moduleDeclaration == null || moduleDeclaration.IsIgnoringInspectionResultFor(AnnotationName))
30+
if (moduleDeclaration == null)
3131
{
3232
continue;
3333
}

Rubberduck.CodeAnalysis/Inspections/Abstract/InspectionBase.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections.Generic;
33
using System.Globalization;
44
using System.Linq;
5-
using Rubberduck.Parsing.Annotations;
65
using Rubberduck.Parsing.Inspections.Abstract;
76
using Rubberduck.Parsing.Symbols;
87
using Rubberduck.Parsing.VBA;
@@ -105,7 +104,9 @@ public IEnumerable<IInspectionResult> GetInspectionResults(CancellationToken tok
105104
{
106105
var _stopwatch = new Stopwatch();
107106
_stopwatch.Start();
108-
var result = DoGetInspectionResults();
107+
var declarationFinder = State.DeclarationFinder;
108+
var result = DoGetInspectionResults()
109+
.Where(ir => !ir.IsIgnoringInspectionResult(declarationFinder));
109110
_stopwatch.Stop();
110111
_logger.Trace("Intercepted invocation of '{0}.{1}' returned {2} objects.", GetType().Name, nameof(DoGetInspectionResults), result.Count());
111112
_logger.Trace("Intercepted invocation of '{0}.{1}' ran for {2}ms", GetType().Name, nameof(DoGetInspectionResults), _stopwatch.ElapsedMilliseconds);

Rubberduck.CodeAnalysis/Inspections/Abstract/InspectionResultBase.cs

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Rubberduck.Inspections.Abstract
1313
{
14-
public abstract class InspectionResultBase : IInspectionResult, INavigateSource, IExportable
14+
public abstract class InspectionResultBase : IInspectionResult, INavigateSource
1515
{
1616
protected InspectionResultBase(IInspection inspection,
1717
string description,
@@ -56,39 +56,6 @@ public int CompareTo(IInspectionResult other)
5656
return Inspection.CompareTo(other.Inspection);
5757
}
5858

59-
/// <summary>
60-
/// WARNING: This property can have side effects. It can change the ActiveVBProject if the result has a null Declaration,
61-
/// which causes a flicker in the VBE. This should only be called if it is *absolutely* necessary.
62-
/// </summary>
63-
public string ToClipboardString()
64-
{
65-
var module = QualifiedSelection.QualifiedName;
66-
var documentName = Target != null
67-
? Target.ProjectDisplayName
68-
: string.Empty;
69-
//todo: Find a sane way to reimplement this.
70-
//if (string.IsNullOrEmpty(documentName))
71-
//{
72-
// var component = module.Component;
73-
// documentName = component != null
74-
// ? component.ParentProject.ProjectDisplayName
75-
// : string.Empty;
76-
//}
77-
if (string.IsNullOrEmpty(documentName))
78-
{
79-
documentName = Path.GetFileName(module.ProjectPath);
80-
}
81-
82-
return string.Format(
83-
InspectionsUI.QualifiedSelectionInspection,
84-
Inspection.Severity,
85-
Description,
86-
$"({documentName})",
87-
module.ProjectName,
88-
module.ComponentName,
89-
QualifiedSelection.Selection.StartLine);
90-
}
91-
9259
private NavigateCodeEventArgs _navigationArgs;
9360
public NavigateCodeEventArgs GetNavigationArgs()
9461
{
@@ -105,11 +72,5 @@ public int CompareTo(object obj)
10572
{
10673
return CompareTo(obj as IInspectionResult);
10774
}
108-
109-
public object[] ToArray()
110-
{
111-
var module = QualifiedSelection.QualifiedName;
112-
return new object[] { Inspection.Severity.ToString(), module.ProjectName, module.ComponentName, Description, QualifiedSelection.Selection.StartLine, QualifiedSelection.Selection.StartColumn };
113-
}
11475
}
11576
}

Rubberduck.CodeAnalysis/Inspections/Abstract/MemberAccessMayReturnNothingInspectionBase.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
2929
}
3030

3131
var output = new List<IInspectionResult>();
32-
foreach (var reference in interesting.Where(use => !use.IsIgnoringInspectionResultFor(AnnotationName)))
32+
// prefilter to reduce search space
33+
var prefilteredReferences = interesting.Where(use => !use.IsIgnoringInspectionResultFor(AnnotationName));
34+
foreach (var reference in prefilteredReferences)
3335
{
3436
var access = reference.Context.GetAncestor<VBAParser.MemberAccessExprContext>();
3537
var usageContext = access.Parent is VBAParser.IndexExprContext

Rubberduck.CodeAnalysis/Inspections/Concrete/ArgumentWithIncompatibleObjectTypeInspection.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
109109
argumentReferenceWithTypeName.argumentTypeName));
110110

111111
return offendingArguments
112-
.Where(argumentReferenceWithTypeName => !IsIgnored(argumentReferenceWithTypeName.Item1))
112+
// Ignoring the Declaration disqualifies all assignments
113+
.Where(argumentReferenceWithTypeName => !argumentReferenceWithTypeName.Item1.Declaration.IsIgnoringInspectionResultFor(AnnotationName))
113114
.Select(argumentReference => InspectionResult(argumentReference, _declarationFinderProvider));
114115
}
115116

@@ -167,13 +168,6 @@ private bool HasSubType(Declaration declaration, string typeName)
167168
return classType.Supertypes.Select(supertype => supertype.QualifiedModuleName.ToString()).Contains(typeName);
168169
}
169170

170-
private bool IsIgnored(IdentifierReference assignment)
171-
{
172-
return assignment.IsIgnoringInspectionResultFor(AnnotationName)
173-
// Ignoring the Declaration disqualifies all assignments
174-
|| assignment.Declaration.IsIgnoringInspectionResultFor(AnnotationName);
175-
}
176-
177171
private IInspectionResult InspectionResult((IdentifierReference argumentReference, string argumentTypeName) argumentReferenceWithTypeName, IDeclarationFinderProvider declarationFinderProvider)
178172
{
179173
var (argumentReference, argumentTypeName) = argumentReferenceWithTypeName;

Rubberduck.CodeAnalysis/Inspections/Concrete/AssignedByValParameterInspection.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
4747
var parameters = State.DeclarationFinder.UserDeclarations(DeclarationType.Parameter)
4848
.Cast<ParameterDeclaration>()
4949
.Where(item => !item.IsByRef
50-
&& !item.IsIgnoringInspectionResultFor(AnnotationName)
5150
&& item.References.Any(reference => reference.IsAssignment));
5251

5352
return parameters

Rubberduck.CodeAnalysis/Inspections/Concrete/AssignmentNotUsedInspection.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,8 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
7171
}
7272

7373
return nodes
74-
.Where(issue => !issue.IsIgnoringInspectionResultFor(AnnotationName)
75-
// Ignoring the Declaration disqualifies all assignments
76-
&& !issue.Declaration.IsIgnoringInspectionResultFor(AnnotationName))
74+
// Ignoring the Declaration disqualifies all assignments
75+
.Where(issue => !issue.Declaration.IsIgnoringInspectionResultFor(AnnotationName))
7776
.Select(issue => new IdentifierReferenceInspectionResult(this, Description, State, issue))
7877
.ToList();
7978
}

Rubberduck.CodeAnalysis/Inspections/Concrete/BooleanAssignedInIfElseInspection.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public BooleanAssignedInIfElseInspection(RubberduckParserState state)
4848
protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
4949
{
5050
return Listener.Contexts
51-
.Where(result => !result.IsIgnoringInspectionResultFor(State.DeclarationFinder, AnnotationName))
5251
.Select(result => new QualifiedContextInspectionResult(this,
5352
string.Format(InspectionResults.BooleanAssignedInIfElseInspection,
5453
(((VBAParser.IfStmtContext)result.Context).block().GetDescendent<VBAParser.LetStmtContext>()).lExpression().GetText().Trim()),

Rubberduck.CodeAnalysis/Inspections/Concrete/ConstantNotUsedInspection.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
4646
{
4747
var results = State.DeclarationFinder.UserDeclarations(DeclarationType.Constant)
4848
.Where(declaration => declaration.Context != null
49-
&& !declaration.References.Any()
50-
&& !declaration.IsIgnoringInspectionResultFor(AnnotationName))
49+
&& !declaration.References.Any())
5150
.ToList();
5251

5352
return results.Select(issue =>

Rubberduck.CodeAnalysis/Inspections/Concrete/DefTypeStatementInspection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public DefTypeStatementInspection(RubberduckParserState state)
4343

4444
protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
4545
{
46-
var results = Listener.Contexts.Where(context => !context.IsIgnoringInspectionResultFor(State.DeclarationFinder, AnnotationName))
46+
var results = Listener.Contexts
4747
.Select(context => new QualifiedContextInspectionResult(this,
4848
string.Format(InspectionResults.DefTypeStatementInspection,
4949
GetTypeOfDefType(context.Context.start.Text),

0 commit comments

Comments
 (0)