Skip to content

Commit 44a1115

Browse files
committed
Merge pull request #709 from Hosch250/next
Implement IRubberduckCodePane and more Rename tests.
2 parents 3f5b3bc + 32cf4d4 commit 44a1115

File tree

58 files changed

+1497
-1162
lines changed

Some content is hidden

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

58 files changed

+1497
-1162
lines changed

RetailCoder.VBE/App.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Drawing;
43
using System.Globalization;
54
using System.Windows.Forms;
@@ -12,36 +11,38 @@
1211
using Rubberduck.UI.CodeInspections;
1312
using Rubberduck.UI.ParserErrors;
1413
using Rubberduck.VBEditor;
14+
using Rubberduck.VBEditor.VBEInterfaces.RubberduckCodePane;
1515

1616
namespace Rubberduck
1717
{
1818
public class App : IDisposable
1919
{
2020
private readonly VBE _vbe;
2121
private readonly AddIn _addIn;
22-
private IList<IInspection> _inspections;
2322
private Inspector _inspector;
2423
private ParserErrorsPresenter _parserErrorsPresenter;
2524
private readonly IGeneralConfigService _configService = new ConfigurationLoader();
2625
private readonly ActiveCodePaneEditor _editor;
26+
private readonly IRubberduckCodePaneFactory _factory;
2727
private IRubberduckParser _parser;
2828

2929
private Configuration _config;
3030
private RubberduckMenu _menu;
3131
private FormContextMenu _formContextMenu;
3232
private CodeInspectionsToolbar _codeInspectionsToolbar;
33-
private bool displayToolbar = false;
34-
private Point toolbarCoords = new Point(-1, -1);
33+
private bool _displayToolbar = false;
34+
private Point _toolbarCoords = new Point(-1, -1);
3535

3636
public App(VBE vbe, AddIn addIn)
3737
{
3838
_vbe = vbe;
3939
_addIn = addIn;
40+
_factory = new RubberduckCodePaneFactory();
4041

4142
_parserErrorsPresenter = new ParserErrorsPresenter(vbe, addIn);
4243
_configService.SettingsChanged += _configService_SettingsChanged;
4344

44-
_editor = new ActiveCodePaneEditor(vbe);
45+
_editor = new ActiveCodePaneEditor(vbe, _factory);
4546

4647
LoadConfig();
4748

@@ -78,28 +79,28 @@ private void LoadConfig()
7879

7980
private void Setup()
8081
{
81-
_parser = new RubberduckParser();
82+
_parser = new RubberduckParser(_factory);
8283
_parser.ParseStarted += _parser_ParseStarted;
8384
_parser.ParserError += _parser_ParserError;
8485

8586
_inspector = new Inspector(_parser, _configService);
8687

8788
_parserErrorsPresenter = new ParserErrorsPresenter(_vbe, _addIn);
8889

89-
_menu = new RubberduckMenu(_vbe, _addIn, _configService, _parser, _editor, _inspector);
90+
_menu = new RubberduckMenu(_vbe, _addIn, _configService, _parser, _editor, _inspector, _factory);
9091
_menu.Initialize();
9192

92-
_formContextMenu = new FormContextMenu(_vbe, _parser);
93+
_formContextMenu = new FormContextMenu(_vbe, _parser, _factory);
9394
_formContextMenu.Initialize();
9495

9596
_codeInspectionsToolbar = new CodeInspectionsToolbar(_vbe, _inspector);
9697
_codeInspectionsToolbar.Initialize();
9798

98-
if (toolbarCoords.X != -1 && toolbarCoords.Y != -1)
99+
if (_toolbarCoords.X != -1 && _toolbarCoords.Y != -1)
99100
{
100-
_codeInspectionsToolbar.ToolbarCoords = toolbarCoords;
101+
_codeInspectionsToolbar.ToolbarCoords = _toolbarCoords;
101102
}
102-
_codeInspectionsToolbar.ToolbarVisible = displayToolbar;
103+
_codeInspectionsToolbar.ToolbarVisible = _displayToolbar;
103104
}
104105

105106
private void _parser_ParseStarted(object sender, ParseStartedEventArgs e)
@@ -139,8 +140,8 @@ private void CleanUp()
139140

140141
if (_codeInspectionsToolbar != null)
141142
{
142-
displayToolbar = _codeInspectionsToolbar.ToolbarVisible;
143-
toolbarCoords = _codeInspectionsToolbar.ToolbarCoords;
143+
_displayToolbar = _codeInspectionsToolbar.ToolbarVisible;
144+
_toolbarCoords = _codeInspectionsToolbar.ToolbarCoords;
144145
_codeInspectionsToolbar.Dispose();
145146
}
146147

RetailCoder.VBE/Extension.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Extensibility;
66
using Microsoft.Vbe.Interop;
77
using Rubberduck.UI;
8+
using Rubberduck.VBEditor.VBEInterfaces.RubberduckCodePane;
89

910
namespace Rubberduck
1011
{

RetailCoder.VBE/Inspections/CodeInspectionResultBase.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@
55
using Rubberduck.Parsing.Nodes;
66
using Rubberduck.Parsing.Symbols;
77
using Rubberduck.VBEditor;
8+
using Rubberduck.VBEditor.VBEInterfaces.RubberduckCodePane;
89

910
namespace Rubberduck.Inspections
1011
{
1112
public abstract class CodeInspectionResultBase : ICodeInspectionResult
1213
{
13-
protected CodeInspectionResultBase(string inspection, CodeInspectionSeverity type, Declaration target)
14+
private readonly IRubberduckCodePaneFactory _factory;
15+
16+
protected CodeInspectionResultBase(string inspection, CodeInspectionSeverity type, Declaration target, IRubberduckCodePaneFactory factory)
1417
: this(inspection, type, target.QualifiedName.QualifiedModuleName, null)
1518
{
1619
_target = target;
20+
_factory = factory;
1721
}
1822

1923
/// <summary>
@@ -72,7 +76,7 @@ public virtual QualifiedSelection QualifiedSelection
7276
}
7377
return _context == null
7478
? _comment.QualifiedSelection
75-
: new QualifiedSelection(_qualifiedName, _context.GetSelection());
79+
: new QualifiedSelection(_qualifiedName, _context.GetSelection(), _factory);
7680
}
7781
}
7882

RetailCoder.VBE/Inspections/DefaultProjectNameInspection.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
using Rubberduck.Parsing;
44
using Rubberduck.Parsing.Symbols;
55
using Rubberduck.UI;
6+
using Rubberduck.VBEditor.VBEInterfaces.RubberduckCodePane;
67

78
namespace Rubberduck.Inspections
89
{
910
class GenericProjectNameInspection : IInspection
1011
{
11-
public GenericProjectNameInspection()
12+
private readonly IRubberduckCodePaneFactory _factory;
13+
14+
public GenericProjectNameInspection(IRubberduckCodePaneFactory factory)
1215
{
16+
_factory = factory;
1317
Severity = CodeInspectionSeverity.Suggestion;
1418
}
1519

@@ -24,7 +28,7 @@ public IEnumerable<CodeInspectionResultBase> GetInspectionResults(VBProjectParse
2428
.Where(declaration => !declaration.IsBuiltIn
2529
&& declaration.DeclarationType == DeclarationType.Project
2630
&& declaration.IdentifierName.StartsWith("VBAProject"))
27-
.Select(issue => new GenericProjectNameInspectionResult(string.Format(Description, issue.IdentifierName), Severity, issue, parseResult))
31+
.Select(issue => new GenericProjectNameInspectionResult(string.Format(Description, issue.IdentifierName), Severity, issue, parseResult, _factory))
2832
.ToList();
2933

3034
return issues;

RetailCoder.VBE/Inspections/DefaultProjectNameInspectionResult.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@
55
using Rubberduck.Refactorings.Rename;
66
using Rubberduck.UI;
77
using Rubberduck.UI.Refactorings;
8+
using Rubberduck.VBEditor.VBEInterfaces.RubberduckCodePane;
89

910
namespace Rubberduck.Inspections
1011
{
1112
public class GenericProjectNameInspectionResult : CodeInspectionResultBase
1213
{
1314
private readonly VBProjectParseResult _parseResult;
15+
private readonly IRubberduckCodePaneFactory _factory;
1416

15-
public GenericProjectNameInspectionResult(string inspection, CodeInspectionSeverity type, Declaration target, VBProjectParseResult parseResult)
16-
: base(inspection, type, target)
17+
public GenericProjectNameInspectionResult(string inspection, CodeInspectionSeverity type, Declaration target, VBProjectParseResult parseResult, IRubberduckCodePaneFactory factory)
18+
: base(inspection, type, target, factory)
1719
{
1820
_parseResult = parseResult;
21+
_factory = factory;
1922
}
2023

2124
public override IDictionary<string, Action> GetQuickFixes()
@@ -33,8 +36,8 @@ private void RenameProject()
3336

3437
using (var view = new RenameDialog())
3538
{
36-
var factory = new RenamePresenterFactory(vbe, view, _parseResult, new RubberduckMessageBox());
37-
var refactoring = new RenameRefactoring(factory);
39+
var factory = new RenamePresenterFactory(vbe, view, _parseResult, new RubberduckMessageBox(), _factory);
40+
var refactoring = new RenameRefactoring(factory, new RubberduckMessageBox());
3841
refactoring.Refactor(Target);
3942
}
4043
}

RetailCoder.VBE/Inspections/MultipleDeclarationsInspection.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44
using Rubberduck.Parsing;
55
using Rubberduck.Parsing.Symbols;
66
using Rubberduck.UI;
7+
using Rubberduck.VBEditor.VBEInterfaces.RubberduckCodePane;
78

89
namespace Rubberduck.Inspections
910
{
1011
public class MultipleDeclarationsInspection : IInspection
1112
{
12-
public MultipleDeclarationsInspection()
13+
private readonly IRubberduckCodePaneFactory _factory;
14+
15+
public MultipleDeclarationsInspection(IRubberduckCodePaneFactory factory)
1316
{
17+
_factory = factory;
1418
Severity = CodeInspectionSeverity.Warning;
1519
}
1620

@@ -27,7 +31,7 @@ public IEnumerable<CodeInspectionResultBase> GetInspectionResults(VBProjectParse
2731
|| item.DeclarationType == DeclarationType.Constant)
2832
.GroupBy(variable => variable.Context.Parent as ParserRuleContext)
2933
.Where(grouping => grouping.Count() > 1)
30-
.Select(grouping => new MultipleDeclarationsInspectionResult(Description, Severity, new QualifiedContext<ParserRuleContext>(grouping.First().QualifiedName.QualifiedModuleName, grouping.Key)));
34+
.Select(grouping => new MultipleDeclarationsInspectionResult(Description, Severity, new QualifiedContext<ParserRuleContext>(grouping.First().QualifiedName.QualifiedModuleName, grouping.Key), _factory));
3135

3236
return issues;
3337
}

RetailCoder.VBE/Inspections/MultipleDeclarationsInspectionResult.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@
66
using Rubberduck.Parsing.Grammar;
77
using Rubberduck.UI;
88
using Rubberduck.VBEditor;
9+
using Rubberduck.VBEditor.VBEInterfaces.RubberduckCodePane;
910

1011
namespace Rubberduck.Inspections
1112
{
1213
public class MultipleDeclarationsInspectionResult : CodeInspectionResultBase
1314
{
15+
private readonly IRubberduckCodePaneFactory _factory;
16+
1417
public MultipleDeclarationsInspectionResult(string inspection, CodeInspectionSeverity type,
15-
QualifiedContext<ParserRuleContext> qualifiedContext)
18+
QualifiedContext<ParserRuleContext> qualifiedContext, IRubberduckCodePaneFactory factory)
1619
: base(inspection, type, qualifiedContext.ModuleName, qualifiedContext.Context)
1720
{
21+
_factory = factory;
1822
}
1923

2024
public override IDictionary<string, Action> GetQuickFixes()
@@ -39,7 +43,7 @@ public override QualifiedSelection QualifiedSelection
3943
context = Context.Parent as ParserRuleContext;
4044
}
4145
var selection = context.GetSelection();
42-
return new QualifiedSelection(QualifiedName, selection);
46+
return new QualifiedSelection(QualifiedName, selection, _factory);
4347
}
4448
}
4549

RetailCoder.VBE/Inspections/OptionBaseInspection.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44
using Rubberduck.Parsing.Grammar;
55
using Rubberduck.Parsing.Symbols;
66
using Rubberduck.UI;
7+
using Rubberduck.VBEditor.VBEInterfaces.RubberduckCodePane;
78

89
namespace Rubberduck.Inspections
910
{
1011
public class OptionBaseInspection : IInspection
1112
{
12-
public OptionBaseInspection()
13+
private readonly IRubberduckCodePaneFactory _factory;
14+
15+
public OptionBaseInspection(IRubberduckCodePaneFactory factory)
1316
{
17+
_factory = factory;
1418
Severity = CodeInspectionSeverity.Warning;
1519
}
1620

@@ -33,7 +37,7 @@ public IEnumerable<CodeInspectionResultBase> GetInspectionResults(VBProjectParse
3337
}
3438

3539
var issues = options.Where(option => ((VBAParser.OptionBaseStmtContext)option.Context).INTEGERLITERAL().GetText() == "1")
36-
.Select(issue => new OptionBaseInspectionResult(Description, Severity, issue.QualifiedName.QualifiedModuleName));
40+
.Select(issue => new OptionBaseInspectionResult(Description, Severity, issue.QualifiedName.QualifiedModuleName, _factory));
3741

3842
return issues;
3943
}

RetailCoder.VBE/Inspections/OptionBaseInspectionResult.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
using System.Collections.Generic;
33
using Rubberduck.Parsing.Nodes;
44
using Rubberduck.VBEditor;
5+
using Rubberduck.VBEditor.VBEInterfaces.RubberduckCodePane;
56

67
namespace Rubberduck.Inspections
78
{
89
public class OptionBaseInspectionResult : CodeInspectionResultBase
910
{
10-
public OptionBaseInspectionResult(string inspection, CodeInspectionSeverity type, QualifiedModuleName qualifiedName)
11-
: base(inspection, type, new CommentNode("", new QualifiedSelection(qualifiedName, Selection.Home)))
11+
public OptionBaseInspectionResult(string inspection, CodeInspectionSeverity type, QualifiedModuleName qualifiedName, IRubberduckCodePaneFactory factory)
12+
: base(inspection, type, new CommentNode("", new QualifiedSelection(qualifiedName, Selection.Home, factory)))
1213
{
1314
}
1415

RetailCoder.VBE/Inspections/OptionExplicitInspection.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44
using Rubberduck.Parsing.Grammar;
55
using Rubberduck.Parsing.Symbols;
66
using Rubberduck.UI;
7+
using Rubberduck.VBEditor.VBEInterfaces.RubberduckCodePane;
78

89
namespace Rubberduck.Inspections
910
{
1011
public class OptionExplicitInspection : IInspection
1112
{
12-
public OptionExplicitInspection()
13+
private readonly IRubberduckCodePaneFactory _factory;
14+
15+
public OptionExplicitInspection(IRubberduckCodePaneFactory factory)
1316
{
17+
_factory = factory;
1418
Severity = CodeInspectionSeverity.Warning;
1519
}
1620

@@ -37,7 +41,7 @@ public IEnumerable<CodeInspectionResultBase> GetInspectionResults(VBProjectParse
3741
.Where(declaration => !declaration.IsBuiltIn && ModuleTypes.Contains(declaration.DeclarationType));
3842

3943
var issues = modules.Where(module => !options.Select(option => option.Scope).Contains(module.Scope))
40-
.Select(issue => new OptionExplicitInspectionResult(Description, Severity, issue.QualifiedName.QualifiedModuleName));
44+
.Select(issue => new OptionExplicitInspectionResult(Description, Severity, issue.QualifiedName.QualifiedModuleName, _factory));
4145

4246
return issues;
4347
}

0 commit comments

Comments
 (0)