diff --git a/Installer Build Script.iss b/Installer Build Script.iss deleted file mode 100644 index a1dbd28d4c..0000000000 --- a/Installer Build Script.iss +++ /dev/null @@ -1,238 +0,0 @@ -#define BuildDir SourcePath + "RetailCoder.VBE\bin\release" -#define AppName "Rubberduck" -#define AddinDLL "Rubberduck.dll" -#define InspectionsDLL "Rubberduck.Inspections.dll" -#define AppVersion GetFileVersion(SourcePath + "RetailCoder.VBE\bin\release\Rubberduck.dll") -#define AppPublisher "Rubberduck" -#define AppURL "http://rubberduckvba.com" -#define License SourcePath + "\License.rtf" -#define OutputDirectory SourcePath + "\Installers" -#define AddinProgId "Rubberduck.Extension" -#define AddinCLSID "8D052AD8-BBD2-4C59-8DEC-F697CA1F8A66" - -[Setup] -; TODO this CLSID should match the one used by the current installer. -AppId={{979AFF96-DD9E-4FC2-802D-9E0C36A60D09} -AppName={#AppName} -AppVersion={#AppVersion} -AppPublisher={#AppPublisher} -AppPublisherURL={#AppURL} -AppSupportURL={#AppURL} -AppUpdatesURL={#AppURL} -; use the local appdata folder instead of the program files dir. -DefaultDirName={commonappdata}\{#AppName} -DefaultGroupName=Rubberduck -AllowNoIcons=yes -LicenseFile={#License} -OutputDir={#OutputDirectory} -OutputBaseFilename=Rubberduck.Setup -Compression=lzma -SolidCompression=yes - -ArchitecturesAllowed=x86 x64 -ArchitecturesInstallIn64BitMode=x64 - -[Languages] -; TODO add additional installation languages here. -Name: "English"; MessagesFile: "compiler:Default.isl" - -[Files] -; Install the correct bitness binaries. -Source: "libs\NativeBinaries\amd64\*"; DestDir: "{app}"; Flags: ignoreversion; Excludes: "{#AddinDLL}"; Check: Is64BitOfficeInstalled -Source: "libs\NativeBinaries\x86\*"; DestDir: "{app}"; Flags: ignoreversion; Excludes: "{#AddinDLL}"; Check: Is32BitOfficeInstalled - -Source: "{#BuildDir}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Excludes: "{#AddinDLL},\NativeBinaries" -Source: "{#BuildDir}\{#InspectionsDLL}"; DestDir: "{app}"; Flags: ignoreversion -Source: "{#BuildDir}\{#AddinDLL}"; DestDir: "{app}"; Flags: ignoreversion; AfterInstall: RegisterAddin - -[Run] -; http://stackoverflow.com/questions/5618337/how-to-register-a-net-dll-using-inno-setup -Filename: "{dotnet4032}\RegAsm.exe"; Parameters: "/codebase {#AddinDLL}"; WorkingDir: "{app}"; Flags: runascurrentuser runminimized; StatusMsg: "Registering Controls..."; Check: Is32BitOfficeInstalled -Filename: "{dotnet4064}\RegAsm.exe"; Parameters: "/codebase {#AddinDLL}"; WorkingDir: "{app}"; Flags: runascurrentuser runminimized; StatusMsg: "Registering Controls..."; Check: Is64BitOfficeInstalled - -[UninstallRun] -Filename: "{dotnet4032}\RegAsm.exe"; Parameters: "/u {#AddinDLL}"; WorkingDir: "{app}"; StatusMsg: "Unregistering Controls..."; Flags: runascurrentuser runminimized; Check: Is32BitOfficeInstalled -Filename: "{dotnet4064}\RegAsm.exe"; Parameters: "/u {#AddinDLL}"; WorkingDir: "{app}"; StatusMsg: "Unregistering Controls..."; Flags: runascurrentuser runminimized; Check: Is64BitOfficeInstalled - -[UninstallDelete] -Type: filesandordirs; Name: "{localappdata}\{#AppName}" - -[CustomMessages] -; TODO add additional languages here. -English.NETFramework40NotInstalled=Microsoft .NET Framework 4.0 installation was not detected. - -[Icons] -Name: "{group}\{cm:ProgramOnTheWeb,{#AppName}}"; Filename: "{#AppURL}" -Name: "{group}\{cm:UninstallProgram,{#AppName}}"; Filename: "{uninstallexe}" - -[Code] -// The following code is adapted from: http://stackoverflow.com/a/11651515/2301065 -const - SCS_32BIT_BINARY = 0; - SCS_64BIT_BINARY = 6; - // There are other values that GetBinaryType can return, but we're not interested in them. - OfficeNotFound = -1; - -var - HasCheckedOfficeBitness: Boolean; - OfficeIs64Bit: Boolean; - -function GetBinaryType(lpApplicationName: AnsiString; var lpBinaryType: Integer): Boolean; -external 'GetBinaryTypeA@kernel32.dll stdcall'; - -function GetOfficeAppBitness(exeName: string): Integer; -var - appPath: String; - binaryType: Integer; -begin - Result := OfficeNotFound; // Default value. - - if RegQueryStringValue(HKEY_LOCAL_MACHINE, - 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\' + exeName, - '', appPath) then begin - try - if GetBinaryType(appPath, binaryType) then Result := binaryType; - except - end; - end; -end; - -function GetOfficeBitness(): Integer; -var - appBitness: Integer; - officeExeNames: array[0..6] of String; - i: Integer; -begin - officeExeNames[0] := 'excel.exe'; - officeExeNames[1] := 'msaccess.exe'; - officeExeNames[2] := 'winword.exe'; - officeExeNames[3] := 'outlook.exe'; - officeExeNames[4] := 'powerpnt.exe'; - officeExeNames[5] := 'mspub.exe'; - officeExeNames[6] := 'winproj.exe'; - - for i := 0 to 4 do begin - appBitness := GetOfficeAppBitness(officeExeNames[i]); - if appBitness <> OfficeNotFound then begin - Result := appBitness; - exit; - end; - end; - // Note if we get to here then we haven't found any Office versions. Should - // we fail the installation? -end; - -function Is64BitOfficeInstalled(): Boolean; -begin - if (not HasCheckedOfficeBitness) then - OfficeIs64Bit := (GetOfficeBitness() = SCS_64BIT_BINARY); - Result := OfficeIs64Bit; -end; - -function Is32BitOfficeInstalled(): Boolean; -begin - Result := (not Is64BitOfficeInstalled()); -end; - -// http://kynosarges.org/DotNetVersion.html -function IsDotNetDetected(version: string; service: cardinal): boolean; -// Indicates whether the specified version and service pack of the .NET Framework is installed. -// -// version -- Specify one of these strings for the required .NET Framework version: -// 'v1.1.4322' .NET Framework 1.1 -// 'v2.0.50727' .NET Framework 2.0 -// 'v3.0' .NET Framework 3.0 -// 'v3.5' .NET Framework 3.5 -// 'v4\Client' .NET Framework 4.0 Client Profile -// 'v4\Full' .NET Framework 4.0 Full Installation -// 'v4.5' .NET Framework 4.5 -// -// service -- Specify any non-negative integer for the required service pack level: -// 0 No service packs required -// 1, 2, etc. Service pack 1, 2, etc. required -var - key: string; - install, release, serviceCount: cardinal; - check45, success: boolean; -begin - // .NET 4.5 installs as update to .NET 4.0 Full - if version = 'v4.5' then begin - version := 'v4\Full'; - check45 := true; - end else - check45 := false; - - // installation key group for all .NET versions - key := 'SOFTWARE\Microsoft\NET Framework Setup\NDP\' + version; - - // .NET 3.0 uses value InstallSuccess in subkey Setup - if Pos('v3.0', version) = 1 then begin - success := RegQueryDWordValue(HKLM, key + '\Setup', 'InstallSuccess', install); - end else begin - success := RegQueryDWordValue(HKLM, key, 'Install', install); - end; - - // .NET 4.0/4.5 uses value Servicing instead of SP - if Pos('v4', version) = 1 then begin - success := success and RegQueryDWordValue(HKLM, key, 'Servicing', serviceCount); - end else begin - success := success and RegQueryDWordValue(HKLM, key, 'SP', serviceCount); - end; - - // .NET 4.5 uses additional value Release - if check45 then begin - success := success and RegQueryDWordValue(HKLM, key, 'Release', release); - success := success and (release >= 378389); - end; - - result := success and (install = 1) and (serviceCount >= service); -end; - -function InitializeSetup(): Boolean; -var - iErrorCode: Integer; -begin - // MS .NET Framework 4.5 must be installed for this application to work. - if not IsDotNetDetected('v4.5', 0) then - begin - MsgBox(ExpandConstant('{cm:NETFramework40NotInstalled}'), mbCriticalError, mb_Ok); - ShellExec('open', 'http://msdn.microsoft.com/en-us/netframework/aa731542', '', '', SW_SHOW, ewNoWait, iErrorCode) - Result := False; - end - else - Result := True; -end; - -procedure RegisterAddinForIDE(const iRootKey: Integer; const sAddinSubKey: String; const sProgIDConnect: String); -begin - RegWriteStringValue(iRootKey, sAddinSubKey + '\' + sProgIDConnect, 'FriendlyName', '{#AppName}'); - RegWriteStringValue(iRootKey, sAddinSubKey + '\' + sProgIDConnect, 'Description' , '{#AppName}'); - RegWriteDWordValue (iRootKey, sAddinSubKey + '\' + sProgIDConnect, 'LoadBehavior', 3); -end; - -procedure UnregisterAddinForIDE(const iRootKey: Integer; const sAddinSubKey: String; const sProgIDConnect: String); -begin - if RegKeyExists(iRootKey, sAddinSubKey + '\' + sProgIDConnect) then - RegDeleteKeyIncludingSubkeys(iRootKey, sAddinSubKey + '\' + sProgIDConnect); -end; - -procedure RegisterAddin(); -begin - if Is32BitOfficeInstalled() then - RegisterAddinForIDE(HKCU32, 'Software\Microsoft\VBA\VBE\6.0\Addins', '{#AddinProgId}'); - - if Is64BitOfficeInstalled() then - RegisterAddinForIDE(HKCU64, 'Software\Microsoft\VBA\VBE\6.0\Addins64', '{#AddinProgId}'); -end; - -procedure UnregisterAddin(); -begin - UnregisterAddinForIDE(HKCU32, 'Software\Microsoft\VBA\VBE\6.0\Addins', '{#AddinProgId}'); - if IsWin64() then - UnregisterAddinForIDE(HKCU64, 'Software\Microsoft\VBA\VBE\6.0\Addins64', '{#AddinProgId}'); -end; - -procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); -begin - if CurUninstallStep = usUninstall then UnregisterAddin(); -end; diff --git a/License.rtf b/License.rtf deleted file mode 100644 index 1668d69734..0000000000 --- a/License.rtf +++ /dev/null @@ -1,848 +0,0 @@ -{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch31506\stshfloch31506\stshfhich31506\stshfbi31507\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0{\fonttbl{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f34\fbidi \froman\fcharset1\fprq2{\*\panose 02040503050406030204}Cambria Math;} -{\f37\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;}{\flomajor\f31500\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;} -{\fdbmajor\f31501\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\fhimajor\f31502\fbidi \froman\fcharset0\fprq2{\*\panose 02040503050406030204}Cambria;} -{\fbimajor\f31503\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\flominor\f31504\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;} -{\fdbminor\f31505\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\fhiminor\f31506\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;} -{\fbiminor\f31507\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f39\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\f40\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;} -{\f42\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\f43\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\f44\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\f45\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);} -{\f46\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\f47\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\f409\fbidi \fswiss\fcharset238\fprq2 Calibri CE;}{\f410\fbidi \fswiss\fcharset204\fprq2 Calibri Cyr;} -{\f412\fbidi \fswiss\fcharset161\fprq2 Calibri Greek;}{\f413\fbidi \fswiss\fcharset162\fprq2 Calibri Tur;}{\f416\fbidi \fswiss\fcharset186\fprq2 Calibri Baltic;}{\f417\fbidi \fswiss\fcharset163\fprq2 Calibri (Vietnamese);} -{\flomajor\f31508\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\flomajor\f31509\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}{\flomajor\f31511\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;} -{\flomajor\f31512\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\flomajor\f31513\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\flomajor\f31514\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);} -{\flomajor\f31515\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\flomajor\f31516\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\fdbmajor\f31518\fbidi \froman\fcharset238\fprq2 Times New Roman CE;} -{\fdbmajor\f31519\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}{\fdbmajor\f31521\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\fdbmajor\f31522\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;} -{\fdbmajor\f31523\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\fdbmajor\f31524\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\fdbmajor\f31525\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;} -{\fdbmajor\f31526\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\fhimajor\f31528\fbidi \froman\fcharset238\fprq2 Cambria CE;}{\fhimajor\f31529\fbidi \froman\fcharset204\fprq2 Cambria Cyr;} -{\fhimajor\f31531\fbidi \froman\fcharset161\fprq2 Cambria Greek;}{\fhimajor\f31532\fbidi \froman\fcharset162\fprq2 Cambria Tur;}{\fhimajor\f31535\fbidi \froman\fcharset186\fprq2 Cambria Baltic;} -{\fhimajor\f31536\fbidi \froman\fcharset163\fprq2 Cambria (Vietnamese);}{\fbimajor\f31538\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\fbimajor\f31539\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;} -{\fbimajor\f31541\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\fbimajor\f31542\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\fbimajor\f31543\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);} -{\fbimajor\f31544\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\fbimajor\f31545\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\fbimajor\f31546\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);} -{\flominor\f31548\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\flominor\f31549\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}{\flominor\f31551\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;} -{\flominor\f31552\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\flominor\f31553\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\flominor\f31554\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);} -{\flominor\f31555\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\flominor\f31556\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\fdbminor\f31558\fbidi \froman\fcharset238\fprq2 Times New Roman CE;} -{\fdbminor\f31559\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}{\fdbminor\f31561\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\fdbminor\f31562\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;} -{\fdbminor\f31563\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\fdbminor\f31564\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\fdbminor\f31565\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;} -{\fdbminor\f31566\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\fhiminor\f31568\fbidi \fswiss\fcharset238\fprq2 Calibri CE;}{\fhiminor\f31569\fbidi \fswiss\fcharset204\fprq2 Calibri Cyr;} -{\fhiminor\f31571\fbidi \fswiss\fcharset161\fprq2 Calibri Greek;}{\fhiminor\f31572\fbidi \fswiss\fcharset162\fprq2 Calibri Tur;}{\fhiminor\f31575\fbidi \fswiss\fcharset186\fprq2 Calibri Baltic;} -{\fhiminor\f31576\fbidi \fswiss\fcharset163\fprq2 Calibri (Vietnamese);}{\fbiminor\f31578\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\fbiminor\f31579\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;} -{\fbiminor\f31581\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\fbiminor\f31582\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\fbiminor\f31583\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);} -{\fbiminor\f31584\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\fbiminor\f31585\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\fbiminor\f31586\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}} -{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0; -\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;\chyperlink\ctint255\cshade255\red0\green0\blue255;}{\*\defchp \f31506\fs22 }{\*\defpap \ql \li0\ri0\sa200\sl276\slmult1 -\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 }\noqfpromote {\stylesheet{\ql \li0\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 -\ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \snext0 \sqformat \spriority0 \styrsid7085820 Normal;}{\*\cs10 \additive \ssemihidden \sunhideused \spriority1 Default Paragraph Font;}{\* -\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\trcbpat1\trcfpat1\tblind0\tblindtype3\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv \ql \li0\ri0\sa200\sl276\slmult1 -\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \snext11 \ssemihidden \sunhideused \sqformat Normal Table;}{\*\cs15 -\additive \rtlch\fcs1 \af0 \ltrch\fcs0 \ul\cf17 \sbasedon10 \sunhideused \styrsid12126636 Hyperlink;}}{\*\rsidtbl \rsid1324744\rsid3570377\rsid7085820\rsid12126636}{\mmathPr\mmathFont34\mbrkBin0\mbrkBinSub0\msmallFrac0\mdispDef1\mlMargin0\mrMargin0 -\mdefJc1\mwrapIndent1440\mintLim0\mnaryLim1}{\info{\author Christopher J. McClellan}{\operator Christopher J. McClellan}{\creatim\yr2015\mo3\dy14\hr11\min13}{\revtim\yr2015\mo3\dy14\hr11\min16}{\version1}{\edmins3}{\nofpages28}{\nofwords5365} -{\nofchars30582}{\*\company Microsoft Corporation}{\nofcharsws35876}{\vern32775}}{\*\xmlnstbl {\xmlns1 http://schemas.microsoft.com/office/word/2003/wordml}}\paperw12240\paperh15840\margl1440\margr1440\margt1440\margb1440\gutter0\ltrsect -\widowctrl\ftnbj\aenddoc\trackmoves1\trackformatting1\donotembedsysfont1\relyonvml0\donotembedlingdata0\grfdocevents0\validatexml1\showplaceholdtext0\ignoremixedcontent0\saveinvalidxml0\showxmlerrors1\noxlattoyen -\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\formshade\horzdoc\dgmargin\dghspace180\dgvspace180\dghorigin1440\dgvorigin1440\dghshow1\dgvshow1 -\jexpand\viewkind1\viewscale100\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule\nobrkwrptbl\snaptogridincell\allowfieldendsel\wrppunct -\asianbrkrule\rsidroot12126636\newtblstyruls\nogrowautofit\usenormstyforlist\noindnmbrts\felnbrelev\nocxsptable\indrlsweleven\noafcnsttbl\afelev\utinl\hwelev\spltpgpar\notcvasp\notbrkcnstfrctbl\notvatxbx\krnprsnet\cachedcolbal \nouicompat \fet0 -{\*\wgrffmtfilter 2450}\nofeaturethrottle1\ilfomacatclnup0\ltrpar \sectd \ltrsect\linex0\endnhere\sectlinegrid360\sectdefaultcl\sectrsid7085820\sftnbj {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl2 -\pnucltr\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang {\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl6 -\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang -{\pntxtb (}{\pntxta )}}\pard\plain \ltrpar\ql \li0\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid12126636 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 -\f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid12126636 Rubberduck is a COM add-in for the VBA IDE (VBE). -\par -\par Copyright (C) 2014-2016 Mathieu Guindon & Christopher McClellan -\par -\par This program is free software: you can redistribute it and/or modify -\par it under the terms of the GNU General Public License as published by -\par the Free Software Foundation, either version 3 of the License, or -\par (at your option) any later version. -\par -\par This program is distributed in the hope that it will be useful, -\par but WITHOUT ANY WARRANTY; without even the implied warranty of -\par MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -\par GNU General Public License for more details. -\par -\par You should have received a copy of the GNU General Public License -\par along with this program. If not, see }{\field{\*\fldinst {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid12126636 HYPERLINK "http://www.gnu.org/licenses/" }}{\fldrslt {\rtlch\fcs1 \af31507 \ltrch\fcs0 \cs15\ul\cf17\insrsid12126636\charrsid10953201 -http://www.gnu.org/licenses/}}}\sectd \ltrsect\linex0\endnhere\sectlinegrid360\sectdefaultcl\sectrsid7085820\sftnbj {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid12126636 .}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid7085820 -\par }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid12126636 ****************************************************** -\par GNU GENERAL PUBLIC LICENSE -\par Version 3, 29 June 2007 -\par -\par Copyright (C) 2007 Free Software Foundation, Inc. -\par Everyone is permitted to copy and distribute verbatim copies -\par of this license document, but changing it is not allowed. -\par -\par Preamble -\par -\par The GNU General Public License is a free, copyleft license for -\par software and other kinds of works. -\par -\par The licenses for most software and other practical works are designed -\par to take away your freedom to share and change the works. By contrast, -\par the GNU General Public License is intended to guarantee your freedom to -\par share and change all versions of a program--to make sure it remains free -\par software for all its users. We, the Free Software Foundation, use the -\par GNU General Public License for most of our software; it applies also to -\par any other work released this way by its authors. You can apply it to -\par your programs, too. -\par -\par When we speak of free software, we are referring to freedom, not -\par price. Our General Public Licenses are designed to make sure that you -\par have the freedom to distribute copies of free software (and charge for -\par them if you wish), that you receive source code or can get it if you -\par want it, that you can change the software or use pieces of it in new -\par free programs, and that you know you can do these things. -\par -\par To protect your rights, we need to prevent others from denying you -\par these rights or asking you to surrender the rights. Therefore, you have -\par certain responsibilities if you distribute copies of the software, or if -\par you modify it: responsibilities to respect the freedom of others. -\par -\par For example, if you distribute copies of such a program, whether -\par gratis or for a fee, you must pass on to the recipients the same -\par freedoms that you received. You must make sure that they, too, receive -\par or can get the source code. And you must show them these terms so they -\par know their rights. -\par -\par Developers that use the GNU GPL protect your rights with two steps: -\par (1) assert copyright on the software, and (2) offer you this License -\par giving you legal permission to copy, distribute and/or modify it. -\par -\par For the developers' and authors' protection, the GPL clearly explains -\par that there is no warranty for this free software. For both users' and -\par authors' sake, the GPL requires that modified versions be marked as -\par changed, so that their problems will not be attributed erroneously to -\par authors of previous versions. -\par -\par Some devices are designed to deny users access to install or run -\par modified versions of the software inside them, although the manufacturer -\par can do so. This is fundamentally incompatible with the aim of -\par protecting users' freedom to change the software. The systematic -\par pattern of such abuse occurs in the area of products for individuals to -\par use, which is precisely where it is most unacceptable. Therefore, we -\par have designed this version of the GPL to prohibit the practice for those -\par products. If such problems arise substantially in other domains, we -\par stand ready to extend this provision to those domains in future versions -\par of the GPL, as needed to protect the freedom of users. -\par -\par Finally, every program is threatened constantly by software patents. -\par States should not allow patents to restrict development and use of -\par software on general-purpose computers, but in those that do, we wish to -\par avoid the special danger that patents applied to a free program could -\par make it effectively proprietary. To prevent this, the GPL assures that -\par patents cannot be used to render the program non-free. -\par -\par The precise terms and conditions for copying, distribution and -\par modification follow. -\par -\par TERMS AND CONDITIONS -\par -\par 0. Definitions. -\par -\par "This License" refers to version 3 of the GNU General Public License. -\par -\par "Copyright" also means copyright-like laws that apply to other kinds of -\par works, such as semiconductor masks. -\par -\par "The Program" refers to any copyrightable work licensed under this -\par License. Each licensee is addressed as "you". "Licensees" and -\par "recipients" may be individuals or organizations. -\par -\par To "modify" a work means to copy from or adapt all or part of the work -\par in a fashion requiring copyright permission, other than the making of an -\par exact copy. The resulting work is called a "modified version" of the -\par earlier work or a work "based on" the earlier work. -\par -\par A "covered work" means either the unmodified Program or a work based -\par on the Program. -\par -\par To "propagate" a work means to do anything with it that, without -\par permission, would make you directly or secondarily liable for -\par infringement under applicable copyright law, except executing it on a -\par computer or modifying a private copy. Propagation includes copying, -\par distribution (with or without modification), making available to the -\par public, and in some countries other activities as well. -\par -\par To "convey" a work means any kind of propagation that enables other -\par parties to make or receive copies. Mere interaction with a user through -\par a computer network, with no transfer of a copy, is not conveying. -\par -\par An interactive user interface displays "Appropriate Legal Notices" -\par to the extent that it includes a convenient and prominently visible -\par feature that (1) displays an appropriate copyright notice, and (2) -\par tells the user that there is no warranty for the work (except to the -\par extent that warranties are provided), that licensees may convey the -\par work under this License, and how to view a copy of this License. If -\par the interface presents a list of user commands or options, such as a -\par menu, a prominent item in the list meets this criterion. -\par -\par 1. Source Code. -\par -\par The "source code" for a work means the preferred form of the work -\par for making modifications to it. "Object code" means any non-source -\par form of a work. -\par -\par A "Standard Interface" means an interface that either is an official -\par standard defined by a recognized standards body, or, in the case of -\par interfaces specified for a particular programming language, one that -\par is widely used among developers working in that language. -\par -\par The "System Libraries" of an executable work include anything, other -\par than the work as a whole, that (a) is included in the normal form of -\par packaging a Major Component, but which is not part of that Major -\par Component, and (b) serves only to enable use of the work with that -\par Major Component, or to implement a Standard Interface for which an -\par implementation is available to the public in source code form. A -\par "Major Component", in this context, means a major essential component -\par (kernel, window system, and so on) of the specific operating system -\par (if any) on which the executable work runs, or a compiler used to -\par produce the work, or an object code interpreter used to run it. -\par -\par The "Corresponding Source" for a work in object code form means all -\par the source code needed to generate, install, and (for an executable -\par work) run the object code and to modify the work, including scripts to -\par control those activities. However, it does not include the work's -\par System Libraries, or general-purpose tools or generally available free -\par programs which are used unmodified in performing those activities but -\par which are not part of the work. For example, Corresponding Source -\par includes interface definition files associated with source files for -\par the work, and the source code for shared libraries and dynamically -\par linked subprograms that the work is specifically designed to require, -\par such as by intimate data communication or control flow between those -\par subprograms and other parts of the work. -\par -\par The Corresponding Source need not include anything that users -\par can regenerate automatically from other parts of the Corresponding -\par Source. -\par -\par The Corresponding Source for a work in source code form is that -\par same work. -\par -\par 2. Basic Permissions. -\par -\par All rights granted under this License are granted for the term of -\par copyright on the Program, and are irrevocable provided the stated -\par conditions are met. This License explicitly affirms your unlimited -\par permission to run the unmodified Program. The output from running a -\par covered work is covered by this License only if the output, given its -\par content, constitutes a covered work. This License acknowledges your -\par rights of fair use or other equivalent, as provided by copyright law. -\par -\par You may make, run and propagate covered works that you do not -\par convey, without conditions so long as your license otherwise remains -\par in force. You may convey covered works to others for the sole purpose -\par of having them make modifications exclusively for you, or provide you -\par with facilities for running those works, provided that you comply with -\par the terms of this License in conveying all material for which you do -\par not control copyright. Those thus making or running the covered works -\par for you must do so exclusively on your behalf, under your direction -\par and control, on terms that prohibit them from making any copies of -\par your copyrighted material outside their relationship with you. -\par -\par Conveying under any other circumstances is permitted solely under -\par the conditions stated below. Sublicensing is not allowed; section 10 -\par makes it unnecessary. -\par -\par 3. Protecting Users' Legal Rights From Anti-Circumvention Law. -\par -\par No covered work shall be deemed part of an effective technological -\par measure under any applicable law fulfilling obligations under article -\par 11 of the WIPO copyright treaty adopted on 20 December 1996, or -\par similar laws prohibiting or restricting circumvention of such -\par measures. -\par -\par When you convey a covered work, you waive any legal power to forbid -\par circumvention of technological measures to the extent such circumvention -\par is effected by exercising rights under this License with respect to -\par the covered work, and you disclaim any intention to limit operation or -\par modification of the work as a means of enforcing, against the work's -\par users, your or third parties' legal rights to forbid circumvention of -\par technological measures. -\par -\par 4. Conveying Verbatim Copies. -\par -\par You may convey verbatim copies of the Program's source code as you -\par receive it, in any medium, provided that you conspicuously and -\par appropriately publish on each copy an appropriate copyright notice; -\par keep intact all notices stating that this License and any -\par non-permissive terms added in accord with section 7 apply to the code; -\par keep intact all notices of the absence of any warranty; and give all -\par recipients a copy of this License along with the Program. -\par -\par You may charge any price or no price for each copy that you convey, -\par and you may offer support or warranty protection for a fee. -\par -\par 5. Conveying Modified Source Versions. -\par -\par You may convey a work based on the Program, or the modifications to -\par produce it from the Program, in the form of source code under the -\par terms of section 4, provided that you also meet all of these conditions: -\par -\par a) The work must carry prominent notices stating that you modified -\par it, and giving a relevant date. -\par -\par b) The work must carry prominent notices stating that it is -\par released under this License and any conditions added under section -\par 7. This requirement modifies the requirement in section 4 to -\par "keep intact all notices". -\par -\par c) You must license the entire work, as a whole, under this -\par License to anyone who comes into possession of a copy. This -\par License will therefore apply, along with any applicable section 7 -\par additional terms, to the whole of the work, and all its parts, -\par regardless of how they are packaged. This License gives no -\par permission to license the work in any other way, but it does not -\par invalidate such permission if you have separately received it. -\par -\par d) If the work has interactive user interfaces, each must display -\par Appropriate Legal Notices; however, if the Program has interactive -\par interfaces that do not display Appropriate Legal Notices, your -\par work need not make them do so. -\par -\par A compilation of a covered work with other separate and independent -\par works, which are not by their nature extensions of the covered work, -\par and which are not combined with it such as to form a larger program, -\par in or on a volume of a storage or distribution medium, is called an -\par "aggregate" if the compilation and its resulting copyright are not -\par used to limit the access or legal rights of the compilation's users -\par beyond what the individual works permit. Inclusion of a covered work -\par in an aggregate does not cause this License to apply to the other -\par parts of the aggregate. -\par -\par 6. Conveying Non-Source Forms. -\par -\par You may convey a covered work in object code form under the terms -\par of sections 4 and 5, provided that you also convey the -\par machine-readable Corresponding Source under the terms of this License, -\par in one of these ways: -\par -\par a) Convey the object code in, or embodied in, a physical product -\par (including a physical distribution medium), accompanied by the -\par Corresponding Source fixed on a durable physical medium -\par customarily used for software interchange. -\par -\par b) Convey the object code in, or embodied in, a physical product -\par (including a physical distribution medium), accompanied by a -\par written offer, valid for at least three years and valid for as -\par long as you offer spare parts or customer support for that product -\par model, to give anyone who possesses the object code either (1) a -\par copy of the Corresponding Source for all the software in the -\par product that is covered by this License, on a durable physical -\par medium customarily used for software interchange, for a price no -\par more than your reasonable cost of physically performing this -\par conveying of source, or (2) access to copy the -\par Corresponding Source from a network server at no charge. -\par -\par c) Convey individual copies of the object code with a copy of the -\par written offer to provide the Corresponding Source. This -\par alternative is allowed only occasionally and noncommercially, and -\par only if you received the object code with such an offer, in accord -\par with subsection 6b. -\par -\par d) Convey the object code by offering access from a designated -\par place (gratis or for a charge), and offer equivalent access to the -\par Corresponding Source in the same way through the same place at no -\par further charge. You need not require recipients to copy the -\par Corresponding Source along with the object code. If the place to -\par copy the object code is a network server, the Corresponding Source -\par may be on a different server (operated by you or a third party) -\par that supports equivalent copying facilities, provided you maintain -\par clear directions next to the object code saying where to find the -\par Corresponding Source. Regardless of what server hosts the -\par Corresponding Source, you remain obligated to ensure that it is -\par available for as long as needed to satisfy these requirements. -\par -\par e) Convey the object code using peer-to-peer transmission, provided -\par you inform other peers where the object code and Corresponding -\par Source of the work are being offered to the general public at no -\par charge under subsection 6d. -\par -\par A separable portion of the object code, whose source code is excluded -\par from the Corresponding Source as a System Library, need not be -\par included in conveying the object code work. -\par -\par A "User Product" is either (1) a "consumer product", which means any -\par tangible personal property which is normally used for personal, family, -\par or household purposes, or (2) anything designed or sold for incorporation -\par into a dwelling. In determining whether a product is a consumer product, -\par doubtful cases shall be resolved in favor of coverage. For a particular -\par product received by a particular user, "normally used" refers to a -\par typical or common use of that class of product, regardless of the status -\par of the particular user or of the way in which the particular user -\par actually uses, or expects or is expected to use, the product. A product -\par is a consumer product regardless of whether the product has substantial -\par commercial, industrial or non-consumer uses, unless such uses represent -\par the only significant mode of use of the product. -\par -\par "Installation Information" for a User Product means any methods, -\par procedures, authorization keys, or other information required to install -\par and execute modified versions of a covered work in that User Product from -\par a modified version of its Corresponding Source. The information must -\par suffice to ensure that the continued functioning of the modified object -\par code is in no case prevented or interfered with solely because -\par modification has been made. -\par -\par If you convey an object code work under this section in, or with, or -\par specifically for use in, a User Product, and the conveying occurs as -\par part of a transaction in which the right of possession and use of the -\par User Product is transferred to the recipient in perpetuity or for a -\par fixed term (regardless of how the transaction is characterized), the -\par Corresponding Source conveyed under this section must be accompanied -\par by the Installation Information. But this requirement does not apply -\par if neither you nor any third party retains the ability to install -\par modified object code on the User Product (for example, the work has -\par been installed in ROM). -\par -\par The requirement to provide Installation Information does not include a -\par requirement to continue to provide support service, warranty, or updates -\par for a work that has been modified or installed by the recipient, or for -\par the User Product in which it has been modified or installed. Access to a -\par network may be denied when the modification itself materially and -\par adversely affects the operation of the network or violates the rules and -\par protocols for communication across the network. -\par -\par Corresponding Source conveyed, and Installation Information provided, -\par in accord with this section must be in a format that is publicly -\par documented (and with an implementation available to the public in -\par source code form), and must require no special password or key for -\par unpacking, reading or copying. -\par -\par 7. Additional Terms. -\par -\par "Additional permissions" are terms that supplement the terms of this -\par License by making exceptions from one or more of its conditions. -\par Additional permissions that are applicable to the entire Program shall -\par be treated as though they were included in this License, to the extent -\par that they are valid under applicable law. If additional permissions -\par apply only to part of the Program, that part may be used separately -\par under those permissions, but the entire Program remains governed by -\par this License without regard to the additional permissions. -\par -\par When you convey a copy of a covered work, you may at your option -\par remove any additional permissions from that copy, or from any part of -\par it. (Additional permissions may be written to require their own -\par removal in certain cases when you modify the work.) You may place -\par additional permissions on material, added by you to a covered work, -\par for which you have or can give appropriate copyright permission. -\par -\par Notwithstanding any other provision of this License, for material you -\par add to a covered work, you may (if authorized by the copyright holders of -\par that material) supplement the terms of this License with terms: -\par -\par a) Disclaiming warranty or limiting liability differently from the -\par terms of sections 15 and 16 of this License; or -\par -\par b) Requiring preservation of specified reasonable legal notices or -\par author attributions in that material or in the Appropriate Legal -\par Notices displayed by works containing it; or -\par -\par c) Prohibiting misrepresentation of the origin of that material, or -\par requiring that modified versions of such material be marked in -\par reasonable ways as different from the original version; or -\par -\par d) Limiting the use for publicity purposes of names of licensors or -\par authors of the material; or -\par -\par e) Declining to grant rights under trademark law for use of some -\par trade names, trademarks, or service marks; or -\par -\par f) Requiring indemnification of licensors and authors of that -\par material by anyone who conveys the material (or modified versions of -\par it) with contractual assumptions of liability to the recipient, for -\par any liability that these contractual assumptions directly impose on -\par those licensors and authors. -\par -\par All other non-permissive additional terms are considered "further -\par restrictions" within the meaning of section 10. If the Program as you -\par received it, or any part of it, contains a notice stating that it is -\par governed by this License along with a term that is a further -\par restriction, you may remove that term. If a license document contains -\par a further restriction but permits relicensing or conveying under this -\par License, you may add to a covered work material governed by the terms -\par of that license document, provided that the further restriction does -\par not survive such relicensing or conveying. -\par -\par If you add terms to a covered work in accord with this section, you -\par must place, in the relevant source files, a statement of the -\par additional terms that apply to those files, or a notice indicating -\par where to find the applicable terms. -\par -\par Additional terms, permissive or non-permissive, may be stated in the -\par form of a separately written license, or stated as exceptions; -\par the above requirements apply either way. -\par -\par 8. Termination. -\par -\par You may not propagate or modify a covered work except as expressly -\par provided under this License. Any attempt otherwise to propagate or -\par modify it is void, and will automatically terminate your rights under -\par this License (including any patent licenses granted under the third -\par paragraph of section 11). -\par -\par However, if you cease all violation of this License, then your -\par license from a particular copyright holder is reinstated (a) -\par provisionally, unless and until the copyright holder explicitly and -\par finally terminates your license, and (b) permanently, if the copyright -\par holder fails to notify you of the violation by some reasonable means -\par prior to 60 days after the cessation. -\par -\par Moreover, your license from a particular copyright holder is -\par reinstated permanently if the copyright holder notifies you of the -\par violation by some reasonable means, this is the first time you have -\par received notice of violation of this License (for any work) from that -\par copyright holder, and you cure the violation prior to 30 days after -\par your receipt of the notice. -\par -\par Termination of your rights under this section does not terminate the -\par licenses of parties who have received copies or rights from you under -\par this License. If your rights have been terminated and not permanently -\par reinstated, you do not qualify to receive new licenses for the same -\par material under section 10. -\par -\par 9. Acceptance Not Required for Having Copies. -\par -\par You are not required to accept this License in order to receive or -\par run a copy of the Program. Ancillary propagation of a covered work -\par occurring solely as a consequence of using peer-to-peer transmission -\par to receive a copy likewise does not require acceptance. However, -\par nothing other than this License grants you permission to propagate or -\par modify any covered work. These actions infringe copyright if you do -\par not accept this License. Therefore, by modifying or propagating a -\par covered work, you indicate your acceptance of this License to do so. -\par -\par 10. Automatic Licensing of Downstream Recipients. -\par -\par Each time you convey a covered work, the recipient automatically -\par receives a license from the original licensors, to run, modify and -\par propagate that work, subject to this License. You are not responsible -\par for enforcing compliance by third parties with this License. -\par -\par An "entity transaction" is a transaction transferring control of an -\par organization, or substantially all assets of one, or subdividing an -\par organization, or merging organizations. If propagation of a covered -\par work results from an entity transaction, each party to that -\par transaction who receives a copy of the work also receives whatever -\par licenses to the work the party's predecessor in interest had or could -\par give under the previous paragraph, plus a right to possession of the -\par Corresponding Source of the work from the predecessor in interest, if -\par the predecessor has it or can get it with reasonable efforts. -\par -\par You may not impose any further restrictions on the exercise of the -\par rights granted or affirmed under this License. For example, you may -\par not impose a license fee, royalty, or other charge for exercise of -\par rights granted under this License, and you may not initiate litigation -\par (including a cross-claim or counterclaim in a lawsuit) alleging that -\par any patent claim is infringed by making, using, selling, offering for -\par sale, or importing the Program or any portion of it. -\par -\par 11. Patents. -\par -\par A "contributor" is a copyright holder who authorizes use under this -\par License of the Program or a work on which the Program is based. The -\par work thus licensed is called the contributor's "contributor version". -\par -\par A contributor's "essential patent claims" are all patent claims -\par owned or controlled by the contributor, whether already acquired or -\par hereafter acquired, that would be infringed by some manner, permitted -\par by this License, of making, using, or selling its contributor version, -\par but do not include claims that would be infringed only as a -\par consequence of further modification of the contributor version. For -\par purposes of this definition, "control" includes the right to grant -\par patent sublicenses in a manner consistent with the requirements of -\par this License. -\par -\par Each contributor grants you a non-exclusive, worldwide, royalty-free -\par patent license under the contributor's essential patent claims, to -\par make, use, sell, offer for sale, import and otherwise run, modify and -\par propagate the contents of its contributor version. -\par -\par In the following three paragraphs, a "patent license" is any express -\par agreement or commitment, however denominated, not to enforce a patent -\par (such as an express permission to practice a patent or covenant not to -\par sue for patent infringement). To "grant" such a patent license to a -\par party means to make such an agreement or commitment not to enforce a -\par patent against the party. -\par -\par If you convey a covered work, knowingly relying on a patent license, -\par and the Corresponding Source of the work is not available for anyone -\par to copy, free of charge and under the terms of this License, through a -\par publicly available network server or other readily accessible means, -\par then you must either (1) cause the Corresponding Source to be so -\par available, or (2) arrange to deprive yourself of the benefit of the -\par patent license for this particular work, or (3) arrange, in a manner -\par consistent with the requirements of this License, to extend the patent -\par license to downstream recipients. "Knowingly relying" means you have -\par actual knowledge that, but for the patent license, your conveying the -\par covered work in a country, or your recipient's use of the covered work -\par in a country, would infringe one or more identifiable patents in that -\par country that you have reason to believe are valid. -\par -\par If, pursuant to or in connection with a single transaction or -\par arrangement, you convey, or propagate by procuring conveyance of, a -\par covered work, and grant a patent license to some of the parties -\par receiving the covered work authorizing them to use, propagate, modify -\par or convey a specific copy of the covered work, then the patent license -\par you grant is automatically extended to all recipients of the covered -\par work and works based on it. -\par -\par A patent license is "discriminatory" if it does not include within -\par the scope of its coverage, prohibits the exercise of, or is -\par conditioned on the non-exercise of one or more of the rights that are -\par specifically granted under this License. You may not convey a covered -\par work if you are a party to an arrangement with a third party that is -\par in the business of distributing software, under which you make payment -\par to the third party based on the extent of your activity of conveying -\par the work, and under which the third party grants, to any of the -\par parties who would receive the covered work from you, a discriminatory -\par patent license (a) in connection with copies of the covered work -\par conveyed by you (or copies made from those copies), or (b) primarily -\par for and in connection with specific products or compilations that -\par contain the covered work, unless you entered into that arrangement, -\par or that patent license was granted, prior to 28 March 2007. -\par -\par Nothing in this License shall be construed as excluding or limiting -\par any implied license or other defenses to infringement that may -\par otherwise be available to you under applicable patent law. -\par -\par 12. No Surrender of Others' Freedom. -\par -\par If conditions are imposed on you (whether by court order, agreement or -\par otherwise) that contradict the conditions of this License, they do not -\par excuse you from the conditions of this License. If you cannot convey a -\par covered work so as to satisfy simultaneously your obligations under this -\par License and any other pertinent obligations, then as a consequence you may -\par not convey it at all. For example, if you agree to terms that obligate you -\par to collect a royalty for further conveying from those to whom you convey -\par the Program, the only way you could satisfy both those terms and this -\par License would be to refrain entirely from conveying the Program. -\par -\par 13. Use with the GNU Affero General Public License. -\par -\par Notwithstanding any other provision of this License, you have -\par permission to link or combine any covered work with a work licensed -\par under version 3 of the GNU Affero General Public License into a single -\par combined work, and to convey the resulting work. The terms of this -\par License will continue to apply to the part which is the covered work, -\par but the special requirements of the GNU Affero General Public License, -\par section 13, concerning interaction through a network will apply to the -\par combination as such. -\par -\par 14. Revised Versions of this License. -\par -\par The Free Software Foundation may publish revised and/or new versions of -\par the GNU General Public License from time to time. Such new versions will -\par be similar in spirit to the present version, but may differ in detail to -\par address new problems or concerns. -\par -\par Each version is given a distinguishing version number. If the -\par Program specifies that a certain numbered version of the GNU General -\par Public License "or any later version" applies to it, you have the -\par option of following the terms and conditions either of that numbered -\par version or of any later version published by the Free Software -\par Foundation. If the Program does not specify a version number of the -\par GNU General Public License, you may choose any version ever published -\par by the Free Software Foundation. -\par -\par If the Program specifies that a proxy can decide which future -\par versions of the GNU General Public License can be used, that proxy's -\par public statement of acceptance of a version permanently authorizes you -\par to choose that version for the Program. -\par -\par Later license versions may give you additional or different -\par permissions. However, no additional obligations are imposed on any -\par author or copyright holder as a result of your choosing to follow a -\par later version. -\par -\par 15. Disclaimer of Warranty. -\par -\par THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -\par APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -\par HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -\par OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -\par THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -\par PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -\par IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -\par ALL NECESSARY SERVICING, REPAIR OR CORRECTION. -\par -\par 16. Limitation of Liability. -\par -\par IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -\par WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -\par THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -\par GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -\par USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -\par DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -\par PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -\par EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -\par SUCH DAMAGES. -\par -\par 17. Interpretation of Sections 15 and 16. -\par -\par If the disclaimer of warranty and limitation of liability provided -\par above cannot be given local legal effect according to their terms, -\par reviewing courts shall apply local law that most closely approximates -\par an absolute waiver of all civil liability in connection with the -\par Program, unless a warranty or assumption of liability accompanies a -\par copy of the Program in return for a fee. -\par -\par END OF TERMS AND CONDITIONS -\par -\par How to Apply These Terms to Your New Programs -\par -\par If you develop a new program, and you want it to be of the greatest -\par possible use to the public, the best way to achieve this is to make it -\par free software which everyone can redistribute and change under these terms. -\par -\par To do so, attach the following notices to the program. It is safest -\par to attach them to the start of each source file to most effectively -\par state the exclusion of warranty; and each file should have at least -\par the "copyright" line and a pointer to where the full notice is found. -\par -\par \{one line to give the program's name and a brief idea of what it does.\} -\par Copyright (C) \{year\} \{name of author\} -\par -\par This program is free software: you can redistribute it and/or modify -\par it under the terms of the GNU General Public License as published by -\par the Free Software Foundation, either version 3 of the License, or -\par (at your option) any later version. -\par -\par This program is distributed in the hope that it will be useful, -\par but WITHOUT ANY WARRANTY; without even the implied warranty of -\par MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -\par GNU General Public License for more details. -\par -\par You should have received a copy of the GNU General Public License -\par along with this program. If not, see . -\par -\par Also add information on how to contact you by electronic and paper mail. -\par -\par If the program does terminal interaction, make it output a short -\par notice like this when it starts in an interactive mode: -\par -\par \{project\} Copyright (C) \{year\} \{fullname\} -\par This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. -\par This is free software, and you are welcome to redistribute it -\par under certain conditions; type `show c' for details. -\par -\par The hypothetical commands `show w' and `show c' should show the appropriate -\par parts of the General Public License. Of course, your program's commands -\par might be different; for a GUI interface, you would use an "about box". -\par -\par You should also get your employer (if you work as a programmer) or school, -\par if any, to sign a "copyright disclaimer" for the program, if necessary. -\par For more information on this, and how to apply and follow the GNU GPL, see -\par . -\par -\par The GNU General Public License does not permit incorporating your program -\par into proprietary programs. If your program is a subroutine library, you -\par may consider it more useful to permit linking proprietary applications with -\par the library. If this is what you want to do, use the GNU Lesser General -\par Public License instead of this License. But first, please read -\par . -\par }{\*\themedata 504b030414000600080000002100828abc13fa0000001c020000130000005b436f6e74656e745f54797065735d2e786d6cac91cb6ac3301045f785fe83d0b6d8 -72ba28a5d8cea249777d2cd20f18e4b12d6a8f843409c9df77ecb850ba082d74231062ce997b55ae8fe3a00e1893f354e9555e6885647de3a8abf4fbee29bbd7 -2a3150038327acf409935ed7d757e5ee14302999a654e99e393c18936c8f23a4dc072479697d1c81e51a3b13c07e4087e6b628ee8cf5c4489cf1c4d075f92a0b -44d7a07a83c82f308ac7b0a0f0fbf90c2480980b58abc733615aa2d210c2e02cb04430076a7ee833dfb6ce62e3ed7e14693e8317d8cd0433bf5c60f53fea2fe7 -065bd80facb647e9e25c7fc421fd2ddb526b2e9373fed4bb902e182e97b7b461e6bfad3f010000ffff0300504b030414000600080000002100a5d6a7e7c00000 -00360100000b0000005f72656c732f2e72656c73848fcf6ac3300c87ef85bd83d17d51d2c31825762fa590432fa37d00e1287f68221bdb1bebdb4fc7060abb08 -84a4eff7a93dfeae8bf9e194e720169aaa06c3e2433fcb68e1763dbf7f82c985a4a725085b787086a37bdbb55fbc50d1a33ccd311ba548b63095120f88d94fbc -52ae4264d1c910d24a45db3462247fa791715fd71f989e19e0364cd3f51652d73760ae8fa8c9ffb3c330cc9e4fc17faf2ce545046e37944c69e462a1a82fe353 -bd90a865aad41ed0b5b8f9d6fd010000ffff0300504b0304140006000800000021006b799616830000008a0000001c0000007468656d652f7468656d652f7468 -656d654d616e616765722e786d6c0ccc4d0ac3201040e17da17790d93763bb284562b2cbaebbf600439c1a41c7a0d29fdbd7e5e38337cedf14d59b4b0d592c9c -070d8a65cd2e88b7f07c2ca71ba8da481cc52c6ce1c715e6e97818c9b48d13df49c873517d23d59085adb5dd20d6b52bd521ef2cdd5eb9246a3d8b4757e8d3f7 -29e245eb2b260a0238fd010000ffff0300504b03041400060008000000210096b5ade296060000501b0000160000007468656d652f7468656d652f7468656d65 -312e786d6cec594f6fdb3614bf0fd87720746f6327761a07758ad8b19b2d4d1bc46e871e698996d850a240d2497d1bdae38001c3ba618715d86d87615b8116d8 -a5fb34d93a6c1dd0afb0475292c5585e9236d88aad3e2412f9e3fbff1e1fa9abd7eec70c1d1221294fda5efd72cd4324f1794093b0eddd1ef62fad79482a9c04 -98f184b4bd2991deb58df7dfbb8ad755446282607d22d771db8b944ad79796a40fc3585ee62949606ecc458c15bc8a702910f808e8c66c69b9565b5d8a314d3c -94e018c8de1a8fa94fd05093f43672e23d06af89927ac06762a049136785c10607758d9053d965021d62d6f6804fc08f86e4bef210c352c144dbab999fb7b471 -7509af678b985ab0b6b4ae6f7ed9ba6c4170b06c788a705430adf71bad2b5b057d03606a1ed7ebf5babd7a41cf00b0ef83a6569632cd467faddec9699640f671 -9e76b7d6ac355c7c89feca9cccad4ea7d36c65b258a206641f1b73f8b5da6a6373d9c11b90c537e7f08dce66b7bbeae00dc8e257e7f0fd2badd5868b37a088d1 -e4600ead1ddaef67d40bc898b3ed4af81ac0d76a197c86826828a24bb318f3442d8ab518dfe3a20f000d6458d104a9694ac6d88728eee2782428d60cf03ac1a5 -193be4cbb921cd0b495fd054b5bd0f530c1931a3f7eaf9f7af9e3f45c70f9e1d3ff8e9f8e1c3e3073f5a42ceaa6d9c84e5552fbffdeccfc71fa33f9e7ef3f2d1 -17d57859c6fffac327bffcfc793510d26726ce8b2f9ffcf6ecc98baf3efdfdbb4715f04d814765f890c644a29be408edf3181433567125272371be15c308d3f2 -8acd249438c19a4b05fd9e8a1cf4cd296699771c393ac4b5e01d01e5a30a787d72cf1178108989a2159c77a2d801ee72ce3a5c545a6147f32a99793849c26ae6 -6252c6ed637c58c5bb8b13c7bfbd490a75330f4b47f16e441c31f7184e140e494214d273fc80900aedee52ead87597fa824b3e56e82e451d4c2b4d32a423279a -668bb6690c7e9956e90cfe766cb37b077538abd27a8b1cba48c80acc2a841f12e698f13a9e281c57911ce298950d7e03aba84ac8c154f8655c4f2af074481847 -bd804859b5e696007d4b4edfc150b12addbecba6b18b148a1e54d1bc81392f23b7f84137c2715a851dd0242a633f900710a218ed715505dfe56e86e877f0034e -16bafb0e258ebb4faf06b769e888340b103d3311da9750aa9d0a1cd3e4efca31a3508f6d0c5c5c398602f8e2ebc71591f5b616e24dd893aa3261fb44f95d843b -5974bb5c04f4edafb95b7892ec1108f3f98de75dc97d5772bdff7cc95d94cf672db4b3da0a6557f70db629362d72bcb0431e53c6066acac80d699a6409fb44d0 -8741bdce9c0e4971624a2378cceaba830b05366b90e0ea23aaa241845368b0eb9e2612ca8c742851ca251ceccc70256d8d87265dd96361531f186c3d9058edf2 -c00eafe8e1fc5c509031bb4d680e9f39a3154de0accc56ae644441edd76156d7429d995bdd88664a9dc3ad50197c38af1a0c16d684060441db02565e85f3b966 -0d0713cc48a0ed6ef7dedc2dc60b17e92219e180643ed27acffba86e9c94c78ab90980d8a9f0913ee49d62b512b79626fb06dccee2a432bbc60276b9f7dec44b -7904cfbca4f3f6443ab2a49c9c2c41476dafd55c6e7ac8c769db1bc399161ee314bc2e75cf8759081743be1236ec4f4d6693e5336fb672c5dc24a8c33585b5fb -9cc24e1d4885545b58463634cc5416022cd19cacfccb4d30eb45296023fd35a458598360f8d7a4003bbaae25e331f155d9d9a5116d3bfb9a95523e51440ca2e0 -088dd844ec6370bf0e55d027a012ae264c45d02f708fa6ad6da6dce29c255df9f6cae0ec38666984b372ab5334cf640b37795cc860de4ae2816e95b21be5ceaf -8a49f90b52a51cc6ff3355f47e0237052b81f6800fd7b802239daf6d8f0b1571a8426944fdbe80c6c1d40e8816b88b8569082ab84c36ff0539d4ff6dce591a26 -ade1c0a7f669880485fd484582903d284b26fa4e2156cff62e4b9265844c4495c495a9157b440e091bea1ab8aaf7760f4510eaa69a6465c0e04ec69ffb9e65d0 -28d44d4e39df9c1a52ecbd3607fee9cec7263328e5d661d3d0e4f62f44acd855ed7ab33cdf7bcb8ae889599bd5c8b3029895b6825696f6af29c239b75a5bb1e6 -345e6ee6c28117e73586c1a2214ae1be07e93fb0ff51e133fb65426fa843be0fb515c187064d0cc206a2fa926d3c902e907670048d931db4c1a44959d366ad93 -b65abe595f70a75bf03d616c2dd959fc7d4e6317cd99cbcec9c58b34766661c7d6766ca1a9c1b327531486c6f941c638c67cd22a7f75e2a37be0e82db8df9f30 -254d30c1372581a1f51c983c80e4b71ccdd28dbf000000ffff0300504b0304140006000800000021000dd1909fb60000001b010000270000007468656d652f74 -68656d652f5f72656c732f7468656d654d616e616765722e786d6c2e72656c73848f4d0ac2301484f78277086f6fd3ba109126dd88d0add40384e4350d363f24 -51eced0dae2c082e8761be9969bb979dc9136332de3168aa1a083ae995719ac16db8ec8e4052164e89d93b64b060828e6f37ed1567914b284d262452282e3198 -720e274a939cd08a54f980ae38a38f56e422a3a641c8bbd048f7757da0f19b017cc524bd62107bd5001996509affb3fd381a89672f1f165dfe514173d9850528 -a2c6cce0239baa4c04ca5bbabac4df000000ffff0300504b01022d0014000600080000002100828abc13fa0000001c0200001300000000000000000000000000 -000000005b436f6e74656e745f54797065735d2e786d6c504b01022d0014000600080000002100a5d6a7e7c0000000360100000b000000000000000000000000 -002b0100005f72656c732f2e72656c73504b01022d00140006000800000021006b799616830000008a0000001c00000000000000000000000000140200007468 -656d652f7468656d652f7468656d654d616e616765722e786d6c504b01022d001400060008000000210096b5ade296060000501b000016000000000000000000 -00000000d10200007468656d652f7468656d652f7468656d65312e786d6c504b01022d00140006000800000021000dd1909fb60000001b010000270000000000 -00000000000000009b0900007468656d652f7468656d652f5f72656c732f7468656d654d616e616765722e786d6c2e72656c73504b050600000000050005005d010000960a00000000} -{\*\colorschememapping 3c3f786d6c2076657273696f6e3d22312e302220656e636f64696e673d225554462d3822207374616e64616c6f6e653d22796573223f3e0d0a3c613a636c724d -617020786d6c6e733a613d22687474703a2f2f736368656d61732e6f70656e786d6c666f726d6174732e6f72672f64726177696e676d6c2f323030362f6d6169 -6e22206267313d226c743122207478313d22646b3122206267323d226c743222207478323d22646b322220616363656e74313d22616363656e74312220616363 -656e74323d22616363656e74322220616363656e74333d22616363656e74332220616363656e74343d22616363656e74342220616363656e74353d22616363656e74352220616363656e74363d22616363656e74362220686c696e6b3d22686c696e6b2220666f6c486c696e6b3d22666f6c486c696e6b222f3e} -{\*\latentstyles\lsdstimax267\lsdlockeddef0\lsdsemihiddendef1\lsdunhideuseddef1\lsdqformatdef0\lsdprioritydef99{\lsdlockedexcept \lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority0 \lsdlocked0 Normal; -\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority9 \lsdlocked0 heading 1;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 2;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 3;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 4; -\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 5;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 6;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 7;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 8;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 9; -\lsdpriority39 \lsdlocked0 toc 1;\lsdpriority39 \lsdlocked0 toc 2;\lsdpriority39 \lsdlocked0 toc 3;\lsdpriority39 \lsdlocked0 toc 4;\lsdpriority39 \lsdlocked0 toc 5;\lsdpriority39 \lsdlocked0 toc 6;\lsdpriority39 \lsdlocked0 toc 7; -\lsdpriority39 \lsdlocked0 toc 8;\lsdpriority39 \lsdlocked0 toc 9;\lsdqformat1 \lsdpriority35 \lsdlocked0 caption;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority10 \lsdlocked0 Title;\lsdpriority1 \lsdlocked0 Default Paragraph Font; -\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority11 \lsdlocked0 Subtitle;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority22 \lsdlocked0 Strong;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority20 \lsdlocked0 Emphasis; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority59 \lsdlocked0 Table Grid;\lsdunhideused0 \lsdlocked0 Placeholder Text;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority1 \lsdlocked0 No Spacing; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading;\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List;\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List;\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List;\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid;\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 1; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 1; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 1;\lsdunhideused0 \lsdlocked0 Revision; -\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority34 \lsdlocked0 List Paragraph;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority29 \lsdlocked0 Quote;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority30 \lsdlocked0 Intense Quote; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 1; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 1; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 2; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 2; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 2; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 2; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 2; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 3; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 3; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 3; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 3; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 3; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 4; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 4; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 4; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 4; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 5; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 5; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 5; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 5; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 5; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 6; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 6; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 6; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 6; -\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 6; -\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority19 \lsdlocked0 Subtle Emphasis;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority21 \lsdlocked0 Intense Emphasis; -\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority31 \lsdlocked0 Subtle Reference;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority32 \lsdlocked0 Intense Reference; -\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority33 \lsdlocked0 Book Title;\lsdpriority37 \lsdlocked0 Bibliography;\lsdqformat1 \lsdpriority39 \lsdlocked0 TOC Heading;}}{\*\datastore 010500000200000018000000 -4d73786d6c322e534158584d4c5265616465722e352e3000000000000000000000060000 -d0cf11e0a1b11ae1000000000000000000000000000000003e000300feff090006000000000000000000000001000000010000000000000000100000feffffff00000000feffffff0000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -fffffffffffffffffdfffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -ffffffffffffffffffffffffffffffff52006f006f007400200045006e00740072007900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016000500ffffffffffffffffffffffffec69d9888b8b3d4c859eaf6cd158be0f0000000000000000000000007071 -40e4695ed001feffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000 -000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffff000000000000000000000000000000000000000000000000 -0000000000000000000000000000000000000000000000000105000000000000}} diff --git a/README.md b/README.md index 98493b019c..6ebc316dbf 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ - + -Branch | Description | Build Status | -|------------|---|--------------| -| **master** | The last released build | ![master branch build status][masterBuildStatus] | -| **next** | The current build (dev) | ![next branch build status][nextBuildStatus] | +|Branch | Description | Build Status | Download link | +|------------|---|--------------|-| +| **master** | The last released build | ![master branch build status][masterBuildStatus] | [stable](https://github.com/rubberduck-vba/Rubberduck/releases/latest) | +| **next** | The current build (dev) | ![next branch build status][nextBuildStatus] | [dev](https://github.com/rubberduck-vba/Rubberduck/releases) | [nextBuildStatus]:https://ci.appveyor.com/api/projects/status/we3pdnkeebo4nlck/branch/next?svg=true [masterBuildStatus]:https://ci.appveyor.com/api/projects/status/we3pdnkeebo4nlck/branch/master?svg=true @@ -19,15 +19,17 @@ Branch | Description | Build Status | [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/rubberduck-vba/Rubberduck.svg)](http://isitmaintained.com/project/rubberduck-vba/Rubberduck "Average time to resolve an issue") [![Percentage of issues still open](http://isitmaintained.com/badge/open/rubberduck-vba/Rubberduck.svg)](http://isitmaintained.com/project/rubberduck-vba/Rubberduck "Percentage of issues still open") > **[rubberduckvba.com](http://rubberduckvba.com)** [Wiki](https://github.com/retailcoder/Rubberduck/wiki) [Rubberduck News](https://rubberduckvba.wordpress.com/) -> contact@rubberduckvba.com +> devs@rubberduckvba.com > Follow [@rubberduckvba](https://twitter.com/rubberduckvba) on Twitter --- * [Attributions](https://github.com/rubberduck-vba/Rubberduck/blob/next/docs/Attributions.md) * [About](https://github.com/rubberduck-vba/Rubberduck/blob/next/docs/About.md) - * [Getting Started](https://github.com/rubberduck-vba/Rubberduck/blob/next/docs/GettingStarted.md) + * [Installing](https://github.com/rubberduck-vba/Rubberduck/wiki/Installing) + * [Getting Started](https://github.com/rubberduck-vba/Rubberduck/blob/next/docs/GettingStarted.md) using Rubberduck * [Contributing](https://github.com/rubberduck-vba/Rubberduck/blob/next/CONTRIBUTING.md) + * [User Testimonials](https://github.com/rubberduck-vba/Rubberduck/blob/next/thanks.md) --- @@ -35,7 +37,7 @@ Branch | Description | Build Status | Rubberduck is a COM add-in for the VBA IDE (VBE). -Copyright (C) 2014-2017 Mathieu Guindon & Christopher McClellan +Copyright (C) 2014-2018 Mathieu Guindon & Christopher McClellan This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/RetailCoder.VBE/Common/TimerHook.cs b/RetailCoder.VBE/Common/TimerHook.cs deleted file mode 100644 index fe29028a51..0000000000 --- a/RetailCoder.VBE/Common/TimerHook.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System; -using System.Diagnostics; -using Rubberduck.Common.WinAPI; - -namespace Rubberduck.Common -{ - public class TimerHook : IAttachable, IDisposable - { - private readonly IntPtr _mainWindowHandle; - private readonly User32.TimerProc _timerProc; - - private IntPtr _timerId; - private bool _isAttached; - - public TimerHook(IntPtr mainWindowHandle) - { - _mainWindowHandle = mainWindowHandle; - _timerProc = TimerCallback; - } - - public bool IsAttached { get { return _isAttached; } } - public event EventHandler MessageReceived; - - public void Attach() - { - if (_isAttached) - { - return; - } - - try - { - var timerId = (IntPtr)Kernel32.GlobalAddAtom(Guid.NewGuid().ToString()); - User32.SetTimer(_mainWindowHandle, timerId, 500, _timerProc); - _isAttached = true; - } - catch (Exception exception) - { - Console.WriteLine(exception); - } - } - - public void Detach() - { - if (!_isAttached) - { - Debug.Assert(_timerId == IntPtr.Zero); - return; - } - - try - { - User32.KillTimer(_mainWindowHandle, _timerId); - Kernel32.GlobalDeleteAtom(_timerId); - - _timerId = IntPtr.Zero; - _isAttached = false; - } - catch (Exception exception) - { - Console.WriteLine(exception); - } - } - - private void OnTick() - { - var handler = MessageReceived; - if (handler != null) - { - handler.Invoke(this, HookEventArgs.Empty); - } - } - - private void TimerCallback(IntPtr hWnd, WindowLongFlags msg, IntPtr timerId, uint time) - { - OnTick(); - } - - public void Dispose() - { - if (_isAttached) - { - Detach(); - } - - Debug.Assert(_timerId == IntPtr.Zero); - } - } -} diff --git a/RetailCoder.VBE/Common/WinAPI/Kernel32.cs b/RetailCoder.VBE/Common/WinAPI/Kernel32.cs deleted file mode 100644 index 70a5643b70..0000000000 --- a/RetailCoder.VBE/Common/WinAPI/Kernel32.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace Rubberduck.Common.WinAPI -{ - /// - /// Exposes Kernel32.dll API. - /// - public static class Kernel32 - { - /// - /// Adds a character string to the global atom table and returns a unique value (an atom) identifying the string. - /// - /// - /// The null-terminated string to be added. - /// The string can have a maximum size of 255 bytes. - /// Strings that differ only in case are considered identical. - /// The case of the first string of this name added to the table is preserved and returned by the GlobalGetAtomName function. - /// - /// If the function succeeds, the return value is the newly created atom. - [DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)] - public static extern ushort GlobalAddAtom(string lpString); - - /// - /// Decrements the reference count of a global string atom. - /// If the atom's reference count reaches zero, GlobalDeleteAtom removes the string associated with the atom from the global atom table. - /// - /// The atom and character string to be deleted. - /// The function always returns (ATOM) 0. - [DllImport("kernel32.dll", SetLastError=true, ExactSpelling=true)] - public static extern ushort GlobalDeleteAtom(IntPtr nAtom); - - /// - /// Retrieves a module handle for the specified module. - /// The module must have been loaded by the calling process. - /// - /// The name of the loaded module (either a .dll or .exe file). - /// If the file name extension is omitted, the default library extension .dll is appended. - /// The file name string can include a trailing point character (.) to indicate that the module name has no extension. - /// The string does not have to specify a path. When specifying a path, be sure to use backslashes (\), not forward slashes (/). - /// The name is compared (case independently) to the names of modules currently mapped into the address space of the calling process. - /// If the function succeeds, the return value is a handle to the specified module. - /// If the function fails, the return value is NULL. To get extended error information, call GetLastError. - /// The returned handle is not global or inheritable. It cannot be duplicated or used by another process. - /// This function must be used carefully in a multithreaded application. There is no guarantee that the module handle remains valid between the time this function returns the handle and the time it is used. - /// For example, suppose that a thread retrieves a module handle, but before it uses the handle, a second thread frees the module. - /// If the system loads another module, it could reuse the module handle that was recently freed. - /// Therefore, the first thread would have a handle to a different module than the one intended. - /// - [DllImport("kernel32.dll", CharSet = CharSet.Auto)] - public static extern IntPtr GetModuleHandle(string lpModuleName); - - - } -} diff --git a/RetailCoder.VBE/Common/WinAPI/User32.cs b/RetailCoder.VBE/Common/WinAPI/User32.cs deleted file mode 100644 index 5a83177980..0000000000 --- a/RetailCoder.VBE/Common/WinAPI/User32.cs +++ /dev/null @@ -1,168 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using System.Text; -using Rubberduck.VBEditor.WindowsApi; - -namespace Rubberduck.Common.WinAPI -{ - public enum KeyModifier : uint - { - ALT = 0x1, - CONTROL = 0x2, - SHIFT = 0x4, - WIN = 0x8 - } - - /// - /// Exposes User32.dll API. - /// - public static class User32 - { - /// - /// Defines a system-wide hot key. - /// - /// A handle to the window that will receive WM_HOTKEY messages generated by the hot key. - /// If this parameter is NULL, WM_HOTKEY messages are posted to the message queue of the calling thread and must be processed in the message loop. - /// The identifier of the hot key. - /// If the hWnd parameter is NULL, then the hot key is associated with the current thread rather than with a particular window. - /// If a hot key already exists with the same hWnd and id parameters - /// The keys that must be pressed in combination with the key specified by the uVirtKey parameter in order to generate the WM_HOTKEY message. - /// The fsModifiers parameter can be a combination of the following values. - /// The virtual-key code of the hot key - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - [DllImport("user32.dll", SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool RegisterHotKey(IntPtr hWnd, IntPtr id, uint fsModifiers, uint vk); - - - /// - /// Frees a hot key previously registered by the calling thread. - /// - /// A handle to the window associated with the hot key to be freed. This parameter should be NULL if the hot key is not associated with a window. - /// The identifier of the hot key to be freed. - /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError. - [DllImport("user32.dll", SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool UnregisterHotKey(IntPtr hWnd, IntPtr id); - - [DllImport("user32.dll")] - public static extern IntPtr SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong); - - [DllImport("user32.dll")] - public static extern IntPtr CallWindowProc(IntPtr lpPrevWndFunc, IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam); - public delegate IntPtr WndProc(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam); - - /// - /// Retrieves a handle to the foreground window (the window with which the user is currently working). - /// The system assigns a slightly higher priority to the thread that creates the foreground window than it does to other threads. - /// - /// The return value is a handle to the foreground window. - /// The foreground window can be NULL in certain circumstances, such as when a window is losing activation. - [DllImport("user32.dll")] - public static extern IntPtr GetForegroundWindow(); - - /// - /// Retrieves the name of the class to which the specified window belongs. - /// - /// A handle to the window and, indirectly, the class to which the window belongs. - /// The class name string (maximum 256 characters). - /// The length of the lpClassName buffer, in characters. - /// The buffer must be large enough to include the terminating null character; otherwise, the class name string is truncated to nMaxCount-1 characters. - /// If the function succeeds, the return value is the number of characters copied to the buffer, not including the terminating null character. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] - public static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount); - - /// - /// Retrieves the identifier of the thread that created the specified window and, optionally, - /// the identifier of the process that created the window. - /// - /// A handle to the window. - /// A pointer to a variable that receives the process identifier. - /// If this parameter is not NULL, GetWindowThreadProcessId copies the identifier of the process to the variable; otherwise, it does not. - /// The return value is the identifier of the thread that created the window. - [DllImport("user32.dll", SetLastError = true)] - public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId); - - /// - /// Retrieves the identifier of the thread that created the specified window. - /// - /// A handle to the window. - /// IntPtr.Zero - /// - [DllImport("user32.dll")] - public static extern uint GetWindowThreadProcessId(IntPtr hWnd, IntPtr processId); - - /// - /// Creates a timer with the specified time-out value. - /// - /// A handle to the window to be associated with the timer. - /// This window must be owned by the calling thread. - /// If a NULL value for hWnd is passed in along with an nIDEvent of an existing timer, - /// that timer will be replaced in the same way that an existing non-NULL hWnd timer will be. - /// A nonzero timer identifier. - /// If the hWnd parameter is NULL, and the nIDEvent does not match an existing timer then it is ignored and a new timer ID is generated. - /// If the hWnd parameter is not NULL and the window specified by hWnd already has a timer with the value nIDEvent, - /// then the existing timer is replaced by the new timer. When SetTimer replaces a timer, the timer is reset. - /// Therefore, a message will be sent after the current time-out value elapses, but the previously set time-out value is ignored. - /// If the call is not intended to replace an existing timer, nIDEvent should be 0 if the hWnd is NULL. - /// The time-out value, in milliseconds. - /// A pointer to the function to be notified when the time-out value elapses. - /// For more information about the function, see TimerProc. If lpTimerFunc is NULL, the system posts a WM_TIMER message to the application queue. - /// The hwnd member of the message's MSG structure contains the value of the hWnd parameter. - /// If the function succeeds and the hWnd parameter is NULL, the return value is an integer identifying the new timer. - /// An application can pass this value to the KillTimer function to destroy the timer. - /// If the function succeeds and the hWnd parameter is not NULL, then the return value is a nonzero integer. - /// An application can pass the value of the nIDEvent parameter to the KillTimer function to destroy the timer. - /// If the function fails to create a timer, the return value is zero. To get extended error information, call GetLastError. - [DllImport("user32.dll", ExactSpelling = true)] - public static extern IntPtr SetTimer(IntPtr hWnd, IntPtr nIDEvent, uint uElapse, TimerProc lpTimerFunc); - public delegate void TimerProc(IntPtr hWnd, WindowLongFlags uMsg, IntPtr nIDEvent, uint dwTime); - - /// - /// Creates a timer with the specified time-out value. - /// - /// A handle to the window to be associated with the timer. - /// This window must be owned by the calling thread. - /// If a NULL value for hWnd is passed in along with an nIDEvent of an existing timer, - /// that timer will be replaced in the same way that an existing non-NULL hWnd timer will be. - /// A nonzero timer identifier. - /// If the hWnd parameter is NULL, and the nIDEvent does not match an existing timer then it is ignored and a new timer ID is generated. - /// If the hWnd parameter is not NULL and the window specified by hWnd already has a timer with the value nIDEvent, - /// then the existing timer is replaced by the new timer. When SetTimer replaces a timer, the timer is reset. - /// Therefore, a message will be sent after the current time-out value elapses, but the previously set time-out value is ignored. - /// If the call is not intended to replace an existing timer, nIDEvent should be 0 if the hWnd is NULL. - /// The time-out value, in milliseconds. - /// A pointer to the function to be notified when the time-out value elapses. - /// For more information about the function, see TimerProc. If lpTimerFunc is NULL, the system posts a WM_TIMER message to the application queue. - /// The hwnd member of the message's MSG structure contains the value of the hWnd parameter. - /// If the function succeeds and the hWnd parameter is NULL, the return value is an integer identifying the new timer. - /// An application can pass this value to the KillTimer function to destroy the timer. - /// If the function succeeds and the hWnd parameter is not NULL, then the return value is a nonzero integer. - /// An application can pass the value of the nIDEvent parameter to the KillTimer function to destroy the timer. - /// If the function fails to create a timer, the return value is zero. To get extended error information, call GetLastError. - [DllImport("user32.dll", ExactSpelling = true)] - public static extern IntPtr SetTimer(IntPtr hWnd, IntPtr nIDEvent, uint uElapse, IntPtr lpTimerFunc); - - /// - /// Destroys the specified timer. - /// - /// A handle to the window associated with the specified timer. - /// This value must be the same as the hWnd value passed to the SetTimer function that created the timer. - /// The timer to be destroyed. - /// If the window handle passed to SetTimer is valid, this parameter must be the same as the nIDEvent value passed to SetTimer. - /// If the application calls SetTimer with hWnd set to NULL, this parameter must be the timer identifier returned by SetTimer. - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - [DllImport("user32.dll", ExactSpelling = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool KillTimer(IntPtr hWnd, IntPtr uIDEvent); - - [DllImport("user32.dll", CharSet = CharSet.Auto)] - internal static extern IntPtr SendMessage(IntPtr hWnd, WM msg, IntPtr wParam, IntPtr lParam); - - public delegate int WindowEnumProc(IntPtr hwnd, IntPtr lparam); - [DllImport("user32.dll")] - public static extern bool EnumChildWindows(IntPtr hwnd, WindowEnumProc func, IntPtr lParam); - } -} diff --git a/RetailCoder.VBE/Navigation/RegexSearchReplace/RegexSearchReplaceModel.cs b/RetailCoder.VBE/Navigation/RegexSearchReplace/RegexSearchReplaceModel.cs deleted file mode 100644 index c7ef8b4045..0000000000 --- a/RetailCoder.VBE/Navigation/RegexSearchReplace/RegexSearchReplaceModel.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Rubberduck.UI; - -namespace Rubberduck.Navigation.RegexSearchReplace -{ - public class RegexSearchReplaceModel : ViewModelBase - { - private string _searchPattern; - public string SearchPattern { get { return _searchPattern; } set { _searchPattern = value; OnPropertyChanged(); } } - - private string _replacePattern; - public string ReplacePattern { get { return _replacePattern; } set { _replacePattern = value; OnPropertyChanged(); } } - - private RegexSearchReplaceScope _searchScope; - public RegexSearchReplaceScope SearchScope { get { return _searchScope; } set { _searchScope = value; OnPropertyChanged(); } } - } -} diff --git a/RetailCoder.VBE/Rubberduck.csproj.DotSettings b/RetailCoder.VBE/Rubberduck.csproj.DotSettings deleted file mode 100644 index fb27ca935d..0000000000 --- a/RetailCoder.VBE/Rubberduck.csproj.DotSettings +++ /dev/null @@ -1,4 +0,0 @@ - - CSharp70 - True - True \ No newline at end of file diff --git a/RetailCoder.VBE/Settings/CodeInspectionConfigProvider.cs b/RetailCoder.VBE/Settings/CodeInspectionConfigProvider.cs deleted file mode 100644 index 7b2715c4fd..0000000000 --- a/RetailCoder.VBE/Settings/CodeInspectionConfigProvider.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Collections.Generic; -using Rubberduck.Parsing.Inspections.Resources; -using Rubberduck.SettingsProvider; -using Rubberduck.Parsing.Inspections.Abstract; -using System.Linq; - -namespace Rubberduck.Settings -{ - public class CodeInspectionConfigProvider : IConfigProvider - { - private readonly IPersistanceService _persister; - private readonly IEnumerable _foundInspections; - - public CodeInspectionConfigProvider(IPersistanceService persister, IEnumerable foundInspections) - { - _persister = persister; - _foundInspections = foundInspections; - } - - public CodeInspectionSettings Create() - { - var prototype = new CodeInspectionSettings(GetDefaultCodeInspections(), new WhitelistedIdentifierSetting[] { }, true); - return _persister.Load(prototype) ?? prototype; - } - - public CodeInspectionSettings CreateDefaults() - { - return new CodeInspectionSettings(GetDefaultCodeInspections(), new WhitelistedIdentifierSetting[] {}, true); - } - - public void Save(CodeInspectionSettings settings) - { - _persister.Save(settings); - } - - public IEnumerable GetDefaultCodeInspections() - { - return _foundInspections.Select(inspection => new CodeInspectionSetting(inspection)); - } - } -} diff --git a/RetailCoder.VBE/Settings/GeneralSettings.cs b/RetailCoder.VBE/Settings/GeneralSettings.cs deleted file mode 100644 index fcdd5e57b9..0000000000 --- a/RetailCoder.VBE/Settings/GeneralSettings.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using NLog; -using System.Xml.Serialization; -using Rubberduck.Common; - -namespace Rubberduck.Settings -{ - public interface IGeneralSettings - { - DisplayLanguageSetting Language { get; set; } - bool ShowSplash { get; set; } - bool CheckVersion { get; set; } - bool SmartIndenterPrompted { get; set; } - bool AutoSaveEnabled { get; set; } - int AutoSavePeriod { get; set; } - int MinimumLogLevel { get; set; } - bool SourceControlEnabled { get; set; } - } - - [XmlType(AnonymousType = true)] - public class GeneralSettings : IGeneralSettings, IEquatable - { - public DisplayLanguageSetting Language { get; set; } - public bool ShowSplash { get; set; } - public bool CheckVersion { get; set; } - public bool SmartIndenterPrompted { get; set; } - public bool AutoSaveEnabled { get; set; } - public int AutoSavePeriod { get; set; } - - private int _logLevel; - public int MinimumLogLevel - { - get { return _logLevel; } - set - { - if (value < LogLevelHelper.MinLogLevel()) - { - _logLevel = LogLevelHelper.MinLogLevel(); - } - else if (value > LogLevelHelper.MaxLogLevel()) - { - _logLevel = LogLevelHelper.MaxLogLevel(); - } - else - { - _logLevel = value; - } - } - } - - public bool SourceControlEnabled { get; set; } - - public GeneralSettings() - { - Language = new DisplayLanguageSetting("en-US"); - ShowSplash = true; - CheckVersion = true; - SmartIndenterPrompted = false; - AutoSaveEnabled = false; - AutoSavePeriod = 10; - MinimumLogLevel = LogLevel.Off.Ordinal; - SourceControlEnabled = false; - } - - public bool Equals(GeneralSettings other) - { - return other != null && - Language.Equals(other.Language) && - ShowSplash == other.ShowSplash && - CheckVersion == other.CheckVersion && - SmartIndenterPrompted == other.SmartIndenterPrompted && - AutoSaveEnabled == other.AutoSaveEnabled && - AutoSavePeriod == other.AutoSavePeriod && - MinimumLogLevel == other.MinimumLogLevel && - SourceControlEnabled == other.SourceControlEnabled; - } - } -} \ No newline at end of file diff --git a/RetailCoder.VBE/Settings/HotkeyConfigProvider.cs b/RetailCoder.VBE/Settings/HotkeyConfigProvider.cs deleted file mode 100644 index 22989db436..0000000000 --- a/RetailCoder.VBE/Settings/HotkeyConfigProvider.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Rubberduck.SettingsProvider; - -namespace Rubberduck.Settings -{ - public class HotkeyConfigProvider : IConfigProvider - { - private readonly IPersistanceService _persister; - - public HotkeyConfigProvider(IPersistanceService persister) - { - _persister = persister; - } - - public HotkeySettings Create() - { - var prototype = new HotkeySettings(); - return _persister.Load(prototype) ?? prototype; - } - - public HotkeySettings CreateDefaults() - { - return new HotkeySettings(); - } - - public void Save(HotkeySettings settings) - { - _persister.Save(settings); - } - } -} diff --git a/RetailCoder.VBE/Settings/HotkeySettings.cs b/RetailCoder.VBE/Settings/HotkeySettings.cs deleted file mode 100644 index 40c9b012b1..0000000000 --- a/RetailCoder.VBE/Settings/HotkeySettings.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Rubberduck.Common.Hotkeys; - -namespace Rubberduck.Settings -{ - public interface IHotkeySettings - { - HotkeySetting[] Settings { get; set; } - } - - public class HotkeySettings : IHotkeySettings, IEquatable - { - private static readonly HotkeySetting[] Defaults = - { - new HotkeySetting{Name=RubberduckHotkey.ParseAll.ToString(), IsEnabled=true, HasCtrlModifier = true, Key1="`" }, - new HotkeySetting{Name=RubberduckHotkey.IndentProcedure.ToString(), IsEnabled=true, HasCtrlModifier = true, Key1="P" }, - new HotkeySetting{Name=RubberduckHotkey.IndentModule.ToString(), IsEnabled=true, HasCtrlModifier = true, Key1="M" }, - new HotkeySetting{Name=RubberduckHotkey.CodeExplorer.ToString(), IsEnabled=true, HasCtrlModifier = true, Key1="R" }, - new HotkeySetting{Name=RubberduckHotkey.FindSymbol.ToString(), IsEnabled=true, HasCtrlModifier = true, Key1="T" }, - new HotkeySetting{Name=RubberduckHotkey.InspectionResults.ToString(), IsEnabled=true, HasCtrlModifier = true, HasShiftModifier = true, Key1="I" }, - new HotkeySetting{Name=RubberduckHotkey.TestExplorer.ToString(), IsEnabled=true, HasCtrlModifier = true, HasShiftModifier = true, Key1="T" }, - new HotkeySetting{Name=RubberduckHotkey.RefactorMoveCloserToUsage.ToString(), IsEnabled=true, HasCtrlModifier = true, HasShiftModifier = true, Key1="C" }, - new HotkeySetting{Name=RubberduckHotkey.RefactorRename.ToString(), IsEnabled=true, HasCtrlModifier = true, HasShiftModifier = true, Key1="R" }, - new HotkeySetting{Name=RubberduckHotkey.RefactorExtractMethod.ToString(), IsEnabled=true, HasCtrlModifier = true, HasShiftModifier = true, Key1="M" }, - new HotkeySetting{Name=RubberduckHotkey.SourceControl.ToString(), IsEnabled=true, HasCtrlModifier = true, HasShiftModifier = true, Key1="D6" }, - new HotkeySetting{Name=RubberduckHotkey.RefactorEncapsulateField.ToString(), IsEnabled=true, HasCtrlModifier = true, HasShiftModifier = true, Key1="F" }, - new HotkeySetting{Name=RubberduckHotkey.ExportActiveProject.ToString(), IsEnabled = true, HasCtrlModifier = true, HasShiftModifier = true, Key1="E" } - }; - - private HashSet _settings; - - public HotkeySettings() - { - Settings = Defaults.ToArray(); - } - - public HotkeySetting[] Settings - { - get { return _settings.ToArray(); } - set - { - if (value == null || value.Length == 0) - { - _settings = new HashSet(Defaults); - return; - } - _settings = new HashSet(); - var incoming = value.ToList(); - //Make sure settings are valid to keep trash out of the config file. - RubberduckHotkey assigned; - incoming.RemoveAll(h => !Enum.TryParse(h.Name, out assigned) || !IsValid(h)); - - //Only take the first setting if multiple definitions are found. - foreach (var setting in incoming.GroupBy(s => s.Name).Select(hotkey => hotkey.First())) - { - //Only allow one hotkey to be enabled with the same key combination. - setting.IsEnabled &= !IsDuplicate(setting); - _settings.Add(setting); - } - - //Merge any hotkeys that weren't found in the input. - foreach (var setting in Defaults.Where(setting => _settings.FirstOrDefault(s => s.Name.Equals(setting.Name)) == null)) - { - setting.IsEnabled &= !IsDuplicate(setting); - _settings.Add(setting); - } - } - } - - private bool IsDuplicate(HotkeySetting candidate) - { - return _settings.FirstOrDefault( - s => - s.Key1 == candidate.Key1 && - s.Key2 == candidate.Key2 && - s.HasAltModifier == candidate.HasAltModifier && - s.HasCtrlModifier == candidate.HasCtrlModifier && - s.HasShiftModifier == candidate.HasShiftModifier) != null; - } - - public bool Equals(HotkeySettings other) - { - return other != null && Settings.SequenceEqual(other.Settings); - } - - private static bool IsValid(HotkeySetting candidate) - { - //This feels a bit sleazy... - try - { - // ReSharper disable once UnusedVariable - var test = new Hotkey(new IntPtr(), candidate.ToString(), null); - return true; - } - catch - { - return false; - } - } - } -} diff --git a/RetailCoder.VBE/Settings/MinimumLogLevel.cs b/RetailCoder.VBE/Settings/MinimumLogLevel.cs deleted file mode 100644 index 33d41d713c..0000000000 --- a/RetailCoder.VBE/Settings/MinimumLogLevel.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Globalization; -using Rubberduck.UI; - -namespace Rubberduck.Settings -{ - public sealed class MinimumLogLevel - { - private readonly int _ordinal; - private readonly string _name; - - public MinimumLogLevel(int ordinal, string logLevelName) - { - _ordinal = ordinal; - _name = RubberduckUI.ResourceManager.GetString("GeneralSettings_" + logLevelName + "LogLevel", CultureInfo.CurrentUICulture); - } - - public int Ordinal - { - get - { - return _ordinal; - } - } - - public string Name - { - get - { - return _name; - } - } - } -} diff --git a/RetailCoder.VBE/Settings/RubberduckHotkey.cs b/RetailCoder.VBE/Settings/RubberduckHotkey.cs deleted file mode 100644 index c15d5822f3..0000000000 --- a/RetailCoder.VBE/Settings/RubberduckHotkey.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Rubberduck.Settings -{ - public enum RubberduckHotkey - { - None, - ParseAll, - IndentProcedure, - IndentModule, - CodeExplorer, - FindSymbol, - InspectionResults, - TestExplorer, - RefactorMoveCloserToUsage, - RefactorRename, - RefactorExtractMethod, - RefactorEncapsulateField, - SourceControl, - ExportActiveProject - } -} diff --git a/RetailCoder.VBE/UI/CodeExplorer/Commands/CommitCommand.cs b/RetailCoder.VBE/UI/CodeExplorer/Commands/CommitCommand.cs deleted file mode 100644 index 37ceb77aa8..0000000000 --- a/RetailCoder.VBE/UI/CodeExplorer/Commands/CommitCommand.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Diagnostics; -using NLog; -using Rubberduck.Navigation.CodeExplorer; -using Rubberduck.UI.Command; -using Rubberduck.UI.SourceControl; - -namespace Rubberduck.UI.CodeExplorer.Commands -{ - [CodeExplorerCommand] - public class CommitCommand : CommandBase - { - private readonly IDockablePresenter _presenter; - - public CommitCommand(IDockablePresenter presenter) : base(LogManager.GetCurrentClassLogger()) - { - _presenter = presenter; - } - - protected override bool EvaluateCanExecute(object parameter) - { - return parameter is CodeExplorerComponentViewModel; - } - - protected override void OnExecute(object parameter) - { - _presenter.Show(); - - var panel = _presenter.UserControl as SourceControlPanel; - Debug.Assert(panel != null); - - var vm = panel.ViewModel; - if (vm != null) - { - vm.SetTab(SourceControlTab.Changes); - } - } - } -} diff --git a/RetailCoder.VBE/UI/CodeExplorer/Commands/OpenProjectPropertiesCommand.cs b/RetailCoder.VBE/UI/CodeExplorer/Commands/OpenProjectPropertiesCommand.cs deleted file mode 100644 index 2e0299bc59..0000000000 --- a/RetailCoder.VBE/UI/CodeExplorer/Commands/OpenProjectPropertiesCommand.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System.Runtime.InteropServices; -using NLog; -using Rubberduck.Navigation.CodeExplorer; -using Rubberduck.UI.Command; -using Rubberduck.VBEditor.SafeComWrappers.Abstract; - -namespace Rubberduck.UI.CodeExplorer.Commands -{ - [CodeExplorerCommand] - public class OpenProjectPropertiesCommand : CommandBase - { - private readonly IVBE _vbe; - - public OpenProjectPropertiesCommand(IVBE vbe) : base(LogManager.GetCurrentClassLogger()) - { - _vbe = vbe; - } - - protected override bool EvaluateCanExecute(object parameter) - { - try - { - var projects = _vbe.VBProjects; - { - return parameter != null || projects.Count == 1; - } - } - catch (COMException) - { - return false; - } - } - - protected override void OnExecute(object parameter) - { - const int openProjectPropertiesId = 2578; - - var projects = _vbe.VBProjects; - { - var commandBars = _vbe.CommandBars; - var command = commandBars.FindControl(openProjectPropertiesId); - - if (projects.Count == 1) - { - command.Execute(); - return; - } - - var node = parameter as CodeExplorerItemViewModel; - while (!(node is ICodeExplorerDeclarationViewModel)) - { - // ReSharper disable once PossibleNullReferenceException - node = node.Parent; // the project node is an ICodeExplorerDeclarationViewModel--no worries here - } - - try - { - _vbe.ActiveVBProject = node.GetSelectedDeclaration().Project; - } - catch (COMException) - { - return; // the project was probably removed from the VBE, but not from the CE - } - - command.Execute(); - } - } - } -} diff --git a/RetailCoder.VBE/UI/CodeExplorer/Commands/UndoCommand.cs b/RetailCoder.VBE/UI/CodeExplorer/Commands/UndoCommand.cs deleted file mode 100644 index 8c3a513060..0000000000 --- a/RetailCoder.VBE/UI/CodeExplorer/Commands/UndoCommand.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using NLog; -using Rubberduck.Navigation.CodeExplorer; -using Rubberduck.SourceControl; -using Rubberduck.UI.Command; -using Rubberduck.UI.SourceControl; -using Rubberduck.VBEditor.SafeComWrappers; - -namespace Rubberduck.UI.CodeExplorer.Commands -{ - [CodeExplorerCommand] - public class UndoCommand : CommandBase - { - private readonly IDockablePresenter _presenter; - private readonly IMessageBox _messageBox; - - public UndoCommand(IDockablePresenter presenter, IMessageBox messageBox) : base(LogManager.GetCurrentClassLogger()) - { - _presenter = presenter; - _messageBox = messageBox; - } - - protected override bool EvaluateCanExecute(object parameter) - { - var node = parameter as CodeExplorerComponentViewModel; - if (node == null) - { - return false; - } - - var panel = _presenter.UserControl as SourceControlPanel; - Debug.Assert(panel != null); - - var panelViewModel = panel.ViewModel; - if (panelViewModel == null) - { - return false; - } - - panelViewModel.SetTab(SourceControlTab.Changes); - var viewModel = panelViewModel.SelectedItem.ViewModel as ChangesPanelViewModel; - - return viewModel != null && viewModel.IncludedChanges != null && - viewModel.IncludedChanges.Select(s => s.FilePath).Contains(GetFileName(node)); - } - - protected override void OnExecute(object parameter) - { - var panel = _presenter.UserControl as SourceControlPanel; - Debug.Assert(panel != null); - - var panelViewModel = panel.ViewModel; - if (panelViewModel == null) - { - return; - } - - panelViewModel.SetTab(SourceControlTab.Changes); - var viewModel = panelViewModel.SelectedItem.ViewModel as ChangesPanelViewModel; - if (viewModel == null) - { - return; - } - - var fileName = GetFileName((ICodeExplorerDeclarationViewModel)parameter); - var result = _messageBox.Show(string.Format(RubberduckUI.SourceControl_UndoPrompt, fileName), - RubberduckUI.SourceControl_UndoTitle, System.Windows.Forms.MessageBoxButtons.OKCancel, - System.Windows.Forms.MessageBoxIcon.Warning, System.Windows.Forms.MessageBoxDefaultButton.Button2); - - if (result != System.Windows.Forms.DialogResult.OK) - { - return; - } - - viewModel.UndoChangesToolbarButtonCommand.Execute(new FileStatusEntry(fileName, FileStatus.Modified)); - _presenter.Show(); - } - - private string GetFileName(ICodeExplorerDeclarationViewModel node) - { - var component = node.Declaration.QualifiedName.QualifiedModuleName.Component; - - var fileExtensions = new Dictionary - { - { ComponentType.StandardModule, ".bas" }, - { ComponentType.ClassModule, ".cls" }, - { ComponentType.Document, ".cls" }, - { ComponentType.UserForm, ".frm" } - }; - - string ext; - fileExtensions.TryGetValue(component.Type, out ext); - return component.Name + ext; - } - } -} \ No newline at end of file diff --git a/RetailCoder.VBE/UI/Command/MenuItems/SourceControlCommandMenuItem.cs b/RetailCoder.VBE/UI/Command/MenuItems/SourceControlCommandMenuItem.cs deleted file mode 100644 index c762fa4990..0000000000 --- a/RetailCoder.VBE/UI/Command/MenuItems/SourceControlCommandMenuItem.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Rubberduck.UI.Command.MenuItems.ParentMenus; - -namespace Rubberduck.UI.Command.MenuItems -{ - public class SourceControlCommandMenuItem : CommandMenuItemBase - { - public SourceControlCommandMenuItem(CommandBase command) - : base(command) - { - } - - public override string Key => "ToolsMenu_SourceControl"; - public override int DisplayOrder => (int)ToolsMenuItemDisplayOrder.SourceControl; - } -} diff --git a/RetailCoder.VBE/UI/Command/MenuItems/UiDispatcher.cs b/RetailCoder.VBE/UI/Command/MenuItems/UiDispatcher.cs deleted file mode 100644 index 84626a911c..0000000000 --- a/RetailCoder.VBE/UI/Command/MenuItems/UiDispatcher.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Threading; -using System.Windows.Threading; -using NLog; - -namespace Rubberduck.UI.Command.MenuItems -{ - public static class UiDispatcher - { - // thanks to Pellared on http://stackoverflow.com/a/12909070/1188513 - - private static SynchronizationContext UiContext { get; set; } - - public static void Initialize() - { - if (UiContext == null) - { - UiContext = SynchronizationContext.Current; - } - } - - /// - /// Invokes an action asynchronously on the UI thread. - /// - /// The action that must be executed. - public static void InvokeAsync(Action action) - { - CheckInitialization(); - - UiContext.Post(x => action(), null); - } - - /// - /// Executes an action on the UI thread. If this method is called - /// from the UI thread, the action is executed immendiately. If the - /// method is called from another thread, the action will be enqueued - /// on the UI thread's dispatcher and executed asynchronously. - /// For additional operations on the UI thread, you can get a - /// reference to the UI thread's context thanks to the property - /// . - /// - /// The action that will be executed on the UI - /// thread. - public static void Invoke(Action action) - { - CheckInitialization(); - - if (UiContext == SynchronizationContext.Current) - { - action(); - } - else - { - InvokeAsync(action); - } - } - - private static void CheckInitialization() - { - if (UiContext == null) throw new InvalidOperationException("UiDispatcher is not initialized. Invoke Initialize() from UI thread first."); - } - - public static void Shutdown() - { - Invoke(() => - { - LogManager.GetCurrentClassLogger().Debug("Invoking shutdown on UI thread dispatcher."); - Dispatcher.CurrentDispatcher.InvokeShutdown(); - }); - } - } -} diff --git a/RetailCoder.VBE/UI/Command/Refactorings/RefactorIntroduceFieldCommand.cs b/RetailCoder.VBE/UI/Command/Refactorings/RefactorIntroduceFieldCommand.cs deleted file mode 100644 index 8c57b22c3b..0000000000 --- a/RetailCoder.VBE/UI/Command/Refactorings/RefactorIntroduceFieldCommand.cs +++ /dev/null @@ -1,62 +0,0 @@ -using Rubberduck.Common; -using Rubberduck.Parsing.Symbols; -using Rubberduck.Parsing.VBA; -using Rubberduck.Refactorings.IntroduceField; -using Rubberduck.VBEditor.SafeComWrappers.Abstract; - -namespace Rubberduck.UI.Command.Refactorings -{ - public class RefactorIntroduceFieldCommand : RefactorCommandBase - { - private readonly RubberduckParserState _state; - private readonly IMessageBox _messageBox; - - public RefactorIntroduceFieldCommand (IVBE vbe, RubberduckParserState state, IMessageBox messageBox) - :base(vbe) - { - _state = state; - _messageBox = messageBox; - } - - protected override bool EvaluateCanExecute(object parameter) - { - var pane = Vbe.ActiveCodePane; - { - if (_state.Status != ParserState.Ready || pane.IsWrappingNullReference) - { - return false; - } - - var selection = pane.GetQualifiedSelection(); - if (!selection.HasValue) - { - return false; - } - - var target = _state.AllUserDeclarations.FindVariable(selection.Value); - - return target != null && target.ParentScopeDeclaration.DeclarationType.HasFlag(DeclarationType.Member); - } - } - - protected override void OnExecute(object parameter) - { - var pane = Vbe.ActiveCodePane; - { - if (pane.IsWrappingNullReference) - { - return; - } - - var selection = pane.GetQualifiedSelection(); - if (!selection.HasValue) - { - return; - } - - var refactoring = new IntroduceFieldRefactoring(Vbe, _state, _messageBox); - refactoring.Refactor(selection.Value); - } - } - } -} diff --git a/RetailCoder.VBE/UI/Command/Refactorings/RefactorIntroduceParameterCommand.cs b/RetailCoder.VBE/UI/Command/Refactorings/RefactorIntroduceParameterCommand.cs deleted file mode 100644 index ee27da508f..0000000000 --- a/RetailCoder.VBE/UI/Command/Refactorings/RefactorIntroduceParameterCommand.cs +++ /dev/null @@ -1,62 +0,0 @@ -using Rubberduck.Common; -using Rubberduck.Parsing.Symbols; -using Rubberduck.Parsing.VBA; -using Rubberduck.Refactorings.IntroduceParameter; -using Rubberduck.VBEditor.SafeComWrappers.Abstract; - -namespace Rubberduck.UI.Command.Refactorings -{ - public class RefactorIntroduceParameterCommand : RefactorCommandBase - { - private readonly RubberduckParserState _state; - private readonly IMessageBox _messageBox; - - public RefactorIntroduceParameterCommand (IVBE vbe, RubberduckParserState state, IMessageBox messageBox) - :base(vbe) - { - _state = state; - _messageBox = messageBox; - } - - protected override bool EvaluateCanExecute(object parameter) - { - var pane = Vbe.ActiveCodePane; - { - if (_state.Status != ParserState.Ready || pane.IsWrappingNullReference) - { - return false; - } - - var selection = pane.GetQualifiedSelection(); - if (!selection.HasValue) - { - return false; - } - - var target = _state.AllUserDeclarations.FindVariable(selection.Value); - - return target != null && target.ParentScopeDeclaration.DeclarationType.HasFlag(DeclarationType.Member); - } - } - - protected override void OnExecute(object parameter) - { - var pane = Vbe.ActiveCodePane; - { - if (pane.IsWrappingNullReference) - { - return; - } - - var selection = pane.GetQualifiedSelection(); - if (!selection.HasValue) - { - return; - } - - var refactoring = new IntroduceParameterRefactoring(Vbe, _state, _messageBox); - refactoring.Refactor(selection.Value); - } - } - } -} diff --git a/RetailCoder.VBE/UI/Command/Refactorings/RefactorReorderParametersCommand.cs b/RetailCoder.VBE/UI/Command/Refactorings/RefactorReorderParametersCommand.cs deleted file mode 100644 index 165343795a..0000000000 --- a/RetailCoder.VBE/UI/Command/Refactorings/RefactorReorderParametersCommand.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System.Linq; -using System.Runtime.InteropServices; -using Rubberduck.Common; -using Rubberduck.Parsing.Symbols; -using Rubberduck.Parsing.VBA; -using Rubberduck.Refactorings.ReorderParameters; -using Rubberduck.UI.Refactorings.ReorderParameters; -using Rubberduck.VBEditor; -using Rubberduck.VBEditor.SafeComWrappers.Abstract; - -namespace Rubberduck.UI.Command.Refactorings -{ - [ComVisible(false)] - public class RefactorReorderParametersCommand : RefactorCommandBase - { - private readonly RubberduckParserState _state; - private readonly IMessageBox _msgbox; - - public RefactorReorderParametersCommand(IVBE vbe, RubberduckParserState state, IMessageBox msgbox) - : base (vbe) - { - _state = state; - _msgbox = msgbox; - } - - private static readonly DeclarationType[] ValidDeclarationTypes = - { - DeclarationType.Event, - DeclarationType.Function, - DeclarationType.Procedure, - DeclarationType.PropertyGet, - DeclarationType.PropertyLet, - DeclarationType.PropertySet - }; - - protected override bool EvaluateCanExecute(object parameter) - { - var pane = Vbe.ActiveCodePane; - { - if (pane.IsWrappingNullReference || _state.Status != ParserState.Ready) - { - return false; - } - - var selection = pane.GetQualifiedSelection(); - var member = _state.AllUserDeclarations.FindTarget(selection.Value, ValidDeclarationTypes); - if (member == null) - { - return false; - } - - var parameters = _state.AllUserDeclarations.Where(item => item.DeclarationType == DeclarationType.Parameter && member.Equals(item.ParentScopeDeclaration)).ToList(); - var canExecute = (member.DeclarationType == DeclarationType.PropertyLet || member.DeclarationType == DeclarationType.PropertySet) - ? parameters.Count > 2 - : parameters.Count > 1; - - return canExecute; - } - } - - protected override void OnExecute(object parameter) - { - var pane = Vbe.ActiveCodePane; - var module = pane.CodeModule; - { - if (pane.IsWrappingNullReference) - { - return; - } - var selection = new QualifiedSelection(new QualifiedModuleName(module.Parent), pane.Selection); - - using (var view = new ReorderParametersDialog(new ReorderParametersViewModel(_state))) - { - var factory = new ReorderParametersPresenterFactory(Vbe, view, _state, _msgbox); - var refactoring = new ReorderParametersRefactoring(Vbe, factory, _msgbox); - refactoring.Refactor(selection); - } - } - } - } -} diff --git a/RetailCoder.VBE/UI/Command/ReparseCommand.cs b/RetailCoder.VBE/UI/Command/ReparseCommand.cs deleted file mode 100644 index b5ecbcc202..0000000000 --- a/RetailCoder.VBE/UI/Command/ReparseCommand.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Runtime.InteropServices; -using NLog; -using Rubberduck.Parsing.VBA; -using Rubberduck.Settings; -using Rubberduck.UI.CodeExplorer.Commands; - -namespace Rubberduck.UI.Command -{ - [ComVisible(false)] - [CodeExplorerCommand] - public class ReparseCommand : CommandBase - { - private readonly RubberduckParserState _state; - - public ReparseCommand(RubberduckParserState state) : base(LogManager.GetCurrentClassLogger()) - { - _state = state; - } - - public override RubberduckHotkey Hotkey - { - get { return RubberduckHotkey.ParseAll; } - } - - protected override bool EvaluateCanExecute(object parameter) - { - return _state.Status == ParserState.Pending - || _state.Status == ParserState.Ready - || _state.Status == ParserState.Error - || _state.Status == ParserState.ResolverError; - } - - protected override void OnExecute(object parameter) - { - _state.OnParseRequested(this); - } - } -} diff --git a/RetailCoder.VBE/UI/Command/SourceControlCommand.cs b/RetailCoder.VBE/UI/Command/SourceControlCommand.cs deleted file mode 100644 index 384af6ad34..0000000000 --- a/RetailCoder.VBE/UI/Command/SourceControlCommand.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Runtime.InteropServices; -using NLog; -using Rubberduck.Settings; - -namespace Rubberduck.UI.Command -{ - /// - /// A command that displays the Source Control panel. - /// - [ComVisible(false)] - public class SourceControlCommand : CommandBase - { - private readonly IDockablePresenter _presenter; - - public SourceControlCommand(IDockablePresenter presenter) : base(LogManager.GetCurrentClassLogger()) - { - _presenter = presenter; - } - - protected override void OnExecute(object parameter) - { - _presenter.Show(); - } - - public override RubberduckHotkey Hotkey - { - get { return RubberduckHotkey.SourceControl; } - } - } -} diff --git a/RetailCoder.VBE/UI/DockableWindowHost.Designer.cs b/RetailCoder.VBE/UI/DockableWindowHost.Designer.cs deleted file mode 100644 index 59f2d5224d..0000000000 --- a/RetailCoder.VBE/UI/DockableWindowHost.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.ComponentModel; - -namespace Rubberduck.UI -{ - partial class _DockableWindowHost - { - /// - /// Required designer variable. - /// - private IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - } - - #endregion - } -} diff --git a/RetailCoder.VBE/UI/DockableWindowHost.cs b/RetailCoder.VBE/UI/DockableWindowHost.cs deleted file mode 100644 index e5122ed7ce..0000000000 --- a/RetailCoder.VBE/UI/DockableWindowHost.cs +++ /dev/null @@ -1,212 +0,0 @@ -using System; -using System.ComponentModel; -using System.Diagnostics; -using System.Drawing; -using System.Runtime.InteropServices; -using System.Windows.Forms; -using Rubberduck.Common.WinAPI; -using Rubberduck.VBEditor; -using Rubberduck.VBEditor.WindowsApi; -using User32 = Rubberduck.Common.WinAPI.User32; - -namespace Rubberduck.UI -{ - [ComVisible(true)] - [Guid(RubberduckGuid.DockableWindowHostGuid)] - [ProgId(RubberduckProgId.DockableWindowHostProgId)] - [EditorBrowsable(EditorBrowsableState.Never)] - //Nothing breaks because we declare a ProgId - // ReSharper disable once InconsistentNaming - //Underscores make classes invisible to VB6 object explorer - public partial class _DockableWindowHost : UserControl - { - public static string RegisteredProgId => RubberduckProgId.DockableWindowHostProgId; - - // ReSharper disable UnusedAutoPropertyAccessor.Local - [StructLayout(LayoutKind.Sequential)] - private struct Rect - { - public int Left { get; set; } - public int Top { get; set; } - public int Right { get; set; } - public int Bottom { get; set; } - } - // ReSharper restore UnusedAutoPropertyAccessor.Local - - [StructLayout(LayoutKind.Explicit)] - private struct LParam - { - [FieldOffset(0)] - public uint Value; - [FieldOffset(0)] - public readonly ushort LowWord; - [FieldOffset(2)] - public readonly ushort HighWord; - } - - [DllImport("User32.dll")] - static extern IntPtr GetParent(IntPtr hWnd); - - [DllImport("User32.dll", EntryPoint = "GetClientRect")] - static extern int GetClientRect(IntPtr hWnd, ref Rect lpRect); - - private IntPtr _parentHandle; - private ParentWindow _subClassingWindow; - private GCHandle _thisHandle; - - internal void AddUserControl(UserControl control, IntPtr vbeHwnd) - { - _parentHandle = GetParent(Handle); - _subClassingWindow = new ParentWindow(vbeHwnd, new IntPtr(GetHashCode()), _parentHandle); - _subClassingWindow.CallBackEvent += OnCallBackEvent; - - //DO NOT REMOVE THIS CALL. Dockable windows are instantiated by the VBE, not directly by RD. On top of that, - //since we have to inherit from UserControl we don't have to keep handling window messages until the VBE gets - //around to destroying the control's host or it results in an access violation when the base class is disposed. - //We need to manually call base.Dispose() ONLY in response to a WM_DESTROY message. - _thisHandle = GCHandle.Alloc(this, GCHandleType.Normal); - - if (control != null) - { - control.Dock = DockStyle.Fill; - Controls.Add(control); - } - AdjustSize(); - } - - private void OnCallBackEvent(object sender, SubClassingWindowEventArgs e) - { - if (!e.Closing) - { - var param = new LParam {Value = (uint) e.LParam}; - Size = new Size(param.LowWord, param.HighWord); - } - else - { - Debug.WriteLine("DockableWindowHost removed event handler."); - _subClassingWindow.CallBackEvent -= OnCallBackEvent; - } - } - - private void AdjustSize() - { - var rect = new Rect(); - if (GetClientRect(_parentHandle, ref rect) != 0) - { - Size = new Size(rect.Right - rect.Left, rect.Bottom - rect.Top); - } - } - - protected override bool ProcessKeyPreview(ref Message m) - { - const int wmKeydown = 0x100; - var result = false; - - var hostedUserControl = (UserControl)Controls[0]; - - if (m.Msg == wmKeydown) - { - var pressedKey = (Keys)m.WParam; - switch (pressedKey) - { - case Keys.Tab: - switch (ModifierKeys) - { - case Keys.None: - SelectNextControl(hostedUserControl.ActiveControl, true, true, true, true); - result = true; - break; - case Keys.Shift: - SelectNextControl(hostedUserControl.ActiveControl, false, true, true, true); - result = true; - break; - } - break; - case Keys.Return: - if (hostedUserControl.ActiveControl.GetType() == typeof(Button)) - { - var activeButton = (Button)hostedUserControl.ActiveControl; - activeButton.PerformClick(); - } - break; - } - } - - if (!result) - { - result = base.ProcessKeyPreview(ref m); - } - return result; - } - - protected override void DefWndProc(ref Message m) - { - //See the comment in the ctor for why we have to listen for this. - if (m.Msg == (int) WM.DESTROY) - { - Debug.WriteLine("DockableWindowHost received WM.DESTROY."); - _thisHandle.Free(); - } - base.DefWndProc(ref m); - } - - //override - - public void Release() - { - Debug.WriteLine("DockableWindowHost release called."); - _subClassingWindow.Dispose(); - } - - protected override void DestroyHandle() - { - Debug.WriteLine("DockableWindowHost DestroyHandle called."); - base.DestroyHandle(); - } - - [ComVisible(false)] - public class ParentWindow : SubclassingWindow - { - public event SubClassingWindowEventHandler CallBackEvent; - public delegate void SubClassingWindowEventHandler(object sender, SubClassingWindowEventArgs e); - - private readonly IntPtr _vbeHwnd; - - private void OnCallBackEvent(SubClassingWindowEventArgs e) - { - if (CallBackEvent != null) - { - CallBackEvent(this, e); - } - } - - public ParentWindow(IntPtr vbeHwnd, IntPtr id, IntPtr handle) : base(id, handle) - { - _vbeHwnd = vbeHwnd; - } - - private bool _closing; - public override int SubClassProc(IntPtr hWnd, IntPtr msg, IntPtr wParam, IntPtr lParam, IntPtr uIdSubclass, IntPtr dwRefData) - { - switch ((uint)msg) - { - case (uint)WM.SIZE: - var args = new SubClassingWindowEventArgs(lParam); - if (!_closing) OnCallBackEvent(args); - break; - case (uint)WM.SETFOCUS: - if (!_closing) User32.SendMessage(_vbeHwnd, WM.RUBBERDUCK_CHILD_FOCUS, Hwnd, Hwnd); - break; - case (uint)WM.KILLFOCUS: - if (!_closing) User32.SendMessage(_vbeHwnd, WM.RUBBERDUCK_CHILD_FOCUS, Hwnd, IntPtr.Zero); - break; - case (uint)WM.RUBBERDUCK_SINKING: - OnCallBackEvent(new SubClassingWindowEventArgs(lParam) { Closing = true }); - _closing = true; - break; - } - return base.SubClassProc(hWnd, msg, wParam, lParam, uIdSubclass, dwRefData); - } - } - } -} diff --git a/RetailCoder.VBE/UI/FindSymbol/SearchResult.cs b/RetailCoder.VBE/UI/FindSymbol/SearchResult.cs deleted file mode 100644 index 32a1f73923..0000000000 --- a/RetailCoder.VBE/UI/FindSymbol/SearchResult.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Windows.Media.Imaging; -using Rubberduck.Parsing.Symbols; - -namespace Rubberduck.UI.FindSymbol -{ - public class SearchResult - { - private readonly Declaration _declaration; - private readonly BitmapImage _icon; - - public SearchResult(Declaration declaration, BitmapImage icon) - { - _declaration = declaration; - _icon = icon; - } - - public Declaration Declaration { get { return _declaration; } } - public string IdentifierName { get { return _declaration.IdentifierName; } } - public string Location { get { return _declaration.Scope; } } - - public BitmapImage Icon { get { return _icon; } } - - } -} diff --git a/RetailCoder.VBE/UI/IdentifierReferences/IdentifierReferenceListItem.cs b/RetailCoder.VBE/UI/IdentifierReferences/IdentifierReferenceListItem.cs deleted file mode 100644 index 0726644947..0000000000 --- a/RetailCoder.VBE/UI/IdentifierReferences/IdentifierReferenceListItem.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Rubberduck.Parsing.Symbols; -using Rubberduck.VBEditor; - -namespace Rubberduck.UI.IdentifierReferences -{ - public class IdentifierReferenceListItem - { - private readonly IdentifierReference _reference; - - public IdentifierReferenceListItem(IdentifierReference reference) - { - _reference = reference; - } - - public IdentifierReference GetReferenceItem() - { - return _reference; - } - - public QualifiedSelection Selection { get { return new QualifiedSelection(_reference.QualifiedModuleName, _reference.Selection); } } - public string IdentifierName { get { return _reference.IdentifierName; } } - - public string DisplayString - { - get - { - return string.Format("{0} - {1}, line {2}", - _reference.Context.Parent.GetText(), - Selection.QualifiedName.ComponentName, - Selection.Selection.StartLine); - } - } - } -} diff --git a/RetailCoder.VBE/UI/IdentifierReferences/ImplementationListItem.cs b/RetailCoder.VBE/UI/IdentifierReferences/ImplementationListItem.cs deleted file mode 100644 index 36ce376927..0000000000 --- a/RetailCoder.VBE/UI/IdentifierReferences/ImplementationListItem.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Rubberduck.Parsing.Symbols; -using Rubberduck.VBEditor; - -namespace Rubberduck.UI.IdentifierReferences -{ - public class ImplementationListItem - { - private readonly Declaration _declaration; - - public ImplementationListItem(Declaration declaration) - { - _declaration = declaration; - } - - public Declaration GetDeclaration() - { - return _declaration; - } - - public QualifiedSelection Selection { get { return new QualifiedSelection(_declaration.QualifiedName.QualifiedModuleName, _declaration.Selection); } } - public string IdentifierName { get { return _declaration.IdentifierName; } } - - public string DisplayString - { - get - { - return string.Format("{0}, line {1}", - _declaration.Scope, - Selection.Selection.StartLine); - } - } - } -} diff --git a/RetailCoder.VBE/UI/Refactorings/EncapsulateField/EncapsulateFieldView.xaml.cs b/RetailCoder.VBE/UI/Refactorings/EncapsulateField/EncapsulateFieldView.xaml.cs deleted file mode 100644 index ae5ed0216e..0000000000 --- a/RetailCoder.VBE/UI/Refactorings/EncapsulateField/EncapsulateFieldView.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace Rubberduck.UI.Refactorings.EncapsulateField -{ - /// - /// Interaction logic for EncapsulateFieldView.xaml - /// - public partial class EncapsulateFieldView : UserControl - { - public EncapsulateFieldView() - { - InitializeComponent(); - } - } -} diff --git a/RetailCoder.VBE/UI/RegexSearchReplace/RegexSearchReplaceDialog.cs b/RetailCoder.VBE/UI/RegexSearchReplace/RegexSearchReplaceDialog.cs deleted file mode 100644 index 0f8d07f664..0000000000 --- a/RetailCoder.VBE/UI/RegexSearchReplace/RegexSearchReplaceDialog.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Windows.Forms; -using Rubberduck.Navigation.RegexSearchReplace; - -namespace Rubberduck.UI.RegexSearchReplace -{ - public partial class RegexSearchReplaceDialog : Form, IRegexSearchReplaceDialog - { - public string SearchPattern { get { return SearchBox.Text.Replace(@"\\", @"\"); } } - public string ReplacePattern { get { return ReplaceBox.Text; } } - public RegexSearchReplaceScope Scope { get { return ConvertScopeLabelsToEnum(); } } - - public RegexSearchReplaceDialog() - { - InitializeComponent(); - - InitializeCaptions(); - ScopeComboBox.DataSource = ScopeLabels(); - } - - private void InitializeCaptions() - { - Text = RubberduckUI.RegexSearchReplace_Caption; - SearchLabel.Text = RubberduckUI.RegexSearchReplace_SearchLabel; - ReplaceLabel.Text = RubberduckUI.RegexSearchReplace_ReplaceLabel; - ScopeLabel.Text = RubberduckUI.RegexSearchReplace_ScopeLabel; - - FindButton.Text = RubberduckUI.RegexSearchReplace_FindButtonLabel; - ReplaceButton.Text = RubberduckUI.RegexSearchReplace_ReplaceButtonLabel; - ReplaceAllButton.Text = RubberduckUI.RegexSearchReplace_ReplaceAllButtonLabel; - CancelDialogButton.Text = RubberduckUI.CancelButtonText; - } - - private List ScopeLabels() - { - return (from object scope in Enum.GetValues(typeof(RegexSearchReplaceScope)) - select - RubberduckUI.ResourceManager.GetString("RegexSearchReplaceScope_" + scope, RubberduckUI.Culture)) - .ToList(); - } - - private RegexSearchReplaceScope ConvertScopeLabelsToEnum() - { - var scopes = from RegexSearchReplaceScope scope in Enum.GetValues(typeof(RegexSearchReplaceScope)) - where ReferenceEquals(RubberduckUI.ResourceManager.GetString("RegexSearchReplaceScope_" + scope, RubberduckUI.Culture), ScopeComboBox.SelectedValue) - select scope; - - - return scopes.First(); - } - - public event EventHandler FindButtonClicked; - protected virtual void OnFindButtonClicked(object sender, EventArgs e) - { - var handler = FindButtonClicked; - if (handler != null) - { - handler(this, EventArgs.Empty); - } - } - - public event EventHandler ReplaceButtonClicked; - protected virtual void OnReplaceButtonClicked(object sender, EventArgs e) - { - var handler = ReplaceButtonClicked; - if (handler != null) - { - handler(this, EventArgs.Empty); - } - } - - public event EventHandler ReplaceAllButtonClicked; - protected virtual void OnReplaceAllButtonClicked(object sender, EventArgs e) - { - var handler = ReplaceAllButtonClicked; - if (handler != null) - { - handler(this, EventArgs.Empty); - } - } - - public event EventHandler CancelButtonClicked; - protected virtual void OnCancelButtonClicked(object sender, EventArgs e) - { - var handler = CancelButtonClicked; - if (handler != null) - { - handler(this, EventArgs.Empty); - } - } - } -} diff --git a/RetailCoder.VBE/UI/RubberduckUI.resx b/RetailCoder.VBE/UI/RubberduckUI.resx deleted file mode 100644 index 70976a7909..0000000000 --- a/RetailCoder.VBE/UI/RubberduckUI.resx +++ /dev/null @@ -1,2149 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Cancel - - - class - - - constant - - - enum - - - enum member - - - event - - - function - - - library function - - - module - - - parameter - - - procedure - - - property get accessor - - - property let accessor - - - property set accessor - - - user-defined type - - - user-defined type member - - - variable - - - Name: - - - Ok - - - Rubberduck - Rename - - - Please specify new name for {0} '{1}'. - 0: DeclarationType; 1: IdentifierName - - - Rename identifier - - - General Settings - - - Code Inspection Settings - - - Todo Settings - - - Configure inspection severity. Use "DoNotShow" to disable an inspection. - - - Click [Ok] to close the window and apply changes, or [Cancel] to discard them. - - - Configure markers to be recognized in comments. - - - line label - - - Inspecting... - - - (none) - - - (parsing...) - - - Rubberduck - Reorder Parameters - - - Select a parameter and drag it or use buttons to move it up or down. - - - Move down - - - Move up - - - Reorder parameters - - - control - - - Optional parameters must be specified at the end of the parameter list. - - - Less than two parameters in method '{0}'. - 0: Selected target - - - No references were found for identifier '{0}'. - - - ParamArray parameter must be specified last. - - - No parameters in method '{0}'. - 0: Selected target - - - All references: '{0}' - - - Remove parameters - - - Method '{0}' implements '{1}.{2}'. Change interface signature? (Will propagate to all implementations.) - 0: Selected target; 1: Interface name; 2: Interface member name - - - Cannot remove last parameter from setter or letter. - - - The current selection is not valid. - - - Accessibility: - - - Rubberduck - Extract Method - - - Please specify method name, return type and/or parameters (if applicable), and other options. - - - Parameters: - - - Preview: - - - Return: - - - Set - - - Extract method - - - Class or member '{0}' is not implemented. - - - &Find all references... - - - Find &symbol... - - - Go to &implementation... - - - Extract &Method - - - Remo&ve Parameters - - - &Rename - - - Re&order Parameters - TC: different hotkey - - - Ru&bberduck - - - &About... - - - &Code Explorer - - - Code &Inspections - - - S&ettings - - - &Refactor - - - &Source Control - - - To&Do Items - - - Unit &Tests - - - &Run All Tests - - - &Test Explorer - - - {0} (parsing...) - - - Home - - - Error Loading Rubberduck Configuration - - - Parsing '{0}'... - - - Parsing project components... - - - {0} -{1} - -{2} - -Would you like to restore default configuration? -Warning: All customized settings will be lost. Your old file will be saved in '{3}'. - - - Resolving... - TC: deleted {0} - - - Rubberduck Add-In could not be loaded - - - Version {0} - - - BUG - - - NOTE - - - TODO - - - Implementations of '{0}' - - - Code Inspections - - - {0} ({1} issue) - - - {0} issue - {0}=number - - - Run code inspections - - - Fix - - - Issue - - - Name - - - Next - - - Offline - - - Online - - - Parameter - - - Passed - - - Previous - - - Severity - - - Create New Repository - - - {0} Failed - - - {0} Inconclusive - - - {0} Passed - - - Type - - - Two or more projects containing test methods have the same name and identically named tests. Please rename one to continue. - - - Test Explorer - - - Todo Explorer - - - Warning - - - You've earned the "Continuator" badge! - - - Module options should be specified first - - - Component - - - Result - - - Outcome - - - Display language: - - - English - - - French - - - Rubberduck - Remove Parameters - - - Select a parameter and double-click it or use buttons to remove or restore it. - - - Restore - - - Rubberduck - Parser Errors - - - Class module (.cls) - - - UserForm (.frm) - TC - - - Standard module (.bas) - TC - - - Test module - TC - - - Display member &names - - - Display full &signatures - - - Find All Implementations... - TC - - - Find All References... - TC - - - Inspect - - - Navigate - - - Refresh - - - Rename - - - Run All &Tests - - - Open Designer - - - Toggle folders - - - Copy to clipboard - - - Copy inspection results to clipboard - - - Go - - - Navigate to selected issue - - - Navigate to next issue - - - Navigate to previous issue - - - Address the issue - - - Run code inspections - - - Description - - - Line Number - - - Project Name - - - Add - - - Test Method (Expected Error) - - - Test Method - - - Test Module - - - Duration - - - Navigate to selected - - - Message - - - Method Name - - - Module Name - - - Module - - - All Tests - - - Run - - - Run - - - Failed Tests - - - Repeat Last Run - - - Not Run Tests - - - Passed Tests - - - Selected Tests - - - Line - - - Project - - - project - - - Add - - - Change - - - Remove - - - Rubberduck Settings - - - Token Text: - - - Token List: - - - Navigation - - - TODO Explorer - - - Rubberduck Code Inspections - {0} -{1} issues found. - {0}=timestamp; {1}=number - - - Method '{0}' implements '{1}.{2}'. Rename the interface member? - 0: Selected target; 1: Interface name; 2: Interface member name - - - OK - - - New - - - Reset - - - Reset settings to default configuration? - - - Renaming to '{0}' clashes with '{1}' in the same scope. -Are you sure you want to proceed with this rename? - - - Please ensure that exactly 1 control is selected before renaming. - - - Rename {0} - - - Code Explorer - - - Attributions - - - About Rubberduck - - - © Copyright 2014-2017 Mathieu Guindon & Christopher McClellan - - - Special Thanks - - - Source Control - - - '.gitattributes' File - TC - - - Cancel - - - Default Repository Location - - - Email Address - - - Global Settings - - - '.gitignore' File - TC - - - Refreshes pending changes - - - Repository Settings - - - Update - - - User Name: - TC: added colon - - - Changes - - - Branches - - - Commit - - - Go - - - Commit message: - - - Commit and Push - - - Commit and Sync - - - Rubberduck - Create Branch - - - Branch: - - - Destination - - - Excluded changes - - - Fetch - - - Included changes - - - Incoming commits - - - Merge - - - Rubberduck - Merge - - - New Branch - - - Outgoing commits - - - Pull - - - Push - - - Settings - - - Source - - - Sync - - - Unsynced commits - - - Untracked files - - - Na&vigate - - - &New - - - R&efresh - - - Re&name - - - Please specify branch name. - - - New branch - - - Please select source and destination branches. - - - Merge branches - - - No repository found. - - - Successfully Merged {0} into {1} - - - Rubberduck - Delete Branch - - - Please specify branch name. - - - Delete branch - - - {0} ({1} issues) - {0}=status; {1}=number - - - Rubberduck Code Inspections - {0} -{1} issue found. - {0}=timestamp; {1}=number - - - {0} issues - {0}=number - - - Text: - - - Text - - - German - - - Na&vigate - - - All Opened Files - - - All Open Projects - - - Current Block - - - Current File - - - Current Project - - - Selection - - - Regex Search & Replace - - - Find - - - Replace All - - - Replace - - - Replace: - - - Scope: - - - Search: - - - Details - - - Make ActiveSheet reference explicit - - - Make ActiveWorkbook reference explicit - - - Add a component to the active project - - - Display style - - - Find symbol - - - Current &Module - - - Current &Procedure - - - Current Project - - - In&dent - - - Introduce &Parameter - - - Introduce &Field - - - Selection is not a variable. - Used in both Introduce Parameter and Introduce Field - - - &Encapsulate Field - - - Rubberduck - Encapsulate Field - - - Please specify property name, parameter accessibility, and setter type. - - - Preview: - - - Property Name: - - - Setter Type: - - - Encapsulate Field - - - Parameter Name: - - - Delete branch - - - Move Closer To &Usage - - - Rubberduck - Move Closer To Usage - - - '{0}' is not used anywhere. - {0}: Variable Name - - - '{0}' has references in multiple methods. - {0}: Variable Name - - - Rubberduck - Introduce Field - - - Rubberduck - Introduce Parameter - - - Method '{0}' implements '{1}.{2}'. Change interface signature? (Will propagate to all implementations.) - 0: Selected target; 1: Interface name; 2: Interface member name - - - E&xtract Interface - - - &Implement Interface - - - Rubberduck - Implement Interface - - - The current selection is not valid. - - - Invalid Selection. - - - Rubberduck - Extract Interface - - - Extract Interface - - - Please specify interface name and members. - - - Select All - - - Deselect All - - - Members - - - Unit Test Settings - - - Window Settings - - - Severity: - - - Indenter Settings - - - Configure indenter settings. - - - Configure the settings for new unit test modules and methods. - - - Configure the settings for window visibility. - - - Type safety: - - - Binding mode: - - - Early binding - - - Test method initialization/cleanup - - - Insert test method stub - - - Test module initialization/cleanup - - - Late binding - - - Permissive assert - - - Strict assert - - - Test Module Template - - - Window visibility at startup - - - Failed - - - Inconclusive - - - Succeeded - - - Unknown - - - Absolute - - - Align In Column - - - Same Gap - - - Standard Gap - - - Description - - - Enabled - - - Key1 - - - Align comments with code - - - Align continuations - - - Align dims - - - Alignment Options - - - Enable Options - - - Enable undo - - - End-of-line comment style: - - - Force compiler directives to column 1 - - - Force debug directives to column 1 - - - Ignore operators - - - Indent case - - - Indent compiler directives - - - Indent entire procedure body - - - Indent first comment block - - - Indent first declaration block - - - Indent Options - - - Indent spaces: - - - Special Options - - - Indent Module - - - Indent Procedure - - - By module - - - By inspection type - - - Issue - - - Location - - - Type - - - Grouping - - - By inspection type - - - By location - - - By outcome - - - Hotkeys: - - - Settings - - - Parsing powered by ANTLR -GitHub integration powered by LibGit2Sharp -Syntax highlighting powered by AvalonEdit -Native hooks powered by EasyHook -Fugue icons by Yusuke Kamiyamane -IDE icons from SharpDevelop -WPF localization support by Grant Frisken - - - All contributors to our GitHub repository -All our stargazers, likers & followers, for the warm fuzzies -...and anyone reading this! - - - Search Results - - - Location - The applicable selection, in L1C1 notation - - - Member - The member name, e.g. "Method1" - - - Module - The qualified module name, e.g. "Project1.Module1" - - - Context - A column to display the search result itself - - - All implementations: '{0}' - 0: declaration.identifiername - - - All references: '{0}' - 0: declaration.identifiername - - - Rubberduck - - - Type - - - Branch Name: - - - Local Directory: - - - Remote Path: - - - File Path - - - File Status - - - Author - - - Id - - - Message - - - Dismiss - - - Password: - - - Delete - - - Publish - - - Unpublish - - - Source Branch: - - - Published Branches - - - Unpublished Branches - - - Your last action failed because Rubberduck did not have your authorization credentials. Please login and try again. - - - Exclude - - - Include - - - Undo - - - Delete - - - Parse Error - - - Loading references - - - Parsed - - - Parsing... - - - Pending - - - Ready - - - Resolver Error - - - Resolving declarations... - - - Blogs: - - - Community: - - - Contributors & supporters: - - - Merge status. - - - Your user name, email address, and default repository location have been saved. - - - Settings updated - - - Repository does not contain any branches. - - - No branches found - - - Parse all opened projects - - - Alt - - - Ctrl - - - Key2 - - - Shift - - - Code Explorer - - - Code Inspections - - - Refactor / Extract Method - - - Refactor / Rename - - - Test Explorer - - - this method runs once per module - - - this method runs before every test in the module - - - this method runs after every test in the module - - - Rename test - - - Test raised an error - - - Change to expected error number - - - Expected error was not raised - - - Invalid key. - - - Hook is already detached. - - - Hook is already attached. - - - Hotkey ({0}) not registered. - - - Find symbol - - - Refactor / Move declaration closer to usage - - - Rege&x Search/Replace - - - Refresh parser state - - - By marker - - - library procedure - - - Toggle signatures - - - Export... - - - Import... - - - Print... - - - Remove... - - - Folder Delimiter: - - - Period (.) - - - Slash (/) - - - Commit... - - - Commit status. - - - Commit and push succeeded. - - - Commit and sync succeeded. - - - Commit succeeded. - - - Missing credentials. - - - Undo... - - - Do you want to undo your changes to {0}? - - - Source Control - Undo - - - &Add '@NoIndent - - - Sort - - - by Name - - - Group by Type - - - As in module - - - Ignored - - - Total Duration - - - Parser Errors - - - Minimum Log Level: - - - Debug - - - Error - - - Fatal - - - Info - - - No Logging - - - Trace - - - Warn - - - Show Log Folder - - - Publish repository. - - - No open repository to push to specified remote location. - - - A source file was modified out of the editor; reload it? - - - Open Command Prompt - - - Command prompt executable location - - - Command Prompt Executable - - - Default Repository Directory - - - Failure opening command prompt - - - Please open or activate a project and try again. - - - No active project - - - Resolving references... - - - Project properties - - - If logging is enabled, you may create an issue on our GitHub page with the contents of your log file in '%AppData%\Roaming\Rubberduck\Logs' for support. - - - An unknown error occurred. - - - Added - - - Ignored - - - Missing - - - Modified - - - Nonexistent - - - Removed - - - Renamed in index - - - Renamed in working directory - - - Staged - - - Staged type change - - - Type changed - - - Unaltered - - - Unreadable - - - Untracked - - - Clone a remote repository from a provided URL to the local disk. The repository will then be loaded into the active project. - - - Clone Remote Repository - - - Creates a new local repository from the active project. - - - Create New Local Repository - - - Manage - - - Open local repository from disk. The active project will host the source code. - - - Open Local Repository - - - Open Working Directory - - - Publishes an existing repository to a remote location. The active project must be connected to a repository. - - - Publish Existing Repository - - - Rubberduck encountered an error. Please save your work and restart the host program; if logging is enabled, you can upload your log file located at '%AppData%Roaming\Rubberduck\Logs\RubberduckLog.txt' to a GitHub issue at 'https://github.com/rubberduck-vba/Rubberduck/issues/new' and report the bug. - - - Test Method (&Expected Error) - - - Test &Method - - - Test M&odule - - - Indent - - - Source Control - - - Rubberduck - Regex Analyzer - - - Description - - - Global - - - Ignore case - - - Pattern - - - Regex &Assistant - - - T&ools - - - (no pattern) - - - Enter a regular expression to analyze in the box below. - - - Regular Expression Analyzer - - - Whitelisted Identifiers - - - These identifiers will be ignored by the 'Use meaningful names' inspection - - - Refactor / Encapsulate Field - - - Collapse node and all child nodes - - - Expand node and all child nodes - - - Miscellaneous - - - Run inspections automatically on successful parse - - - Show splash screen at startup - - - Toolwindows were not correctly destroyed and/or could not be recreated; the VBE may not be in a stable state. Rubberduck will load normally next time the VBE is initialized. - - - Rubberduck will not reload - - - {0} module(s) failed to parse; click for details. - - - {0}. Click to refresh. - - - Indent comments in Enum and Type blocks like in procedures - - - Public Enum ExampleEnum -' Enum comment. -Foo -Bar ' Member comment. -End Enum - -' Example Procedure -Sub ExampleProc() - -' SMART INDENTER -' Original VB6 code graciously offered to Rubberduck by Stephen Bullen & Rob Bovey -' © 2016 by Rubberduck VBA. - -Dim count As Integer -Static name As String - -If YouLikeRubberduck Then -' Star us on GitHub http://github.com/rubberduck-vba/Rubberduck -' Follow us on Twitter @rubberduckvba -' Visit http://rubberduckvba.com for news and updates - -Select Case X -Case "A" -' If you have any comments or suggestions, _ -or find valid VBA code that isn't indented correctly, - -#If VBA6 Then -MsgBox "Contact contact@rubberduck-vba.com" -#End If - -Case "Continued strings and parameters can be" _ -& "lined up for easier reading, optionally ignoring" _ -& "any operators (&+, etc) at the start of the line." - -Debug.Print "X<>1" -End Select 'Case X -End If 'More Tools? Suggestions http://github.com/rubberduck-vba/Rubberduck/Issues/New - -End Sub - - - Load Indenter Settings - - - Save Indenter Settings - - - XML file (.xml)|*.xml|Rubberduck config file|*.config - - - Export - - - Import - - - Load General Settings - - - Load Inspection Settings - - - Load Todo List Settings - - - Load Unit Test Settings - - - Load Window Settings - - - Save General Settings - - - Save Inspection Settings - - - Save Todo List Settings - - - Save Unit Test Settings - - - Save Window Settings - - - references - Used to display number of references in commandbar's context selection - - - multiple controls - Used to display description of multiple control selection in commandbar's context selection - - - Smart Indenter settings were found in your registry. -Would you like to import them to Rubberduck? - - - Maintain vertical spacing - - - Vertical Spacing - - - runtime expression - - - Assigned ByVal parameter QuickFix - Make Local Copy - - - Please specify a name to use for the local copy of ByVal {0} '{1}' - 0: DeclarationType; 1: IdentifierName - - - Specify Local Copy Variable Name - - - Indented Code Sample - - - Rubberduck version {0} is now available! Would you like to review the release notes now? - - - Check if a newer version is available at startup - - - Variable names must begin with a letter. - - - Variable names cannot contain special characters other than underscores. - - - The local variable cannot be the same as the '{0}' parameter it replaces - {0} = proposed variable name. - - - '{0}' is already accessible to this scope. - {0} = proposed variable name. - - - The identifier '{0}' will trigger a "Use meaningful name" inspection result. Consider choosing a different name. - {0} = proposed variable name. - - - '{0}' is a reserved keyword. - {0} = proposed variable name. - - - Variable '{0}' is assigned. Remove assignment instruction(s)? - - - Inconclusive Tests - - - expected has {0} dimensions; actual has {1} dimensions. {2} - {0} and {1} are dimension numbers (1, 2, etc.), {2} = message parameter. This should always be at the end. - - - {0} assertion failed. {1} - {0} = method placeholder (i.e. AreEqual), {1} = message parameter. This should always be at the end. - - - Dimension {0}: expected has an LBound of {1}; actual has an LBound of {2}. {3} - {0} = dimension number, {1} and {2} = LBound numbers, {3} = message parameter. This should always be at the end. - - - [expected] and [actual] values are not the same type. - - - Neither [expected] or [actual] is an array. - - - {0} is not an array. - {0} is either [expected] or [actual] - - - [expected] is a reference type and [actual] is a value type. - - - Dimension {0}: expected has a UBound of {1}; actual has a UBound of {2}. {3} - {0} = dimension number, {1} and {2} = UBound numbers, {3} = message parameter. This should always be at the end. - - - [expected] and [actual] are arrays. Consider using {0}. - {0} is either Assert.SequenceEquals or Assert.NotSequenceEquals. - - - [expected] and [actual] are Nothing. Consider using {0}. - {0} is either Assert.AreSame or Assert.AreNotSame. - - - [expected] and [actual] are reference types. Consider using {0}. - {0} is either Assert.AreSame or Assert.AreNotSame. - - - [expected] and [actual] are value types. Consider using {0}. - {0} is either Assert.AreEqual or Assert.AreNotEqual. - - - [expected] is a value type and [actual] is a reference type. - - - Unexpected COM exception while running tests. - - - OK, Rubberduck asserted. Now what? - Reported when an AssertClass is passed as a parameter to a faked function. - - - Expected: Stack overflow?; Actual: Guard clause. - Reported when an IFake interface is passed as a parameter to a faked function. - - - IVerify too. - Reported when an IVerify interface is passed as a parameter to a faked function. - - - Unexpected exception while running tests. - - - Not implemented. - Placeholder text for planned functionality. - - - Expected: {0}; Actual: {1}. {2} - {0} = expected value, {1} = actual value, {2} = optional user supplied message (always last) - - - Rubberduck could not process the invocation results. - - - No matching invocation for parameter {0}; Only {1} invocations. {2} - {0} = parameter name, {1} = number of invokes, {2} = optional user supplied message (always last) - - - Parameter {0} was not a numeric value on invocation {1}. {2} - {0} = parameter name, {1} = invocation under test, {2} = optional user supplied message (always last) - - - Parameter {0} was not passed on invocation {1}. {2} - {0} = parameter name, {1} = invocation under test, {2} = optional user supplied message (always last) - - - Preview - - - Invalid setup of IFake {0}. PassThrough property must be False. - {0} = name of the function being faked. - - - Unable to detect selected rename target - - - Identifier {0} cannot be renamed. - - - Could not rename {0}. - - - Could not rename Interface Member {0}. - - - {0} {1} cannot be changed. - 0: DeclarationType; 1: IdentifierName - - - Inspection Severities - - - Method '{0}' is an EventHandler for control '{1}'. Only the control can be renamed. Rename '{1}' instead? - 0: Selected target Identifier; 1: Control Name - - - Method '{0}' is an implementation of event '{1}.{2}'. Rename event '{2}' instead? - 0: Selected target Identifier; 1: Event Parent; 2: Event name - - - Enable Source Control. Requires a restart to take effect. - - - Only enable these if you know what you're doing. Enabling and/or using features from this section may result in things breaking unexpectedly and irrevocable data loss. - - - Experimental Features: - - - Export Active Project... - - - Choose a folder to export the source of {0} to: - {0} VBProject.Name - - - Export Project... - - - Export Active Project - - - Open - - - Open Designer - - - All Files - - - VB Files - - - Import Source Files - - - Add Module - - - to parse and process the projects in the VBE. - Follows the text for "Refresh" - - - Rubberduck doesn't see anything yet. - - - Test module with stubs - TC - - - Refresh - - - Rubberduck TODO Items - {0} -{1} items found. - {0}=timestamp; {1}=number - - - Rubberduck TODO Items - {0} -{1} items found. - {0}=timestamp; {1}=number - - - {0}: {1} - {2}.{3} line {4}. - - - Copy to clipboard - - - Copy successful - - - Click here to copy version info to clipboard. - - - Version information copied to clipboard. - - - Code Metrics - - - Code Metrics - - - Cyclomatic Complexity - - - Lines - - - Maximum Nesting - - \ No newline at end of file diff --git a/RetailCoder.VBE/UI/Settings/SettingsView.cs b/RetailCoder.VBE/UI/Settings/SettingsView.cs deleted file mode 100644 index 1847d90996..0000000000 --- a/RetailCoder.VBE/UI/Settings/SettingsView.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Globalization; - -namespace Rubberduck.UI.Settings -{ - public class SettingsView - { - public string Label { get { return RubberduckUI.ResourceManager.GetString("SettingsCaption_" + View); } } - public string Instructions - { - get - { - return RubberduckUI.ResourceManager.GetString("SettingsInstructions_" + View, CultureInfo.CurrentUICulture); - } - } - public ISettingsView Control { get; set; } - public SettingsViews View { get; set; } - } -} diff --git a/RetailCoder.VBE/UI/SourceControl/BranchesPanelViewModel.cs b/RetailCoder.VBE/UI/SourceControl/BranchesPanelViewModel.cs deleted file mode 100644 index e924c56989..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/BranchesPanelViewModel.cs +++ /dev/null @@ -1,522 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.RegularExpressions; -using NLog; -using Rubberduck.SourceControl; -using Rubberduck.UI.Command; -// ReSharper disable ExplicitCallerInfoArgument - -namespace Rubberduck.UI.SourceControl -{ - public class BranchesPanelViewModel : ViewModelBase, IControlViewModel - { - private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - - public BranchesPanelViewModel() - { - _newBranchCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => CreateBranch(), _ => Provider != null); - _mergeBranchCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => MergeBranch(), _ => Provider != null); - - _createBranchOkButtonCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => CreateBranchOk(), _ => !IsNotValidBranchName); - _createBranchCancelButtonCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => CreateBranchCancel()); - - _mergeBranchesOkButtonCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => MergeBranchOk(), _ => SourceBranch != DestinationBranch); - _mergeBranchesCancelButtonCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => MergeBranchCancel()); - - _deleteBranchToolbarButtonCommand = - new DelegateCommand(LogManager.GetCurrentClassLogger(), isBranchPublished => DeleteBranch(bool.Parse((string) isBranchPublished)), - isBranchPublished => CanDeleteBranch(bool.Parse((string)isBranchPublished))); - - _publishBranchToolbarButtonCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => PublishBranch(), _ => !string.IsNullOrEmpty(CurrentUnpublishedBranch)); - _unpublishBranchToolbarButtonCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => UnpublishBranch(), _ => !string.IsNullOrEmpty(CurrentPublishedBranch)); - } - - private ISourceControlProvider _provider; - public ISourceControlProvider Provider - { - get { return _provider; } - set - { - Logger.Trace("Provider changed"); - - _provider = value; - RefreshView(); - } - } - - public void RefreshView() - { - Logger.Trace("Refreshing view"); - - OnPropertyChanged("LocalBranches"); - OnPropertyChanged("PublishedBranches"); - OnPropertyChanged("UnpublishedBranches"); - OnPropertyChanged("Branches"); - - CurrentBranch = Provider.CurrentBranch.Name; - - SourceBranch = null; - DestinationBranch = CurrentBranch; - } - - public void ResetView() - { - Logger.Trace("Resetting view"); - - _provider = null; - _currentBranch = string.Empty; - SourceBranch = string.Empty; - DestinationBranch = CurrentBranch; - - OnPropertyChanged("LocalBranches"); - OnPropertyChanged("PublishedBranches"); - OnPropertyChanged("UnpublishedBranches"); - OnPropertyChanged("Branches"); - OnPropertyChanged("CurrentBranch"); - } - - public SourceControlTab Tab { get { return SourceControlTab.Branches; } } - - public IEnumerable Branches - { - get - { - return Provider == null - ? Enumerable.Empty() - : Provider.Branches.Select(b => b.Name); - } - } - - public IEnumerable LocalBranches - { - get - { - return Provider == null - ? Enumerable.Empty() - : Provider.Branches.Where(b => !b.IsRemote).Select(b => b.Name); - } - } - - public IEnumerable PublishedBranches - { - get - { - return Provider == null - ? Enumerable.Empty() - : Provider.Branches.Where(b => !b.IsRemote && !string.IsNullOrEmpty(b.TrackingName)).Select(b => b.Name); - } - } - - public IEnumerable UnpublishedBranches - { - get - { - return Provider == null - ? Enumerable.Empty() - : Provider.Branches.Where(b => !b.IsRemote && string.IsNullOrEmpty(b.TrackingName)).Select(b => b.Name); - } - } - - private string _currentBranch; - public string CurrentBranch - { - get { return _currentBranch; } - set - { - if (_currentBranch != value) - { - _currentBranch = value; - OnPropertyChanged(); - - CreateBranchSource = value; - - if (Provider == null) { return; } - - try - { - Provider.NotifyExternalFileChanges = false; - Provider.HandleVbeSinkEvents = false; - Provider.Checkout(_currentBranch); - } - catch (SourceControlException ex) - { - RaiseErrorEvent(ex.Message, ex.InnerException, NotificationType.Error); - } - catch - { - RaiseErrorEvent(RubberduckUI.SourceControl_UnknownErrorTitle, - RubberduckUI.SourceControl_UnknownErrorMessage, NotificationType.Error); - throw; - } - Provider.NotifyExternalFileChanges = true; - Provider.HandleVbeSinkEvents = true; - } - } - } - - private string _currentPublishedBranch; - public string CurrentPublishedBranch - { - get { return _currentPublishedBranch; } - set - { - _currentPublishedBranch = value; - OnPropertyChanged(); - } - } - - private string _currentUnpublishedBranch; - public string CurrentUnpublishedBranch - { - get { return _currentUnpublishedBranch; } - set - { - _currentUnpublishedBranch = value; - OnPropertyChanged(); - } - } - - private bool _displayCreateBranchGrid; - public bool DisplayCreateBranchGrid - { - get { return _displayCreateBranchGrid; } - set - { - if (_displayCreateBranchGrid != value) - { - _displayCreateBranchGrid = value; - OnPropertyChanged(); - } - } - } - - private string _createBranchSource; - public string CreateBranchSource - { - get { return _createBranchSource; } - set - { - if (_createBranchSource != value) - { - _createBranchSource = value; - OnPropertyChanged(); - } - } - } - - private string _newBranchName; - public string NewBranchName - { - get { return _newBranchName; } - set - { - if (_newBranchName != value) - { - _newBranchName = value; - OnPropertyChanged(); - OnPropertyChanged("IsNotValidBranchName"); - } - } - } - - // Courtesy of http://stackoverflow.com/a/12093994/4088852 - Assumes --allow-onelevel is set TODO: Verify provider honor that. - private static readonly Regex ValidBranchNameRegex = new Regex(@"^(?!@$|build-|/|.*([/.]\.|//|@\{|\\))[^\u0000-\u0037\u0177 ~^:?*[]+/?[^\u0000-\u0037\u0177 ~^:?*[]+(? b.Name == CurrentPublishedBranch).TrackingName); - } - catch (SourceControlException ex) - { - RaiseErrorEvent(ex.Message, ex.InnerException, NotificationType.Error); - } - catch - { - RaiseErrorEvent(RubberduckUI.SourceControl_UnknownErrorTitle, - RubberduckUI.SourceControl_UnknownErrorMessage, NotificationType.Error); - throw; - } - - RefreshView(); - } - - private readonly CommandBase _newBranchCommand; - public CommandBase NewBranchCommand - { - get - { - return _newBranchCommand; - } - } - - private readonly CommandBase _mergeBranchCommand; - public CommandBase MergeBranchCommand - { - get - { - return _mergeBranchCommand; - } - } - - private readonly CommandBase _createBranchOkButtonCommand; - public CommandBase CreateBranchOkButtonCommand - { - get - { - return _createBranchOkButtonCommand; - } - } - - private readonly CommandBase _createBranchCancelButtonCommand; - public CommandBase CreateBranchCancelButtonCommand - { - get - { - return _createBranchCancelButtonCommand; - } - } - - private readonly CommandBase _mergeBranchesOkButtonCommand; - public CommandBase MergeBranchesOkButtonCommand - { - get - { - return _mergeBranchesOkButtonCommand; - } - } - - private readonly CommandBase _mergeBranchesCancelButtonCommand; - public CommandBase MergeBranchesCancelButtonCommand - { - get - { - return _mergeBranchesCancelButtonCommand; - } - } - - private readonly CommandBase _deleteBranchToolbarButtonCommand; - public CommandBase DeleteBranchToolbarButtonCommand - { - get - { - return _deleteBranchToolbarButtonCommand; - } - } - - private readonly CommandBase _publishBranchToolbarButtonCommand; - public CommandBase PublishBranchToolbarButtonCommand - { - get { return _publishBranchToolbarButtonCommand; } - } - - private readonly CommandBase _unpublishBranchToolbarButtonCommand; - public CommandBase UnpublishBranchToolbarButtonCommand - { - get { return _unpublishBranchToolbarButtonCommand; } - } - - public event EventHandler ErrorThrown; - private void RaiseErrorEvent(string message, Exception innerException, NotificationType notificationType) - { - var handler = ErrorThrown; - if (handler != null) - { - handler(this, new ErrorEventArgs(message, innerException, notificationType)); - } - } - - private void RaiseErrorEvent(string title, string message, NotificationType notificationType) - { - var handler = ErrorThrown; - if (handler != null) - { - handler(this, new ErrorEventArgs(title, message, notificationType)); - } - } - } -} diff --git a/RetailCoder.VBE/UI/SourceControl/BranchesView.xaml b/RetailCoder.VBE/UI/SourceControl/BranchesView.xaml deleted file mode 100644 index ccac49b7ef..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/BranchesView.xaml +++ /dev/null @@ -1,346 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/RetailCoder.VBE/UI/SourceControl/BranchesView.xaml.cs b/RetailCoder.VBE/UI/SourceControl/BranchesView.xaml.cs deleted file mode 100644 index cd84e2c4e6..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/BranchesView.xaml.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Rubberduck.UI.SourceControl -{ - /// - /// Interaction logic for BranchesView.xaml - /// - public partial class BranchesView : IControlView - { - public BranchesView() - { - InitializeComponent(); - } - - public BranchesView(IControlViewModel vm) : this() - { - DataContext = vm; - } - - public IControlViewModel ViewModel { get { return (IControlViewModel)DataContext; } } - } -} diff --git a/RetailCoder.VBE/UI/SourceControl/ChangesPanelViewModel.cs b/RetailCoder.VBE/UI/SourceControl/ChangesPanelViewModel.cs deleted file mode 100644 index 43777245a3..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/ChangesPanelViewModel.cs +++ /dev/null @@ -1,294 +0,0 @@ -using System; -using System.Collections.ObjectModel; -using System.Diagnostics; -using System.IO; -using System.Linq; -using NLog; -using Rubberduck.SourceControl; -using Rubberduck.UI.Command; -// ReSharper disable ExplicitCallerInfoArgument - -namespace Rubberduck.UI.SourceControl -{ - public class ChangesPanelViewModel : ViewModelBase, IControlViewModel - { - private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - - public ChangesPanelViewModel() - { - _commitCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => Commit(), _ => !string.IsNullOrEmpty(CommitMessage) && IncludedChanges != null && IncludedChanges.Any()); - - _includeChangesToolbarButtonCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), fileStatusEntry => IncludeChanges((IFileStatusEntry)fileStatusEntry)); - _excludeChangesToolbarButtonCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), fileStatusEntry => ExcludeChanges((IFileStatusEntry)fileStatusEntry)); - _undoChangesToolbarButtonCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), fileStatusEntry => UndoChanges((IFileStatusEntry) fileStatusEntry)); - } - - private string _commitMessage; - public string CommitMessage - { - get { return _commitMessage; } - set - { - if (_commitMessage != value) - { - _commitMessage = value; - OnPropertyChanged(); - } - } - } - - private ISourceControlProvider _provider; - public ISourceControlProvider Provider - { - get { return _provider; } - set - { - _provider = value; - _provider.BranchChanged += Provider_BranchChanged; - - RefreshView(); - } - } - - public void RefreshView() - { - Logger.Trace("Refreshing view"); - - OnPropertyChanged("CurrentBranch"); - - IncludedChanges = Provider == null - ? new ObservableCollection() - : new ObservableCollection( - Provider.Status() - .Where( - stat => - (stat.FileStatus.HasFlag(FileStatus.Modified) || - stat.FileStatus.HasFlag(FileStatus.Added) || - stat.FileStatus.HasFlag(FileStatus.Removed) || - stat.FileStatus.HasFlag(FileStatus.RenamedInIndex) || - stat.FileStatus.HasFlag(FileStatus.RenamedInWorkDir)) && - !ExcludedChanges.Select(f => f.FilePath).Contains(stat.FilePath))); - - UntrackedFiles = Provider == null - ? new ObservableCollection() - : new ObservableCollection( - Provider.Status().Where(stat => stat.FileStatus.HasFlag(FileStatus.Untracked))); - } - - public void ResetView() - { - Logger.Trace("Resetting view"); - - _provider.BranchChanged -= Provider_BranchChanged; - _provider = null; - - OnPropertyChanged("CurrentBranch"); - - IncludedChanges = new ObservableCollection(); - UntrackedFiles = new ObservableCollection(); - } - - public SourceControlTab Tab { get { return SourceControlTab.Changes; } } - - private void Provider_BranchChanged(object sender, EventArgs e) - { - OnPropertyChanged("CurrentBranch"); - } - - public string CurrentBranch - { - get { return Provider == null ? string.Empty : Provider.CurrentBranch.Name; } - } - - public CommitAction CommitAction { get; set; } - - private ObservableCollection _includedChanges; - public ObservableCollection IncludedChanges - { - get { return _includedChanges; } - set - { - if (_includedChanges != value) - { - _includedChanges = value; - OnPropertyChanged(); - } - } - } - - private ObservableCollection _excludedChanges = new ObservableCollection(); - public ObservableCollection ExcludedChanges - { - get { return _excludedChanges; } - set - { - if (_excludedChanges != value) - { - _excludedChanges = value; - OnPropertyChanged(); - } - } - } - - private ObservableCollection _untrackedFiles; - public ObservableCollection UntrackedFiles - { - get { return _untrackedFiles; } - set - { - if (_untrackedFiles != value) - { - _untrackedFiles = value; - OnPropertyChanged(); - } - } - } - - private void UndoChanges(IFileStatusEntry fileStatusEntry) - { - Logger.Trace("Undoing changes to file {0}", fileStatusEntry.FilePath); - - try - { - var file = Path.GetFileName(fileStatusEntry.FilePath); - Debug.Assert(!string.IsNullOrEmpty(file)); - Provider.Undo(Path.Combine(Provider.CurrentRepository.LocalLocation, file)); - RefreshView(); - } - catch (SourceControlException ex) - { - RaiseErrorEvent(ex.Message, ex.InnerException, NotificationType.Error); - } - catch - { - RaiseErrorEvent(RubberduckUI.SourceControl_UnknownErrorTitle, - RubberduckUI.SourceControl_UnknownErrorMessage, NotificationType.Error); - throw; - } - } - - private void Commit() - { - Logger.Trace("Committing"); - - var changes = IncludedChanges.Select(c => c.FilePath).ToList(); - if (!changes.Any()) - { - return; - } - - try - { - Provider.Stage(changes); - Provider.Commit(CommitMessage); - - if (CommitAction == CommitAction.CommitAndSync) - { - Logger.Trace("Commit and sync (pull + push)"); - Provider.Pull(); - Provider.Push(); - } - - if (CommitAction == CommitAction.CommitAndPush) - { - Logger.Trace("Commit and push"); - Provider.Push(); - } - - RefreshView(); - - switch (CommitAction) - { - case CommitAction.Commit: - RaiseErrorEvent(RubberduckUI.SourceControl_CommitStatus, RubberduckUI.SourceControl_CommitStatus_CommitSuccess, NotificationType.Info); - return; - case CommitAction.CommitAndPush: - RaiseErrorEvent(RubberduckUI.SourceControl_CommitStatus, RubberduckUI.SourceControl_CommitStatus_CommitAndPushSuccess, NotificationType.Info); - return; - case CommitAction.CommitAndSync: - RaiseErrorEvent(RubberduckUI.SourceControl_CommitStatus, RubberduckUI.SourceControl_CommitStatus_CommitAndSyncSuccess, NotificationType.Info); - return; - } - } - catch (SourceControlException ex) - { - RaiseErrorEvent(ex.Message, ex.InnerException, NotificationType.Error); - } - catch - { - RaiseErrorEvent(RubberduckUI.SourceControl_UnknownErrorTitle, - RubberduckUI.SourceControl_UnknownErrorMessage, NotificationType.Error); - throw; - } - - CommitMessage = string.Empty; - } - - private void IncludeChanges(IFileStatusEntry fileStatusEntry) - { - if (UntrackedFiles.FirstOrDefault(f => f.FilePath == fileStatusEntry.FilePath) != null) - { - Logger.Trace("Tracking file {0}", fileStatusEntry.FilePath); - Provider.AddFile(fileStatusEntry.FilePath); - } - else - { - Logger.Trace("Removing file {0} from excluded changes", fileStatusEntry.FilePath); - ExcludedChanges.Remove(ExcludedChanges.FirstOrDefault(f => f.FilePath == fileStatusEntry.FilePath)); - } - - RefreshView(); - } - - private void ExcludeChanges(IFileStatusEntry fileStatusEntry) - { - Logger.Trace("Adding file {0} to excluded changes", fileStatusEntry.FilePath); - ExcludedChanges.Add(fileStatusEntry); - - RefreshView(); - } - - private readonly CommandBase _commitCommand; - public CommandBase CommitCommand - { - get { return _commitCommand; } - } - - private readonly CommandBase _undoChangesToolbarButtonCommand; - public CommandBase UndoChangesToolbarButtonCommand - { - get { return _undoChangesToolbarButtonCommand; } - } - - private readonly CommandBase _excludeChangesToolbarButtonCommand; - public CommandBase ExcludeChangesToolbarButtonCommand - { - get { return _excludeChangesToolbarButtonCommand; } - } - - private readonly CommandBase _includeChangesToolbarButtonCommand; - public CommandBase IncludeChangesToolbarButtonCommand - { - get { return _includeChangesToolbarButtonCommand; } - } - - public event EventHandler ErrorThrown; - private void RaiseErrorEvent(string message, Exception innerException, NotificationType notificationType) - { - var handler = ErrorThrown; - if (handler != null) - { - handler(this, new ErrorEventArgs(message, innerException, notificationType)); - } - } - - private void RaiseErrorEvent(string title, string message, NotificationType notificationType) - { - var handler = ErrorThrown; - if (handler != null) - { - handler(this, new ErrorEventArgs(title, message, notificationType)); - } - } - } -} diff --git a/RetailCoder.VBE/UI/SourceControl/ChangesView.xaml b/RetailCoder.VBE/UI/SourceControl/ChangesView.xaml deleted file mode 100644 index da06175dc9..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/ChangesView.xaml +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/RetailCoder.VBE/UI/SourceControl/ChangesView.xaml.cs b/RetailCoder.VBE/UI/SourceControl/ChangesView.xaml.cs deleted file mode 100644 index e30011c221..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/ChangesView.xaml.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Rubberduck.UI.SourceControl -{ - /// - /// Interaction logic for ChangesView.xaml - /// - public partial class ChangesView : IControlView - { - public ChangesView() - { - InitializeComponent(); - } - - public ChangesView(IControlViewModel vm) : this() - { - DataContext = vm; - } - - public IControlViewModel ViewModel { get { return (IControlViewModel)DataContext; } } - } -} diff --git a/RetailCoder.VBE/UI/SourceControl/CommitAction.cs b/RetailCoder.VBE/UI/SourceControl/CommitAction.cs deleted file mode 100644 index d87250a2d3..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/CommitAction.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Rubberduck.UI.SourceControl -{ - public enum CommitAction - { - Commit, - CommitAndPush, - CommitAndSync - } -} diff --git a/RetailCoder.VBE/UI/SourceControl/Converters/ChangeTypesToTextConverter.cs b/RetailCoder.VBE/UI/SourceControl/Converters/ChangeTypesToTextConverter.cs deleted file mode 100644 index 62c6ec104e..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/Converters/ChangeTypesToTextConverter.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Globalization; -using System.Linq; -using System.Windows.Data; - -namespace Rubberduck.UI.SourceControl.Converters -{ - public class ChangeTypesToTextConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - var values = value.ToString().Split(new[] {", "}, StringSplitOptions.RemoveEmptyEntries); - var translatedValue = values.Select(s => RubberduckUI.ResourceManager.GetString("SourceControl_FileStatus_" + s)); - return string.Join(", ", translatedValue); - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - throw new InvalidOperationException(); - } - } -} diff --git a/RetailCoder.VBE/UI/SourceControl/Converters/CommitActionTextToEnum.cs b/RetailCoder.VBE/UI/SourceControl/Converters/CommitActionTextToEnum.cs deleted file mode 100644 index dac664146f..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/Converters/CommitActionTextToEnum.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Globalization; -using System.Windows.Data; - -namespace Rubberduck.UI.SourceControl.Converters -{ - public class CommitActionTextToEnum : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - var action = (CommitAction)value; - switch (action) - { - case CommitAction.Commit: - return RubberduckUI.SourceControl_Commit; - case CommitAction.CommitAndPush: - return RubberduckUI.SourceControl_CommitAndPush; - case CommitAction.CommitAndSync: - return RubberduckUI.SourceControl_CommitAndSync; - default: - return value; - } - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - var text = (string)value; - - if (text == RubberduckUI.SourceControl_Commit) - { - return CommitAction.Commit; - } - if (text == RubberduckUI.SourceControl_CommitAndPush) - { - return CommitAction.CommitAndPush; - } - if (text == RubberduckUI.SourceControl_CommitAndSync) - { - return CommitAction.CommitAndSync; - } - - return null; - } - } -} diff --git a/RetailCoder.VBE/UI/SourceControl/Converters/CommitActionsToTextConverter.cs b/RetailCoder.VBE/UI/SourceControl/Converters/CommitActionsToTextConverter.cs deleted file mode 100644 index 85769fa9d7..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/Converters/CommitActionsToTextConverter.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Windows.Data; - -namespace Rubberduck.UI.SourceControl.Converters -{ - public class CommitActionsToTextConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - var modes = (IEnumerable)value; - return modes.Select(s => RubberduckUI.ResourceManager.GetString("SourceControl_" + s, CultureInfo.CurrentUICulture)).ToArray(); - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - return value; - } - } -} diff --git a/RetailCoder.VBE/UI/SourceControl/IControlView.cs b/RetailCoder.VBE/UI/SourceControl/IControlView.cs deleted file mode 100644 index 26319bdc88..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/IControlView.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Rubberduck.UI.SourceControl -{ - public interface IControlView - { - IControlViewModel ViewModel { get; } - } -} diff --git a/RetailCoder.VBE/UI/SourceControl/IControlViewModel.cs b/RetailCoder.VBE/UI/SourceControl/IControlViewModel.cs deleted file mode 100644 index 713aef4f38..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/IControlViewModel.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using Rubberduck.SourceControl; - -namespace Rubberduck.UI.SourceControl -{ - using System.Linq; - - public class ErrorEventArgs - { - public readonly string Title; - public readonly string InnerMessage; - public readonly NotificationType NotificationType; - - public ErrorEventArgs(string title, Exception innerException, NotificationType notificationType) - { - Title = title; - InnerMessage = GetInnerExceptionMessage(innerException); - NotificationType = notificationType; - } - - public ErrorEventArgs(string title, string message, NotificationType notificationType) - { - Title = title; - InnerMessage = message; - NotificationType = notificationType; - } - - private string GetInnerExceptionMessage(Exception ex) - { - return ex is AggregateException - ? string.Join(Environment.NewLine, ((AggregateException) ex).InnerExceptions.Select(s => s.Message)) - : ex.Message; - } - } - - public interface IControlViewModel - { - SourceControlTab Tab { get; } - - ISourceControlProvider Provider { get; set; } - event EventHandler ErrorThrown; - - void RefreshView(); - void ResetView(); - } -} diff --git a/RetailCoder.VBE/UI/SourceControl/NotificationType.cs b/RetailCoder.VBE/UI/SourceControl/NotificationType.cs deleted file mode 100644 index fcf8a59c3d..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/NotificationType.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Rubberduck.UI.SourceControl -{ - public enum NotificationType - { - Info, - Error - } -} diff --git a/RetailCoder.VBE/UI/SourceControl/SettingsPanelViewModel.cs b/RetailCoder.VBE/UI/SourceControl/SettingsPanelViewModel.cs deleted file mode 100644 index 8754278aae..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/SettingsPanelViewModel.cs +++ /dev/null @@ -1,271 +0,0 @@ -using System; -using System.Diagnostics; -using System.IO; -using System.Windows.Forms; -using NLog; -using Rubberduck.SettingsProvider; -using Rubberduck.UI.Command; -using Rubberduck.SourceControl; - -namespace Rubberduck.UI.SourceControl -{ - public class SettingsPanelViewModel : ViewModelBase, IControlViewModel, IDisposable - { - private readonly IConfigProvider _configService; - private readonly IFolderBrowserFactory _folderBrowserFactory; - private readonly IOpenFileDialog _openFileDialog; - private readonly SourceControlSettings _config; - - public SettingsPanelViewModel( - IConfigProvider configService, - IFolderBrowserFactory folderBrowserFactory, - IOpenFileDialog openFileDialog) - { - _configService = configService; - _folderBrowserFactory = folderBrowserFactory; - _config = _configService.Create(); - - _openFileDialog = openFileDialog; - _openFileDialog.Filter = "Executables (*.exe)|*.exe|All files (*.*)|*.*"; - _openFileDialog.Multiselect = false; - _openFileDialog.ReadOnlyChecked = true; - _openFileDialog.CheckFileExists = true; - - UserName = _config.UserName; - EmailAddress = _config.EmailAddress; - DefaultRepositoryLocation = _config.DefaultRepositoryLocation; - CommandPromptLocation = _config.CommandPromptLocation; - - _showDefaultRepoFolderPickerCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ShowDefaultRepoFolderPicker()); - _showCommandPromptExePickerCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ShowCommandPromptExePicker()); - _cancelSettingsChangesCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => CancelSettingsChanges()); - _updateSettingsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => UpdateSettings()); - _showGitIgnoreCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ShowGitIgnore(), _ => Provider != null); - _showGitAttributesCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ShowGitAttributes(), _ => Provider != null); - } - - public ISourceControlProvider Provider { get; set; } - public void RefreshView() { } // nothing to refresh here - - public void ResetView() - { - Provider = null; - } - - public SourceControlTab Tab { get { return SourceControlTab.Settings; } } - - private string _userName; - public string UserName - { - get { return _userName; } - set - { - if (_userName != value) - { - _userName = value; - OnPropertyChanged(); - } - } - } - - private string _emailAddress; - public string EmailAddress - { - get { return _emailAddress; } - set - { - if (_emailAddress != value) - { - _emailAddress = value; - OnPropertyChanged(); - } - } - } - - private string _defaultRepositoryLocation; - public string DefaultRepositoryLocation - { - get { return _defaultRepositoryLocation; } - set - { - if (_defaultRepositoryLocation != value) - { - _defaultRepositoryLocation = value; - OnPropertyChanged(); - } - } - } - - private string _commandPromptExeLocation; - public string CommandPromptLocation - { - get { return _commandPromptExeLocation; } - set - { - if (_commandPromptExeLocation != value) - { - _commandPromptExeLocation = value; - OnPropertyChanged(); - } - } - } - - private void ShowDefaultRepoFolderPicker() - { - using (var folderPicker = _folderBrowserFactory.CreateFolderBrowser(RubberduckUI.SourceControl_FilePickerDefaultRepoHeader)) - { - if (folderPicker.ShowDialog() == DialogResult.OK) - { - DefaultRepositoryLocation = folderPicker.SelectedPath; - } - } - } - - private void ShowCommandPromptExePicker() - { - if (_openFileDialog.ShowDialog() == DialogResult.OK) - { - CommandPromptLocation = _openFileDialog.FileName; - } - } - - private void CancelSettingsChanges() - { - UserName = _config.UserName; - EmailAddress = _config.EmailAddress; - DefaultRepositoryLocation = _config.DefaultRepositoryLocation; - CommandPromptLocation = _config.CommandPromptLocation; - } - - private void UpdateSettings() - { - _config.UserName = UserName; - _config.EmailAddress = EmailAddress; - _config.DefaultRepositoryLocation = DefaultRepositoryLocation; - _config.CommandPromptLocation = CommandPromptLocation; - - _configService.Save(_config); - - RaiseErrorEvent(RubberduckUI.SourceControl_UpdateSettingsTitle, - RubberduckUI.SourceControl_UpdateSettingsMessage, NotificationType.Info); - } - - private void ShowGitIgnore() - { - OpenFileInExternalEditor(GitSettingsFile.Ignore); - } - - private void ShowGitAttributes() - { - OpenFileInExternalEditor(GitSettingsFile.Attributes); - } - - private void OpenFileInExternalEditor(GitSettingsFile fileType) - { - var fileName = string.Empty; - var defaultContents = string.Empty; - switch (fileType) - { - case GitSettingsFile.Ignore: - fileName = ".gitignore"; - defaultContents = DefaultSettings.GitIgnoreText(); - break; - case GitSettingsFile.Attributes: - fileName = ".gitattributes"; - defaultContents = DefaultSettings.GitAttributesText(); - break; - } - - var repo = Provider.CurrentRepository; - var filePath = Path.Combine(repo.LocalLocation, fileName); - - if (!File.Exists(filePath)) - { - File.WriteAllText(filePath, defaultContents); - } - - Process.Start(filePath); - } - - private readonly CommandBase _showDefaultRepoFolderPickerCommand; - public CommandBase ShowDefaultRepoFolderPickerCommand - { - get - { - return _showDefaultRepoFolderPickerCommand; - } - } - - private readonly CommandBase _showCommandPromptExePickerCommand; - public CommandBase ShowCommandPromptExePickerCommand - { - get - { - return _showCommandPromptExePickerCommand; - } - } - - private readonly CommandBase _cancelSettingsChangesCommand; - public CommandBase CancelSettingsChangesCommand - { - get - { - return _cancelSettingsChangesCommand; - } - } - - private readonly CommandBase _updateSettingsCommand; - public CommandBase UpdateSettingsCommand - { - get - { - return _updateSettingsCommand; - } - } - - private readonly CommandBase _showGitIgnoreCommand; - public CommandBase ShowGitIgnoreCommand - { - get - { - return _showGitIgnoreCommand; - } - } - - private readonly CommandBase _showGitAttributesCommand; - public CommandBase ShowGitAttributesCommand - { - get - { - return _showGitAttributesCommand; - } - } - - public event EventHandler ErrorThrown; - private void RaiseErrorEvent(string message, Exception innerException, NotificationType notificationType) - { - var handler = ErrorThrown; - if (handler != null) - { - handler(this, new ErrorEventArgs(message, innerException, notificationType)); - } - } - - private void RaiseErrorEvent(string title, string message, NotificationType notificationType) - { - var handler = ErrorThrown; - if (handler != null) - { - handler(this, new ErrorEventArgs(title, message, notificationType)); - } - } - - public void Dispose() - { - if (_openFileDialog != null) - { - _openFileDialog.Dispose(); - } - } - } -} \ No newline at end of file diff --git a/RetailCoder.VBE/UI/SourceControl/SettingsView.xaml b/RetailCoder.VBE/UI/SourceControl/SettingsView.xaml deleted file mode 100644 index 4735b3b97e..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/SettingsView.xaml +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/RetailCoder.VBE/UI/SourceControl/SettingsView.xaml.cs b/RetailCoder.VBE/UI/SourceControl/SettingsView.xaml.cs deleted file mode 100644 index 83cf476972..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/SettingsView.xaml.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Rubberduck.UI.SourceControl -{ - /// - /// Interaction logic for SettingsView.xaml - /// - public partial class SettingsView : IControlView - { - public SettingsView() - { - InitializeComponent(); - } - - public SettingsView(IControlViewModel vm) : this() - { - DataContext = vm; - } - - public IControlViewModel ViewModel { get { return (IControlViewModel)DataContext; } } - } -} diff --git a/RetailCoder.VBE/UI/SourceControl/SourceControl.Designer.cs b/RetailCoder.VBE/UI/SourceControl/SourceControl.Designer.cs deleted file mode 100644 index 49c03f48ca..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/SourceControl.Designer.cs +++ /dev/null @@ -1,83 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Rubberduck.UI.SourceControl { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class SourceControl { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal SourceControl() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Rubberduck.UI.SourceControl.SourceControl", typeof(SourceControl).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap cross_circle { - get { - object obj = ResourceManager.GetObject("cross_circle", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap information { - get { - object obj = ResourceManager.GetObject("information", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - } -} diff --git a/RetailCoder.VBE/UI/SourceControl/SourceControl.resx b/RetailCoder.VBE/UI/SourceControl/SourceControl.resx deleted file mode 100644 index 98d8d9ebd0..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/SourceControl.resx +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - ..\..\Resources\cross-circle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\..\Resources\information.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - \ No newline at end of file diff --git a/RetailCoder.VBE/UI/SourceControl/SourceControlDockablePresenter.cs b/RetailCoder.VBE/UI/SourceControl/SourceControlDockablePresenter.cs deleted file mode 100644 index f851c03569..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/SourceControlDockablePresenter.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Diagnostics; -using Rubberduck.Settings; -using Rubberduck.SettingsProvider; -using Rubberduck.VBEditor.SafeComWrappers.Abstract; - -namespace Rubberduck.UI.SourceControl -{ - /// - /// Presenter for the source control view. - /// - public class SourceControlDockablePresenter : DockableToolwindowPresenter - { - public SourceControlDockablePresenter(IVBE vbe, IAddIn addin, SourceControlPanel window, IConfigProvider settings) - : base(vbe, addin, window, settings) - { - } - - public SourceControlPanel Window() - { - var control = UserControl as SourceControlPanel; - Debug.Assert(control != null); - return control; - } - } -} diff --git a/RetailCoder.VBE/UI/SourceControl/SourceControlPanel.Designer.cs b/RetailCoder.VBE/UI/SourceControl/SourceControlPanel.Designer.cs deleted file mode 100644 index 53a38b6dc0..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/SourceControlPanel.Designer.cs +++ /dev/null @@ -1,263 +0,0 @@ -using System.ComponentModel; -using System.Windows.Forms; - -namespace Rubberduck.UI.SourceControl -{ - partial class SourceControlPanel - { - /// - /// Required designer variable. - /// - private IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - /*System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SourceControlPanel)); - this.SourceControlToolbar = new System.Windows.Forms.ToolStrip(); - this.RefreshButton = new System.Windows.Forms.ToolStripButton(); - this.OpenWorkingFolderButton = new System.Windows.Forms.ToolStripButton(); - this.InitRepoButton = new System.Windows.Forms.ToolStripButton(); - this.CloneRepoButton = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.StatusMessage = new System.Windows.Forms.ToolStripLabel(); - this.SourceControlTabs = new System.Windows.Forms.TabControl(); - this.ChangesTab = new System.Windows.Forms.TabPage(); - this.BranchesTab = new System.Windows.Forms.TabPage(); - this.UnsyncedCommitsTab = new System.Windows.Forms.TabPage(); - this.SettingsTab = new System.Windows.Forms.TabPage(); - this.MainContainer = new System.Windows.Forms.SplitContainer(); - this.SourceControlToolbar.SuspendLayout(); - this.SourceControlTabs.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.MainContainer)).BeginInit(); - this.MainContainer.Panel2.SuspendLayout(); - this.MainContainer.SuspendLayout(); - this.SuspendLayout(); - // - // SourceControlToolbar - // - this.SourceControlToolbar.ImageScalingSize = new System.Drawing.Size(20, 20); - this.SourceControlToolbar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.RefreshButton, - this.OpenWorkingFolderButton, - this.InitRepoButton, - this.CloneRepoButton, - this.toolStripSeparator1, - this.StatusMessage}); - this.SourceControlToolbar.Location = new System.Drawing.Point(0, 0); - this.SourceControlToolbar.MaximumSize = new System.Drawing.Size(340, 31); - this.SourceControlToolbar.Name = "SourceControlToolbar"; - this.SourceControlToolbar.Size = new System.Drawing.Size(340, 27); - this.SourceControlToolbar.TabIndex = 0; - this.SourceControlToolbar.Text = "toolStrip1"; - // - // RefreshButton - // - this.RefreshButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.RefreshButton.Image = global::Rubberduck.Properties.Resources.arrow_circle_double; - this.RefreshButton.ImageTransparentColor = System.Drawing.Color.Magenta; - this.RefreshButton.Name = "RefreshButton"; - this.RefreshButton.Size = new System.Drawing.Size(24, 24); - this.RefreshButton.Text = "Refresh"; - this.RefreshButton.ToolTipText = "Refreshes pending changes"; - this.RefreshButton.Click += new System.EventHandler(this.RefreshButton_Click); - // - // OpenWorkingFolderButton - // - this.OpenWorkingFolderButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.OpenWorkingFolderButton.Image = global::Rubberduck.Properties.Resources.folder_horizontal_open; - this.OpenWorkingFolderButton.ImageTransparentColor = System.Drawing.Color.Magenta; - this.OpenWorkingFolderButton.Name = "OpenWorkingFolderButton"; - this.OpenWorkingFolderButton.Size = new System.Drawing.Size(24, 24); - this.OpenWorkingFolderButton.ToolTipText = "Open working folder"; - this.OpenWorkingFolderButton.Click += new System.EventHandler(this.OpenWorkingFolderButton_Click); - // - // InitRepoButton - // - this.InitRepoButton.AccessibleDescription = "Initialize repository from the active project."; - this.InitRepoButton.AccessibleName = "Initalize Report Button"; - this.InitRepoButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.InitRepoButton.Image = ((System.Drawing.Image)(resources.GetObject("InitRepoButton.Image"))); - this.InitRepoButton.ImageTransparentColor = System.Drawing.Color.Magenta; - this.InitRepoButton.Name = "InitRepoButton"; - this.InitRepoButton.Size = new System.Drawing.Size(24, 24); - this.InitRepoButton.ToolTipText = "Init New Repo from this Project"; - this.InitRepoButton.Click += new System.EventHandler(this.InitRepoButton_Click); - // - // CloneRepoButton - // - this.CloneRepoButton.AccessibleRole = System.Windows.Forms.AccessibleRole.None; - this.CloneRepoButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.CloneRepoButton.Image = global::Rubberduck.Properties.Resources.drive_download; - this.CloneRepoButton.ImageTransparentColor = System.Drawing.Color.Magenta; - this.CloneRepoButton.Name = "CloneRepoButton"; - this.CloneRepoButton.Size = new System.Drawing.Size(24, 24); - this.CloneRepoButton.Text = "Clone repo"; - this.CloneRepoButton.Click += new System.EventHandler(this.CloneRepoButton_Click); - // - // toolStripSeparator1 - // - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(6, 27); - // - // StatusMessage - // - this.StatusMessage.Enabled = false; - this.StatusMessage.ForeColor = System.Drawing.SystemColors.ButtonShadow; - this.StatusMessage.Image = global::Rubberduck.Properties.Resources.icon_github; - this.StatusMessage.Name = "StatusMessage"; - this.StatusMessage.Size = new System.Drawing.Size(74, 24); - this.StatusMessage.Text = "Offline"; - // - // SourceControlTabs - // - this.SourceControlTabs.Controls.Add(this.ChangesTab); - this.SourceControlTabs.Controls.Add(this.BranchesTab); - this.SourceControlTabs.Controls.Add(this.UnsyncedCommitsTab); - this.SourceControlTabs.Controls.Add(this.SettingsTab); - this.SourceControlTabs.Dock = System.Windows.Forms.DockStyle.Fill; - this.SourceControlTabs.Location = new System.Drawing.Point(0, 0); - this.SourceControlTabs.Margin = new System.Windows.Forms.Padding(4); - this.SourceControlTabs.Name = "SourceControlTabs"; - this.SourceControlTabs.SelectedIndex = 0; - this.SourceControlTabs.Size = new System.Drawing.Size(511, 405); - this.SourceControlTabs.TabIndex = 1; - // - // ChangesTab - // - this.ChangesTab.BackColor = System.Drawing.Color.Transparent; - this.ChangesTab.Location = new System.Drawing.Point(4, 25); - this.ChangesTab.Margin = new System.Windows.Forms.Padding(4); - this.ChangesTab.Name = "ChangesTab"; - this.ChangesTab.Padding = new System.Windows.Forms.Padding(4); - this.ChangesTab.Size = new System.Drawing.Size(503, 376); - this.ChangesTab.TabIndex = 0; - this.ChangesTab.Text = "Changes"; - // - // BranchesTab - // - this.BranchesTab.Location = new System.Drawing.Point(4, 25); - this.BranchesTab.Margin = new System.Windows.Forms.Padding(4); - this.BranchesTab.Name = "BranchesTab"; - this.BranchesTab.Padding = new System.Windows.Forms.Padding(4); - this.BranchesTab.Size = new System.Drawing.Size(503, 376); - this.BranchesTab.TabIndex = 1; - this.BranchesTab.Text = "Branches"; - this.BranchesTab.UseVisualStyleBackColor = true; - // - // UnsyncedCommitsTab - // - this.UnsyncedCommitsTab.Location = new System.Drawing.Point(4, 25); - this.UnsyncedCommitsTab.Margin = new System.Windows.Forms.Padding(4); - this.UnsyncedCommitsTab.Name = "UnsyncedCommitsTab"; - this.UnsyncedCommitsTab.Padding = new System.Windows.Forms.Padding(4); - this.UnsyncedCommitsTab.Size = new System.Drawing.Size(503, 376); - this.UnsyncedCommitsTab.TabIndex = 2; - this.UnsyncedCommitsTab.Text = "Unsynced commits"; - this.UnsyncedCommitsTab.UseVisualStyleBackColor = true; - // - // SettingsTab - // - this.SettingsTab.Location = new System.Drawing.Point(4, 25); - this.SettingsTab.Margin = new System.Windows.Forms.Padding(4); - this.SettingsTab.Name = "SettingsTab"; - this.SettingsTab.Padding = new System.Windows.Forms.Padding(4); - this.SettingsTab.Size = new System.Drawing.Size(503, 376); - this.SettingsTab.TabIndex = 3; - this.SettingsTab.Text = "Settings"; - this.SettingsTab.UseVisualStyleBackColor = true; - // - // MainContainer - // - this.MainContainer.Dock = System.Windows.Forms.DockStyle.Fill; - this.MainContainer.IsSplitterFixed = true; - this.MainContainer.Location = new System.Drawing.Point(0, 27); - this.MainContainer.Margin = new System.Windows.Forms.Padding(4); - this.MainContainer.Name = "MainContainer"; - this.MainContainer.Orientation = System.Windows.Forms.Orientation.Horizontal; - // - // MainContainer.Panel2 - // - this.MainContainer.Panel2.Controls.Add(this.SourceControlTabs); - this.MainContainer.Size = new System.Drawing.Size(511, 556); - this.MainContainer.SplitterDistance = 146; - this.MainContainer.SplitterWidth = 5; - this.MainContainer.TabIndex = 2; - // - // SourceControlPanel - // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.MainContainer); - this.Controls.Add(this.SourceControlToolbar); - this.Margin = new System.Windows.Forms.Padding(4); - this.MinimumSize = new System.Drawing.Size(340, 314); - this.Name = "SourceControlPanel"; - this.Size = new System.Drawing.Size(511, 583); - this.SourceControlToolbar.ResumeLayout(false); - this.SourceControlToolbar.PerformLayout(); - this.SourceControlTabs.ResumeLayout(false); - this.MainContainer.Panel2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.MainContainer)).EndInit(); - this.MainContainer.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout();*/ - - this.ElementHost = new System.Windows.Forms.Integration.ElementHost(); - this.SourceControlPanelControl = new Rubberduck.UI.SourceControl.SourceControlView(); - this.SuspendLayout(); - // - // elementHost1 - // - this.ElementHost.Dock = System.Windows.Forms.DockStyle.Fill; - this.ElementHost.Location = new System.Drawing.Point(0, 0); - this.ElementHost.Name = "elementHost1"; - this.ElementHost.Size = new System.Drawing.Size(150, 150); - this.ElementHost.TabIndex = 0; - this.ElementHost.Text = "elementHost1"; - this.ElementHost.Child = this.SourceControlPanelControl; - // - // SourceControlWindow - // - this.Controls.Add(this.ElementHost); - this.Name = "SourceControlWindow"; - this.ResumeLayout(false); - } - - #endregion - - /*private ToolStrip SourceControlToolbar; - private ToolStripButton RefreshButton; - private TabControl SourceControlTabs; - private TabPage ChangesTab; - private TabPage BranchesTab; - private TabPage UnsyncedCommitsTab; - private TabPage SettingsTab; - private ToolStripSeparator toolStripSeparator1; - private ToolStripLabel StatusMessage; - private ToolStripButton OpenWorkingFolderButton; - private ToolStripButton InitRepoButton; - private SplitContainer MainContainer; - private ToolStripButton CloneRepoButton;*/ - - private System.Windows.Forms.Integration.ElementHost ElementHost; - private SourceControlView SourceControlPanelControl; - } -} diff --git a/RetailCoder.VBE/UI/SourceControl/SourceControlPanel.cs b/RetailCoder.VBE/UI/SourceControl/SourceControlPanel.cs deleted file mode 100644 index f3a2761004..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/SourceControlPanel.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using System.Windows.Forms; - -namespace Rubberduck.UI.SourceControl -{ - [ExcludeFromCodeCoverage] - public partial class SourceControlPanel : UserControl, IDockableUserControl - { - private SourceControlPanel() - { - InitializeComponent(); - } - - public SourceControlPanel(SourceControlViewViewModel viewModel) : this() - { - _viewModel = viewModel; - SourceControlPanelControl.DataContext = viewModel; - } - - public string ClassId - { - get { return "19A32FC9-4902-4385-9FE7-829D4F9C441D"; } - } - - public string Caption - { - get { return RubberduckUI.SourceControlPanel_Caption; } - } - - private readonly SourceControlViewViewModel _viewModel; - public SourceControlViewViewModel ViewModel - { - get { return _viewModel; } - } - } -} diff --git a/RetailCoder.VBE/UI/SourceControl/SourceControlPanel.resx b/RetailCoder.VBE/UI/SourceControl/SourceControlPanel.resx deleted file mode 100644 index 24e9156e44..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/SourceControlPanel.resx +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAG2SURBVDhP1dPPS9NxHMfx/QvdROpgDrGUTRldhHQ7RAfp - IsToYBOxkQgjQaUojSQXGLQWiYI0lI0th4rrF+KPklVU/iZFzKlDtznHdH6by2bqns4vuyThyE69j28+ - n8fnA+/3S8I/1pHAd98oMy8qmOq5zmTnNcY6Shm2aXCa1Pi+DYlnJGtfTXidtXiGbrP09hbugRoW+qpw - 9VYy+1rHXizGZjTKiiDgCgRQfYkhexPhlbGQd5YbSHzv6+CHI/5cJ3uhDnaDVnZWzfzyt7MYR+cHbxKZ - e0J45hHCVCMbkw8Ijd9HmNDzvEGZAMLdxNZs7AYs7Ky0s+15xpa7hajXJAITXeWM2rV8tpby0axhsFWN - w1CYHIi4nrK12Hz8HxwA4dnHCNMPWY9fDI7VExi+y+qnO6yP3Psfgas9BcjbMii25B0PkNsyUfmLkLVI - /w4o6b+AvCvrNyDHmM7F6lMJ4A+LtO0z8XOpVRxj7ksZZaFqLge1IpC9fJ5UdxZpuhPJV/kgCxr7Oc5a - pZxpOy0CGYaTSPUpXGm6dHSYDpfCoRIBhTk/0UmSxsOl/VCJwq5E269LdGAfYd5FP2NXY7gAAAAASUVO - RK5CYII= - - - - 34 - - diff --git a/RetailCoder.VBE/UI/SourceControl/SourceControlProviderFactory.cs b/RetailCoder.VBE/UI/SourceControl/SourceControlProviderFactory.cs deleted file mode 100644 index 5f475e1c33..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/SourceControlProviderFactory.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Rubberduck.SourceControl; -using Rubberduck.VBEditor.SafeComWrappers.Abstract; - -namespace Rubberduck.UI.SourceControl -{ - public interface ISourceControlProviderFactory - { - ISourceControlProvider CreateProvider(IVBProject project); - ISourceControlProvider CreateProvider(IVBProject project, IRepository repository); - ISourceControlProvider CreateProvider(IVBProject project, IRepository repository, SecureCredentials secureCredentials); - void Release(ISourceControlProvider provider); - } -} diff --git a/RetailCoder.VBE/UI/SourceControl/SourceControlView.xaml b/RetailCoder.VBE/UI/SourceControl/SourceControlView.xaml deleted file mode 100644 index f8b136cf18..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/SourceControlView.xaml +++ /dev/null @@ -1,749 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - M 0,0 L 4,3.5 L 0,7 Z - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/RetailCoder.VBE/UI/SourceControl/UnsyncedCommitsView.xaml.cs b/RetailCoder.VBE/UI/SourceControl/UnsyncedCommitsView.xaml.cs deleted file mode 100644 index 13fee65b3f..0000000000 --- a/RetailCoder.VBE/UI/SourceControl/UnsyncedCommitsView.xaml.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Rubberduck.UI.SourceControl -{ - /// - /// Interaction logic for UnsyncedCommitsView.xaml - /// - public partial class UnsyncedCommitsView : IControlView - { - public UnsyncedCommitsView() - { - InitializeComponent(); - } - - public UnsyncedCommitsView(IControlViewModel vm) : this() - { - DataContext = vm; - } - - public IControlViewModel ViewModel { get { return (IControlViewModel)DataContext; } } - } -} diff --git a/RetailCoder.VBE/UnitTesting/FakesProviderFactory.cs b/RetailCoder.VBE/UnitTesting/FakesProviderFactory.cs deleted file mode 100644 index 8c4c8b277d..0000000000 --- a/RetailCoder.VBE/UnitTesting/FakesProviderFactory.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Rubberduck.UnitTesting -{ - public interface IFakesProviderFactory - { - FakesProvider GetFakesProvider(); - } - - public class FakesProviderFactory : IFakesProviderFactory - { - public FakesProvider GetFakesProvider() - { - return new FakesProvider(); - } - } -} diff --git a/RetailCoder.VBE/UnitTesting/ProjectTestExtensions.cs b/RetailCoder.VBE/UnitTesting/ProjectTestExtensions.cs deleted file mode 100644 index 375ba6943c..0000000000 --- a/RetailCoder.VBE/UnitTesting/ProjectTestExtensions.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Runtime.InteropServices; -using System.Reflection; -using System.IO; -using System.Linq; -using Rubberduck.VBEditor.SafeComWrappers.Abstract; - -namespace Rubberduck.UnitTesting -{ - [ComVisible(false)] - public static class ProjectTestExtensions - { - public static void EnsureReferenceToAddInLibrary(this IVBProject project) - { - var assembly = Assembly.GetExecutingAssembly(); - - var name = assembly.GetName().Name.Replace('.', '_'); - var referencePath = Path.ChangeExtension(assembly.Location, ".tlb"); - - var references = project.References; - { - var reference = references.SingleOrDefault(r => r.Name == name); - if (reference != null) - { - references.Remove(reference); - } - - if (references.All(r => r.FullPath != referencePath)) - { - references.AddFromFile(referencePath); - } - } - } - } -} diff --git a/RetailCoder.VBE/UnitTesting/TestEngine.cs b/RetailCoder.VBE/UnitTesting/TestEngine.cs deleted file mode 100644 index 1f113f50be..0000000000 --- a/RetailCoder.VBE/UnitTesting/TestEngine.cs +++ /dev/null @@ -1,139 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Runtime.InteropServices; -using NLog; -using Rubberduck.Parsing.Annotations; -using Rubberduck.Parsing.Symbols; -using Rubberduck.Parsing.VBA; -using Rubberduck.UI; -using Rubberduck.UI.UnitTesting; -using Rubberduck.VBEditor.Application; -using Rubberduck.VBEditor.SafeComWrappers.Abstract; - -namespace Rubberduck.UnitTesting -{ - public class TestEngine : ITestEngine - { - private readonly IVBE _vbe; - private readonly RubberduckParserState _state; - private readonly IFakesProviderFactory _fakesFactory; - - // can't be assigned from constructor because ActiveVBProject is null at startup: - private IHostApplication _hostApplication; - private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - - public TestEngine(TestExplorerModel model, IVBE vbe, RubberduckParserState state, IFakesProviderFactory fakesFactory) - { - Debug.WriteLine("TestEngine created."); - Model = model; - _vbe = vbe; - _state = state; - _fakesFactory = fakesFactory; - } - - public TestExplorerModel Model { get; } - - public event EventHandler TestCompleted; - - private void OnTestCompleted() - { - var handler = TestCompleted; - handler?.Invoke(this, EventArgs.Empty); - } - - public void Refresh() - { - Model.Refresh(); - } - - public void Run() - { - Refresh(); - Run(Model.LastRun); - } - - public void Run(IEnumerable tests) - { - var testMethods = tests as IList ?? tests.ToList(); - if (!testMethods.Any()) - { - return; - } - - var modules = testMethods.GroupBy(test => test.Declaration.QualifiedName.QualifiedModuleName); - foreach (var module in modules) - { - var testInitialize = module.Key.FindTestInitializeMethods(_state).ToList(); - var testCleanup = module.Key.FindTestCleanupMethods(_state).ToList(); - - var capturedModule = module; - var moduleTestMethods = testMethods - .Where(test => test.Declaration.QualifiedName.QualifiedModuleName.ProjectId == capturedModule.Key.ProjectId - && test.Declaration.QualifiedName.QualifiedModuleName.ComponentName == capturedModule.Key.ComponentName); - - var fakes = _fakesFactory.GetFakesProvider(); - - Run(module.Key.FindModuleInitializeMethods(_state)); - foreach (var test in moduleTestMethods) - { - // no need to run setup/teardown for ignored tests - if (test.Declaration.Annotations.Any(a => a.AnnotationType == AnnotationType.IgnoreTest)) - { - test.UpdateResult(TestOutcome.Ignored); - OnTestCompleted(); - continue; - } - - var stopwatch = new Stopwatch(); - stopwatch.Start(); - - try - { - fakes.StartTest(); - Run(testInitialize); - test.Run(); - Run(testCleanup); - } - catch (COMException ex) - { - Logger.Error(ex, "Unexpected COM exception while running tests.", test.Declaration?.QualifiedName); - test.UpdateResult(TestOutcome.Inconclusive, RubberduckUI.Assert_ComException); - } - finally - { - fakes.StopTest(); - } - - stopwatch.Stop(); - test.Result.SetDuration(stopwatch.ElapsedMilliseconds); - - OnTestCompleted(); - Model.AddExecutedTest(test); - } - Run(module.Key.FindModuleCleanupMethods(_state)); - } - } - - private void Run(IEnumerable members) - { - if (_hostApplication == null) - { - _hostApplication = _vbe.HostApplication(); - } - - foreach (var member in members) - { - try - { - _hostApplication.Run(member); - } - catch (COMException ex) - { - Logger.Error(ex, "Unexpected COM exception while running tests.", member?.QualifiedName); - } - } - } - } -} diff --git a/RetailCoder.VBE/API/VBA/Accessibility.cs b/Rubberduck.API/API/VBA/Accessibility.cs similarity index 77% rename from RetailCoder.VBE/API/VBA/Accessibility.cs rename to Rubberduck.API/API/VBA/Accessibility.cs index 14adad550f..36a62475e2 100644 --- a/RetailCoder.VBE/API/VBA/Accessibility.cs +++ b/Rubberduck.API/API/VBA/Accessibility.cs @@ -2,7 +2,7 @@ namespace Rubberduck.API.VBA { - [ComVisible(true)] + [ComVisible(true), Guid(RubberduckGuid.AccessibilityGuid)] public enum Accessibility { Implicit, diff --git a/RetailCoder.VBE/API/VBA/Declaration.cs b/Rubberduck.API/API/VBA/Declaration.cs similarity index 78% rename from RetailCoder.VBE/API/VBA/Declaration.cs rename to Rubberduck.API/API/VBA/Declaration.cs index 2071f7fc08..0aa1254585 100644 --- a/RetailCoder.VBE/API/VBA/Declaration.cs +++ b/Rubberduck.API/API/VBA/Declaration.cs @@ -32,20 +32,18 @@ public interface IDeclaration [EditorBrowsable(EditorBrowsableState.Always)] public class Declaration : IDeclaration { - private readonly RubberduckDeclaration _declaration; - internal Declaration(RubberduckDeclaration declaration) { - _declaration = declaration; + Instance = declaration; } - protected RubberduckDeclaration Instance { get { return _declaration; } } + protected RubberduckDeclaration Instance { get; } - public bool IsArray { get { return _declaration.IsArray; } } - public string Name { get { return _declaration.IdentifierName; } } - public Accessibility Accessibility { get { return (Accessibility)_declaration.Accessibility; } } - public DeclarationType DeclarationType {get { return TypeMappings[_declaration.DeclarationType]; }} - public string TypeName { get { return _declaration.AsTypeName; } } + public bool IsArray => Instance.IsArray; + public string Name => Instance.IdentifierName; + public Accessibility Accessibility => (Accessibility)Instance.Accessibility; + public DeclarationType DeclarationType => TypeMappings[Instance.DeclarationType]; + public string TypeName => Instance.AsTypeName; private static readonly IDictionary TypeMappings = new Dictionary @@ -75,20 +73,14 @@ internal Declaration(RubberduckDeclaration declaration) }; private Declaration _parentDeclaration; - public Declaration ParentDeclaration - { - get - { - return _parentDeclaration ?? (_parentDeclaration = new Declaration(Instance.ParentDeclaration)); - } - } + public Declaration ParentDeclaration => _parentDeclaration ?? (_parentDeclaration = new Declaration(Instance.ParentDeclaration)); private IdentifierReference[] _references; public IdentifierReference[] References { get { - return _references ?? (_references = _declaration.References.Select(item => new IdentifierReference(item)).ToArray()); + return _references ?? (_references = Instance.References.Select(item => new IdentifierReference(item)).ToArray()); } } } diff --git a/RetailCoder.VBE/API/VBA/DeclarationType.cs b/Rubberduck.API/API/VBA/DeclarationType.cs similarity index 94% rename from RetailCoder.VBE/API/VBA/DeclarationType.cs rename to Rubberduck.API/API/VBA/DeclarationType.cs index 72092b78aa..dd9daf1b72 100644 --- a/RetailCoder.VBE/API/VBA/DeclarationType.cs +++ b/Rubberduck.API/API/VBA/DeclarationType.cs @@ -2,7 +2,7 @@ namespace Rubberduck.API.VBA { - [ComVisible(true)] + [ComVisible(true), Guid(RubberduckGuid.DeclarationTypeGuid)] //[Flags] public enum DeclarationType { diff --git a/RetailCoder.VBE/API/VBA/IdentifierReference.cs b/Rubberduck.API/API/VBA/IdentifierReference.cs similarity index 55% rename from RetailCoder.VBE/API/VBA/IdentifierReference.cs rename to Rubberduck.API/API/VBA/IdentifierReference.cs index dfcd4f2546..64aff5f55c 100644 --- a/RetailCoder.VBE/API/VBA/IdentifierReference.cs +++ b/Rubberduck.API/API/VBA/IdentifierReference.cs @@ -31,28 +31,19 @@ public IdentifierReference(Parsing.Symbols.IdentifierReference reference) } private Declaration _declaration; - public Declaration Declaration - { - get { return _declaration ?? (_declaration = new Declaration(_reference.Declaration)); } - } + public Declaration Declaration => _declaration ?? (_declaration = new Declaration(_reference.Declaration)); private Declaration _parentScoping; - public Declaration ParentScope - { - get { return _parentScoping ?? (_parentScoping = new Declaration(_reference.ParentScoping)); } - } + public Declaration ParentScope => _parentScoping ?? (_parentScoping = new Declaration(_reference.ParentScoping)); private Declaration _parentNonScoping; - public Declaration ParentNonScoping - { - get { return _parentNonScoping ?? (_parentNonScoping = new Declaration(_reference.ParentNonScoping)); } - } + public Declaration ParentNonScoping => _parentNonScoping ?? (_parentNonScoping = new Declaration(_reference.ParentNonScoping)); - public bool IsAssignment { get { return _reference.IsAssignment; } } + public bool IsAssignment => _reference.IsAssignment; - public int StartLine { get { return _reference.Selection.StartLine; } } - public int EndLine { get { return _reference.Selection.EndLine; } } - public int StartColumn { get { return _reference.Selection.StartColumn; } } - public int EndColumn { get { return _reference.Selection.EndColumn; } } + public int StartLine => _reference.Selection.StartLine; + public int EndLine => _reference.Selection.EndLine; + public int StartColumn => _reference.Selection.StartColumn; + public int EndColumn => _reference.Selection.EndColumn; } } diff --git a/RetailCoder.VBE/API/VBA/ParserState.cs b/Rubberduck.API/API/VBA/ParserState.cs similarity index 83% rename from RetailCoder.VBE/API/VBA/ParserState.cs rename to Rubberduck.API/API/VBA/ParserState.cs index 5a4e9abc35..7b2d708afe 100644 --- a/RetailCoder.VBE/API/VBA/ParserState.cs +++ b/Rubberduck.API/API/VBA/ParserState.cs @@ -8,9 +8,12 @@ using Rubberduck.Parsing.PreProcessing; using Rubberduck.Parsing.Symbols.DeclarationLoaders; using Rubberduck.Parsing.VBA; -using Rubberduck.UI.Command.MenuItems; using Rubberduck.Parsing.Symbols; +using Rubberduck.Parsing.UIContext; +using Rubberduck.VBEditor.ComManagement; +using Rubberduck.VBEditor.Events; using Rubberduck.VBEditor.SafeComWrappers.VBA; +using Rubberduck.VBEditor.Utility; namespace Rubberduck.API.VBA { @@ -49,10 +52,13 @@ public sealed class ParserState : IParserState, IDisposable private AttributeParser _attributeParser; private ParseCoordinator _parser; private VBE _vbe; + private IVBEEvents _vbeEvents; + private readonly IUiDispatcher _dispatcher; public ParserState() { - UiDispatcher.Initialize(); + UiContextProvider.Initialize(); + _dispatcher = new UiDispatcher(UiContextProvider.Instance()); } public void Initialize(Microsoft.Vbe.Interop.VBE vbe) @@ -63,15 +69,17 @@ public void Initialize(Microsoft.Vbe.Interop.VBE vbe) } _vbe = new VBE(vbe); + _vbeEvents = VBEEvents.Initialize(_vbe); var declarationFinderFactory = new ConcurrentlyConstructedDeclarationFinderFactory(); - _state = new RubberduckParserState(null, declarationFinderFactory); + var projectRepository = new ProjectsRepository(_vbe); + _state = new RubberduckParserState(null, projectRepository, declarationFinderFactory, _vbeEvents); _state.StateChanged += _state_StateChanged; var exporter = new ModuleExporter(); Func preprocessorFactory = () => new VBAPreprocessor(double.Parse(_vbe.Version, CultureInfo.InvariantCulture)); - _attributeParser = new AttributeParser(exporter, preprocessorFactory); - var projectManager = new ProjectManager(_state, _vbe); + _attributeParser = new AttributeParser(exporter, preprocessorFactory, _state.ProjectsProvider); + var projectManager = new RepositoryProjectManager(projectRepository); var moduleToModuleReferenceManager = new ModuleToModuleReferenceManager(); var parserStateManager = new ParserStateManager(_state); var referenceRemover = new ReferenceRemover(_state, moduleToModuleReferenceManager); @@ -141,7 +149,7 @@ public void Parse() public void BeginParse() { // non-blocking call - UiDispatcher.Invoke(() => _state.OnParseRequested(this)); + _dispatcher.Invoke(() => _state.OnParseRequested(this)); } public event Action OnParsed; @@ -150,47 +158,36 @@ public void BeginParse() private void _state_StateChanged(object sender, EventArgs e) { - _allDeclarations = _state.AllDeclarations + AllDeclarations = _state.AllDeclarations .Select(item => new Declaration(item)) .ToArray(); - _userDeclarations = _state.AllUserDeclarations + UserDeclarations = _state.AllUserDeclarations .Select(item => new Declaration(item)) .ToArray(); var errorHandler = OnError; if (_state.Status == Parsing.VBA.ParserState.Error && errorHandler != null) { - UiDispatcher.Invoke(errorHandler.Invoke); + _dispatcher.Invoke(errorHandler.Invoke); } var parsedHandler = OnParsed; if (_state.Status == Parsing.VBA.ParserState.Parsed && parsedHandler != null) { - UiDispatcher.Invoke(parsedHandler.Invoke); + _dispatcher.Invoke(parsedHandler.Invoke); } var readyHandler = OnReady; if (_state.Status == Parsing.VBA.ParserState.Ready && readyHandler != null) { - UiDispatcher.Invoke(readyHandler.Invoke); + _dispatcher.Invoke(readyHandler.Invoke); } } - private Declaration[] _allDeclarations; + public Declaration[] AllDeclarations { get; private set; } - public Declaration[] AllDeclarations - { - //[return: MarshalAs(UnmanagedType.SafeArray/*, SafeArraySubType = VarEnum.VT_VARIANT*/)] - get { return _allDeclarations; } - } - - private Declaration[] _userDeclarations; - public Declaration[] UserDeclarations - { - //[return: MarshalAs(UnmanagedType.SafeArray/*, SafeArraySubType = VarEnum.VT_VARIANT*/)] - get { return _userDeclarations; } - } + public Declaration[] UserDeclarations { get; private set; } private bool _disposed; public void Dispose() diff --git a/Rubberduck.API/Properties/AssemblyInfo.cs b/Rubberduck.API/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..6fc89b1dbf --- /dev/null +++ b/Rubberduck.API/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Rubberduck.API")] +[assembly: AssemblyDescription("API for programmatic access to Rubberduck's Code Analysis features.")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Rubberduck-VBA")] +[assembly: AssemblyProduct("Rubberduck.API")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyCulture("en")] +[assembly: AssemblyTrademark("")] +[assembly: InternalsVisibleTo("RubberduckTests")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ac1b4a57-364a-4f90-a0cd-6ee818349ce5")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("2.1.*")] diff --git a/Rubberduck.API/Rubberduck.API.csproj b/Rubberduck.API/Rubberduck.API.csproj new file mode 100644 index 0000000000..44a0342f09 --- /dev/null +++ b/Rubberduck.API/Rubberduck.API.csproj @@ -0,0 +1,81 @@ + + + + + Debug + AnyCPU + {AC1B4A57-364A-4F90-A0CD-6EE818349CE5} + Library + Properties + Rubberduck.API + Rubberduck.API + v4.5 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\libs\Microsoft.VB6.Interop.VBIDE.dll + False + + + False + False + ..\libs\Microsoft.Vbe.Interop.dll + + + False + False + ..\libs\Microsoft.Vbe.Interop.Forms.dll + + + + + + + + + + + + + + + + {a1587eac-7b54-407e-853f-4c7493d0323e} + Rubberduck.Core + + + {a4a618e1-cbca-435f-9c6c-5181e030adfc} + Rubberduck.Parsing + + + {8ce35eb3-8852-4ba1-84dd-df3f5d2967b0} + Rubberduck.VBEditor + + + + + + + + + + \ No newline at end of file diff --git a/RetailCoder.VBE/app.config b/Rubberduck.API/app.config similarity index 100% rename from RetailCoder.VBE/app.config rename to Rubberduck.API/app.config diff --git a/RetailCoder.VBE/App.cs b/Rubberduck.Core/App.cs similarity index 95% rename from RetailCoder.VBE/App.cs rename to Rubberduck.Core/App.cs index 923f62c023..ecca2f7261 100644 --- a/RetailCoder.VBE/App.cs +++ b/Rubberduck.Core/App.cs @@ -11,8 +11,10 @@ using System.Globalization; using System.Windows.Forms; using Rubberduck.Parsing.Inspections.Resources; +using Rubberduck.Parsing.UIContext; using Rubberduck.UI.Command; using Rubberduck.VBEditor.SafeComWrappers.Abstract; +using Rubberduck.VBEditor.Utility; using Rubberduck.VersionCheck; using Application = System.Windows.Forms.Application; @@ -48,7 +50,7 @@ public App(IVBE vbe, _configService.SettingsChanged += _configService_SettingsChanged; - UiDispatcher.Initialize(); + UiContextProvider.Initialize(); } private void _configService_SettingsChanged(object sender, ConfigurationChangedEventArgs e) @@ -120,7 +122,7 @@ public void Startup() _hooks.HookHotkeys(); // need to hook hotkeys before we localize menus, to correctly display ShortcutTexts _appMenus.Localize(); - if (_config.UserSettings.GeneralSettings.CheckVersion) + if (_config.UserSettings.GeneralSettings.CanCheckVersion) { _checkVersionCommand.Execute(null); } @@ -165,7 +167,7 @@ private void CheckForLegacyIndenterSettings() try { Logger.Trace("Checking for legacy Smart Indenter settings."); - if (_config.UserSettings.GeneralSettings.SmartIndenterPrompted || + if (_config.UserSettings.GeneralSettings.IsSmartIndenterPrompted || !_config.UserSettings.IndenterSettings.LegacySettingsExist()) { return; @@ -177,7 +179,7 @@ private void CheckForLegacyIndenterSettings() Logger.Trace("Attempting to load legacy Smart Indenter settings."); _config.UserSettings.IndenterSettings.LoadLegacyFromRegistry(); } - _config.UserSettings.GeneralSettings.SmartIndenterPrompted = true; + _config.UserSettings.GeneralSettings.IsSmartIndenterPrompted = true; _configService.SaveConfiguration(_config); } catch diff --git a/RetailCoder.VBE/AppMenu.cs b/Rubberduck.Core/AppMenu.cs similarity index 80% rename from RetailCoder.VBE/AppMenu.cs rename to Rubberduck.Core/AppMenu.cs index bb9ac4f621..0705f9f26a 100644 --- a/RetailCoder.VBE/AppMenu.cs +++ b/Rubberduck.Core/AppMenu.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; +using NLog; using Rubberduck.Parsing; using Rubberduck.Parsing.VBA; using Rubberduck.UI; @@ -17,6 +19,8 @@ public class AppMenu : IAppMenu, IDisposable private readonly ISelectionChangeService _selectionService; private readonly RubberduckCommandBar _stateBar; + private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); + public AppMenu(IEnumerable menus, IParseCoordinator parser, ISelectionChangeService selectionService, RubberduckCommandBar stateBar) { _menus = menus.ToList(); @@ -77,7 +81,13 @@ private void RemoveMenus() { foreach (var menu in _menus.Where(menu => menu.Item != null)) { + _logger.Debug($"Starting removal of top-level menu {menu.GetType()}."); menu.RemoveMenu(); + //We do this here and not in the menu items because we only want to dispose of/release the parents of the top level parent menus. + //The parents further down get disposed of/released as part of the remove chain. + _logger.Trace($"Removing parent menu of top-level menu {menu.GetType()}."); + menu.Parent.Dispose(); + menu.Parent = null; } } } diff --git a/RetailCoder.VBE/Common/ApplicationConstants.cs b/Rubberduck.Core/Common/ApplicationConstants.cs similarity index 100% rename from RetailCoder.VBE/Common/ApplicationConstants.cs rename to Rubberduck.Core/Common/ApplicationConstants.cs diff --git a/RetailCoder.VBE/Common/ClipboardWriter.cs b/Rubberduck.Core/Common/ClipboardWriter.cs similarity index 94% rename from RetailCoder.VBE/Common/ClipboardWriter.cs rename to Rubberduck.Core/Common/ClipboardWriter.cs index 77e6fd616c..f03b0bf339 100644 --- a/RetailCoder.VBE/Common/ClipboardWriter.cs +++ b/Rubberduck.Core/Common/ClipboardWriter.cs @@ -19,8 +19,8 @@ public class ClipboardWriter : IClipboardWriter public void Write(string text) { - this.AppendString(DataFormats.UnicodeText, text); - this.Flush(); + AppendString(DataFormats.UnicodeText, text); + Flush(); } public void AppendImage(BitmapSource image) diff --git a/RetailCoder.VBE/Common/DeclarationExtensions.cs b/Rubberduck.Core/Common/DeclarationExtensions.cs similarity index 95% rename from RetailCoder.VBE/Common/DeclarationExtensions.cs rename to Rubberduck.Core/Common/DeclarationExtensions.cs index bbbd8ddccf..1af46c4617 100644 --- a/RetailCoder.VBE/Common/DeclarationExtensions.cs +++ b/Rubberduck.Core/Common/DeclarationExtensions.cs @@ -42,7 +42,7 @@ public static Selection GetVariableStmtContextSelection(this Declaration target) { if (target.DeclarationType != DeclarationType.Variable) { - throw new ArgumentException("Target DeclarationType is not Variable.", "target"); + throw new ArgumentException("Target DeclarationType is not Variable.", nameof(target)); } var statement = GetVariableStmtContext(target) ?? target.Context; // undeclared variables don't have a VariableStmtContext @@ -59,7 +59,7 @@ public static Selection GetConstStmtContextSelection(this Declaration target) { if (target.DeclarationType != DeclarationType.Constant) { - throw new ArgumentException("Target DeclarationType is not Constant.", "target"); + throw new ArgumentException("Target DeclarationType is not Constant.", nameof(target)); } var statement = GetConstStmtContext(target); @@ -76,7 +76,7 @@ public static VBAParser.VariableStmtContext GetVariableStmtContext(this Declarat { if (target.DeclarationType != DeclarationType.Variable) { - throw new ArgumentException("Target DeclarationType is not Variable.", "target"); + throw new ArgumentException("Target DeclarationType is not Variable.", nameof(target)); } Debug.Assert(target.IsUndeclared || target.Context is VBAParser.VariableSubStmtContext); @@ -99,7 +99,7 @@ public static VBAParser.ConstStmtContext GetConstStmtContext(this Declaration ta { if (target.DeclarationType != DeclarationType.Constant) { - throw new ArgumentException("Target DeclarationType is not Constant.", "target"); + throw new ArgumentException("Target DeclarationType is not Constant.", nameof(target)); } var statement = target.Context.Parent as VBAParser.ConstStmtContext; @@ -121,11 +121,11 @@ public static bool HasMultipleDeclarationsInStatement(this Declaration target) { if (target.DeclarationType != DeclarationType.Variable) { - throw new ArgumentException("Target DeclarationType is not Variable.", "target"); + throw new ArgumentException("Target DeclarationType is not Variable.", nameof(target)); } - var statement = target.Context.Parent as VBAParser.VariableListStmtContext; - return statement != null && statement.children.OfType().Count() > 1; + return target.Context.Parent is VBAParser.VariableListStmtContext statement + && statement.children.OfType().Count() > 1; } /// @@ -138,17 +138,15 @@ public static int CountOfDeclarationsInStatement(this Declaration target) { if (target.DeclarationType != DeclarationType.Variable) { - throw new ArgumentException("Target DeclarationType is not Variable.", "target"); + throw new ArgumentException("Target DeclarationType is not Variable.", nameof(target)); } - var statement = target.Context.Parent as VBAParser.VariableListStmtContext; - - if (statement != null) + if (target.Context.Parent is VBAParser.VariableListStmtContext statement) { return statement.children.OfType().Count(); } - throw new ArgumentException("'target.Context.Parent' is not type VBAParser.VariabelListStmtContext", "target"); + throw new ArgumentException("'target.Context.Parent' is not type VBAParser.VariabelListStmtContext", nameof(target)); } /// @@ -161,20 +159,17 @@ public static int IndexOfVariableDeclarationInStatement(this Declaration target) { if (target.DeclarationType != DeclarationType.Variable) { - throw new ArgumentException("Target DeclarationType is not Variable.", "target"); + throw new ArgumentException("Target DeclarationType is not Variable.", nameof(target)); } - var statement = target.Context.Parent as VBAParser.VariableListStmtContext; - - if (statement != null) + if (target.Context.Parent is VBAParser.VariableListStmtContext statement) { return statement.children.OfType() .ToList() .IndexOf((VBAParser.VariableSubStmtContext)target.Context) + 1; } - // ReSharper disable once LocalizableElement - throw new ArgumentException("'target.Context.Parent' is not type VBAParser.VariabelListStmtContext", "target"); + throw new ArgumentException("'target.Context.Parent' is not type VBAParser.VariableListStmtContext", nameof(target)); } public static readonly DeclarationType[] ProcedureTypes = @@ -298,9 +293,7 @@ public static Declaration FindSelectedDeclaration(this IEnumerable && item.QualifiedName.QualifiedModuleName == selection.QualifiedName).ToList(); var declaration = items.SingleOrDefault(item => - selector == null - ? item.Selection.Contains(selection.Selection) - : selector(item).Contains(selection.Selection)); + selector?.Invoke(item).Contains(selection.Selection) ?? item.Selection.Contains(selection.Selection)); if (declaration != null) { @@ -580,7 +573,7 @@ public static Declaration FindInterface(this IEnumerable declaratio { foreach (var reference in declaration.References) { - var implementsStmt = ParserRuleContextHelper.GetParent(reference.Context); + var implementsStmt = reference.Context.GetAncestor(); if (implementsStmt == null) { continue; } diff --git a/RetailCoder.VBE/Common/DeclarationIconCache.cs b/Rubberduck.Core/Common/DeclarationIconCache.cs similarity index 100% rename from RetailCoder.VBE/Common/DeclarationIconCache.cs rename to Rubberduck.Core/Common/DeclarationIconCache.cs diff --git a/RetailCoder.VBE/Common/ExportFormatter.cs b/Rubberduck.Core/Common/ExportFormatter.cs similarity index 76% rename from RetailCoder.VBE/Common/ExportFormatter.cs rename to Rubberduck.Core/Common/ExportFormatter.cs index 09eebf826c..582348d9eb 100644 --- a/RetailCoder.VBE/Common/ExportFormatter.cs +++ b/Rubberduck.Core/Common/ExportFormatter.cs @@ -8,12 +8,16 @@ namespace Rubberduck.Common { public enum hAlignment { - Left, Center, Right + Left, + Center, + Right } public enum vAlignment { - Top, Middle, Bottom + Top, + Middle, + Bottom } public class CellFormatting @@ -21,20 +25,25 @@ public class CellFormatting public hAlignment HorizontalAlignment; public vAlignment VerticalAlignment; public string FormatString; - public bool bold; + public bool IsBold; } public class ColumnInfo { - public ColumnInfo(string Title, hAlignment HorizontalAlignment = hAlignment.Left, vAlignment VerticalAlignment = vAlignment.Bottom) + public ColumnInfo(string title, hAlignment horizontalAlignment = hAlignment.Left, vAlignment verticalAlignment = vAlignment.Bottom) { - this.Title = Title; - this.Data = new CellFormatting(); - this.Data.HorizontalAlignment = HorizontalAlignment; - this.Data.VerticalAlignment = VerticalAlignment; - this.Heading = new CellFormatting(); - this.Heading.HorizontalAlignment = HorizontalAlignment; - this.Heading.VerticalAlignment = VerticalAlignment; + Title = title; + Data = new CellFormatting + { + HorizontalAlignment = horizontalAlignment, + VerticalAlignment = verticalAlignment + }; + + Heading = new CellFormatting + { + HorizontalAlignment = horizontalAlignment, + VerticalAlignment = verticalAlignment + }; } public CellFormatting Heading; public CellFormatting Data; @@ -51,10 +60,10 @@ public static string Csv(object[][] data, string title, ColumnInfo[] columnInfos headerRow[c] = CsvEncode(columnInfos[c].Title); } - string[] rows = new string[data.Length]; + var rows = new string[data.Length]; for (var r = 0; r < data.Length; r++) { - string[] row = new string[data[r].Length]; + var row = new string[data[r].Length]; for (var c = 0; c < data[r].Length; c++) { row[c] = CsvEncode(data[r][c]); @@ -66,7 +75,7 @@ public static string Csv(object[][] data, string title, ColumnInfo[] columnInfos private static string CsvEncode(object value) { - string s = ""; + var s = ""; if (value is string) { s = value.ToString(); @@ -91,7 +100,7 @@ private static string CsvEncode(object value) return s; } - public static string HtmlClipboardFragment(object[][] data, string Title, ColumnInfo[] ColumnInfos) + public static string HtmlClipboardFragment(object[][] data, string title, ColumnInfo[] columnInfos) { const string OffsetFormat = "0000000000"; const string CFHeaderTemplate = @@ -112,67 +121,65 @@ public static string HtmlClipboardFragment(object[][] data, string Title, Column "\r\n" + ""; - string html = ExportFormatter.HtmlTable(data, Title, ColumnInfos); + var html = ExportFormatter.HtmlTable(data, title, columnInfos); - int CFHeaderLength = string.Format(CFHeaderTemplate, OffsetFormat, OffsetFormat, OffsetFormat, OffsetFormat).Length; - int startFragment = CFHeaderLength + HtmlHeader.Length; - int endFragment = startFragment + html.Length; - int endHTML = endFragment + HtmlFooter.Length; + var CFHeaderLength = string.Format(CFHeaderTemplate, OffsetFormat, OffsetFormat, OffsetFormat, OffsetFormat).Length; + var startFragment = CFHeaderLength + HtmlHeader.Length; + var endFragment = startFragment + html.Length; + var endHTML = endFragment + HtmlFooter.Length; - string CfHtml = string.Format(CFHeaderTemplate, CFHeaderLength.ToString(OffsetFormat), endHTML.ToString(OffsetFormat), startFragment.ToString(OffsetFormat), endFragment.ToString(OffsetFormat)); + var CfHtml = string.Format(CFHeaderTemplate, CFHeaderLength.ToString(OffsetFormat), endHTML.ToString(OffsetFormat), startFragment.ToString(OffsetFormat), endFragment.ToString(OffsetFormat)); return CfHtml + HtmlHeader + html + HtmlFooter; } - public static string HtmlTable(object[][] data, string Title, ColumnInfo[] ColumnInfos) + public static string HtmlTable(object[][] data, string title, ColumnInfo[] columnInfos) { - string titleRow = HtmlCell(Title,true,false,3,ColumnInfos.Length); + var titleRow = HtmlCell(title,true,false,3,columnInfos.Length); - string[] hcells = new string[ColumnInfos.Length]; - for (var c = 0; c < ColumnInfos.Length; c++) + var hcells = new string[columnInfos.Length]; + for (var c = 0; c < columnInfos.Length; c++) { - hcells[c] = HtmlCell(ColumnInfos[c].Title, true, true, 3, 1, ColumnInfos[c].Heading.HorizontalAlignment); + hcells[c] = HtmlCell(columnInfos[c].Title, true, true, 3, 1, columnInfos[c].Heading.HorizontalAlignment); } - string headerRow = " \r\n" + string.Join(Environment.NewLine, hcells) + "\r\n"; + var headerRow = " \r\n" + string.Join(Environment.NewLine, hcells) + "\r\n"; - string[] rows = new string[data.Length]; + var rows = new string[data.Length]; for (var r = 0; r < data.Length; r++) { - string[] row = new string[data[r].Length]; + var row = new string[data[r].Length]; for (var c = 0; c < data[r].Length; c++) { - row[c] = HtmlCell(data[r][c], r == data.Length - 1, false, 3, 1, ColumnInfos[c].Heading.HorizontalAlignment); + row[c] = HtmlCell(data[r][c], r == data.Length - 1, false, 3, 1, columnInfos[c].Heading.HorizontalAlignment); } rows[r] = " \r\n" + string.Join(Environment.NewLine, row) + "\r\n"; } return "\r\n" + titleRow + "\r\n" + headerRow + "\r\n" + string.Join(Environment.NewLine, rows) + "\r\n
\r\n"; } - private static string HtmlCell(object value, bool BottomBorder = false, bool bold = false, int padding = 3, int colSpan = 1, hAlignment hAlign = hAlignment.Left) + private static string HtmlCell(object value, bool bottomBorder = false, bool bold = false, int padding = 3, int colSpan = 1, hAlignment hAlign = hAlignment.Left) { const string td = "
{3}
"; const string nbsp = " "; - string CellContent = nbsp; - string colspanAttribute = colSpan == 1 ? "" : " colspan=\"" + colSpan + "\""; - bool AlignLeft = true; - string Border = BottomBorder ? "0.5pt" : ""; + var cellContent = nbsp; + var colspanAttribute = colSpan == 1 ? "" : " colspan=\"" + colSpan + "\""; + var border = bottomBorder ? "0.5pt" : ""; if (value != null) { - CellContent = value.ToString().HtmlEncode(); - AlignLeft = value is string; + cellContent = value.ToString().HtmlEncode(); } - return string.Format(td, TdStyle(hAlign, Border, bold), colspanAttribute, TdDivStyle(padding, hAlign), CellContent); + return string.Format(td, TdStyle(hAlign, border, bold), colspanAttribute, TdDivStyle(padding, hAlign), cellContent); } - private static string TdStyle(hAlignment hAlign = hAlignment.Left, string BorderBottom = "", bool bold = false) + private static string TdStyle(hAlignment hAlign = hAlignment.Left, string borderBottom = "", bool isBold = false) { const string tdstyle = "vertical-align: bottom; "; - string sAlign = "text-align: " + hAlign.ToString() + "; " ; - string sBorder = BorderBottom.Length > 0 ? "border-bottom: " + BorderBottom + " solid #000000; " : ""; - string sWeight = bold ? "font-weight: bold; " : ""; + var sAlign = $"text-align: {hAlign.ToString()}; " ; + var sBorder = borderBottom.Length > 0 ? "border-bottom: " + borderBottom + " solid #000000; " : ""; + var sWeight = isBold ? "font-weight: bold; " : ""; return tdstyle + sAlign + sBorder + sWeight; } @@ -194,15 +201,17 @@ private static string HtmlEncode(this string value) return WebUtility.HtmlEncode(value.ToString()); } - public static MemoryStream XmlSpreadsheetNew(object[][] data, string Title, ColumnInfo[] ColumnInfos) + public static MemoryStream XmlSpreadsheetNew(object[][] data, string title, ColumnInfo[] columnInfos) { - MemoryStream strm = new MemoryStream(); - - XmlWriterSettings settings = new XmlWriterSettings(); - settings.Indent = true; - settings.Encoding = new UTF8Encoding(false); - - XmlWriter xmlSS = XmlWriter.Create(strm, settings); + var strm = new MemoryStream(); + + var settings = new XmlWriterSettings + { + Indent = true, + Encoding = new UTF8Encoding(false) + }; + + var xmlSS = XmlWriter.Create(strm, settings); xmlSS.WriteStartDocument(); @@ -338,26 +347,26 @@ public static MemoryStream XmlSpreadsheetNew(object[][] data, string Title, Colu xmlSS.WriteStartElement("Worksheet"); xmlSS.WriteAttributeString("ss", "Name", null, "Sheet1"); xmlSS.WriteStartElement("Table"); - xmlSS.WriteAttributeString("ss", "ExpandedColumnCount", null, ColumnInfos.Length.ToString()); + xmlSS.WriteAttributeString("ss", "ExpandedColumnCount", null, columnInfos.Length.ToString()); xmlSS.WriteAttributeString("ss", "ExpandedRowCount", null, (data.Length + 2).ToString()); xmlSS.WriteAttributeString("ss", "DefaultRowHeight", null, "15"); xmlSS.WriteStartElement("Row"); xmlSS.WriteStartElement("Cell"); - xmlSS.WriteAttributeString("ss", "MergeAcross", null, (ColumnInfos.Length-1).ToString()); + xmlSS.WriteAttributeString("ss", "MergeAcross", null, (columnInfos.Length-1).ToString()); xmlSS.WriteStartElement("Data"); xmlSS.WriteAttributeString("ss", "Type", null, "String"); - xmlSS.WriteValue(Title); + xmlSS.WriteValue(title); xmlSS.WriteEndElement(); //Close Data xmlSS.WriteEndElement(); //Close Cell xmlSS.WriteEndElement(); //Close Row //Column Headers - if (ColumnInfos.Length > 0) + if (columnInfos.Length > 0) { xmlSS.WriteStartElement("Row"); - foreach (ColumnInfo ch in ColumnInfos) + foreach (var ch in columnInfos) { xmlSS.WriteStartElement("Cell"); xmlSS.WriteAttributeString("ss", "StyleID", null, "Header" + ch.Heading.VerticalAlignment.ToString() + ch.Heading.HorizontalAlignment.ToString()); @@ -375,9 +384,9 @@ public static MemoryStream XmlSpreadsheetNew(object[][] data, string Title, Colu xmlSS.WriteStartElement("Row"); for (var c = 0; c < data[r].Length; c++) { - string ValueType = (data[r][c] is string || data[r][c] == null) ? "String" : "Number"; + var valueType = (data[r][c] is string || data[r][c] == null) ? "String" : "Number"; xmlSS.WriteStartElement("Cell"); - if (ColumnInfos[c].Data.HorizontalAlignment == hAlignment.Right) + if (columnInfos[c].Data.HorizontalAlignment == hAlignment.Right) { xmlSS.WriteAttributeString("ss", "StyleID", null, (r == data.Length - 1 ? "LastRowRightAligned" : "RightAligned")); } @@ -390,7 +399,7 @@ public static MemoryStream XmlSpreadsheetNew(object[][] data, string Title, Colu } xmlSS.WriteStartElement("Data"); - xmlSS.WriteAttributeString("ss", "Type", null, ValueType); + xmlSS.WriteAttributeString("ss", "Type", null, valueType); if (data[r][c] != null) { xmlSS.WriteValue(data[r][c].ToString()); @@ -411,7 +420,7 @@ public static MemoryStream XmlSpreadsheetNew(object[][] data, string Title, Colu } - public static string RTF(object[][] data, string Title) + public static string RTF(object[][] data, string title) { const byte fontSize = 16; //half-points const long colWidth = 1440; //twips @@ -430,44 +439,44 @@ public static string RTF(object[][] data, string Title) const string titleFormat = @"\pard{{{0}}}\par{1}"; const string rtfEnd = @"}}{0}"; - string newLine = Environment.NewLine; + var newLine = Environment.NewLine; - StringBuilder s = new StringBuilder(); - s.AppendFormat(rtfStart, fontSize.ToString(), newLine); - s.AppendFormat(titleFormat, Title, newLine); + var sb = new StringBuilder(); + sb.AppendFormat(rtfStart, fontSize, newLine); + sb.AppendFormat(titleFormat, title, newLine); - string cellBorders = string.Format(borderBottom, borderWidth) + string.Format(borderTop, borderWidth); + var cellBorders = string.Format(borderBottom, borderWidth) + string.Format(borderTop, borderWidth); for (var r = 0; r < data.Length; r++) { if (r == 0) { - s.AppendFormat(rowStart,newLine); - for (int c = 0; c < data[r].Length; c++) + sb.AppendFormat(rowStart,newLine); + for (var c = 0; c < data[r].Length; c++) { - s.AppendFormat(headerFormat, cellBorders, colWidth * (c+1), newLine); + sb.AppendFormat(headerFormat, cellBorders, colWidth * (c+1), newLine); } - for (int c = 0; c < data[r].Length; c++) + for (var c = 0; c < data[r].Length; c++) { - s.AppendFormat(cellContent, cellPadding, string.Format(boldFormat,"Col. " + (c+1).ToString()), newLine); + sb.AppendFormat(cellContent, cellPadding, string.Format(boldFormat,"Col. " + (c+1)), newLine); } - s.AppendFormat(rowEnd,newLine); + sb.AppendFormat(rowEnd,newLine); } cellBorders = (r == data.Length - 1) ? string.Format(borderBottom, borderWidth) : ""; - s.AppendFormat(rowStart, newLine); - for (int c = 0; c < data[r].Length; c++) + sb.AppendFormat(rowStart, newLine); + for (var c = 0; c < data[r].Length; c++) { - s.AppendFormat(cellFormat, cellBorders, colWidth * (c + 1), newLine); + sb.AppendFormat(cellFormat, cellBorders, colWidth * (c + 1), newLine); } - for (int c = 0; c < data[r].Length; c++) + for (var c = 0; c < data[r].Length; c++) { - s.AppendFormat(cellContent, cellPadding, data[r][c], newLine); + sb.AppendFormat(cellContent, cellPadding, data[r][c], newLine); } - s.AppendFormat(rowEnd, newLine); + sb.AppendFormat(rowEnd, newLine); } - s.AppendFormat(rtfEnd, newLine); - return s.ToString(); + sb.AppendFormat(rtfEnd, newLine); + return sb.ToString(); } } } diff --git a/RetailCoder.VBE/Common/HookEventArgs.cs b/Rubberduck.Core/Common/HookEventArgs.cs similarity index 62% rename from RetailCoder.VBE/Common/HookEventArgs.cs rename to Rubberduck.Core/Common/HookEventArgs.cs index 3772b7eebc..5d62c56bd0 100644 --- a/RetailCoder.VBE/Common/HookEventArgs.cs +++ b/Rubberduck.Core/Common/HookEventArgs.cs @@ -5,16 +5,15 @@ namespace Rubberduck.Common { public class HookEventArgs : EventArgs { - private readonly Keys _key; private static readonly Lazy _empty = new Lazy(() => new HookEventArgs(Keys.None)); public HookEventArgs(Keys key) { - _key = key; + Key = key; } - public Keys Key { get { return _key; } } + public Keys Key { get; } - public new static HookEventArgs Empty {get { return _empty.Value; }} + public new static HookEventArgs Empty => _empty.Value; } } diff --git a/RetailCoder.VBE/Common/Hotkeys/Hotkey.cs b/Rubberduck.Core/Common/Hotkeys/Hotkey.cs similarity index 77% rename from RetailCoder.VBE/Common/Hotkeys/Hotkey.cs rename to Rubberduck.Core/Common/Hotkeys/Hotkey.cs index 909e291520..b14d43b098 100644 --- a/RetailCoder.VBE/Common/Hotkeys/Hotkey.cs +++ b/Rubberduck.Core/Common/Hotkeys/Hotkey.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Runtime.InteropServices; using System.Windows.Forms; using Rubberduck.Common.WinAPI; using NLog; @@ -10,8 +11,6 @@ namespace Rubberduck.Common.Hotkeys { public class Hotkey : IHotkey { - private readonly string _key; - private readonly CommandBase _command; private readonly IntPtr _hWndVbe; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); @@ -20,19 +19,21 @@ public Hotkey(IntPtr hWndVbe, string key, CommandBase command, Keys secondKey = _hWndVbe = hWndVbe; IsTwoStepHotkey = secondKey != Keys.None; - _key = key; - _command = command; + Key = key; + Command = command; Combo = GetCombo(key); SecondKey = secondKey; } - public CommandBase Command { get { return _command; } } - public string Key { get { return _key; } } + public CommandBase Command { get; } + + public string Key { get; } + public HotkeyInfo HotkeyInfo { get; private set; } - public Keys Combo { get; private set; } - public Keys SecondKey { get; private set; } - public bool IsTwoStepHotkey { get; private set; } - public bool IsAttached { get; private set; } + public Keys Combo { get; } + public Keys SecondKey { get; } + public bool IsTwoStepHotkey { get; } + public bool IsAttached => HotkeyInfo.HookId != IntPtr.Zero; public event EventHandler MessageReceived; @@ -48,13 +49,13 @@ public void OnMessageReceived() public void Attach() { - var hotKey = _key; + var hotKey = Key; var shift = GetModifierValue(ref hotKey); var key = GetKey(hotKey); if (key == Keys.None) { - throw new InvalidOperationException(Rubberduck.UI.RubberduckUI.CommonHotkey_InvalidKey); + throw new InvalidOperationException(RubberduckUI.CommonHotkey_InvalidKey); } HookKey(key, shift); @@ -68,10 +69,19 @@ public void Detach() return; } - User32.UnregisterHotKey(_hWndVbe, HotkeyInfo.HookId); + if (!User32.UnregisterHotKey(_hWndVbe, HotkeyInfo.HookId)) + { + Logger.Warn($"Error calling UnregisterHotKey on hokey with id {HotkeyInfo.HookId} for command of type {Command.GetType()}; the error was {Marshal.GetLastWin32Error()}; going to delete the atom anyway... The memory may leak."); + } + Kernel32.SetLastError(Kernel32.ERROR_SUCCESS); Kernel32.GlobalDeleteAtom(HotkeyInfo.HookId); + var lastError = Marshal.GetLastWin32Error(); + if (lastError != Kernel32.ERROR_SUCCESS) + { + Logger.Warn($"Error calling DeleteGlobalAtom; the error was {lastError}, the id {HotkeyInfo.HookId} and the type of the associated command {Command.GetType()}."); + } - IsAttached = false; + HotkeyInfo = new HotkeyInfo(IntPtr.Zero, Combo); ClearCommandShortcutText(); } @@ -83,20 +93,26 @@ private void HookKey(Keys key, uint shift) } var hookId = (IntPtr)Kernel32.GlobalAddAtom(Guid.NewGuid().ToString()); + if (hookId == IntPtr.Zero) + { + Logger.Warn($"Error calling GlobalAddAtom; the error was {Marshal.GetLastWin32Error()}; aborting the HookKey operation..."); + return; + } + var success = User32.RegisterHotKey(_hWndVbe, hookId, shift, (uint)key); if (!success) { Logger.Debug(RubberduckUI.CommonHotkey_KeyNotRegistered, key); + return; } HotkeyInfo = new HotkeyInfo(hookId, Combo); - IsAttached = true; + Logger.Trace($"Hotkey for the associated command {Command.GetType()} was registered with id {HotkeyInfo.HookId}"); } private void SetCommandShortcutText() { - var command = Command as CommandBase; - if (command != null) + if (Command is CommandBase command) { command.ShortcutText = HotkeyInfo.ToString(); } @@ -104,14 +120,12 @@ private void SetCommandShortcutText() private void ClearCommandShortcutText() { - var command = Command as CommandBase; - if (command != null) + if (Command is CommandBase command) { command.ShortcutText = string.Empty; } } - - + private static readonly IDictionary Modifiers = new Dictionary { { '+', (uint)KeyModifier.SHIFT }, diff --git a/Rubberduck.Core/Common/Hotkeys/HotkeyFactory.cs b/Rubberduck.Core/Common/Hotkeys/HotkeyFactory.cs new file mode 100644 index 0000000000..9fd8a01a6e --- /dev/null +++ b/Rubberduck.Core/Common/Hotkeys/HotkeyFactory.cs @@ -0,0 +1,30 @@ +using Rubberduck.Settings; +using Rubberduck.UI.Command; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Rubberduck.Common.Hotkeys +{ + public class HotkeyFactory + { + private readonly IEnumerable _commands; + + public HotkeyFactory(IEnumerable commands) + { + _commands = commands; + } + + public Hotkey Create(HotkeySetting setting, IntPtr hWndVbe) + { + if (setting == null) + { + return null; + } + + var commandToBind = _commands.FirstOrDefault(command => command.GetType().Name == setting.CommandTypeName); + + return commandToBind == null ? null : new Hotkey(hWndVbe, setting.ToString(), commandToBind); + } + } +} diff --git a/RetailCoder.VBE/Common/Hotkeys/HotkeyInfo.cs b/Rubberduck.Core/Common/Hotkeys/HotkeyInfo.cs similarity index 100% rename from RetailCoder.VBE/Common/Hotkeys/HotkeyInfo.cs rename to Rubberduck.Core/Common/Hotkeys/HotkeyInfo.cs diff --git a/RetailCoder.VBE/Common/Hotkeys/IHotkey.cs b/Rubberduck.Core/Common/Hotkeys/IHotkey.cs similarity index 100% rename from RetailCoder.VBE/Common/Hotkeys/IHotkey.cs rename to Rubberduck.Core/Common/Hotkeys/IHotkey.cs diff --git a/RetailCoder.VBE/Common/IAttachable.cs b/Rubberduck.Core/Common/IAttachable.cs similarity index 100% rename from RetailCoder.VBE/Common/IAttachable.cs rename to Rubberduck.Core/Common/IAttachable.cs diff --git a/RetailCoder.VBE/Common/IExportable.cs b/Rubberduck.Core/Common/IExportable.cs similarity index 100% rename from RetailCoder.VBE/Common/IExportable.cs rename to Rubberduck.Core/Common/IExportable.cs diff --git a/RetailCoder.VBE/Common/IOperatingSystem.cs b/Rubberduck.Core/Common/IOperatingSystem.cs similarity index 100% rename from RetailCoder.VBE/Common/IOperatingSystem.cs rename to Rubberduck.Core/Common/IOperatingSystem.cs diff --git a/RetailCoder.VBE/Common/IRubberduckHooks.cs b/Rubberduck.Core/Common/IRubberduckHooks.cs similarity index 100% rename from RetailCoder.VBE/Common/IRubberduckHooks.cs rename to Rubberduck.Core/Common/IRubberduckHooks.cs diff --git a/RetailCoder.VBE/Common/KeyHookEventArgs.cs b/Rubberduck.Core/Common/KeyHookEventArgs.cs similarity index 59% rename from RetailCoder.VBE/Common/KeyHookEventArgs.cs rename to Rubberduck.Core/Common/KeyHookEventArgs.cs index 9907cc0fe0..ac10aa5927 100644 --- a/RetailCoder.VBE/Common/KeyHookEventArgs.cs +++ b/Rubberduck.Core/Common/KeyHookEventArgs.cs @@ -9,16 +9,13 @@ namespace Rubberduck.Common ///
public class KeyHookEventArgs : EventArgs { - private readonly Keys _key; - private readonly VBComponent _component; - public KeyHookEventArgs(Keys key, VBComponent component) { - _key = key; - _component = component; + Key = key; + Component = component; } - public Keys Key { get { return _key; } } - public VBComponent Component { get { return _component; } } + public Keys Key { get; } + public VBComponent Component { get; } } } diff --git a/RetailCoder.VBE/Common/LogLevelHelper.cs b/Rubberduck.Core/Common/LogLevelHelper.cs similarity index 82% rename from RetailCoder.VBE/Common/LogLevelHelper.cs rename to Rubberduck.Core/Common/LogLevelHelper.cs index f8bbc97f0c..d7545d151e 100644 --- a/RetailCoder.VBE/Common/LogLevelHelper.cs +++ b/Rubberduck.Core/Common/LogLevelHelper.cs @@ -12,21 +12,18 @@ public static class LogLevelHelper private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static string LogHeader; - private static bool LogHeaderWritten; + private static bool IsLogHeaderWritten; - public static IEnumerable LogLevels - { - get - { - return _logLevels.Value; - } - } + public static IEnumerable LogLevels => _logLevels.Value; private static IEnumerable GetLogLevels() { - var logLevels = new List(); - logLevels.Add(LogLevel.Off); - for (int logLevelOrdinal = 0; logLevelOrdinal <= 5; logLevelOrdinal++) + var logLevels = new List + { + LogLevel.Off + }; + + for (var logLevelOrdinal = 0; logLevelOrdinal <= 5; logLevelOrdinal++) { logLevels.Add(LogLevel.FromOrdinal(logLevelOrdinal)); } @@ -43,19 +40,19 @@ public static int MaxLogLevel() return GetLogLevels().Max(lvl => lvl.Ordinal); } - public static void SetDebugInfo(String value) + public static void SetDebugInfo(string value) { LogHeader = value; - LogHeaderWritten = false; + IsLogHeaderWritten = false; } public static void SetMinimumLogLevel(LogLevel minimumLogLevel) { - if (LogManager.GlobalThreshold == minimumLogLevel && LogHeaderWritten == true) + if (LogManager.GlobalThreshold == minimumLogLevel && IsLogHeaderWritten == true) { return; } - if (LogHeaderWritten == true) + if (IsLogHeaderWritten == true) { Logger.Log(LogLevel.Info, "Minimum log level changing from " + LogManager.GlobalThreshold.Name + @@ -86,10 +83,11 @@ public static void SetMinimumLogLevel(LogLevel minimumLogLevel) } LogManager.GlobalThreshold = minimumLogLevel; LogManager.ReconfigExistingLoggers(); - if (LogHeaderWritten == false) + + if (!IsLogHeaderWritten) { Logger.Log(minimumLogLevel, LogHeader); - LogHeaderWritten = true; + IsLogHeaderWritten = true; } } diff --git a/RetailCoder.VBE/Common/ModuleExporter.cs b/Rubberduck.Core/Common/ModuleExporter.cs similarity index 85% rename from RetailCoder.VBE/Common/ModuleExporter.cs rename to Rubberduck.Core/Common/ModuleExporter.cs index f657462280..f99348f951 100644 --- a/RetailCoder.VBE/Common/ModuleExporter.cs +++ b/Rubberduck.Core/Common/ModuleExporter.cs @@ -11,6 +11,7 @@ public class ModuleExporter : IModuleExporter public string ExportPath => TempFile ? ApplicationConstants.RUBBERDUCK_TEMP_PATH + // note that App is not in the entry-point assembly, since Core is not the entry point anymore : Path.GetDirectoryName(Assembly.GetAssembly(typeof(App)).Location); public string Export(IVBComponent component, bool tempFile = true) diff --git a/RetailCoder.VBE/Common/RubberduckHooks.cs b/Rubberduck.Core/Common/RubberduckHooks.cs similarity index 80% rename from RetailCoder.VBE/Common/RubberduckHooks.cs rename to Rubberduck.Core/Common/RubberduckHooks.cs index 13f131d323..6e6b58a006 100644 --- a/RetailCoder.VBE/Common/RubberduckHooks.cs +++ b/Rubberduck.Core/Common/RubberduckHooks.cs @@ -1,12 +1,9 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using System.Diagnostics; using System.Linq; using Rubberduck.Common.Hotkeys; -using Rubberduck.Common.WinAPI; using Rubberduck.Settings; -using Rubberduck.UI.Command; using NLog; using Rubberduck.VBEditor.SafeComWrappers.Abstract; using Rubberduck.VBEditor.WindowsApi; @@ -16,20 +13,15 @@ namespace Rubberduck.Common public class RubberduckHooks : SubclassingWindow, IRubberduckHooks { private readonly IGeneralConfigService _config; - private readonly IEnumerable _commands; + private readonly HotkeyFactory _hotkeyFactory; private readonly IList _hooks = new List(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - public RubberduckHooks(IVBE vbe, IGeneralConfigService config, IEnumerable commands) + public RubberduckHooks(IVBE vbe, IGeneralConfigService config, HotkeyFactory hotkeyFactory) : base((IntPtr)vbe.MainWindow.HWnd, (IntPtr)vbe.MainWindow.HWnd) { - _commands = commands; _config = config; - } - - private CommandBase Command(RubberduckHotkey hotkey) - { - return _commands.FirstOrDefault(s => s.Hotkey == hotkey); + _hotkeyFactory = hotkeyFactory; } public void HookHotkeys() @@ -40,21 +32,19 @@ public void HookHotkeys() var config = _config.LoadConfiguration(); var settings = config.UserSettings.HotkeySettings; - foreach (var hotkey in settings.Settings.Where(hotkey => hotkey.IsEnabled)) + foreach (var hotkeySetting in settings.Settings.Where(hotkeySetting => hotkeySetting.IsEnabled)) { - RubberduckHotkey assigned; - if (Enum.TryParse(hotkey.Name, out assigned)) + var hotkey = _hotkeyFactory.Create(hotkeySetting, Hwnd); + if (hotkey != null) { - var command = Command(assigned); - Debug.Assert(command != null); - - AddHook(new Hotkey(Hwnd, hotkey.ToString(), command)); + AddHook(hotkey); } } + Attach(); } - public IEnumerable Hooks { get { return _hooks; } } + public IEnumerable Hooks => _hooks; public void AddHook(IAttachable hook) { @@ -65,11 +55,7 @@ public void AddHook(IAttachable hook) private void OnMessageReceived(object sender, HookEventArgs args) { - var handler = MessageReceived; - if (handler != null) - { - handler.Invoke(sender, args); - } + MessageReceived?.Invoke(sender, args); } public bool IsAttached { get; private set; } @@ -121,8 +107,8 @@ public void Detach() private void hook_MessageReceived(object sender, HookEventArgs e) { - var hotkey = sender as IHotkey; - if (hotkey != null && hotkey.Command.CanExecute(null)) + if (sender is IHotkey hotkey + && hotkey.Command.CanExecute(null)) { hotkey.Command.Execute(null); return; @@ -161,7 +147,6 @@ public override int SubClassProc(IntPtr hWnd, IntPtr msg, IntPtr wParam, IntPtr break; case WM.CLOSE: case WM.DESTROY: - case WM.RUBBERDUCK_SINKING: Detach(); break; } @@ -186,5 +171,14 @@ private bool HandleHotkeyMessage(IntPtr wParam) } return processed; } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + Detach(); + } + base.Dispose(disposing); + } } } diff --git a/RetailCoder.VBE/Common/StringExtensions.cs b/Rubberduck.Core/Common/StringExtensions.cs similarity index 100% rename from RetailCoder.VBE/Common/StringExtensions.cs rename to Rubberduck.Core/Common/StringExtensions.cs diff --git a/RetailCoder.VBE/Common/UndocumentedAttribute.cs b/Rubberduck.Core/Common/UndocumentedAttribute.cs similarity index 100% rename from RetailCoder.VBE/Common/UndocumentedAttribute.cs rename to Rubberduck.Core/Common/UndocumentedAttribute.cs diff --git a/RetailCoder.VBE/Common/VariableNameValidator.cs b/Rubberduck.Core/Common/VariableNameValidator.cs similarity index 94% rename from RetailCoder.VBE/Common/VariableNameValidator.cs rename to Rubberduck.Core/Common/VariableNameValidator.cs index 3fc80745e8..6f3ec275a5 100644 --- a/RetailCoder.VBE/Common/VariableNameValidator.cs +++ b/Rubberduck.Core/Common/VariableNameValidator.cs @@ -8,8 +8,8 @@ namespace Rubberduck.Common { public static class VariableNameValidator { - private static readonly string Vowels = "aeiouyàâäéèêëïîöôùûü"; - private static readonly int MinVariableNameLength = 3; + private const string Vowels = "aeiouyàâäéèêëïîöôùûü"; + private const int MinVariableNameLength = 3; private static bool HasVowel(string name) { diff --git a/Rubberduck.Core/Common/WinAPI/Kernel32.cs b/Rubberduck.Core/Common/WinAPI/Kernel32.cs new file mode 100644 index 0000000000..a82e23393e --- /dev/null +++ b/Rubberduck.Core/Common/WinAPI/Kernel32.cs @@ -0,0 +1,42 @@ +using System; +using System.Runtime.InteropServices; + +namespace Rubberduck.Common.WinAPI +{ + /// + /// Exposes Kernel32.dll API. + /// + public static class Kernel32 + { + /// + /// Adds a character string to the global atom table and returns a unique value (an atom) identifying the string. + /// + /// + /// The null-terminated string to be added. + /// The string can have a maximum size of 255 bytes. + /// Strings that differ only in case are considered identical. + /// The case of the first string of this name added to the table is preserved and returned by the GlobalGetAtomName function. + /// + /// If the function succeeds, the return value is the newly created atom. + [DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)] + public static extern ushort GlobalAddAtom(string lpString); + + /// + /// Decrements the reference count of a global string atom. + /// If the atom's reference count reaches zero, GlobalDeleteAtom removes the string associated with the atom from the global atom table. + /// + /// The atom and character string to be deleted. + /// The function always returns (ATOM) 0. + [DllImport("kernel32.dll", SetLastError=true, ExactSpelling=true)] + public static extern ushort GlobalDeleteAtom(IntPtr nAtom); + + /// + /// Sets the last-error code for the calling thread. + /// + /// The last-error code for the thread. + [DllImport("kernel32.dll", SetLastError = true)] + public static extern void SetLastError(uint dwErrorCode); + + public static uint ERROR_SUCCESS = 0; + } +} diff --git a/RetailCoder.VBE/Common/WinAPI/POINT.cs b/Rubberduck.Core/Common/WinAPI/POINT.cs similarity index 53% rename from RetailCoder.VBE/Common/WinAPI/POINT.cs rename to Rubberduck.Core/Common/WinAPI/POINT.cs index 35c5f2569c..57e5cc413f 100644 --- a/RetailCoder.VBE/Common/WinAPI/POINT.cs +++ b/Rubberduck.Core/Common/WinAPI/POINT.cs @@ -3,27 +3,27 @@ namespace Rubberduck.Common.WinAPI { [StructLayout(LayoutKind.Sequential)] - public struct POINT + public struct Point { public int X; public int Y; - public POINT(int x, int y) + public Point(int x, int y) { X = x; Y = y; } - public POINT(System.Drawing.Point pt) : this(pt.X, pt.Y) { } + public Point(System.Drawing.Point pt) : this(pt.X, pt.Y) { } - public static implicit operator System.Drawing.Point(POINT p) + public static implicit operator System.Drawing.Point(Point p) { return new System.Drawing.Point(p.X, p.Y); } - public static implicit operator POINT(System.Drawing.Point p) + public static implicit operator Point(System.Drawing.Point p) { - return new POINT(p.X, p.Y); + return new Point(p.X, p.Y); } } } diff --git a/RetailCoder.VBE/Common/WinAPI/RegistryAccess.cs b/Rubberduck.Core/Common/WinAPI/RegistryAccess.cs similarity index 65% rename from RetailCoder.VBE/Common/WinAPI/RegistryAccess.cs rename to Rubberduck.Core/Common/WinAPI/RegistryAccess.cs index f63cff1c1b..6e048ad08d 100644 --- a/RetailCoder.VBE/Common/WinAPI/RegistryAccess.cs +++ b/Rubberduck.Core/Common/WinAPI/RegistryAccess.cs @@ -2,9 +2,9 @@ namespace Rubberduck.Common.WinAPI { - static internal class RegistryAccess + internal static class RegistryAccess { - static internal RegistryKey GetDeviceKey(string device) + internal static RegistryKey GetDeviceKey(string device) { var split = device.Substring(4).Split('#'); @@ -12,10 +12,11 @@ static internal RegistryKey GetDeviceKey(string device) var subClassCode = split[1]; // PNP0303 (SubClass code) var protocolCode = split[2]; // 3&13c0b0c5&0 (Protocol code) - return Registry.LocalMachine.OpenSubKey(string.Format(@"System\CurrentControlSet\Enum\{0}\{1}\{2}", classCode, subClassCode, protocolCode)); + return Registry.LocalMachine.OpenSubKey( + $@"System\CurrentControlSet\Enum\{classCode}\{subClassCode}\{protocolCode}"); } - static internal string GetClassType(string classGuid) + internal static string GetClassType(string classGuid) { var classGuidKey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Class\" + classGuid); diff --git a/Rubberduck.Core/Common/WinAPI/User32.cs b/Rubberduck.Core/Common/WinAPI/User32.cs new file mode 100644 index 0000000000..a48ba7fd1b --- /dev/null +++ b/Rubberduck.Core/Common/WinAPI/User32.cs @@ -0,0 +1,56 @@ +using System; +using System.Runtime.InteropServices; +using System.Text; +using Rubberduck.VBEditor.WindowsApi; + +namespace Rubberduck.Common.WinAPI +{ + public enum KeyModifier : uint + { + ALT = 0x1, + CONTROL = 0x2, + SHIFT = 0x4, + WIN = 0x8 + } + + /// + /// Exposes User32.dll API. + /// + public static class User32 + { + /// + /// Defines a system-wide hot key. + /// + /// A handle to the window that will receive WM_HOTKEY messages generated by the hot key. + /// If this parameter is NULL, WM_HOTKEY messages are posted to the message queue of the calling thread and must be processed in the message loop. + /// The identifier of the hot key. + /// If the hWnd parameter is NULL, then the hot key is associated with the current thread rather than with a particular window. + /// If a hot key already exists with the same hWnd and id parameters + /// The keys that must be pressed in combination with the key specified by the uVirtKey parameter in order to generate the WM_HOTKEY message. + /// The fsModifiers parameter can be a combination of the following values. + /// The virtual-key code of the hot key + /// If the function fails, the return value is zero. To get extended error information, call GetLastError. + [DllImport("user32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool RegisterHotKey(IntPtr hWnd, IntPtr id, uint fsModifiers, uint vk); + + + /// + /// Frees a hot key previously registered by the calling thread. + /// + /// A handle to the window associated with the hot key to be freed. This parameter should be NULL if the hot key is not associated with a window. + /// The identifier of the hot key to be freed. + /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError. + [DllImport("user32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool UnregisterHotKey(IntPtr hWnd, IntPtr id); + + // TODO used to be internal. InternalsVisibleTo should expose this, right? + [DllImport("user32.dll", CharSet = CharSet.Auto)] + public static extern IntPtr SendMessage(IntPtr hWnd, WM msg, IntPtr wParam, IntPtr lParam); + + public delegate int WindowEnumProc(IntPtr hwnd, IntPtr lparam); + [DllImport("user32.dll")] + public static extern bool EnumChildWindows(IntPtr hwnd, WindowEnumProc func, IntPtr lParam); + } +} diff --git a/RetailCoder.VBE/Common/WinAPI/WindowLongFlags.cs b/Rubberduck.Core/Common/WinAPI/WindowLongFlags.cs similarity index 100% rename from RetailCoder.VBE/Common/WinAPI/WindowLongFlags.cs rename to Rubberduck.Core/Common/WinAPI/WindowLongFlags.cs diff --git a/RetailCoder.VBE/Common/WindowsOperatingSystem.cs b/Rubberduck.Core/Common/WindowsOperatingSystem.cs similarity index 100% rename from RetailCoder.VBE/Common/WindowsOperatingSystem.cs rename to Rubberduck.Core/Common/WindowsOperatingSystem.cs diff --git a/RetailCoder.VBE/Ducky.ico b/Rubberduck.Core/Ducky.ico similarity index 100% rename from RetailCoder.VBE/Ducky.ico rename to Rubberduck.Core/Ducky.ico diff --git a/RetailCoder.VBE/EasyHook32.dll b/Rubberduck.Core/EasyHook32.dll similarity index 100% rename from RetailCoder.VBE/EasyHook32.dll rename to Rubberduck.Core/EasyHook32.dll diff --git a/RetailCoder.VBE/EasyHook32Svc.exe b/Rubberduck.Core/EasyHook32Svc.exe similarity index 100% rename from RetailCoder.VBE/EasyHook32Svc.exe rename to Rubberduck.Core/EasyHook32Svc.exe diff --git a/RetailCoder.VBE/EasyHook64.dll b/Rubberduck.Core/EasyHook64.dll similarity index 100% rename from RetailCoder.VBE/EasyHook64.dll rename to Rubberduck.Core/EasyHook64.dll diff --git a/RetailCoder.VBE/EasyHook64Svc.exe b/Rubberduck.Core/EasyHook64Svc.exe similarity index 100% rename from RetailCoder.VBE/EasyHook64Svc.exe rename to Rubberduck.Core/EasyHook64Svc.exe diff --git a/RetailCoder.VBE/EasyLoad32.dll b/Rubberduck.Core/EasyLoad32.dll similarity index 100% rename from RetailCoder.VBE/EasyLoad32.dll rename to Rubberduck.Core/EasyLoad32.dll diff --git a/RetailCoder.VBE/EasyLoad64.dll b/Rubberduck.Core/EasyLoad64.dll similarity index 100% rename from RetailCoder.VBE/EasyLoad64.dll rename to Rubberduck.Core/EasyLoad64.dll diff --git a/Rubberduck.Core/Inspections/IInspectionProvider.cs b/Rubberduck.Core/Inspections/IInspectionProvider.cs new file mode 100644 index 0000000000..11f9df1f24 --- /dev/null +++ b/Rubberduck.Core/Inspections/IInspectionProvider.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using Rubberduck.Parsing.Inspections.Abstract; + +namespace Rubberduck.Inspections +{ + public interface IInspectionProvider + { + IEnumerable Inspections { get; } + } +} \ No newline at end of file diff --git a/Rubberduck.Core/Inspections/InspectionProvider.cs b/Rubberduck.Core/Inspections/InspectionProvider.cs new file mode 100644 index 0000000000..25dc710a6b --- /dev/null +++ b/Rubberduck.Core/Inspections/InspectionProvider.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; +using System.Linq; +using Rubberduck.Parsing.Inspections.Abstract; +using Rubberduck.Settings; + +namespace Rubberduck.Inspections +{ + public class InspectionProvider : IInspectionProvider + { + public InspectionProvider(IEnumerable inspections) + { + var defaultSettings = new DefaultSettings().Default; + var defaultNames = defaultSettings.CodeInspections.Select(x => x.Name); + var defaultInspections = inspections.Where(inspection => defaultNames.Contains(inspection.Name)); + + foreach (var inspection in defaultInspections) + { + inspection.InspectionType = defaultSettings.CodeInspections.First(setting => setting.Name == inspection.Name).InspectionType; + } + + Inspections = inspections; + } + + public IEnumerable Inspections { get; } + } +} diff --git a/RetailCoder.VBE/NLog.xsd b/Rubberduck.Core/NLog.xsd similarity index 74% rename from RetailCoder.VBE/NLog.xsd rename to Rubberduck.Core/NLog.xsd index 4b0477c3c7..4740d8056f 100644 --- a/RetailCoder.VBE/NLog.xsd +++ b/Rubberduck.Core/NLog.xsd @@ -42,7 +42,32 @@ - Pass NLog internal exceptions to the application. Default value is: false. + Throw an exception when there is an internal error. Default value is: false. + + + + + Throw an exception when there is a configuration error. If not set, determined by throwExceptions. + + + + + Gets or sets a value indicating whether Variables should be kept on configuration reload. Default value is: false. + + + + + Write internal NLog messages to the System.Diagnostics.Trace. Default value is: false. + + + + + Write timestamps for internal NLog messages. Default value is: true. + + + + + Use InvariantCulture as default culture instead of CurrentCulture. Default value is: false. @@ -139,6 +164,7 @@ + @@ -169,7 +195,7 @@ - Name of the file to be included. The name is relative to the name of the current config file. + Name of the file to be included. You could use * wildcard. The name is relative to the name of the current config file. @@ -227,7 +253,6 @@ - @@ -240,41 +265,17 @@ - - - - - - - - - - - Name of the target. - - - - - Layout used to format log messages. - - - - - Indicates whether to add <!-- --> comments around all written texts. - - - - - + + @@ -286,6 +287,11 @@ Number of log events that should be processed in a batch by the lazy writer thread. + + + Limit of full s to write before yielding into Performance is better when writing many small batches, than writing a single large batch + + Action to be taken when the lazy writer thread request queue count exceeds the set limit. @@ -301,6 +307,11 @@ Time in milliseconds to sleep between batches. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + @@ -316,12 +327,30 @@ + + + Name of the target. + + + Delay the flush until the LogEvent has been confirmed as written + + + + + Condition expression. Log events who meet this condition will cause a flush on the wrapped target. + + + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + @@ -333,6 +362,7 @@ + @@ -354,6 +384,11 @@ Indicates whether to use sliding timeout. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + @@ -364,21 +399,26 @@ + + + + - - - - - - + + + + + + + @@ -395,6 +435,11 @@ Instance of that is used to format log messages. + + + End of line value if a newline is appended at the end of log message . + + Maximum message size in bytes. @@ -405,11 +450,26 @@ Indicates whether to append newline at the end of log message. + + + Action that should be taken if the will be more connections than . + + Action that should be taken if the message is larger than maxMessageSize. + + + Maximum current connections. 0 = no maximum. + + + + + Indicates whether to keep connection open whenever possible. + + Size of the connection cache (number of connections which are kept alive). @@ -420,19 +480,14 @@ Network address. - - - Indicates whether to keep connection open whenever possible. - - Maximum queue size. - + - Indicates whether to include NLog-specific extensions to log4j schema. + Indicates whether to include stack contents. @@ -440,9 +495,14 @@ Indicates whether to include source info (file name and line number) in the information sent over the network. - + - NDC item separator. + Indicates whether to include NLog-specific extensions to log4j schema. + + + + + Indicates whether to include dictionary contents. @@ -455,19 +515,31 @@ AppInfo field. By default it's the friendly name of the current AppDomain. - + - Indicates whether to include stack contents. + NDC item separator. - + Indicates whether to include dictionary contents. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + + + + + + + + @@ -502,8 +574,10 @@ + + @@ -530,6 +604,11 @@ Indicates whether to use default row highlighting rules. + + + Indicates whether to auto-check if the console is available. - Disables console writing if Environment.UserInteractive = False (Windows Service) - Disables console writing if Console Standard Input is not available (Non-Console-App) + + The encoding for writing messages to the . @@ -540,6 +619,11 @@ Indicates whether the error stream (stderr) should be used instead of the output stream (stdout). + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + @@ -592,6 +676,7 @@ + @@ -615,6 +700,11 @@ Indicates whether to match whole words only. + + + Compile the ? This can improve the performance, but at the costs of more memory usage. If false, the Regex Cache is used. + + Background color. @@ -635,7 +725,9 @@ + + @@ -662,11 +754,21 @@ Indicates whether to send the log messages to the standard error instead of the standard output. + + + Indicates whether to auto-check if the console is available - Disables console writing if Environment.UserInteractive = False (Windows Service) - Disables console writing if Console Standard Input is not available (Non-Console-App) + + The encoding for writing messages to the . + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + @@ -675,64 +777,71 @@ - - - - - - + + + + + + + + + - Name of the target. - + - Connection string. When provided, it overrides the values specified in DBHost, DBUserName, DBPassword, DBDatabase. + Obsolete - value will be ignored! The logging code always runs outside of transaction. Gets or sets a value indicating whether to use database transactions. Some data providers require this. - + - Name of the connection string (as specified in <connectionStrings> configuration section. + Database user name. If the ConnectionString is not provided this value will be used to construct the "User ID=" part of the connection string. - + - Database name. If the ConnectionString is not provided this value will be used to construct the "Database=" part of the connection string. + Name of the database provider. - + - Database host name. If the ConnectionString is not provided this value will be used to construct the "Server=" part of the connection string. + Database password. If the ConnectionString is not provided this value will be used to construct the "Password=" part of the connection string. - + - Database password. If the ConnectionString is not provided this value will be used to construct the "Password=" part of the connection string. + Indicates whether to keep the database connection open between the log events. - + - Name of the database provider. + Database name. If the ConnectionString is not provided this value will be used to construct the "Database=" part of the connection string. - + - Database user name. If the ConnectionString is not provided this value will be used to construct the "User ID=" part of the connection string. + Name of the connection string (as specified in <connectionStrings> configuration section. - + - Indicates whether to keep the database connection open between the log events. + Connection string. When provided, it overrides the values specified in DBHost, DBUserName, DBPassword, DBDatabase. + + + + + Database host name. If the ConnectionString is not provided this value will be used to construct the "Server=" part of the connection string. @@ -740,6 +849,11 @@ Connection string using for installation and uninstallation. If not provided, regular ConnectionString is being used. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + Text of the SQL command to be run on each log level. @@ -831,6 +945,7 @@ + @@ -852,6 +967,11 @@ Footer. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + @@ -861,6 +981,7 @@ + @@ -872,6 +993,11 @@ Layout used to format log messages. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + @@ -886,7 +1012,11 @@ + + + + @@ -923,20 +1053,48 @@ Value to be used as the event Source. + + + Action to take if the message is larger than the option. + + Optional entrytype. When not set, or when not convertable to then determined by + + + Maximum Event log size in kilobytes. If null, the value won't be set. Default is 512 Kilobytes as specified by Eventlog API + + + + + Message length limit to write to the Event Log. + + + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + + + + + + + + + @@ -948,6 +1106,11 @@ Indicates whether to return to the first target after any successful write. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + @@ -961,31 +1124,38 @@ - + - - + + + + + + + + + - - - - - - - + + + + + + + @@ -1017,11 +1187,6 @@ Line ending mode. - - - Maximum number of archive files that should be kept. - - Way file archives are numbered. @@ -1039,7 +1204,7 @@ - Size in bytes above which log files will be automatically archived. + Size in bytes above which log files will be automatically archived. Warning: combining this with isn't supported. We cannot create multiple archive files, if they should have the same name. Choose: @@ -1047,19 +1212,49 @@ Indicates whether to compress archive files into the zip archive format. + + + Maximum number of archive files that should be kept. + + - Gets ors set a value indicating whether a managed file stream is forced, instead of used the native implementation. + Gets or set a value indicating whether a managed file stream is forced, instead of using the native implementation. - + - File attributes (Windows only). + Is the an absolute or relative path? - + - Indicates whether to replace file contents on each write instead of appending log message at the end. + Cleanup invalid values in a filename, e.g. slashes in a filename. If set to true, this can impact the performance of massive writes. If set to false, nothing gets written when the filename is wrong. + + + + + Whether or not this target should just discard all data that its asked to write. Mostly used for when testing NLog Stack except final write + + + + + Is the an absolute or relative path? + + + + + Value indicationg whether file creation calls should be synchronized by a system global mutex. + + + + + Maximum number of log filenames that should be stored as existing. + + + + + Indicates whether the footer should be written only when the file is archived. @@ -1069,7 +1264,7 @@ - Value specifying the date format to use when archving files. + Value specifying the date format to use when archiving files. @@ -1082,29 +1277,34 @@ Indicates whether to create directories if they do not exist. + + + File attributes (Windows only). + + Indicates whether to delete old log file on startup. - + - Indicates whether to enable log file(s) to be deleted. + Indicates whether to replace file contents on each write instead of appending log message at the end. - + - Maximum number of seconds that files are kept open. If this number is negative the files are not automatically closed after a period of inactivity. + Indicates whether to enable log file(s) to be deleted. - + - Indicates whether concurrent writes to the log file by multiple processes on different network hosts. + Number of times the write is appended on the file before NLog discards the log message. - + - Maximum number of log filenames that should be stored as existing. + Indicates whether concurrent writes to the log file by multiple processes on the same host. @@ -1112,34 +1312,39 @@ Indicates whether to keep log file open instead of opening and closing it on each logging event. - + - Indicates whether concurrent writes to the log file by multiple processes on the same host. + Indicates whether concurrent writes to the log file by multiple processes on different network hosts. - + - Number of times the write is appended on the file before NLog discards the log message. + Number of files to be kept open. Setting this to a higher value may improve performance in a situation where a single File target is writing to many files (such as splitting by level or by logger). - + - Delay in milliseconds to wait before attempting to write to the file again. + Maximum number of seconds that files are kept open. If this number is negative the files are not automatically closed after a period of inactivity. - + - Indicates whether to automatically flush the file buffers after each log message. + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit - + - Number of files to be kept open. Setting this to a higher value may improve performance in a situation where a single File target is writing to many files (such as splitting by level or by logger). + Log file buffer size in bytes. - + - Log file buffer size in bytes. + Indicates whether to automatically flush the file buffers after each log message. + + + + + Delay in milliseconds to wait before attempting to write to the file again. @@ -1161,6 +1366,20 @@ + + + + + + + + + + + + + + @@ -1189,6 +1408,7 @@ + @@ -1200,6 +1420,11 @@ Condition expression. Log events who meet this condition will be forwarded to the wrapped target. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + @@ -1215,6 +1440,7 @@ + @@ -1256,6 +1482,11 @@ Username to change context to. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + @@ -1282,6 +1513,38 @@ + + + + + + + + + + + + Name of the target. + + + + + Interval in which messages will be written up to the number of messages. + + + + + Maximum allowed number of messages written per . + + + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + + + + @@ -1294,6 +1557,7 @@ + @@ -1330,6 +1594,11 @@ Indicates whether to use binary message encoding. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + @@ -1337,6 +1606,7 @@ + @@ -1349,11 +1619,16 @@ Name of the parameter. - + Type of the parameter. + + + Type of the parameter. Obsolete alias for + + @@ -1366,15 +1641,16 @@ - - + + - - + + + @@ -1382,6 +1658,8 @@ + + @@ -1418,9 +1696,9 @@ Indicates whether to add new lines between log entries. - + - BCC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). + CC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). @@ -1428,9 +1706,9 @@ Recipients' email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). - + - CC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). + BCC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). @@ -1448,9 +1726,9 @@ Sender's email address (e.g. joe@domain.com). - + - Indicates whether NewLine characters in the body should be replaced with tags. + Indicates the SMTP client timeout. @@ -1458,9 +1736,14 @@ Priority used for sending mails. - + - Indicates the SMTP client timeout. + Indicates whether NewLine characters in the body should be replaced with tags. + + + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit @@ -1498,6 +1781,16 @@ Indicates whether the default Settings from System.Net.MailSettings should be used. + + + Folder where applications save mail messages to be processed by the local SMTP server. + + + + + Specifies how outgoing email messages will be handled. + + @@ -1508,12 +1801,20 @@ + + + + + + + + @@ -1525,6 +1826,11 @@ Layout used to format log messages. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + @@ -1537,6 +1843,7 @@ + @@ -1567,6 +1874,11 @@ Indicates whether to check if a queue exists before writing to it. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + Indicates whether to create the queue if it doesn't exists. @@ -1598,6 +1910,7 @@ + @@ -1611,7 +1924,12 @@ - Method name. The method must be public and static. + Method name. The method must be public and static. Use the AssemblyQualifiedName , https://msdn.microsoft.com/en-us/library/system.type.assemblyqualifiedname(v=vs.110).aspx e.g. + + + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit @@ -1624,13 +1942,17 @@ + + + + @@ -1647,6 +1969,11 @@ Encoding to be used. + + + End of line value if a newline is appended at the end of log message . + + Maximum message size in bytes. @@ -1657,6 +1984,11 @@ Indicates whether to append newline at the end of log message. + + + Action that should be taken if the will be more connections than . + + Action that should be taken if the message is larger than maxMessageSize. @@ -1677,11 +2009,21 @@ Indicates whether to keep connection open whenever possible. + + + Maximum current connections. 0 = no maximum. + + Maximum queue size. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + @@ -1692,21 +2034,26 @@ + + + + - - - - - - + + + + + + + @@ -1723,6 +2070,11 @@ Instance of that is used to format log messages. + + + End of line value if a newline is appended at the end of log message . + + Maximum message size in bytes. @@ -1733,11 +2085,26 @@ Indicates whether to append newline at the end of log message. + + + Action that should be taken if the will be more connections than . + + Action that should be taken if the message is larger than maxMessageSize. + + + Maximum current connections. 0 = no maximum. + + + + + Indicates whether to keep connection open whenever possible. + + Size of the connection cache (number of connections which are kept alive). @@ -1748,19 +2115,14 @@ Network address. - - - Indicates whether to keep connection open whenever possible. - - Maximum queue size. - + - Indicates whether to include NLog-specific extensions to log4j schema. + Indicates whether to include stack contents. @@ -1768,9 +2130,14 @@ Indicates whether to include source info (file name and line number) in the information sent over the network. - + - NDC item separator. + Indicates whether to include NLog-specific extensions to log4j schema. + + + + + Indicates whether to include dictionary contents. @@ -1783,16 +2150,21 @@ AppInfo field. By default it's the friendly name of the current AppDomain. - + - Indicates whether to include stack contents. + NDC item separator. - + Indicates whether to include dictionary contents. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + @@ -1803,6 +2175,7 @@ + @@ -1819,6 +2192,11 @@ Indicates whether to perform layout calculation. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + @@ -1828,6 +2206,7 @@ + @@ -1839,6 +2218,11 @@ Layout used to format log messages. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + @@ -1852,7 +2236,9 @@ + + @@ -1884,11 +2270,21 @@ Performance counter type. + + + The value by which to increment the counter. + + Performance counter instance name. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + @@ -1931,6 +2327,7 @@ + @@ -1942,6 +2339,11 @@ Default filter to be applied when no specific rule matches. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + @@ -1966,12 +2368,18 @@ + Name of the target. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + @@ -1980,6 +2388,7 @@ + @@ -1987,6 +2396,11 @@ Name of the target. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + Number of times to repeat each log message. @@ -2000,6 +2414,7 @@ + @@ -2008,6 +2423,11 @@ Name of the target. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + Number of retries that should be attempted on the wrapped target in case of a failure. @@ -2026,12 +2446,18 @@ + Name of the target. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + @@ -2040,12 +2466,18 @@ + Name of the target. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + @@ -2055,6 +2487,7 @@ + @@ -2066,6 +2499,11 @@ Layout used to format log messages. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + @@ -2076,11 +2514,18 @@ + + + + + + + @@ -2092,11 +2537,26 @@ Should we include the BOM (Byte-order-mark) for UTF? Influences the property. This will only work for UTF-8. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + Encoding. + + + Value whether escaping be done according to the old NLog style (Very non-standard) + + + + + Value whether escaping be done according to Rfc3986 (Supports Internationalized Resource Identifiers - IRIs) + + Web service method name. Only used with Soap. @@ -2107,6 +2567,11 @@ Web service namespace. Only used with Soap. + + + Indicates whether to pre-authenticate the HttpWebRequest (Requires 'Authorization' in parameters) + + Protocol to be used when calling web service. @@ -2117,6 +2582,16 @@ Web service URL. + + + Name of the root XML element, if POST of XML document chosen. If so, this property must not be null. (see and ). + + + + + (optional) root namespace of the XML document, if POST of XML document chosen. (see and ). + + @@ -2126,8 +2601,22 @@ + + + + + + + + + + + + + + @@ -2224,15 +2713,63 @@ + + + + + + + + + List of property names to exclude when is true + + + + + Option to include all properties from the log events + + + + + Indicates whether to include contents of the dictionary. + + + + + Option to render the empty object value {} + + + + + Option to suppress the extra spaces in the output json + + + + + Indicates whether to include contents of the dictionary. + + + + + + + Determines wether or not this attribute will be Json encoded. + + + + + Indicates whether to escape non-ascii characters + + Layout that will be rendered as the attribute's value. @@ -2273,7 +2810,26 @@ - + + + + + + + + Option to include all properties from the log events + + + + + Indicates whether to include contents of the dictionary. + + + + + Indicates whether to include contents of the dictionary. + + @@ -2448,6 +3004,74 @@ + + + + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + Layout to be used to filter log messages. + + + + + Default number of unique filter values to expect, will automatically increase if needed + + + + + Append FilterCount to the when an event is no longer filtered + + + + + Insert FilterCount value into when an event is no longer filtered + + + + + Max number of unique filter values to expect simultaneously + + + + + Max length of filter values, will truncate if above limit + + + + + Default buffer size for the internal buffers + + + + + Reuse internal buffers, and doesn't have to constantly allocate new buffers + + + + + How long before a filter expires, and logging is accepted again + + + + + @@ -2476,4 +3100,4 @@ - + \ No newline at end of file diff --git a/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerComponentViewModel.cs b/Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerComponentViewModel.cs similarity index 74% rename from RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerComponentViewModel.cs rename to Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerComponentViewModel.cs index 21c28bd809..bba88992ae 100644 --- a/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerComponentViewModel.cs +++ b/Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerComponentViewModel.cs @@ -7,17 +7,16 @@ using Rubberduck.VBEditor; using resx = Rubberduck.UI.CodeExplorer.CodeExplorer; using Rubberduck.Parsing.Annotations; +using Rubberduck.VBEditor.ComManagement; using Rubberduck.VBEditor.SafeComWrappers; namespace Rubberduck.Navigation.CodeExplorer { public class CodeExplorerComponentViewModel : CodeExplorerItemViewModel, ICodeExplorerDeclarationViewModel { - private readonly Declaration _declaration; - public Declaration Declaration { get { return _declaration; } } + public Declaration Declaration { get; } - private readonly CodeExplorerItemViewModel _parent; - public override CodeExplorerItemViewModel Parent { get { return _parent; } } + public override CodeExplorerItemViewModel Parent { get; } private static readonly DeclarationType[] MemberTypes = { @@ -35,10 +34,13 @@ public class CodeExplorerComponentViewModel : CodeExplorerItemViewModel, ICodeEx DeclarationType.Variable, }; - public CodeExplorerComponentViewModel(CodeExplorerItemViewModel parent, Declaration declaration, IEnumerable declarations) + private readonly IProjectsProvider _projectsProvider; + + public CodeExplorerComponentViewModel(CodeExplorerItemViewModel parent, Declaration declaration, IEnumerable declarations, IProjectsProvider projectsProvider) { - _parent = parent; - _declaration = declaration; + Parent = parent; + Declaration = declaration; + _projectsProvider = projectsProvider; _icon = Icons[DeclarationType]; Items = declarations.GroupBy(item => item.Scope).SelectMany(grouping => grouping.Where(item => item.ParentDeclaration != null @@ -48,14 +50,19 @@ public CodeExplorerComponentViewModel(CodeExplorerItemViewModel parent, Declarat .Select(item => new CodeExplorerMemberViewModel(this, item, grouping))) .ToList(); - _name = _declaration.IdentifierName; + _name = Declaration.IdentifierName; - var component = declaration.QualifiedName.QualifiedModuleName.Component; + var qualifiedModuleName = declaration.QualifiedName.QualifiedModuleName; try { - if (component.Type == ComponentType.Document) + if (qualifiedModuleName.ComponentType == ComponentType.Document) { - var parenthesizedName = component.Properties["Name"].Value.ToString(); + var component = _projectsProvider.Component(qualifiedModuleName); + string parenthesizedName; + using (var properties = component.Properties) + { + parenthesizedName = properties["Name"].Value.ToString() ?? String.Empty; + } if (ContainsBuiltinDocumentPropertiesProperty()) { @@ -81,7 +88,7 @@ public CodeExplorerComponentViewModel(CodeExplorerItemViewModel parent, Declarat private bool ContainsBuiltinDocumentPropertiesProperty() { - var properties = _declaration.QualifiedName.QualifiedModuleName.Component.Properties; + using (var properties = _projectsProvider.Component(Declaration.QualifiedName.QualifiedModuleName).Properties) { return properties.Any(item => item.Name == "BuiltinDocumentProperties"); } @@ -90,7 +97,7 @@ private bool ContainsBuiltinDocumentPropertiesProperty() private bool _isErrorState; public bool IsErrorState { - get { return _isErrorState; } + get => _isErrorState; set { _isErrorState = value; @@ -112,18 +119,18 @@ public bool IsTestModule { get { - return _declaration.DeclarationType == DeclarationType.ProceduralModule - && _declaration.Annotations.Any(annotation => annotation.AnnotationType == AnnotationType.TestModule); + return Declaration.DeclarationType == DeclarationType.ProceduralModule + && Declaration.Annotations.Any(annotation => annotation.AnnotationType == AnnotationType.TestModule); } } private readonly string _name; - public override string Name { get { return _name; } } - public override string NameWithSignature { get { return _name; } } + public override string Name => _name; + public override string NameWithSignature => _name; - public override QualifiedSelection? QualifiedSelection { get { return _declaration.QualifiedSelection; } } + public override QualifiedSelection? QualifiedSelection => Declaration.QualifiedSelection; - private ComponentType ComponentType { get { return _declaration.QualifiedName.QualifiedModuleName.ComponentType; } } + private ComponentType ComponentType => Declaration.QualifiedName.QualifiedModuleName.ComponentType; private static readonly IDictionary DeclarationTypes = new Dictionary { @@ -159,7 +166,7 @@ private DeclarationType DeclarationType }; private BitmapImage _icon; - public override BitmapImage CollapsedIcon { get { return _icon; } } - public override BitmapImage ExpandedIcon { get { return _icon; } } + public override BitmapImage CollapsedIcon => _icon; + public override BitmapImage ExpandedIcon => _icon; } } diff --git a/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerCustomFolderViewModel.cs b/Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerCustomFolderViewModel.cs similarity index 60% rename from RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerCustomFolderViewModel.cs rename to Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerCustomFolderViewModel.cs index ca9959610e..2b84a8cdd1 100644 --- a/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerCustomFolderViewModel.cs +++ b/Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerCustomFolderViewModel.cs @@ -4,15 +4,13 @@ using System.Windows.Media.Imaging; using Rubberduck.Parsing.Symbols; using Rubberduck.VBEditor; +using Rubberduck.VBEditor.ComManagement; using resx = Rubberduck.Properties.Resources; namespace Rubberduck.Navigation.CodeExplorer { public class CodeExplorerCustomFolderViewModel : CodeExplorerItemViewModel { - private readonly string _fullPath; - private readonly string _name; - private readonly string _folderAttribute; private static readonly DeclarationType[] ComponentTypes = { DeclarationType.ClassModule, @@ -21,15 +19,18 @@ public class CodeExplorerCustomFolderViewModel : CodeExplorerItemViewModel DeclarationType.UserForm, }; - public CodeExplorerCustomFolderViewModel(CodeExplorerItemViewModel parent, string name, string fullPath) + private readonly IProjectsProvider _projectsProvider; + + public CodeExplorerCustomFolderViewModel(CodeExplorerItemViewModel parent, string name, string fullPath, IProjectsProvider projectsProvider) { _parent = parent; - _fullPath = fullPath; - _name = name.Replace("\"", string.Empty); - _folderAttribute = string.Format("@Folder(\"{0}\")", fullPath.Replace("\"", string.Empty)); + _projectsProvider = projectsProvider; + FullPath = fullPath; + Name = name.Replace("\"", string.Empty); + FolderAttribute = string.Format("@Folder(\"{0}\")", fullPath.Replace("\"", string.Empty)); - _collapsedIcon = GetImageSource(resx.folder_horizontal); - _expandedIcon = GetImageSource(resx.folder_horizontal_open); + CollapsedIcon = GetImageSource(resx.folder_horizontal); + ExpandedIcon = GetImageSource(resx.folder_horizontal_open); } public void AddNodes(List declarations) @@ -45,7 +46,7 @@ public void AddNodes(List declarations) var members = declarations.Where(item => !ComponentTypes.Contains(item.DeclarationType) && item.ComponentName == moduleName); - AddChild(new CodeExplorerComponentViewModel(this, parent, members)); + AddChild(new CodeExplorerComponentViewModel(this, parent, members, _projectsProvider)); } catch (InvalidOperationException exception) { @@ -54,20 +55,19 @@ public void AddNodes(List declarations) } } - public string FolderAttribute { get { return _folderAttribute; } } + public string FolderAttribute { get; } + + public string FullPath { get; } - public string FullPath { get { return _fullPath; } } + public override string Name { get; } - public override string Name { get { return _name; } } - public override string NameWithSignature { get { return Name; } } + public override string NameWithSignature => Name; // Is this actually doing anything? Should this member be replaced with 'Name'? - public override QualifiedSelection? QualifiedSelection { get { return null; } } + public override QualifiedSelection? QualifiedSelection => null; - private readonly BitmapImage _collapsedIcon; - public override BitmapImage CollapsedIcon { get { return _collapsedIcon; } } + public override BitmapImage CollapsedIcon { get; } - private readonly BitmapImage _expandedIcon; - public override BitmapImage ExpandedIcon { get { return _expandedIcon; } } + public override BitmapImage ExpandedIcon { get; } // I have to set the parent from a different location than // the node is created because of the folder helper @@ -77,6 +77,6 @@ internal void SetParent(CodeExplorerItemViewModel parent) } private CodeExplorerItemViewModel _parent; - public override CodeExplorerItemViewModel Parent { get { return _parent; } } + public override CodeExplorerItemViewModel Parent => _parent; } } diff --git a/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerItemViewModel.cs b/Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerItemViewModel.cs similarity index 89% rename from RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerItemViewModel.cs rename to Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerItemViewModel.cs index 92ee48334c..0ea016eea3 100644 --- a/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerItemViewModel.cs +++ b/Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerItemViewModel.cs @@ -18,12 +18,10 @@ public override int Compare(CodeExplorerItemViewModel x, CodeExplorerItemViewMod } var nodeComparison = new CompareByNodeType().Compare(x, y); - if (nodeComparison != 0) - { - return nodeComparison; - } - return string.CompareOrdinal(x.NameWithSignature, y.NameWithSignature); + return nodeComparison != 0 + ? nodeComparison + : string.CompareOrdinal(x.NameWithSignature, y.NameWithSignature); } } @@ -67,10 +65,8 @@ public override int Compare(CodeExplorerItemViewModel x, CodeExplorerItemViewMod // keep separate types separate if (xNode.Declaration.DeclarationType != yNode.Declaration.DeclarationType) { - int xValue, yValue; - - if (SortOrder.TryGetValue(xNode.Declaration.DeclarationType, out xValue) && - SortOrder.TryGetValue(yNode.Declaration.DeclarationType, out yValue)) + if (SortOrder.TryGetValue(xNode.Declaration.DeclarationType, out var xValue) && + SortOrder.TryGetValue(yNode.Declaration.DeclarationType, out var yValue)) { if (xValue != yValue) { return xValue < yValue ? -1 : 1; } @@ -89,13 +85,13 @@ public override int Compare(CodeExplorerItemViewModel x, CodeExplorerItemViewMod if (x.ExpandedIcon != y.ExpandedIcon) { - // ReSharper disable PossibleInvalidOperationException - this will have a component - var xComponent = x.QualifiedSelection.Value.QualifiedName.Component; - var yComponent = y.QualifiedSelection.Value.QualifiedName.Component; + // ReSharper disable PossibleInvalidOperationException - this will have a QualifiedSelection + var xQmn = x.QualifiedSelection.Value.QualifiedName; + var yQmn = y.QualifiedSelection.Value.QualifiedName; - if (xComponent.Type == ComponentType.Document ^ yComponent.Type == ComponentType.Document) + if (xQmn.ComponentType == ComponentType.Document ^ yQmn.ComponentType == ComponentType.Document) { - return xComponent.Type == ComponentType.Document ? -1 : 1; + return xQmn.ComponentType == ComponentType.Document ? -1 : 1; } } @@ -169,7 +165,7 @@ public abstract class CodeExplorerItemViewModel : ViewModelBase private List _items = new List(); public List Items { - get { return _items; } + get => _items; protected set { _items = value; @@ -180,7 +176,7 @@ protected set private bool _isExpanded; public bool IsExpanded { - get { return _isExpanded; } + get => _isExpanded; set { _isExpanded = value; @@ -193,7 +189,7 @@ public bool IsExpanded private bool _isVisisble = true; public bool IsVisible { - get { return _isVisisble; } + get => _isVisisble; set { _isVisisble = value; @@ -229,8 +225,8 @@ public CodeExplorerItemViewModel GetChild(string name) public Declaration GetSelectedDeclaration() { - return this is ICodeExplorerDeclarationViewModel - ? ((ICodeExplorerDeclarationViewModel)this).Declaration + return this is ICodeExplorerDeclarationViewModel viewModel + ? viewModel.Declaration : null; } diff --git a/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerMemberViewModel.cs b/Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerMemberViewModel.cs similarity index 88% rename from RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerMemberViewModel.cs rename to Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerMemberViewModel.cs index 938cfb602c..e339ccb59b 100644 --- a/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerMemberViewModel.cs +++ b/Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerMemberViewModel.cs @@ -12,8 +12,7 @@ namespace Rubberduck.Navigation.CodeExplorer { public class CodeExplorerMemberViewModel : CodeExplorerItemViewModel, ICodeExplorerDeclarationViewModel { - private readonly Declaration _declaration; - public Declaration Declaration { get { return _declaration; } } + public Declaration Declaration { get; } private static readonly DeclarationType[] SubMemberTypes = { @@ -61,9 +60,9 @@ public class CodeExplorerMemberViewModel : CodeExplorerItemViewModel, ICodeExplo public CodeExplorerMemberViewModel(CodeExplorerItemViewModel parent, Declaration declaration, IEnumerable declarations) { - _parent = parent; + Parent = parent; - _declaration = declaration; + Declaration = declaration; if (declarations != null) { Items = declarations.Where(item => SubMemberTypes.Contains(item.DeclarationType) && item.ParentDeclaration.Equals(declaration)) @@ -77,7 +76,7 @@ public CodeExplorerMemberViewModel(CodeExplorerItemViewModel parent, Declaration : declaration.Accessibility; var key = Tuple.Create(declaration.DeclarationType, modifier); - _name = DetermineMemberName(declaration); + Name = DetermineMemberName(declaration); _icon = Mappings[key]; } @@ -100,11 +99,9 @@ private string RemoveExtraWhiteSpace(string value) return newStr.ToString(); } - private readonly string _name; - public override string Name { get { return _name; } } + public override string Name { get; } - private readonly CodeExplorerItemViewModel _parent; - public override CodeExplorerItemViewModel Parent { get { return _parent; } } + public override CodeExplorerItemViewModel Parent { get; } private string _signature = null; public override string NameWithSignature @@ -117,15 +114,15 @@ public override string NameWithSignature } var context = - _declaration.Context.children.FirstOrDefault(d => d is VBAParser.ArgListContext) as VBAParser.ArgListContext; + Declaration.Context.children.FirstOrDefault(d => d is VBAParser.ArgListContext) as VBAParser.ArgListContext; if (context == null) { _signature = Name; } - else if (_declaration.DeclarationType == DeclarationType.PropertyGet - || _declaration.DeclarationType == DeclarationType.PropertyLet - || _declaration.DeclarationType == DeclarationType.PropertySet) + else if (Declaration.DeclarationType == DeclarationType.PropertyGet + || Declaration.DeclarationType == DeclarationType.PropertyLet + || Declaration.DeclarationType == DeclarationType.PropertySet) { // 6 being the three-letter "get/let/set" + parens + space _signature = Name.Insert(Name.Length - 6, RemoveExtraWhiteSpace(context.GetText())); @@ -138,7 +135,7 @@ public override string NameWithSignature } } - public override QualifiedSelection? QualifiedSelection { get { return _declaration.QualifiedSelection; } } + public override QualifiedSelection? QualifiedSelection => Declaration.QualifiedSelection; private static string DetermineMemberName(Declaration declaration) { @@ -174,7 +171,7 @@ public void ParentComponentHasError() } private BitmapImage _icon; - public override BitmapImage CollapsedIcon { get { return _icon; } } - public override BitmapImage ExpandedIcon { get { return _icon; } } + public override BitmapImage CollapsedIcon => _icon; + public override BitmapImage ExpandedIcon => _icon; } } diff --git a/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerProjectViewModel.cs b/Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerProjectViewModel.cs similarity index 76% rename from RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerProjectViewModel.cs rename to Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerProjectViewModel.cs index 2e03e79abd..716b2f12db 100644 --- a/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerProjectViewModel.cs +++ b/Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerProjectViewModel.cs @@ -12,8 +12,8 @@ namespace Rubberduck.Navigation.CodeExplorer { public class CodeExplorerProjectViewModel : CodeExplorerItemViewModel, ICodeExplorerDeclarationViewModel { - private readonly Declaration _declaration; - public Declaration Declaration { get { return _declaration; } } + public Declaration Declaration { get; } + private readonly CodeExplorerCustomFolderViewModel _folderTree; private static readonly DeclarationType[] ComponentTypes = @@ -26,8 +26,8 @@ public class CodeExplorerProjectViewModel : CodeExplorerItemViewModel, ICodeExpl public CodeExplorerProjectViewModel(FolderHelper folderHelper, Declaration declaration, IEnumerable declarations) { - _declaration = declaration; - _name = _declaration.IdentifierName; + Declaration = declaration; + _name = Declaration.IdentifierName; IsExpanded = true; _folderTree = folderHelper.GetFolderTree(declaration); @@ -36,7 +36,7 @@ public CodeExplorerProjectViewModel(FolderHelper folderHelper, Declaration decla FillFolders(declarations.ToList()); Items = _folderTree.Items.ToList(); - _icon = _declaration.Project.Protection == ProjectProtection.Locked + _icon = Declaration.Project?.Protection == ProjectProtection.Locked ? GetImageSource(resx.lock__exclamation) : GetImageSource(resx.ObjectLibrary); } @@ -63,11 +63,11 @@ private void FillFolders(IEnumerable declarations) foreach (var grouping in groupedItems) { - AddNodesToTree(_folderTree, items, grouping); + CanAddNodesToTree(_folderTree, items, grouping); } } - private bool AddNodesToTree(CodeExplorerCustomFolderViewModel tree, List items, IGrouping grouping) + private bool CanAddNodesToTree(CodeExplorerCustomFolderViewModel tree, List items, IGrouping grouping) { foreach (var folder in tree.Items.OfType()) { @@ -88,20 +88,20 @@ private bool AddNodesToTree(CodeExplorerCustomFolderViewModel tree, List().Any(node => AddNodesToTree(node, items, grouping)); + return tree.Items.OfType().Any(node => CanAddNodesToTree(node, items, grouping)); } private readonly BitmapImage _icon; - public override BitmapImage CollapsedIcon { get { return _icon; } } - public override BitmapImage ExpandedIcon { get { return _icon; } } - + public override BitmapImage CollapsedIcon => _icon; + public override BitmapImage ExpandedIcon => _icon; + // projects are always at the top of the tree - public override CodeExplorerItemViewModel Parent { get { return null; } } + public override CodeExplorerItemViewModel Parent => null; private string _name; - public override string Name { get { return _name; } } - public override string NameWithSignature { get { return _name; } } - public override QualifiedSelection? QualifiedSelection { get { return _declaration.QualifiedSelection; } } + public override string Name => _name; + public override string NameWithSignature => _name; + public override QualifiedSelection? QualifiedSelection => Declaration.QualifiedSelection; public void SetParenthesizedName(string parenthesizedName) { diff --git a/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerViewModel.cs b/Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerViewModel.cs similarity index 88% rename from RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerViewModel.cs rename to Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerViewModel.cs index d35b028bd1..b71ff6b8f9 100644 --- a/RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerViewModel.cs +++ b/Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerViewModel.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using NLog; @@ -15,11 +14,10 @@ using Rubberduck.UI; using Rubberduck.UI.CodeExplorer.Commands; using Rubberduck.UI.Command; -using Rubberduck.UI.Command.MenuItems; using Rubberduck.VBEditor; using Rubberduck.VBEditor.SafeComWrappers; -using Rubberduck.VBEditor.SafeComWrappers.Abstract; using System.Windows; +using Rubberduck.Parsing.UIContext; // ReSharper disable CanBeReplacedWithTryCastAndCheckForNull // ReSharper disable ExplicitCallerInfoArgument @@ -30,22 +28,27 @@ public sealed class CodeExplorerViewModel : ViewModelBase, IDisposable { private readonly FolderHelper _folderHelper; private readonly RubberduckParserState _state; - private IConfigProvider _generalSettingsProvider; - private IConfigProvider _windowSettingsProvider; - private GeneralSettings _generalSettings; - private WindowSettings _windowSettings; + private readonly IConfigProvider _windowSettingsProvider; + private readonly GeneralSettings _generalSettings; + private readonly WindowSettings _windowSettings; + private readonly IUiDispatcher _uiDispatcher; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - public CodeExplorerViewModel(FolderHelper folderHelper, RubberduckParserState state, List commands, - IConfigProvider generalSettingsProvider, IConfigProvider windowSettingsProvider) + public CodeExplorerViewModel( + FolderHelper folderHelper, + RubberduckParserState state, + List commands, + IConfigProvider generalSettingsProvider, + IConfigProvider windowSettingsProvider, + IUiDispatcher uiDispatcher) { _folderHelper = folderHelper; _state = state; _state.StateChanged += HandleStateChanged; _state.ModuleStateChanged += ParserState_ModuleStateChanged; - _generalSettingsProvider = generalSettingsProvider; _windowSettingsProvider = windowSettingsProvider; + _uiDispatcher = uiDispatcher; if (generalSettingsProvider != null) { @@ -96,9 +99,6 @@ public CodeExplorerViewModel(FolderHelper folderHelper, RubberduckParserState st PrintCommand = commands.OfType().SingleOrDefault(); - CommitCommand = commands.OfType().SingleOrDefault(); - UndoCommand = commands.OfType().SingleOrDefault(); - CopyResultsCommand = commands.OfType().SingleOrDefault(); SetNameSortCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), param => @@ -366,7 +366,7 @@ private void UpdateNodes(IEnumerable oldList, IEnumer } } - private void ParserState_ModuleStateChanged(object sender, Parsing.ParseProgressEventArgs e) + private void ParserState_ModuleStateChanged(object sender, ParseProgressEventArgs e) { // if we are resolving references, we already have the declarations and don't need to display error if (!(e.State == ParserState.Error || @@ -376,11 +376,10 @@ private void ParserState_ModuleStateChanged(object sender, Parsing.ParseProgress return; } - var components = e.Module.Component.Collection; - var componentProject = components.Parent; + var componentProject = _state.ProjectsProvider.Project(e.Module.ProjectId); { var projectNode = Projects.OfType() - .FirstOrDefault(p => p.Declaration.Project.Equals(componentProject)); + .FirstOrDefault(p => p.Declaration.Project?.Equals(componentProject) ?? false); if (projectNode == null) { @@ -395,19 +394,19 @@ private void ParserState_ModuleStateChanged(object sender, Parsing.ParseProgress var projectName = componentProject.Name; var folderNode = projectNode.Items.FirstOrDefault(f => f is CodeExplorerCustomFolderViewModel && f.Name == projectName); - UiDispatcher.Invoke(() => + _uiDispatcher.Invoke(() => { try { if (folderNode == null) { - folderNode = new CodeExplorerCustomFolderViewModel(projectNode, projectName, projectName); + folderNode = new CodeExplorerCustomFolderViewModel(projectNode, projectName, projectName, _state.ProjectsProvider); projectNode.AddChild(folderNode); } var declaration = CreateDeclaration(e.Module); var newNode = - new CodeExplorerComponentViewModel(folderNode, declaration, new List()) + new CodeExplorerComponentViewModel(folderNode, declaration, new List(), _state.ProjectsProvider) { IsErrorState = true }; @@ -429,7 +428,7 @@ private Declaration CreateDeclaration(QualifiedModuleName module) { var projectDeclaration = _state.DeclarationFinder.UserDeclarations(DeclarationType.Project) - .FirstOrDefault(item => item.Project.VBComponents.Contains(module.Component)); + .FirstOrDefault(item => item.ProjectId == module.ProjectId); if (module.ComponentType == ComponentType.StandardModule) { @@ -479,16 +478,20 @@ private void SetErrorState(CodeExplorerItemViewModel itemNode, QualifiedModuleNa private void ExecuteCollapseNodes(object parameter) { - var node = parameter as CodeExplorerItemViewModel; - if (node == null) { return; } + if (!(parameter is CodeExplorerItemViewModel node)) + { + return; + } SwitchNodeState(node, false); } private void ExecuteExpandNodes(object parameter) { - var node = parameter as CodeExplorerItemViewModel; - if (node == null) { return; } + if (!(parameter is CodeExplorerItemViewModel node)) + { + return; + } SwitchNodeState(node, true); } @@ -535,9 +538,6 @@ private void SwitchNodeState(CodeExplorerItemViewModel node, bool expandedState) public CommandBase PrintCommand { get; } - public CommandBase CommitCommand { get; } - public CommandBase UndoCommand { get; } - private readonly CommandBase _externalRemoveCommand; // this is a special case--we have to reset SelectedItem to prevent a crash @@ -552,46 +552,13 @@ private void ExecuteRemoveComand(object param) private bool CanExecuteExportAllCommand => ExportAllCommand.CanExecute(SelectedItem); - public Visibility ExportVisibility - { - get - { - if (CanExecuteExportAllCommand == false) - { return Visibility.Visible; } - else { return Visibility.Collapsed; } - } - } - - public Visibility ExportAllVisibility - { - get - { - if (CanExecuteExportAllCommand == true) - { return Visibility.Visible; } - else { return Visibility.Collapsed; } - } - } + public Visibility ExportVisibility => CanExecuteExportAllCommand ? Visibility.Collapsed : Visibility.Visible; - public bool IsSourceControlEnabled - { - get { return _generalSettings.SourceControlEnabled; } - } + public Visibility ExportAllVisibility => CanExecuteExportAllCommand ? Visibility.Visible : Visibility.Collapsed; - public Visibility TreeViewVisibility - { - get - { - return Projects == null || Projects.Count == 0 ? Visibility.Collapsed : Visibility.Visible; - } - } + public Visibility TreeViewVisibility => Projects == null || Projects.Count == 0 ? Visibility.Collapsed : Visibility.Visible; - public Visibility EmptyUIRefreshMessageVisibility - { - get - { - return _isBusy ? Visibility.Hidden : Visibility.Visible; - } - } + public Visibility EmptyUIRefreshMessageVisibility => _isBusy ? Visibility.Hidden : Visibility.Visible; public void FilterByName(IEnumerable nodes, string searchString) { diff --git a/RetailCoder.VBE/Navigation/CodeExplorer/ICodeExplorerDeclarationViewModel.cs b/Rubberduck.Core/Navigation/CodeExplorer/ICodeExplorerDeclarationViewModel.cs similarity index 100% rename from RetailCoder.VBE/Navigation/CodeExplorer/ICodeExplorerDeclarationViewModel.cs rename to Rubberduck.Core/Navigation/CodeExplorer/ICodeExplorerDeclarationViewModel.cs diff --git a/RetailCoder.VBE/Navigation/CodeMetrics/CodeMetricsAnalyst.cs b/Rubberduck.Core/Navigation/CodeMetrics/CodeMetricsAnalyst.cs similarity index 73% rename from RetailCoder.VBE/Navigation/CodeMetrics/CodeMetricsAnalyst.cs rename to Rubberduck.Core/Navigation/CodeMetrics/CodeMetricsAnalyst.cs index fbddeba70a..479d463db3 100644 --- a/RetailCoder.VBE/Navigation/CodeMetrics/CodeMetricsAnalyst.cs +++ b/Rubberduck.Core/Navigation/CodeMetrics/CodeMetricsAnalyst.cs @@ -1,29 +1,24 @@ -using System.Collections.Generic; -using System.Linq; -using Rubberduck.Parsing.VBA; +using Antlr4.Runtime.Misc; using Antlr4.Runtime.Tree; using Rubberduck.Parsing.Grammar; -using Rubberduck.VBEditor; -using Antlr4.Runtime.Misc; using Rubberduck.Parsing.Symbols; -using Rubberduck.SmartIndenter; +using Rubberduck.Parsing.VBA; +using Rubberduck.VBEditor; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; namespace Rubberduck.Navigation.CodeMetrics { public class CodeMetricsAnalyst : ICodeMetricsAnalyst - { - private readonly IIndenterSettings _indenterSettings; - - public CodeMetricsAnalyst(IIndenterSettings indenterSettings) - { - _indenterSettings = indenterSettings; - } + { + public CodeMetricsAnalyst() { } public IEnumerable ModuleMetrics(RubberduckParserState state) { if (state == null || !state.AllUserDeclarations.Any()) { - // must not return Enumerable.Empty + // can not explicitly return Enumerable.Empty, this is equivalent yield break; } @@ -42,8 +37,9 @@ public ModuleMetricsResult GetModuleResult(RubberduckParserState state, Qualifie private ModuleMetricsResult GetModuleResult(QualifiedModuleName qmn, IParseTree moduleTree, DeclarationFinder declarationFinder) { - // Consider rewrite as visitor? That should make subtrees easier and allow us to expand metrics - var cmListener = new CodeMetricsListener(declarationFinder, _indenterSettings); + // FIXME rewrite as visitor, see discussion on pulls#3522 + // That should make subtrees easier and allow us to expand metrics + var cmListener = new CodeMetricsListener(declarationFinder); ParseTreeWalker.Default.Walk(cmListener, moduleTree); return cmListener.GetMetricsResult(qmn); } @@ -52,31 +48,36 @@ private ModuleMetricsResult GetModuleResult(QualifiedModuleName qmn, IParseTree private class CodeMetricsListener : VBAParserBaseListener { private readonly DeclarationFinder _finder; - private readonly IIndenterSettings _indenterSettings; private Declaration _currentMember; + private int _currentNestingLevel = 0; + private int _currentMaxNesting = 0; private List _results = new List(); private List _moduleResults = new List(); private List _memberResults = new List(); - public CodeMetricsListener(DeclarationFinder finder, IIndenterSettings indenterSettings) + public CodeMetricsListener(DeclarationFinder finder) { _finder = finder; - _indenterSettings = indenterSettings; } - - public override void EnterEndOfLine([NotNull] VBAParser.EndOfLineContext context) + public override void EnterBlock([NotNull] VBAParser.BlockContext context) { - int followingIndentationLevel = 0; - // we have a proper newline - if (context.NEWLINE() != null) + _currentNestingLevel++; + if (_currentNestingLevel > _currentMaxNesting) { - // the last whitespace, which is the one in front of the next line's contents - var followingWhitespace = context.whiteSpace().LastOrDefault(); - followingIndentationLevel = IndentationLevelFromWhitespace(followingWhitespace); + _currentMaxNesting = _currentNestingLevel; } - (_currentMember == null ? _moduleResults : _results).Add(new CodeMetricsResult(1, 0, followingIndentationLevel)); + } + + public override void ExitBlock([NotNull] VBAParser.BlockContext context) + { + _currentNestingLevel--; + } + + public override void EnterEndOfLine([NotNull] VBAParser.EndOfLineContext context) + { + (_currentMember == null ? _moduleResults : _results).Add(new CodeMetricsResult(1, 0, 0)); } public override void EnterIfStmt([NotNull] VBAParser.IfStmtContext context) @@ -160,27 +161,15 @@ public override void ExitPropertySetStmt([NotNull] VBAParser.PropertySetStmtCont { ExitMeasurableMember(); } - - public override void EnterBlockStmt([NotNull] VBAParser.BlockStmtContext context) - { - // there is a whitespace context here after the option of a statementLabel. - // we need to account for that - _results.Add(new CodeMetricsResult(0, 0, IndentationLevelFromWhitespace(context.whiteSpace()))); - } - private int IndentationLevelFromWhitespace(VBAParser.WhiteSpaceContext wsContext) - { - if (wsContext == null) return 0; - // the only thing that contains underscores is the line-continuation at this point - var lineContinuation = wsContext.children.LastOrDefault((tree) => tree.GetText().Contains("_")); - var index = lineContinuation != null ? wsContext.children.IndexOf(lineContinuation) : 0; - return (wsContext?.ChildCount ?? 0 - index) / _indenterSettings.IndentSpaces; - } - private void ExitMeasurableMember() { + Debug.Assert(_currentNestingLevel == 0, "Unexpected Nesting Level when exiting Measurable Member"); + _results.Add(new CodeMetricsResult(0, 0, _currentMaxNesting)); _memberResults.Add(new MemberMetricsResult(_currentMember, _results)); - _results = new List(); // reinitialize to drop results + // reset state + _results = new List(); + _currentMaxNesting = 0; _currentMember = null; } diff --git a/RetailCoder.VBE/Navigation/CodeMetrics/CodeMetricsResult.cs b/Rubberduck.Core/Navigation/CodeMetrics/CodeMetricsResult.cs similarity index 100% rename from RetailCoder.VBE/Navigation/CodeMetrics/CodeMetricsResult.cs rename to Rubberduck.Core/Navigation/CodeMetrics/CodeMetricsResult.cs diff --git a/RetailCoder.VBE/Navigation/CodeMetrics/CodeMetricsViewModel.cs b/Rubberduck.Core/Navigation/CodeMetrics/CodeMetricsViewModel.cs similarity index 100% rename from RetailCoder.VBE/Navigation/CodeMetrics/CodeMetricsViewModel.cs rename to Rubberduck.Core/Navigation/CodeMetrics/CodeMetricsViewModel.cs diff --git a/RetailCoder.VBE/Navigation/CodeMetrics/ICodeMetricsAnalyst.cs b/Rubberduck.Core/Navigation/CodeMetrics/ICodeMetricsAnalyst.cs similarity index 100% rename from RetailCoder.VBE/Navigation/CodeMetrics/ICodeMetricsAnalyst.cs rename to Rubberduck.Core/Navigation/CodeMetrics/ICodeMetricsAnalyst.cs diff --git a/RetailCoder.VBE/Navigation/Folders/FolderHelper.cs b/Rubberduck.Core/Navigation/Folders/FolderHelper.cs similarity index 88% rename from RetailCoder.VBE/Navigation/Folders/FolderHelper.cs rename to Rubberduck.Core/Navigation/Folders/FolderHelper.cs index 980559c95a..b58fcc5c64 100644 --- a/RetailCoder.VBE/Navigation/Folders/FolderHelper.cs +++ b/Rubberduck.Core/Navigation/Folders/FolderHelper.cs @@ -17,16 +17,13 @@ public class FolderHelper DeclarationType.UserForm, }; - public FolderHelper(RubberduckParserState state) - { - _state = state; - } + public FolderHelper(RubberduckParserState state) => _state = state; public CodeExplorerCustomFolderViewModel GetFolderTree(Declaration declaration = null) { var delimiter = GetDelimiter(); - var root = new CodeExplorerCustomFolderViewModel(null, string.Empty, string.Empty); + var root = new CodeExplorerCustomFolderViewModel(null, string.Empty, string.Empty, _state.ProjectsProvider); var items = declaration == null ? _state.AllUserDeclarations.ToList() @@ -49,7 +46,7 @@ public CodeExplorerCustomFolderViewModel GetFolderTree(Declaration declaration = var node = currentNode.Items.FirstOrDefault(i => i.Name == section); if (node == null) { - node = new CodeExplorerCustomFolderViewModel(currentNode, section, fullPath); + node = new CodeExplorerCustomFolderViewModel(currentNode, section, fullPath, _state.ProjectsProvider); currentNode.AddChild(node); } @@ -60,9 +57,6 @@ public CodeExplorerCustomFolderViewModel GetFolderTree(Declaration declaration = return root; } - private char GetDelimiter() - { - return '.'; - } + private char GetDelimiter() => '.'; } } diff --git a/RetailCoder.VBE/Navigation/RegexSearchReplace/IRegexSearchReplace.cs b/Rubberduck.Core/Navigation/RegexSearchReplace/IRegexSearchReplace.cs similarity index 100% rename from RetailCoder.VBE/Navigation/RegexSearchReplace/IRegexSearchReplace.cs rename to Rubberduck.Core/Navigation/RegexSearchReplace/IRegexSearchReplace.cs diff --git a/RetailCoder.VBE/Navigation/RegexSearchReplace/IRegexSearchReplaceDialog.cs b/Rubberduck.Core/Navigation/RegexSearchReplace/IRegexSearchReplaceDialog.cs similarity index 100% rename from RetailCoder.VBE/Navigation/RegexSearchReplace/IRegexSearchReplaceDialog.cs rename to Rubberduck.Core/Navigation/RegexSearchReplace/IRegexSearchReplaceDialog.cs diff --git a/RetailCoder.VBE/Navigation/RegexSearchReplace/RegexSearchReplace.cs b/Rubberduck.Core/Navigation/RegexSearchReplace/RegexSearchReplace.cs similarity index 53% rename from RetailCoder.VBE/Navigation/RegexSearchReplace/RegexSearchReplace.cs rename to Rubberduck.Core/Navigation/RegexSearchReplace/RegexSearchReplace.cs index 6a9acc601b..a47f0bb757 100644 --- a/RetailCoder.VBE/Navigation/RegexSearchReplace/RegexSearchReplace.cs +++ b/Rubberduck.Core/Navigation/RegexSearchReplace/RegexSearchReplace.cs @@ -35,15 +35,9 @@ public RegexSearchReplace(IVBE vbe, IParseCoordinator parser) public IEnumerable Search(string searchPattern, RegexSearchReplaceScope scope = RegexSearchReplaceScope.CurrentFile) { - Func> searchFunc; - if (_search.TryGetValue(scope, out searchFunc)) - { - return searchFunc.Invoke(searchPattern); - } - else - { - return new List(); - } + return _search.TryGetValue(scope, out var searchFunc) + ? searchFunc.Invoke(searchPattern) + : new List(); } public void Replace(string searchPattern, string replaceValue, RegexSearchReplaceScope scope) @@ -100,11 +94,18 @@ private void SetSelection(RegexSearchResult item) private List SearchSelection(string searchPattern) { - var pane = _vbe.ActiveCodePane; - var module = pane.CodeModule; + using (var pane = _vbe.ActiveCodePane) { - var results = GetResultsFromModule(module, searchPattern); - return results.Where(r => pane.Selection.Contains(r.Selection)).ToList(); + if (pane == null || pane.IsWrappingNullReference) + { + return new List(); + } + + using (var module = pane.CodeModule) + { + var results = GetResultsFromModule(module, searchPattern); + return results.Where(r => pane.Selection.Contains(r.Selection)).ToList(); + } } } @@ -121,34 +122,62 @@ private List SearchCurrentBlock(string searchPattern) }; var state = _parser.State; - var pane = _vbe.ActiveCodePane; - var module = pane.CodeModule; + using (var pane = _vbe.ActiveCodePane) { - var results = GetResultsFromModule(module, searchPattern); + if (pane == null || pane.IsWrappingNullReference) + { + return new List(); + } + + using (var module = pane.CodeModule) + { + var results = GetResultsFromModule(module, searchPattern); + + var qualifiedSelection = pane.GetQualifiedSelection(); + dynamic block = state.AllDeclarations.FindTarget(qualifiedSelection.Value, declarationTypes).Context + .Parent; + var selection = new Selection(block.Start.Line, block.Start.Column, block.Stop.Line, + block.Stop.Column); - var qualifiedSelection = new QualifiedSelection(new QualifiedModuleName(module.Parent), pane.Selection); - dynamic block = state.AllDeclarations.FindTarget(qualifiedSelection, declarationTypes).Context.Parent; - var selection = new Selection(block.Start.Line, block.Start.Column, block.Stop.Line, block.Stop.Column); - return results.Where(r => selection.Contains(r.Selection)).ToList(); + return results.Where(r => selection.Contains(r.Selection)).ToList(); + } } } private List SearchCurrentFile(string searchPattern) { - var pane = _vbe.ActiveCodePane; + using (var pane = _vbe.ActiveCodePane) { - return GetResultsFromModule(pane.CodeModule, searchPattern).ToList(); + if (pane == null || pane.IsWrappingNullReference) + { + return new List(); + } + + using (var codeModule = pane.CodeModule) + { + return GetResultsFromModule(codeModule, searchPattern).ToList(); + } } } private List SearchOpenFiles(string searchPattern) { var results = new List(); - var panes = _vbe.CodePanes; + using (var panes = _vbe.CodePanes) { foreach (var codePane in panes) { - results.AddRange(GetResultsFromModule(codePane.CodeModule, searchPattern)); + try + { + using (var codeModule = codePane.CodeModule) + { + results.AddRange(GetResultsFromModule(codeModule, searchPattern)); + } + } + finally + { + codePane.Dispose(); + } } return results; @@ -158,35 +187,68 @@ private List SearchOpenFiles(string searchPattern) private List SearchCurrentProject(string searchPattern) { var results = new List(); - var project = _vbe.ActiveVBProject; - var components = project.VBComponents; + using (var project = _vbe.ActiveVBProject) { - foreach (var component in components) + using (var components = project.VBComponents) { - results.AddRange(GetResultsFromModule(component.CodeModule, searchPattern)); + foreach (var component in components) + { + try + { + using (var codeModule = component.CodeModule) + { + results.AddRange(GetResultsFromModule(codeModule, searchPattern)); + } + } + finally + { + component.Dispose(); + } + } + return results; } - - return results; } } private List SearchOpenProjects(string searchPattern) { var results = new List(); - var projects = _vbe.VBProjects; + using (var projects = _vbe.VBProjects) { - var modules = projects - .Where(project => project.Protection == ProjectProtection.Unprotected) - .SelectMany(project => project.VBComponents) - .Select(component => component.CodeModule); - - foreach (var module in modules) + foreach (var project in projects) { - results.AddRange(GetResultsFromModule(module, searchPattern)); + try + { + if (project.Protection == ProjectProtection.Locked) + { + continue; + } + + using (var components = project.VBComponents) + { + foreach (var component in components) + { + try + { + using (var codeModule = component.CodeModule) + { + results.AddRange(GetResultsFromModule(codeModule, searchPattern)); + } + } + finally + { + component.Dispose(); + } + } + } + } + finally + { + project.Dispose(); + } } - - return results; } + return results; } } } diff --git a/Rubberduck.Core/Navigation/RegexSearchReplace/RegexSearchReplaceModel.cs b/Rubberduck.Core/Navigation/RegexSearchReplace/RegexSearchReplaceModel.cs new file mode 100644 index 0000000000..caba21e5a8 --- /dev/null +++ b/Rubberduck.Core/Navigation/RegexSearchReplace/RegexSearchReplaceModel.cs @@ -0,0 +1,41 @@ +using Rubberduck.UI; + +namespace Rubberduck.Navigation.RegexSearchReplace +{ + public class RegexSearchReplaceModel : ViewModelBase + { + private string _searchPattern; + public string SearchPattern + { + get => _searchPattern; + set + { + _searchPattern = value; + OnPropertyChanged(); + } + } + + private string _replacePattern; + public string ReplacePattern + { + get => _replacePattern; + set + { + _replacePattern = value; + OnPropertyChanged(); + } + } + + private RegexSearchReplaceScope _searchScope; + public RegexSearchReplaceScope SearchScope + { + get => _searchScope; + set + { + _searchScope = value; + OnPropertyChanged(); + + } + } + } +} diff --git a/RetailCoder.VBE/Navigation/RegexSearchReplace/RegexSearchReplacePresenter.cs b/Rubberduck.Core/Navigation/RegexSearchReplace/RegexSearchReplacePresenter.cs similarity index 100% rename from RetailCoder.VBE/Navigation/RegexSearchReplace/RegexSearchReplacePresenter.cs rename to Rubberduck.Core/Navigation/RegexSearchReplace/RegexSearchReplacePresenter.cs diff --git a/RetailCoder.VBE/Navigation/RegexSearchReplace/RegexSearchReplaceScope.cs b/Rubberduck.Core/Navigation/RegexSearchReplace/RegexSearchReplaceScope.cs similarity index 100% rename from RetailCoder.VBE/Navigation/RegexSearchReplace/RegexSearchReplaceScope.cs rename to Rubberduck.Core/Navigation/RegexSearchReplace/RegexSearchReplaceScope.cs diff --git a/RetailCoder.VBE/Navigation/RegexSearchReplace/RegexSearchResult.cs b/Rubberduck.Core/Navigation/RegexSearchReplace/RegexSearchResult.cs similarity index 69% rename from RetailCoder.VBE/Navigation/RegexSearchReplace/RegexSearchResult.cs rename to Rubberduck.Core/Navigation/RegexSearchReplace/RegexSearchResult.cs index f3c3978c51..b91bca055c 100644 --- a/RetailCoder.VBE/Navigation/RegexSearchReplace/RegexSearchResult.cs +++ b/Rubberduck.Core/Navigation/RegexSearchReplace/RegexSearchResult.cs @@ -6,10 +6,10 @@ namespace Rubberduck.Navigation.RegexSearchReplace { public class RegexSearchResult { - public Match Match { get; private set; } - public ICodeModule Module { get; private set; } - public Selection Selection { get; private set; } - public string DisplayString { get { return Match.Value; } } + public Match Match { get; } + public ICodeModule Module { get; } + public Selection Selection { get; } + public string DisplayString => Match.Value; public RegexSearchResult(Match match, ICodeModule module, int line) { diff --git a/RetailCoder.VBE/Properties/Annotations.cs b/Rubberduck.Core/Properties/Annotations.cs similarity index 100% rename from RetailCoder.VBE/Properties/Annotations.cs rename to Rubberduck.Core/Properties/Annotations.cs diff --git a/Rubberduck.Core/Properties/AssemblyInfo.cs b/Rubberduck.Core/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..e3a78d14c2 --- /dev/null +++ b/Rubberduck.Core/Properties/AssemblyInfo.cs @@ -0,0 +1,34 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Allgemeine Informationen über eine Assembly werden über die folgenden +// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +// die einer Assembly zugeordnet sind. +[assembly: AssemblyTitle("Rubberduck.Core")] +[assembly: AssemblyDescription("The core of Rubberduck")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Rubberduck-VBA")] +[assembly: AssemblyProduct("Rubberduck.Core")] +[assembly: AssemblyCopyright("Copyright © 2014-2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: InternalsVisibleTo("Rubberduck.Main")] +[assembly: InternalsVisibleTo("RubberduckTests")] + +// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar +// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von +// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen. +[assembly: ComVisible(false)] + +// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird +[assembly: Guid("7f136926-696e-4051-bd40-efc19c8f78c6")] + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +[assembly: AssemblyVersion("2.1.*")] diff --git a/RetailCoder.VBE/Properties/Resources.Designer.cs b/Rubberduck.Core/Properties/Resources.Designer.cs similarity index 100% rename from RetailCoder.VBE/Properties/Resources.Designer.cs rename to Rubberduck.Core/Properties/Resources.Designer.cs diff --git a/RetailCoder.VBE/Properties/Resources.resx b/Rubberduck.Core/Properties/Resources.resx similarity index 100% rename from RetailCoder.VBE/Properties/Resources.resx rename to Rubberduck.Core/Properties/Resources.resx diff --git a/Rubberduck.Core/Properties/Settings.Designer.cs b/Rubberduck.Core/Properties/Settings.Designer.cs new file mode 100644 index 0000000000..f891ef82a6 --- /dev/null +++ b/Rubberduck.Core/Properties/Settings.Designer.cs @@ -0,0 +1,429 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Rubberduck.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.5.0.0")] + public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + R + true + true + false + true + CodePaneRefactorRenameCommand +")] + public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_CodePaneRefactorRenameCommand { + get { + return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_CodePaneRefactorRenameCommand"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + F + true + true + false + true + RefactorEncapsulateFieldCommand +")] + public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_RefactorEncapsulateFieldCommand { + get { + return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_RefactorEncapsulateFieldCommand"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + M + true + true + false + true + RefactorExtractMethodCommand +")] + public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_RefactorExtractMethodCommand { + get { + return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_RefactorExtractMethodCommand"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + C + true + true + false + true + RefactorMoveCloserToUsageCommand +")] + public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_RefactorMoveCloserToUsageCommand { + get { + return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_RefactorMoveCloserToUsageCommand"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + R + true + false + false + true + CodeExplorerCommand +")] + public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_CodeExplorerCommand { + get { + return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_CodeExplorerCommand"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + E + true + true + false + true + ExportAllCommand +")] + public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_ExportAllCommand { + get { + return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_ExportAllCommand"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + T + true + false + false + true + FindSymbolCommand +")] + public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_FindSymbolCommand { + get { + return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_FindSymbolCommand"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + M + true + false + false + true + IndentCurrentModuleCommand +")] + public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_IndentCurrentModuleCommand { + get { + return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_IndentCurrentModuleCommand"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + P + true + false + false + true + IndentCurrentProcedureCommand +")] + public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_IndentCurrentProcedureCommand { + get { + return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_IndentCurrentProcedureCommand"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + I + true + true + false + true + InspectionResultsCommand +")] + public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_InspectionResultsCommand { + get { + return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_InspectionResultsCommand"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + ` + true + false + false + true + ReparseCommand +")] + public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_ReparseCommand { + get { + return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_ReparseCommand"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + T + true + true + false + true + TestExplorerCommand +")] + public global::Rubberduck.Settings.HotkeySetting DefaultHotkey_TestExplorerCommand { + get { + return ((global::Rubberduck.Settings.HotkeySetting)(this["DefaultHotkey_TestExplorerCommand"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("\r\n")] + public global::Rubberduck.Settings.ToDoMarker ToDoMarker_ToDo { + get { + return ((global::Rubberduck.Settings.ToDoMarker)(this["ToDoMarker_ToDo"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("\r\n")] + public global::Rubberduck.Settings.ToDoMarker ToDoMarker_Note { + get { + return ((global::Rubberduck.Settings.ToDoMarker)(this["ToDoMarker_Note"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("\r\n")] + public global::Rubberduck.Settings.ToDoMarker ToDoMarker_Bug { + get { + return ((global::Rubberduck.Settings.ToDoMarker)(this["ToDoMarker_Bug"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + false + false + false + false + true + false + false +")] + public global::Rubberduck.Settings.WindowSettings WindowSettings { + get { + return ((global::Rubberduck.Settings.WindowSettings)(this["WindowSettings"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + LateBinding + StrictAssert + true + true + false +")] + public global::Rubberduck.Settings.UnitTestSettings UnitTestSettings { + get { + return ((global::Rubberduck.Settings.UnitTestSettings)(this["UnitTestSettings"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute(@" + + + true + true + true + false + false + 10 + 6 + +")] + public global::Rubberduck.Settings.GeneralSettings GeneralSettings { + get { + return ((global::Rubberduck.Settings.GeneralSettings)(this["GeneralSettings"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("\r\n\r\n \r\n \r\n \r\n \r\n <" + + "CodeInspection Name=\"UnhandledOnErrorResumeNextInspection\" Severity=\"Warning\" In" + + "spectionType=\"CodeQualityIssues\" />\r\n \r\n <" + + "CodeInspection Name=\"ImplicitByRefModifierInspection\" Severity=\"Hint\" Inspection" + + "Type=\"CodeQualityIssues\" />\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n <" + + "CodeInspection Name=\"ObjectVariableNotSetInspection\" Severity=\"Error\" Inspection" + + "Type=\"CodeQualityIssues\" />\r\n \r\n \r\n \r" + + "\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n true\r\n")] + public global::Rubberduck.Settings.CodeInspectionSettings CodeInspectionSettings { + get { + return ((global::Rubberduck.Settings.CodeInspectionSettings)(this["CodeInspectionSettings"])); + } + } + } +} diff --git a/Rubberduck.Core/Properties/Settings.settings b/Rubberduck.Core/Properties/Settings.settings new file mode 100644 index 0000000000..92d2d087a9 --- /dev/null +++ b/Rubberduck.Core/Properties/Settings.settings @@ -0,0 +1,260 @@ + + + + + + <?xml version="1.0" encoding="utf-16"?> +<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>R</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>true</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>CodePaneRefactorRenameCommand</CommandTypeName> +</HotkeySetting> + + + <?xml version="1.0" encoding="utf-16"?> +<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>F</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>true</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>RefactorEncapsulateFieldCommand</CommandTypeName> +</HotkeySetting> + + + <?xml version="1.0" encoding="utf-16"?> +<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>M</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>true</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>RefactorExtractMethodCommand</CommandTypeName> +</HotkeySetting> + + + <?xml version="1.0" encoding="utf-16"?> +<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>C</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>true</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>RefactorMoveCloserToUsageCommand</CommandTypeName> +</HotkeySetting> + + + <?xml version="1.0" encoding="utf-16"?> +<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>R</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>false</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>CodeExplorerCommand</CommandTypeName> +</HotkeySetting> + + + <?xml version="1.0" encoding="utf-16"?> +<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>E</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>true</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>ExportAllCommand</CommandTypeName> +</HotkeySetting> + + + <?xml version="1.0" encoding="utf-16"?> +<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>T</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>false</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>FindSymbolCommand</CommandTypeName> +</HotkeySetting> + + + <?xml version="1.0" encoding="utf-16"?> +<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>M</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>false</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>IndentCurrentModuleCommand</CommandTypeName> +</HotkeySetting> + + + <?xml version="1.0" encoding="utf-16"?> +<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>P</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>false</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>IndentCurrentProcedureCommand</CommandTypeName> +</HotkeySetting> + + + <?xml version="1.0" encoding="utf-16"?> +<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>I</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>true</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>InspectionResultsCommand</CommandTypeName> +</HotkeySetting> + + + <?xml version="1.0" encoding="utf-16"?> +<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>`</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>false</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>ReparseCommand</CommandTypeName> +</HotkeySetting> + + + <?xml version="1.0" encoding="utf-16"?> +<HotkeySetting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Key1>T</Key1> + <IsEnabled>true</IsEnabled> + <HasShiftModifier>true</HasShiftModifier> + <HasAltModifier>false</HasAltModifier> + <HasCtrlModifier>true</HasCtrlModifier> + <CommandTypeName>TestExplorerCommand</CommandTypeName> +</HotkeySetting> + + + <?xml version="1.0" encoding="utf-16"?> +<ToDoMarker xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Text="TODO" /> + + + <?xml version="1.0" encoding="utf-16"?> +<ToDoMarker xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Text="NOTE" /> + + + <?xml version="1.0" encoding="utf-16"?> +<ToDoMarker xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Text="BUG" /> + + + <?xml version="1.0" encoding="utf-16"?> +<WindowSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <CodeExplorerVisibleOnStartup>false</CodeExplorerVisibleOnStartup> + <CodeInspectionsVisibleOnStartup>false</CodeInspectionsVisibleOnStartup> + <TestExplorerVisibleOnStartup>false</TestExplorerVisibleOnStartup> + <TodoExplorerVisibleOnStartup>false</TodoExplorerVisibleOnStartup> + <CodeExplorer_SortByName>true</CodeExplorer_SortByName> + <CodeExplorer_SortByCodeOrder>false</CodeExplorer_SortByCodeOrder> + <CodeExplorer_GroupByType>false</CodeExplorer_GroupByType> +</WindowSettings> + + + <?xml version="1.0" encoding="utf-16"?> +<UnitTestSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <BindingMode>LateBinding</BindingMode> + <AssertMode>StrictAssert</AssertMode> + <ModuleInit>true</ModuleInit> + <MethodInit>true</MethodInit> + <DefaultTestStubInNewModule>false</DefaultTestStubInNewModule> +</UnitTestSettings> + + + <?xml version="1.0" encoding="utf-16"?> +<GeneralSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Language Code="en-US" /> + <CanShowSplash>true</CanShowSplash> + <CanCheckVersion>true</CanCheckVersion> + <CompileBeforeParse>true</CompileBeforeParse> + <IsSmartIndenterPrompted>false</IsSmartIndenterPrompted> + <IsAutoSaveEnabled>false</IsAutoSaveEnabled> + <AutoSavePeriod>10</AutoSavePeriod> + <MinimumLogLevel>6</MinimumLogLevel> + <EnableExperimentalFeatures /> +</GeneralSettings> + + + <?xml version="1.0" encoding="utf-16"?> +<CodeInspectionSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <CodeInspections> + <CodeInspection Name="BooleanAssignedInIfElseInspection" Severity="Warning" InspectionType="MaintainabilityAndReadabilityIssues" /> + <CodeInspection Name="ObsoleteErrorSyntaxInspection" Severity="Suggestion" InspectionType="LanguageOpportunities" /> + <CodeInspection Name="StopKeywordInspection" Severity="Suggestion" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="UnhandledOnErrorResumeNextInspection" Severity="Warning" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="EmptyStringLiteralInspection" Severity="Warning" InspectionType="LanguageOpportunities" /> + <CodeInspection Name="ImplicitByRefModifierInspection" Severity="Hint" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="MissingAttributeInspection" Severity="Warning" InspectionType="RubberduckOpportunities" /> + <CodeInspection Name="FunctionReturnValueNotUsedInspection" Severity="Warning" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="IllegalAnnotationInspection" Severity="Error" InspectionType="RubberduckOpportunities" /> + <CodeInspection Name="RedundantByRefModifierInspection" Severity="DoNotShow" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="MissingAnnotationArgumentInspection" Severity="Error" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="ModuleScopeDimKeywordInspection" Severity="Suggestion" InspectionType="LanguageOpportunities" /> + <CodeInspection Name="MultilineParameterInspection" Severity="Suggestion" InspectionType="MaintainabilityAndReadabilityIssues" /> + <CodeInspection Name="MultipleDeclarationsInspection" Severity="Warning" InspectionType="MaintainabilityAndReadabilityIssues" /> + <CodeInspection Name="ObsoleteCallStatementInspection" Severity="Suggestion" InspectionType="LanguageOpportunities" /> + <CodeInspection Name="ObsoleteCommentSyntaxInspection" Severity="Suggestion" InspectionType="LanguageOpportunities" /> + <CodeInspection Name="ObsoleteLetStatementInspection" Severity="Suggestion" InspectionType="LanguageOpportunities" /> + <CodeInspection Name="OptionBaseInspection" Severity="Hint" InspectionType="MaintainabilityAndReadabilityIssues" /> + <CodeInspection Name="RedundantOptionInspection" Severity="Hint" InspectionType="LanguageOpportunities" /> + <CodeInspection Name="OptionExplicitInspection" Severity="Error" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="ProcedureCanBeWrittenAsFunctionInspection" Severity="Suggestion" InspectionType="LanguageOpportunities" /> + <CodeInspection Name="ApplicationWorksheetFunctionInspection" Severity="Suggestion" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="AssignedByValParameterInspection" Severity="Warning" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="EmptyModuleInspection" Severity="Hint" InspectionType="MaintainabilityAndReadabilityIssues" /> + <CodeInspection Name="LineLabelNotUsedInspection" Severity="Warning" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="IntegerDataTypeInspection" Severity="Hint" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="ShadowedDeclarationInspection" Severity="DoNotShow" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="ConstantNotUsedInspection" Severity="Warning" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="DefaultProjectNameInspection" Severity="Suggestion" InspectionType="MaintainabilityAndReadabilityIssues" /> + <CodeInspection Name="EmptyCaseBlockInspection" Severity="Warning" InspectionType="MaintainabilityAndReadabilityIssues" /> + <CodeInspection Name="EmptyDoWhileBlockInspection" Severity="Suggestion" InspectionType="MaintainabilityAndReadabilityIssues" /> + <CodeInspection Name="EmptyElseBlockInspection" Severity="Warning" InspectionType="MaintainabilityAndReadabilityIssues" /> + <CodeInspection Name="EmptyForEachBlockInspection" Severity="Warning" InspectionType="MaintainabilityAndReadabilityIssues" /> + <CodeInspection Name="EmptyForLoopBlockInspection" Severity="Warning" InspectionType="MaintainabilityAndReadabilityIssues" /> + <CodeInspection Name="EmptyIfBlockInspection" Severity="Warning" InspectionType="MaintainabilityAndReadabilityIssues" /> + <CodeInspection Name="EmptyWhileWendBlockInspection" Severity="Warning" InspectionType="MaintainabilityAndReadabilityIssues" /> + <CodeInspection Name="EncapsulatePublicFieldInspection" Severity="Suggestion" InspectionType="MaintainabilityAndReadabilityIssues" /> + <CodeInspection Name="HostSpecificExpressionInspection" Severity="Warning" InspectionType="LanguageOpportunities" /> + <CodeInspection Name="HungarianNotationInspection" Severity="Suggestion" InspectionType="MaintainabilityAndReadabilityIssues" /> + <CodeInspection Name="ImplicitActiveSheetReferenceInspection" Severity="Warning" InspectionType="LanguageOpportunities" /> + <CodeInspection Name="ImplicitActiveWorkbookReferenceInspection" Severity="Warning" InspectionType="LanguageOpportunities" /> + <CodeInspection Name="ImplicitDefaultMemberAssignmentInspection" Severity="Suggestion" InspectionType="LanguageOpportunities" /> + <CodeInspection Name="ImplicitPublicMemberInspection" Severity="Hint" InspectionType="LanguageOpportunities" /> + <CodeInspection Name="ImplicitVariantReturnTypeInspection" Severity="Hint" InspectionType="LanguageOpportunities" /> + <CodeInspection Name="MemberNotOnInterfaceInspection" Severity="Warning" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="MoveFieldCloserToUsageInspection" Severity="Hint" InspectionType="MaintainabilityAndReadabilityIssues" /> + <CodeInspection Name="NonReturningFunctionInspection" Severity="Error" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="ObjectVariableNotSetInspection" Severity="Error" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="ObsoleteGlobalInspection" Severity="Suggestion" InspectionType="LanguageOpportunities" /> + <CodeInspection Name="ObsoleteTypeHintInspection" Severity="Suggestion" InspectionType="LanguageOpportunities" /> + <CodeInspection Name="ParameterCanBeByValInspection" Severity="Suggestion" InspectionType="MaintainabilityAndReadabilityIssues" /> + <CodeInspection Name="ParameterNotUsedInspection" Severity="Warning" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="ProcedureNotUsedInspection" Severity="Warning" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="SelfAssignedDeclarationInspection" Severity="Suggestion" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="UnassignedVariableUsageInspection" Severity="Error" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="UndeclaredVariableInspection" Severity="Error" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="UntypedFunctionUsageInspection" Severity="Hint" InspectionType="LanguageOpportunities" /> + <CodeInspection Name="UseMeaningfulNameInspection" Severity="Suggestion" InspectionType="MaintainabilityAndReadabilityIssues" /> + <CodeInspection Name="VariableNotAssignedInspection" Severity="Warning" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="VariableNotUsedInspection" Severity="Warning" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="VariableTypeNotDeclaredInspection" Severity="Warning" InspectionType="LanguageOpportunities" /> + <CodeInspection Name="WriteOnlyPropertyInspection" Severity="Suggestion" InspectionType="CodeQualityIssues" /> + <CodeInspection Name="DefTypeStatementInspection" Severity="Suggestion" InspectionType="LanguageOpportunities" /> + <CodeInspection Name="StepIsNotSpecifiedInspection" Severity="DoNotShow" InspectionType="LanguageOpportunities" /> + <CodeInspection Name="StepOneIsRedundantInspection" Severity="Hint" InspectionType="LanguageOpportunities" /> + </CodeInspections> + <WhitelistedIdentifiers /> + <RunInspectionsOnSuccessfulParse>true</RunInspectionsOnSuccessfulParse> +</CodeInspectionSettings> + + + \ No newline at end of file diff --git a/RetailCoder.VBE/Refactorings/EncapsulateField/EncapsulateFieldModel.cs b/Rubberduck.Core/Refactorings/EncapsulateField/EncapsulateFieldModel.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/EncapsulateField/EncapsulateFieldModel.cs rename to Rubberduck.Core/Refactorings/EncapsulateField/EncapsulateFieldModel.cs diff --git a/RetailCoder.VBE/Refactorings/EncapsulateField/EncapsulateFieldPresenter.cs b/Rubberduck.Core/Refactorings/EncapsulateField/EncapsulateFieldPresenter.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/EncapsulateField/EncapsulateFieldPresenter.cs rename to Rubberduck.Core/Refactorings/EncapsulateField/EncapsulateFieldPresenter.cs diff --git a/RetailCoder.VBE/Refactorings/EncapsulateField/EncapsulateFieldPresenterFactory.cs b/Rubberduck.Core/Refactorings/EncapsulateField/EncapsulateFieldPresenterFactory.cs similarity index 82% rename from RetailCoder.VBE/Refactorings/EncapsulateField/EncapsulateFieldPresenterFactory.cs rename to Rubberduck.Core/Refactorings/EncapsulateField/EncapsulateFieldPresenterFactory.cs index 33fe592ad0..c725c76cbd 100644 --- a/RetailCoder.VBE/Refactorings/EncapsulateField/EncapsulateFieldPresenterFactory.cs +++ b/Rubberduck.Core/Refactorings/EncapsulateField/EncapsulateFieldPresenterFactory.cs @@ -1,6 +1,7 @@ using Rubberduck.Parsing.VBA; using Rubberduck.UI.Refactorings; using Rubberduck.UI.Refactorings.EncapsulateField; +using Rubberduck.VBEditor; using Rubberduck.VBEditor.SafeComWrappers.Abstract; namespace Rubberduck.Refactorings.EncapsulateField @@ -20,13 +21,9 @@ public EncapsulateFieldPresenterFactory(IVBE vbe, RubberduckParserState state, I public EncapsulateFieldPresenter Create() { - var pane = _vbe.ActiveCodePane; - if (pane == null || pane.IsWrappingNullReference) - { - return null; - } - var selection = pane.GetQualifiedSelection(); + var selection = _vbe.GetActiveSelection(); + if (!selection.HasValue) { return null; diff --git a/RetailCoder.VBE/Refactorings/EncapsulateField/EncapsulateFieldRefactoring.cs b/Rubberduck.Core/Refactorings/EncapsulateField/EncapsulateFieldRefactoring.cs similarity index 87% rename from RetailCoder.VBE/Refactorings/EncapsulateField/EncapsulateFieldRefactoring.cs rename to Rubberduck.Core/Refactorings/EncapsulateField/EncapsulateFieldRefactoring.cs index b0810d02dc..0c51cd0b8a 100644 --- a/RetailCoder.VBE/Refactorings/EncapsulateField/EncapsulateFieldRefactoring.cs +++ b/Rubberduck.Core/Refactorings/EncapsulateField/EncapsulateFieldRefactoring.cs @@ -46,15 +46,28 @@ public void Refactor() public void Refactor(QualifiedSelection target) { - var pane = _vbe.ActiveCodePane; - pane.Selection = target.Selection; + using (var pane = _vbe.ActiveCodePane) + { + if (pane == null || pane.IsWrappingNullReference) + { + return; + } + pane.Selection = target.Selection; + } Refactor(); } public void Refactor(Declaration target) { - var pane = _vbe.ActiveCodePane; - pane.Selection = target.QualifiedSelection.Selection; + using (var pane = _vbe.ActiveCodePane) + { + if (pane == null || pane.IsWrappingNullReference) + { + return; + } + + pane.Selection = target.QualifiedSelection.Selection; + } Refactor(); } @@ -77,7 +90,7 @@ private void AddProperty(IModuleRewriter rewriter) if (_model.TargetDeclaration.Accessibility != Accessibility.Private) { - var newField = "Private " + _model.TargetDeclaration.IdentifierName + " As " + _model.TargetDeclaration.AsTypeName; + var newField = $"Private {_model.TargetDeclaration.IdentifierName} As {_model.TargetDeclaration.AsTypeName}"; if (fields.Count > 1) { newField = Environment.NewLine + newField; diff --git a/RetailCoder.VBE/Refactorings/EncapsulateField/IEncapsulateFieldDialog.cs b/Rubberduck.Core/Refactorings/EncapsulateField/IEncapsulateFieldDialog.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/EncapsulateField/IEncapsulateFieldDialog.cs rename to Rubberduck.Core/Refactorings/EncapsulateField/IEncapsulateFieldDialog.cs diff --git a/RetailCoder.VBE/Refactorings/EncapsulateField/PropertyGenerator.cs b/Rubberduck.Core/Refactorings/EncapsulateField/PropertyGenerator.cs similarity index 92% rename from RetailCoder.VBE/Refactorings/EncapsulateField/PropertyGenerator.cs rename to Rubberduck.Core/Refactorings/EncapsulateField/PropertyGenerator.cs index 0e67c7c51b..f0e9426ff5 100644 --- a/RetailCoder.VBE/Refactorings/EncapsulateField/PropertyGenerator.cs +++ b/Rubberduck.Core/Refactorings/EncapsulateField/PropertyGenerator.cs @@ -11,9 +11,8 @@ public class PropertyGenerator public bool GenerateLetter { get; set; } public bool GenerateSetter { get; set; } - public string AllPropertyCode => GetterCode + - (GenerateLetter ? LetterCode : string.Empty) + - (GenerateSetter ? SetterCode : string.Empty); + public string AllPropertyCode => + $"{GetterCode}{(GenerateLetter ? LetterCode : string.Empty)}{(GenerateSetter ? SetterCode : string.Empty)}"; public string GetterCode { diff --git a/RetailCoder.VBE/Refactorings/ExtractInterface/ExtractInterfaceModel.cs b/Rubberduck.Core/Refactorings/ExtractInterface/ExtractInterfaceModel.cs similarity index 97% rename from RetailCoder.VBE/Refactorings/ExtractInterface/ExtractInterfaceModel.cs rename to Rubberduck.Core/Refactorings/ExtractInterface/ExtractInterfaceModel.cs index 71d1be1e5e..a3df64f186 100644 --- a/RetailCoder.VBE/Refactorings/ExtractInterface/ExtractInterfaceModel.cs +++ b/Rubberduck.Core/Refactorings/ExtractInterface/ExtractInterfaceModel.cs @@ -45,7 +45,7 @@ public ExtractInterfaceModel(RubberduckParserState state, QualifiedSelection sel return; } - InterfaceName = "I" + TargetDeclaration.IdentifierName; + InterfaceName = $"I{TargetDeclaration.IdentifierName}"; Members = declarations.Where(item => item.ProjectId == TargetDeclaration.ProjectId && item.ComponentName == TargetDeclaration.ComponentName diff --git a/RetailCoder.VBE/Refactorings/ExtractInterface/ExtractInterfacePresenter.cs b/Rubberduck.Core/Refactorings/ExtractInterface/ExtractInterfacePresenter.cs similarity index 77% rename from RetailCoder.VBE/Refactorings/ExtractInterface/ExtractInterfacePresenter.cs rename to Rubberduck.Core/Refactorings/ExtractInterface/ExtractInterfacePresenter.cs index def182b60a..cb1ae4546a 100644 --- a/RetailCoder.VBE/Refactorings/ExtractInterface/ExtractInterfacePresenter.cs +++ b/Rubberduck.Core/Refactorings/ExtractInterface/ExtractInterfacePresenter.cs @@ -1,5 +1,6 @@ using System.Linq; using System.Windows.Forms; +using Rubberduck.Parsing.Symbols; using Rubberduck.UI.Refactorings; namespace Rubberduck.Refactorings.ExtractInterface @@ -27,7 +28,11 @@ public ExtractInterfaceModel Show() return null; } - _view.ViewModel.ComponentNames = _model.TargetDeclaration.Project.VBComponents.Select(c => c.Name).ToList(); + _view.ViewModel.ComponentNames = _model.State.DeclarationFinder + .UserDeclarations(DeclarationType.Module) + .Where(moduleDeclaration => moduleDeclaration.ProjectId == _model.TargetDeclaration.ProjectId) + .Select(module => module.ComponentName) + .ToList(); _view.ViewModel.InterfaceName = _model.InterfaceName; _view.ViewModel.Members = _model.Members.ToList(); diff --git a/RetailCoder.VBE/Refactorings/ExtractInterface/ExtractInterfacePresenterFactory.cs b/Rubberduck.Core/Refactorings/ExtractInterface/ExtractInterfacePresenterFactory.cs similarity index 68% rename from RetailCoder.VBE/Refactorings/ExtractInterface/ExtractInterfacePresenterFactory.cs rename to Rubberduck.Core/Refactorings/ExtractInterface/ExtractInterfacePresenterFactory.cs index 83ed18a77e..06f05d8d55 100644 --- a/RetailCoder.VBE/Refactorings/ExtractInterface/ExtractInterfacePresenterFactory.cs +++ b/Rubberduck.Core/Refactorings/ExtractInterface/ExtractInterfacePresenterFactory.cs @@ -1,6 +1,7 @@ using System.Linq; using Rubberduck.Parsing.VBA; using Rubberduck.UI.Refactorings; +using Rubberduck.VBEditor; using Rubberduck.VBEditor.SafeComWrappers.Abstract; namespace Rubberduck.Refactorings.ExtractInterface @@ -20,26 +21,18 @@ public ExtractInterfacePresenterFactory(IVBE vbe, RubberduckParserState state, I public ExtractInterfacePresenter Create() { - var pane = _vbe.ActiveCodePane; - if (pane == null || pane.IsWrappingNullReference) - { - return null; - } - var selection = pane.GetQualifiedSelection(); + + var selection = _vbe.GetActiveSelection(); + if (selection == null) { return null; } var model = new ExtractInterfaceModel(_state, selection.Value); - if (!model.Members.Any()) - { - // don't show the UI if there's no member to extract - return null; - } - - return new ExtractInterfacePresenter(_view, model); + // don't show the UI if there's no memeber to extract + return model.Members.Any() ? new ExtractInterfacePresenter(_view, model) : null; } } } diff --git a/RetailCoder.VBE/Refactorings/ExtractInterface/ExtractInterfaceRefactoring.cs b/Rubberduck.Core/Refactorings/ExtractInterface/ExtractInterfaceRefactoring.cs similarity index 69% rename from RetailCoder.VBE/Refactorings/ExtractInterface/ExtractInterfaceRefactoring.cs rename to Rubberduck.Core/Refactorings/ExtractInterface/ExtractInterfaceRefactoring.cs index 54d711e6bd..580a448d82 100644 --- a/RetailCoder.VBE/Refactorings/ExtractInterface/ExtractInterfaceRefactoring.cs +++ b/Rubberduck.Core/Refactorings/ExtractInterface/ExtractInterfaceRefactoring.cs @@ -39,25 +39,21 @@ public void Refactor() return; } - var pane = _vbe.ActiveCodePane; - QualifiedSelection? oldSelection; - if (!pane.IsWrappingNullReference) + using (var pane = _vbe.ActiveCodePane) { - var module = pane.CodeModule; + if (pane.IsWrappingNullReference) { - oldSelection = module.GetQualifiedSelection(); + return; } - } - else - { - return; - } - AddInterface(); + var oldSelection = pane.GetQualifiedSelection(); - if (oldSelection.HasValue) - { - pane.Selection = oldSelection.Value.Selection; + AddInterface(); + + if (oldSelection.HasValue) + { + pane.Selection = oldSelection.Value.Selection; + } } _model.State.OnParseRequested(this); @@ -65,7 +61,7 @@ public void Refactor() public void Refactor(QualifiedSelection target) { - var pane = _vbe.ActiveCodePane; + using (var pane = _vbe.ActiveCodePane) { if (pane.IsWrappingNullReference) { @@ -78,7 +74,7 @@ public void Refactor(QualifiedSelection target) public void Refactor(Declaration target) { - var pane = _vbe.ActiveCodePane; + using (var pane = _vbe.ActiveCodePane) { if (pane.IsWrappingNullReference) { @@ -91,6 +87,12 @@ public void Refactor(Declaration target) private void AddInterface() { + var targetProject = _model.TargetDeclaration.Project; + if (targetProject == null) + { + return; //The target project is not available. + } + var rewriter = _model.State.GetRewriter(_model.TargetDeclaration); var firstNonFieldMember = _model.State.DeclarationFinder.Members(_model.TargetDeclaration) @@ -100,17 +102,23 @@ private void AddInterface() AddInterfaceMembersToClass(rewriter); - var components = _model.TargetDeclaration.Project.VBComponents; - var interfaceComponent = components.Add(ComponentType.ClassModule); - var interfaceModule = interfaceComponent.CodeModule; - interfaceComponent.Name = _model.InterfaceName; - - var optionPresent = interfaceModule.CountOfLines > 1; - if (!optionPresent) + using (var components = targetProject.VBComponents) { - interfaceModule.InsertLines(1, Tokens.Option + ' ' + Tokens.Explicit + Environment.NewLine); + using (var interfaceComponent = components.Add(ComponentType.ClassModule)) + { + using (var interfaceModule = interfaceComponent.CodeModule) + { + interfaceComponent.Name = _model.InterfaceName; + + var optionPresent = interfaceModule.CountOfLines > 1; + if (!optionPresent) + { + interfaceModule.InsertLines(1, $"{Tokens.Option} {Tokens.Explicit}{Environment.NewLine}"); + } + interfaceModule.InsertLines(3, GetInterfaceModuleBody()); + } + } } - interfaceModule.InsertLines(3, GetInterfaceModuleBody()); } private void AddInterfaceMembersToClass(IModuleRewriter rewriter) diff --git a/RetailCoder.VBE/Refactorings/ExtractInterface/InterfaceMember.cs b/Rubberduck.Core/Refactorings/ExtractInterface/InterfaceMember.cs similarity index 63% rename from RetailCoder.VBE/Refactorings/ExtractInterface/InterfaceMember.cs rename to Rubberduck.Core/Refactorings/ExtractInterface/InterfaceMember.cs index 56de1a218a..6c21a6a74a 100644 --- a/RetailCoder.VBE/Refactorings/ExtractInterface/InterfaceMember.cs +++ b/Rubberduck.Core/Refactorings/ExtractInterface/InterfaceMember.cs @@ -15,7 +15,7 @@ public class Parameter public override string ToString() { - return ParamAccessibility + " " + ParamName + " As " + ParamType; + return $"{ParamAccessibility} {ParamName} As {ParamType}"; } } @@ -30,7 +30,7 @@ public class InterfaceMember : ViewModelBase private bool _isSelected; public bool IsSelected { - get { return _isSelected; } + get => _isSelected; set { _isSelected = value; @@ -44,10 +44,9 @@ public string FullMemberSignature { get { - var signature = MemberType + " " + Member.IdentifierName + "(" + - string.Join(", ", MemberParams) + ")"; + var signature = $"{MemberType} {Member.IdentifierName}({string.Join(", ", MemberParams)})"; - return Type == null ? signature : signature + " As " + Type; + return Type == null ? signature : $"{signature} As {Type}"; } } @@ -59,8 +58,7 @@ public InterfaceMember(Declaration member) GetMethodType(); - var memberWithParams = member as IParameterizedDeclaration; - if (memberWithParams != null) + if (member is IParameterizedDeclaration memberWithParams) { MemberParams = memberWithParams.Parameters .OrderBy(o => o.Selection.StartLine) @@ -91,38 +89,32 @@ private void GetMethodType() { var context = Member.Context; - var subStmtContext = context as VBAParser.SubStmtContext; - if (subStmtContext != null) + if (context is VBAParser.SubStmtContext) { MemberType = Tokens.Sub; } - var functionStmtContext = context as VBAParser.FunctionStmtContext; - if (functionStmtContext != null) + if (context is VBAParser.FunctionStmtContext) { MemberType = Tokens.Function; } - var propertyGetStmtContext = context as VBAParser.PropertyGetStmtContext; - if (propertyGetStmtContext != null) + if (context is VBAParser.PropertyGetStmtContext) { - MemberType = Tokens.Property + " " + Tokens.Get; + MemberType = $"{Tokens.Property} {Tokens.Get}"; } - var propertyLetStmtContext = context as VBAParser.PropertyLetStmtContext; - if (propertyLetStmtContext != null) + if (context is VBAParser.PropertyLetStmtContext) { - MemberType = Tokens.Property + " " + Tokens.Let; + MemberType = $"{Tokens.Property} {Tokens.Let}"; } - var propertySetStmtContext = context as VBAParser.PropertySetStmtContext; - if (propertySetStmtContext != null) + if (context is VBAParser.PropertySetStmtContext) { - MemberType = Tokens.Property + " " + Tokens.Set; + MemberType = $"{Tokens.Property} {Tokens.Set}"; } } - public string Body => "Public " + FullMemberSignature + Environment.NewLine + - "End " + MemberType.Split(' ').First() + Environment.NewLine; + public string Body => string.Format("Public {0}{1}End {2}{1}", FullMemberSignature, Environment.NewLine, MemberType.Split(' ').First()); } } diff --git a/RetailCoder.VBE/Refactorings/ExtractMethod/ExtractMethodExtraction.cs b/Rubberduck.Core/Refactorings/ExtractMethod/ExtractMethodExtraction.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/ExtractMethod/ExtractMethodExtraction.cs rename to Rubberduck.Core/Refactorings/ExtractMethod/ExtractMethodExtraction.cs diff --git a/RetailCoder.VBE/Refactorings/ExtractMethod/ExtractMethodModel.cs b/Rubberduck.Core/Refactorings/ExtractMethod/ExtractMethodModel.cs similarity index 98% rename from RetailCoder.VBE/Refactorings/ExtractMethod/ExtractMethodModel.cs rename to Rubberduck.Core/Refactorings/ExtractMethod/ExtractMethodModel.cs index af9a5963f1..0aa4c32530 100644 --- a/RetailCoder.VBE/Refactorings/ExtractMethod/ExtractMethodModel.cs +++ b/Rubberduck.Core/Refactorings/ExtractMethod/ExtractMethodModel.cs @@ -27,11 +27,9 @@ public static IEnumerable GroupByMissing(this IEnumerable inputs, Fu { var initialized = false; - T first = default(T); - T last = default(T); - T next = default(T); - Tuple tuple = null; - + T first = default; + T last = default; + foreach (var input in inputs) { if (!initialized) diff --git a/RetailCoder.VBE/Refactorings/ExtractMethod/ExtractMethodParameterClassification.cs b/Rubberduck.Core/Refactorings/ExtractMethod/ExtractMethodParameterClassification.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/ExtractMethod/ExtractMethodParameterClassification.cs rename to Rubberduck.Core/Refactorings/ExtractMethod/ExtractMethodParameterClassification.cs diff --git a/RetailCoder.VBE/Refactorings/ExtractMethod/ExtractMethodPresenter.cs b/Rubberduck.Core/Refactorings/ExtractMethod/ExtractMethodPresenter.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/ExtractMethod/ExtractMethodPresenter.cs rename to Rubberduck.Core/Refactorings/ExtractMethod/ExtractMethodPresenter.cs diff --git a/RetailCoder.VBE/Refactorings/ExtractMethod/ExtractMethodPresenterFactory.cs b/Rubberduck.Core/Refactorings/ExtractMethod/ExtractMethodPresenterFactory.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/ExtractMethod/ExtractMethodPresenterFactory.cs rename to Rubberduck.Core/Refactorings/ExtractMethod/ExtractMethodPresenterFactory.cs diff --git a/RetailCoder.VBE/Refactorings/ExtractMethod/ExtractMethodRefactoring.cs b/Rubberduck.Core/Refactorings/ExtractMethod/ExtractMethodRefactoring.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/ExtractMethod/ExtractMethodRefactoring.cs rename to Rubberduck.Core/Refactorings/ExtractMethod/ExtractMethodRefactoring.cs diff --git a/RetailCoder.VBE/Refactorings/ExtractMethod/ExtractMethodSelectionValidation.cs b/Rubberduck.Core/Refactorings/ExtractMethod/ExtractMethodSelectionValidation.cs similarity index 99% rename from RetailCoder.VBE/Refactorings/ExtractMethod/ExtractMethodSelectionValidation.cs rename to Rubberduck.Core/Refactorings/ExtractMethod/ExtractMethodSelectionValidation.cs index b24a9e495e..8ff0885b28 100644 --- a/RetailCoder.VBE/Refactorings/ExtractMethod/ExtractMethodSelectionValidation.cs +++ b/Rubberduck.Core/Refactorings/ExtractMethod/ExtractMethodSelectionValidation.cs @@ -65,7 +65,6 @@ public bool withinSingleProcedure(QualifiedSelection qualifiedSelection) return (procEnd as Declaration).QualifiedSelection.Equals((procStart as Declaration).QualifiedSelection) && (procSignatureLastLine < startLine); - } } } diff --git a/RetailCoder.VBE/Refactorings/ExtractMethod/ExtractedMethod.cs b/Rubberduck.Core/Refactorings/ExtractMethod/ExtractedMethod.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/ExtractMethod/ExtractedMethod.cs rename to Rubberduck.Core/Refactorings/ExtractMethod/ExtractedMethod.cs diff --git a/RetailCoder.VBE/Refactorings/ExtractMethod/ExtractedParameter.cs b/Rubberduck.Core/Refactorings/ExtractMethod/ExtractedParameter.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/ExtractMethod/ExtractedParameter.cs rename to Rubberduck.Core/Refactorings/ExtractMethod/ExtractedParameter.cs diff --git a/RetailCoder.VBE/Refactorings/ExtractMethod/IExtractMethodDialog.cs b/Rubberduck.Core/Refactorings/ExtractMethod/IExtractMethodDialog.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/ExtractMethod/IExtractMethodDialog.cs rename to Rubberduck.Core/Refactorings/ExtractMethod/IExtractMethodDialog.cs diff --git a/RetailCoder.VBE/Refactorings/ExtractMethod/IExtractMethodExtraction.cs b/Rubberduck.Core/Refactorings/ExtractMethod/IExtractMethodExtraction.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/ExtractMethod/IExtractMethodExtraction.cs rename to Rubberduck.Core/Refactorings/ExtractMethod/IExtractMethodExtraction.cs diff --git a/RetailCoder.VBE/Refactorings/ExtractMethod/IExtractMethodModel.cs b/Rubberduck.Core/Refactorings/ExtractMethod/IExtractMethodModel.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/ExtractMethod/IExtractMethodModel.cs rename to Rubberduck.Core/Refactorings/ExtractMethod/IExtractMethodModel.cs diff --git a/RetailCoder.VBE/Refactorings/ExtractMethod/IExtractMethodParameterClassification.cs b/Rubberduck.Core/Refactorings/ExtractMethod/IExtractMethodParameterClassification.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/ExtractMethod/IExtractMethodParameterClassification.cs rename to Rubberduck.Core/Refactorings/ExtractMethod/IExtractMethodParameterClassification.cs diff --git a/RetailCoder.VBE/Refactorings/ExtractMethod/IExtractMethodProc.cs b/Rubberduck.Core/Refactorings/ExtractMethod/IExtractMethodProc.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/ExtractMethod/IExtractMethodProc.cs rename to Rubberduck.Core/Refactorings/ExtractMethod/IExtractMethodProc.cs diff --git a/RetailCoder.VBE/Refactorings/ExtractMethod/IExtractMethodRule.cs b/Rubberduck.Core/Refactorings/ExtractMethod/IExtractMethodRule.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/ExtractMethod/IExtractMethodRule.cs rename to Rubberduck.Core/Refactorings/ExtractMethod/IExtractMethodRule.cs diff --git a/RetailCoder.VBE/Refactorings/ExtractMethod/IExtractMethodSelectionValidation.cs b/Rubberduck.Core/Refactorings/ExtractMethod/IExtractMethodSelectionValidation.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/ExtractMethod/IExtractMethodSelectionValidation.cs rename to Rubberduck.Core/Refactorings/ExtractMethod/IExtractMethodSelectionValidation.cs diff --git a/RetailCoder.VBE/Refactorings/ExtractMethod/IExtractedMethod.cs b/Rubberduck.Core/Refactorings/ExtractMethod/IExtractedMethod.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/ExtractMethod/IExtractedMethod.cs rename to Rubberduck.Core/Refactorings/ExtractMethod/IExtractedMethod.cs diff --git a/RetailCoder.VBE/Refactorings/IRefactoring.cs b/Rubberduck.Core/Refactorings/IRefactoring.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/IRefactoring.cs rename to Rubberduck.Core/Refactorings/IRefactoring.cs diff --git a/RetailCoder.VBE/Refactorings/IRefactoringPresenterFactory.cs b/Rubberduck.Core/Refactorings/IRefactoringPresenterFactory.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/IRefactoringPresenterFactory.cs rename to Rubberduck.Core/Refactorings/IRefactoringPresenterFactory.cs diff --git a/RetailCoder.VBE/Refactorings/ImplementInterface/ImplementInterfaceRefactoring.cs b/Rubberduck.Core/Refactorings/ImplementInterface/ImplementInterfaceRefactoring.cs similarity index 87% rename from RetailCoder.VBE/Refactorings/ImplementInterface/ImplementInterfaceRefactoring.cs rename to Rubberduck.Core/Refactorings/ImplementInterface/ImplementInterfaceRefactoring.cs index 5b03dac1e9..d5346d1e46 100644 --- a/RetailCoder.VBE/Refactorings/ImplementInterface/ImplementInterfaceRefactoring.cs +++ b/Rubberduck.Core/Refactorings/ImplementInterface/ImplementInterfaceRefactoring.cs @@ -34,19 +34,25 @@ public ImplementInterfaceRefactoring(IVBE vbe, RubberduckParserState state, IMes public void Refactor() { - if (_vbe.ActiveCodePane == null) + QualifiedSelection? qualifiedSelection; + using (var activePane = _vbe.ActiveCodePane) { - _messageBox.Show(RubberduckUI.ImplementInterface_InvalidSelectionMessage, RubberduckUI.ImplementInterface_Caption, - System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); - return; - } - - var qualifiedSelection = _vbe.ActiveCodePane.GetQualifiedSelection(); - if (!qualifiedSelection.HasValue) - { - _messageBox.Show(RubberduckUI.ImplementInterface_InvalidSelectionMessage, RubberduckUI.ImplementInterface_Caption, - System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); - return; + if (activePane == null || activePane.IsWrappingNullReference) + { + _messageBox.Show(RubberduckUI.ImplementInterface_InvalidSelectionMessage, + RubberduckUI.ImplementInterface_Caption, + System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); + return; + } + + qualifiedSelection = activePane.GetQualifiedSelection(); + if (!qualifiedSelection.HasValue) + { + _messageBox.Show(RubberduckUI.ImplementInterface_InvalidSelectionMessage, + RubberduckUI.ImplementInterface_Caption, + System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); + return; + } } Refactor(qualifiedSelection.Value); @@ -74,19 +80,19 @@ public void Refactor(QualifiedSelection selection) return; } - QualifiedSelection? oldSelection = null; - if (_vbe.ActiveCodePane != null) - { - oldSelection = _vbe.ActiveCodePane.CodeModule.GetQualifiedSelection(); - } + var oldSelection = _vbe.GetActiveSelection(); ImplementMissingMembers(_state.GetRewriter(_targetClass)); if (oldSelection.HasValue) { - var module = oldSelection.Value.QualifiedName.Component.CodeModule; - var pane = module.CodePane; - pane.Selection = oldSelection.Value.Selection; + using (var module = _state.ProjectsProvider.Component(oldSelection.Value.QualifiedName).CodeModule) + { + using (var pane = module.CodePane) + { + pane.Selection = oldSelection.Value.Selection; + } + } } _state.OnParseRequested(this); diff --git a/RetailCoder.VBE/Refactorings/ImplementInterface/Parameter.cs b/Rubberduck.Core/Refactorings/ImplementInterface/Parameter.cs similarity index 81% rename from RetailCoder.VBE/Refactorings/ImplementInterface/Parameter.cs rename to Rubberduck.Core/Refactorings/ImplementInterface/Parameter.cs index 593ff26a37..a218a4ae4d 100644 --- a/RetailCoder.VBE/Refactorings/ImplementInterface/Parameter.cs +++ b/Rubberduck.Core/Refactorings/ImplementInterface/Parameter.cs @@ -8,7 +8,7 @@ public class Parameter public override string ToString() { - return Accessibility + " " + Name + " As " + AsTypeName; + return $"{Accessibility} {Name} As {AsTypeName}"; } } } diff --git a/RetailCoder.VBE/Refactorings/IntroduceField/IntroduceFieldRefactoring.cs b/Rubberduck.Core/Refactorings/IntroduceField/IntroduceFieldRefactoring.cs similarity index 88% rename from RetailCoder.VBE/Refactorings/IntroduceField/IntroduceFieldRefactoring.cs rename to Rubberduck.Core/Refactorings/IntroduceField/IntroduceFieldRefactoring.cs index f254bf59ff..abd9b8c34e 100644 --- a/RetailCoder.VBE/Refactorings/IntroduceField/IntroduceFieldRefactoring.cs +++ b/Rubberduck.Core/Refactorings/IntroduceField/IntroduceFieldRefactoring.cs @@ -33,7 +33,7 @@ public IntroduceFieldRefactoring(IVBE vbe, RubberduckParserState state, IMessage public void Refactor() { - var selection = _vbe.ActiveCodePane.GetQualifiedSelection(); + var selection = _vbe.GetActiveSelection(); if (!selection.HasValue) { @@ -78,21 +78,19 @@ private void PromoteVariable(IModuleRewriter rewriter, Declaration target) return; } - QualifiedSelection? oldSelection = null; - if (_vbe.ActiveCodePane != null) - { - oldSelection = _vbe.ActiveCodePane.CodeModule.GetQualifiedSelection(); - } + var oldSelection = _vbe.GetActiveSelection(); rewriter.Remove(target); AddField(rewriter, target); if (oldSelection.HasValue) { - var module = oldSelection.Value.QualifiedName.Component.CodeModule; - var pane = module.CodePane; + using (var module = _state.ProjectsProvider.Component(oldSelection.Value.QualifiedName).CodeModule) { - pane.Selection = oldSelection.Value.Selection; + using (var pane = module.CodePane) + { + pane.Selection = oldSelection.Value.Selection; + } } } diff --git a/RetailCoder.VBE/Refactorings/IntroduceParameter/IntroduceParameterRefactoring.cs b/Rubberduck.Core/Refactorings/IntroduceParameter/IntroduceParameterRefactoring.cs similarity index 88% rename from RetailCoder.VBE/Refactorings/IntroduceParameter/IntroduceParameterRefactoring.cs rename to Rubberduck.Core/Refactorings/IntroduceParameter/IntroduceParameterRefactoring.cs index 5c6f10df40..50cd41c875 100644 --- a/RetailCoder.VBE/Refactorings/IntroduceParameter/IntroduceParameterRefactoring.cs +++ b/Rubberduck.Core/Refactorings/IntroduceParameter/IntroduceParameterRefactoring.cs @@ -40,19 +40,17 @@ public IntroduceParameterRefactoring(IVBE vbe, RubberduckParserState state, IMes public void Refactor() { - var pane = _vbe.ActiveCodePane; - var module = pane.CodeModule; + var selection = _vbe.GetActiveSelection(); + + if (!selection.HasValue) { - var selection = module.GetQualifiedSelection(); - if (!selection.HasValue) - { - _messageBox.Show(RubberduckUI.PromoteVariable_InvalidSelection, RubberduckUI.IntroduceParameter_Caption, - MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - return; - } - - Refactor(selection.Value); + _messageBox.Show(RubberduckUI.PromoteVariable_InvalidSelection, RubberduckUI.IntroduceParameter_Caption, + MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; } + + Refactor(selection.Value); + } public void Refactor(QualifiedSelection selection) @@ -99,20 +97,21 @@ private void PromoteVariable(Declaration target) var rewriter = _state.GetRewriter(target); _rewriters.Add(rewriter); - QualifiedSelection? oldSelection = null; - var pane = _vbe.ActiveCodePane; - var module = pane.CodeModule; - if (_vbe.ActiveCodePane != null) + using (var pane = _vbe.ActiveCodePane) { - oldSelection = module.GetQualifiedSelection(); - } + QualifiedSelection? oldSelection = null; + if (pane != null && !pane.IsWrappingNullReference) + { + oldSelection = pane.GetQualifiedSelection(); + } - UpdateSignature(target); - rewriter.Remove(target); + UpdateSignature(target); + rewriter.Remove(target); - if (oldSelection.HasValue) - { - pane.Selection = oldSelection.Value.Selection; + if (oldSelection.HasValue && !pane.IsWrappingNullReference) + { + pane.Selection = oldSelection.Value.Selection; + } } foreach (var tokenRewriter in _rewriters) @@ -178,7 +177,7 @@ private void UpdateSignature(Declaration targetVariable) .Where(item => item.ProjectId == interfaceImplementation.ProjectId && item.IdentifierName == - interfaceImplementation.ComponentName + "_" + interfaceImplementation.IdentifierName + $"{interfaceImplementation.ComponentName}_{interfaceImplementation.IdentifierName}" && !item.Equals(functionDeclaration)); foreach (var implementation in interfaceImplementations) @@ -200,7 +199,7 @@ private void AddParameter(Declaration targetMethod, Declaration targetVariable, _rewriters.Add(rewriter); var argList = paramList.arg(); - var newParameter = Tokens.ByVal + " " + targetVariable.IdentifierName + " "+ Tokens.As + " " + targetVariable.AsTypeName; + var newParameter = $"{Tokens.ByVal} {targetVariable.IdentifierName} {Tokens.As} {targetVariable.AsTypeName}"; if (!argList.Any()) { diff --git a/RetailCoder.VBE/Refactorings/MoveCloserToUsage/MoveCloserToUsageRefactoring.cs b/Rubberduck.Core/Refactorings/MoveCloserToUsage/MoveCloserToUsageRefactoring.cs similarity index 76% rename from RetailCoder.VBE/Refactorings/MoveCloserToUsage/MoveCloserToUsageRefactoring.cs rename to Rubberduck.Core/Refactorings/MoveCloserToUsage/MoveCloserToUsageRefactoring.cs index 9eaa9d587b..199d5da13d 100644 --- a/RetailCoder.VBE/Refactorings/MoveCloserToUsage/MoveCloserToUsageRefactoring.cs +++ b/Rubberduck.Core/Refactorings/MoveCloserToUsage/MoveCloserToUsageRefactoring.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Windows.Forms; using Antlr4.Runtime; +using Antlr4.Runtime.Misc; using Rubberduck.Common; using Rubberduck.Parsing.Grammar; using Rubberduck.Parsing.Rewriter; @@ -34,7 +35,8 @@ public MoveCloserToUsageRefactoring(IVBE vbe, RubberduckParserState state, IMess public void Refactor() { - var qualifiedSelection = _vbe.ActiveCodePane.CodeModule.GetQualifiedSelection(); + var qualifiedSelection = _vbe.GetActiveSelection(); + if (qualifiedSelection != null) { Refactor(_declarations.FindVariable(qualifiedSelection.Value)); @@ -103,22 +105,22 @@ private void MoveCloserToUsage() } QualifiedSelection? oldSelection = null; - var pane = _vbe.ActiveCodePane; - var module = pane.CodeModule; - if (!module.IsWrappingNullReference) + using (var pane = _vbe.ActiveCodePane) { - oldSelection = module.GetQualifiedSelection(); - } - - InsertNewDeclaration(); - RemoveOldDeclaration(); - UpdateOtherModules(); + if (!pane.IsWrappingNullReference) + { + oldSelection = pane.GetQualifiedSelection(); + } - if (oldSelection.HasValue) - { - pane.Selection = oldSelection.Value.Selection; - } + InsertNewDeclaration(); + RemoveOldDeclaration(); + UpdateOtherModules(); + if (oldSelection.HasValue && !pane.IsWrappingNullReference) + { + pane.Selection = oldSelection.Value.Selection; + } + } foreach (var rewriter in _rewriters) { rewriter.Rewrite(); @@ -128,27 +130,28 @@ private void MoveCloserToUsage() private void UpdateOtherModules() { QualifiedSelection? oldSelection = null; - var pane = _vbe.ActiveCodePane; - var module = pane.CodeModule; - if (!module.IsWrappingNullReference) + using (var pane = _vbe.ActiveCodePane) { - oldSelection = module.GetQualifiedSelection(); - } + if (!pane.IsWrappingNullReference) + { + oldSelection = pane.GetQualifiedSelection(); + } - var newTarget = _state.DeclarationFinder.MatchName(_target.IdentifierName).FirstOrDefault( - item => item.ComponentName == _target.ComponentName && - item.ParentScope == _target.ParentScope && - item.ProjectId == _target.ProjectId && - Equals(item.Selection, _target.Selection)); + var newTarget = _state.DeclarationFinder.MatchName(_target.IdentifierName).FirstOrDefault( + item => item.ComponentName == _target.ComponentName && + item.ParentScope == _target.ParentScope && + item.ProjectId == _target.ProjectId && + Equals(item.Selection, _target.Selection)); - if (newTarget != null) - { - UpdateCallsToOtherModule(newTarget.References.ToList()); - } + if (newTarget != null) + { + UpdateCallsToOtherModule(newTarget.References.ToList()); + } - if (oldSelection.HasValue) - { - pane.Selection = oldSelection.Value.Selection; + if (oldSelection.HasValue) + { + pane.Selection = oldSelection.Value.Selection; + } } } @@ -180,7 +183,7 @@ private void RemoveOldDeclaration() _rewriters.Add(rewriter); } - private void UpdateCallsToOtherModule(List references) + private void UpdateCallsToOtherModule(IEnumerable references) { foreach (var reference in references.OrderByDescending(o => o.Selection.StartLine).ThenByDescending(t => t.Selection.StartColumn)) { @@ -196,7 +199,8 @@ private void UpdateCallsToOtherModule(List references) } var rewriter = _state.GetRewriter(reference.QualifiedModuleName); - rewriter.Replace(parent as ParserRuleContext, reference.IdentifierName); + var tokenInterval = Interval.Of(parent.SourceInterval.a, reference.Context.SourceInterval.b); + rewriter.Replace(tokenInterval, reference.IdentifierName); _rewriters.Add(rewriter); } diff --git a/RetailCoder.VBE/Refactorings/RemoveParameters/Parameter.cs b/Rubberduck.Core/Refactorings/RemoveParameters/Parameter.cs similarity index 96% rename from RetailCoder.VBE/Refactorings/RemoveParameters/Parameter.cs rename to Rubberduck.Core/Refactorings/RemoveParameters/Parameter.cs index 5bd80a0c72..a4a8d04f87 100644 --- a/RetailCoder.VBE/Refactorings/RemoveParameters/Parameter.cs +++ b/Rubberduck.Core/Refactorings/RemoveParameters/Parameter.cs @@ -16,7 +16,7 @@ public class Parameter : ViewModelBase private bool _isRemoved; public bool IsRemoved { - get { return _isRemoved; } + get => _isRemoved; set { _isRemoved = value; diff --git a/RetailCoder.VBE/Refactorings/RemoveParameters/RemoveParametersModel.cs b/Rubberduck.Core/Refactorings/RemoveParameters/RemoveParametersModel.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/RemoveParameters/RemoveParametersModel.cs rename to Rubberduck.Core/Refactorings/RemoveParameters/RemoveParametersModel.cs diff --git a/RetailCoder.VBE/Refactorings/RemoveParameters/RemoveParametersPresenter.cs b/Rubberduck.Core/Refactorings/RemoveParameters/RemoveParametersPresenter.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/RemoveParameters/RemoveParametersPresenter.cs rename to Rubberduck.Core/Refactorings/RemoveParameters/RemoveParametersPresenter.cs diff --git a/RetailCoder.VBE/Refactorings/RemoveParameters/RemoveParametersPresenterFactory.cs b/Rubberduck.Core/Refactorings/RemoveParameters/RemoveParametersPresenterFactory.cs similarity index 84% rename from RetailCoder.VBE/Refactorings/RemoveParameters/RemoveParametersPresenterFactory.cs rename to Rubberduck.Core/Refactorings/RemoveParameters/RemoveParametersPresenterFactory.cs index 10a1578d92..6767fe0e60 100644 --- a/RetailCoder.VBE/Refactorings/RemoveParameters/RemoveParametersPresenterFactory.cs +++ b/Rubberduck.Core/Refactorings/RemoveParameters/RemoveParametersPresenterFactory.cs @@ -24,13 +24,8 @@ public RemoveParametersPresenterFactory(IVBE vbe, IRefactoringDialog references, Decla { foreach (var reference in references.Where(item => item.Context != method.Context)) { - var module = reference.QualifiedModuleName.Component.CodeModule; VBAParser.ArgumentListContext argumentList = null; - var callStmt = ParserRuleContextHelper.GetParent(reference.Context); + var callStmt = reference.Context.GetAncestor(); if (callStmt != null) { argumentList = CallStatement.GetArgumentList(callStmt); @@ -127,10 +127,20 @@ private void AdjustReferences(IEnumerable references, Decla if (argumentList == null) { var indexExpression = - ParserRuleContextHelper.GetParent(reference.Context); + reference.Context.GetAncestor(); if (indexExpression != null) { - argumentList = ParserRuleContextHelper.GetChild(indexExpression); + argumentList = indexExpression.GetChild(); + } + } + + if (argumentList == null) + { + var whitespaceIndexExpression = + reference.Context.GetAncestor(); + if (whitespaceIndexExpression != null) + { + argumentList = whitespaceIndexExpression.GetChild(); } } @@ -139,13 +149,14 @@ private void AdjustReferences(IEnumerable references, Decla continue; } - RemoveCallArguments(argumentList, module); + RemoveCallArguments(argumentList, reference.QualifiedModuleName); } } - private void RemoveCallArguments(VBAParser.ArgumentListContext argList, ICodeModule module) + private void RemoveCallArguments(VBAParser.ArgumentListContext argList, QualifiedModuleName module) { - var rewriter = _model.State.GetRewriter(module.Parent); + var rewriter = _model.State.GetRewriter(module); + _rewriters.Add(rewriter); var args = argList.children.OfType().ToList(); for (var i = 0; i < _model.Parameters.Count; i++) @@ -157,6 +168,8 @@ private void RemoveCallArguments(VBAParser.ArgumentListContext argList, ICodeMod if (_model.Parameters[i].IsParamArray) { + //The following code works because it is neither allowed to use both named arguments + //and a ParamArray nor optional arguments and a ParamArray. var index = i == 0 ? 0 : argList.children.IndexOf(args[i - 1]) + 1; for (var j = index; j < argList.children.Count; j++) { @@ -165,7 +178,7 @@ private void RemoveCallArguments(VBAParser.ArgumentListContext argList, ICodeMod break; } - if (args.Count > i && args[i].positionalArgument() != null) + if (args.Count > i && (args[i].positionalArgument() != null || args[i].missingArgument() != null)) { rewriter.Remove(args[i]); } @@ -219,8 +232,7 @@ private void AdjustSignatures() var interfaceImplementations = _model.Declarations.FindInterfaceImplementationMembers().Where(item => item.ProjectId == _model.TargetDeclaration.ProjectId && - item.IdentifierName == - _model.TargetDeclaration.ComponentName + "_" + _model.TargetDeclaration.IdentifierName); + item.IdentifierName == $"{_model.TargetDeclaration.ComponentName}_{_model.TargetDeclaration.IdentifierName}"); foreach (var interfaceImplentation in interfaceImplementations) { diff --git a/RetailCoder.VBE/Refactorings/Rename/RenameModel.cs b/Rubberduck.Core/Refactorings/Rename/RenameModel.cs similarity index 94% rename from RetailCoder.VBE/Refactorings/Rename/RenameModel.cs rename to Rubberduck.Core/Refactorings/Rename/RenameModel.cs index 9c9bdb2ac1..49af12547e 100644 --- a/RetailCoder.VBE/Refactorings/Rename/RenameModel.cs +++ b/Rubberduck.Core/Refactorings/Rename/RenameModel.cs @@ -17,8 +17,8 @@ public class RenameModel private Declaration _target; public Declaration Target { - get { return _target; } - set { _target = value; } + get => _target; + set => _target = value; } public QualifiedSelection Selection { get; } diff --git a/RetailCoder.VBE/Refactorings/Rename/RenamePresenter.cs b/Rubberduck.Core/Refactorings/Rename/RenamePresenter.cs similarity index 71% rename from RetailCoder.VBE/Refactorings/Rename/RenamePresenter.cs rename to Rubberduck.Core/Refactorings/Rename/RenamePresenter.cs index ea1b5d9886..e64b015fb4 100644 --- a/RetailCoder.VBE/Refactorings/Rename/RenamePresenter.cs +++ b/Rubberduck.Core/Refactorings/Rename/RenamePresenter.cs @@ -15,39 +15,40 @@ public interface IRenamePresenter public class RenamePresenter : IRenamePresenter { private readonly IRefactoringDialog _view; - private readonly RenameModel _model; public RenamePresenter(IRefactoringDialog view, RenameModel model) { _view = view; - _model = model; + Model = model; } - public RenameModel Model => _model; + public RenameModel Model { get; } public RenameModel Show() { - if (_model.Target == null) { return null; } - - return Show(_model.Target); + return Model.Target == null ? null : Show(Model.Target); } public RenameModel Show(Declaration target) { - if(null == target) { return null; } + if (null == target) + { + return null; + } - _model.Target = target; + Model.Target = target; _view.ViewModel.Target = target; _view.ShowDialog(); + if (_view.DialogResult != DialogResult.OK) { return null; } - _model.NewName = _view.ViewModel.NewName; - return _model; + Model.NewName = _view.ViewModel.NewName; + return Model; } } } diff --git a/RetailCoder.VBE/Refactorings/Rename/RenamePresenterFactory.cs b/Rubberduck.Core/Refactorings/Rename/RenamePresenterFactory.cs similarity index 75% rename from RetailCoder.VBE/Refactorings/Rename/RenamePresenterFactory.cs rename to Rubberduck.Core/Refactorings/Rename/RenamePresenterFactory.cs index a1bfc234c8..d5f88fda6b 100644 --- a/RetailCoder.VBE/Refactorings/Rename/RenamePresenterFactory.cs +++ b/Rubberduck.Core/Refactorings/Rename/RenamePresenterFactory.cs @@ -21,11 +21,8 @@ public RenamePresenterFactory(IVBE vbe, IRefactoringDialog view public RenamePresenter Create() { - var codePane = _vbe.ActiveCodePane; - var qualifiedSelection = codePane.IsWrappingNullReference - ? new QualifiedSelection() - : new QualifiedSelection(new QualifiedModuleName(codePane.CodeModule.Parent), codePane.Selection); - + var activeSelection = _vbe.GetActiveSelection(); + var qualifiedSelection = activeSelection.HasValue ? activeSelection.Value : new QualifiedSelection(); return new RenamePresenter(_view, new RenameModel(_vbe, _state, qualifiedSelection)); } } diff --git a/RetailCoder.VBE/Refactorings/Rename/RenameRefactoring.cs b/Rubberduck.Core/Refactorings/Rename/RenameRefactoring.cs similarity index 82% rename from RetailCoder.VBE/Refactorings/Rename/RenameRefactoring.cs rename to Rubberduck.Core/Refactorings/Rename/RenameRefactoring.cs index c859ab826d..f42e559678 100644 --- a/RetailCoder.VBE/Refactorings/Rename/RenameRefactoring.cs +++ b/Rubberduck.Core/Refactorings/Rename/RenameRefactoring.cs @@ -1,5 +1,6 @@ using System.Linq; using System.Windows.Forms; +using Rubberduck.Parsing; using Rubberduck.Parsing.Symbols; using Rubberduck.Parsing.VBA; using Rubberduck.UI; @@ -26,9 +27,9 @@ public class RenameRefactoring : IRefactoring private readonly RubberduckParserState _state; private RenameModel _model; private Tuple _initialSelection; - private List _modulesToRewrite; - private Dictionary _renameActions; - private List _neverRenameIdentifiers; + private readonly List _modulesToRewrite; + private readonly Dictionary _renameActions; + private readonly List _neverRenameIdentifiers; private bool IsInterfaceMemberRename { set; get; } private bool IsControlEventHandlerRename { set; get; } @@ -42,16 +43,17 @@ public RenameRefactoring(IVBE vbe, IRefactoringPresenterFactory(_vbe.ActiveCodePane, _vbe.ActiveCodePane.IsWrappingNullReference ? Selection.Empty : _vbe.ActiveCodePane.Selection); + var activeCodePane = _vbe.ActiveCodePane; + _initialSelection = new Tuple(activeCodePane, activeCodePane.IsWrappingNullReference ? Selection.Empty : activeCodePane.Selection); _modulesToRewrite = new List(); _renameActions = new Dictionary { - {DeclarationType.Member, new Action(RenameMember)}, - {DeclarationType.Parameter, new Action(RenameParameter)}, - {DeclarationType.Event, new Action(RenameEvent)}, - {DeclarationType.Variable, new Action(RenameVariable)}, - {DeclarationType.Module, new Action(RenameModule)}, - {DeclarationType.Project, new Action(RenameProject)} + {DeclarationType.Member, RenameMember}, + {DeclarationType.Parameter, RenameParameter}, + {DeclarationType.Event, RenameEvent}, + {DeclarationType.Variable, RenameVariable}, + {DeclarationType.Module, RenameModule}, + {DeclarationType.Project, RenameProject} }; IsInterfaceMemberRename = false; RequestParseAfterRename = true; @@ -88,7 +90,10 @@ private void RefactorImpl(Declaration inputTarget, IRenamePresenter presenter) { try { - if (!TrySetRenameTargetFromInputTarget(inputTarget)) { return; } + if (!TrySetRenameTargetFromInputTarget(inputTarget)) + { + return; + } if (TrySetNewName(presenter)) { @@ -157,16 +162,19 @@ private bool TrySetRenameTargetFromInputTarget(Declaration inputTarget) var message = string.Format(RubberduckUI.RenamePresenter_TargetIsControlEventHandler, inputTarget.IdentifierName, _model.Target.DeclarationType, _model.Target.IdentifierName); return UserConfirmsRenameOfResolvedTarget(message); } - else if (IsUserEventHandlerRename) + + if (IsUserEventHandlerRename) { var message = string.Format(RubberduckUI.RenamePresenter_TargetIsEventHandlerImplementation, inputTarget.IdentifierName, _model.Target.DeclarationType, _model.Target.IdentifierName); return UserConfirmsRenameOfResolvedTarget(message); } - else if (IsInterfaceMemberRename) + + if (IsInterfaceMemberRename) { var message = string.Format(RubberduckUI.RenamePresenter_TargetIsInterfaceMemberImplementation, inputTarget.IdentifierName, _model.Target.ComponentName, _model.Target.IdentifierName); return UserConfirmsRenameOfResolvedTarget(message); } + Debug.Assert(false, $"Resolved rename target ({_model.Target.Scope}) unhandled"); } return true; @@ -175,7 +183,7 @@ private bool TrySetRenameTargetFromInputTarget(Declaration inputTarget) private bool UserConfirmsRenameOfResolvedTarget(string message) { var confirm = _messageBox?.Show(message, RubberduckUI.RenameDialog_TitleText, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); - return confirm.HasValue ? confirm.Value == DialogResult.Yes : false; + return confirm.HasValue && confirm.Value == DialogResult.Yes; } private Declaration ResolveRenameTargetIfEventHandlerSelected(Declaration selectedTarget) @@ -204,21 +212,28 @@ private bool IsValidTarget(Declaration target) if (target.DeclarationType.HasFlag(DeclarationType.Control)) { - var module = target.QualifiedName.QualifiedModuleName.Component.CodeModule; - var control = module.Parent.Controls.Where(item => item.Name == target.IdentifierName).FirstOrDefault(); - if (control == null) + var component = _state.ProjectsProvider.Component(target.QualifiedName.QualifiedModuleName); + using (var controls = component.Controls) { - PresentRenameErrorMessage($"{BuildDefaultErrorMessage(target)} - Null control reference"); - return false; + using (var control = controls.FirstOrDefault(item => item.Name == target.IdentifierName)) + { + if (control == null) + { + PresentRenameErrorMessage($"{BuildDefaultErrorMessage(target)} - Null control reference"); + return false; + } + } } } else if (target.DeclarationType.HasFlag(DeclarationType.Module)) { - var module = target.QualifiedName.QualifiedModuleName.Component.CodeModule; - if (module.IsWrappingNullReference) + using (var module = _state.ProjectsProvider.Component(target.QualifiedName.QualifiedModuleName).CodeModule) { - PresentRenameErrorMessage($"{BuildDefaultErrorMessage(target)} - Null Module reference"); - return false; + if (module.IsWrappingNullReference) + { + PresentRenameErrorMessage($"{BuildDefaultErrorMessage(target)} - Null Module reference"); + return false; + } } } return true; @@ -240,7 +255,7 @@ private bool TrySetNewName(IRenamePresenter presenter) var rename = _messageBox?.Show(message, RubberduckUI.RenameDialog_Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); - return rename.HasValue ? rename.Value == DialogResult.Yes : false; + return rename.HasValue && rename.Value == DialogResult.Yes; } return true; @@ -249,7 +264,7 @@ private bool TrySetNewName(IRenamePresenter presenter) private Declaration ResolveEventHandlerToControl(Declaration userTarget) { var control = _state.DeclarationFinder.UserDeclarations(DeclarationType.Control) - .Where(ctrl => userTarget.Scope.StartsWith($"{ctrl.ParentScope}.{ctrl.IdentifierName}_")).FirstOrDefault(); + .FirstOrDefault(ctrl => userTarget.Scope.StartsWith($"{ctrl.ParentScope}.{ctrl.IdentifierName}_")); IsControlEventHandlerRename = control != null; @@ -271,9 +286,8 @@ private Declaration ResolveEventHandlerToUserEvent(Declaration userTarget) { var eventName = userTarget.IdentifierName.Remove(0, $"{withEvent.IdentifierName}_".Length); - var eventDeclaration = _state.DeclarationFinder.UserDeclarations(DeclarationType.Event) - .Where(ev => ev.IdentifierName.Equals(eventName) - && withEvent.AsTypeName.Equals(ev.ParentDeclaration.IdentifierName)).FirstOrDefault(); + var eventDeclaration = _state.DeclarationFinder.UserDeclarations(DeclarationType.Event).FirstOrDefault(ev => ev.IdentifierName.Equals(eventName) + && withEvent.AsTypeName.Equals(ev.ParentDeclaration.IdentifierName)); IsUserEventHandlerRename = eventDeclaration != null; @@ -376,13 +390,18 @@ private void RenameVariable() { if (_model.Target.DeclarationType.HasFlag(DeclarationType.Control)) { - var module = _model.Target.QualifiedName.QualifiedModuleName.Component.CodeModule; - var control = module.Parent.Controls.SingleOrDefault(item => item.Name == _model.Target.IdentifierName); - Debug.Assert(control != null, $"input validation fail: unable to locate '{_model.Target.IdentifierName}' in Controls collection"); + var component = _state.ProjectsProvider.Component(_model.Target.QualifiedName.QualifiedModuleName); + using (var controls = component.Controls) + { + using (var control = controls.SingleOrDefault(item => item.Name == _model.Target.IdentifierName)) + { + Debug.Assert(control != null, + $"input validation fail: unable to locate '{_model.Target.IdentifierName}' in Controls collection"); - control.Name = _model.NewName; + control.Name = _model.NewName; + } + } RenameReferences(_model.Target, _model.NewName); - var controlEventHandlers = FindEventHandlersForControl(_model.Target); RenameDefinedFormatMembers(controlEventHandlers, _appendUnderscoreFormat); } @@ -407,7 +426,7 @@ private void RenameModule() { foreach (var reference in _model.Target.References) { - var ctxt = ParserRuleContextHelper.GetParent(reference.Context); + var ctxt = reference.Context.GetAncestor(); if (ctxt != null) { RenameDefinedFormatMembers(_state.DeclarationFinder.FindInterfaceMembersForImplementsContext(ctxt), _appendUnderscoreFormat); @@ -415,7 +434,7 @@ private void RenameModule() } } - var component = _model.Target.QualifiedName.QualifiedModuleName.Component; + var component = _state.ProjectsProvider.Component(_model.Target.QualifiedName.QualifiedModuleName); if (component.Type == ComponentType.Document) { var properties = component.Properties; @@ -438,23 +457,42 @@ private void RenameModule() } else { - Debug.Assert(!component.CodeModule.IsWrappingNullReference, "input validation fail: Attempting to rename an ICodeModule wrapping a null reference"); - component.CodeModule.Name = _model.NewName; + using (var codeModule = component.CodeModule) + { + Debug.Assert(!codeModule.IsWrappingNullReference, "input validation fail: Attempting to rename an ICodeModule wrapping a null reference"); + codeModule.Name = _model.NewName; + } } } private void RenameProject() { RequestParseAfterRename = false; - var projects = _model.VBE.VBProjects; - var project = projects.SingleOrDefault(p => p.ProjectId == _model.Target.ProjectId); + var project = ProjectById(_vbe, _model.Target.ProjectId); if (project != null) { project.Name = _model.NewName; + project.Dispose(); } } + private IVBProject ProjectById(IVBE vbe, string projectId) + { + using (var projects = vbe.VBProjects) + { + foreach (var project in projects) + { + if (project.ProjectId == projectId) + { + return project; + } + project.Dispose(); + } + } + return null; + } + private void RenameDefinedFormatMembers(IEnumerable members, string underscoreFormat) { if (!members.Any()) { return; } @@ -495,8 +533,7 @@ private void RenameDeclaration(Declaration target, string newName) _modulesToRewrite.Add(target.QualifiedName.QualifiedModuleName); var rewriter = _state.GetRewriter(target.QualifiedName.QualifiedModuleName); - var context = target.Context as IIdentifierContext; - if (null != context) + if (target.Context is IIdentifierContext context) { rewriter.Replace(context.IdentifierTokens, newName); } @@ -530,9 +567,15 @@ private IEnumerable FindEventHandlersForControl(Declaration control private void CacheInitialSelection(QualifiedSelection qSelection) { - if (!qSelection.QualifiedName.Component.CodeModule.CodePane.IsWrappingNullReference) + using (var codeModule = _state.ProjectsProvider.Component(qSelection.QualifiedName).CodeModule) { - _initialSelection = new Tuple(qSelection.QualifiedName.Component.CodeModule.CodePane, qSelection.QualifiedName.Component.CodeModule.CodePane.Selection); + using (var codePane = codeModule.CodePane) + { + if (!codePane.IsWrappingNullReference) + { + _initialSelection = new Tuple(codePane, codePane.Selection); + } + } } } diff --git a/RetailCoder.VBE/Refactorings/ReorderParameters/Parameter.cs b/Rubberduck.Core/Refactorings/ReorderParameters/Parameter.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/ReorderParameters/Parameter.cs rename to Rubberduck.Core/Refactorings/ReorderParameters/Parameter.cs diff --git a/RetailCoder.VBE/Refactorings/ReorderParameters/ReorderParametersModel.cs b/Rubberduck.Core/Refactorings/ReorderParameters/ReorderParametersModel.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/ReorderParameters/ReorderParametersModel.cs rename to Rubberduck.Core/Refactorings/ReorderParameters/ReorderParametersModel.cs diff --git a/RetailCoder.VBE/Refactorings/ReorderParameters/ReorderParametersPresenter.cs b/Rubberduck.Core/Refactorings/ReorderParameters/ReorderParametersPresenter.cs similarity index 100% rename from RetailCoder.VBE/Refactorings/ReorderParameters/ReorderParametersPresenter.cs rename to Rubberduck.Core/Refactorings/ReorderParameters/ReorderParametersPresenter.cs diff --git a/RetailCoder.VBE/Refactorings/ReorderParameters/ReorderParametersPresenterFactory.cs b/Rubberduck.Core/Refactorings/ReorderParameters/ReorderParametersPresenterFactory.cs similarity index 84% rename from RetailCoder.VBE/Refactorings/ReorderParameters/ReorderParametersPresenterFactory.cs rename to Rubberduck.Core/Refactorings/ReorderParameters/ReorderParametersPresenterFactory.cs index 4b531460d1..06a60c5e6f 100644 --- a/RetailCoder.VBE/Refactorings/ReorderParameters/ReorderParametersPresenterFactory.cs +++ b/Rubberduck.Core/Refactorings/ReorderParameters/ReorderParametersPresenterFactory.cs @@ -24,14 +24,8 @@ public ReorderParametersPresenterFactory(IVBE vbe, IRefactoringDialog _rewriters = new HashSet(); + private readonly IProjectsProvider _projectsProvider; - public ReorderParametersRefactoring(IVBE vbe, IRefactoringPresenterFactory factory, IMessageBox messageBox) + public ReorderParametersRefactoring(IVBE vbe, IRefactoringPresenterFactory factory, IMessageBox messageBox, IProjectsProvider projectsProvider) { _vbe = vbe; _factory = factory; _messageBox = messageBox; + _projectsProvider = projectsProvider; } public void Refactor() @@ -41,22 +45,22 @@ public void Refactor() return; } - var pane = _vbe.ActiveCodePane; - if (!pane.IsWrappingNullReference) + using (var pane = _vbe.ActiveCodePane) { - QualifiedSelection? oldSelection; - var module = pane.CodeModule; + if (pane.IsWrappingNullReference) { - oldSelection = module.GetQualifiedSelection(); + return; } + var oldSelection = pane.GetQualifiedSelection(); + AdjustReferences(_model.TargetDeclaration.References); AdjustSignatures(); - if (oldSelection.HasValue) + if (oldSelection.HasValue && !pane.IsWrappingNullReference) { pane.Selection = oldSelection.Value.Selection; - } + } } foreach (var rewriter in _rewriters) @@ -69,11 +73,16 @@ public void Refactor() public void Refactor(QualifiedSelection target) { - var pane = _vbe.ActiveCodePane; + using (var pane = _vbe.ActiveCodePane) { + if (pane == null || pane.IsWrappingNullReference) + { + return; + } + pane.Selection = target.Selection; - Refactor(); } + Refactor(); } public void Refactor(Declaration target) @@ -83,11 +92,15 @@ public void Refactor(Declaration target) throw new ArgumentException("Invalid declaration type"); } - var pane = _vbe.ActiveCodePane; + using (var pane = _vbe.ActiveCodePane) { + if (pane == null || pane.IsWrappingNullReference) + { + return; + } pane.Selection = target.QualifiedSelection.Selection; - Refactor(); } + Refactor(); } private bool IsValidParamOrder() @@ -106,21 +119,21 @@ private bool IsValidParamOrder() } var indexOfParamArray = _model.Parameters.FindIndex(param => param.IsParamArray); - if (indexOfParamArray >= 0 && indexOfParamArray != _model.Parameters.Count - 1) + if (indexOfParamArray < 0 || indexOfParamArray == _model.Parameters.Count - 1) { - _messageBox.Show(RubberduckUI.ReorderPresenter_ParamArrayError, RubberduckUI.ReorderParamsDialog_TitleText, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - return false; + return true; } - return true; + + _messageBox.Show(RubberduckUI.ReorderPresenter_ParamArrayError, RubberduckUI.ReorderParamsDialog_TitleText, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return false; } private void AdjustReferences(IEnumerable references) { foreach (var reference in references.Where(item => item.Context != _model.TargetDeclaration.Context)) { - var module = reference.QualifiedModuleName.Component.CodeModule; VBAParser.ArgumentListContext argumentList = null; - var callStmt = ParserRuleContextHelper.GetParent(reference.Context); + var callStmt = reference.Context.GetAncestor(); if (callStmt != null) { argumentList = CallStatement.GetArgumentList(callStmt); @@ -128,15 +141,22 @@ private void AdjustReferences(IEnumerable references) if (argumentList == null) { - var indexExpression = ParserRuleContextHelper.GetParent(reference.Context); + var indexExpression = reference.Context.GetAncestor(); if (indexExpression != null) { - argumentList = ParserRuleContextHelper.GetChild(indexExpression); + argumentList = indexExpression.GetChild(); } } - if (argumentList == null) { continue; } - RewriteCall(argumentList, module); + if (argumentList == null) + { + continue; + } + + using (var module = _projectsProvider.Component(reference.QualifiedModuleName).CodeModule) + { + RewriteCall(argumentList, module); + } } } @@ -147,7 +167,7 @@ private void RewriteCall(VBAParser.ArgumentListContext argList, ICodeModule modu var args = argList.argument().Select((s, i) => new { Index = i, Text = s.GetText() }).ToList(); for (var i = 0; i < _model.Parameters.Count; i++) { - if (argList.argument().Count <= i) + if (argList.argument().Length <= i) { break; } diff --git a/RetailCoder.VBE/Resources/AboutBanner.png b/Rubberduck.Core/Resources/AboutBanner.png similarity index 100% rename from RetailCoder.VBE/Resources/AboutBanner.png rename to Rubberduck.Core/Resources/AboutBanner.png diff --git a/RetailCoder.VBE/Resources/Custom/Mask/AddPropertyMask.bmp b/Rubberduck.Core/Resources/Custom/Mask/AddPropertyMask.bmp similarity index 100% rename from RetailCoder.VBE/Resources/Custom/Mask/AddPropertyMask.bmp rename to Rubberduck.Core/Resources/Custom/Mask/AddPropertyMask.bmp diff --git a/RetailCoder.VBE/Resources/Custom/Mask/AddVariableMask.bmp b/Rubberduck.Core/Resources/Custom/Mask/AddVariableMask.bmp similarity index 100% rename from RetailCoder.VBE/Resources/Custom/Mask/AddVariableMask.bmp rename to Rubberduck.Core/Resources/Custom/Mask/AddVariableMask.bmp diff --git a/RetailCoder.VBE/Resources/Custom/Mask/AllLoadedTestsMask.bmp b/Rubberduck.Core/Resources/Custom/Mask/AllLoadedTestsMask.bmp similarity index 100% rename from RetailCoder.VBE/Resources/Custom/Mask/AllLoadedTestsMask.bmp rename to Rubberduck.Core/Resources/Custom/Mask/AllLoadedTestsMask.bmp diff --git a/RetailCoder.VBE/Resources/Custom/Mask/ExtractInterfaceMask.bmp b/Rubberduck.Core/Resources/Custom/Mask/ExtractInterfaceMask.bmp similarity index 100% rename from RetailCoder.VBE/Resources/Custom/Mask/ExtractInterfaceMask.bmp rename to Rubberduck.Core/Resources/Custom/Mask/ExtractInterfaceMask.bmp diff --git a/RetailCoder.VBE/Resources/Custom/Mask/ExtractMethodMask.bmp b/Rubberduck.Core/Resources/Custom/Mask/ExtractMethodMask.bmp similarity index 100% rename from RetailCoder.VBE/Resources/Custom/Mask/ExtractMethodMask.bmp rename to Rubberduck.Core/Resources/Custom/Mask/ExtractMethodMask.bmp diff --git a/RetailCoder.VBE/Resources/Custom/Mask/FindSymbolMask.bmp b/Rubberduck.Core/Resources/Custom/Mask/FindSymbolMask.bmp similarity index 100% rename from RetailCoder.VBE/Resources/Custom/Mask/FindSymbolMask.bmp rename to Rubberduck.Core/Resources/Custom/Mask/FindSymbolMask.bmp diff --git a/RetailCoder.VBE/Resources/Custom/Mask/ImplementInterfaceMask.bmp b/Rubberduck.Core/Resources/Custom/Mask/ImplementInterfaceMask.bmp similarity index 100% rename from RetailCoder.VBE/Resources/Custom/Mask/ImplementInterfaceMask.bmp rename to Rubberduck.Core/Resources/Custom/Mask/ImplementInterfaceMask.bmp diff --git a/RetailCoder.VBE/Resources/Custom/Mask/PromoteLocalMask.bmp b/Rubberduck.Core/Resources/Custom/Mask/PromoteLocalMask.bmp similarity index 100% rename from RetailCoder.VBE/Resources/Custom/Mask/PromoteLocalMask.bmp rename to Rubberduck.Core/Resources/Custom/Mask/PromoteLocalMask.bmp diff --git a/RetailCoder.VBE/Resources/Custom/Mask/RemoveParametersMask.bmp b/Rubberduck.Core/Resources/Custom/Mask/RemoveParametersMask.bmp similarity index 100% rename from RetailCoder.VBE/Resources/Custom/Mask/RemoveParametersMask.bmp rename to Rubberduck.Core/Resources/Custom/Mask/RemoveParametersMask.bmp diff --git a/RetailCoder.VBE/Resources/Custom/Mask/ReorderParametersMask.bmp b/Rubberduck.Core/Resources/Custom/Mask/ReorderParametersMask.bmp similarity index 100% rename from RetailCoder.VBE/Resources/Custom/Mask/ReorderParametersMask.bmp rename to Rubberduck.Core/Resources/Custom/Mask/ReorderParametersMask.bmp diff --git a/RetailCoder.VBE/Resources/Custom/Mask/TestManagerMask.bmp b/Rubberduck.Core/Resources/Custom/Mask/TestManagerMask.bmp similarity index 100% rename from RetailCoder.VBE/Resources/Custom/Mask/TestManagerMask.bmp rename to Rubberduck.Core/Resources/Custom/Mask/TestManagerMask.bmp diff --git a/RetailCoder.VBE/Resources/Custom/PNG/AddClass.png b/Rubberduck.Core/Resources/Custom/PNG/AddClass.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/AddClass.png rename to Rubberduck.Core/Resources/Custom/PNG/AddClass.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/AddEvent.png b/Rubberduck.Core/Resources/Custom/PNG/AddEvent.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/AddEvent.png rename to Rubberduck.Core/Resources/Custom/PNG/AddEvent.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/AddForm.png b/Rubberduck.Core/Resources/Custom/PNG/AddForm.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/AddForm.png rename to Rubberduck.Core/Resources/Custom/PNG/AddForm.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/AddMethod.png b/Rubberduck.Core/Resources/Custom/PNG/AddMethod.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/AddMethod.png rename to Rubberduck.Core/Resources/Custom/PNG/AddMethod.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/AddModule.png b/Rubberduck.Core/Resources/Custom/PNG/AddModule.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/AddModule.png rename to Rubberduck.Core/Resources/Custom/PNG/AddModule.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/AddProperty.png b/Rubberduck.Core/Resources/Custom/PNG/AddProperty.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/AddProperty.png rename to Rubberduck.Core/Resources/Custom/PNG/AddProperty.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/AddVariable.png b/Rubberduck.Core/Resources/Custom/PNG/AddVariable.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/AddVariable.png rename to Rubberduck.Core/Resources/Custom/PNG/AddVariable.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/AllLoadedTests.png b/Rubberduck.Core/Resources/Custom/PNG/AllLoadedTests.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/AllLoadedTests.png rename to Rubberduck.Core/Resources/Custom/PNG/AllLoadedTests.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ApplyCodeChanges.png b/Rubberduck.Core/Resources/Custom/PNG/ApplyCodeChanges.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ApplyCodeChanges.png rename to Rubberduck.Core/Resources/Custom/PNG/ApplyCodeChanges.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/CollapseDown.png b/Rubberduck.Core/Resources/Custom/PNG/CollapseDown.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/CollapseDown.png rename to Rubberduck.Core/Resources/Custom/PNG/CollapseDown.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/CollapseUp.png b/Rubberduck.Core/Resources/Custom/PNG/CollapseUp.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/CollapseUp.png rename to Rubberduck.Core/Resources/Custom/PNG/CollapseUp.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/DisplayFullSignature.png b/Rubberduck.Core/Resources/Custom/PNG/DisplayFullSignature.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/DisplayFullSignature.png rename to Rubberduck.Core/Resources/Custom/PNG/DisplayFullSignature.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/DisplayName.png b/Rubberduck.Core/Resources/Custom/PNG/DisplayName.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/DisplayName.png rename to Rubberduck.Core/Resources/Custom/PNG/DisplayName.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/Document.png b/Rubberduck.Core/Resources/Custom/PNG/Document.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/Document.png rename to Rubberduck.Core/Resources/Custom/PNG/Document.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ExportTestRunResults.png b/Rubberduck.Core/Resources/Custom/PNG/ExportTestRunResults.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ExportTestRunResults.png rename to Rubberduck.Core/Resources/Custom/PNG/ExportTestRunResults.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ExtractInterface.png b/Rubberduck.Core/Resources/Custom/PNG/ExtractInterface.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ExtractInterface.png rename to Rubberduck.Core/Resources/Custom/PNG/ExtractInterface.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ExtractMethod.png b/Rubberduck.Core/Resources/Custom/PNG/ExtractMethod.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ExtractMethod.png rename to Rubberduck.Core/Resources/Custom/PNG/ExtractMethod.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/FindSymbol.png b/Rubberduck.Core/Resources/Custom/PNG/FindSymbol.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/FindSymbol.png rename to Rubberduck.Core/Resources/Custom/PNG/FindSymbol.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/FolderClosed.png b/Rubberduck.Core/Resources/Custom/PNG/FolderClosed.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/FolderClosed.png rename to Rubberduck.Core/Resources/Custom/PNG/FolderClosed.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/FolderClosedHidden.png b/Rubberduck.Core/Resources/Custom/PNG/FolderClosedHidden.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/FolderClosedHidden.png rename to Rubberduck.Core/Resources/Custom/PNG/FolderClosedHidden.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/FolderClosedVirtual.png b/Rubberduck.Core/Resources/Custom/PNG/FolderClosedVirtual.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/FolderClosedVirtual.png rename to Rubberduck.Core/Resources/Custom/PNG/FolderClosedVirtual.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/FolderOpen.png b/Rubberduck.Core/Resources/Custom/PNG/FolderOpen.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/FolderOpen.png rename to Rubberduck.Core/Resources/Custom/PNG/FolderOpen.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/FolderOpenHidden.png b/Rubberduck.Core/Resources/Custom/PNG/FolderOpenHidden.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/FolderOpenHidden.png rename to Rubberduck.Core/Resources/Custom/PNG/FolderOpenHidden.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/FolderOpenVirtual.png b/Rubberduck.Core/Resources/Custom/PNG/FolderOpenVirtual.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/FolderOpenVirtual.png rename to Rubberduck.Core/Resources/Custom/PNG/FolderOpenVirtual.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/GenerateMethod.png b/Rubberduck.Core/Resources/Custom/PNG/GenerateMethod.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/GenerateMethod.png rename to Rubberduck.Core/Resources/Custom/PNG/GenerateMethod.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/GroupBy.png b/Rubberduck.Core/Resources/Custom/PNG/GroupBy.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/GroupBy.png rename to Rubberduck.Core/Resources/Custom/PNG/GroupBy.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ImplementInterface.png b/Rubberduck.Core/Resources/Custom/PNG/ImplementInterface.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ImplementInterface.png rename to Rubberduck.Core/Resources/Custom/PNG/ImplementInterface.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ListOfTests.png b/Rubberduck.Core/Resources/Custom/PNG/ListOfTests.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ListOfTests.png rename to Rubberduck.Core/Resources/Custom/PNG/ListOfTests.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/NewConstant.png b/Rubberduck.Core/Resources/Custom/PNG/NewConstant.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/NewConstant.png rename to Rubberduck.Core/Resources/Custom/PNG/NewConstant.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/NewEvent.png b/Rubberduck.Core/Resources/Custom/PNG/NewEvent.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/NewEvent.png rename to Rubberduck.Core/Resources/Custom/PNG/NewEvent.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectAssembly.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectAssembly.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectAssembly.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectAssembly.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectClass.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectClass.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectClass.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectClass.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectClassFriend.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectClassFriend.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectClassFriend.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectClassFriend.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectClassPrivate.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectClassPrivate.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectClassPrivate.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectClassPrivate.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectClassProtected.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectClassProtected.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectClassProtected.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectClassProtected.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectClassSealed.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectClassSealed.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectClassSealed.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectClassSealed.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectClassShortcut.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectClassShortcut.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectClassShortcut.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectClassShortcut.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectConstant.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectConstant.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectConstant.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectConstant.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectConstantFriend.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectConstantFriend.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectConstantFriend.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectConstantFriend.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectConstantPrivate.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectConstantPrivate.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectConstantPrivate.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectConstantPrivate.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectConstantProtected.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectConstantProtected.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectConstantProtected.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectConstantProtected.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectConstantSealed.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectConstantSealed.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectConstantSealed.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectConstantSealed.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectConstantShortcut.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectConstantShortcut.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectConstantShortcut.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectConstantShortcut.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectEnum.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectEnum.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectEnum.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectEnum.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectEnumFriend.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectEnumFriend.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectEnumFriend.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectEnumFriend.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectEnumItem.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectEnumItem.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectEnumItem.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectEnumItem.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectEnumItemFriend.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectEnumItemFriend.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectEnumItemFriend.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectEnumItemFriend.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectEnumItemPrivate.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectEnumItemPrivate.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectEnumItemPrivate.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectEnumItemPrivate.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectEnumItemProtected.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectEnumItemProtected.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectEnumItemProtected.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectEnumItemProtected.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectEnumItemSealed.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectEnumItemSealed.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectEnumItemSealed.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectEnumItemSealed.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectEnumItemShortcut.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectEnumItemShortcut.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectEnumItemShortcut.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectEnumItemShortcut.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectEnumPrivate.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectEnumPrivate.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectEnumPrivate.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectEnumPrivate.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectEnumProtected.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectEnumProtected.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectEnumProtected.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectEnumProtected.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectEnumSealed.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectEnumSealed.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectEnumSealed.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectEnumSealed.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectEnumShortcut.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectEnumShortcut.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectEnumShortcut.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectEnumShortcut.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectEvent.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectEvent.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectEvent.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectEvent.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectEventFriend.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectEventFriend.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectEventFriend.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectEventFriend.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectEventPrivate.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectEventPrivate.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectEventPrivate.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectEventPrivate.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectEventProtected.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectEventProtected.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectEventProtected.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectEventProtected.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectEventSealed.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectEventSealed.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectEventSealed.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectEventSealed.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectEventShortcut.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectEventShortcut.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectEventShortcut.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectEventShortcut.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectField.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectField.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectField.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectField.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectFieldFriend.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectFieldFriend.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectFieldFriend.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectFieldFriend.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectFieldPrivate.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectFieldPrivate.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectFieldPrivate.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectFieldPrivate.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectFieldProtected.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectFieldProtected.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectFieldProtected.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectFieldProtected.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectFieldSealed.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectFieldSealed.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectFieldSealed.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectFieldSealed.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectFieldShortcut.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectFieldShortcut.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectFieldShortcut.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectFieldShortcut.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectLibrary.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectLibrary.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectLibrary.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectLibrary.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectMethod.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectMethod.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectMethod.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectMethod.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectMethodFriend.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectMethodFriend.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectMethodFriend.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectMethodFriend.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectMethodPrivate.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectMethodPrivate.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectMethodPrivate.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectMethodPrivate.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectMethodProtected.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectMethodProtected.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectMethodProtected.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectMethodProtected.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectMethodSealed.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectMethodSealed.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectMethodSealed.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectMethodSealed.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectMethodShortcut.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectMethodShortcut.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectMethodShortcut.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectMethodShortcut.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectModule.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectModule.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectModule.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectModule.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectModuleFriend.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectModuleFriend.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectModuleFriend.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectModuleFriend.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectModulePrivate.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectModulePrivate.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectModulePrivate.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectModulePrivate.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectModuleProtected.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectModuleProtected.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectModuleProtected.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectModuleProtected.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectModuleSealed.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectModuleSealed.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectModuleSealed.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectModuleSealed.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectModuleShortcut.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectModuleShortcut.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectModuleShortcut.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectModuleShortcut.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectProperties.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectProperties.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectProperties.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectProperties.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectPropertiesFriend.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectPropertiesFriend.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectPropertiesFriend.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectPropertiesFriend.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectPropertiesPrivate.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectPropertiesPrivate.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectPropertiesPrivate.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectPropertiesPrivate.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectPropertiesProtected.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectPropertiesProtected.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectPropertiesProtected.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectPropertiesProtected.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectPropertiesSealed.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectPropertiesSealed.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectPropertiesSealed.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectPropertiesSealed.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectPropertiesShortcut.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectPropertiesShortcut.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectPropertiesShortcut.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectPropertiesShortcut.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectStructure.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectStructure.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectStructure.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectStructure.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectStructureFriend.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectStructureFriend.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectStructureFriend.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectStructureFriend.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectStructurePrivate.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectStructurePrivate.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectStructurePrivate.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectStructurePrivate.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectStructureProtected.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectStructureProtected.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectStructureProtected.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectStructureProtected.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectStructureSealed.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectStructureSealed.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectStructureSealed.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectStructureSealed.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectStructureShortcut.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectStructureShortcut.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectStructureShortcut.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectStructureShortcut.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectType.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectType.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectType.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectType.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectTypeFriend.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectTypeFriend.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectTypeFriend.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectTypeFriend.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectTypePrivate.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectTypePrivate.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectTypePrivate.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectTypePrivate.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectTypeProtected.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectTypeProtected.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectTypeProtected.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectTypeProtected.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectTypeSealed.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectTypeSealed.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectTypeSealed.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectTypeSealed.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectTypeShortcut.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectTypeShortcut.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectTypeShortcut.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectTypeShortcut.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectValueType.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectValueType.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectValueType.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectValueType.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectValueTypeFriend.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectValueTypeFriend.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectValueTypeFriend.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectValueTypeFriend.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectValueTypePrivate.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectValueTypePrivate.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectValueTypePrivate.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectValueTypePrivate.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectValueTypeProtected.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectValueTypeProtected.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectValueTypeProtected.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectValueTypeProtected.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectValueTypeSealed.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectValueTypeSealed.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectValueTypeSealed.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectValueTypeSealed.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ObjectValueTypeShortcut.png b/Rubberduck.Core/Resources/Custom/PNG/ObjectValueTypeShortcut.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ObjectValueTypeShortcut.png rename to Rubberduck.Core/Resources/Custom/PNG/ObjectValueTypeShortcut.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/Options.png b/Rubberduck.Core/Resources/Custom/PNG/Options.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/Options.png rename to Rubberduck.Core/Resources/Custom/PNG/Options.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/Play.png b/Rubberduck.Core/Resources/Custom/PNG/Play.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/Play.png rename to Rubberduck.Core/Resources/Custom/PNG/Play.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ProjectForm.png b/Rubberduck.Core/Resources/Custom/PNG/ProjectForm.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ProjectForm.png rename to Rubberduck.Core/Resources/Custom/PNG/ProjectForm.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ProjectReference.png b/Rubberduck.Core/Resources/Custom/PNG/ProjectReference.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ProjectReference.png rename to Rubberduck.Core/Resources/Custom/PNG/ProjectReference.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/PromoteLocal.png b/Rubberduck.Core/Resources/Custom/PNG/PromoteLocal.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/PromoteLocal.png rename to Rubberduck.Core/Resources/Custom/PNG/PromoteLocal.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/Recursion.png b/Rubberduck.Core/Resources/Custom/PNG/Recursion.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/Recursion.png rename to Rubberduck.Core/Resources/Custom/PNG/Recursion.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/Refresh.png b/Rubberduck.Core/Resources/Custom/PNG/Refresh.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/Refresh.png rename to Rubberduck.Core/Resources/Custom/PNG/Refresh.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/RemoveParameters.png b/Rubberduck.Core/Resources/Custom/PNG/RemoveParameters.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/RemoveParameters.png rename to Rubberduck.Core/Resources/Custom/PNG/RemoveParameters.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/ReorderParameters.png b/Rubberduck.Core/Resources/Custom/PNG/ReorderParameters.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/ReorderParameters.png rename to Rubberduck.Core/Resources/Custom/PNG/ReorderParameters.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/Services.png b/Rubberduck.Core/Resources/Custom/PNG/Services.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/Services.png rename to Rubberduck.Core/Resources/Custom/PNG/Services.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/StepRunTest.png b/Rubberduck.Core/Resources/Custom/PNG/StepRunTest.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/StepRunTest.png rename to Rubberduck.Core/Resources/Custom/PNG/StepRunTest.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/Task.png b/Rubberduck.Core/Resources/Custom/PNG/Task.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/Task.png rename to Rubberduck.Core/Resources/Custom/PNG/Task.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/TestManager.png b/Rubberduck.Core/Resources/Custom/PNG/TestManager.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/TestManager.png rename to Rubberduck.Core/Resources/Custom/PNG/TestManager.png diff --git a/RetailCoder.VBE/Resources/Custom/PNG/TestMethod.png b/Rubberduck.Core/Resources/Custom/PNG/TestMethod.png similarity index 100% rename from RetailCoder.VBE/Resources/Custom/PNG/TestMethod.png rename to Rubberduck.Core/Resources/Custom/PNG/TestMethod.png diff --git a/RetailCoder.VBE/Resources/Custom/attribution.txt b/Rubberduck.Core/Resources/Custom/attribution.txt similarity index 100% rename from RetailCoder.VBE/Resources/Custom/attribution.txt rename to Rubberduck.Core/Resources/Custom/attribution.txt diff --git a/RetailCoder.VBE/Resources/Custom/cc_license.txt b/Rubberduck.Core/Resources/Custom/cc_license.txt similarity index 100% rename from RetailCoder.VBE/Resources/Custom/cc_license.txt rename to Rubberduck.Core/Resources/Custom/cc_license.txt diff --git a/RetailCoder.VBE/Resources/Custom/mit_license.txt b/Rubberduck.Core/Resources/Custom/mit_license.txt similarity index 100% rename from RetailCoder.VBE/Resources/Custom/mit_license.txt rename to Rubberduck.Core/Resources/Custom/mit_license.txt diff --git a/RetailCoder.VBE/Resources/Ducky.ico b/Rubberduck.Core/Resources/Ducky.ico similarity index 100% rename from RetailCoder.VBE/Resources/Ducky.ico rename to Rubberduck.Core/Resources/Ducky.ico diff --git a/RetailCoder.VBE/Resources/RD-300x250-base.png b/Rubberduck.Core/Resources/RD-300x250-base.png similarity index 100% rename from RetailCoder.VBE/Resources/RD-300x250-base.png rename to Rubberduck.Core/Resources/RD-300x250-base.png diff --git a/RetailCoder.VBE/Resources/RD-InstallWindow.png b/Rubberduck.Core/Resources/RD-InstallWindow.png similarity index 100% rename from RetailCoder.VBE/Resources/RD-InstallWindow.png rename to Rubberduck.Core/Resources/RD-InstallWindow.png diff --git a/RetailCoder.VBE/Resources/Rubberduck.png b/Rubberduck.Core/Resources/Rubberduck.png similarity index 100% rename from RetailCoder.VBE/Resources/Rubberduck.png rename to Rubberduck.Core/Resources/Rubberduck.png diff --git a/RetailCoder.VBE/Resources/Rubberduck/RD-AboutWindow.png b/Rubberduck.Core/Resources/Rubberduck/RD-AboutWindow.png similarity index 100% rename from RetailCoder.VBE/Resources/Rubberduck/RD-AboutWindow.png rename to Rubberduck.Core/Resources/Rubberduck/RD-AboutWindow.png diff --git a/RetailCoder.VBE/Resources/Rubberduck/RD-InstallBanner.bmp b/Rubberduck.Core/Resources/Rubberduck/RD-InstallBanner.bmp similarity index 100% rename from RetailCoder.VBE/Resources/Rubberduck/RD-InstallBanner.bmp rename to Rubberduck.Core/Resources/Rubberduck/RD-InstallBanner.bmp diff --git a/RetailCoder.VBE/Resources/Rubberduck/RD-InstallWindow.bmp b/Rubberduck.Core/Resources/Rubberduck/RD-InstallWindow.bmp similarity index 100% rename from RetailCoder.VBE/Resources/Rubberduck/RD-InstallWindow.bmp rename to Rubberduck.Core/Resources/Rubberduck/RD-InstallWindow.bmp diff --git a/RetailCoder.VBE/Resources/application-resize.png b/Rubberduck.Core/Resources/application-resize.png similarity index 100% rename from RetailCoder.VBE/Resources/application-resize.png rename to Rubberduck.Core/Resources/application-resize.png diff --git a/RetailCoder.VBE/Resources/arrow-090.png b/Rubberduck.Core/Resources/arrow-090.png similarity index 100% rename from RetailCoder.VBE/Resources/arrow-090.png rename to Rubberduck.Core/Resources/arrow-090.png diff --git a/RetailCoder.VBE/Resources/arrow-270.png b/Rubberduck.Core/Resources/arrow-270.png similarity index 100% rename from RetailCoder.VBE/Resources/arrow-270.png rename to Rubberduck.Core/Resources/arrow-270.png diff --git a/RetailCoder.VBE/Resources/arrow-branch-090.png b/Rubberduck.Core/Resources/arrow-branch-090.png similarity index 100% rename from RetailCoder.VBE/Resources/arrow-branch-090.png rename to Rubberduck.Core/Resources/arrow-branch-090.png diff --git a/RetailCoder.VBE/Resources/arrow-circle-double.png b/Rubberduck.Core/Resources/arrow-circle-double.png similarity index 100% rename from RetailCoder.VBE/Resources/arrow-circle-double.png rename to Rubberduck.Core/Resources/arrow-circle-double.png diff --git a/RetailCoder.VBE/Resources/arrow-circle-left.png b/Rubberduck.Core/Resources/arrow-circle-left.png similarity index 100% rename from RetailCoder.VBE/Resources/arrow-circle-left.png rename to Rubberduck.Core/Resources/arrow-circle-left.png diff --git a/RetailCoder.VBE/Resources/arrow-merge-090.png b/Rubberduck.Core/Resources/arrow-merge-090.png similarity index 100% rename from RetailCoder.VBE/Resources/arrow-merge-090.png rename to Rubberduck.Core/Resources/arrow-merge-090.png diff --git a/RetailCoder.VBE/Resources/arrow-repeat.png b/Rubberduck.Core/Resources/arrow-repeat.png similarity index 100% rename from RetailCoder.VBE/Resources/arrow-repeat.png rename to Rubberduck.Core/Resources/arrow-repeat.png diff --git a/RetailCoder.VBE/Resources/arrow-repeat1.png b/Rubberduck.Core/Resources/arrow-repeat1.png similarity index 100% rename from RetailCoder.VBE/Resources/arrow-repeat1.png rename to Rubberduck.Core/Resources/arrow-repeat1.png diff --git a/RetailCoder.VBE/Resources/arrow-return-180-left.png b/Rubberduck.Core/Resources/arrow-return-180-left.png similarity index 100% rename from RetailCoder.VBE/Resources/arrow-return-180-left.png rename to Rubberduck.Core/Resources/arrow-return-180-left.png diff --git a/RetailCoder.VBE/Resources/arrow-split.png b/Rubberduck.Core/Resources/arrow-split.png similarity index 100% rename from RetailCoder.VBE/Resources/arrow-split.png rename to Rubberduck.Core/Resources/arrow-split.png diff --git a/RetailCoder.VBE/Resources/arrow-step.png b/Rubberduck.Core/Resources/arrow-step.png similarity index 100% rename from RetailCoder.VBE/Resources/arrow-step.png rename to Rubberduck.Core/Resources/arrow-step.png diff --git a/RetailCoder.VBE/Resources/arrow.png b/Rubberduck.Core/Resources/arrow.png similarity index 100% rename from RetailCoder.VBE/Resources/arrow.png rename to Rubberduck.Core/Resources/arrow.png diff --git a/RetailCoder.VBE/Resources/arrow1.png b/Rubberduck.Core/Resources/arrow1.png similarity index 100% rename from RetailCoder.VBE/Resources/arrow1.png rename to Rubberduck.Core/Resources/arrow1.png diff --git a/RetailCoder.VBE/Resources/arrow_circle_double_mask.bmp b/Rubberduck.Core/Resources/arrow_circle_double_mask.bmp similarity index 100% rename from RetailCoder.VBE/Resources/arrow_circle_double_mask.bmp rename to Rubberduck.Core/Resources/arrow_circle_double_mask.bmp diff --git a/RetailCoder.VBE/Resources/balloon_ellipsis.bmp b/Rubberduck.Core/Resources/balloon_ellipsis.bmp similarity index 100% rename from RetailCoder.VBE/Resources/balloon_ellipsis.bmp rename to Rubberduck.Core/Resources/balloon_ellipsis.bmp diff --git a/RetailCoder.VBE/Resources/balloon_mask.bmp b/Rubberduck.Core/Resources/balloon_mask.bmp similarity index 100% rename from RetailCoder.VBE/Resources/balloon_mask.bmp rename to Rubberduck.Core/Resources/balloon_mask.bmp diff --git a/RetailCoder.VBE/Resources/balloon_prohibition.bmp b/Rubberduck.Core/Resources/balloon_prohibition.bmp similarity index 100% rename from RetailCoder.VBE/Resources/balloon_prohibition.bmp rename to Rubberduck.Core/Resources/balloon_prohibition.bmp diff --git a/RetailCoder.VBE/Resources/balloon_smiley.bmp b/Rubberduck.Core/Resources/balloon_smiley.bmp similarity index 100% rename from RetailCoder.VBE/Resources/balloon_smiley.bmp rename to Rubberduck.Core/Resources/balloon_smiley.bmp diff --git a/RetailCoder.VBE/Resources/blue-folder-horizontal-open.png b/Rubberduck.Core/Resources/blue-folder-horizontal-open.png similarity index 100% rename from RetailCoder.VBE/Resources/blue-folder-horizontal-open.png rename to Rubberduck.Core/Resources/blue-folder-horizontal-open.png diff --git a/RetailCoder.VBE/Resources/blue-folder-horizontal.png b/Rubberduck.Core/Resources/blue-folder-horizontal.png similarity index 100% rename from RetailCoder.VBE/Resources/blue-folder-horizontal.png rename to Rubberduck.Core/Resources/blue-folder-horizontal.png diff --git a/RetailCoder.VBE/Resources/circle_mask.bmp b/Rubberduck.Core/Resources/circle_mask.bmp similarity index 100% rename from RetailCoder.VBE/Resources/circle_mask.bmp rename to Rubberduck.Core/Resources/circle_mask.bmp diff --git a/RetailCoder.VBE/Resources/control-000-small.png b/Rubberduck.Core/Resources/control-000-small.png similarity index 100% rename from RetailCoder.VBE/Resources/control-000-small.png rename to Rubberduck.Core/Resources/control-000-small.png diff --git a/RetailCoder.VBE/Resources/control.png b/Rubberduck.Core/Resources/control.png similarity index 100% rename from RetailCoder.VBE/Resources/control.png rename to Rubberduck.Core/Resources/control.png diff --git a/RetailCoder.VBE/Resources/creative-commons.png b/Rubberduck.Core/Resources/creative-commons.png similarity index 100% rename from RetailCoder.VBE/Resources/creative-commons.png rename to Rubberduck.Core/Resources/creative-commons.png diff --git a/RetailCoder.VBE/Resources/cross-button.png b/Rubberduck.Core/Resources/cross-button.png similarity index 100% rename from RetailCoder.VBE/Resources/cross-button.png rename to Rubberduck.Core/Resources/cross-button.png diff --git a/RetailCoder.VBE/Resources/cross-circle.png b/Rubberduck.Core/Resources/cross-circle.png similarity index 100% rename from RetailCoder.VBE/Resources/cross-circle.png rename to Rubberduck.Core/Resources/cross-circle.png diff --git a/RetailCoder.VBE/Resources/cross-script.png b/Rubberduck.Core/Resources/cross-script.png similarity index 100% rename from RetailCoder.VBE/Resources/cross-script.png rename to Rubberduck.Core/Resources/cross-script.png diff --git a/RetailCoder.VBE/Resources/disk.png b/Rubberduck.Core/Resources/disk.png similarity index 100% rename from RetailCoder.VBE/Resources/disk.png rename to Rubberduck.Core/Resources/disk.png diff --git a/RetailCoder.VBE/Resources/document-copy.png b/Rubberduck.Core/Resources/document-copy.png similarity index 100% rename from RetailCoder.VBE/Resources/document-copy.png rename to Rubberduck.Core/Resources/document-copy.png diff --git a/RetailCoder.VBE/Resources/document-excel.png b/Rubberduck.Core/Resources/document-excel.png similarity index 100% rename from RetailCoder.VBE/Resources/document-excel.png rename to Rubberduck.Core/Resources/document-excel.png diff --git a/RetailCoder.VBE/Resources/document-office.png b/Rubberduck.Core/Resources/document-office.png similarity index 100% rename from RetailCoder.VBE/Resources/document-office.png rename to Rubberduck.Core/Resources/document-office.png diff --git a/RetailCoder.VBE/Resources/document-outlook.png b/Rubberduck.Core/Resources/document-outlook.png similarity index 100% rename from RetailCoder.VBE/Resources/document-outlook.png rename to Rubberduck.Core/Resources/document-outlook.png diff --git a/RetailCoder.VBE/Resources/document-powerpoint.png b/Rubberduck.Core/Resources/document-powerpoint.png similarity index 100% rename from RetailCoder.VBE/Resources/document-powerpoint.png rename to Rubberduck.Core/Resources/document-powerpoint.png diff --git a/RetailCoder.VBE/Resources/document-smiley-sad.png b/Rubberduck.Core/Resources/document-smiley-sad.png similarity index 100% rename from RetailCoder.VBE/Resources/document-smiley-sad.png rename to Rubberduck.Core/Resources/document-smiley-sad.png diff --git a/RetailCoder.VBE/Resources/document-word.png b/Rubberduck.Core/Resources/document-word.png similarity index 100% rename from RetailCoder.VBE/Resources/document-word.png rename to Rubberduck.Core/Resources/document-word.png diff --git a/RetailCoder.VBE/Resources/drive-download.png b/Rubberduck.Core/Resources/drive-download.png similarity index 100% rename from RetailCoder.VBE/Resources/drive-download.png rename to Rubberduck.Core/Resources/drive-download.png diff --git a/RetailCoder.VBE/Resources/drive-upload.png b/Rubberduck.Core/Resources/drive-upload.png similarity index 100% rename from RetailCoder.VBE/Resources/drive-upload.png rename to Rubberduck.Core/Resources/drive-upload.png diff --git a/RetailCoder.VBE/Resources/edit-list-order.png b/Rubberduck.Core/Resources/edit-list-order.png similarity index 100% rename from RetailCoder.VBE/Resources/edit-list-order.png rename to Rubberduck.Core/Resources/edit-list-order.png diff --git a/RetailCoder.VBE/Resources/exclamation-circle.png b/Rubberduck.Core/Resources/exclamation-circle.png similarity index 100% rename from RetailCoder.VBE/Resources/exclamation-circle.png rename to Rubberduck.Core/Resources/exclamation-circle.png diff --git a/RetailCoder.VBE/Resources/exclamation-diamond.png b/Rubberduck.Core/Resources/exclamation-diamond.png similarity index 100% rename from RetailCoder.VBE/Resources/exclamation-diamond.png rename to Rubberduck.Core/Resources/exclamation-diamond.png diff --git a/RetailCoder.VBE/Resources/exclamation-white.png b/Rubberduck.Core/Resources/exclamation-white.png similarity index 100% rename from RetailCoder.VBE/Resources/exclamation-white.png rename to Rubberduck.Core/Resources/exclamation-white.png diff --git a/RetailCoder.VBE/Resources/exclamation.png b/Rubberduck.Core/Resources/exclamation.png similarity index 100% rename from RetailCoder.VBE/Resources/exclamation.png rename to Rubberduck.Core/Resources/exclamation.png diff --git a/RetailCoder.VBE/Resources/facebook-circle-256.png b/Rubberduck.Core/Resources/facebook-circle-256.png similarity index 100% rename from RetailCoder.VBE/Resources/facebook-circle-256.png rename to Rubberduck.Core/Resources/facebook-circle-256.png diff --git a/RetailCoder.VBE/Resources/facebook-icon.png b/Rubberduck.Core/Resources/facebook-icon.png similarity index 100% rename from RetailCoder.VBE/Resources/facebook-icon.png rename to Rubberduck.Core/Resources/facebook-icon.png diff --git a/RetailCoder.VBE/Resources/flask--arrow.png b/Rubberduck.Core/Resources/flask--arrow.png similarity index 100% rename from RetailCoder.VBE/Resources/flask--arrow.png rename to Rubberduck.Core/Resources/flask--arrow.png diff --git a/RetailCoder.VBE/Resources/flask--exclamation.png b/Rubberduck.Core/Resources/flask--exclamation.png similarity index 100% rename from RetailCoder.VBE/Resources/flask--exclamation.png rename to Rubberduck.Core/Resources/flask--exclamation.png diff --git a/RetailCoder.VBE/Resources/flask--pencil.png b/Rubberduck.Core/Resources/flask--pencil.png similarity index 100% rename from RetailCoder.VBE/Resources/flask--pencil.png rename to Rubberduck.Core/Resources/flask--pencil.png diff --git a/RetailCoder.VBE/Resources/flask--plus.png b/Rubberduck.Core/Resources/flask--plus.png similarity index 100% rename from RetailCoder.VBE/Resources/flask--plus.png rename to Rubberduck.Core/Resources/flask--plus.png diff --git a/RetailCoder.VBE/Resources/flask-empty.png b/Rubberduck.Core/Resources/flask-empty.png similarity index 100% rename from RetailCoder.VBE/Resources/flask-empty.png rename to Rubberduck.Core/Resources/flask-empty.png diff --git a/RetailCoder.VBE/Resources/flask.png b/Rubberduck.Core/Resources/flask.png similarity index 100% rename from RetailCoder.VBE/Resources/flask.png rename to Rubberduck.Core/Resources/flask.png diff --git a/RetailCoder.VBE/Resources/flask_exclamation_mask.png b/Rubberduck.Core/Resources/flask_exclamation_mask.png similarity index 100% rename from RetailCoder.VBE/Resources/flask_exclamation_mask.png rename to Rubberduck.Core/Resources/flask_exclamation_mask.png diff --git a/RetailCoder.VBE/Resources/flask_mask.png b/Rubberduck.Core/Resources/flask_mask.png similarity index 100% rename from RetailCoder.VBE/Resources/flask_mask.png rename to Rubberduck.Core/Resources/flask_mask.png diff --git a/RetailCoder.VBE/Resources/folder--pencil.png b/Rubberduck.Core/Resources/folder--pencil.png similarity index 100% rename from RetailCoder.VBE/Resources/folder--pencil.png rename to Rubberduck.Core/Resources/folder--pencil.png diff --git a/RetailCoder.VBE/Resources/folder--plus.png b/Rubberduck.Core/Resources/folder--plus.png similarity index 100% rename from RetailCoder.VBE/Resources/folder--plus.png rename to Rubberduck.Core/Resources/folder--plus.png diff --git a/RetailCoder.VBE/Resources/folder-horizontal-open.png b/Rubberduck.Core/Resources/folder-horizontal-open.png similarity index 100% rename from RetailCoder.VBE/Resources/folder-horizontal-open.png rename to Rubberduck.Core/Resources/folder-horizontal-open.png diff --git a/RetailCoder.VBE/Resources/folder-horizontal.png b/Rubberduck.Core/Resources/folder-horizontal.png similarity index 100% rename from RetailCoder.VBE/Resources/folder-horizontal.png rename to Rubberduck.Core/Resources/folder-horizontal.png diff --git a/RetailCoder.VBE/Resources/folder-open.png b/Rubberduck.Core/Resources/folder-open.png similarity index 100% rename from RetailCoder.VBE/Resources/folder-open.png rename to Rubberduck.Core/Resources/folder-open.png diff --git a/RetailCoder.VBE/Resources/folder-rename.png b/Rubberduck.Core/Resources/folder-rename.png similarity index 100% rename from RetailCoder.VBE/Resources/folder-rename.png rename to Rubberduck.Core/Resources/folder-rename.png diff --git a/RetailCoder.VBE/Resources/folder.png b/Rubberduck.Core/Resources/folder.png similarity index 100% rename from RetailCoder.VBE/Resources/folder.png rename to Rubberduck.Core/Resources/folder.png diff --git a/RetailCoder.VBE/Resources/gear.png b/Rubberduck.Core/Resources/gear.png similarity index 100% rename from RetailCoder.VBE/Resources/gear.png rename to Rubberduck.Core/Resources/gear.png diff --git a/RetailCoder.VBE/Resources/git.png b/Rubberduck.Core/Resources/git.png similarity index 100% rename from RetailCoder.VBE/Resources/git.png rename to Rubberduck.Core/Resources/git.png diff --git a/RetailCoder.VBE/Resources/github-alt.png b/Rubberduck.Core/Resources/github-alt.png similarity index 100% rename from RetailCoder.VBE/Resources/github-alt.png rename to Rubberduck.Core/Resources/github-alt.png diff --git a/RetailCoder.VBE/Resources/github_circle_black-128.png b/Rubberduck.Core/Resources/github_circle_black-128.png similarity index 100% rename from RetailCoder.VBE/Resources/github_circle_black-128.png rename to Rubberduck.Core/Resources/github_circle_black-128.png diff --git a/RetailCoder.VBE/Resources/google-circle-512.png b/Rubberduck.Core/Resources/google-circle-512.png similarity index 100% rename from RetailCoder.VBE/Resources/google-circle-512.png rename to Rubberduck.Core/Resources/google-circle-512.png diff --git a/RetailCoder.VBE/Resources/hourglass.png b/Rubberduck.Core/Resources/hourglass.png similarity index 100% rename from RetailCoder.VBE/Resources/hourglass.png rename to Rubberduck.Core/Resources/hourglass.png diff --git a/RetailCoder.VBE/Resources/icon-github.png b/Rubberduck.Core/Resources/icon-github.png similarity index 100% rename from RetailCoder.VBE/Resources/icon-github.png rename to Rubberduck.Core/Resources/icon-github.png diff --git a/RetailCoder.VBE/Resources/information-white.png b/Rubberduck.Core/Resources/information-white.png similarity index 100% rename from RetailCoder.VBE/Resources/information-white.png rename to Rubberduck.Core/Resources/information-white.png diff --git a/RetailCoder.VBE/Resources/information.png b/Rubberduck.Core/Resources/information.png similarity index 100% rename from RetailCoder.VBE/Resources/information.png rename to Rubberduck.Core/Resources/information.png diff --git a/RetailCoder.VBE/Resources/init-repo.png b/Rubberduck.Core/Resources/init-repo.png similarity index 100% rename from RetailCoder.VBE/Resources/init-repo.png rename to Rubberduck.Core/Resources/init-repo.png diff --git a/RetailCoder.VBE/Resources/light-bulb-code.png b/Rubberduck.Core/Resources/light-bulb-code.png similarity index 100% rename from RetailCoder.VBE/Resources/light-bulb-code.png rename to Rubberduck.Core/Resources/light-bulb-code.png diff --git a/RetailCoder.VBE/Resources/lock--exclamation.png b/Rubberduck.Core/Resources/lock--exclamation.png similarity index 100% rename from RetailCoder.VBE/Resources/lock--exclamation.png rename to Rubberduck.Core/Resources/lock--exclamation.png diff --git a/RetailCoder.VBE/Resources/magnifier--arrow.png b/Rubberduck.Core/Resources/magnifier--arrow.png similarity index 100% rename from RetailCoder.VBE/Resources/magnifier--arrow.png rename to Rubberduck.Core/Resources/magnifier--arrow.png diff --git a/RetailCoder.VBE/Resources/magnifier-medium.png b/Rubberduck.Core/Resources/magnifier-medium.png similarity index 100% rename from RetailCoder.VBE/Resources/magnifier-medium.png rename to Rubberduck.Core/Resources/magnifier-medium.png diff --git a/RetailCoder.VBE/Resources/minus-circle.png b/Rubberduck.Core/Resources/minus-circle.png similarity index 100% rename from RetailCoder.VBE/Resources/minus-circle.png rename to Rubberduck.Core/Resources/minus-circle.png diff --git a/RetailCoder.VBE/Resources/minus-circle1.png b/Rubberduck.Core/Resources/minus-circle1.png similarity index 100% rename from RetailCoder.VBE/Resources/minus-circle1.png rename to Rubberduck.Core/Resources/minus-circle1.png diff --git a/RetailCoder.VBE/Resources/minus-white.png b/Rubberduck.Core/Resources/minus-white.png similarity index 100% rename from RetailCoder.VBE/Resources/minus-white.png rename to Rubberduck.Core/Resources/minus-white.png diff --git a/RetailCoder.VBE/Resources/navigation-180.png b/Rubberduck.Core/Resources/navigation-180.png similarity index 100% rename from RetailCoder.VBE/Resources/navigation-180.png rename to Rubberduck.Core/Resources/navigation-180.png diff --git a/RetailCoder.VBE/Resources/navigation.png b/Rubberduck.Core/Resources/navigation.png similarity index 100% rename from RetailCoder.VBE/Resources/navigation.png rename to Rubberduck.Core/Resources/navigation.png diff --git a/RetailCoder.VBE/Resources/plus-circle.png b/Rubberduck.Core/Resources/plus-circle.png similarity index 100% rename from RetailCoder.VBE/Resources/plus-circle.png rename to Rubberduck.Core/Resources/plus-circle.png diff --git a/RetailCoder.VBE/Resources/plus-circle1.png b/Rubberduck.Core/Resources/plus-circle1.png similarity index 100% rename from RetailCoder.VBE/Resources/plus-circle1.png rename to Rubberduck.Core/Resources/plus-circle1.png diff --git a/RetailCoder.VBE/Resources/printer.png b/Rubberduck.Core/Resources/printer.png similarity index 100% rename from RetailCoder.VBE/Resources/printer.png rename to Rubberduck.Core/Resources/printer.png diff --git a/RetailCoder.VBE/Resources/question-white.png b/Rubberduck.Core/Resources/question-white.png similarity index 100% rename from RetailCoder.VBE/Resources/question-white.png rename to Rubberduck.Core/Resources/question-white.png diff --git a/RetailCoder.VBE/Resources/rubberduck_adsize.png b/Rubberduck.Core/Resources/rubberduck_adsize.png similarity index 100% rename from RetailCoder.VBE/Resources/rubberduck_adsize.png rename to Rubberduck.Core/Resources/rubberduck_adsize.png diff --git a/RetailCoder.VBE/Resources/terminal.png b/Rubberduck.Core/Resources/terminal.png similarity index 100% rename from RetailCoder.VBE/Resources/terminal.png rename to Rubberduck.Core/Resources/terminal.png diff --git a/RetailCoder.VBE/Resources/tick-circle.png b/Rubberduck.Core/Resources/tick-circle.png similarity index 100% rename from RetailCoder.VBE/Resources/tick-circle.png rename to Rubberduck.Core/Resources/tick-circle.png diff --git a/RetailCoder.VBE/Resources/tick.png b/Rubberduck.Core/Resources/tick.png similarity index 100% rename from RetailCoder.VBE/Resources/tick.png rename to Rubberduck.Core/Resources/tick.png diff --git a/RetailCoder.VBE/Resources/twitter_circle_black-512.png b/Rubberduck.Core/Resources/twitter_circle_black-512.png similarity index 100% rename from RetailCoder.VBE/Resources/twitter_circle_black-512.png rename to Rubberduck.Core/Resources/twitter_circle_black-512.png diff --git a/RetailCoder.VBE/Rubberduck.csproj b/Rubberduck.Core/Rubberduck.Core.csproj similarity index 89% rename from RetailCoder.VBE/Rubberduck.csproj rename to Rubberduck.Core/Rubberduck.Core.csproj index f77b296dc7..f135ce7573 100644 --- a/RetailCoder.VBE/Rubberduck.csproj +++ b/Rubberduck.Core/Rubberduck.Core.csproj @@ -1,16 +1,14 @@  - - Debug AnyCPU - {20589DE8-432E-4359-9232-69EB070B7185} + {A1587EAC-7B54-407E-853F-4C7493D0323E} Library Properties Rubberduck - Rubberduck + Rubberduck.Core v4.5 512 @@ -26,12 +24,12 @@ DEBUG;TRACE prompt 4 - true - bin\Debug\Rubberduck.XML + false + bin\Debug\Rubberduck.Core.xml 1591 AnyCPU true - 7.1 + 7.2 full @@ -40,25 +38,25 @@ TRACE prompt 4 - true - bin\Release\Rubberduck.XML + false + bin\Release\Rubberduck.Core.xml true 1591 - 7.1 + 7.2 true bin\DebugAccess\ DEBUG;TRACE bin\Debug\Rubberduck.XML - true + false full AnyCPU prompt MinimumRecommendedRules.ruleset 4 false - 7.1 + 7.2 true @@ -148,7 +146,7 @@ bin\Debug64\ DEBUG;TRACE bin\Debug\Rubberduck.XML - true + false 1591 full AnyCPU @@ -156,7 +154,7 @@ MinimumRecommendedRules.ruleset 4 false - 7.1 + 7.2 true @@ -191,13 +189,13 @@ bin\Release64\ TRACE true - true + false full AnyCPU prompt MinimumRecommendedRules.ruleset 4 - 7.1 + 7.2 true @@ -229,41 +227,33 @@ - - ..\packages\Antlr4.Runtime.4.3.0\lib\net45\Antlr4.Runtime.net45.dll - False + + ..\packages\Antlr4.Runtime.4.6.4\lib\net45\Antlr4.Runtime.dll ..\packages\Castle.Core.4.1.1\lib\net45\Castle.Core.dll - True ..\packages\Castle.Windsor.4.0.0\lib\net45\Castle.Windsor.dll - True ..\packages\EasyHook.2.7.6270\lib\net40\EasyHook.dll - True True ..\packages\HtmlAgilityPack.1.4.9.5\lib\Net45\HtmlAgilityPack.dll - True - - ..\packages\AvalonEdit.5.0.3\lib\Net40\ICSharpCode.AvalonEdit.dll + + ..\packages\AvalonEdit.5.0.4\lib\Net40\ICSharpCode.AvalonEdit.dll ..\libs\Infralution.Localization.Wpf.dll - - False - ..\packages\LibGit2Sharp.0.24.0\lib\net40\LibGit2Sharp.dll - ..\packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\Microsoft.Expression.Interactions.dll + True ..\libs\Microsoft.VB6.Interop.VBIDE.dll @@ -275,6 +265,9 @@ ..\libs\Microsoft.Vbe.Interop.Forms.dll True + + ..\packages\NLog.4.4.12\lib\net45\NLog.dll + @@ -296,6 +289,7 @@ ..\packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\System.Windows.Interactivity.dll + True @@ -308,22 +302,16 @@ ..\libs\Office.dll - - ..\packages\NLog.4.0.1\lib\net45\NLog.dll - - - - - - + + @@ -337,7 +325,6 @@ - @@ -345,12 +332,20 @@ + + + + + True + True + Settings.settings + @@ -363,15 +358,15 @@ - + + - @@ -389,7 +384,6 @@ - @@ -434,6 +428,7 @@ EmptyUIRefresh.xaml + @@ -464,32 +459,15 @@ ReorderParametersView.xaml + + RubberduckUI.resx + True + True + - - - - - - - - - - - - + - - - - - - - - - - - @@ -512,7 +490,6 @@ - @@ -629,7 +606,6 @@ - @@ -655,8 +631,6 @@ - - @@ -713,11 +687,6 @@ True RubberduckUI.de.resx - - True - True - RubberduckUI.resx - @@ -837,21 +806,7 @@ True True - - BranchesView.xaml - - - - ChangesView.xaml - - - - - - - - Form @@ -859,33 +814,7 @@ RenameDialog.cs - - - SettingsView.xaml - - - - True - True - SourceControl.resx - - - UserControl - - - SourceControlPanel.cs - - - SourceControlView.xaml - - - - - - UnsyncedCommitsView.xaml - - Form @@ -896,7 +825,6 @@ - UserControl @@ -938,26 +866,16 @@ ToDoExplorerWindow.cs - - UserControl - - - DockableWindowHost.cs - UserControl TestExplorerWindow.cs - - - - @@ -966,7 +884,6 @@ - @@ -1017,6 +934,11 @@ RubberduckUI.de.Designer.cs Designer + + Designer + PublicResXFileCodeGenerator + RubberduckUI.Designer.cs + SettingsForm.cs @@ -1040,18 +962,6 @@ RubberduckUI.fr.Designer.cs Designer - - PublicResXFileCodeGenerator - Designer - RubberduckUI.Designer.cs - - - ResXFileCodeGenerator - SourceControl.Designer.cs - - - SourceControlPanel.cs - Splash.cs @@ -1064,14 +974,9 @@ - - - PreserveNewest - - + Designer - @@ -1099,7 +1004,6 @@ - @@ -1148,6 +1052,14 @@ + + Designer + + + + PublicSettingsSingleFileGenerator + Settings.Designer.cs + @@ -1364,10 +1276,6 @@ {B9C0BF22-4D8A-4BF4-89F9-E789C0063DEB} Rubberduck.SmartIndenter - - {0040E129-1AA2-459F-A59A-129FA4035E01} - Rubberduck.SourceControl - {8CE35EB3-8852-4BA1-84DD-DF3F5D2967B0} Rubberduck.VBEditor @@ -1474,26 +1382,6 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - Designer MSBuild:Compile @@ -1508,12 +1396,8 @@ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - diff --git a/RetailCoder.VBE/RubberduckGuid.cs b/Rubberduck.Core/RubberduckGuid.cs similarity index 85% rename from RetailCoder.VBE/RubberduckGuid.cs rename to Rubberduck.Core/RubberduckGuid.cs index 3d2a70b3e4..28d261aed3 100644 --- a/RetailCoder.VBE/RubberduckGuid.cs +++ b/Rubberduck.Core/RubberduckGuid.cs @@ -4,6 +4,9 @@ namespace Rubberduck { public static class RubberduckGuid { + // TypeLib Guid: + public const string RubberduckTypeLibGuid = "e07c841c-14b4-4890-83e9-8c80b06dd59d"; + // Addin Guids: public const string ExtensionGuid = "8D052AD8-BBD2-4C59-8DEC-F697CA1F8A66"; // shipped public const string DockableWindowHostGuid = "9CF1392A-2DC9-48A6-AC0B-E601A9802608"; // shipped @@ -13,7 +16,7 @@ public static class RubberduckGuid public const string IdentifierReferenceClassGuid = "57F78E64-8ADF-4D81-A467-A0139B877D14"; // shipped prior to 2.0.14 public const string ParserStateClassGuid = "28754D11-10CC-45FD-9F6A-525A65412B7A"; // shipped prior to 2.0.14 public const string IParserStateEventsGuid = "3D8EAA28-8983-44D5-83AF-2EEC4C363079"; // shipped prior to 2.0.14 - + // Unit testing Guids: private const string UnitTestingGuidspace = "-43F0-3B33-B105-9B8188A6F040"; public const string AssertClassGuid = "69E194DA" + UnitTestingGuidspace; // shipped prior to 2.0.14 @@ -24,5 +27,9 @@ public static class RubberduckGuid public const string IFakeGuid = "69E194DF" + UnitTestingGuidspace; // added for 2.0.14 public const string IVerifyGuid = "69E194E0" + UnitTestingGuidspace; // added for 2.0.14 public const string IStubGuid = "69E194E1" + UnitTestingGuidspace; // added for 2.0.14 + + // Enum Guids: + public const string DeclarationTypeGuid = "3E077C17-5678-3605-8449-FEABE42C9725"; + public const string AccessibilityGuid = "6BD869B8-C7C6-3970-8ED4-AC74DD2EBA92"; } } \ No newline at end of file diff --git a/RetailCoder.VBE/RubberduckProgId.cs b/Rubberduck.Core/RubberduckProgId.cs similarity index 100% rename from RetailCoder.VBE/RubberduckProgId.cs rename to Rubberduck.Core/RubberduckProgId.cs diff --git a/Rubberduck.Core/Settings/CodeInspectionConfigProvider.cs b/Rubberduck.Core/Settings/CodeInspectionConfigProvider.cs new file mode 100644 index 0000000000..b0962e6d56 --- /dev/null +++ b/Rubberduck.Core/Settings/CodeInspectionConfigProvider.cs @@ -0,0 +1,69 @@ +using System.Collections.Generic; +using System.Linq; +using Rubberduck.Inspections; +using Rubberduck.SettingsProvider; +using Rubberduck.Parsing.VBA; + +namespace Rubberduck.Settings +{ + public class CodeInspectionConfigProvider : IConfigProvider + { + private readonly IPersistanceService _persister; + private readonly CodeInspectionSettings _defaultSettings; + private readonly HashSet _foundInspectionNames; + + public CodeInspectionConfigProvider(IPersistanceService persister, IInspectionProvider inspectionProvider) + { + _persister = persister; + _foundInspectionNames = inspectionProvider.Inspections.Select(inspection => inspection.Name).ToHashSet(); + _defaultSettings = new DefaultSettings().Default; + // Ignore settings for unknown inpections, for example when using the Experimental attribute + _defaultSettings.CodeInspections = _defaultSettings.CodeInspections.Where(setting => _foundInspectionNames.Contains(setting.Name)).ToHashSet(); + + var defaultNames = _defaultSettings.CodeInspections.Select(x => x.Name); + var nonDefaultInspections = inspectionProvider.Inspections.Where(inspection => !defaultNames.Contains(inspection.Name)); + + _defaultSettings.CodeInspections.UnionWith(nonDefaultInspections.Select(inspection => new CodeInspectionSetting(inspection))); + } + + public CodeInspectionSettings Create() + { + var loaded = _persister.Load(_defaultSettings); + + if (loaded == null) + { + return _defaultSettings; + } + + // Loaded settings don't contain defaults, so we need to combine user settings with defaults. + var settings = new HashSet(); + + foreach (var loadedSetting in loaded.CodeInspections.Where(inspection => _foundInspectionNames.Contains(inspection.Name))) + { + var matchingDefaultSetting = _defaultSettings.CodeInspections.FirstOrDefault(inspection => inspection.Equals(loadedSetting)); + if (matchingDefaultSetting != null) + { + loadedSetting.InspectionType = matchingDefaultSetting.InspectionType; + } + + settings.Add(loadedSetting); + } + + settings.UnionWith(_defaultSettings.CodeInspections.Where(inspection => !settings.Contains(inspection))); + + loaded.CodeInspections = settings; + + return loaded; + } + + public CodeInspectionSettings CreateDefaults() + { + return _defaultSettings; + } + + public void Save(CodeInspectionSettings settings) + { + _persister.Save(settings); + } + } +} diff --git a/RetailCoder.VBE/Settings/CodeInspectionSettings.cs b/Rubberduck.Core/Settings/CodeInspectionSettings.cs similarity index 85% rename from RetailCoder.VBE/Settings/CodeInspectionSettings.cs rename to Rubberduck.Core/Settings/CodeInspectionSettings.cs index 1d9f287526..1c4a507ead 100644 --- a/RetailCoder.VBE/Settings/CodeInspectionSettings.cs +++ b/Rubberduck.Core/Settings/CodeInspectionSettings.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Configuration; using System.Globalization; using System.Linq; using System.Xml.Serialization; @@ -15,6 +16,7 @@ public interface ICodeInspectionSettings bool RunInspectionsOnSuccessfulParse { get; set; } } + [SettingsSerializeAs(SettingsSerializeAs.Xml)] [XmlType(AnonymousType = true)] public class CodeInspectionSettings : ICodeInspectionSettings, IEquatable { @@ -52,7 +54,7 @@ public CodeInspectionSetting GetSetting(Type inspectionType) { return existing; } - var proto = Convert.ChangeType(Activator.CreateInstance(inspectionType), inspectionType); + var proto = Convert.ChangeType(Activator.CreateInstance(inspectionType, new object[]{null}), inspectionType); var setting = new CodeInspectionSetting(proto as IInspectionModel); CodeInspections.Add(setting); return setting; @@ -94,7 +96,7 @@ public string Description public string AnnotationName => Name.Replace("Inspection", string.Empty); [XmlIgnore] - public CodeInspectionSeverity DefaultSeverity { get; private set; } + public CodeInspectionSeverity DefaultSeverity { get; } [XmlAttribute] public CodeInspectionSeverity Severity { get; set; } @@ -126,36 +128,33 @@ public string SeverityLabel [XmlAttribute] public CodeInspectionType InspectionType { get; set; } + /// + /// Default constructor required for XML serialization. + /// public CodeInspectionSetting() { - //default constructor required for serialization } - public CodeInspectionSetting(string name, CodeInspectionType type, CodeInspectionSeverity defaultSeverity = CodeInspectionSeverity.Warning) - : this(name, string.Empty, type, defaultSeverity, defaultSeverity) + public CodeInspectionSetting(string name, CodeInspectionType type) + : this(name, string.Empty, type) { } - public CodeInspectionSetting(string name, string description, CodeInspectionType type, CodeInspectionSeverity defaultSeverity = CodeInspectionSeverity.Warning, CodeInspectionSeverity severity = CodeInspectionSeverity.Warning) + public CodeInspectionSetting(string name, string description, CodeInspectionType type, CodeInspectionSeverity severity = CodeInspectionSeverity.Warning) { Name = name; Description = description; InspectionType = type; Severity = severity; - DefaultSeverity = defaultSeverity; + DefaultSeverity = CodeInspectionSeverity.Warning; } public CodeInspectionSetting(IInspectionModel inspection) - : this(inspection.Name, inspection.Description, inspection.InspectionType, inspection.DefaultSeverity, inspection.Severity) + : this(inspection.Name, inspection.Description, inspection.InspectionType, inspection.Severity) { } public override bool Equals(object obj) { - var inspectionSetting = obj as CodeInspectionSetting; - - return inspectionSetting != null && - inspectionSetting.InspectionType == InspectionType && - inspectionSetting.Name == Name && - inspectionSetting.Severity == Severity; + return obj is CodeInspectionSetting inspectionSetting && inspectionSetting.Name == Name; } public override int GetHashCode() @@ -163,7 +162,6 @@ public override int GetHashCode() unchecked { var hashCode = Name?.GetHashCode() ?? 0; - hashCode = (hashCode * 397) ^ (int)Severity; hashCode = (hashCode * 397) ^ (int)InspectionType; return hashCode; } diff --git a/RetailCoder.VBE/Settings/Configuration.cs b/Rubberduck.Core/Settings/Configuration.cs similarity index 100% rename from RetailCoder.VBE/Settings/Configuration.cs rename to Rubberduck.Core/Settings/Configuration.cs diff --git a/RetailCoder.VBE/Settings/ConfigurationLoader.cs b/Rubberduck.Core/Settings/ConfigurationLoader.cs similarity index 93% rename from RetailCoder.VBE/Settings/ConfigurationLoader.cs rename to Rubberduck.Core/Settings/ConfigurationLoader.cs index a8dda4a1e1..c767457fad 100644 --- a/RetailCoder.VBE/Settings/ConfigurationLoader.cs +++ b/Rubberduck.Core/Settings/ConfigurationLoader.cs @@ -7,9 +7,9 @@ namespace Rubberduck.Settings { public class ConfigurationChangedEventArgs : EventArgs { - public bool LanguageChanged { get; private set; } - public bool InspectionSettingsChanged { get; private set; } - public bool RunInspectionsOnReparse { get; private set; } + public bool LanguageChanged { get; } + public bool InspectionSettingsChanged { get; } + public bool RunInspectionsOnReparse { get; } public ConfigurationChangedEventArgs(bool runInspections, bool languageChanged, bool inspectionSettingsChanged) { @@ -105,11 +105,7 @@ public void SaveConfiguration(Configuration toSerialize) public event EventHandler SettingsChanged; protected virtual void OnSettingsChanged(ConfigurationChangedEventArgs e) { - var handler = SettingsChanged; - if (handler != null) - { - handler(this, e); - } + SettingsChanged?.Invoke(this, e); } } } diff --git a/Rubberduck.Core/Settings/DefaultSettings.cs b/Rubberduck.Core/Settings/DefaultSettings.cs new file mode 100644 index 0000000000..0db99a836a --- /dev/null +++ b/Rubberduck.Core/Settings/DefaultSettings.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using System.Linq; + +namespace Rubberduck.Settings +{ + public class DefaultSettings + { + public IEnumerable Defaults { get; } + public T Default => Defaults.First(); + + public DefaultSettings() + { + var properties = typeof(Properties.Settings).GetProperties().Where(prop => prop.PropertyType == typeof(T)); + + Defaults = properties.Select(prop => prop.GetValue(Properties.Settings.Default)).Cast(); + } + } +} diff --git a/RetailCoder.VBE/Settings/DisplayLanguageSetting.cs b/Rubberduck.Core/Settings/DisplayLanguageSetting.cs similarity index 66% rename from RetailCoder.VBE/Settings/DisplayLanguageSetting.cs rename to Rubberduck.Core/Settings/DisplayLanguageSetting.cs index 1c36e138e9..64cdb42d0a 100644 --- a/RetailCoder.VBE/Settings/DisplayLanguageSetting.cs +++ b/Rubberduck.Core/Settings/DisplayLanguageSetting.cs @@ -10,9 +10,11 @@ public class DisplayLanguageSetting [XmlAttribute] public string Code { get; set; } + /// + /// Default constructor required for XML serialization. + /// public DisplayLanguageSetting() { - // serialization constructor } public DisplayLanguageSetting(string code) @@ -23,31 +25,27 @@ public DisplayLanguageSetting(string code) try { culture = CultureInfo.GetCultureInfo(code); - _exists = true; + Exists = true; } catch (CultureNotFoundException) { culture = RubberduckUI.Culture; - _exists = false; + Exists = false; } var resource = "Language_" + Code.Substring(0, 2).ToUpper(); - _name = RubberduckUI.ResourceManager.GetString(resource, culture); + Name = RubberduckUI.ResourceManager.GetString(resource, culture); } - private readonly string _name; - private readonly bool _exists; - [XmlIgnore] - public string Name { get { return _name; } } + public string Name { get; } [XmlIgnore] - public bool Exists { get { return _exists; } } + public bool Exists { get; } public override bool Equals(object obj) { - var other = obj as DisplayLanguageSetting; - return other != null && Code.Equals(other.Code); + return obj is DisplayLanguageSetting other && Code.Equals(other.Code); } public override int GetHashCode() diff --git a/Rubberduck.Core/Settings/ExperimentalFeatures.cs b/Rubberduck.Core/Settings/ExperimentalFeatures.cs new file mode 100644 index 0000000000..6b017804c3 --- /dev/null +++ b/Rubberduck.Core/Settings/ExperimentalFeatures.cs @@ -0,0 +1,54 @@ +using System.Xml.Serialization; +using Rubberduck.UI; + +namespace Rubberduck.Settings +{ + public class ExperimentalFeatures : ViewModelBase + { + private bool _isEnabled; + public bool IsEnabled + { + get { return _isEnabled; } + set + { + _isEnabled = value; + OnPropertyChanged(); + } + } + + private string _key; + public string Key + { + get { return _key; } + set + { + _key = value; + OnPropertyChanged(); + OnPropertyChanged(nameof(DisplayValue)); + } + } + + [XmlIgnore] + public string DisplayValue => Key == null ? string.Empty : RubberduckUI.ResourceManager.GetString(Key); + + public override string ToString() + { + return Key; + } + + public override bool Equals(object obj) + { + return obj is ExperimentalFeatures value && + value.IsEnabled == IsEnabled && + value.Key == Key; + } + + public override int GetHashCode() + { + unchecked + { + return (IsEnabled.GetHashCode() * 397) ^ (Key != null ? Key.GetHashCode() : 0); + } + } + } +} \ No newline at end of file diff --git a/RetailCoder.VBE/Settings/GeneralConfigProvider.cs b/Rubberduck.Core/Settings/GeneralConfigProvider.cs similarity index 73% rename from RetailCoder.VBE/Settings/GeneralConfigProvider.cs rename to Rubberduck.Core/Settings/GeneralConfigProvider.cs index dc7954e7d9..3fcc7af6c2 100644 --- a/RetailCoder.VBE/Settings/GeneralConfigProvider.cs +++ b/Rubberduck.Core/Settings/GeneralConfigProvider.cs @@ -7,16 +7,17 @@ public class GeneralConfigProvider : IConfigProvider { private GeneralSettings _current; private readonly IPersistanceService _persister; + private readonly GeneralSettings _defaultSettings; public GeneralConfigProvider(IPersistanceService persister) { _persister = persister; + _defaultSettings = new DefaultSettings().Default; } public GeneralSettings Create() { - var prototype = new GeneralSettings(); - var updated = _persister.Load(prototype) ?? prototype; + var updated = _persister.Load(_defaultSettings) ?? _defaultSettings; CheckForEventsToRaise(updated); _current = updated; @@ -26,7 +27,7 @@ public GeneralSettings Create() public GeneralSettings CreateDefaults() { - return new GeneralSettings(); + return _defaultSettings; } public void Save(GeneralSettings settings) @@ -42,7 +43,7 @@ private void CheckForEventsToRaise(GeneralSettings other) OnLanguageChanged(EventArgs.Empty); } if (_current == null || - other.AutoSaveEnabled != _current.AutoSaveEnabled || + other.IsAutoSaveEnabled != _current.IsAutoSaveEnabled || other.AutoSavePeriod != _current.AutoSavePeriod) { OnAutoSaveSettingsChanged(EventArgs.Empty); @@ -52,22 +53,13 @@ private void CheckForEventsToRaise(GeneralSettings other) public event EventHandler LanguageChanged; protected virtual void OnLanguageChanged(EventArgs e) { - var handler = LanguageChanged; LanguageChanged?.Invoke(this, e); } public event EventHandler AutoSaveSettingsChanged; protected virtual void OnAutoSaveSettingsChanged(EventArgs e) { - var handler = AutoSaveSettingsChanged; AutoSaveSettingsChanged?.Invoke(this, e); } - - public event EventHandler SourceControlEnabledChanged; - protected virtual void OnSourceControlEnabledChanged(EventArgs e) - { - var handler = SourceControlEnabledChanged; - SourceControlEnabledChanged?.Invoke(this, e); - } } } \ No newline at end of file diff --git a/Rubberduck.Core/Settings/GeneralSettings.cs b/Rubberduck.Core/Settings/GeneralSettings.cs new file mode 100644 index 0000000000..bbbb317ba0 --- /dev/null +++ b/Rubberduck.Core/Settings/GeneralSettings.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Xml.Serialization; +using Rubberduck.Common; + +namespace Rubberduck.Settings +{ + public interface IGeneralSettings + { + DisplayLanguageSetting Language { get; set; } + bool CanShowSplash { get; set; } + bool CanCheckVersion { get; set; } + bool CompileBeforeParse { get; set; } + bool IsSmartIndenterPrompted { get; set; } + bool IsAutoSaveEnabled { get; set; } + int AutoSavePeriod { get; set; } + int MinimumLogLevel { get; set; } + List EnableExperimentalFeatures { get; set; } + } + + [SettingsSerializeAs(SettingsSerializeAs.Xml)] + [XmlType(AnonymousType = true)] + public class GeneralSettings : IGeneralSettings, IEquatable + { + public DisplayLanguageSetting Language { get; set; } + public bool CanShowSplash { get; set; } + public bool CanCheckVersion { get; set; } + public bool CompileBeforeParse { get; set; } + public bool IsSmartIndenterPrompted { get; set; } + public bool IsAutoSaveEnabled { get; set; } + public int AutoSavePeriod { get; set; } + + private int _logLevel; + public int MinimumLogLevel + { + get => _logLevel; + set + { + if (value < LogLevelHelper.MinLogLevel()) + { + _logLevel = LogLevelHelper.MinLogLevel(); + } + else if (value > LogLevelHelper.MaxLogLevel()) + { + _logLevel = LogLevelHelper.MaxLogLevel(); + } + else + { + _logLevel = value; + } + } + } + + public List EnableExperimentalFeatures { get; set; } = new List(); + + public GeneralSettings() + { + //Enforce non-default default value for members + //In other words, if we want a bool to default to + //true, it must be set here for correct behavior + CompileBeforeParse = true; + } + + public bool Equals(GeneralSettings other) + { + return other != null && + Language.Equals(other.Language) && + CanShowSplash == other.CanShowSplash && + CanCheckVersion == other.CanCheckVersion && + CompileBeforeParse == other.CompileBeforeParse && + IsSmartIndenterPrompted == other.IsSmartIndenterPrompted && + IsAutoSaveEnabled == other.IsAutoSaveEnabled && + AutoSavePeriod == other.AutoSavePeriod && + MinimumLogLevel == other.MinimumLogLevel && + EnableExperimentalFeatures.All(a => other.EnableExperimentalFeatures.Contains(a)) && + EnableExperimentalFeatures.Count == other.EnableExperimentalFeatures.Count; + } + } +} \ No newline at end of file diff --git a/Rubberduck.Core/Settings/HotkeyConfigProvider.cs b/Rubberduck.Core/Settings/HotkeyConfigProvider.cs new file mode 100644 index 0000000000..9826ddd975 --- /dev/null +++ b/Rubberduck.Core/Settings/HotkeyConfigProvider.cs @@ -0,0 +1,41 @@ +using System.Collections.Generic; +using Rubberduck.SettingsProvider; + +namespace Rubberduck.Settings +{ + public class HotkeyConfigProvider : IConfigProvider + { + private readonly IPersistanceService _persister; + private readonly IEnumerable _defaultHotkeys; + + public HotkeyConfigProvider(IPersistanceService persister) + { + _persister = persister; + _defaultHotkeys = new DefaultSettings().Defaults; + } + + public HotkeySettings Create() + { + var prototype = new HotkeySettings(_defaultHotkeys); + + // Loaded settings don't contain defaults, so we need to use the `Settings` property to combine user settings with defaults. + var loaded = _persister.Load(prototype); + if (loaded != null) + { + prototype.Settings = loaded.Settings; + } + + return prototype; + } + + public HotkeySettings CreateDefaults() + { + return new HotkeySettings(_defaultHotkeys); + } + + public void Save(HotkeySettings settings) + { + _persister.Save(settings); + } + } +} diff --git a/RetailCoder.VBE/Settings/HotkeySetting.cs b/Rubberduck.Core/Settings/HotkeySetting.cs similarity index 79% rename from RetailCoder.VBE/Settings/HotkeySetting.cs rename to Rubberduck.Core/Settings/HotkeySetting.cs index 6c0fecc985..f105a77958 100644 --- a/RetailCoder.VBE/Settings/HotkeySetting.cs +++ b/Rubberduck.Core/Settings/HotkeySetting.cs @@ -1,16 +1,17 @@ using System.Globalization; using System.Xml.Serialization; using Rubberduck.UI; +using System.Configuration; namespace Rubberduck.Settings { + [SettingsSerializeAs(SettingsSerializeAs.Xml)] public class HotkeySetting { public const string KeyModifierAlt = "%"; public const string KeyModifierCtrl = "^"; public const string KeyModifierShift = "+"; - public string Name { get; set; } public string Key1 { get; set; } /// /// For 2-step hotkeys, the 2nd key to press. Note: hidden until 2-step hotkeys are an actual thing. @@ -21,11 +22,12 @@ public class HotkeySetting public bool HasAltModifier { get; set; } public bool HasCtrlModifier { get; set; } + public string CommandTypeName { get; set; } + + public bool IsValid => HasAltModifier || HasCtrlModifier; + [XmlIgnore] - public string Prompt - { - get { return RubberduckUI.ResourceManager.GetString("HotkeyDescription_" + Name, CultureInfo.CurrentUICulture); } - } + public string Prompt => RubberduckUI.ResourceManager.GetString($"CommandDescription_{CommandTypeName}", CultureInfo.CurrentUICulture); public override string ToString() { @@ -38,10 +40,8 @@ public override string ToString() public override bool Equals(object obj) { - var hotkey = obj as HotkeySetting; - - return hotkey != null && - hotkey.Name == Name && + return obj is HotkeySetting hotkey && + hotkey.CommandTypeName == CommandTypeName && hotkey.Key1 == Key1 && hotkey.Key2 == Key2 && hotkey.HasAltModifier == HasAltModifier && @@ -54,7 +54,7 @@ public override int GetHashCode() { unchecked { - var hashCode = (Name != null ? Name.GetHashCode() : 0); + var hashCode = (CommandTypeName != null ? CommandTypeName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Key1 != null ? Key1.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Key2 != null ? Key2.GetHashCode() : 0); hashCode = (hashCode * 397) ^ HasShiftModifier.GetHashCode(); diff --git a/Rubberduck.Core/Settings/HotkeySettings.cs b/Rubberduck.Core/Settings/HotkeySettings.cs new file mode 100644 index 0000000000..ee2bf7fc75 --- /dev/null +++ b/Rubberduck.Core/Settings/HotkeySettings.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Rubberduck.Common.Hotkeys; +using Rubberduck.Parsing.VBA; + +namespace Rubberduck.Settings +{ + public interface IHotkeySettings + { + HotkeySetting[] Settings { get; set; } + } + + public class HotkeySettings : IHotkeySettings, IEquatable + { + private readonly IEnumerable _defaultSettings; + private HashSet _settings = new HashSet(); + + public HotkeySetting[] Settings + { + get => _settings?.ToArray(); + set + { + // Enable loading user settings during deserialization + if (_defaultSettings == null) + { + if (value != null) + { + AddUnique(value); + } + + return; + } + + var defaults = _defaultSettings.ToArray(); + + if (value == null || value.Length == 0) + { + _settings = new HashSet(defaults); + return; + } + + _settings = new HashSet(); + + var incoming = value.ToList(); + //Make sure settings are valid to keep trash out of the config file. + var hotkeyCommandTypeNames = defaults.Select(h => h.CommandTypeName); + incoming.RemoveAll(h => !hotkeyCommandTypeNames.Contains(h.CommandTypeName) || !IsValid(h)); + + AddUnique(incoming); + + //Merge any hotkeys that weren't found in the input. + foreach (var setting in defaults.Where(setting => _settings.FirstOrDefault(s => s.CommandTypeName.Equals(setting.CommandTypeName)) == null)) + { + setting.IsEnabled &= !IsDuplicate(setting); + _settings.Add(setting); + } + } + } + + /// + /// Default constructor required for XML serialization. + /// + public HotkeySettings() + { + } + + public HotkeySettings(IEnumerable defaultSettings) + { + _defaultSettings = defaultSettings; + _settings = defaultSettings.ToHashSet(); + } + + public bool Equals(HotkeySettings other) + { + return other != null && Settings.SequenceEqual(other.Settings); + } + + private static bool IsValid(HotkeySetting candidate) + { + //This feels a bit sleazy... + try + { + // ReSharper disable once UnusedVariable + var test = new Hotkey(new IntPtr(), candidate.ToString(), null); + return true; + } + catch + { + return false; + } + } + + private void AddUnique(IEnumerable settings) + { + //Only take the first setting if multiple definitions are found. + foreach (var setting in settings.GroupBy(s => s.CommandTypeName).Select(hotkey => hotkey.First())) + { + //Only allow one hotkey to be enabled with the same key combination. + setting.IsEnabled &= !IsDuplicate(setting); + _settings.Add(setting); + } + } + + private bool IsDuplicate(HotkeySetting candidate) + { + return _settings.FirstOrDefault( + s => + s.Key1 == candidate.Key1 && + s.Key2 == candidate.Key2 && + s.HasAltModifier == candidate.HasAltModifier && + s.HasCtrlModifier == candidate.HasCtrlModifier && + s.HasShiftModifier == candidate.HasShiftModifier) != null; + } + } +} diff --git a/RetailCoder.VBE/Settings/IConfigurationService.cs b/Rubberduck.Core/Settings/IConfigurationService.cs similarity index 100% rename from RetailCoder.VBE/Settings/IConfigurationService.cs rename to Rubberduck.Core/Settings/IConfigurationService.cs diff --git a/Rubberduck.Core/Settings/MinimumLogLevel.cs b/Rubberduck.Core/Settings/MinimumLogLevel.cs new file mode 100644 index 0000000000..75487c54e7 --- /dev/null +++ b/Rubberduck.Core/Settings/MinimumLogLevel.cs @@ -0,0 +1,18 @@ +using System.Globalization; +using Rubberduck.UI; + +namespace Rubberduck.Settings +{ + public sealed class MinimumLogLevel + { + public MinimumLogLevel(int ordinal, string logLevelName) + { + Ordinal = ordinal; + Name = RubberduckUI.ResourceManager.GetString("GeneralSettings_" + logLevelName + "LogLevel", CultureInfo.CurrentUICulture); + } + + public int Ordinal { get; } + + public string Name { get; } + } +} diff --git a/RetailCoder.VBE/Settings/ToDoListConfigProvider.cs b/Rubberduck.Core/Settings/ToDoListConfigProvider.cs similarity index 65% rename from RetailCoder.VBE/Settings/ToDoListConfigProvider.cs rename to Rubberduck.Core/Settings/ToDoListConfigProvider.cs index bf79d7f5cd..e874c4d9c6 100644 --- a/RetailCoder.VBE/Settings/ToDoListConfigProvider.cs +++ b/Rubberduck.Core/Settings/ToDoListConfigProvider.cs @@ -1,25 +1,28 @@ -using Rubberduck.SettingsProvider; +using System.Collections.Generic; +using Rubberduck.SettingsProvider; namespace Rubberduck.Settings { public class ToDoListConfigProvider : IConfigProvider { private readonly IPersistanceService _persister; + private readonly IEnumerable _defaultMarkers; public ToDoListConfigProvider(IPersistanceService persister) { _persister = persister; + _defaultMarkers = new DefaultSettings().Defaults; } public ToDoListSettings Create() { - var prototype = new ToDoListSettings(); + var prototype = new ToDoListSettings(_defaultMarkers); return _persister.Load(prototype) ?? prototype; } public ToDoListSettings CreateDefaults() { - return new ToDoListSettings(); + return new ToDoListSettings(_defaultMarkers); } public void Save(ToDoListSettings settings) diff --git a/RetailCoder.VBE/Settings/ToDoListSettings.cs b/Rubberduck.Core/Settings/ToDoListSettings.cs similarity index 67% rename from RetailCoder.VBE/Settings/ToDoListSettings.cs rename to Rubberduck.Core/Settings/ToDoListSettings.cs index d866d52df3..ae1c20fc9c 100644 --- a/RetailCoder.VBE/Settings/ToDoListSettings.cs +++ b/Rubberduck.Core/Settings/ToDoListSettings.cs @@ -2,11 +2,10 @@ using System.Collections.Generic; using System.Linq; using System.Xml.Serialization; -using Rubberduck.UI; namespace Rubberduck.Settings { - interface IToDoListSettings + internal interface IToDoListSettings { ToDoMarker[] ToDoMarkers { get; set; } } @@ -19,7 +18,7 @@ public class ToDoListSettings : IToDoListSettings, IEquatable [XmlArrayItem("ToDoMarker", IsNullable = false)] public ToDoMarker[] ToDoMarkers { - get { return _markers.ToArray(); } + get => _markers.ToArray(); set { //Only take the first marker if there are duplicates. @@ -27,18 +26,16 @@ public ToDoMarker[] ToDoMarkers } } + /// + /// Default constructor required for XML serialization. + /// public ToDoListSettings() { - var note = new ToDoMarker(RubberduckUI.TodoMarkerNote); - var todo = new ToDoMarker(RubberduckUI.TodoMarkerTodo); - var bug = new ToDoMarker(RubberduckUI.TodoMarkerBug); - - ToDoMarkers = new[] { note, todo, bug }; } - public ToDoListSettings(IEnumerable markers) + public ToDoListSettings(IEnumerable defaultMarkers) { - _markers = markers; + _markers = defaultMarkers; } public bool Equals(ToDoListSettings other) diff --git a/RetailCoder.VBE/Settings/ToDoMarkers.cs b/Rubberduck.Core/Settings/ToDoMarkers.cs similarity index 86% rename from RetailCoder.VBE/Settings/ToDoMarkers.cs rename to Rubberduck.Core/Settings/ToDoMarkers.cs index c2e34a94aa..63e996f372 100644 --- a/RetailCoder.VBE/Settings/ToDoMarkers.cs +++ b/Rubberduck.Core/Settings/ToDoMarkers.cs @@ -1,4 +1,5 @@ using System; +using System.Configuration; using System.Xml.Serialization; namespace Rubberduck.Settings @@ -8,6 +9,7 @@ public interface IToDoMarker string Text { get; set; } } + [SettingsSerializeAs(SettingsSerializeAs.Xml)] [XmlType(AnonymousType = true)] public class ToDoMarker : IToDoMarker { @@ -35,7 +37,7 @@ public ToDoMarker(string text, TodoPriority priority) : this(text) { } - /// Convert this object into a string representation. Over-riden for easy databinding. + /// Convert this object into a string representation. Overriden for easy databinding. /// The Text property. public override string ToString() { @@ -44,9 +46,10 @@ public override string ToString() public override bool Equals(object obj) { - var other = obj as ToDoMarker; - - if (other == null) { return false; } + if (!(obj is ToDoMarker other)) + { + return false; + } return Text == other.Text; } diff --git a/RetailCoder.VBE/Settings/UnitTestConfigProvider.cs b/Rubberduck.Core/Settings/UnitTestConfigProvider.cs similarity index 71% rename from RetailCoder.VBE/Settings/UnitTestConfigProvider.cs rename to Rubberduck.Core/Settings/UnitTestConfigProvider.cs index de1e84dfab..41063e45c0 100644 --- a/RetailCoder.VBE/Settings/UnitTestConfigProvider.cs +++ b/Rubberduck.Core/Settings/UnitTestConfigProvider.cs @@ -5,21 +5,22 @@ namespace Rubberduck.Settings public class UnitTestConfigProvider : IConfigProvider { private readonly IPersistanceService _persister; + private readonly UnitTestSettings _defaultSettings; public UnitTestConfigProvider(IPersistanceService persister) { _persister = persister; + _defaultSettings = new DefaultSettings().Default; } public UnitTestSettings Create() { - var prototype = new UnitTestSettings(); - return _persister.Load(prototype) ?? prototype; + return _persister.Load(_defaultSettings) ?? _defaultSettings; } public UnitTestSettings CreateDefaults() { - return new UnitTestSettings(); + return _defaultSettings; } public void Save(UnitTestSettings settings) diff --git a/RetailCoder.VBE/Settings/UnitTestSettings.cs b/Rubberduck.Core/Settings/UnitTestSettings.cs similarity index 90% rename from RetailCoder.VBE/Settings/UnitTestSettings.cs rename to Rubberduck.Core/Settings/UnitTestSettings.cs index e64ed07021..ff197be5f5 100644 --- a/RetailCoder.VBE/Settings/UnitTestSettings.cs +++ b/Rubberduck.Core/Settings/UnitTestSettings.cs @@ -1,4 +1,5 @@ using System; +using System.Configuration; using System.Xml.Serialization; namespace Rubberduck.Settings @@ -25,13 +26,15 @@ public interface IUnitTestSettings bool DefaultTestStubInNewModule { get; set; } } + [SettingsSerializeAs(SettingsSerializeAs.Xml)] [XmlType(AnonymousType = true)] public class UnitTestSettings : IUnitTestSettings, IEquatable { + /// + /// Default constructor required for XML serialization. + /// public UnitTestSettings() - : this(BindingMode.LateBinding, AssertMode.StrictAssert, true, true, false) { - //empty constructor needed for serialization } public UnitTestSettings(BindingMode bindingMode, AssertMode assertMode, bool moduleInit, bool methodInit, bool defaultTestStub) diff --git a/RetailCoder.VBE/Settings/UserSettings.cs b/Rubberduck.Core/Settings/UserSettings.cs similarity index 100% rename from RetailCoder.VBE/Settings/UserSettings.cs rename to Rubberduck.Core/Settings/UserSettings.cs diff --git a/RetailCoder.VBE/Settings/WhitelistedIdentifierSetting.cs b/Rubberduck.Core/Settings/WhitelistedIdentifierSetting.cs similarity index 100% rename from RetailCoder.VBE/Settings/WhitelistedIdentifierSetting.cs rename to Rubberduck.Core/Settings/WhitelistedIdentifierSetting.cs diff --git a/RetailCoder.VBE/Settings/WindowConfigProvider.cs b/Rubberduck.Core/Settings/WindowConfigProvider.cs similarity index 71% rename from RetailCoder.VBE/Settings/WindowConfigProvider.cs rename to Rubberduck.Core/Settings/WindowConfigProvider.cs index 7eb6424aea..6bbade33a4 100644 --- a/RetailCoder.VBE/Settings/WindowConfigProvider.cs +++ b/Rubberduck.Core/Settings/WindowConfigProvider.cs @@ -5,21 +5,22 @@ namespace Rubberduck.Settings public class WindowConfigProvider : IConfigProvider { private readonly IPersistanceService _persister; + private readonly WindowSettings _defaultSettings; public WindowConfigProvider(IPersistanceService persister) { _persister = persister; + _defaultSettings = new DefaultSettings().Default; } public WindowSettings Create() { - var prototype = new WindowSettings(); - return _persister.Load(prototype) ?? prototype; + return _persister.Load(_defaultSettings) ?? _defaultSettings; } public WindowSettings CreateDefaults() { - return new WindowSettings(); + return _defaultSettings; } public void Save(WindowSettings settings) diff --git a/RetailCoder.VBE/Settings/WindowSettings.cs b/Rubberduck.Core/Settings/WindowSettings.cs similarity index 68% rename from RetailCoder.VBE/Settings/WindowSettings.cs rename to Rubberduck.Core/Settings/WindowSettings.cs index 4413b677d1..c6c0cc96bb 100644 --- a/RetailCoder.VBE/Settings/WindowSettings.cs +++ b/Rubberduck.Core/Settings/WindowSettings.cs @@ -1,9 +1,9 @@ using System; +using System.Configuration; using System.Xml.Serialization; using Rubberduck.UI; using Rubberduck.UI.CodeExplorer; using Rubberduck.UI.Inspections; -using Rubberduck.UI.SourceControl; using Rubberduck.UI.ToDoItems; using Rubberduck.UI.UnitTesting; @@ -13,7 +13,6 @@ public interface IWindowSettings { bool CodeExplorerVisibleOnStartup { get; set; } bool CodeInspectionsVisibleOnStartup { get; set; } - bool SourceControlVisibleOnStartup { get; set; } bool TestExplorerVisibleOnStartup { get; set; } bool TodoExplorerVisibleOnStartup { get; set; } @@ -24,23 +23,23 @@ public interface IWindowSettings bool IsWindowVisible(DockableToolwindowPresenter candidate); } + [SettingsSerializeAs(SettingsSerializeAs.Xml)] [XmlType(AnonymousType = true)] public class WindowSettings : IWindowSettings, IEquatable { + /// + /// Default constructor required for XML serialization. Initializes all settings to false. + /// public WindowSettings() - : this(false, false, false, false, false, true, false, false) - // SortByName and SortByLocation are opposites; SortByName should start as True. { - //empty constructor needed for serialization } public WindowSettings(bool codeExplorerVisibleOnStartup, bool codeInspectionsVisibleOnStartup, - bool sourceControlVisibleOnStartup, bool testExplorerVisibleOnStartup, bool todoExplorerVisibleOnStartup, + bool testExplorerVisibleOnStartup, bool todoExplorerVisibleOnStartup, bool codeExplorer_SortByName, bool codeExplorer_SortByCodeOrder, bool codeExplorer_GroupByType) { CodeExplorerVisibleOnStartup = codeExplorerVisibleOnStartup; CodeInspectionsVisibleOnStartup = codeInspectionsVisibleOnStartup; - SourceControlVisibleOnStartup = sourceControlVisibleOnStartup; TestExplorerVisibleOnStartup = testExplorerVisibleOnStartup; TodoExplorerVisibleOnStartup = todoExplorerVisibleOnStartup; @@ -51,7 +50,6 @@ public WindowSettings(bool codeExplorerVisibleOnStartup, bool codeInspectionsVis public bool CodeExplorerVisibleOnStartup { get; set; } public bool CodeInspectionsVisibleOnStartup { get; set; } - public bool SourceControlVisibleOnStartup { get; set; } public bool TestExplorerVisibleOnStartup { get; set; } public bool TodoExplorerVisibleOnStartup { get; set; } @@ -63,28 +61,20 @@ public bool IsWindowVisible(DockableToolwindowPresenter candidate) { //I'm sure there's a better way to do this, because this is a lazy-ass way to do it. //We're injecting into the base class, so check the derived class: - if (candidate is CodeExplorerDockablePresenter) + switch (candidate) { - return CodeExplorerVisibleOnStartup; + case CodeExplorerDockablePresenter _: + return CodeExplorerVisibleOnStartup; + case InspectionResultsDockablePresenter _: + return CodeInspectionsVisibleOnStartup; + case TestExplorerDockablePresenter _: + return TestExplorerVisibleOnStartup; + case ToDoExplorerDockablePresenter _: + return TodoExplorerVisibleOnStartup; + default: + //Oh. Hello. I have no clue who you are... + return false; } - if (candidate is InspectionResultsDockablePresenter) - { - return CodeInspectionsVisibleOnStartup; - } - if (candidate is SourceControlDockablePresenter) - { - return SourceControlVisibleOnStartup; - } - if (candidate is TestExplorerDockablePresenter) - { - return TestExplorerVisibleOnStartup; - } - if (candidate is ToDoExplorerDockablePresenter) - { - return TodoExplorerVisibleOnStartup; - } - //Oh. Hello. I have no clue who you are... - return false; } public bool Equals(WindowSettings other) @@ -92,7 +82,6 @@ public bool Equals(WindowSettings other) return other != null && CodeExplorerVisibleOnStartup == other.CodeExplorerVisibleOnStartup && CodeInspectionsVisibleOnStartup == other.CodeInspectionsVisibleOnStartup && - SourceControlVisibleOnStartup == other.SourceControlVisibleOnStartup && TestExplorerVisibleOnStartup == other.TestExplorerVisibleOnStartup && TodoExplorerVisibleOnStartup == other.TodoExplorerVisibleOnStartup && CodeExplorer_SortByName == other.CodeExplorer_SortByName && diff --git a/RetailCoder.VBE/ToDoItems/ToDoItem.cs b/Rubberduck.Core/ToDoItems/ToDoItem.cs similarity index 50% rename from RetailCoder.VBE/ToDoItems/ToDoItem.cs rename to Rubberduck.Core/ToDoItems/ToDoItem.cs index 10fc0b3789..00e9ba302e 100644 --- a/RetailCoder.VBE/ToDoItems/ToDoItem.cs +++ b/Rubberduck.Core/ToDoItems/ToDoItem.cs @@ -12,43 +12,40 @@ namespace Rubberduck.ToDoItems /// public class ToDoItem : INavigateSource, IExportable { - private readonly string _description; - public string Description { get { return _description; } } + public string Description { get; } - private readonly string _type; - public string Type { get { return _type; } } + public string Type { get; } - private readonly QualifiedSelection _selection; - public QualifiedSelection Selection { get { return _selection; } } + public QualifiedSelection Selection { get; } public ToDoItem(string markerText, CommentNode comment) { - _description = comment.CommentText; - _selection = comment.QualifiedSelection; - _type = markerText; + Description = comment.CommentText; + Selection = comment.QualifiedSelection; + Type = markerText; } public NavigateCodeEventArgs GetNavigationArgs() { - return new NavigateCodeEventArgs(_selection); + return new NavigateCodeEventArgs(Selection); } public object[] ToArray() { - var module = _selection.QualifiedName; - return new object[] { _type, Description, module.ProjectName, module.ComponentName, _selection.Selection.StartLine, _selection.Selection.StartColumn }; + var module = Selection.QualifiedName; + return new object[] { Type, Description, module.ProjectName, module.ComponentName, Selection.Selection.StartLine, Selection.Selection.StartColumn }; } public string ToClipboardString() { - var module = _selection.QualifiedName; + var module = Selection.QualifiedName; return string.Format( RubberduckUI.ToDoExplorerToDoItemFormat, - _type, - _description, + Type, + Description, module.ProjectName, module.ComponentName, - _selection.Selection.StartLine); + Selection.Selection.StartLine); } } } diff --git a/RetailCoder.VBE/UI/About/AboutControl.xaml b/Rubberduck.Core/UI/About/AboutControl.xaml similarity index 87% rename from RetailCoder.VBE/UI/About/AboutControl.xaml rename to Rubberduck.Core/UI/About/AboutControl.xaml index 91e8817e9f..49330df009 100644 --- a/RetailCoder.VBE/UI/About/AboutControl.xaml +++ b/Rubberduck.Core/UI/About/AboutControl.xaml @@ -18,7 +18,7 @@ - + @@ -27,8 +27,24 @@ MouseLeftButtonDown="CopyVersionInfo_MouseLeftButtonDown"> + + + +