Example #1
0
 private Token(Token oldToken, ILink link)
     : this(oldToken.Document, oldToken.FullName, oldToken.Value, oldToken.Type, oldToken.LineNumber, oldToken.IsDeclaration, oldToken.IsSearchable)
 {
     Link = link;
     LeadingTrivia = oldToken.LeadingTrivia;
     TrailingTrivia = oldToken.TrailingTrivia;
 }
Example #2
0
 private Token(Token oldToken, ICollection<Trivia> leading, ICollection<Trivia> trailing)
     : this(oldToken.Document, oldToken.FullName, oldToken.Value, oldToken.Type, oldToken.LineNumber, oldToken.IsDeclaration, oldToken.IsSearchable)
 {
     Link = oldToken.Link;
     LeadingTrivia = leading;
     TrailingTrivia = trailing;
 }
Example #3
0
 /// <summary>
 /// Creates a new token with the provided trivia.
 /// </summary>
 /// <returns>A new token containing the provided trivia.</returns>
 public Token WithTrivia(ICollection<Trivia> leading, ICollection<Trivia> trailing)
 {
     var newToken = new Token(this, leading, trailing);
     return newToken;
 }
Example #4
0
 /// <summary>
 /// Create a new token with the provided link.
 /// </summary>
 /// <returns>A new token containing the provided link.</returns>
 public Token WithLink(ILink link)
 {
     var newToken = new Token(this, link);
     return newToken;
 }
 private void processSymbolLink(StreamWriter sw, Token token)
 {
     var symbolLink = token.Link as SymbolLink;
     var name = symbolLink.ReferencedSymbolName;
     Token referencedToken;
     if(_tokenLookup.TryGetValue(name, out referencedToken))
     {
         var relPath = Utilities.MakeRelativePath(token.Document.RelativePath, referencedToken.Document.RelativePath);
         var path = relPath + "#" + referencedToken.LineNumber.ToString();
         sw.Write(path);
     }
     else
     {
         //If we can't find it, just make the link point nowhere.
         sw.Write('#');
     }
 }
 private void processUrlLink(StreamWriter sw, Token token)
 {
     var urlLink = token.Link as UrlLink;
     var url = urlLink.Url;
     sw.Write(url);
 }
        private void processToken(StreamWriter sw, Token token)
        {
            processTriviaCollection(sw, token.LeadingTrivia);

            sw.Write("<span class='");
            sw.Write(HttpUtility.HtmlEncode(token.Type));
            sw.Write("'>");
            if(token.Link != null)
            {
                sw.Write("<a href='");

                var symbolLink = token.Link as SymbolLink;
                if (symbolLink != null)
                {
                    processSymbolLink(sw, token);
                    sw.Write("'>");
                }

                var urlLink = token.Link as UrlLink;
                if (urlLink != null)
                {
                    processUrlLink(sw, token);
                    sw.Write("'");
                    sw.Write(" target='_blank'");
                    sw.Write(">");
                }

                sw.Write(HttpUtility.HtmlEncode(token.Value));
                sw.Write("</a>");
            }
            else
            {
                sw.Write(HttpUtility.HtmlEncode(token.Value));
            }

            sw.Write("</span>");
            processTriviaCollection(sw, token.TrailingTrivia);
        }