public int GetWordExtent(IVsTextLayer textLayer, TextAddress ta, WORDEXTFLAGS flags, TextSpan[] textSpan)
 => VSConstants.E_NOTIMPL;
예제 #2
0
파일: Source.cs 프로젝트: hesam/SketchSharp
    static bool MatchToken( WORDEXTFLAGS flags, TokenInfo info ) {
      if ((flags & WORDEXTFLAGS.WORDEXT_FINDTOKEN) != 0)
        return !(info.type == TokenType.Comment ||
          info.type == TokenType.LineComment ||
          info.type == TokenType.Embedded);
      else 
        return (info.type == TokenType.Keyword ||
          info.type == TokenType.Identifier ||
          info.type == TokenType.String ||
          info.type == TokenType.Literal );

    }
예제 #3
0
 public int GetWordExtent(IVsTextLayer pTextLayer, TextAddress ta, WORDEXTFLAGS flags, TextSpan[] pts)
 {
     return(failed);
 }
예제 #4
0
 public int GetWordExtent(IVsTextLayer pTextLayer, TextAddress ta, WORDEXTFLAGS flags, TextSpan[] pts)
 {
     return(VSConstants.E_NOTIMPL);
 }
예제 #5
0
파일: Source.cs 프로젝트: hesam/SketchSharp
    public bool GetWordExtent(int line, int idx, WORDEXTFLAGS flags, out int startIdx, out int endIdx) {
      Debug.Assert(line >=0 && idx >= 0);

      startIdx = endIdx = 0;

      //get the character classes
      TokenInfo[] lineInfo = this.colorizer.GetLineInfo(line, this.colorState);
      if (lineInfo == null) return false;

      int count = lineInfo.Length;

      TokenInfo info = new TokenInfo();
      int index = this.GetTokenInfoAt(lineInfo, idx, ref info);
      if (index<0) return false;

      //don't do anything in comment or text or literal space
      if (info.type == TokenType.Comment || 
        info.type == TokenType.LineComment ||
        info.type == TokenType.Embedded || 
        info.type == TokenType.Text || 
        info.type == TokenType.String || 
        info.type == TokenType.Literal )
        return false;

      //search for a token
      switch (flags & WORDEXTFLAGS.WORDEXT_MOVETYPE_MASK) {
        case WORDEXTFLAGS.WORDEXT_PREVIOUS:
          index--;
          while (index >= 0 && ! MatchToken(flags, lineInfo[index])) index--;
          if (idx < 0) return false;
          break;

        case WORDEXTFLAGS.WORDEXT_NEXT:
          idx++;
          while (index < count && !MatchToken(flags,lineInfo[index])) index++;
          if (index >= count) return false;
          break;

        case WORDEXTFLAGS.WORDEXT_NEAREST: {
          int prevIdx = index;
          prevIdx--;
          while (prevIdx >= 0 && !MatchToken(flags,lineInfo[prevIdx])) prevIdx--;

          int nextIdx = index;
          while (nextIdx < count && !MatchToken(flags,lineInfo[nextIdx])) nextIdx++;
      
          if (prevIdx < 0 && nextIdx >= count) return false;
          else if (nextIdx >= count) index = prevIdx;
          else if (prevIdx <  0)     index = nextIdx;
          else if (index - prevIdx < nextIdx - index) index = prevIdx;
          else index = nextIdx;      
          break;
        }
        case WORDEXTFLAGS.WORDEXT_CURRENT:
        default:
          if (!MatchToken(flags, info))
            return false;
          break;
      }

      info = lineInfo[index];
      //we found something, set the span
      startIdx = info.startIndex;
      endIdx = info.endIndex;
      if (index<lineInfo.Length)
        endIdx = lineInfo[index+1].startIndex;

      return true;        
    }
