Java Code Examples for com.intellij.psi.tree.IElementType#getLanguage()
The following examples show how to use
com.intellij.psi.tree.IElementType#getLanguage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FilteredIndentsHighlightingPass.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
private boolean isComment(int offset) { final HighlighterIterator it = myEditor.getHighlighter().createIterator(offset); IElementType tokenType = it.getTokenType(); Language language = tokenType.getLanguage(); TokenSet comments = myComments.get(language); if (comments == null) { ParserDefinition definition = LanguageParserDefinitions.INSTANCE.forLanguage(language); if (definition != null) { comments = definition.getCommentTokens(); } if (comments == null) { return false; } else { myComments.put(language, comments); } } return comments.contains(tokenType); }
Example 2
Source File: FilteredIndentsHighlightingPass.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
private boolean isComment(int offset) { final HighlighterIterator it = myEditor.getHighlighter().createIterator(offset); IElementType tokenType = it.getTokenType(); Language language = tokenType.getLanguage(); TokenSet comments = myComments.get(language); if (comments == null) { ParserDefinition definition = LanguageParserDefinitions.INSTANCE.forLanguage(language); if (definition != null) { comments = definition.getCommentTokens(); } if (comments == null) { return false; } else { myComments.put(language, comments); } } return comments.contains(tokenType); }
Example 3
Source File: CacheUtil.java From consulo with Apache License 2.0 | 6 votes |
public static boolean isInComments(final IElementType tokenType, LanguageVersion languageVersion) { final Language language = tokenType.getLanguage(); //for (CommentTokenSetProvider provider : CommentTokenSetProvider.EXTENSION.allForLanguage(language)) { // if (provider.isInComments(tokenType)) { // return true; // } //} boolean inComments = false; final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(language); if (parserDefinition != null) { final TokenSet commentTokens = parserDefinition.getCommentTokens(languageVersion); if (commentTokens.contains(tokenType)) { inComments = true; } } return inComments; }
Example 4
Source File: CommentUtilCore.java From consulo with Apache License 2.0 | 6 votes |
public static boolean isCommentToken(@Nonnull IElementType tokenType, @Nonnull LanguageVersion languageVersion) { final Language language = tokenType.getLanguage(); if(language != languageVersion.getLanguage()) { return false; } final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(language); if (parserDefinition != null) { final TokenSet commentTokens = parserDefinition.getCommentTokens(languageVersion); if (commentTokens.contains(tokenType)) { return true; } } return false; }
Example 5
Source File: IndentsPass.java From consulo with Apache License 2.0 | 6 votes |
private boolean isComment(int offset) { final HighlighterIterator it = myEditor.getHighlighter().createIterator(offset); IElementType tokenType = it.getTokenType(); Language language = tokenType.getLanguage(); TokenSet comments = myComments.get(language); if (comments == null) { ParserDefinition definition = LanguageParserDefinitions.INSTANCE.forLanguage(language); if (definition != null) { comments = definition.getCommentTokens(LanguageVersionUtil.findLanguageVersion(language, myFile)); } if (comments == null) { return false; } else { myComments.put(language, comments); } } return comments.contains(tokenType); }
Example 6
Source File: GeneratedParserUtilBase.java From intellij-latte with MIT License | 5 votes |
public static void initState(ErrorState state, PsiBuilder builder, IElementType root, TokenSet[] extendsSets) { state.extendsSets = extendsSets; PsiFile file = builder.getUserDataUnprotected(FileContextUtil.CONTAINING_FILE_KEY); state.completionState = file == null? null: file.getUserData(COMPLETION_STATE_KEY); Language language = file == null? root.getLanguage() : file.getLanguage(); state.caseSensitive = language.isCaseSensitive(); PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(language); state.braces = matcher == null ? null : matcher.getPairs(); if (state.braces != null && state.braces.length == 0) state.braces = null; }
Example 7
Source File: GeneratedParserUtilBase.java From intellij-xquery with Apache License 2.0 | 5 votes |
public static void initState(ErrorState state, PsiBuilder builder, IElementType root, TokenSet[] extendsSets) { state.extendsSets = extendsSets; PsiFile file = builder.getUserDataUnprotected(FileContextUtil.CONTAINING_FILE_KEY); state.completionState = file == null? null: file.getUserData(COMPLETION_STATE_KEY); Language language = file == null? root.getLanguage() : file.getLanguage(); state.caseSensitive = language.isCaseSensitive(); PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(language); state.braces = matcher == null ? null : matcher.getPairs(); if (state.braces != null && state.braces.length == 0) state.braces = null; }
Example 8
Source File: PlatformIdTableBuilding.java From consulo with Apache License 2.0 | 5 votes |
private boolean isCommentToken(Map<Language, LanguageVersion> cache, IElementType token) { Language language = token.getLanguage(); LanguageVersion languageVersion = cache.get(language); if (languageVersion == null) { cache.put(language, languageVersion = LanguageVersionUtil.findLanguageVersion(language, myProject, myFile)); } return CommentUtilCore.isCommentToken(token, languageVersion); }
Example 9
Source File: LineLayout.java From consulo with Apache License 2.0 | 5 votes |
private static boolean distinctTokens(@Nullable IElementType token1, @Nullable IElementType token2) { if (token1 == token2) return false; if (token1 == null || token2 == null) return true; if (StringEscapesTokenTypes.STRING_LITERAL_ESCAPES.contains(token1) || StringEscapesTokenTypes.STRING_LITERAL_ESCAPES.contains(token2)) return false; if (token1 != TokenType.WHITE_SPACE && token2 != TokenType.WHITE_SPACE && !token1.getLanguage().is(token2.getLanguage())) return true; Language language = token1.getLanguage(); if (language == Language.ANY) language = token2.getLanguage(); BidiRegionsSeparator separator = LanguageBidiRegionsSeparator.INSTANCE.forLanguage(language); return separator.createBorderBetweenTokens(token1, token2); }
Example 10
Source File: GeneratedParserUtilBase.java From consulo with Apache License 2.0 | 5 votes |
public static void initState(ErrorState state, PsiBuilder builder, IElementType root, TokenSet[] extendsSets) { state.extendsSets = extendsSets; PsiFile file = builder.getUserData(FileContextUtil.CONTAINING_FILE_KEY); state.completionState = file == null? null: file.getUserData(COMPLETION_STATE_KEY); Language language = file == null? root.getLanguage() : file.getLanguage(); state.caseSensitive = language.isCaseSensitive(); PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(language); state.braces = matcher == null ? null : matcher.getPairs(); if (state.braces != null && state.braces.length == 0) state.braces = null; }
Example 11
Source File: GeneratedParserUtilBase.java From Intellij-Dust with MIT License | 5 votes |
private static void initState(IElementType root, PsiBuilder builder, ErrorState state) { PsiFile file = builder.getUserDataUnprotected(FileContextUtil.CONTAINING_FILE_KEY); state.completionState = file == null? null: file.getUserData(COMPLETION_STATE_KEY); Language language = file == null? root.getLanguage() : file.getLanguage(); state.caseSensitive = language.isCaseSensitive(); ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(language); if (parserDefinition != null) { state.commentTokens = parserDefinition.getCommentTokens(); state.whitespaceTokens = parserDefinition.getWhitespaceTokens(); } PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(language); state.braces = matcher == null ? null : matcher.getPairs(); if (state.braces != null && state.braces.length == 0) state.braces = null; }
Example 12
Source File: TokenWrapper.java From consulo with Apache License 2.0 | 4 votes |
public TokenWrapper(IElementType delegate, CharSequence value) { super("Wrapper", delegate.getLanguage(), false); myDelegate = delegate; myValue = value; }
Example 13
Source File: CodeBlockUtil.java From consulo with Apache License 2.0 | 4 votes |
private static Language getBraceType(HighlighterIterator iterator) { final IElementType type = iterator.getTokenType(); return type.getLanguage(); }