本文整理汇总了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();
}
}
示例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));
}
示例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));
}
示例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;
}