Skip to content
This repository was archived by the owner on Aug 9, 2025. It is now read-only.

Commit 9442b5d

Browse files
committed
Cleanup - remove references, reuse code.
1 parent 1d13fbb commit 9442b5d

File tree

3 files changed

+27
-46
lines changed

3 files changed

+27
-46
lines changed

CPPCheckPlugin/CPPCheckPlugin.csproj

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,11 @@
5353
<Reference Include="Microsoft.VisualStudio.Shell.Interop.11.0">
5454
<EmbedInteropTypes>true</EmbedInteropTypes>
5555
</Reference>
56-
<Reference Include="Microsoft.VisualStudio.TextManager.Interop" />
5756
<Reference Include="Microsoft.VisualStudio.Shell.11.0" />
5857
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0" />
5958
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.11.0" />
6059
<Reference Include="System" />
61-
<Reference Include="System.Core" />
62-
<Reference Include="System.Data" />
6360
<Reference Include="System.Design" />
64-
<Reference Include="System.Drawing" />
65-
<Reference Include="System.Management" />
6661
<Reference Include="System.Windows.Forms" />
6762
<Reference Include="System.Xml" />
6863
<Reference Include="PresentationCore" />
@@ -80,33 +75,6 @@
8075
<Isolated>False</Isolated>
8176
<EmbedInteropTypes>False</EmbedInteropTypes>
8277
</COMReference>
83-
<COMReference Include="EnvDTE100">
84-
<Guid>{26AD1324-4B7C-44BC-84F8-B86AED45729F}</Guid>
85-
<VersionMajor>10</VersionMajor>
86-
<VersionMinor>0</VersionMinor>
87-
<Lcid>0</Lcid>
88-
<WrapperTool>primary</WrapperTool>
89-
<Isolated>False</Isolated>
90-
<EmbedInteropTypes>False</EmbedInteropTypes>
91-
</COMReference>
92-
<COMReference Include="EnvDTE80">
93-
<Guid>{1A31287A-4D7D-413E-8E32-3B374931BD89}</Guid>
94-
<VersionMajor>8</VersionMajor>
95-
<VersionMinor>0</VersionMinor>
96-
<Lcid>0</Lcid>
97-
<WrapperTool>primary</WrapperTool>
98-
<Isolated>False</Isolated>
99-
<EmbedInteropTypes>False</EmbedInteropTypes>
100-
</COMReference>
101-
<COMReference Include="EnvDTE90">
102-
<Guid>{2CE2370E-D744-4936-A090-3FFFE667B0E1}</Guid>
103-
<VersionMajor>9</VersionMajor>
104-
<VersionMinor>0</VersionMinor>
105-
<Lcid>0</Lcid>
106-
<WrapperTool>primary</WrapperTool>
107-
<Isolated>False</Isolated>
108-
<EmbedInteropTypes>False</EmbedInteropTypes>
109-
</COMReference>
11078
<COMReference Include="Microsoft.VisualStudio.CommandBars">
11179
<Guid>{1CBA492E-7263-47BB-87FE-639000619B15}</Guid>
11280
<VersionMajor>8</VersionMajor>
@@ -189,9 +157,6 @@
189157
<Generator>MSBuild:Compile</Generator>
190158
</Page>
191159
</ItemGroup>
192-
<ItemGroup>
193-
<WCFMetadata Include="Service References\" />
194-
</ItemGroup>
195160
<PropertyGroup>
196161
<UseCodebase>true</UseCodebase>
197162
</PropertyGroup>

CPPCheckPlugin/CPPCheckPluginPackage.cs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ protected override void Initialize()
3838
_eventsHandlers = _dte.Events.DocumentEvents;
3939
_eventsHandlers.DocumentSaved += documentSaved;
4040

41-
{
42-
var outputWindow = (OutputWindow)_dte.GetOutputWindow().Object;
43-
_fileAnalysisOutputPane = outputWindow.OutputWindowPanes.Add("[cppcheck] File analysis output");
44-
}
41+
_fileAnalysisOutputPane = _dte.AddOutputWindowPane("[cppcheck] File analysis output");
4542

4643
_analyzers.Add(new AnalyzerCppcheck());
4744

@@ -63,20 +60,31 @@ protected override void Initialize()
6360
}
6461
}
6562

63+
protected override void Dispose(bool disposing)
64+
{
65+
cleanup();
66+
base.Dispose(disposing);
67+
}
68+
6669
protected override int QueryClose(out bool canClose)
6770
{
6871
int result = base.QueryClose(out canClose);
6972
if (canClose)
7073
{
71-
foreach (var item in _analyzers)
72-
{
73-
item.Dispose();
74-
}
74+
cleanup();
7575
}
7676
return result;
7777
}
7878
#endregion
7979

80+
private void cleanup()
81+
{
82+
foreach (var item in _analyzers)
83+
{
84+
item.Dispose();
85+
}
86+
}
87+
8088
private void onCheckCurrentProjectRequested(object sender, EventArgs e)
8189
{
8290
checkCurrentProject();
@@ -138,7 +146,8 @@ private void checkCurrentProject()
138146
return;
139147
}
140148
currentConfig = ((Project)o).ConfigurationManager.ActiveConfiguration;
141-
foreach (dynamic file in project.Files)
149+
dynamic projectFiles = project.Files;
150+
foreach (dynamic file in projectFiles)
142151
{
143152
Type fileObjectType = file.GetType();
144153
// Automatic property binding fails with VS2013 for some unknown reason, using Reflection directly instead.
@@ -164,8 +173,7 @@ private void checkCurrentProject()
164173

165174
if (_projectAnalysisOutputPane == null)
166175
{
167-
var outputWindow = (OutputWindow)_dte.GetOutputWindow().Object;
168-
_projectAnalysisOutputPane = outputWindow.OutputWindowPanes.Add("[cppcheck] Project analysis output");
176+
_projectAnalysisOutputPane = _dte.AddOutputWindowPane("[cppcheck] Project analysis output");
169177
}
170178

171179
runAnalysis(files, currentConfig, true, _projectAnalysisOutputPane);
@@ -181,6 +189,7 @@ private void runAnalysis(SourceFile file, Configuration currentConfig, bool brin
181189
private void runAnalysis(List<SourceFile> files, Configuration currentConfig, bool bringOutputToFrontAfterAnalysis, OutputWindowPane outputPane)
182190
{
183191
Debug.Assert(outputPane != null);
192+
Debug.Assert(currentConfig != null);
184193
outputPane.Clear();
185194
var currentConfigName = currentConfig.ConfigurationName;
186195
foreach (var analyzer in _analyzers)

CPPCheckPlugin/DTEHelper.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ public static Window GetOutputWindow(this DTE dte)
88
{
99
return dte.Windows.Item(Constants.vsWindowKindOutput);
1010
}
11+
12+
public static OutputWindowPane AddOutputWindowPane(this DTE dte, string name)
13+
{
14+
var outputWindow = (OutputWindow)dte.GetOutputWindow().Object;
15+
var newPane = outputWindow.OutputWindowPanes.Add(name);
16+
return newPane;
17+
}
1118
}
1219
}
1320

0 commit comments

Comments
 (0)