Permalink
Browse files

Fix conflict with multiple JetBrains products installed

The JetBrains set of products reuses at a code level several VS
components.  In particular it reuses the tagging infrastructure between
R#, dotTrace and dotCover.

The VsVim external edit monitoring service was only doing a name match
on the tagger infrastructure.  When mulitple JetBrains products were
installed it would pick the first it saw, which was almost never R#, and
listen to that tagger for rename events.  Since it wasn't the R# tagger
it didn't get the notification and R# support appeared to be broken.

This change alters the code to do a smarter match.   It's smarter but
more restrictive.  If R# changes the assembly name between versions then
it will break VsVim.  Dev10 is in the name of the assembly and it's
unclear if it's referring to the Dev10 editor or specifically Visual
Studio 2010.  I tried peaking at the R# 7.0 support which includes Dev11
but the link is currently down.  Added some code to fall back to a less
restrictive match in case a strong one wasn't found.

closes #635
  • Loading branch information...
1 parent cf6c800 commit 92541d27f9fa67fa8de7367070eb5b1b63468a73 @jaredpar committed May 30, 2012
@@ -19,12 +19,13 @@ internal sealed class ResharperExternalEditAdapter : IExternalEditAdapter, IResh
internal const string ExternalEditAttribute1 = "ReSharper Template Editor Template Keyword";
internal const string ExternalEditAttribute2 = "ReSharper LiveTemplates Current HotSpot";
internal const string ExternalEditAttribute3 = "ReSharper LiveTemplates Current HotSpot mirror";
+ internal const string ResharperTaggerProviderName = "VsDocumentMarkupTaggerProvider";
+ internal const string ResharperAssembylName = "JetBrains.Platform.ReSharper.VsIntegration.DevTen";
private static readonly Guid Resharper5Guid = new Guid("0C6E6407-13FC-4878-869A-C8B4016C57FE");
- private static readonly string ResharperTaggerName = "VsDocumentMarkupTaggerProvider";
private static FieldInfo AttributeIdFieldInfo;
- private readonly Dictionary<Type,bool> _tagMap = new Dictionary<Type,bool>();
+ private readonly Dictionary<Type, bool> _tagMap = new Dictionary<Type, bool>();
private readonly bool _isResharperInstalled;
/// <summary>
@@ -99,17 +100,53 @@ private bool TryGetResharperTagger(ITextBuffer textBuffer, out ITagger<ITag> tag
return false;
}
+ // The various JetBrains products reuse at a code base level certain constructs
+ // such as ITagger<T> implementations. For example both R# and dotTrace and
+ // dotCover use the VsDocumentMarkerTaggerProvider. If multiple products are
+ // installed then MEF composition will return them in a non-deterministic
+ // order. They all have the same fully qualified name. The only way to
+ // distinguish them is to look at the assembly name containing the type
+ bool sawName = false;
foreach (var pair in TaggerProviders)
{
var provider = pair.Value;
- var name = provider.GetType().Name;
- if (name == ResharperTaggerName)
+ var providerType = provider.GetType();
+ if (providerType.Name == ResharperTaggerProviderName)
{
- var taggerResult = provider.SafeCreateTagger<ITag>(textBuffer);
- if (taggerResult.IsSuccess)
+ if (providerType.Assembly.FullName.StartsWith(ResharperAssembylName))
{
- tagger = taggerResult.Value;
- return true;
+ var taggerResult = provider.SafeCreateTagger<ITag>(textBuffer);
+ if (taggerResult.IsSuccess)
+ {
+ tagger = taggerResult.Value;
+ return true;
+ }
+ }
+ else
+ {
+ sawName = true;
+ }
+ }
+ }
+
+ // It's unclear if the Dev10 portion changes in R# builds for Dev11 or not. Once
+ // a R# 7.0 build is available we can verify this to be the case or not. Until then
+ // assume the name does change and bind to the short name here. Will at least
+ // work for customers with only R# installed on VS11
+ if (sawName)
+ {
+ foreach (var pair in TaggerProviders)
+ {
+ var provider = pair.Value;
+ var providerType = provider.GetType();
+ if (providerType.Name == ResharperTaggerProviderName)
+ {
+ var taggerResult = provider.SafeCreateTagger<ITag>(textBuffer);
+ if (taggerResult.IsSuccess)
+ {
+ tagger = taggerResult.Value;
+ return true;
+ }
}
}
}
View
@@ -3,7 +3,6 @@
using System.IO;
using EditorUtils;
using EnvDTE;
-using Microsoft.FSharp.Core;
using Microsoft.VisualStudio.Editor;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Text;
@@ -73,7 +72,7 @@ private bool SafeExecuteCommand(string command, string args = "")
_dte.ExecuteCommand(command, args);
return true;
}
- catch (Exception e)
+ catch
{
return false;
}
@@ -222,4 +222,4 @@
<Target Name="AfterBuild">
</Target>
-->
-</Project>
+</Project>
@@ -69,74 +69,56 @@
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
</PropertyGroup>
<ItemGroup>
- <Reference Include="FSharp.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\References\FSharp.Core.dll</HintPath>
- </Reference>
- <Reference Include="Microsoft.VisualStudio.CoreUtility, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\References\Microsoft.VisualStudio.CoreUtility.dll</HintPath>
- </Reference>
+ <Reference Include="FSharp.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
+ <Reference Include="Microsoft.VisualStudio.CoreUtility, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.Editor, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
+ <SpecificVersion>True</SpecificVersion>
<HintPath>..\References\Microsoft.VisualStudio.Editor.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\..\Program Files (x86)\Microsoft Visual Studio 2010 SDK SP1\VisualStudioIntegration\Common\Assemblies\v2.0\Microsoft.VisualStudio.OLE.Interop.dll</HintPath>
+ <SpecificVersion>True</SpecificVersion>
+ <HintPath>c:\Program Files (x86)\Microsoft Visual Studio 2010 SDK SP1\VisualStudioIntegration\Common\Assemblies\v2.0\Microsoft.VisualStudio.OLE.Interop.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Platform.VSEditor.Interop, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <HintPath>..\References\Microsoft.VisualStudio.Platform.VSEditor.Interop.dll</HintPath>
+ <HintPath>c:\Program Files (x86)\Microsoft Visual Studio 10.0\common7\ide\PrivateAssemblies\Microsoft.VisualStudio.Platform.VSEditor.Interop.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.VisualStudio.Platform.WindowManagement, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Microsoft.VisualStudio.Platform.WindowManagement.dll</HintPath>
+ <SpecificVersion>True</SpecificVersion>
+ <HintPath>c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Microsoft.VisualStudio.Platform.WindowManagement.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\..\Program Files (x86)\Microsoft Visual Studio 2010 SDK SP1\VisualStudioIntegration\Common\Assemblies\v2.0\Microsoft.VisualStudio.Shell.dll</HintPath>
+ <SpecificVersion>True</SpecificVersion>
+ <HintPath>c:\Program Files (x86)\Microsoft Visual Studio 2010 SDK SP1\VisualStudioIntegration\Common\Assemblies\v2.0\Microsoft.VisualStudio.Shell.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\..\Program Files (x86)\Microsoft Visual Studio 2010 SDK SP1\VisualStudioIntegration\Common\Assemblies\v4.0\Microsoft.VisualStudio.Shell.10.0.dll</HintPath>
+ <SpecificVersion>True</SpecificVersion>
+ <HintPath>c:\Program Files (x86)\Microsoft Visual Studio 2010 SDK SP1\VisualStudioIntegration\Common\Assemblies\v4.0\Microsoft.VisualStudio.Shell.10.0.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\..\Program Files (x86)\Microsoft Visual Studio 2010 SDK SP1\VisualStudioIntegration\Common\Assemblies\v2.0\Microsoft.VisualStudio.Shell.Interop.dll</HintPath>
+ <SpecificVersion>True</SpecificVersion>
+ <HintPath>c:\Program Files (x86)\Microsoft Visual Studio 2010 SDK SP1\VisualStudioIntegration\Common\Assemblies\v2.0\Microsoft.VisualStudio.Shell.Interop.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Interop.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
+ <SpecificVersion>True</SpecificVersion>
<EmbedInteropTypes>True</EmbedInteropTypes>
- <HintPath>..\..\..\..\Program Files (x86)\Microsoft Visual Studio 2010 SDK SP1\VisualStudioIntegration\Common\Assemblies\v2.0\Microsoft.VisualStudio.Shell.Interop.10.0.dll</HintPath>
+ <HintPath>c:\Program Files (x86)\Microsoft Visual Studio 2010 SDK SP1\VisualStudioIntegration\Common\Assemblies\v2.0\Microsoft.VisualStudio.Shell.Interop.10.0.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\..\Program Files (x86)\Microsoft Visual Studio 2010 SDK SP1\VisualStudioIntegration\Common\Assemblies\v2.0\Microsoft.VisualStudio.Shell.Interop.8.0.dll</HintPath>
+ <SpecificVersion>True</SpecificVersion>
+ <HintPath>c:\Program Files (x86)\Microsoft Visual Studio 2010 SDK SP1\VisualStudioIntegration\Common\Assemblies\v2.0\Microsoft.VisualStudio.Shell.Interop.8.0.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.ViewManager, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
+ <SpecificVersion>True</SpecificVersion>
<HintPath>..\References\Microsoft.VisualStudio.Shell.ViewManager.dll</HintPath>
</Reference>
- <Reference Include="Microsoft.VisualStudio.Text.Data, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\References\Microsoft.VisualStudio.Text.Data.dll</HintPath>
- </Reference>
- <Reference Include="Microsoft.VisualStudio.Text.Logic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\References\Microsoft.VisualStudio.Text.Logic.dll</HintPath>
- </Reference>
- <Reference Include="Microsoft.VisualStudio.Text.UI, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\References\Microsoft.VisualStudio.Text.UI.dll</HintPath>
- </Reference>
- <Reference Include="Microsoft.VisualStudio.Text.UI.Wpf, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\References\Microsoft.VisualStudio.Text.UI.Wpf.dll</HintPath>
- </Reference>
+ <Reference Include="Microsoft.VisualStudio.Text.Data, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
+ <Reference Include="Microsoft.VisualStudio.Text.Logic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
+ <Reference Include="Microsoft.VisualStudio.Text.UI, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
+ <Reference Include="Microsoft.VisualStudio.Text.UI.Wpf, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.TextManager.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\..\Program Files (x86)\Microsoft Visual Studio 2010 SDK SP1\VisualStudioIntegration\Common\Assemblies\v2.0\Microsoft.VisualStudio.TextManager.Interop.dll</HintPath>
+ <SpecificVersion>True</SpecificVersion>
+ <HintPath>c:\Program Files (x86)\Microsoft Visual Studio 2010 SDK SP1\VisualStudioIntegration\Common\Assemblies\v2.0\Microsoft.VisualStudio.TextManager.Interop.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />

0 comments on commit 92541d2

Please sign in to comment.