Java 类com.intellij.psi.CustomHighlighterTokenType 实例源码

项目:intellij-ce-playground    文件:CustomFileTypeEditorTest.java   
public void testCpp() throws Exception {
  EditorHighlighter highlighter = HighlighterFactory.createHighlighter(getProject(), "A.cpp");
  //                   0123456789012345678 9 0123 45 6 7
  highlighter.setText("#include try enum \"\\xff\\z\\\"xxx\"");
  HighlighterIterator iterator = highlighter.createIterator(2);
  assertEquals(CustomHighlighterTokenType.KEYWORD_1, iterator.getTokenType());

  iterator = highlighter.createIterator(9);
  assertEquals(CustomHighlighterTokenType.KEYWORD_2, iterator.getTokenType());

  iterator = highlighter.createIterator(15);
  assertEquals(CustomHighlighterTokenType.KEYWORD_1, iterator.getTokenType());

  iterator = highlighter.createIterator(19);
  assertEquals(StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN, iterator.getTokenType());

  iterator = highlighter.createIterator(23);
  assertEquals(StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN, iterator.getTokenType());

  iterator = highlighter.createIterator(25);
  assertEquals(StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN, iterator.getTokenType());

  iterator = highlighter.createIterator(27);
  assertEquals(CustomHighlighterTokenType.STRING, iterator.getTokenType());
}
项目:intellij-ce-playground    文件:KeywordParser.java   
public boolean hasToken(int position, CharSequence myBuffer, @Nullable TokenInfo tokenInfo) {
  int index = 0;
  int offset = position;
  while (offset < myBuffer.length()) {
    char c = myBuffer.charAt(offset++);
    int nextIndex = myTrie.findSubNode(index, myIgnoreCase ? Character.toUpperCase(c) : c);
    if (nextIndex == 0) {
      break;
    }
    index = nextIndex;
    if (myHashCodes.contains(index) && isWordEnd(offset, myBuffer)) {
      String keyword = myBuffer.subSequence(position, offset).toString();
      String testKeyword = myIgnoreCase ? StringUtil.toUpperCase(keyword) : keyword;
      for (int i = 0; i < CustomHighlighterTokenType.KEYWORD_TYPE_COUNT; i++) {
        if (myKeywordSets.get(i).contains(testKeyword)) {
          if (tokenInfo != null) {
            tokenInfo.updateData(position, position + keyword.length(), getToken(i));
          }
          return true;
        }
      }
    }
  }

  return false;
}
项目:tools-idea    文件:CustomFileTypeEditorTest.java   
public void testCpp() throws Exception {
  EditorHighlighter highlighter = HighlighterFactory.createHighlighter(getProject(), "A.cpp");
  //                   0123456789012345678 9 0123 45 6 7
  highlighter.setText("#include try enum \"\\xff\\z\\\"xxx\"");
  HighlighterIterator iterator = highlighter.createIterator(2);
  assertEquals(CustomHighlighterTokenType.KEYWORD_1, iterator.getTokenType());

  iterator = highlighter.createIterator(9);
  assertEquals(CustomHighlighterTokenType.KEYWORD_2, iterator.getTokenType());

  iterator = highlighter.createIterator(15);
  assertEquals(CustomHighlighterTokenType.KEYWORD_1, iterator.getTokenType());

  iterator = highlighter.createIterator(19);
  assertEquals(StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN, iterator.getTokenType());

  iterator = highlighter.createIterator(23);
  assertEquals(StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN, iterator.getTokenType());

  iterator = highlighter.createIterator(25);
  assertEquals(StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN, iterator.getTokenType());

  iterator = highlighter.createIterator(27);
  assertEquals(CustomHighlighterTokenType.STRING, iterator.getTokenType());
}
项目:tools-idea    文件:KeywordParser.java   
public boolean hasToken(int position, CharSequence myBuffer, TokenInfo myTokenInfo) {
  int index = 0;
  int offset = position;
  boolean found = false;
  while (offset < myBuffer.length()) {
    char c = myBuffer.charAt(offset++);
    int nextIndex = myTrie.findSubNode(index, myIgnoreCase ? Character.toUpperCase(c) : c);
    if (nextIndex == 0) {
      break;
    }
    index = nextIndex;
    if (myHashCodes.contains(index) && isWordEnd(offset, myBuffer)) {
      String keyword = myBuffer.subSequence(position, offset).toString();
      String testKeyword = myIgnoreCase ? StringUtil.toUpperCase(keyword) : keyword;
      for (int i = 0; i < CustomHighlighterTokenType.KEYWORD_TYPE_COUNT; i++) {
        if (myKeywordSets.get(i).contains(testKeyword)) {
          myTokenInfo.updateData(position, position + keyword.length(), getToken(i));
          found = true;
          break;
        }
      }
    }
  }

  return found;
}
项目:tools-idea    文件:CustomFileTypeBraceMatcher.java   
@Override
public IElementType getOppositeBraceTokenType(@NotNull IElementType type) {
  if (!(type instanceof CustomHighlighterTokenType.CustomElementType)) {
    return null;
  }

  if (type == CustomHighlighterTokenType.L_BRACE) return CustomHighlighterTokenType.R_BRACE;
  if (type == CustomHighlighterTokenType.R_BRACE) return CustomHighlighterTokenType.L_BRACE;

  if (type == CustomHighlighterTokenType.L_BRACKET) return CustomHighlighterTokenType.R_BRACKET;
  if (type == CustomHighlighterTokenType.R_BRACKET) return CustomHighlighterTokenType.L_BRACKET;
  if (type == CustomHighlighterTokenType.L_ANGLE) return CustomHighlighterTokenType.R_ANGLE;
  if (type == CustomHighlighterTokenType.R_ANGLE) return CustomHighlighterTokenType.L_ANGLE;
  if (type == CustomHighlighterTokenType.L_PARENTH) return CustomHighlighterTokenType.R_PARENTH;
  if (type == CustomHighlighterTokenType.R_PARENTH) return CustomHighlighterTokenType.L_PARENTH;

  return null;
}
项目:consulo    文件:AbstractCustomLexer.java   
public void advance() {
  if (myPosition >= myEndOffset) {
    myCurrentToken.updateData(myPosition, myPosition, null);
    return;
  }
  boolean tokenFound = false;
  for (TokenParser tokenParser : myTokenParsers) {
    if (tokenParser.hasToken(myPosition)) {
      tokenParser.getTokenInfo(myCurrentToken);
      if (myCurrentToken.getEnd() <= myCurrentToken.getStart()) {
        throw new AssertionError(tokenParser);
      }
      tokenFound = true;
      break;
    }
  }

  if (!tokenFound) {
    myCurrentToken.updateData(myPosition, myPosition + 1, CustomHighlighterTokenType.CHARACTER);
  }
  myPosition = myCurrentToken.getEnd();
}
项目:consulo    文件:KeywordParser.java   
public boolean hasToken(int position, CharSequence myBuffer, TokenInfo myTokenInfo) {
  int index = 0;
  int offset = position;
  boolean found = false;
  while (offset < myBuffer.length()) {
    char c = myBuffer.charAt(offset++);
    int nextIndex = myTrie.findSubNode(index, myIgnoreCase ? Character.toUpperCase(c) : c);
    if (nextIndex == 0) {
      break;
    }
    index = nextIndex;
    if (myHashCodes.contains(index) && isWordEnd(offset, myBuffer)) {
      String keyword = myBuffer.subSequence(position, offset).toString();
      String testKeyword = myIgnoreCase ? StringUtil.toUpperCase(keyword) : keyword;
      for (int i = 0; i < CustomHighlighterTokenType.KEYWORD_TYPE_COUNT; i++) {
        if (myKeywordSets.get(i).contains(testKeyword)) {
          myTokenInfo.updateData(position, position + keyword.length(), getToken(i));
          found = true;
          break;
        }
      }
    }
  }

  return found;
}
项目:consulo-java    文件:CustomFileTypeEditorTest.java   
public void testCpp() throws Exception {
  EditorHighlighter highlighter = HighlighterFactory.createHighlighter(getProject(), "A.cpp");
  //                   0123456789012345678 9 0123 45 6 7
  highlighter.setText("#include try enum \"\\xff\\z\\\"xxx\"");
  HighlighterIterator iterator = highlighter.createIterator(2);
  assertEquals(CustomHighlighterTokenType.KEYWORD_1, iterator.getTokenType());

  iterator = highlighter.createIterator(9);
  assertEquals(CustomHighlighterTokenType.KEYWORD_2, iterator.getTokenType());

  iterator = highlighter.createIterator(15);
  assertEquals(CustomHighlighterTokenType.KEYWORD_1, iterator.getTokenType());

  iterator = highlighter.createIterator(19);
  assertEquals(StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN, iterator.getTokenType());

  iterator = highlighter.createIterator(23);
  assertEquals(StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN, iterator.getTokenType());

  iterator = highlighter.createIterator(25);
  assertEquals(StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN, iterator.getTokenType());

  iterator = highlighter.createIterator(27);
  assertEquals(CustomHighlighterTokenType.STRING, iterator.getTokenType());
}
项目:intellij-ce-playground    文件:CustomFileTypeEditorTest.java   
public void testHaskel() throws Exception {
  EditorHighlighter highlighter = HighlighterFactory.createHighlighter(getProject(), "A.hs");
  //                   0123456789012345678 9 0123 45 6 7
  highlighter.setText("{-# #-} module");
  HighlighterIterator iterator = highlighter.createIterator(2);
  assertEquals(CustomHighlighterTokenType.MULTI_LINE_COMMENT, iterator.getTokenType());

  iterator = highlighter.createIterator(12);
  assertEquals(CustomHighlighterTokenType.KEYWORD_1, iterator.getTokenType());
}
项目:intellij-ce-playground    文件:IdTableBuilding.java   
public static WordsScanner createCustomFileTypeScanner(SyntaxTable syntaxTable) {
  return new DefaultWordsScanner(new CustomFileTypeLexer(syntaxTable, true),
                                 TokenSet.create(CustomHighlighterTokenType.IDENTIFIER),
                                 TokenSet.create(CustomHighlighterTokenType.LINE_COMMENT,
                                                 CustomHighlighterTokenType.MULTI_LINE_COMMENT),
                                 TokenSet.create(CustomHighlighterTokenType.STRING, CustomHighlighterTokenType.SINGLE_QUOTED_STRING));

}
项目:intellij-ce-playground    文件:PunctuationParser.java   
@Override
public boolean hasToken(int position) {
  final char c = myBuffer.charAt(position);
  if (".,:;".indexOf(c) >= 0) {
    myTokenInfo.updateData(position, position+1, CustomHighlighterTokenType.PUNCTUATION);
    return true;
  }
  return false;
}
项目:intellij-ce-playground    文件:IdentifierParser.java   
@Override
public boolean hasToken(int position) {
  if (!Character.isJavaIdentifierStart(myBuffer.charAt(position))) return false;
  final int start = position;
  for (position++; position < myEndOffset; position++) {
    if (!isIdentifierPart(position)) break;
  }
  IElementType tokenType = CustomHighlighterTokenType.IDENTIFIER;
  myTokenInfo.updateData(start, position, tokenType);
  return true;
}
项目:intellij-ce-playground    文件:NumberParser.java   
@Override
public boolean hasToken(int position) {
  final int start = position;
  final char startChar = myBuffer.charAt(start);
  if(!isDigit(startChar)) return false;
  for (position++; position < myEndOffset; position++) {
    if (!isDigit(myBuffer.charAt(position))) break;
  }

  if (position < myEndOffset && myBuffer.charAt(position) == '.') {
    final int dotPosition = position;
    position++;

    if (position < myEndOffset && !isDigit(myBuffer.charAt(position))) {
      position = dotPosition;
    } else {
      // after decimal point
      for (; position < myEndOffset; position++) {
        if (!isDigit(myBuffer.charAt(position))) break;
      }
      if (position < myEndOffset) {
        final char finalChar = myBuffer.charAt(position);
        if (!isNumberTail(finalChar) && !isDelimiter(finalChar)) {
          position = dotPosition;
        }
      }
    }
  }
  while(position < myEndOffset && isNumberTail(myBuffer.charAt(position))) {
    position++;
  }

  myTokenInfo.updateData(start, position, CustomHighlighterTokenType.NUMBER);
  return true;
}
项目:intellij-ce-playground    文件:KeywordParser.java   
public KeywordParser(List<Set<String>> keywordSets, boolean ignoreCase) {
  myIgnoreCase = ignoreCase;
  LOG.assertTrue(keywordSets.size() == CustomHighlighterTokenType.KEYWORD_TYPE_COUNT);
  for (Set<String> keywordSet : keywordSets) {
    Set<String> normalized = normalizeKeywordSet(keywordSet);
    myKeywordSets.add(normalized);
    for (String s : normalized) {
      myHashCodes.add(myTrie.getHashCode(s));
    }
  }
}
项目:intellij-ce-playground    文件:KeywordParser.java   
private static IElementType getToken(int keywordSetIndex) {
  switch(keywordSetIndex) {
    case 0: return CustomHighlighterTokenType.KEYWORD_1;
    case 1: return CustomHighlighterTokenType.KEYWORD_2;
    case 2: return CustomHighlighterTokenType.KEYWORD_3;
    case 3: return CustomHighlighterTokenType.KEYWORD_4;
  }
  throw new AssertionError(keywordSetIndex);
}
项目:intellij-ce-playground    文件:WhitespaceParser.java   
@Override
public boolean hasToken(int position) {
  if (!Character.isWhitespace(myBuffer.charAt(position))) return false;
  int start = position;
  for (position++; position < myEndOffset && Character.isWhitespace(myBuffer.charAt(position)); position++) ;
  myTokenInfo.updateData(start, position, CustomHighlighterTokenType.WHITESPACE);
  return true;
}
项目:intellij-ce-playground    文件:CustomFileTypeCompletionContributor.java   
private static boolean inCommentOrLiteral(CompletionParameters parameters) {
  HighlighterIterator iterator = ((EditorEx)parameters.getEditor()).getHighlighter().createIterator(parameters.getOffset());
  IElementType elementType = iterator.getTokenType();
  if (elementType == CustomHighlighterTokenType.WHITESPACE) {
    iterator.retreat();
    elementType = iterator.getTokenType();
  }
  return elementType == CustomHighlighterTokenType.LINE_COMMENT ||
         elementType == CustomHighlighterTokenType.MULTI_LINE_COMMENT ||
         elementType == CustomHighlighterTokenType.STRING ||
         elementType == CustomHighlighterTokenType.SINGLE_QUOTED_STRING;
}
项目:intellij-ce-playground    文件:PlainTextSyntaxHighlighterFactory.java   
public static Lexer createPlainTextLexer() {
  ArrayList<TokenParser> tokenParsers = new ArrayList<TokenParser>();
  tokenParsers.add(new WhitespaceParser());

  tokenParsers.addAll(BraceTokenParser.getBraces());
  tokenParsers.addAll(BraceTokenParser.getParens());
  tokenParsers.addAll(BraceTokenParser.getBrackets());
  tokenParsers.addAll(BraceTokenParser.getAngleBrackets());

  return new MergingLexerAdapter(new AbstractCustomLexer(tokenParsers), TokenSet.create(CustomHighlighterTokenType.CHARACTER));
}
项目:tools-idea    文件:CustomFileTypeEditorTest.java   
public void testHaskel() throws Exception {
  EditorHighlighter highlighter = HighlighterFactory.createHighlighter(getProject(), "A.hs");
  //                   0123456789012345678 9 0123 45 6 7
  highlighter.setText("{-# #-} module");
  HighlighterIterator iterator = highlighter.createIterator(2);
  assertEquals(CustomHighlighterTokenType.MULTI_LINE_COMMENT, iterator.getTokenType());

  iterator = highlighter.createIterator(12);
  assertEquals(CustomHighlighterTokenType.KEYWORD_1, iterator.getTokenType());
}
项目:tools-idea    文件:IdTableBuilding.java   
private static WordsScanner createWordScanner(final CustomSyntaxTableFileType customSyntaxTableFileType) {
  return new DefaultWordsScanner(new CustomFileTypeLexer(customSyntaxTableFileType.getSyntaxTable(), true),
                                 TokenSet.create(CustomHighlighterTokenType.IDENTIFIER),
                                 TokenSet.create(CustomHighlighterTokenType.LINE_COMMENT,
                                                 CustomHighlighterTokenType.MULTI_LINE_COMMENT),
                                 TokenSet.create(CustomHighlighterTokenType.STRING, CustomHighlighterTokenType.SINGLE_QUOTED_STRING));

}
项目:tools-idea    文件:PunctuationParser.java   
@Override
public boolean hasToken(int position) {
  final char c = myBuffer.charAt(position);
  if (".,:;".indexOf(c) >= 0) {
    myTokenInfo.updateData(position, position+1, CustomHighlighterTokenType.PUNCTUATION);
    return true;
  }
  return false;
}
项目:tools-idea    文件:IdentifierParser.java   
public boolean hasToken(int position) {
  if (!Character.isJavaIdentifierStart(myBuffer.charAt(position))) return false;
  final int start = position;
  for (position++; position < myEndOffset; position++) {
    final char c = myBuffer.charAt(position);
    if (!isIdentifierPart(c)) break;
  }
  IElementType tokenType = CustomHighlighterTokenType.IDENTIFIER;
  myTokenInfo.updateData(start, position, tokenType);
  return true;
}
项目:tools-idea    文件:NumberParser.java   
public boolean hasToken(int position) {
  final int start = position;
  final char startChar = myBuffer.charAt(start);
  if(!isDigit(startChar)) return false;
  for (position++; position < myEndOffset; position++) {
    if (!isDigit(myBuffer.charAt(position))) break;
  }

  if (position < myEndOffset && myBuffer.charAt(position) == '.') {
    final int dotPosition = position;
    position++;

    if (position < myEndOffset && !isDigit(myBuffer.charAt(position))) {
      position = dotPosition;
    } else {
      // after decimal point
      for (; position < myEndOffset; position++) {
        if (!isDigit(myBuffer.charAt(position))) break;
      }
      if (position < myEndOffset) {
        final char finalChar = myBuffer.charAt(position);
        if (!isNumberTail(finalChar) && !isDelimiter(finalChar)) {
          position = dotPosition;
        }
      }
    }
  }
  while(position < myEndOffset && isNumberTail(myBuffer.charAt(position))) {
    position++;
  }

  myTokenInfo.updateData(start, position, CustomHighlighterTokenType.NUMBER);
  return true;
}
项目:tools-idea    文件:KeywordParser.java   
public KeywordParser(List<Set<String>> keywordSets, boolean ignoreCase) {
  myIgnoreCase = ignoreCase;
  LOG.assertTrue(keywordSets.size() == CustomHighlighterTokenType.KEYWORD_TYPE_COUNT);
  for (Set<String> keywordSet : keywordSets) {
    Set<String> normalized = normalizeKeywordSet(keywordSet);
    myKeywordSets.add(normalized);
    for (String s : normalized) {
      myHashCodes.add(myTrie.getHashCode(s));
    }
  }
}
项目:tools-idea    文件:KeywordParser.java   
private static IElementType getToken(int keywordSetIndex) {
  switch(keywordSetIndex) {
    case 0: return CustomHighlighterTokenType.KEYWORD_1;
    case 1: return CustomHighlighterTokenType.KEYWORD_2;
    case 2: return CustomHighlighterTokenType.KEYWORD_3;
    case 3: return CustomHighlighterTokenType.KEYWORD_4;
  }
  throw new AssertionError(keywordSetIndex);
}
项目:tools-idea    文件:WhitespaceParser.java   
public boolean hasToken(int position) {
  if (!Character.isWhitespace(myBuffer.charAt(position))) return false;
  int start = position;
  for (position++; position < myEndOffset && Character.isWhitespace(myBuffer.charAt(position)); position++) ;
  myTokenInfo.updateData(start, position, CustomHighlighterTokenType.WHITESPACE);
  return true;
}
项目:tools-idea    文件:PlainTextSyntaxHighlighterFactory.java   
public static Lexer createPlainTextLexer() {
  ArrayList<TokenParser> tokenParsers = new ArrayList<TokenParser>();
  tokenParsers.add(new WhitespaceParser());

  tokenParsers.addAll(BraceTokenParser.getBraces());
  tokenParsers.addAll(BraceTokenParser.getParens());
  tokenParsers.addAll(BraceTokenParser.getBrackets());
  tokenParsers.addAll(BraceTokenParser.getAngleBrackets());

  return new MergingLexerAdapter(new AbstractCustomLexer(tokenParsers), TokenSet.create(CustomHighlighterTokenType.CHARACTER));
}
项目:tools-idea    文件:CustomFileTypeBraceMatcher.java   
@Override
public boolean isLBraceToken(HighlighterIterator iterator, CharSequence fileText, FileType fileType) {
  final IElementType tokenType = iterator.getTokenType();

  return tokenType == CustomHighlighterTokenType.L_BRACKET ||
         tokenType == CustomHighlighterTokenType.L_ANGLE ||
         tokenType == CustomHighlighterTokenType.L_PARENTH ||
         tokenType == CustomHighlighterTokenType.L_BRACE;
}
项目:tools-idea    文件:CustomFileTypeBraceMatcher.java   
@Override
public boolean isPairBraces(IElementType tokenType, IElementType tokenType2) {
  return (tokenType == CustomHighlighterTokenType.L_BRACE && tokenType2 == CustomHighlighterTokenType.R_BRACE) ||
         (tokenType == CustomHighlighterTokenType.R_BRACE && tokenType2 == CustomHighlighterTokenType.L_BRACE) ||
         (tokenType == CustomHighlighterTokenType.L_BRACKET && tokenType2 == CustomHighlighterTokenType.R_BRACKET) ||
         (tokenType == CustomHighlighterTokenType.R_BRACKET && tokenType2 == CustomHighlighterTokenType.L_BRACKET) ||
         (tokenType == CustomHighlighterTokenType.L_ANGLE && tokenType2 == CustomHighlighterTokenType.R_ANGLE) ||
         (tokenType == CustomHighlighterTokenType.R_ANGLE && tokenType2 == CustomHighlighterTokenType.L_ANGLE) ||
         (tokenType == CustomHighlighterTokenType.L_PARENTH && tokenType2 == CustomHighlighterTokenType.R_PARENTH) ||
         (tokenType == CustomHighlighterTokenType.R_PARENTH && tokenType2 == CustomHighlighterTokenType.L_PARENTH);
}
项目:tools-idea    文件:CustomFileTypeQuoteHandler.java   
@Override
public boolean isClosingQuote(HighlighterIterator iterator, int offset) {
  final IElementType tokenType = iterator.getTokenType();

  if (tokenType == CustomHighlighterTokenType.STRING ||
      tokenType == CustomHighlighterTokenType.SINGLE_QUOTED_STRING ||
      tokenType == CustomHighlighterTokenType.CHARACTER){
    int start = iterator.getStart();
    int end = iterator.getEnd();
    return end - start >= 1 && offset == end - 1;
  }
  return false;
}
项目:tools-idea    文件:CustomFileTypeQuoteHandler.java   
@Override
public boolean isOpeningQuote(HighlighterIterator iterator, int offset) {
  final IElementType tokenType = iterator.getTokenType();

  if (tokenType == CustomHighlighterTokenType.STRING ||
      tokenType == CustomHighlighterTokenType.SINGLE_QUOTED_STRING ||
      tokenType == CustomHighlighterTokenType.CHARACTER){
    int start = iterator.getStart();
    return offset == start;
  }
  return false;
}
项目:tools-idea    文件:CustomFileTypeQuoteHandler.java   
@Override
public boolean hasNonClosedLiteral(Editor editor, HighlighterIterator iterator, int offset) {
  try {
    Document doc = editor.getDocument();
    CharSequence chars = doc.getCharsSequence();
    int lineEnd = doc.getLineEndOffset(doc.getLineNumber(offset));

    while (!iterator.atEnd() && iterator.getStart() < lineEnd) {
      IElementType tokenType = iterator.getTokenType();

      if (tokenType == CustomHighlighterTokenType.STRING ||
          tokenType == CustomHighlighterTokenType.SINGLE_QUOTED_STRING ||
          tokenType == CustomHighlighterTokenType.CHARACTER) {

        if (iterator.getStart() >= iterator.getEnd() - 1 ||
            chars.charAt(iterator.getEnd() - 1) != '\"' && chars.charAt(iterator.getEnd() - 1) != '\'') {
          return true;
        }
      }
      iterator.advance();
    }
  } finally {
    while (!iterator.atEnd() && iterator.getStart() != offset) iterator.retreat();
  }

  return false;
}
项目:tools-idea    文件:CustomFileTypeQuoteHandler.java   
@Override
public boolean isInsideLiteral(HighlighterIterator iterator) {
  final IElementType tokenType = iterator.getTokenType();

  return tokenType == CustomHighlighterTokenType.STRING ||
      tokenType == CustomHighlighterTokenType.SINGLE_QUOTED_STRING ||
      tokenType == CustomHighlighterTokenType.CHARACTER;
}
项目:consulo    文件:IdTableBuilding.java   
private static WordsScanner createWordScanner(final CustomSyntaxTableFileType customSyntaxTableFileType) {
  return new DefaultWordsScanner(new CustomFileTypeLexer(customSyntaxTableFileType.getSyntaxTable(), true),
                                 TokenSet.create(CustomHighlighterTokenType.IDENTIFIER),
                                 TokenSet.create(CustomHighlighterTokenType.LINE_COMMENT,
                                                 CustomHighlighterTokenType.MULTI_LINE_COMMENT),
                                 TokenSet.create(CustomHighlighterTokenType.STRING, CustomHighlighterTokenType.SINGLE_QUOTED_STRING));

}
项目:consulo    文件:PunctuationParser.java   
@Override
public boolean hasToken(int position) {
  final char c = myBuffer.charAt(position);
  if (".,:;".indexOf(c) >= 0) {
    myTokenInfo.updateData(position, position+1, CustomHighlighterTokenType.PUNCTUATION);
    return true;
  }
  return false;
}
项目:consulo    文件:IdentifierParser.java   
public boolean hasToken(int position) {
  if (!Character.isJavaIdentifierStart(myBuffer.charAt(position))) return false;
  final int start = position;
  for (position++; position < myEndOffset; position++) {
    final char c = myBuffer.charAt(position);
    if (!isIdentifierPart(c)) break;
  }
  IElementType tokenType = CustomHighlighterTokenType.IDENTIFIER;
  myTokenInfo.updateData(start, position, tokenType);
  return true;
}
项目:consulo    文件:NumberParser.java   
public boolean hasToken(int position) {
  final int start = position;
  final char startChar = myBuffer.charAt(start);
  if(!isDigit(startChar)) return false;
  for (position++; position < myEndOffset; position++) {
    if (!isDigit(myBuffer.charAt(position))) break;
  }

  if (position < myEndOffset && myBuffer.charAt(position) == '.') {
    final int dotPosition = position;
    position++;

    if (position < myEndOffset && !isDigit(myBuffer.charAt(position))) {
      position = dotPosition;
    } else {
      // after decimal point
      for (; position < myEndOffset; position++) {
        if (!isDigit(myBuffer.charAt(position))) break;
      }
      if (position < myEndOffset) {
        final char finalChar = myBuffer.charAt(position);
        if (!isNumberTail(finalChar) && !isDelimiter(finalChar)) {
          position = dotPosition;
        }
      }
    }
  }
  while(position < myEndOffset && isNumberTail(myBuffer.charAt(position))) {
    position++;
  }

  myTokenInfo.updateData(start, position, CustomHighlighterTokenType.NUMBER);
  return true;
}
项目:consulo    文件:KeywordParser.java   
public KeywordParser(List<Set<String>> keywordSets, boolean ignoreCase) {
  myIgnoreCase = ignoreCase;
  LOG.assertTrue(keywordSets.size() == CustomHighlighterTokenType.KEYWORD_TYPE_COUNT);
  for (Set<String> keywordSet : keywordSets) {
    Set<String> normalized = normalizeKeywordSet(keywordSet);
    myKeywordSets.add(normalized);
    for (String s : normalized) {
      myHashCodes.add(myTrie.getHashCode(s));
    }
  }
}
项目:consulo    文件:KeywordParser.java   
private static IElementType getToken(int keywordSetIndex) {
  switch(keywordSetIndex) {
    case 0: return CustomHighlighterTokenType.KEYWORD_1;
    case 1: return CustomHighlighterTokenType.KEYWORD_2;
    case 2: return CustomHighlighterTokenType.KEYWORD_3;
    case 3: return CustomHighlighterTokenType.KEYWORD_4;
  }
  throw new AssertionError(keywordSetIndex);
}
项目:consulo    文件:WhitespaceParser.java   
public boolean hasToken(int position) {
  if (!Character.isWhitespace(myBuffer.charAt(position))) return false;
  int start = position;
  for (position++; position < myEndOffset && Character.isWhitespace(myBuffer.charAt(position)); position++) ;
  myTokenInfo.updateData(start, position, CustomHighlighterTokenType.WHITESPACE);
  return true;
}