Skip to content

Commit 0741ce0

Browse files
authored
Merge branch 'next' into next
2 parents bfcc147 + df2a00f commit 0741ce0

24 files changed

+427
-49
lines changed

RetailCoder.VBE/Common/Hotkeys/HotkeyInfo.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Text;
33
using System.Windows.Forms;
4+
using Rubberduck.UI;
45

56
namespace Rubberduck.Common.Hotkeys
67
{
@@ -25,20 +26,21 @@ public override string ToString()
2526
var builder = new StringBuilder();
2627
if (_keys.HasFlag(Keys.Alt))
2728
{
28-
builder.Append(Rubberduck.UI.RubberduckUI.GeneralSettings_HotkeyAlt);
29+
builder.Append(RubberduckUI.GeneralSettings_HotkeyAlt);
2930
builder.Append('+');
3031
}
3132
if (_keys.HasFlag(Keys.Control))
3233
{
33-
builder.Append(Rubberduck.UI.RubberduckUI.GeneralSettings_HotkeyCtrl);
34+
builder.Append(RubberduckUI.GeneralSettings_HotkeyCtrl);
3435
builder.Append('+');
3536
}
3637
if (_keys.HasFlag(Keys.Shift))
3738
{
38-
builder.Append(Rubberduck.UI.RubberduckUI.GeneralSettings_HotkeyShift);
39+
builder.Append(RubberduckUI.GeneralSettings_HotkeyShift);
3940
builder.Append('+');
4041
}
41-
builder.Append(_keys & ~Modifiers);
42+
43+
builder.Append(HotkeyDisplayConverter.Convert(_keys & ~Modifiers));
4244
return builder.ToString();
4345
}
4446
}

RetailCoder.VBE/Common/RubberduckHooks.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using Rubberduck.UI.Command;
1414
using Rubberduck.UI.Command.Refactorings;
1515
using NLog;
16+
using Rubberduck.UI;
1617

1718
namespace Rubberduck.Common
1819
{

RetailCoder.VBE/Inspections/IParseTreeInspection.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Rubberduck.Parsing;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using Rubberduck.Parsing.Grammar;
45

56
namespace Rubberduck.Inspections
67
{
@@ -17,11 +18,13 @@ public ParseTreeResults()
1718
ObsoleteLetContexts = Enumerable.Empty<QualifiedContext>();
1819
ArgListsWithOneByRefParam = Enumerable.Empty<QualifiedContext>();
1920
EmptyStringLiterals = Enumerable.Empty<QualifiedContext>();
21+
MalformedAnnotations = Enumerable.Empty<QualifiedContext<VBAParser.AnnotationContext>>();
2022
}
2123

2224
public IEnumerable<QualifiedContext> ObsoleteCallContexts;
2325
public IEnumerable<QualifiedContext> ObsoleteLetContexts;
2426
public IEnumerable<QualifiedContext> ArgListsWithOneByRefParam;
2527
public IEnumerable<QualifiedContext> EmptyStringLiterals;
28+
public IEnumerable<QualifiedContext<VBAParser.AnnotationContext>> MalformedAnnotations;
2629
}
2730
}

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<root>
33
<!--
44
Microsoft ResX Schema
@@ -59,7 +59,7 @@
5959
: using a System.ComponentModel.TypeConverter
6060
: and then encoded with base64 encoding.
6161
-->
62-
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
62+
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
6363
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
6464
<xsd:element name="root" msdata:IsDataSet="true">
6565
<xsd:complexType>
@@ -555,4 +555,13 @@
555555
<data name="VariableTypeNotDeclaredInspectionResultFormat" xml:space="preserve">
556556
<value>{0} '{1}' is implicitly 'Variant'</value>
557557
</data>
558-
</root>
558+
<data name="MalformedAnnotationInspectionMeta" xml:space="preserve">
559+
<value>An annotation comment is malformed.</value>
560+
</data>
561+
<data name="MalformedAnnotationInspectionName" xml:space="preserve">
562+
<value>Malformed annotation.</value>
563+
</data>
564+
<data name="MalformedAnnotationInspectionResultFormat" xml:space="preserve">
565+
<value>The annotation '{0}' is malformed</value>
566+
</data>
567+
</root>

RetailCoder.VBE/Inspections/Inspector.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Rubberduck.UI;
1010
using Antlr4.Runtime.Tree;
1111
using Rubberduck.Parsing;
12+
using Rubberduck.Parsing.Grammar;
1213

