public INavigationToken CreateToken(IDefinitionToken analysisToken, IDocument document)
 {
     if (analysisToken == null)
     {
         throw new ArgumentNullException(nameof(analysisToken));
     }
     return(new NavigationToken(analysisToken, document));
 }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the description text of the definition in the comment to the right or above the definition.
        /// Must be on UI thread
        /// </summary>
        /// <returns>Description text if exists otherwise null</returns>
        public static string GetDescription(this IDefinitionToken token)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            var serviceProvider = ServiceProvider.GlobalProvider;
            var documentFactory = serviceProvider.GetMefService <IDocumentFactory>();

            return(documentFactory != null
                ? GetDescription(token, documentFactory)
                : null);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns the description text of the definition in the comment to the right or above the definition.
        /// </summary>
        /// <returns>Description text if exists otherwise null</returns>
        public static string GetDescription(this IDefinitionToken token, IDocumentFactory documentFactory)
        {
            var tokenEnd = token.Span.End;
            var snapshot = token.Span.Snapshot;

            var document = documentFactory.GetOrCreateDocument(snapshot.TextBuffer);

            if (document == null)
            {
                return(null);
            }

            var tokenizer       = document.DocumentTokenizer;
            var tokenizerResult = tokenizer.CurrentResult;

            if (tokenizerResult.Snapshot != snapshot)
            {
                return(null);
            }

            return(TryGetDescriptionToTheRight(tokenizer, tokenizerResult, tokenEnd)
                   ?? TryGetDescriptionAbove(tokenizer, tokenizerResult, tokenEnd));
        }
Exemplo n.º 4
0
 public NavigationToken(IDefinitionToken definition, IDocument document)
 {
     Document   = document;
     Definition = definition;
 }