Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions RetailCoder.VBE/Inspections/Abstract/InspectionBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@ protected bool IsInspectionDisabled(Declaration declaration, string inspectionNa
&& ((IgnoreAnnotation)annotation).IsIgnored(inspectionName));
}

protected bool IsInspectionDisabled(IdentifierReference reference, string inspectionName)
{
if (reference == null)
{
return false;
}

return reference.Annotations.Any(annotation =>
annotation.AnnotationType == AnnotationType.Ignore
&& ((IgnoreAnnotation)annotation).IsIgnored(inspectionName));
}

public int CompareTo(IInspection other)
{
return string.Compare(InspectionType + Name, other.InspectionType + other.Name, StringComparison.Ordinal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ public ImplicitByRefParameterInspection(RubberduckParserState state)
public override IEnumerable<InspectionResultBase> GetInspectionResults()
{
var interfaceMembersScope = UserDeclarations.FindInterfaceImplementationMembers().Select(m => m.Scope);
var builtinEventHandlers = State.AllDeclarations.FindBuiltInEventHandlers();
var builtinEventHandlers = Declarations.FindBuiltInEventHandlers();

var issues = (from item in UserDeclarations
where
!IsInspectionDisabled(item, AnnotationName)
&& item.DeclarationType == DeclarationType.Parameter
where item.DeclarationType == DeclarationType.Parameter
// ParamArray parameters do not allow an explicit "ByRef" parameter mechanism.
&& !((ParameterDeclaration)item).IsParamArray
&& !interfaceMembersScope.Contains(item.ParentScope)
Expand All @@ -40,7 +38,6 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
select new QualifiedContext<VBAParser.ArgContext>(item.QualifiedName, arg))
.Select(issue => new ImplicitByRefParameterInspectionResult(this, issue.Context.unrestrictedIdentifier().GetText(), issue));


return issues;
}
}
Expand Down
5 changes: 2 additions & 3 deletions RetailCoder.VBE/Inspections/ImplicitPublicMemberInspection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ public ImplicitPublicMemberInspection(RubberduckParserState state)
public override IEnumerable<InspectionResultBase> GetInspectionResults()
{
var issues = from item in UserDeclarations
where !IsInspectionDisabled(item, AnnotationName)
&& ProcedureTypes.Contains(item.DeclarationType)
where ProcedureTypes.Contains(item.DeclarationType)
&& item.Accessibility == Accessibility.Implicit
let context = new QualifiedContext<ParserRuleContext>(item.QualifiedName, item.Context)
select new ImplicitPublicMemberInspectionResult(this, context, item);
select new ImplicitPublicMemberInspectionResult(this, context, item);
return issues;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ public ImplicitVariantReturnTypeInspection(RubberduckParserState state)
public override IEnumerable<InspectionResultBase> GetInspectionResults()
{
var issues = from item in UserDeclarations
where !IsInspectionDisabled(item, AnnotationName)
&& ProcedureTypes.Contains(item.DeclarationType)
&& !item.IsTypeSpecified
where ProcedureTypes.Contains(item.DeclarationType) && !item.IsTypeSpecified
let issue = new {Declaration = item, QualifiedContext = new QualifiedContext<ParserRuleContext>(item.QualifiedName, item.Context)}
select new ImplicitVariantReturnTypeInspectionResult(this, issue.Declaration.IdentifierName, issue.QualifiedContext, item);
return issues;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public MultipleDeclarationsInspection(RubberduckParserState state)
public override IEnumerable<InspectionResultBase> GetInspectionResults()
{
var issues = UserDeclarations
.Where(item => !IsInspectionDisabled(item, AnnotationName))
.Where(item => item.DeclarationType == DeclarationType.Variable
|| item.DeclarationType == DeclarationType.Constant)
.GroupBy(variable => variable.Context.Parent as ParserRuleContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
if (!stringStrippedLines.Contains(":"))
{
results.Add(new ObsoleteCallStatementUsageInspectionResult(this,
new QualifiedContext<VBAParser.CallStmtContext>(context.ModuleName,
context.Context as VBAParser.CallStmtContext)));
new QualifiedContext<VBAParser.CallStmtContext>(context.ModuleName, context.Context)));
}
}
}
Expand Down
11 changes: 5 additions & 6 deletions RetailCoder.VBE/Inspections/ProcedureNotUsedInspection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
{
var declarations = UserDeclarations.ToList();

var classes = UserDeclarations.Where(item => item.DeclarationType == DeclarationType.ClassModule).ToList();
var modules = UserDeclarations.Where(item => item.DeclarationType == DeclarationType.ProceduralModule).ToList();
var classes = declarations.Where(item => item.DeclarationType == DeclarationType.ClassModule).ToList();
var modules = declarations.Where(item => item.DeclarationType == DeclarationType.ProceduralModule).ToList();

var handlers = declarations.Where(item => item.DeclarationType == DeclarationType.Control)
.SelectMany(control => declarations.FindEventHandlers(control)).ToList();

var withEventFields = UserDeclarations.Where(item => item.DeclarationType == DeclarationType.Variable && item.IsWithEvents);
var withEventFields = declarations.Where(item => item.DeclarationType == DeclarationType.Variable && item.IsWithEvents);
handlers.AddRange(withEventFields.SelectMany(field => declarations.FindEventProcedures(field)));

var forms = declarations.Where(item => item.DeclarationType == DeclarationType.ClassModule
Expand All @@ -54,11 +54,10 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
handlers.AddRange(forms.SelectMany(form => State.FindFormEventHandlers(form)));
}

handlers.AddRange(State.AllDeclarations.FindBuiltInEventHandlers());
handlers.AddRange(Declarations.FindBuiltInEventHandlers());

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

issues = DocumentEventHandlerPrefixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public UndeclaredVariableInspectionResult(IInspection inspection, Declaration ta
_quickFixes = new QuickFixBase[]
{
new IntroduceLocalVariableQuickFix(target),
new IgnoreOnceQuickFix(target.Context, target.QualifiedSelection, inspection.Name),
new IgnoreOnceQuickFix(target.Context, target.QualifiedSelection, inspection.AnnotationName),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
&& !UserDeclarations.Any(d => d.DeclarationType == DeclarationType.UserDefinedType
&& d.IdentifierName == declaration.AsTypeName)
&& !declaration.IsSelfAssigned
&& !declaration.References.Any(reference => reference.IsAssignment));
&& !declaration.References.Any(reference => reference.IsAssignment && !IsInspectionDisabled(reference, AnnotationName)));

//The parameter scoping was apparently incorrect before - need to filter for the actual function.
var lenFunction = BuiltInDeclarations.SingleOrDefault(s => s.DeclarationType == DeclarationType.Function && s.Scope.Equals("VBE7.DLL;VBA.Strings.Len"));
Expand Down
3 changes: 2 additions & 1 deletion RetailCoder.VBE/Inspections/UndeclaredVariableInspection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Rubberduck.Inspections.Abstract;
using Rubberduck.Inspections.Resources;
using Rubberduck.Inspections.Results;
using Rubberduck.Parsing.Symbols;
using Rubberduck.Parsing.VBA;

namespace Rubberduck.Inspections
Expand All @@ -20,7 +21,7 @@ public UndeclaredVariableInspection(RubberduckParserState state)

public override IEnumerable<InspectionResultBase> GetInspectionResults()
{
return UserDeclarations.Where(item => item.IsUndeclared)
return UserDeclarations.Where(item => item.IsUndeclared && item.DeclarationType == DeclarationType.Variable)
.Select(item => new UndeclaredVariableInspectionResult(this, item));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()

return declarations.SelectMany(declaration => declaration.References
.Where(item => _tokens.Contains(item.IdentifierName) &&
!IsInspectionDisabled(item.QualifiedModuleName.Component, item.Selection.StartLine))
!IsInspectionDisabled(item, AnnotationName))
.Select(item => new UntypedFunctionUsageInspectionResult(this, item)));
}
}
Expand Down
4 changes: 2 additions & 2 deletions RetailCoder.VBE/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.11.*")]
[assembly: AssemblyFileVersion("2.0.11.0")]
[assembly: AssemblyVersion("2.0.12.*")]
[assembly: AssemblyFileVersion("2.0.12.0")]
2 changes: 1 addition & 1 deletion Rubberduck.Parsing/Rubberduck.Parsing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
<Compile Include="Symbols\DebugDeclarations.cs" />
<Compile Include="Symbols\AliasDeclarations.cs" />
<Compile Include="Symbols\FormEventDeclarations.cs" />
<Compile Include="Symbols\ICustomDelarationLoader.cs" />
<Compile Include="Symbols\ICustomDeclarationLoader.cs" />
<Compile Include="Symbols\Identifier.cs" />
<Compile Include="Binding\IBindingContext.cs" />
<Compile Include="Binding\IBoundExpression.cs" />
Expand Down
2 changes: 1 addition & 1 deletion Rubberduck.Parsing/VBA/ParseCoordinator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private void ParseAll(object requestor, CancellationTokenSource token)
}

State.SetStatusAndFireStateChanged(requestor, State.Status);
return;
//return; // returning here leaves state in 'ResolvedDeclarations' when a module is removed, which disables refresh
}

foreach (var component in toParse)
Expand Down