Skip to content

Commit 0a63b70

Browse files
authored
Merge pull request #140 from rubberduck-vba/next
sync with main repo
2 parents 8e5fa68 + 3a4c011 commit 0a63b70

File tree

77 files changed

+1020
-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.

77 files changed

+1020
-842
lines changed

RetailCoder.VBE/API/ParserState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void Initialize(VBE vbe)
7878
public void Parse()
7979
{
8080
// blocking call
81-
_parser.Parse();
81+
_parser.Parse(new System.Threading.CancellationTokenSource());
8282
}
8383

8484
/// <summary>

RetailCoder.VBE/App.cs

Lines changed: 0 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
using Rubberduck.UI.Command.MenuItems;
1212
using System;
1313
using System.Globalization;
14-
using System.Threading.Tasks;
1514
using System.Windows.Forms;
1615

1716
namespace Rubberduck
@@ -141,7 +140,6 @@ public void Startup()
141140
_appMenus.Initialize();
142141
_hooks.HookHotkeys(); // need to hook hotkeys before we localize menus, to correctly display ShortcutTexts
143142
_appMenus.Localize();
144-
Task.Delay(1000).ContinueWith(t => UiDispatcher.Invoke(() => _parser.State.OnParseRequested(this)));
145143
UpdateLoggingLevel();
146144
}
147145

@@ -157,168 +155,6 @@ public void Shutdown()
157155
}
158156
}
159157

