Skip to content

Commit 6bb6fd6

Browse files
committed
Merge branch 'next' of https://github.com/rubberduck-vba/Rubberduck into next
2 parents aaeaecb + a2580e1 commit 6bb6fd6

File tree

255 files changed

+5501
-2333
lines changed

Some content is hidden

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

255 files changed

+5501
-2333
lines changed

RetailCoder.VBE/API/ParserState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void Initialize(VBE vbe)
7373
Func<IVBAPreprocessor> preprocessorFactory = () => new VBAPreprocessor(double.Parse(vbe.Version, CultureInfo.InvariantCulture));
7474
_attributeParser = new AttributeParser(new ModuleExporter(), preprocessorFactory);
7575
_parser = new RubberduckParser(vbe, _state, _attributeParser, preprocessorFactory,
76-
new List<ICustomDeclarationLoader> { new DebugDeclarations(_state), new FormEventDeclarations(_state), new AliasDeclarations(_state) });
76+
new List<ICustomDeclarationLoader> { new DebugDeclarations(_state), new SpecialFormDeclarations(_state), new FormEventDeclarations(_state), new AliasDeclarations(_state) });
7777
}
7878

7979
/// <summary>

RetailCoder.VBE/App.cs

Lines changed: 29 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ private void RefreshSelection()
8484
if (!pane.IsWrappingNullReference)
8585
{
8686
selectedDeclaration = _parser.State.FindSelectedDeclaration(pane);
87-
_stateBar.SetContextSelectionCaption(GetSelectionText(selectedDeclaration));
87+
var caption = _stateBar.GetContextSelectionCaption(_vbe.ActiveCodePane, selectedDeclaration);
88+
_stateBar.SetContextSelectionCaption(caption);
8889
}
8990

9091
var currentStatus = _parser.State.Status;
@@ -99,55 +100,6 @@ private void RefreshSelection()
99100
}
100101
}
101102

102-
private string GetSelectionText(Declaration declaration)
103-
{
104-
if (declaration == null && _vbe.ActiveCodePane != null)
105-
{
106-
var selection = _vbe.ActiveCodePane.GetQualifiedSelection();
107-
if (selection.HasValue)
108-
{
109-
return selection.Value.ToString();
110-
}
111-
}
112-
else if (declaration == null && _vbe.ActiveCodePane == null)
113-
{
114-
return string.Empty;
115-
}
116-
else if (declaration != null && !declaration.IsBuiltIn && declaration.DeclarationType != DeclarationType.ClassModule && declaration.DeclarationType != DeclarationType.ProceduralModule)
117-
{
118-
var typeName = declaration.HasTypeHint
119-
? Declaration.TypeHintToTypeName[declaration.TypeHint]
120-
: declaration.AsTypeName;
121-
122-
return string.Format("{0}|{1}: {2} ({3}{4})",
123-
declaration.QualifiedSelection.Selection,
124-
declaration.QualifiedName.QualifiedModuleName,
125-
declaration.IdentifierName,
126-
RubberduckUI.ResourceManager.GetString("DeclarationType_" + declaration.DeclarationType, UI.Settings.Settings.Culture),
127-
string.IsNullOrEmpty(declaration.AsTypeName) ? string.Empty : ": " + typeName);
128-
}
129-
else if (declaration != null)
130-
{
131-
// todo: confirm this is what we want, and then refator
132-
var selection = _vbe.ActiveCodePane.GetQualifiedSelection();
133-
if (selection.HasValue)
134-
{
135-
var typeName = declaration.HasTypeHint
136-
? Declaration.TypeHintToTypeName[declaration.TypeHint]
137-
: declaration.AsTypeName;
138-
139-
return string.Format("{0}|{1}: {2} ({3}{4})",
140-
selection.Value.Selection,
141-
declaration.QualifiedName.QualifiedModuleName,
142-
declaration.IdentifierName,
143-
RubberduckUI.ResourceManager.GetString("DeclarationType_" + declaration.DeclarationType, UI.Settings.Settings.Culture),
144-
string.IsNullOrEmpty(declaration.AsTypeName) ? string.Empty : ": " + typeName);
145-
}
146-
}
147-
148-
return string.Empty;
149-
}
150-
151103
private bool ShouldEvaluateCanExecute(Declaration selectedDeclaration, ParserState currentStatus)
152104
{
153105
return _lastStatus != currentStatus ||
@@ -194,6 +146,7 @@ public void Startup()
194146
{
195147
EnsureLogFolderPathExists();
196148
LoadConfig();
149+
CheckForLegacyIndenterSettings();
197150
_appMenus.Initialize();
198151
_stateBar.Initialize();
199152
_hooks.HookHotkeys(); // need to hook hotkeys before we localize menus, to correctly display ShortcutTexts
@@ -244,6 +197,32 @@ private void LoadConfig()
244197
}
245198
}
246199

