Skip to content

Commit e4b06ac

Browse files
authored
Merge pull request #2550 from retailcoder/next
MockVbeBuilder correctly loads serialized references
2 parents a70ffd8 + 5296504 commit e4b06ac

29 files changed

+613
-172
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using Rubberduck.Inspections.Abstract;
4+
using Rubberduck.Inspections.Resources;
5+
using Rubberduck.Inspections.Results;
6+
using Rubberduck.Parsing.Symbols;
7+
using Rubberduck.Parsing.VBA;
8+
9+
namespace Rubberduck.Inspections
10+
{
11+
public sealed class HostSpecificExpressionInspection : InspectionBase
12+
{
13+
public HostSpecificExpressionInspection(RubberduckParserState state)
14+
: base(state)
15+
{
16+
}
17+
18+
public override string Meta { get { return InspectionsUI.HostSpecificExpressionInspectionMeta; } }
19+
public override string Description { get { return InspectionsUI.HostSpecificExpressionInspectionName; } }
20+
public override CodeInspectionType InspectionType { get { return CodeInspectionType.LanguageOpportunities; } }
21+
22+
public override IEnumerable<InspectionResultBase> GetInspectionResults()
23+
{
24+
return Declarations.Where(item => item.DeclarationType == DeclarationType.BracketedExpression)
25+
.Select(item => new HostSpecificExpressionInspectionResult(this, item)).ToList();
26+
}
27+
}
28+
}

RetailCoder.VBE/Inspections/Resources/InspectionsUI.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.

RetailCoder.VBE/Inspections/Resources/InspectionsUI.resx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,4 +625,13 @@ If the parameter can be null, ignore this inspection result; passing a null valu
625625
<value>Member '{0}' is not declared on the interface for type '{1}'.</value>
626626
<comment>{0} Member used, {1} type being accessed.</comment>
627627
</data>
628+
<data name="HostSpecificExpressionInspectionMeta" xml:space="preserve">
629+
<value>Bracketed expressions are evaluated by the host application at runtime, which means VBA can't validate the expression at compile-time. Consider using the host application's object model instead.</value>
630+
</data>
631+
<data name="HostSpecificExpressionInspectionName" xml:space="preserve">
632+
<value>Host-specific bracketed expression is only evaluated at runtime</value>
633+
</data>
634+
<data name="HostSpecificExpressionInspectionResultFormat" xml:space="preserve">
635+
<value>Expression '{0}' cannot be validated at compile-time.</value>
636+
</data>
628637
</root>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Rubberduck.Inspections.Abstract;
2+
using Rubberduck.Inspections.Resources;
3+
using Rubberduck.Parsing.Symbols;
4+
5+
namespace Rubberduck.Inspections.Results
6+
{
7+
public class HostSpecificExpressionInspectionResult : InspectionResultBase
8+
{
9+
public HostSpecificExpressionInspectionResult(IInspection inspection, Declaration target)
10+
: base(inspection, target)
11+
{
12+
}
13+
14+
public override string Description
15+
{
16+
get
17+
{
18+
return string.Format(InspectionsUI.HostSpecificExpressionInspectionResultFormat, Target.IdentifierName);
19+
}
20+
}
21+
}
22+
}

RetailCoder.VBE/Root/RubberduckModule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public override void Load()
9191
Bind<Func<IIndenterSettings>>().ToMethod(t => () => KernelInstance.Get<IGeneralConfigService>().LoadConfiguration().UserSettings.IndenterSettings);
9292

9393
BindCustomDeclarationLoadersToParser();
94-
Rebind<IParseCoordinator>().To<ParseCoordinator>().InSingletonScope();
94+
Rebind<IParseCoordinator>().To<ParseCoordinator>().InSingletonScope().WithConstructorArgument("serializedDeclarationsPath", (string)null);
9595
Bind<Func<IVBAPreprocessor>>().ToMethod(p => () => new VBAPreprocessor(double.Parse(_vbe.Version, CultureInfo.InvariantCulture)));
9696

9797
Rebind<ISearchResultsWindowViewModel>().To<SearchResultsWindowViewModel>().InSingletonScope();

RetailCoder.VBE/Rubberduck.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@
365365
<Compile Include="Common\WinAPI\WM.cs" />
366366
<Compile Include="Common\WindowsOperatingSystem.cs" />
367367
<Compile Include="Common\UndocumentedAttribute.cs" />
368+
<Compile Include="Inspections\HostSpecificExpressionInspection.cs" />
368369
<Compile Include="Inspections\HungarianNotationInspection.cs" />
369370
<Compile Include="Inspections\ImplicitDefaultMemberAssignmentInspection.cs" />
370371
<Compile Include="Inspections\MemberNotOnInterfaceInspection.cs" />
@@ -375,6 +376,7 @@
375376
<DependentUpon>InspectionsUI.resx</DependentUpon>
376377
</Compile>
377378
<Compile Include="Inspections\Results\AggregateInspectionResult.cs" />
379+
<Compile Include="Inspections\Results\HostSpecificExpressionInspectionResult.cs" />
378380
<Compile Include="Inspections\Results\ImplicitDefaultMemberAssignmentInspectionResult.cs" />
379381
<Compile Include="Inspections\QuickFixes\IntroduceLocalVariableQuickFix.cs" />
380382
<Compile Include="Inspections\QuickFixes\OptionExplicitQuickFix.cs" />

0 commit comments

Comments
 (0)