Skip to content

Commit 5cfc091

Browse files
authored
Merge branch 'next' into next
2 parents 5e16e8a + b017124 commit 5cfc091

File tree

82 files changed

+971
-842
lines changed

Some content is hidden

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

82 files changed

+971
-842
lines changed

RetailCoder.VBE/API/ParserState.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ public void Initialize(VBE vbe)
6363
throw new InvalidOperationException("ParserState is already initialized.");
6464
}
6565

66-
_state = new RubberduckParserState(vbe, new Sinks(vbe));
66+
_state = new RubberduckParserState(new Sinks(vbe));
6767
_state.StateChanged += _state_StateChanged;
6868

6969
Func<IVBAPreprocessor> preprocessorFactory = () => new VBAPreprocessor(double.Parse(vbe.Version, CultureInfo.InvariantCulture));
7070
_attributeParser = new AttributeParser(new ModuleExporter(), preprocessorFactory);
71-
_parser = new RubberduckParser(_state, _attributeParser, preprocessorFactory,
71+
_parser = new RubberduckParser(vbe, _state, _attributeParser, preprocessorFactory,
7272
new List<ICustomDeclarationLoader> { new DebugDeclarations(_state), new FormEventDeclarations(_state), new AliasDeclarations(_state) });
7373
}
7474

RetailCoder.VBE/Inspections/IParseTreeInspection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ public ParseTreeResults()
2525
public IEnumerable<QualifiedContext> ObsoleteLetContexts;
2626
public IEnumerable<QualifiedContext> ArgListsWithOneByRefParam;
2727
public IEnumerable<QualifiedContext> EmptyStringLiterals;
28-
public IEnumerable<QualifiedContext<VBAParser.AnnotationContext>> MalformedAnnotations;
28+
public IEnumerable<QualifiedContext> MalformedAnnotations;
2929
}
3030
}

RetailCoder.VBE/Inspections/MalformedAnnotationInspection.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,18 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
2727

2828
var results = new List<MalformedAnnotationInspectionResult>();
2929

30-
foreach (var context in ParseTreeResults.MalformedAnnotations)
30+
foreach (var result in ParseTreeResults.MalformedAnnotations)
3131
{
32-
if (context.Context.annotationName().GetText() == AnnotationType.Ignore.ToString() ||
33-
context.Context.annotationName().GetText() == AnnotationType.Folder.ToString())
32+
var context = (VBAParser.AnnotationContext)result.Context;
33+
34+
if (context.annotationName().GetText() == AnnotationType.Ignore.ToString() ||
35+
context.annotationName().GetText() == AnnotationType.Folder.ToString())
3436
{
35-
if (context.Context.annotationArgList() == null)
37+
if (context.annotationArgList() == null)
3638
{
3739
results.Add(new MalformedAnnotationInspectionResult(this,
38-
new QualifiedContext<VBAParser.AnnotationContext>(context.ModuleName,
39-
context.Context)));
40+
new QualifiedContext<VBAParser.AnnotationContext>(result.ModuleName,
41+
context)));
4042
}
4143
}
4244
}

