Skip to content

Commit d0ebc1f

Browse files
committed
#1942 - AssignedByValParameter new QuickFix
Merged rubberduck-vba/next. Resolved RubberduckUI.resx conflict
2 parents 6343529 + 314a2d0 commit d0ebc1f

File tree

93 files changed

+2144
-968
lines changed

Some content is hidden

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

93 files changed

+2144
-968
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ LibGit2Sharp is the library that has allowed us to integrate Git right into the
8181
8282
Which basically means it's a reimplementation of Git in C. It also [happens to be the technology Microsoft uses for their own Git integration with Visual Studio](http://www.hanselman.com/blog/GitSupportForVisualStudioGitTFSAndVSPutIntoContext.aspx).
8383

84+
###[AvalonEdit](http://avalonedit.net)
85+
86+
Source code looks a lot better with syntax highlighting, and AvalonEdit excels at it.
87+
88+
> AvalonEdit is a WPF-based text editor component. It was written by [Daniel Grunwald](https://github.com/dgrunwald) for the [SharpDevelop](http://www.icsharpcode.net/OpenSource/SD/) IDE. Starting with version 5.0, AvalonEdit is released under the [MIT license](http://opensource.org/licenses/MIT).
89+
90+
We're currently only using a tiny bit of this code editor's functionality (more to come!).
91+
8492
###[WPF Localization Using RESX Files](http://www.codeproject.com/Articles/35159/WPF-Localization-Using-RESX-Files)
8593

8694
This library makes localizing WPF applications at runtime using resx files a breeze. Thank you [Grant Frisken](http://www.codeproject.com/script/Membership/View.aspx?mid=1079060)!

RetailCoder.VBE/App.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
using System.Globalization;
1414
using System.Linq;
1515
using System.Windows.Forms;
16+
using Rubberduck.UI.Command;
1617
using Rubberduck.UI.Command.MenuItems.CommandBars;
1718
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
19+
using Rubberduck.VersionCheck;
1820

1921
namespace Rubberduck
2022
{
@@ -28,6 +30,8 @@ public sealed class App : IDisposable
2830
private readonly IAppMenu _appMenus;
2931
private readonly RubberduckCommandBar _stateBar;
3032
private readonly IRubberduckHooks _hooks;
33+
private readonly IVersionCheck _version;
34+
private readonly CommandBase _checkVersionCommand;
3135

3236
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
3337

@@ -39,7 +43,9 @@ public App(IVBE vbe,
3943
IGeneralConfigService configService,
4044
IAppMenu appMenus,
4145
RubberduckCommandBar stateBar,
42-
IRubberduckHooks hooks)
46+
IRubberduckHooks hooks,
47+
IVersionCheck version,
48+
CommandBase checkVersionCommand)
4349
{
4450
_vbe = vbe;
4551
_messageBox = messageBox;
@@ -49,6 +55,8 @@ public App(IVBE vbe,
4955
_appMenus = appMenus;
5056
_stateBar = stateBar;
5157
_hooks = hooks;
58+
_version = version;
59+
_checkVersionCommand = checkVersionCommand;
5260

5361
_hooks.MessageReceived += _hooks_MessageReceived;
5462
_configService.SettingsChanged += _configService_SettingsChanged;
@@ -158,6 +166,11 @@ public void Startup()
158166
_stateBar.SetStatusLabelCaption(ParserState.Pending);
159167
_stateBar.EvaluateCanExecute(_parser.State);
160168
UpdateLoggingLevel();
169+
170+
if (_config.UserSettings.GeneralSettings.CheckVersion)
171+
{
172+
_checkVersionCommand.Execute(null);
173+
}
161174
}
162175

163176
public void Shutdown()
@@ -229,8 +242,8 @@ private void CheckForLegacyIndenterSettings()
229242

230243
private void LogRubberduckSart()
231244
{
232-
var version = GetType().Assembly.GetName().Version.ToString();
233-
GlobalDiagnosticsContext.Set("RubberduckVersion", version);
245+
var version = _version.CurrentVersion;
246+
GlobalDiagnosticsContext.Set("RubberduckVersion", version.ToString());
234247
var headers = new List<string>
235248
{
236249
string.Format("Rubberduck version {0} loading:", version),

RetailCoder.VBE/Extension.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ private void InitializeAddIn()
172172
{
173173
splash = new Splash
174174
{
175+
// note: IVersionCheck.CurrentVersion could return this string.
175176
Version = string.Format("version {0}", Assembly.GetExecutingAssembly().GetName().Version)
176177
};
177178
splash.Show();

RetailCoder.VBE/Inspections/Abstract/IInspectionResult.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ public interface IInspectionResult : IComparable<IInspectionResult>, IComparable
1111
QualifiedSelection QualifiedSelection { get; }
1212
IInspection Inspection { get; }
1313
object[] ToArray();
14+
string ToClipboardString();
1415
}
1516
}

RetailCoder.VBE/Inspections/Abstract/InspectionResultBase.cs

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Generic;
2+
using System.IO;
23
using System.Linq;
34
using Antlr4.Runtime;
45
using Rubberduck.Inspections.Resources;
@@ -87,18 +88,33 @@ public virtual int CompareTo(IInspectionResult other)
8788
return Inspection.CompareTo(other.Inspection);
8889
}
8990

90-
//public override string ToString()
91-
//{
92-
// var module = QualifiedSelection.QualifiedName;
93-
// return string.Format(
94-
// InspectionsUI.QualifiedSelectionInspection,
95-
// Inspection.Severity,
96-
// Description,
97-
// "(" + module.ProjectDisplayName + ")",
98-
// module.ProjectName,
99-
// module.ComponentName,
100-
// QualifiedSelection.Selection.StartLine);
101-
//}
91+
/// <summary>
92+
/// WARNING: This property can have side effects. It can change the ActiveVBProject if the result has a null Declaration,
93+
/// which causes a flicker in the VBE. This should only be called if it is *absolutely* necessary.
94+
/// </summary>
95+
public string ToClipboardString()
96+
{
97+
var module = QualifiedSelection.QualifiedName;
98+
var documentName = _target != null ? _target.ProjectDisplayName : string.Empty;
99+
if (string.IsNullOrEmpty(documentName))
100+
{
101+
var component = module.Component;
102+
documentName = component != null ? component.ParentProject.ProjectDisplayName : string.Empty;
103+
}
104+
if (string.IsNullOrEmpty(documentName))
105+
{
106+
documentName = Path.GetFileName(module.ProjectPath);
107+
}
108+
109+
return string.Format(
110+
InspectionsUI.QualifiedSelectionInspection,
111+
Inspection.Severity,
112+
Description,
113+
"(" + documentName + ")",
114+
module.ProjectName,
115+
module.ComponentName,
116+
QualifiedSelection.Selection.StartLine);
117+
}
102118

103119
public virtual NavigateCodeEventArgs GetNavigationArgs()
104120
{

RetailCoder.VBE/Inspections/ObjectVariableNotSetInspection.cs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Rubberduck.Inspections.Abstract;
44
using Rubberduck.Inspections.Resources;
55
using Rubberduck.Inspections.Results;
6+
using Rubberduck.Parsing;
67
using Rubberduck.Parsing.Grammar;
78
using Rubberduck.Parsing.Symbols;
89
using Rubberduck.Parsing.VBA;
@@ -20,29 +21,13 @@ public ObjectVariableNotSetInspection(RubberduckParserState state)
2021
public override string Description { get { return InspectionsUI.ObjectVariableNotSetInspectionName; } }
2122
public override CodeInspectionType InspectionType { get { return CodeInspectionType.CodeQualityIssues; } }
2223

23-
private static readonly IReadOnlyList<string> ValueTypes = new[]
24-
{
25-
Tokens.Boolean,
26-
Tokens.Byte,
27-
Tokens.Currency,
28-
Tokens.Date,
29-
Tokens.Decimal,
30-
Tokens.Double,
31-
Tokens.Integer,
32-
Tokens.Long,
33-
Tokens.LongLong,
34-
Tokens.Single,
35-
Tokens.String,
36-
Tokens.Variant
37-
};
38-
3924
public override IEnumerable<InspectionResultBase> GetInspectionResults()
4025
{
4126
var interestingDeclarations =
4227
State.AllUserDeclarations.Where(item =>
4328
!item.IsSelfAssigned &&
4429
!item.IsArray &&
45-
!ValueTypes.Contains(item.AsTypeName) &&
30+
!SymbolList.ValueTypes.Contains(item.AsTypeName) &&
4631
(item.AsTypeDeclaration == null || (!ClassModuleDeclaration.HasDefaultMember(item.AsTypeDeclaration) &&
4732
item.AsTypeDeclaration.DeclarationType != DeclarationType.Enumeration &&
4833
item.AsTypeDeclaration.DeclarationType != DeclarationType.UserDefinedType)) &&
@@ -54,7 +39,7 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
5439
(item.DeclarationType == DeclarationType.Function || item.DeclarationType == DeclarationType.PropertyGet)
5540
&& !item.IsArray
5641
&& item.IsTypeSpecified
57-
&& !ValueTypes.Contains(item.AsTypeName)
42+
&& !SymbolList.ValueTypes.Contains(item.AsTypeName)
5843
&& (item.AsTypeDeclaration == null // null if unresolved (e.g. in unit tests)
5944
|| (item.AsTypeDeclaration.DeclarationType != DeclarationType.Enumeration && item.AsTypeDeclaration.DeclarationType != DeclarationType.UserDefinedType
6045
&& item.AsTypeDeclaration != null

RetailCoder.VBE/Inspections/ProcedureNotUsedInspection.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
6060
handlers.AddRange(forms.SelectMany(form => State.FindFormEventHandlers(form)));
6161
}
6262

63-
//handlers.AddRange(builtInHandlers);
64-
6563
var interfaceMembers = State.DeclarationFinder.FindAllInterfaceMembers().ToList();
6664
var implementingMembers = State.DeclarationFinder.FindAllInterfaceImplementingMembers().ToList();
6765

@@ -78,7 +76,10 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
7876
private static readonly DeclarationType[] ProcedureTypes =
7977
{
8078
DeclarationType.Procedure,
81-
DeclarationType.Function
79+
DeclarationType.Function,
80+
DeclarationType.LibraryProcedure,
81+
DeclarationType.LibraryFunction,
82+
DeclarationType.Event
8283
};
8384

8485
private bool IsIgnoredDeclaration(Declaration declaration, IEnumerable<Declaration> interfaceMembers, IEnumerable<Declaration> interfaceImplementingMembers , IEnumerable<Declaration> handlers, IEnumerable<Declaration> classes, IEnumerable<Declaration> modules)

RetailCoder.VBE/Inspections/QuickFixes/RemoveTypeHintsQuickFix.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Antlr4.Runtime;
33
using Rubberduck.Inspections.Abstract;
44
using Rubberduck.Inspections.Resources;
5+
using Rubberduck.Parsing;
56
using Rubberduck.Parsing.Grammar;
67
using Rubberduck.Parsing.Symbols;
78
using Rubberduck.VBEditor;
@@ -47,7 +48,7 @@ private void FixTypeHintUsage(string hint, ICodeModule module, Selection selecti
4748
{
4849
var line = module.GetLines(selection.StartLine, 1);
4950

50-
var asTypeClause = ' ' + Tokens.As + ' ' + Declaration.TypeHintToTypeName[hint];
51+
var asTypeClause = ' ' + Tokens.As + ' ' + SymbolList.TypeHintToTypeName[hint];
5152

5253
string fix;
5354

RetailCoder.VBE/Inspections/Results/ImplicitActiveWorkbookReferenceInspectionResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public override IEnumerable<QuickFixBase> QuickFixes
3030

3131
public override string Description
3232
{
33-
get { return string.Format(InspectionsUI.ImplicitActiveSheetReferenceInspectionResultFormat, Context.GetText() /*_reference.Declaration.IdentifierName*/); }
33+
get { return string.Format(InspectionsUI.ImplicitActiveWorkbookReferenceInspectionResultFormat, Context.GetText() /*_reference.Declaration.IdentifierName*/); }
3434
}
3535
}
3636
}

RetailCoder.VBE/Inspections/SelfAssignedDeclarationInspection.cs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using Rubberduck.Inspections.Abstract;
44
using Rubberduck.Inspections.QuickFixes;
55
using Rubberduck.Inspections.Resources;
6-
using Rubberduck.Parsing.Grammar;
6+
using Rubberduck.Parsing;
77
using Rubberduck.Parsing.VBA;
88
using Rubberduck.Parsing.Symbols;
99

@@ -20,27 +20,12 @@ public SelfAssignedDeclarationInspection(RubberduckParserState state)
2020
public override string Description { get { return InspectionsUI.SelfAssignedDeclarationInspectionName; } }
2121
public override CodeInspectionType InspectionType { get { return CodeInspectionType.CodeQualityIssues; } }
2222

23-
private static readonly IReadOnlyList<string> ValueTypes = new[]
24-
{
25-
Tokens.Boolean,
26-
Tokens.Byte,
27-
Tokens.Currency,
28-
Tokens.Date,
29-
Tokens.Decimal,
30-
Tokens.Double,
31-
Tokens.Integer,
32-
Tokens.Long,
33-
Tokens.LongLong,
34-
Tokens.Single,
35-
Tokens.String
36-
};
37-
3823
public override IEnumerable<InspectionResultBase> GetInspectionResults()
3924
{
4025
return UserDeclarations
4126
.Where(declaration => declaration.IsSelfAssigned
4227
&& declaration.IsTypeSpecified
43-
&& !ValueTypes.Contains(declaration.AsTypeName)
28+
&& !SymbolList.ValueTypes.Contains(declaration.AsTypeName)
4429
&& declaration.DeclarationType == DeclarationType.Variable
4530
&& (declaration.AsTypeDeclaration == null
4631
|| declaration.AsTypeDeclaration.DeclarationType != DeclarationType.UserDefinedType)

0 commit comments

Comments
 (0)