200+
private void CheckForLegacyIndenterSettings()
201+
{
202+
try
203+
{
204+
Logger.Trace("Checking for legacy Smart Indenter settings.");
205+
if (_config.UserSettings.GeneralSettings.SmartIndenterPrompted ||
206+
!_config.UserSettings.IndenterSettings.LegacySettingsExist())
207+
{
208+
return;
209+
}
210+
var response =
211+
_messageBox.Show(RubberduckUI.SmartIndenter_LegacySettingPrompt, "Rubberduck", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
212+
if (response == DialogResult.Yes)
213+
{
214+
Logger.Trace("Attempting to load legacy Smart Indenter settings.");
215+
_config.UserSettings.IndenterSettings.LoadLegacyFromRegistry();
216+
}
217+
_config.UserSettings.GeneralSettings.SmartIndenterPrompted = true;
218+
_configService.SaveConfiguration(_config);
219+
}
220+
catch
221+
{
222+
//Meh.
223+
}
224+
}
225+
247226
private bool _disposed;
248227
public void Dispose()
249228
{
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace Rubberduck.Common
9+
{
10+
public static class StringExtensions
11+
{
12+
public static string Captialize(this string input)
13+
{
14+
var tokens = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
15+
if (tokens.Length == 0)
16+
{
17+
return input;
18+
}
19+
tokens[0] = CultureInfo.CurrentUICulture.TextInfo.ToTitleCase(tokens[0]);
20+
return string.Join(" ", tokens);
21+
}
22+
}
23+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
3+
namespace Rubberduck.Common
4+
{
5+
/// <summary>
6+
/// Mark a feature as undocumented.
7+
/// </summary>
8+
/// <remarks>The RubberduckWeb project may this attribute to filter viewable content.</remarks>
9+
[AttributeUsage(AttributeTargets.Class)]
10+
public class UndocumentedAttribute : Attribute
11+
{
12+
}
13+
}

RetailCoder.VBE/Inspections/IInspection.cs renamed to RetailCoder.VBE/Inspections/Abstract/IInspection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Collections.Generic;
33
using Rubberduck.Root;
44

5-
namespace Rubberduck.Inspections
5+
namespace Rubberduck.Inspections.Abstract
66
{
77
/// <summary>
88
/// An interface that abstracts a runnable code inspection.

RetailCoder.VBE/Inspections/IInspectionModel.cs renamed to RetailCoder.VBE/Inspections/Abstract/IInspectionModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace Rubberduck.Inspections
1+
using Rubberduck.Inspections.Resources;
2+
3+
namespace Rubberduck.Inspections.Abstract
24
{
35
/// <summary>
46
/// An interface that abstracts the data structure for a code inspection
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Rubberduck.VBEditor;
4+
5+
namespace Rubberduck.Inspections.Abstract
6+
{
7+
public interface IInspectionResult : IComparable<IInspectionResult>, IComparable
8+
{
9+
IEnumerable<QuickFixBase> QuickFixes { get; }
10+
string Description { get; }
11+
QualifiedSelection QualifiedSelection { get; }
12+
IInspection Inspection { get; }
13+
object[] ToArray();
14+
}
15+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Threading;
4+
using System.Threading.Tasks;
5+
using Rubberduck.Parsing.VBA;
6+
7+
namespace Rubberduck.Inspections.Abstract
8+
{
9+
public interface IInspector : IDisposable
10+
{
11+
Task<IEnumerable<IInspectionResult>> FindIssuesAsync(RubberduckParserState state, CancellationToken token);
12+
}
13+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Collections.Generic;
2+
using Antlr4.Runtime;
3+
using Rubberduck.Parsing;
4+
5+
namespace Rubberduck.Inspections.Abstract
6+
{
7+
public interface IParseTreeInspection : IInspection
8+
{
9+
/// <summary>
10+
/// Parse tree inspections have their results property-injected.
11+
/// </summary>
12+
void SetResults(IEnumerable<QualifiedContext> results);
13+
}
14+
15+
/// <summary>
16+
///
17+
/// </summary>
18+
/// <typeparam name="TContext"></typeparam>
19+
public interface IParseTreeInspection<TContext> : IParseTreeInspection where TContext : ParserRuleContext
20+
{
21+
IEnumerable<QualifiedContext<TContext>> ParseTreeResults { get; }
22+
}
23+
}

RetailCoder.VBE/Inspections/InspectionBase.cs renamed to RetailCoder.VBE/Inspections/Abstract/InspectionBase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using Rubberduck.Inspections.Resources;
45
using Rubberduck.Parsing.Annotations;
56
using Rubberduck.Parsing.Symbols;
67
using Rubberduck.Parsing.VBA;
78
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
89

9-
namespace Rubberduck.Inspections
10+
namespace Rubberduck.Inspections.Abstract
1011
{
1112
public abstract class InspectionBase : IInspection
1213
{

0 commit comments

Comments
 (0)