Skip to content

Commit

Permalink
Merge pull request #35 from Dmitry-Me/overridedisposablefrompackage
Browse files Browse the repository at this point in the history
Cleanup - remove references, reuse code.
  • Loading branch information
Dmitry-Me committed Feb 17, 2014
2 parents 1d13fbb + 9442b5d commit e65b2a3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 46 deletions.
35 changes: 0 additions & 35 deletions CPPCheckPlugin/CPPCheckPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,11 @@
<Reference Include="Microsoft.VisualStudio.Shell.Interop.11.0">
<EmbedInteropTypes>true</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.VisualStudio.TextManager.Interop" />
<Reference Include="Microsoft.VisualStudio.Shell.11.0" />
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0" />
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.11.0" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Management" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="PresentationCore" />
Expand All @@ -80,33 +75,6 @@
<Isolated>False</Isolated>
<EmbedInteropTypes>False</EmbedInteropTypes>
</COMReference>
<COMReference Include="EnvDTE100">
<Guid>{26AD1324-4B7C-44BC-84F8-B86AED45729F}</Guid>
<VersionMajor>10</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>False</EmbedInteropTypes>
</COMReference>
<COMReference Include="EnvDTE80">
<Guid>{1A31287A-4D7D-413E-8E32-3B374931BD89}</Guid>
<VersionMajor>8</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>False</EmbedInteropTypes>
</COMReference>
<COMReference Include="EnvDTE90">
<Guid>{2CE2370E-D744-4936-A090-3FFFE667B0E1}</Guid>
<VersionMajor>9</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>False</EmbedInteropTypes>
</COMReference>
<COMReference Include="Microsoft.VisualStudio.CommandBars">
<Guid>{1CBA492E-7263-47BB-87FE-639000619B15}</Guid>
<VersionMajor>8</VersionMajor>
Expand Down Expand Up @@ -189,9 +157,6 @@
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<PropertyGroup>
<UseCodebase>true</UseCodebase>
</PropertyGroup>
Expand Down
31 changes: 20 additions & 11 deletions CPPCheckPlugin/CPPCheckPluginPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ protected override void Initialize()
_eventsHandlers = _dte.Events.DocumentEvents;
_eventsHandlers.DocumentSaved += documentSaved;

{
var outputWindow = (OutputWindow)_dte.GetOutputWindow().Object;
_fileAnalysisOutputPane = outputWindow.OutputWindowPanes.Add("[cppcheck] File analysis output");
}
_fileAnalysisOutputPane = _dte.AddOutputWindowPane("[cppcheck] File analysis output");

_analyzers.Add(new AnalyzerCppcheck());

Expand All @@ -63,20 +60,31 @@ protected override void Initialize()
}
}

protected override void Dispose(bool disposing)
{
cleanup();
base.Dispose(disposing);
}

protected override int QueryClose(out bool canClose)
{
int result = base.QueryClose(out canClose);
if (canClose)
{
foreach (var item in _analyzers)
{
item.Dispose();
}
cleanup();
}
return result;
}
#endregion

private void cleanup()
{
foreach (var item in _analyzers)
{
item.Dispose();
}
}

private void onCheckCurrentProjectRequested(object sender, EventArgs e)
{
checkCurrentProject();
Expand Down Expand Up @@ -138,7 +146,8 @@ private void checkCurrentProject()
return;
}
currentConfig = ((Project)o).ConfigurationManager.ActiveConfiguration;
foreach (dynamic file in project.Files)
dynamic projectFiles = project.Files;
foreach (dynamic file in projectFiles)
{
Type fileObjectType = file.GetType();
// Automatic property binding fails with VS2013 for some unknown reason, using Reflection directly instead.
Expand All @@ -164,8 +173,7 @@ private void checkCurrentProject()

if (_projectAnalysisOutputPane == null)
{
var outputWindow = (OutputWindow)_dte.GetOutputWindow().Object;
_projectAnalysisOutputPane = outputWindow.OutputWindowPanes.Add("[cppcheck] Project analysis output");
_projectAnalysisOutputPane = _dte.AddOutputWindowPane("[cppcheck] Project analysis output");
}

runAnalysis(files, currentConfig, true, _projectAnalysisOutputPane);
Expand All @@ -181,6 +189,7 @@ private void runAnalysis(SourceFile file, Configuration currentConfig, bool brin
private void runAnalysis(List<SourceFile> files, Configuration currentConfig, bool bringOutputToFrontAfterAnalysis, OutputWindowPane outputPane)
{
Debug.Assert(outputPane != null);
Debug.Assert(currentConfig != null);
outputPane.Clear();
var currentConfigName = currentConfig.ConfigurationName;
foreach (var analyzer in _analyzers)
Expand Down
7 changes: 7 additions & 0 deletions CPPCheckPlugin/DTEHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ public static Window GetOutputWindow(this DTE dte)
{
return dte.Windows.Item(Constants.vsWindowKindOutput);
}

public static OutputWindowPane AddOutputWindowPane(this DTE dte, string name)
{
var outputWindow = (OutputWindow)dte.GetOutputWindow().Object;
var newPane = outputWindow.OutputWindowPanes.Add(name);
return newPane;
}
}
}

0 comments on commit e65b2a3

Please sign in to comment.