160-
/*#region sink handlers.
161-
async void sink_ProjectRemoved(object sender, DispatcherEventArgs<VBProject> e)
162-
{
163-
if (!_handleSinkEvents || !_vbe.IsInDesignMode()) { return; }
164-
165-
if (e.Item.Protection == vbext_ProjectProtection.vbext_pp_locked)
166-
{
167-
Logger.Debug("Locked project '{0}' was removed.", e.Item.Name);
168-
return;
169-
}
170-
171-
_parser.Cancel();
172-
173-
var projectId = e.Item.HelpFile;
174-
Debug.Assert(projectId != null);
175-
176-
_parser.State.RemoveProject(e.Item);
177-
_parser.State.OnParseRequested(this);
178-
}
179-
180-
async void sink_ProjectAdded(object sender, DispatcherEventArgs<VBProject> e)
181-
{
182-
if (!_handleSinkEvents || !_vbe.IsInDesignMode()) { return; }
183-
184-
Logger.Debug("Project '{0}' was added.", e.Item.Name);
185-
if (e.Item.Protection == vbext_ProjectProtection.vbext_pp_locked)
186-
{
187-
Logger.Debug("Project is protected and will not be added to parser state.");
188-
return;
189-
}
190-
191-
_parser.State.AddProject(e.Item); // note side-effect: assigns ProjectId/HelpFile
192-
var projectId = e.Item.HelpFile;
193-
RegisterComponentsEventSink(e.Item.VBComponents, projectId);
194-
195-
if (!_parser.State.AllDeclarations.Any())
196-
{
197-
// forces menus to evaluate their CanExecute state:
198-
Parser_StateChanged(this, new ParserStateEventArgs(ParserState.Pending));
199-
_stateBar.SetStatusText();
200-
return;
201-
}
202-
203-
_parser.State.OnParseRequested(sender);
204-
}
205-
206-
async void sink_ComponentSelected(object sender, DispatcherEventArgs<VBComponent> e)
207-
{
208-
if (!_handleSinkEvents || !_vbe.IsInDesignMode()) { return; }
209-
210-
if (!_parser.State.AllDeclarations.Any())
211-
{
212-
return;
213-
}
214-
}
215-
216-
async void sink_ComponentRenamed(object sender, DispatcherRenamedEventArgs<VBComponent> e)
217-
{
218-
if (!_handleSinkEvents || !_vbe.IsInDesignMode()) { return; }
219-
220-
if (!_parser.State.AllDeclarations.Any())
221-
{
222-
return;
223-
}
224-
225-
_parser.Cancel();
226-
227-
_sourceControlPanelVM.HandleRenamedComponent(e.Item, e.OldName);
228-
229-
Logger.Debug("Component '{0}' was renamed to '{1}'.", e.OldName, e.Item.Name);
230-
231-
var projectId = e.Item.Collection.Parent.HelpFile;
232-
var componentDeclaration = _parser.State.AllDeclarations.FirstOrDefault(f =>
233-
f.ProjectId == projectId &&
234-
f.DeclarationType == DeclarationType.ClassModule &&
235-
f.IdentifierName == e.OldName);
236-
237-
if (e.Item.Type == vbext_ComponentType.vbext_ct_Document &&
238-
componentDeclaration != null &&
239-
240-
// according to ThunderFrame, Excel is the only one we explicitly support
241-
// with two Document-component types just skip the Worksheet component
242-
((ClassModuleDeclaration) componentDeclaration).Supertypes.All(a => a.IdentifierName != "Worksheet"))
243-
{
244-
_parser.State.RemoveProject(projectId);
245-
246-
_parser.State.AddProject(e.Item.Collection.Parent);
247-
}
248-
else
249-
{
250-
_parser.State.RemoveRenamedComponent(e.Item, e.OldName);
251-
}
252-
253-
_parser.State.OnParseRequested(this);
254-
}
255-
256-
async void sink_ComponentRemoved(object sender, DispatcherEventArgs<VBComponent> e)
257-
{
258-
if (!_handleSinkEvents || !_vbe.IsInDesignMode()) { return; }
259-
260-
if (!_parser.State.AllDeclarations.Any())
261-
{
262-
return;
263-
}
264-
265-
_parser.Cancel(e.Item);
266-
267-
_sourceControlPanelVM.HandleRemovedComponent(e.Item);
268-
269-
Logger.Debug("Component '{0}' was removed.", e.Item.Name);
270-
_parser.State.ClearStateCache(e.Item, true);
271-
}
272-
273-
async void sink_ComponentReloaded(object sender, DispatcherEventArgs<VBComponent> e)
274-
{
275-
if (!_handleSinkEvents || !_vbe.IsInDesignMode()) { return; }
276-
277-
if (!_parser.State.AllDeclarations.Any())
278-
{
279-
return;
280-
}
281-
282-
_parser.Cancel(e.Item);
283-
284-
_parser.State.OnParseRequested(sender, e.Item);
285-
}
286-
287-
async void sink_ComponentAdded(object sender, DispatcherEventArgs<VBComponent> e)
288-
{
289-
if (!_handleSinkEvents || !_vbe.IsInDesignMode()) { return; }
290-
291-
if (!_parser.State.AllDeclarations.Any())
292-
{
293-
return;
294-
}
295-
296-
_sourceControlPanelVM.HandleAddedComponent(e.Item);
297-
298-
Logger.Debug("Component '{0}' was added.", e.Item.Name);
299-
_parser.State.OnParseRequested(sender, e.Item);
300-
}
301-
302-
async void sink_ProjectRenamed(object sender, DispatcherRenamedEventArgs<VBProject> e)
303-
{
304-
if (!_handleSinkEvents || !_vbe.IsInDesignMode()) { return; }
305-
306-
if (!_parser.State.AllDeclarations.Any())
307-
{
308-
return;
309-
}
310-
311-
_parser.Cancel();
312-
313-
Logger.Debug("Project '{0}' (ID {1}) was renamed to '{2}'.", e.OldName, e.Item.HelpFile, e.Item.Name);
314-
315-
_parser.State.RemoveProject(e.Item.HelpFile);
316-
_parser.State.AddProject(e.Item);
317-
318-
_parser.State.OnParseRequested(sender);
319-
}
320-
#endregion*/
321-
322158
private void _stateBar_Refresh(object sender, EventArgs e)
323159
{
324160
// handles "refresh" button click on "Rubberduck" command bar

RetailCoder.VBE/Extension.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66
using Rubberduck.UI;
77
using System;
88
using System.ComponentModel;
9+
using System.Globalization;
910
using System.IO;
1011
using System.Reflection;
1112
using System.Runtime.InteropServices;
1213
using System.Windows.Forms;
14+
using System.Windows.Threading;
1315
using Ninject.Extensions.Interception;
1416
using NLog;
17+
using Rubberduck.Settings;
18+
using Rubberduck.SettingsProvider;
1519

1620
namespace Rubberduck
1721
{
@@ -46,6 +50,24 @@ public void OnConnection(object Application, ext_ConnectMode ConnectMode, object
4650
{
4751
var currentDomain = AppDomain.CurrentDomain;
4852
currentDomain.AssemblyResolve += LoadFromSameFolder;
53+
54+
var config = new XmlPersistanceService<GeneralSettings>
55+
{
56+
FilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Rubberduck",
57+
"rubberduck.config")
58+
};
59+
60+
var settings = config.Load(null);
61+
if (settings != null)
62+
{
63+
try
64+
{
65+
var cultureInfo = CultureInfo.GetCultureInfo(settings.Language.Code);
66+
Dispatcher.CurrentDispatcher.Thread.CurrentUICulture = cultureInfo;
67+
}
68+
catch (CultureNotFoundException) { }
69+
}
70+
4971
_kernel.Load(new RubberduckModule((VBE)Application, (AddIn)AddInInst));
5072
_app = _kernel.Get<App>();
5173
_app.Startup();

RetailCoder.VBE/Inspections/SelfAssignedDeclarationInspection.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
3939
&& declaration.IsTypeSpecified
4040
&& !ValueTypes.Contains(declaration.AsTypeName)
4141
&& declaration.DeclarationType == DeclarationType.Variable
42+
&& declaration.AsTypeDeclaration.DeclarationType != DeclarationType.UserDefinedType
4243
&& declaration.ParentScopeDeclaration != null
4344
&& declaration.ParentScopeDeclaration.DeclarationType.HasFlag(DeclarationType.Member))
4445
.Select(issue => new SelfAssignedDeclarationInspectionResult(this, issue));

RetailCoder.VBE/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("2.0.2.*")]
35-
[assembly: AssemblyFileVersion("2.0.2.0")]
34+
[assembly: AssemblyVersion("2.0.4.*")]
35+
[assembly: AssemblyFileVersion("2.0.4.0")]

RetailCoder.VBE/Rubberduck.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,11 @@
850850
<DependentUpon>SettingsView.xaml</DependentUpon>
851851
</Compile>
852852
<Compile Include="UI\SourceControl\SettingsViewViewModel.cs" />
853+
<Compile Include="UI\SourceControl\SourceControl.Designer.cs">
854+
<AutoGen>True</AutoGen>
855+
<DesignTime>True</DesignTime>
856+
<DependentUpon>SourceControl.resx</DependentUpon>
857+
</Compile>
853858
<Compile Include="UI\SourceControl\SourceControlPanel.cs">
854859
<SubType>UserControl</SubType>
855860
</Compile>
@@ -1066,6 +1071,10 @@
10661071
<SubType>Designer</SubType>
10671072
<LastGenOutput>RubberduckUI.Designer.cs</LastGenOutput>
10681073
</EmbeddedResource>
1074+
<EmbeddedResource Include="UI\SourceControl\SourceControl.resx">
1075+
<Generator>ResXFileCodeGenerator</Generator>
1076+
<LastGenOutput>SourceControl.Designer.cs</LastGenOutput>
1077+
</EmbeddedResource>
10691078
<EmbeddedResource Include="UI\SourceControl\SourceControlPanel.resx">
10701079
<DependentUpon>SourceControlPanel.cs</DependentUpon>
10711080
</EmbeddedResource>

RetailCoder.VBE/UI/CodeExplorer/CodeExplorerControl.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@
696696
IsCheckable="True" />
697697
</MenuItem>
698698
</Menu>
699-
<ToggleButton Name="DisplaySignatures" IsEnabled="{Binding CanRefresh}" ToolTip="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_ShowSignaturesToolTip}" IsChecked="True">
699+
<ToggleButton Name="DisplaySignatures" ToolTip="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_ShowSignaturesToolTip}" IsChecked="True">
700700
<Image Height="16" Source="../../Resources/Custom/PNG/DisplayFullSignature.png" />
701701
</ToggleButton>
702702

RetailCoder.VBE/UI/Command/MenuItems/AddTestMethodCommandMenuItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public AddTestMethodCommandMenuItem(CommandBase command)
1212
{
1313
}
1414

15-
public override string Key { get { return "TestExplorer_AddTestMethod"; } }
15+
public override string Key { get { return "TestExplorerMenu_AddTestMethod"; } }
1616
public override int DisplayOrder { get { return (int)UnitTestingMenuItemDisplayOrder.AddTestMethod; } }
1717

1818
public override Image Image { get { return Resources.flask; } }

RetailCoder.VBE/UI/Command/MenuItems/AddTestMethodExpectedErrorCommandMenuItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public AddTestMethodExpectedErrorCommandMenuItem(CommandBase command)
1212
{
1313
}
1414

15-
public override string Key { get { return "TestExplorer_AddExpectedErrorTestMethod"; } }
15+
public override string Key { get { return "TestExplorerMenu_AddExpectedErrorTestMethod"; } }
1616
public override int DisplayOrder { get { return (int)UnitTestingMenuItemDisplayOrder.AddTestMethodExpectedError; } }
1717

1818
public override Image Image { get { return Resources.flask_exclamation; } }

RetailCoder.VBE/UI/Command/MenuItems/AddTestModuleCommandMenuItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public AddTestModuleCommandMenuItem(CommandBase command)
1010
{
1111
}
1212

13-
public override string Key { get { return "TestExplorer_AddTestModule"; } }
13+
public override string Key { get { return "TestExplorerMenu_AddTestModule"; } }
1414
public override int DisplayOrder { get { return (int)UnitTestingMenuItemDisplayOrder.AddTestModule; } }
1515
public override bool BeginGroup { get { return true; } }
1616
}

0 commit comments

Comments
 (0)