1314
namespace Rubberduck.Inspections
1415
{
@@ -78,7 +79,7 @@ public async Task<IEnumerable<ICodeInspectionResult>> FindIssuesAsync(Rubberduck
7879
{
7980
allIssues.Add(inspectionResult);
8081
}
81-
})).ToList();
82+
}, token)).ToList();
8283

8384
await Task.WhenAll(inspections);
8485
state.OnStatusMessageUpdate(RubberduckUI.ResourceManager.GetString("ParserState_" + state.Status, UI.Settings.Settings.Culture)); // should be "Ready"
@@ -99,12 +100,14 @@ before moving them into the ParseTreeResults after qualifying them
99100
var obsoleteLetStatementListener = new ObsoleteLetStatementInspection.ObsoleteLetStatementListener();
100101
var emptyStringLiteralListener = new EmptyStringLiteralInspection.EmptyStringLiteralListener();
101102
var argListWithOneByRefParamListener = new ProcedureCanBeWrittenAsFunctionInspection.ArgListWithOneByRefParamListener();
103+
var malformedAnnotationListenter = new MalformedAnnotationInspection.MalformedAnnotationStatementListener();
102104

103105
var combinedListener = new CombinedParseTreeListener(new IParseTreeListener[]{
104106
obsoleteCallStatementListener,
105107
obsoleteLetStatementListener,
106108
emptyStringLiteralListener,
107109
argListWithOneByRefParamListener,
110+
malformedAnnotationListenter
108111
});
109112

110113
ParseTreeWalker.Default.Walk(combinedListener, componentTreePair.Value);
@@ -113,6 +116,7 @@ before moving them into the ParseTreeResults after qualifying them
113116
result.EmptyStringLiterals = result.EmptyStringLiterals.Concat(emptyStringLiteralListener.Contexts.Select(context => new QualifiedContext(componentTreePair.Key, context)));
114117
result.ObsoleteLetContexts = result.ObsoleteLetContexts.Concat(obsoleteLetStatementListener.Contexts.Select(context => new QualifiedContext(componentTreePair.Key, context)));
115118
result.ObsoleteCallContexts = result.ObsoleteCallContexts.Concat(obsoleteCallStatementListener.Contexts.Select(context => new QualifiedContext(componentTreePair.Key, context)));
119+
result.MalformedAnnotations = result.MalformedAnnotations.Concat(malformedAnnotationListenter.Contexts.Select(context => new QualifiedContext<VBAParser.AnnotationContext>(componentTreePair.Key, context)));
116120
}
117121
return result;
118122
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
using System.Collections.Generic;
2+
using Rubberduck.Parsing;
3+
using Rubberduck.Parsing.Annotations;
4+
using Rubberduck.Parsing.VBA;
5+
using Rubberduck.Parsing.Grammar;
6+
7+
namespace Rubberduck.Inspections
8+
{
9+
public sealed class MalformedAnnotationInspection : InspectionBase, IParseTreeInspection
10+
{
11+
public MalformedAnnotationInspection(RubberduckParserState state)
12+
: base(state, CodeInspectionSeverity.Error)
13+
{
14+
}
15+
16+
public override string Meta { get { return InspectionsUI.MalformedAnnotationInspectionMeta; } }
17+
public override string Description { get { return InspectionsUI.MalformedAnnotationInspectionResultFormat; } }
18+
public override CodeInspectionType InspectionType { get { return CodeInspectionType.CodeQualityIssues; } }
19+
public ParseTreeResults ParseTreeResults { get; set; }
20+
21+
public override IEnumerable<InspectionResultBase> GetInspectionResults()
22+
{
23+
if (ParseTreeResults == null)
24+
{
25+
return new InspectionResultBase[] { };
26+
}
27+
28+
var results = new List<MalformedAnnotationInspectionResult>();
29+
30+
foreach (var context in ParseTreeResults.MalformedAnnotations)
31+
{
32+
if (context.Context.annotationName().GetText() == AnnotationType.Ignore.ToString() ||
33+
context.Context.annotationName().GetText() == AnnotationType.Folder.ToString())
34+
{
35+
if (context.Context.annotationArgList() == null)
36+
{
37+
results.Add(new MalformedAnnotationInspectionResult(this,
38+
new QualifiedContext<VBAParser.AnnotationContext>(context.ModuleName,
39+
context.Context)));
40+
}
41+
}
42+
}
43+
44+
return results;
45+
}
46+
47+
public class MalformedAnnotationStatementListener : VBAParserBaseListener
48+
{
49+
private readonly IList<VBAParser.AnnotationContext> _contexts = new List<VBAParser.AnnotationContext>();
50+
public IEnumerable<VBAParser.AnnotationContext> Contexts { get { return _contexts; } }
51+
52+
public override void ExitAnnotation(VBAParser.AnnotationContext context)
53+
{
54+
if (context.annotationName() != null)
55+
{
56+
_contexts.Add(context);
57+
}
58+
}
59+
}
60+
}
61+
62+
public class MalformedAnnotationInspectionResult : InspectionResultBase
63+
{
64+
public MalformedAnnotationInspectionResult(IInspection inspection, QualifiedContext<VBAParser.AnnotationContext> qualifiedContext)
65+
: base(inspection, qualifiedContext.ModuleName, qualifiedContext.Context)
66+
{
67+
}
68+
69+
public override string Description
70+
{
71+
get { return string.Format(Inspection.Description, ((VBAParser.AnnotationContext)Context).annotationName()); }
72+
}
73+
}
74+
}