RetailCoder.VBE/Sinks.cs

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,22 @@ namespace Rubberduck
1111
{
1212
public class ProjectEventArgs : EventArgs, IProjectEventArgs
1313
{
14-
public ProjectEventArgs(string projectId)
14+
public ProjectEventArgs(string projectId, VBProject project)
1515
{
1616
_projectId = projectId;
17+
_project = project;
1718
}
1819

1920
private readonly string _projectId;
2021
public string ProjectId { get { return _projectId; } }
22+
23+
private readonly VBProject _project;
24+
public VBProject Project { get { return _project; } }
2125
}
2226

2327
public class ProjectRenamedEventArgs : ProjectEventArgs, IProjectRenamedEventArgs
2428
{
25-
public ProjectRenamedEventArgs(string projectId, string oldName) : base(projectId)
29+
public ProjectRenamedEventArgs(string projectId, VBProject project, string oldName) : base(projectId, project)
2630
{
2731
_oldName = oldName;
2832
}
@@ -33,27 +37,28 @@ public ProjectRenamedEventArgs(string projectId, string oldName) : base(projectI
3337

3438
public class ComponentEventArgs : EventArgs, IComponentEventArgs
3539
{
36-
public ComponentEventArgs(string projectId, string componentName, vbext_ComponentType type)
40+
public ComponentEventArgs(string projectId, VBProject project, VBComponent component)
3741
{
3842
_projectId = projectId;
39-
_componentName = componentName;
40-
_type = type;
43+
_project = project;
44+
_component = component;
4145
}
4246

4347
private readonly string _projectId;
4448
public string ProjectId { get { return _projectId; } }
4549

46-
private readonly string _componentName;
47-
public string ComponentName { get { return _componentName; } }
50+
private readonly VBProject _project;
51+
public VBProject Project { get { return _project; } }
52+
53+
private readonly VBComponent _component;
54+
public VBComponent Component { get { return _component; } }
4855

49-
private readonly vbext_ComponentType _type;
50-
public vbext_ComponentType Type { get { return _type; } }
5156
}
5257

5358
public class ComponentRenamedEventArgs : ComponentEventArgs, IComponentRenamedEventArgs
5459
{
55-
public ComponentRenamedEventArgs(string projectId, string componentName, vbext_ComponentType type, string oldName)
56-
: base(projectId, componentName, type)
60+
public ComponentRenamedEventArgs(string projectId, VBProject project, VBComponent component, string oldName)
61+
: base(projectId, project, component)
5762
{
5863
_oldName = oldName;
5964
}
@@ -108,7 +113,7 @@ private void _sink_ProjectActivated(object sender, DispatcherEventArgs<VBProject
108113
var handler = ProjectActivated;
109114
if (handler != null)
110115
{
111-
handler(sender, new ProjectEventArgs(projectId));
116+
handler(sender, new ProjectEventArgs(projectId, e.Item));
112117
}
113118
});
114119
}
@@ -127,7 +132,7 @@ private void _sink_ProjectAdded(object sender, DispatcherEventArgs<VBProject> e)
127132
var handler = ProjectAdded;
128133
if (handler != null)
129134
{
130-
handler(sender, new ProjectEventArgs(projectId));
135+
handler(sender, new ProjectEventArgs(projectId, e.Item));
131136
}
132137
});
133138
}
@@ -144,7 +149,7 @@ private void _sink_ProjectRemoved(object sender, DispatcherEventArgs<VBProject>
144149
var handler = ProjectRemoved;
145150
if (handler != null)
146151
{
147-
handler(sender, new ProjectEventArgs(projectId));
152+
handler(sender, new ProjectEventArgs(projectId, e.Item));
148153
}
149154
});
150155
}
@@ -161,7 +166,7 @@ private void _sink_ProjectRenamed(object sender, DispatcherRenamedEventArgs<VBPr
161166
var handler = ProjectRenamed;
162167
if (handler != null)
163168
{
164-
handler(sender, new ProjectRenamedEventArgs(projectId, oldName));
169+
handler(sender, new ProjectRenamedEventArgs(projectId, e.Item, oldName));
165170
}
166171
});
167172
}
@@ -228,12 +233,11 @@ private void ComponentsSink_ComponentActivated(object sender, DispatcherEventArg
228233
if (!IsEnabled) { return; }
229234

230235
var projectId = e.Item.Collection.Parent.HelpFile;
231-
var componentName = e.Item.Name;
232236

233237
var handler = ComponentActivated;
234238
if (handler != null)
235239
{
236-
handler(sender, new ComponentEventArgs(projectId, componentName, e.Item.Type));
240+
handler(sender, new ComponentEventArgs(projectId, e.Item.Collection.Parent, e.Item));
237241
}
238242
}
239243

@@ -247,7 +251,7 @@ private void ComponentsSink_ComponentAdded(object sender, DispatcherEventArgs<VB
247251
var handler = ComponentAdded;
248252
if (handler != null)
249253
{
250-
handler(sender, new ComponentEventArgs(projectId, componentName, e.Item.Type));
254+
handler(sender, new ComponentEventArgs(projectId, e.Item.Collection.Parent, e.Item));
251255
}
252256
}
253257

@@ -261,7 +265,7 @@ private void ComponentsSink_ComponentReloaded(object sender, DispatcherEventArgs
261265
var handler = ComponentReloaded;
262266
if (handler != null)
263267
{
264-
handler(sender, new ComponentEventArgs(projectId, componentName, e.Item.Type));
268+
handler(sender, new ComponentEventArgs(projectId, e.Item.Collection.Parent, e.Item));
265269
}
266270
}
267271

@@ -275,7 +279,7 @@ private void ComponentsSink_ComponentRemoved(object sender, DispatcherEventArgs<
275279
var handler = ComponentRemoved;
276280
if (handler != null)
277281
{
278-
handler(sender, new ComponentEventArgs(projectId, componentName, e.Item.Type));
282+
handler(sender, new ComponentEventArgs(projectId, e.Item.Collection.Parent, e.Item));
279283
}
280284
}
281285

@@ -290,7 +294,7 @@ private void ComponentsSink_ComponentRenamed(object sender, DispatcherRenamedEve
290294
var handler = ComponentRenamed;
291295
if (handler != null)
292296
{
293-
handler(sender, new ComponentRenamedEventArgs(projectId, componentName, e.Item.Type, oldName));
297+
handler(sender, new ComponentRenamedEventArgs(projectId, e.Item.Collection.Parent, e.Item, e.OldName));
294298
}
295299
}
296300

@@ -304,7 +308,7 @@ private void ComponentsSink_ComponentSelected(object sender, DispatcherEventArgs
304308
var handler = ComponentSelected;
305309
if (handler != null)
306310
{
307-
handler(sender, new ComponentEventArgs(projectId, componentName, e.Item.Type));
311+
handler(sender, new ComponentEventArgs(projectId, e.Item.Collection.Parent, e.Item));
308312
}
309313
}
310314
#endregion

RetailCoder.VBE/UI/SourceControl/BranchesViewViewModel.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public string CurrentBranch
140140
}
141141
catch (SourceControlException ex)
142142
{
143-
RaiseErrorEvent(ex.Message, ex.InnerException.Message, NotificationType.Error);
143+
RaiseErrorEvent(ex.Message, ex.InnerException, NotificationType.Error);
144144
}
145145
catch
146146
{
@@ -324,7 +324,7 @@ private void CreateBranchOk()
324324
}
325325
catch (SourceControlException ex)
326326
{
327-
RaiseErrorEvent(ex.Message, ex.InnerException.Message, NotificationType.Error);
327+
RaiseErrorEvent(ex.Message, ex.InnerException, NotificationType.Error);
328328
}
329329
catch
330330
{
@@ -358,7 +358,7 @@ private void MergeBranchOk()
358358
}
359359
catch (SourceControlException ex)
360360
{
361-
RaiseErrorEvent(ex.Message, ex.InnerException.Message, NotificationType.Error);
361+
RaiseErrorEvent(ex.Message, ex.InnerException, NotificationType.Error);
362362
Provider.NotifyExternalFileChanges = true;
363363
Provider.HandleVbeSinkEvents = true;
364364
return;
@@ -394,7 +394,7 @@ private void DeleteBranch(bool isBranchPublished)
394394
}
395395
catch (SourceControlException ex)
396396
{
397-
RaiseErrorEvent(ex.Message, ex.InnerException.Message, NotificationType.Error);
397+
RaiseErrorEvent(ex.Message, ex.InnerException, NotificationType.Error);
398398
}
399399
catch
400400
{
@@ -422,7 +422,7 @@ private void PublishBranch()
422422
}
423423
catch (SourceControlException ex)
424424
{
425-
RaiseErrorEvent(ex.Message, ex.InnerException.Message, NotificationType.Error);
425+
RaiseErrorEvent(ex.Message, ex.InnerException, NotificationType.Error);
426426
}
427427
catch
428428
{
@@ -443,7 +443,7 @@ private void UnpublishBranch()
443443
}
444444
catch (SourceControlException ex)
445445
{
446-
RaiseErrorEvent(ex.Message, ex.InnerException.Message, NotificationType.Error);
446+
RaiseErrorEvent(ex.Message, ex.InnerException, NotificationType.Error);
447447
}
448448
catch
449449
{
@@ -531,12 +531,21 @@ public CommandBase UnpublishBranchToolbarButtonCommand
531531
}
532532

533533
public event EventHandler<ErrorEventArgs> ErrorThrown;
534-
private void RaiseErrorEvent(string message, string innerMessage, NotificationType notificationType)
534+
private void RaiseErrorEvent(string message, Exception innerException, NotificationType notificationType)
535535
{
536536
var handler = ErrorThrown;
537537
if (handler != null)
538538
{
539-
handler(this, new ErrorEventArgs(message, innerMessage, notificationType));
539+
handler(this, new ErrorEventArgs(message, innerException, notificationType));
540+
}
541+
}
542+
543+
private void RaiseErrorEvent(string title, string message, NotificationType notificationType)
544+
{
545+
var handler = ErrorThrown;
546+
if (handler != null)
547+
{
548+
handler(this, new ErrorEventArgs(title, message, notificationType));
540549
}
541550
}
542551
}

