public void RegisterToken(SyntaxToken token)
 {
     if (_KnownTokens.TryGetValue(token.LineNumber, out var lineCache))
     {
         lineCache[token.ColumnPosition] = token.GetHashCode();
     }
     else
     {
         _KnownTokens[token.LineNumber] = new Dictionary <int, int> {
             { token.ColumnPosition, token.GetHashCode() }
         }
     };
 }
        /// <summary>
        /// Because <paramref name="destination"/> is immutable, any changes (such as gaining a parent) a new version to be created.
        /// Adding an annotation allows tracking this node, since it will stay with it in any reincarnations.
        /// </summary>
        public SyntaxToken WithDelegateToParentAnnotation(SyntaxToken lastSourceToken, SyntaxToken destination)
        {
            var identifier = lastSourceToken.GetHashCode() + "|" + destination.GetHashCode();
            _trailingTriviaConversionsBySource[lastSourceToken] = identifier;

            destination = destination.WithAdditionalAnnotations(new SyntaxAnnotation(TrailingTriviaConversionKind, identifier));
            _annotationData.Add(identifier, lastSourceToken);
            return destination;
        }
Beispiel #3
0
        public override int GetHashCode()
        {
            var hashCode = -1113933263;

            hashCode = hashCode * -1521134295 + SourceLine.GetHashCode();
            hashCode = hashCode * -1521134295 + TargetLine.GetHashCode();
            hashCode = hashCode * -1521134295 + SourceTrivia.GetHashCode();
            hashCode = hashCode * -1521134295 + TargetToken.GetHashCode();
            hashCode = hashCode * -1521134295 + IsLeading.GetHashCode();
            return(hashCode);
        }
        public bool IsKnown(SyntaxToken token)
        {
            if (_KnownTokens.TryGetValue(token.LineNumber, out var lineCache))
            {
                if (lineCache.TryGetValue(token.ColumnPosition, out var hash))
                {
                    if (hash == token.GetHashCode())
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }