Skip to content

Commit 5d4aaf1

Browse files
committed
Merge pull request #672 from rubberduck-vba/next
Merge [next] into [master]
2 parents 3be7706 + d587441 commit 5d4aaf1

File tree

540 files changed

+32058
-13513
lines changed

Some content is hidden

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

540 files changed

+32058
-13513
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,4 @@ $RECYCLE.BIN/
166166
# Workbook for debugging
167167
*.xlsm
168168
Installers/
169+
*.xlsx

.nuget/NuGet.Config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<solution>
4+
<add key="disableSourceControlIntegration" value="true" />
5+
</solution>
6+
</configuration>

.nuget/NuGet.exe

1.59 MB
Binary file not shown.

.nuget/NuGet.targets

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
5+
6+
<!-- Enable the restore command to run before builds -->
7+
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>
8+
9+
<!-- Property that enables building a package from a project -->
10+
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
11+
12+
<!-- Determines if package restore consent is required to restore packages -->
13+
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
14+
15+
<!-- Download NuGet.exe if it does not already exist -->
16+
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
17+
</PropertyGroup>
18+
19+
<ItemGroup Condition=" '$(PackageSources)' == '' ">
20+
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
21+
<!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
22+
<!--
23+
<PackageSource Include="https://www.nuget.org/api/v2/" />
24+
<PackageSource Include="https://my-nuget-source/nuget/" />
25+
-->
26+
</ItemGroup>
27+
28+
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
29+
<!-- Windows specific commands -->
30+
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
31+
</PropertyGroup>
32+
33+
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
34+
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
35+
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
36+
</PropertyGroup>
37+
38+
<PropertyGroup>
39+
<PackagesProjectConfig Condition=" '$(OS)' == 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config</PackagesProjectConfig>
40+
<PackagesProjectConfig Condition=" '$(OS)' != 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config</PackagesProjectConfig>
41+
</PropertyGroup>
42+
43+
<PropertyGroup>
44+
<PackagesConfig Condition="Exists('$(MSBuildProjectDirectory)\packages.config')">$(MSBuildProjectDirectory)\packages.config</PackagesConfig>
45+
<PackagesConfig Condition="Exists('$(PackagesProjectConfig)')">$(PackagesProjectConfig)</PackagesConfig>
46+
</PropertyGroup>
47+
48+
<PropertyGroup>
49+
<!-- NuGet command -->
50+
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
51+
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
52+
53+
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
54+
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 "$(NuGetExePath)"</NuGetCommand>
55+
56+
<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
57+
58+
<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
59+
<NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>
60+
61+
<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
62+
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>
63+
64+
<!-- Commands -->
65+
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
66+
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>
67+
68+
<!-- We need to ensure packages are restored prior to assembly resolve -->
69+
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
70+
RestorePackages;
71+
$(BuildDependsOn);
72+
</BuildDependsOn>
73+
74+
<!-- Make the build depend on restore packages -->
75+
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
76+
$(BuildDependsOn);
77+
BuildPackage;
78+
</BuildDependsOn>
79+
</PropertyGroup>
80+
81+
<Target Name="CheckPrerequisites">
82+
<!-- Raise an error if we're unable to locate nuget.exe -->
83+
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
84+
<!--
85+
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
86+
This effectively acts as a lock that makes sure that the download operation will only happen once and all
87+
parallel builds will have to wait for it to complete.
88+
-->
89+
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
90+
</Target>
91+
92+
<Target Name="_DownloadNuGet">
93+
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
94+
</Target>
95+
96+
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
97+
<Exec Command="$(RestoreCommand)"
98+
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
99+
100+
<Exec Command="$(RestoreCommand)"
101+
LogStandardErrorAsError="true"
102+
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
103+
</Target>
104+
105+
<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
106+
<Exec Command="$(BuildCommand)"
107+
Condition=" '$(OS)' != 'Windows_NT' " />
108+
109+
<Exec Command="$(BuildCommand)"
110+
LogStandardErrorAsError="true"
111+
Condition=" '$(OS)' == 'Windows_NT' " />
112+
</Target>
113+
114+
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
115+
<ParameterGroup>
116+
<OutputFilename ParameterType="System.String" Required="true" />
117+
</ParameterGroup>
118+
<Task>
119+
<Reference Include="System.Core" />
120+
<Using Namespace="System" />
121+
<Using Namespace="System.IO" />
122+
<Using Namespace="System.Net" />
123+
<Using Namespace="Microsoft.Build.Framework" />
124+
<Using Namespace="Microsoft.Build.Utilities" />
125+
<Code Type="Fragment" Language="cs">
126+
<![CDATA[
127+
try {
128+
OutputFilename = Path.GetFullPath(OutputFilename);
129+
130+
Log.LogMessage("Downloading latest version of NuGet.exe...");
131+
WebClient webClient = new WebClient();
132+
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
133+
134+
return true;
135+
}
136+
catch (Exception ex) {
137+
Log.LogErrorFromException(ex);
138+
return false;
139+
}
140+
]]>
141+
</Code>
142+
</Task>
143+
</UsingTask>
144+
</Project>

