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; }
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; }
private static boolean isBrace(@NotNull PsiElement candidate) { final ASTNode node = candidate.getNode(); if (node != null && node.getFirstChildNode() == null) { final PairedBraceMatcher braceMatcher = LanguageBraceMatching.INSTANCE.forLanguage(candidate.getLanguage()); if (braceMatcher != null) { final IElementType elementType = node.getElementType(); for (BracePair pair : braceMatcher.getPairs()) { if (elementType == pair.getLeftBraceType() || elementType == pair.getRightBraceType()) { return true; } } } } return false; }