当前位置: 首页>>代码示例>>Java>>正文


Java CustomFileTypeLexer类代码示例

本文整理汇总了Java中com.intellij.ide.highlighter.custom.CustomFileTypeLexer的典型用法代码示例。如果您正苦于以下问题:Java CustomFileTypeLexer类的具体用法?Java CustomFileTypeLexer怎么用?Java CustomFileTypeLexer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CustomFileTypeLexer类属于com.intellij.ide.highlighter.custom包,在下文中一共展示了CustomFileTypeLexer类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: tokenize

import com.intellij.ide.highlighter.custom.CustomFileTypeLexer; //导入依赖的package包/类
@Override
public void tokenize(@NotNull PsiElement element, TokenConsumer consumer) {
  CustomFileTypeLexer lexer = new CustomFileTypeLexer(mySyntaxTable);
  String text = element.getText();
  lexer.start(text);
  while (true) {
    IElementType tokenType = lexer.getTokenType();
    if (tokenType == null) {
      break;
    }

    if (!isKeyword(tokenType)) {
      consumer.consumeToken(element, text, false, 0, new TextRange(lexer.getTokenStart(), lexer.getTokenEnd()), PlainTextSplitter.getInstance());
    }
    lexer.advance();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:CustomFileTypeTokenizer.java

示例2: createCustomFileTypeScanner

import com.intellij.ide.highlighter.custom.CustomFileTypeLexer; //导入依赖的package包/类
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));

}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:IdTableBuilding.java

示例3: createWordScanner

import com.intellij.ide.highlighter.custom.CustomFileTypeLexer; //导入依赖的package包/类
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));

}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:9,代码来源:IdTableBuilding.java

示例4: findCommentedRange

import com.intellij.ide.highlighter.custom.CustomFileTypeLexer; //导入依赖的package包/类
@Nullable
private TextRange findCommentedRange(final Commenter commenter) {
  final CharSequence text = myDocument.getCharsSequence();
  final FileType fileType = myFile.getFileType();
  if (fileType instanceof CustomSyntaxTableFileType) {
    Lexer lexer = new CustomFileTypeLexer(((CustomSyntaxTableFileType)fileType).getSyntaxTable());
    final int caretOffset = myEditor.getCaretModel().getOffset();
    int commentStart = CharArrayUtil.lastIndexOf(text, commenter.getBlockCommentPrefix(), caretOffset);
    if (commentStart == -1) return null;

    lexer.start(text, commentStart, text.length());
    if (lexer.getTokenType() == CustomHighlighterTokenType.MULTI_LINE_COMMENT && lexer.getTokenEnd() >= caretOffset) {
      return new TextRange(commentStart, lexer.getTokenEnd());
    }
    return null;
  }

  final String prefix;
  final String suffix;

  final SelectionModel selectionModel = myEditor.getSelectionModel();
  if (commenter instanceof SelfManagingCommenter) {
    SelfManagingCommenter selfManagingCommenter = (SelfManagingCommenter)commenter;

    prefix = selfManagingCommenter.getBlockCommentPrefix(
      selectionModel.getSelectionStart(),
      myDocument,
      mySelfManagedCommenterData
    );
    suffix = selfManagingCommenter.getBlockCommentSuffix(
      selectionModel.getSelectionEnd(),
      myDocument,
      mySelfManagedCommenterData
    );
  }
  else {
    prefix = trim(commenter.getBlockCommentPrefix());
    suffix = trim(commenter.getBlockCommentSuffix());
  }
  if (prefix == null || suffix == null) return null;

  TextRange commentedRange;

  if (commenter instanceof SelfManagingCommenter) {
    commentedRange = ((SelfManagingCommenter)commenter).getBlockCommentRange(
      selectionModel.getSelectionStart(),
      selectionModel.getSelectionEnd(),
      myDocument,
      mySelfManagedCommenterData
    );
  }
  else {
    if (!testSelectionForNonComments()) {
      return null;
    }

    commentedRange = getSelectedComments(text, prefix, suffix);
    if (commentedRange == null) {
      PsiElement comment = findCommentAtCaret();
      if (comment != null) {

        String commentText = comment.getText();
        if (commentText.startsWith(prefix) && commentText.endsWith(suffix)) {
          commentedRange = comment.getTextRange();
        }
      }
    }
  }
  return commentedRange;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:71,代码来源:CommentByBlockCommentHandler.java


注:本文中的com.intellij.ide.highlighter.custom.CustomFileTypeLexer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。