Installer Build Script.iss

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,12 @@ ArchitecturesInstallIn64BitMode=x64
3636
Name: "English"; MessagesFile: "compiler:Default.isl"
3737

3838
[Files]
39-
; We are taking everything from the Build directory and adding it to the installer. This
40-
; might not be what we want to do.
41-
Source: "{#BuildDir}\*"; DestDir: "{app}"; Flags: ignoreversion; Excludes: "{#AddinDLL}"; Check: Is64BitOfficeInstalled
39+
; Install the correct bitness binaries.
4240
Source: "{#BuildDir}\NativeBinaries\amd64\*"; DestDir: "{app}"; Flags: ignoreversion; Excludes: "{#AddinDLL}"; Check: Is64BitOfficeInstalled
43-
Source: "{#BuildDir}\{#AddinDLL}"; DestDir: "{app}"; Flags: ignoreversion; Check: Is64BitOfficeInstalled; AfterInstall: RegisterAddin
44-
45-
Source: "{#BuildDir}\*"; DestDir: "{app}"; Flags: ignoreversion; Excludes: "{#AddinDLL}"; Check: Is32BitOfficeInstalled
4641
Source: "{#BuildDir}\NativeBinaries\x86\*"; DestDir: "{app}"; Flags: ignoreversion; Excludes: "{#AddinDLL}"; Check: Is32BitOfficeInstalled
47-
Source: "{#BuildDir}\{#AddinDLL}"; DestDir: "{app}"; Flags: ignoreversion; Check: Is32BitOfficeInstalled; AfterInstall: RegisterAddin
4842

49-
[UninstallDelete]
50-
; Removing all application files (except for configuration).
51-
Name: "{app}\*.dll"; Type: filesandordirs
52-
Name: "{app}\*.xml"; Type: filesandordirs
53-
Name: "{app}\*.pdb"; Type: filesandordirs
43+
Source: "{#BuildDir}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Excludes: "{#AddinDLL},\NativeBinaries"
44+
Source: "{#BuildDir}\{#AddinDLL}"; DestDir: "{app}"; Flags: ignoreversion; AfterInstall: RegisterAddin
5445

5546
[Run]
5647
; http://stackoverflow.com/questions/5618337/how-to-register-a-net-dll-using-inno-setup

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ If you're learning VBA, Rubberduck can help you avoid a few common beginner mist
88

99
[**Rubberduck Wiki**](https://github.com/retailcoder/Rubberduck/wiki)
1010

11+
[![Build status](https://ci.appveyor.com/api/projects/status/bfwl1pwu9eeqd11o/branch/next?svg=true)](https://ci.appveyor.com/project/ckuhn203/rubberduck-3v9qv/branch/next)
12+
1113
---
1214

1315
#Contributing

RetailCoder.VBE/App.cs

Lines changed: 128 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,164 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Drawing;
4+
using System.Globalization;
5+
using System.Windows.Forms;
36
using Microsoft.Vbe.Interop;
4-
using Rubberduck.Config;
57
using Rubberduck.Inspections;
8+
using Rubberduck.Parsing;
9+
using Rubberduck.Parsing.VBA;
10+
using Rubberduck.Settings;
611
using Rubberduck.UI;
712
using Rubberduck.UI.CodeInspections;
8-
using Rubberduck.VBA;
13+
using Rubberduck.UI.ParserErrors;
14+
using Rubberduck.VBEditor;
915

1016
namespace Rubberduck
1117
{
1218
public class App : IDisposable
1319
{
14-
private readonly RubberduckMenu _menu;
15-
private readonly CodeInspectionsToolbar _codeInspectionsToolbar;
16-
private readonly IList<IInspection> _inspections;
17-
private readonly IConfigurationService _configService;
20+
private readonly VBE _vbe;
21+
private readonly AddIn _addIn;
22+
private IList<IInspection> _inspections;
23+
private Inspector _inspector;
24+
private ParserErrorsPresenter _parserErrorsPresenter;
25+
private readonly IGeneralConfigService _configService = new ConfigurationLoader();
26+
private readonly ActiveCodePaneEditor _editor;
27+
private IRubberduckParser _parser;
28+
29+
private Configuration _config;
30+
private RubberduckMenu _menu;
31+
private FormContextMenu _formContextMenu;
32+
private CodeInspectionsToolbar _codeInspectionsToolbar;
33+
private bool displayToolbar = false;
34+
private Point toolbarCoords = new Point(-1, -1);
1835

1936
public App(VBE vbe, AddIn addIn)
2037
{
21-
_configService = new ConfigurationLoader();
22-
_inspections = _configService.GetImplementedCodeInspections();
38+
_vbe = vbe;
39+
_addIn = addIn;
40+
41+
_parserErrorsPresenter = new ParserErrorsPresenter(vbe, addIn);
42+
_configService.SettingsChanged += _configService_SettingsChanged;
43+
44+
_editor = new ActiveCodePaneEditor(vbe);
45+
46+
LoadConfig();
47+
48+
CleanUp();
49+
50+
Setup();
51+
}
52+
53+
private void _configService_SettingsChanged(object sender, EventArgs e)
54+
{
55+
LoadConfig();
2356

24-
var config = _configService.LoadConfiguration();
25-
EnableCodeInspections(config);
26-
var parser = new RubberduckParser();
57+
CleanUp();
2758

28-
var inspector = new Inspector(parser, _inspections);
29-
_menu = new RubberduckMenu(vbe, addIn, _configService, parser, inspector);
30-
_codeInspectionsToolbar = new CodeInspectionsToolbar(vbe, inspector);
59+
Setup();
3160
}
3261

33-
private void EnableCodeInspections(Configuration config)
62+
private void LoadConfig()
3463
{
35-
foreach (var inspection in _inspections)
36-
{
37-
foreach (var setting in config.UserSettings.CodeInspectionSettings.CodeInspections)
38-
{
39-
if (inspection.Name == setting.Name)
40-
{
41-
inspection.Severity = setting.Severity;
42-
}
43-
}
64+
_config = _configService.LoadConfiguration();
65+
66+
var currentCulture = RubberduckUI.Culture;
67+
try
68+
{
69+
RubberduckUI.Culture = CultureInfo.GetCultureInfo(_config.UserSettings.LanguageSetting.Code);
4470
}
71+
catch (CultureNotFoundException exception)
72+
{
73+
MessageBox.Show(exception.Message, "Rubberduck", MessageBoxButtons.OK, MessageBoxIcon.Error);
74+
_config.UserSettings.LanguageSetting.Code = currentCulture.Name;
75+
_configService.SaveConfiguration(_config);
76+
}
77+
}
78+
79+
private void Setup()
80+
{
81+
_parser = new RubberduckParser();
82+
_parser.ParseStarted += _parser_ParseStarted;
83+
_parser.ParserError += _parser_ParserError;
84+
85+
_inspector = new Inspector(_parser, _configService);
86+
87+
_parserErrorsPresenter = new ParserErrorsPresenter(_vbe, _addIn);
88+
89+
_menu = new RubberduckMenu(_vbe, _addIn, _configService, _parser, _editor, _inspector);
90+
_menu.Initialize();
91+
92+
_formContextMenu = new FormContextMenu(_vbe, _parser);
93+
_formContextMenu.Initialize();
94+
95+
_codeInspectionsToolbar = new CodeInspectionsToolbar(_vbe, _inspector);
96+
_codeInspectionsToolbar.Initialize();
97+
98+
if (toolbarCoords.X != -1 && toolbarCoords.Y != -1)
99+
{
100+
_codeInspectionsToolbar.ToolbarCoords = toolbarCoords;
101+
}
102+
_codeInspectionsToolbar.ToolbarVisible = displayToolbar;
103+
}
104+
105+
private void _parser_ParseStarted(object sender, ParseStartedEventArgs e)
106+
{
107+
_parserErrorsPresenter.Clear();
108+
}
109+
110+
private void _parser_ParserError(object sender, ParseErrorEventArgs e)
111+
{
112+
_parserErrorsPresenter.AddError(e);
113+
_parserErrorsPresenter.Show();
45114
}
46115

47116
public void Dispose()
48117
{
49118
Dispose(true);
50-
GC.SuppressFinalize(this);
51119
}
52120

53121
protected virtual void Dispose(bool disposing)
54122
{
55-
if (disposing && _menu != null)
123+
if (!disposing) { return; }
124+
125+
CleanUp();
126+
}
127+
128+
private void CleanUp()
129+
{
130+
if (_menu != null)
56131
{
57132
_menu.Dispose();
58133
}
59-
}
60134

61-
public void CreateExtUi()
62-
{
63-
_menu.Initialize();
64-
_codeInspectionsToolbar.Initialize();
135+
if (_formContextMenu != null)
136+
{
137+
_formContextMenu.Dispose();
138+
}
139+
140+
if (_codeInspectionsToolbar != null)
141+
{
142+
displayToolbar = _codeInspectionsToolbar.ToolbarVisible;
143+
toolbarCoords = _codeInspectionsToolbar.ToolbarCoords;
144+
_codeInspectionsToolbar.Dispose();
145+
}
146+
147+
if (_inspector != null)
148+
{
149+
_inspector.Dispose();
150+
}
151+
152+
if (_parserErrorsPresenter != null)
153+
{
154+
_parserErrorsPresenter.Dispose();
155+
}
156+
157+
if (_parser != null)
158+
{
159+
_parser.ParseStarted -= _parser_ParseStarted;
160+
_parser.ParserError -= _parser_ParserError;
161+
}
65162
}
66163
}
67164
}

0 commit comments

Comments
 (0)