示例#1
0
        public virtual IChameleonNode ReSync(CachingLexer cachingLexer, TreeTextRange changedRange, int insertedTextLen)
        {
            TreeTextRange oldRange = this.GetTreeTextRange();

            Logger.Assert(changedRange.ContainedIn(oldRange), "The condition “changedRange.ContainedIn(oldRange)” is false.");

            int newLength = oldRange.Length - changedRange.Length + insertedTextLen;

            // Find starting comment
            if (!cachingLexer.FindTokenAt(oldRange.StartOffset.Offset) ||
                cachingLexer.TokenType != this.GetTokenType() ||
                cachingLexer.TokenStart != oldRange.StartOffset.Offset ||
                cachingLexer.TokenEnd != oldRange.StartOffset.Offset + newLength)
            {
                return(null);
            }

            var element = TreeElementFactory.CreateLeafElement(
                cachingLexer.TokenType,
                new ProjectedBuffer(
                    cachingLexer.Buffer, new TextRange(cachingLexer.TokenStart, cachingLexer.TokenStart + newLength)),
                0,
                newLength);
            var comment = element as Comment;

            if (comment == null || this.CommentType != comment.CommentType)
            {
                return(null);
            }
            return(comment);
        }
 public override void FindNodesAtInternal(TreeTextRange relativeRange, List <ITreeNode> result,
                                          bool includeContainingNodes)
 {
     if (relativeRange.ContainedIn(TreeTextRange.FromLength(GetTextLength())))
     {
         base.FindNodesAtInternal(relativeRange, result, includeContainingNodes);
     }
 }
示例#3
0
        public override IChameleonNode FindChameleonWhichCoversRange(TreeTextRange textRange)
        {
            if (textRange.ContainedIn(TreeTextRange.FromLength(GetTextLength())))
            {
                return(base.FindChameleonWhichCoversRange(textRange) ?? this);
            }

            return(null);
        }
示例#4
0
    public IChameleonNode ReSync(CachingLexer cachingLexer, TreeTextRange changedRange, int insertedTextLen)
    {
      TreeTextRange oldRange = this.GetTreeTextRange();

      Logger.Assert(changedRange.ContainedIn(oldRange), "The condition “changedRange.ContainedIn(oldRange)” is false.");

      int newLength = oldRange.Length - changedRange.Length + insertedTextLen;
      // Find starting comment
      if (!cachingLexer.FindTokenAt(oldRange.StartOffset.Offset) ||
        cachingLexer.TokenType != GetTokenType() ||
          cachingLexer.TokenStart != oldRange.StartOffset.Offset ||
            cachingLexer.TokenEnd != oldRange.StartOffset.Offset + newLength)
      {
        return null;
      }

      LeafElementBase element = TreeElementFactory.CreateLeafElement(cachingLexer.TokenType, new ProjectedBuffer(cachingLexer.Buffer, new TextRange(cachingLexer.TokenStart, cachingLexer.TokenStart + newLength)), 0, newLength);
      var comment = element as Comment;
      if (comment == null || CommentType != comment.CommentType)
      {
        return null;
      }
      return comment;
    }
示例#5
0
 public override IChameleonNode FindChameleonWhichCoversRange(TreeTextRange textRange)
 {
   return textRange.ContainedIn(TreeTextRange.FromLength(GetTextLength())) ? this : null;
 }
示例#6
0
 public override IChameleonNode FindChameleonWhichCoversRange(TreeTextRange textRange)
 {
     return(textRange.ContainedIn(TreeTextRange.FromLength(this.GetTextLength()))
                ? this
                : null);
 }
    public override IChameleonNode FindChameleonWhichCoversRange(TreeTextRange textRange)
    {
      if (textRange.ContainedIn(TreeTextRange.FromLength(GetTextLength())))
      {
        return base.FindChameleonWhichCoversRange(textRange) ?? this;
      }

      return null;
    }