Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser Fix for LineNumberLovers #3217

Merged
merged 9 commits into from
Aug 3, 2017
6 changes: 3 additions & 3 deletions RetailCoder.VBE/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Rubberduck")]
[assembly: AssemblyProduct("Rubberduck")]
[assembly: AssemblyCopyright("Copyright © 2014-2016")]
[assembly: AssemblyCopyright("Copyright © 2014-2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -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.14.*")]
[assembly: AssemblyFileVersion("2.0.14.0")]
[assembly: AssemblyVersion("2.1.0.*")]
[assembly: AssemblyFileVersion("2.1.0.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public override IEnumerable<IInspectionResult> GetInspectionResults()
.Where(result => !IsIgnoringInspectionResultFor(result.ModuleName, result.Context.Start.Line))
.Select(result => new QualifiedContextInspectionResult(this,
InspectionsUI.EmptyElseBlockInspectionResultFormat,
State,
result));
}

Expand Down
1 change: 0 additions & 1 deletion Rubberduck.Inspections/Concrete/EmptyIfBlockInspection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public override IEnumerable<IInspectionResult> GetInspectionResults()
.Where(result => !IsIgnoringInspectionResultFor(result.ModuleName, result.Context.Start.Line))
.Select(result => new QualifiedContextInspectionResult(this,
InspectionsUI.EmptyIfBlockInspectionResultFormat,
State,
result));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public override IEnumerable<IInspectionResult> GetInspectionResults()
.Where(result => !IsIgnoringInspectionResultFor(result.ModuleName, result.Context.Start.Line))
.Select(result => new QualifiedContextInspectionResult(this,
InspectionsUI.EmptyStringLiteralInspectionResultFormat,
State,
result));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public override IEnumerable<IInspectionResult> GetInspectionResults()
{
return Listener.Contexts.Select(context =>
new QualifiedContextInspectionResult(this,
string.Format(InspectionsUI.IllegalAnnotationInspectionResultFormat, ((VBAParser.AnnotationContext)context.Context).annotationName().GetText()),
State, context));
string.Format(InspectionsUI.IllegalAnnotationInspectionResultFormat, ((VBAParser.AnnotationContext)context.Context).annotationName().GetText()), context));
}

public class IllegalAttributeAnnotationsListener : VBAParserBaseListener, IInspectionListener
Expand Down Expand Up @@ -63,6 +62,11 @@ public IllegalAttributeAnnotationsListener(RubberduckParserState state)
public void ClearContexts()
{
_contexts.Clear();
var keys = _annotationCounts.Keys.ToList();
foreach (var key in keys)
{
_annotationCounts[key] = 0;
}
}

#region scoping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ public override IEnumerable<IInspectionResult> GetInspectionResults()
string.Format(InspectionsUI.ImplicitByRefModifierInspectionResultFormat,
identifier.untypedIdentifier() != null
? identifier.untypedIdentifier().identifierValue().GetText()
: identifier.typedIdentifier().untypedIdentifier().identifierValue().GetText()),
State, issue);
: identifier.typedIdentifier().untypedIdentifier().identifierValue().GetText()), issue);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ where context.annotationName().GetText() == AnnotationType.Ignore.ToString()
select new QualifiedContextInspectionResult(this,
string.Format(InspectionsUI.MissingAnnotationArgumentInspectionResultFormat,
((VBAParser.AnnotationContext)result.Context).annotationName().GetText()),
State,
result));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public override IEnumerable<IInspectionResult> GetInspectionResults()
var name = string.Format(InspectionsUI.MissingAnnotationInspectionResultFormat,
member, ((VBAParser.AttributeStmtContext) context.Context).AnnotationType().ToString());

return new QualifiedContextInspectionResult(this, name, State, context);
return new QualifiedContextInspectionResult(this, name, context);
});
}