예제 #6
0
        public bool GetWordExtent(int line, int idx, WORDEXTFLAGS flags, out int startIdx, out int endIdx)
        {
            Debug.Assert(line >= 0 && idx >= 0);
            startIdx = endIdx = idx;

            int length;
            NativeMethods.ThrowOnFailure(this.textLines.GetLengthOfLine(line, out length));
            // pin to length of line just in case we return false and skip pinning at the end of this method.
            startIdx = endIdx = Math.Min(idx, length);
            if (length == 0)
            {
                return false;
            }

            //get the character classes
            TokenInfo[] lineInfo = this.colorizer.GetLineInfo(this.textLines, line, this.colorState);
            if (lineInfo == null || lineInfo.Length == 0) return false;

            int count = lineInfo.Length;
            TokenInfo info = new TokenInfo();
            int index = this.GetTokenInfoAt(lineInfo, idx, ref info);

            if (index < 0) return false;
            // don't do anything in comment or text or literal space, unless we
            // are doing intellisense in which case we want to match the entire value
            // of quoted strings.
            TokenType type = info.Type;
            if ((flags != SourceImpl.WholeToken || type != TokenType.String) && (type == TokenType.Comment || type == TokenType.LineComment || type == TokenType.Text || type == TokenType.String || type == TokenType.Literal))
                return false;
            //search for a token
            switch (flags & WORDEXTFLAGS.WORDEXT_MOVETYPE_MASK)
            {
                case WORDEXTFLAGS.WORDEXT_PREVIOUS:
                    index--;
                    while (index >= 0 && !MatchToken(flags, lineInfo[index])) index--;
                    if (index < 0) return false;
                    break;

                case WORDEXTFLAGS.WORDEXT_NEXT:
                    index++;
                    while (index < count && !MatchToken(flags, lineInfo[index])) index++;
                    if (index >= count) return false;
                    break;

                case WORDEXTFLAGS.WORDEXT_NEAREST:
                    {
                        int prevIdx = index;
                        prevIdx--;
                        while (prevIdx >= 0 && !MatchToken(flags, lineInfo[prevIdx])) prevIdx--;
                        int nextIdx = index;
                        while (nextIdx < count && !MatchToken(flags, lineInfo[nextIdx])) nextIdx++;
                        if (prevIdx < 0 && nextIdx >= count) return false;
                        else if (nextIdx >= count) index = prevIdx;
                        else if (prevIdx < 0) index = nextIdx;
                        else if (index - prevIdx < nextIdx - index) index = prevIdx;
                        else
                            index = nextIdx;
                        break;
                    }

                case WORDEXTFLAGS.WORDEXT_CURRENT:
                default:
                    if (!MatchToken(flags, info))
                        return false;

                    break;
            }
            info = lineInfo[index];

            // We found something, set the span, pinned to the valid coordinates for the
            // current line.
            startIdx = Math.Min(length, info.StartIndex);
            endIdx = Math.Min(length, info.EndIndex);

            // The scanner endIndex is the last char of the symbol, but
            // GetWordExtent wants it to be the next char after that, so 
            // we increment the endIdx (if we can).
            if (endIdx < length) endIdx++;
            return true;
        }
예제 #7
0
 public int GetWordExtent(IVsTextLayer pTextLayer, TextAddress ta, WORDEXTFLAGS flags, TextSpan[] pts)
 {
     return FAILED;
 }
예제 #8
0
 int IVsLanguageTextOps.GetWordExtent(IVsTextLayer pTextLayer, TextAddress ta, WORDEXTFLAGS flags, TextSpan[] pts)
 {
     return VSConstants.E_NOTIMPL;
 }
예제 #9
0
 public virtual int GetWordExtent(IVsTextLayer textLayer, TextAddress textAddress, WORDEXTFLAGS flags, TextSpan[] span) {
     return VSConstants.E_NOTIMPL;
 }
예제 #10
0
 int IVsLanguageTextOps.GetWordExtent(IVsTextLayer pTextLayer, TextAddress ta, WORDEXTFLAGS flags, TextSpan[] pts)
 {
     return(VSConstants.E_NOTIMPL);
 }
 public int GetWordExtent(IVsTextLayer pTextLayer, TextAddress ta, WORDEXTFLAGS flags, TextSpan[] pts)
 {
     return VSConstants.E_NOTIMPL;
 }
예제 #12
0
 public virtual int GetWordExtent(IVsTextLayer textLayer, TextAddress textAddress, WORDEXTFLAGS flags, TextSpan[] span)
 {
     return(VSConstants.E_NOTIMPL);
 }