Skip to content

Commit 8adf30b

Browse files
committed
Merge branch 'next' of https://github.com/rubberduck-vba/Rubberduck into next
2 parents d90f4f3 + bd1fae3 commit 8adf30b

33 files changed

+7267
-5488
lines changed

RetailCoder.VBE/App.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ public App(VBE vbe, IMessageBox messageBox,
6565
_indenter = indenter;
6666
_hooks = hooks;
6767
_logger = LogManager.GetCurrentClassLogger();
68+
// Anyone else could be starting a parse task before we get to disable logging (if the user has configured it so)
69+
// that is why we are conservative and disable logging by default.
70+
LogManager.DisableLogging();
6871

6972
_hooks.MessageReceived += _hooks_MessageReceived;
7073
_configService.SettingsChanged += _configService_SettingsChanged;
@@ -145,7 +148,6 @@ private void UpdateLoggingLevel()
145148
{
146149
return;
147150
}
148-
LogManager.EnableLogging();
149151
LogLevelHelper.SetMinimumLogLevel(fileRule, LogLevel.FromOrdinal(_config.UserSettings.GeneralSettings.MinimumLogLevel));
150152
}
151153

RetailCoder.VBE/Extension.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,14 @@ public void OnConnection(object Application, ext_ConnectMode ConnectMode, object
5555

5656
Assembly LoadFromSameFolder(object sender, ResolveEventArgs args)
5757
{
58-
string folderPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
59-
string assemblyPath = Path.Combine(folderPath, new AssemblyName(args.Name).Name + ".dll");
58+
var folderPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
59+
var assemblyPath = Path.Combine(folderPath, new AssemblyName(args.Name).Name + ".dll");
6060
if (!File.Exists(assemblyPath))
6161
{
6262
return null;
6363
}
64-
Assembly assembly = Assembly.LoadFrom(assemblyPath);
64+
65+
var assembly = Assembly.LoadFile(assemblyPath);
6566
return assembly;
6667
}
6768

RetailCoder.VBE/Refactorings/ExtractMethod/ExtractMethodPresenter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private void GeneratePreview(IExtractMethodModel extractMethodModel,IExtractMeth
8585
*/
8686
var extractedMethod = extractMethodProc.createProc(extractMethodModel);
8787
var code = extractedMethod.Split(new[]{Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries);
88-
_indenter.Indent(code, "Preview", false);
88+
code = _indenter.Indent(code, "Preview", false).ToArray();
8989
_view.Preview = string.Join(Environment.NewLine, code);
9090
}
9191
}

RetailCoder.VBE/Settings/ToDoListSettings.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Xml.Serialization;
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using System.Xml.Serialization;
24
using Rubberduck.UI;
35

46
namespace Rubberduck.Settings
@@ -11,8 +13,18 @@ interface IToDoListSettings
1113
[XmlType(AnonymousType = true)]
1214
public class ToDoListSettings : IToDoListSettings
1315
{
16+
private IEnumerable<ToDoMarker> _markers;
17+
1418
[XmlArrayItem("ToDoMarker", IsNullable = false)]
15-
public ToDoMarker[] ToDoMarkers { get; set; }
19+
public ToDoMarker[] ToDoMarkers
20+
{
21+
get { return _markers.ToArray(); }
22+
set
23+
{
24+
//Only take the first marker if there are duplicates.
25+
_markers = value.GroupBy(m => m.Text).Select(marker => marker.First()).ToArray();
26+
}
27+
}
1628

1729
public ToDoListSettings()
1830
{
@@ -23,9 +35,9 @@ public ToDoListSettings()
2335
ToDoMarkers = new[] { note, todo, bug };
2436
}
2537

26-
public ToDoListSettings(ToDoMarker[] markers)
38+
public ToDoListSettings(IEnumerable<ToDoMarker> markers)
2739
{
28-
ToDoMarkers = markers;
40+
_markers = markers;
2941
}
3042
}
3143
}

RetailCoder.VBE/UI/Settings/IndenterSettingsViewModel.cs

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Linq;
23
using Rubberduck.Settings;
34
using Rubberduck.SmartIndenter;
45