RetailCoder.VBE/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("2.0.4.*")]
35-
[assembly: AssemblyFileVersion("2.0.4.0")]
34+
[assembly: AssemblyVersion("2.0.5.*")]
35+
[assembly: AssemblyFileVersion("2.0.5.0")]

RetailCoder.VBE/Rubberduck.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@
376376
</Compile>
377377
<Compile Include="Inspections\IParseTreeInspection.cs" />
378378
<Compile Include="Inspections\MakeSingleLineParameterQuickFix.cs" />
379+
<Compile Include="Inspections\MalformedAnnotationInspection.cs" />
379380
<Compile Include="Inspections\ObjectVariableNotSetInspection.cs" />
380381
<Compile Include="Inspections\RemoveExplicitCallStatmentQuickFix.cs" />
381382
<Compile Include="Navigation\CodeExplorer\ICodeExplorerDeclarationViewModel.cs" />
@@ -579,6 +580,7 @@
579580
<Compile Include="Navigation\CodeExplorer\CodeExplorerMemberViewModel.cs" />
580581
<Compile Include="Navigation\CodeExplorer\CodeExplorerProjectViewModel.cs" />
581582
<Compile Include="Navigation\CodeExplorer\CodeExplorerViewModel.cs" />
583+
<Compile Include="UI\HotkeyDisplayConverter.cs" />
582584
<Compile Include="UI\Inspections\InspectionDescriptionConverter.cs" />
583585
<Compile Include="UI\Inspections\InspectionImageSourceConverter.cs" />
584586
<Compile Include="UI\Inspections\InspectionResultsControl.xaml.cs">
@@ -703,6 +705,7 @@
703705
<DesignTime>True</DesignTime>
704706
<DependentUpon>RubberduckUI.sv.resx</DependentUpon>
705707
</Compile>
708+
<Compile Include="UI\Settings\Converters\HotkeyDisplayConverter.cs" />
706709
<Compile Include="UI\Settings\Converters\AssertModeValueToTextConverter.cs" />
707710
<Compile Include="UI\Settings\Converters\DelimiterToTextConverter.cs" />
708711
<Compile Include="UI\Settings\Converters\EndOfLineCommentStyleToTextConverter.cs" />

RetailCoder.VBE/Settings/HotkeySetting.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,6 @@ public string Prompt
2626
get { return RubberduckUI.ResourceManager.GetString("HotkeyDescription_" + Name, UI.Settings.Settings.Culture); }
2727
}
2828

29-
public string ToMenuHotkeyString()
30-
{
31-
return string.Format("{0}{1}{2}+{3}",
32-
HasCtrlModifier ? RubberduckUI.GeneralSettings_HotkeyCtrl : string.Empty,
33-
HasShiftModifier ? (HasCtrlModifier ? "+" : string.Empty) + RubberduckUI.GeneralSettings_HotkeyShift : string.Empty,
34-
HasAltModifier ? (HasCtrlModifier | HasShiftModifier ? "+" : string.Empty) + RubberduckUI.GeneralSettings_HotkeyAlt : string.Empty,
35-
Key1);
36-
}
37-
3829
public override string ToString()
3930
{
4031
return string.Format("{0}{1}{2}{3}",

0 commit comments

Comments
 (0)