RetailCoder.VBE/UI/SourceControl/ChangesViewViewModel.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ private void UndoChanges(IFileStatusEntry fileStatusEntry)
158158
}
159159
catch (SourceControlException ex)
160160
{
161-
RaiseErrorEvent(ex.Message, ex.InnerException.Message, NotificationType.Error);
161+
RaiseErrorEvent(ex.Message, ex.InnerException, NotificationType.Error);
162162
}
163163
catch
164164
{
@@ -213,7 +213,7 @@ private void Commit()
213213
}
214214
catch (SourceControlException ex)
215215
{
216-
RaiseErrorEvent(ex.Message, ex.InnerException.Message, NotificationType.Error);
216+
RaiseErrorEvent(ex.Message, ex.InnerException, NotificationType.Error);
217217
}
218218
catch
219219
{
@@ -274,12 +274,21 @@ public CommandBase IncludeChangesToolbarButtonCommand
274274
}
275275

276276
public event EventHandler<ErrorEventArgs> ErrorThrown;
277-
private void RaiseErrorEvent(string message, string innerMessage, NotificationType notificationType)
277+
private void RaiseErrorEvent(string message, Exception innerException, NotificationType notificationType)
278278
{
279279
var handler = ErrorThrown;
280280
if (handler != null)
281281
{
282-
handler(this, new ErrorEventArgs(message, innerMessage, notificationType));
282+
handler(this, new ErrorEventArgs(message, innerException, notificationType));
283+
}
284+
}
285+
286+
private void RaiseErrorEvent(string title, string message, NotificationType notificationType)
287+
{
288+
var handler = ErrorThrown;
289+
if (handler != null)
290+
{
291+
handler(this, new ErrorEventArgs(title, message, notificationType));
283292
}
284293
}
285294
}

RetailCoder.VBE/UI/SourceControl/IControlViewModel.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,34 @@
33

44
namespace Rubberduck.UI.SourceControl
55
{
6+
using System.Linq;
7+
68
public class ErrorEventArgs
79
{
8-
public readonly string Message;
10+
public readonly string Title;
911
public readonly string InnerMessage;
1012
public readonly NotificationType NotificationType;
1113

12-
public ErrorEventArgs(string message, string innerMessage, NotificationType notificationType)
14+
public ErrorEventArgs(string title, Exception innerException, NotificationType notificationType)
15+
{
16+
Title = title;
17+
InnerMessage = GetInnerExceptionMessage(innerException);
18+
NotificationType = notificationType;
19+
}
20+
21+
public ErrorEventArgs(string title, string message, NotificationType notificationType)
1322
{
14-
Message = message;
15-
InnerMessage = innerMessage;
23+
Title = title;
24+
InnerMessage = message;
1625
NotificationType = notificationType;
1726
}
27+
28+
private string GetInnerExceptionMessage(Exception ex)
29+
{
30+
return ex is AggregateException
31+
? string.Join(Environment.NewLine, ((AggregateException) ex).InnerExceptions.Select(s => s.Message))
32+
: ex.Message;
33+
}
1834
}
1935

2036
public interface IControlViewModel

RetailCoder.VBE/UI/SourceControl/SettingsViewViewModel.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,21 @@ public CommandBase ShowGitAttributesCommand
241241
}
242242

243243
public event EventHandler<ErrorEventArgs> ErrorThrown;
244-
private void RaiseErrorEvent(string message, string innerMessage, NotificationType notificationType)
244+
private void RaiseErrorEvent(string message, Exception innerException, NotificationType notificationType)
245245
{
246246
var handler = ErrorThrown;
247247
if (handler != null)
248248
{
249-
handler(this, new ErrorEventArgs(message, innerMessage, notificationType));
249+
handler(this, new ErrorEventArgs(message, innerException, notificationType));
250+
}
251+
}
252+
253+
private void RaiseErrorEvent(string title, string message, NotificationType notificationType)
254+
{
255+
var handler = ErrorThrown;
256+
if (handler != null)
257+
{
258+
handler(this, new ErrorEventArgs(title, message, notificationType));
250259
}
251260
}
252261

0 commit comments

Comments
 (0)