@@ -267,34 +268,34 @@ public int IndentSpaces
267268
@"' Example Procedure
268269
Sub ExampleProc()
269270
270-
' SMART INDENTER
271-
' Original VB6 code graciously offered to Rubberduck by Stephen Bullen & Rob Bovey
272-
'@ 2016 by Rubberduck VBA.
271+
' SMART INDENTER
272+
' Original VB6 code graciously offered to Rubberduck by Stephen Bullen & Rob Bovey
273+
' @ 2016 by Rubberduck VBA.
273274
274-
Dim iCount As Integer
275-
Static sName As String
275+
Dim count As Integer
276+
Static name As String
276277
277-
If YouLikeRubberduck Then
278-
' Star us on GitHub http://github.com/rubberduck-vba/Rubberduck
279-
' Follow us on Twitter @rubberduck-vba/contributors
280-
' Visit http://rubberduckvba.com for news and updates
278+
If YouLikeRubberduck Then
279+
' Star us on GitHub http://github.com/rubberduck-vba/Rubberduck
280+
' Follow us on Twitter @rubberduck-vba/contributors
281+
' Visit http://rubberduckvba.com for news and updates
281282
282-
Select Case X
283-
Case ""A""
284-
' If you have any comments or suggestions, _
285-
or find valid VBA code that isn't indented correctly,
283+
Select Case X
284+
Case ""A""
285+
' If you have any comments or suggestions, _
286+
or find valid VBA code that isn't indented correctly,
286287
287-
#If VBA6 Then
288-
MsgBox ""Contact contact@rubberduck-vba.com""
289-
#End If
288+
#If VBA6 Then
289+
MsgBox ""Contact contact@rubberduck-vba.com""
290+
#End If
290291
291-
Case ""Continued strings and parameters can be"" _
292-
& ""lined up for easier reading, optionally ignoring"" _
293-
, ""any operators (&+, etc) at the start of the line.""
292+
Case ""Continued strings and parameters can be"" _
293+
& ""lined up for easier reading, optionally ignoring"" _
294+
& ""any operators (&+, etc) at the start of the line.""
294295
295-
Debug.Print ""X<>1""
296-
End Select 'Case X
297-
End If 'More Tools?
296+
Debug.Print ""X<>1""
297+
End Select 'Case X
298+
End If 'More Tools?
298299
299300
End Sub
300301
";
@@ -305,8 +306,8 @@ public string PreviewSampleCode
305306
{
306307
var indenter = new Indenter(null, GetCurrentSettings);
307308

308-
var lines = _previewSampleCode.Split(new[] {Environment.NewLine}, StringSplitOptions.None);
309-
indenter.Indent(lines, "TestModule", false);
309+
var lines = _previewSampleCode.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
310+
lines = indenter.Indent(lines, "TestModule", false).ToArray();
310311
return string.Join(Environment.NewLine, lines);
311312
}
312313
}

RetailCoder.VBE/UI/Settings/TodoSettingsViewModel.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.ObjectModel;
2+
using System.Globalization;
23
using System.Linq;
34
using System.Windows.Input;
45
using Rubberduck.Settings;
@@ -41,7 +42,10 @@ public ICommand AddTodoCommand
4142
}
4243
return _addTodoCommand = new DelegateCommand(_ =>
4344
{
44-
TodoSettings.Add(new ToDoMarker("PLACEHOLDER "));
45+
var placeholder = TodoSettings.Count(m => m.Text.StartsWith("PLACEHOLDER")) + 1;
46+
TodoSettings.Add(
47+
new ToDoMarker(string.Format("PLACEHOLDER{0} ",
48+
placeholder == 1 ? string.Empty : placeholder.ToString(CultureInfo.InvariantCulture))));
4549
});
4650
}
4751
}

RetailCoder.VBE/UI/ToDoItems/ToDoExplorerWindow.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ public ToDoExplorerViewModel ViewModel
2323
{
2424
_viewModel = value;
2525
TodoExplorerControl.DataContext = _viewModel;
26-
if (_viewModel != null)
27-
{
28-
_viewModel.RefreshCommand.Execute(null);
29-
}
3026
}
3127
}
3228

Rubberduck.Parsing/Binding/IndexDefaultBinding.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ with a parameter list that cannot accept any parameters and an <argument-list> t
132132
IBoundExpression boundExpression = null;
133133
var asTypeName = lExpression.ReferencedDeclaration.AsTypeName;
134134
var asTypeDeclaration = lExpression.ReferencedDeclaration.AsTypeDeclaration;
135+
if (asTypeDeclaration == null)
136+
{
137+
return null;
138+
}
135139
boundExpression = ResolveDefaultMember(lExpression, asTypeName, asTypeDeclaration);
136140
if (boundExpression != null)
137141
{
@@ -169,8 +173,7 @@ private IBoundExpression ResolveDefaultMember(IBoundExpression lExpression, stri
169173
The declared type of <l-expression> is a specific class, which has a public default Property
170174
Get, Property Let, function or subroutine, and one of the following is true:
171175
*/
172-
bool hasDefaultMember = asTypeDeclaration != null
173-
&& asTypeDeclaration.DeclarationType == DeclarationType.ClassModule
176+
bool hasDefaultMember = asTypeDeclaration.DeclarationType == DeclarationType.ClassModule
174177
&& ((ClassModuleDeclaration)asTypeDeclaration).DefaultMember != null;
175178
if (hasDefaultMember)
176179
{

0 commit comments

Comments
 (0)