Expand Down
10 changes: 7 additions & 3 deletions Rubberduck.Inspections/Concrete/MissingAttributeInspection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public override IEnumerable<IInspectionResult> GetInspectionResults()
{
return Listener.Contexts.Select(context =>
{
var name = string.Format(InspectionsUI.MissingAttributeInspectionResultFormat, context.MemberName,
var name = string.Format(InspectionsUI.MissingAttributeInspectionResultFormat, context.MemberName.MemberName,
((VBAParser.AnnotationContext) context.Context).annotationName().GetText());
return new QualifiedContextInspectionResult(this, name, State, context);
return new QualifiedContextInspectionResult(this, name, context);
});
}

Expand Down Expand Up @@ -61,7 +61,7 @@ public override void ExitAnnotation(VBAParser.AnnotationContext context)
AddContext(new QualifiedContext<ParserRuleContext>(CurrentModuleName, context));
}
}
else
else if (isMemberAnnotation)
{
// member-level annotation is above the context for the first member in the module..
if (isModuleScope)
Expand All @@ -75,6 +75,10 @@ public override void ExitAnnotation(VBAParser.AnnotationContext context)
AddContext(new QualifiedContext<ParserRuleContext>(CurrentModuleName, context));
}
}
else
{
// annotation is illegal. ignore.
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public override IEnumerable<IInspectionResult> GetInspectionResults()
.Select(r => new QualifiedContext<ParserRuleContext>(result.ModuleName, r)))
.Select(result => new QualifiedContextInspectionResult(this,
string.Format(InspectionsUI.ModuleScopeDimKeywordInspectionResultFormat, ((VBAParser.VariableSubStmtContext)result.Context).identifier().GetText()),
State,
result));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public override IEnumerable<IInspectionResult> GetInspectionResults()
string.Format(context.Context.GetSelection().LineCount > 3
? RubberduckUI.EasterEgg_Continuator
: InspectionsUI.MultilineParameterInspectionResultFormat, ((VBAParser.ArgContext)context.Context).unrestrictedIdentifier().ToString()),
State,
context));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public override IEnumerable<IInspectionResult> GetInspectionResults()
.Where(result => !IsIgnoringInspectionResultFor(result.ModuleName, result.Context.Start.Line))
.Select(context => new QualifiedContextInspectionResult(this,
InspectionsUI.MultipleDeclarationsInspectionResultFormat,
State,
context));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public override IEnumerable<IInspectionResult> GetInspectionResults()
{
results.Add(new QualifiedContextInspectionResult(this,
InspectionsUI.ObsoleteCallStatementInspectionResultFormat,
State,
context));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public ObsoleteCommentSyntaxInspection(RubberduckParserState state)
public override IEnumerable<IInspectionResult> GetInspectionResults()
{
return Listener.Contexts.Where(context => !IsIgnoringInspectionResultFor(context.ModuleName, context.Context.Start.Line))
.Select(context => new QualifiedContextInspectionResult(this, InspectionsUI.ObsoleteCommentSyntaxInspectionResultFormat, State, context));
.Select(context => new QualifiedContextInspectionResult(this, InspectionsUI.ObsoleteCommentSyntaxInspectionResultFormat, context));
}

public class ObsoleteCommentSyntaxListener : VBAParserBaseListener, IInspectionListener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public ObsoleteLetStatementInspection(RubberduckParserState state)
public override IEnumerable<IInspectionResult> GetInspectionResults()
{
return Listener.Contexts.Where(context => !IsIgnoringInspectionResultFor(context.ModuleName, context.Context.Start.Line))
.Select(context => new QualifiedContextInspectionResult(this, InspectionsUI.ObsoleteLetStatementInspectionResultFormat, State, context));
.Select(context => new QualifiedContextInspectionResult(this, InspectionsUI.ObsoleteLetStatementInspectionResultFormat, context));
}

public class ObsoleteLetStatementListener : VBAParserBaseListener, IInspectionListener
Expand Down
1 change: 0 additions & 1 deletion Rubberduck.Inspections/Concrete/OptionBaseInspection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public override IEnumerable<IInspectionResult> GetInspectionResults()
return Listener.Contexts.Where(context => !IsIgnoringInspectionResultFor(context.ModuleName, context.Context.Start.Line))
.Select(context => new QualifiedContextInspectionResult(this,
string.Format(InspectionsUI.OptionBaseInspectionResultFormat, context.ModuleName.ComponentName),
State,
context));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public override IEnumerable<IInspectionResult> GetInspectionResults()
{
return Listener.Contexts.Select(context => new QualifiedContextInspectionResult(this,
string.Format(InspectionsUI.OptionExplicitInspectionResultFormat, context.ModuleName.ComponentName),
State,
context));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ public override IEnumerable<IInspectionResult> GetInspectionResults()
string.Format(InspectionsUI.RedundantByRefModifierInspectionResultFormat,
identifier.untypedIdentifier() != null
? identifier.untypedIdentifier().identifierValue().GetText()
: identifier.typedIdentifier().untypedIdentifier().identifierValue().GetText()),
State, issue);
: identifier.typedIdentifier().untypedIdentifier().identifierValue().GetText()), issue);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public override IEnumerable<IInspectionResult> GetInspectionResults()
return Listener.Contexts.Where(context => !IsIgnoringInspectionResultFor(context.ModuleName, context.Context.Start.Line))
.Select(context => new QualifiedContextInspectionResult(this,
string.Format(InspectionsUI.RedundantOptionInspectionResultFormat, context.Context.GetText()),
State,
context));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public SynchronizeAttributesQuickFix(RubberduckParserState state)
public void Fix(IInspectionResult result)
{
var context = result.Context;
// bug: this needs to assume member name is null for module-level stuff...
if (result.QualifiedMemberName?.MemberName != null)
{
FixMember(result, context);
Expand Down Expand Up @@ -86,11 +87,6 @@ private void FixMember(IInspectionResult result, ParserRuleContext context)
}
}

/// <summary>
/// Adds an annotation to match given attribute.
/// </summary>
/// <param name="memberName"></param>
/// <param name="context"></param>
private void Fix(QualifiedMemberName memberName, VBAParser.AttributeStmtContext context)
{
if (context.AnnotationType() == AnnotationType.Description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
using Rubberduck.Inspections.Abstract;
using Rubberduck.Parsing;
using Rubberduck.Parsing.Inspections.Abstract;
using Rubberduck.Parsing.VBA;
using Rubberduck.VBEditor;

namespace Rubberduck.Inspections.Results
{
class QualifiedContextInspectionResult : InspectionResultBase
{
public QualifiedContextInspectionResult(IInspection inspection, string description, RubberduckParserState state, QualifiedContext context, Dictionary<string, string> properties = null) :
public QualifiedContextInspectionResult(IInspection inspection, string description, QualifiedContext context, Dictionary<string, string> properties = null) :
base(inspection,
description,
context.ModuleName,
Expand All @@ -21,11 +20,5 @@ class QualifiedContextInspectionResult : InspectionResultBase
properties)
{
}

private static QualifiedMemberName? GetQualifiedMemberName(RubberduckParserState state, QualifiedContext context)
{
var members = state.DeclarationFinder.Members(context.ModuleName);
return members.SingleOrDefault(m => m.Selection.Contains(context.Context.GetSelection()))?.QualifiedName;
}
}
}