/// <summary>
        /// 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
        /// </summary>
        private VersionInfo DetectVersionInfo()
        {
            foreach (var provider in GetTaggerProvidersSafe())
            {
                var providerType = provider.GetType();

                // First step is to check the name of the tagger.  The ReSharper taggers we care
                // about all have the same name
                if (providerType.Name == ResharperTaggerProviderName)
                {
                    // Next we need to make sure this is actually a ReSharper tagger.  Both dotCover
                    // and ReSharper use the same tagger name.  The only way to differentiate them is
                    // to look at the assembly version
                    var version = ResharperVersionUtility.DetectFromAssembly(providerType.Assembly);
                    if (version != ReSharperVersion.Unknown)
                    {
                        var editTagDetector = GetEditTagDetector(version);
                        return(new VersionInfo(version, editTagDetector, provider));
                    }
                }
            }

            return(new VersionInfo(
                       ReSharperVersion.Unknown,
                       GetEditTagDetector(ReSharperVersion.Unknown),
                       taggerProvider: null));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 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
        /// </summary>
        private bool TryGetSpecificTagger(ITextBuffer textBuffer, out bool sawName, out ITagger <ITag> tagger)
        {
            sawName = false;
            tagger  = null;

            foreach (var provider in GetTaggerProvidersSafe())
            {
                var providerType = provider.GetType();

                // First step is to check the name of the tagger.  The ReSharper taggers we care
                // about all have the same name
                if (providerType.Name == ResharperTaggerProviderName)
                {
                    // Next we need to make sure this is actually a ReSharper tagger.  Both dotCover
                    // and ReSharper use the same tagger name.  The only way to differentiate them is
                    // to look at the assembly version
                    var version = ResharperVersionUtility.DetectFromAssembly(providerType.Assembly);
                    if (version != ReSharperVersion.Unknown)
                    {
                        SetReSharperVersion(version);
                        var taggerResult = provider.SafeCreateTagger <ITag>(textBuffer);
                        if (taggerResult.IsSuccess)
                        {
                            tagger = taggerResult.Value;
                            return(true);
                        }
                    }
                    else
                    {
                        sawName = true;
                    }
                }
            }

            return(false);
        }