Java Code Examples for com.intellij.psi.tree.IElementType#equals()
The following examples show how to use
com.intellij.psi.tree.IElementType#equals() .
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: IfStatementExpressionAnalyzer.java From IntelliJDeodorant with MIT License | 6 votes |
private void processExpression(DefaultMutableTreeNode parent, PsiExpression expression) { // TODO: not sure if works if (expression instanceof PsiBinaryExpression) { PsiBinaryExpression infixExpression = (PsiBinaryExpression) expression; IElementType operator = infixExpression.getOperationTokenType(); if (operator.equals(JavaTokenType.ANDAND) || operator.equals(JavaTokenType.OROR)) { parent.setUserObject(operator); DefaultMutableTreeNode leftOperandNode = new DefaultMutableTreeNode(); DefaultMutableTreeNode rightOperandNode = new DefaultMutableTreeNode(); parent.add(leftOperandNode); parent.add(rightOperandNode); processExpression(leftOperandNode, infixExpression.getLOperand()); processExpression(rightOperandNode, infixExpression.getROperand()); } else { parent.setUserObject(infixExpression); } } else { parent.setUserObject(expression); } }
Example 2
Source File: BuckSyntaxHighlighter.java From Buck-IntelliJ-Plugin with Apache License 2.0 | 6 votes |
@Override public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { if (tokenType.equals(BuckTypes.DOUBLE_QUOTED_STRING) || tokenType.equals(BuckTypes.SINGLE_QUOTED_STRING)) { return STRING_KEYS; } else if (tokenType.equals(BuckTypes.GLOB_KEYWORD) || tokenType.equals(BuckTypes.GLOB_EXCLUDES_KEYWORD)) { return GLOB_KEYS; } else if (tokenType.equals(BuckTypes.BOOLEAN) || tokenType.equals(BuckTypes.NONE)) { return KEY_KEYS; } else if (tokenType.equals(BuckTypes.NUMBER)) { return NUMBER_KEYS; } else if (tokenType.equals(BuckTypes.LINE_COMMENT)) { return COMMENT_KEYS; } else if (tokenType.equals(BuckTypes.MACROS)) { return MACROS_KEYS; } else if (tokenType.equals(TokenType.BAD_CHARACTER)) { return BAD_CHAR_KEYS; } else { return EMPTY_KEYS; } }
Example 3
Source File: DustSyntaxHighlighter.java From Intellij-Dust with MIT License | 6 votes |
@NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { if (isPartOfComment(tokenType)) { return COMMENT_KEYS; } else if (tokenType.equals(DustTypes.NUMBER)) { return NUMBER_KEYS; } else if (tokenType.equals(DustTypes.IDENTIFIER)) { return IDENTIFIER_KEYS; } else if (isPartOfTag(tokenType)) { return TAG_KEYS; } else if (tokenType.equals(DustTypes.STRING) || tokenType.equals(DustTypes.STRING_START) || tokenType.equals(DustTypes.STRING_END)) { return STRING_KEYS; } else if (tokenType.equals(TokenType.BAD_CHARACTER)) { return BAD_CHAR_KEYS; } else { return EMPTY_KEYS; } }
Example 4
Source File: HXMLSyntaxHighlighter.java From intellij-haxe with Apache License 2.0 | 6 votes |
@NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { if (tokenType.equals(HXMLTypes.KEY_TOKEN)) { return KEY_KEYS; } else if (tokenType.equals(HXMLTypes.QUALIFIEDCLASSNAME)) { return CLASS_NAME_KEYS; } else if (tokenType.equals(HXMLTypes.VALUE_TOKEN)) { return VALUE_KEYS; } else if (tokenType.equals(HXMLTypes.COMMENT)) { return COMMENT_KEYS; } else if (tokenType.equals(TokenType.BAD_CHARACTER)) { return BAD_CHAR_KEYS; } if (tokenType.equals(HXMLTypes.HXML_FILE)) { return INCLUDE_KEYS; } else { return EMPTY_KEYS; } }
Example 5
Source File: DustSyntaxHighlighter.java From Intellij-Dust with MIT License | 6 votes |
private static boolean isPartOfTag(IElementType tokenType) { return tokenType.equals(DustTypes.LD) || tokenType.equals(DustTypes.RD) || tokenType.equals(DustTypes.LB) || tokenType.equals(DustTypes.RB) || tokenType.equals(DustTypes.SLASH_RD) || tokenType.equals(DustTypes.SECTION) || tokenType.equals(DustTypes.EXISTANCE) || tokenType.equals(DustTypes.NOT_EXISTANCE) || tokenType.equals(DustTypes.HELPER) || tokenType.equals(DustTypes.PARTIAL) || tokenType.equals(DustTypes.INLINE_PARTIAL) || tokenType.equals(DustTypes.BLOCK) || tokenType.equals(DustTypes.CLOSE) || tokenType.equals(DustTypes.ELSE) || tokenType.equals(DustTypes.PERIOD) || tokenType.equals(DustTypes.PIPE) || tokenType.equals(DustTypes.EQUAL); }
Example 6
Source File: HaxeConditionalExpression.java From intellij-haxe with Apache License 2.0 | 6 votes |
@NotNull private Object applyBinary(ASTNode op, Object lhs, Object rhs) throws CalculationException { IElementType optype = op.getElementType(); try { if (optype.equals(OCOND_AND)) { return objectIsTrue(lhs) && objectIsTrue(rhs); } if (optype.equals(OCOND_OR)) { return objectIsTrue(lhs) || objectIsTrue(rhs); } if (optype.equals(OEQ)) { return objectCompare(lhs, rhs) == 0; } if (optype.equals(ONOT_EQ)) { return objectCompare(lhs, rhs) != 0; } if (optype.equals(OGREATER)) { return objectCompare(lhs, rhs) > 0; } if (optype.equals(OGREATER_OR_EQUAL)) { return objectCompare(lhs, rhs) >= 0; } if (optype.equals(OLESS_OR_EQUAL)) { return objectCompare(lhs, rhs) <= 0; } if (optype.equals(OLESS)) { return objectCompare(lhs, rhs) < 0; } throw new CalculationException("Unexpected operator when comparing '" + lhs.toString() + " " + optype.toString() + " " + rhs.toString() + "'."); } catch (CompareException e) { // parser eval#1625 maps any calculation failures to false. return new Boolean(false); } }
Example 7
Source File: DotEnvSyntaxHighlighter.java From idea-php-dotenv-plugin with MIT License | 6 votes |
@NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { if (tokenType.equals(DotEnvTypes.SEPARATOR)) { return SEPARATOR_KEYS; } else if (tokenType.equals(DotEnvTypes.KEY_CHARS)) { return KEY_KEYS; } else if (tokenType.equals(DotEnvTypes.VALUE_CHARS)) { return VALUE_KEYS; } else if (tokenType.equals(DotEnvTypes.COMMENT) || tokenType.equals(DotEnvTypes.EXPORT)) { return COMMENT_KEYS; } else if (tokenType.equals(TokenType.BAD_CHARACTER)) { return BAD_CHAR_KEYS; } else { return EMPTY_KEYS; } }
Example 8
Source File: CsvSyntaxHighlighter.java From intellij-csv-validator with Apache License 2.0 | 6 votes |
@NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { if (tokenType.equals(CsvTypes.COMMA)) { return COMMA_KEYS; } else if (tokenType.equals(CsvTypes.QUOTE)) { return QUOTE_KEYS; } else if (tokenType.equals(CsvTypes.TEXT)) { return TEXT_KEYS; } else if (tokenType.equals(CsvTypes.ESCAPED_TEXT)) { return ESCAPED_TEXT_KEYS; } else if (tokenType.equals(TokenType.BAD_CHARACTER)) { return BAD_CHAR_KEYS; } else { return EMPTY_KEYS; } }
Example 9
Source File: WeaveSyntaxHighlighter.java From mule-intellij-plugins with Apache License 2.0 | 6 votes |
@NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { if (tokenType == null) { return new TextAttributesKey[0]; } else if (tokenType.equals(WeaveTypes.LINE_COMMENT)) { return new TextAttributesKey[]{COMMENT}; } else if (tokenType.equals(WeaveTypes.DOCUMENT_SEPARATOR)) { return new TextAttributesKey[]{COMMENT}; } else if (tokenType.equals(WeaveTypes.INTEGER_LITERAL) | tokenType.equals(WeaveTypes.DOUBLE_LITERAL)) { return new TextAttributesKey[]{NUMBER}; } else if (tokenType.equals(WeaveTypes.COMMA) || tokenType.equals(WeaveTypes.COLON)) { return new TextAttributesKey[]{COMMA}; } else if (tokenType.equals(WeaveTypes.TRUE_LITERAL) || tokenType.equals(WeaveTypes.FALSE_LITERAL) || WeavePsiUtils.OperatorsToken.contains(tokenType) || WeavePsiUtils.DirectivesToken.contains(tokenType)) { return new TextAttributesKey[]{KEYWORD}; } else if (tokenType.equals(WeaveTypes.DOUBLE_QUOTED_STRING) || tokenType.equals(WeaveTypes.SINGLE_QUOTED_STRING)) { return new TextAttributesKey[]{STRING}; } else if (tokenType.equals(WeaveTypes.RULE_TYPE_ID)) { return new TextAttributesKey[]{TYPE}; } else { return new TextAttributesKey[0]; } }
Example 10
Source File: RTParserDefinition.java From react-templates-plugin with MIT License | 5 votes |
@NotNull @Override public PsiElement createElement(ASTNode node) { final IElementType type = node.getElementType(); if (type.equals(RTElementTypes.REPEAT_EXPRESSION)) { return new RTRepeatExpression(node); } if (type.equals(RTElementTypes.FILTER_EXPRESSION)) { return new RTFilterExpression(node); } if (type.equals(RTElementTypes.AS_EXPRESSION)) { return new RTAsExpression(node); } return super.createElement(node); }
Example 11
Source File: BcfgPsiImplUtil.java From buck with Apache License 2.0 | 5 votes |
/** Returns true if the inlined file is required. */ public static boolean isRequired(BcfgInline inline) { PsiElement requiredField = inline.getFirstChild(); IElementType elementType = requiredField.getNode().getElementType(); if (elementType.equals(BcfgTypes.REQUIRED_FILE)) { return true; } else if (elementType.equals(BcfgTypes.OPTIONAL_FILE)) { return false; } else { return false; // How could this be a BcfgInline? } }
Example 12
Source File: ElmMainCompletionProvider.java From elm-plugin with MIT License | 5 votes |
private void addCompletionsAfterASTNode(ASTNode node, CompletionResultSet resultSet) { IElementType elementType = node.getElementType(); if (elementType.equals(ElmTypes.DOT)) { addCompletionsAfterDot((PsiElement) node, resultSet); } else if (elementType.equals(ElmTypes.FRESH_LINE)) { this.keywordsProvider.addCompletions(resultSet); this.afterAnnotationProvider.addCompletions(node.getPsi(), resultSet); } }
Example 13
Source File: GraphQLSyntaxHighlighter.java From js-graphql-intellij-plugin with MIT License | 5 votes |
@NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { if (tokenType.equals(GraphQLElementTypes.NAME)) { return IDENTIFIER_KEYS; } else if (KEYWORDS.contains(tokenType)) { return KEYWORD_KEYS; } else if (tokenType.equals(GraphQLElementTypes.NUMBER)) { return NUMBER_KEYS; } else if (tokenType.equals(GraphQLElementTypes.OPEN_QUOTE) || tokenType.equals(GraphQLElementTypes.CLOSING_QUOTE) || tokenType.equals(GraphQLElementTypes.REGULAR_STRING_PART)) { return STRING_KEYS; } else if (tokenType.equals(GraphQLElementTypes.COMMENT)) { return COMMENT_KEYS; } else if (tokenType.equals(GraphQLElementTypes.BRACE_L) || tokenType.equals(GraphQLElementTypes.BRACE_R)) { return BRACES_KEYS; } else if (tokenType.equals(GraphQLElementTypes.PAREN_L) || tokenType.equals(GraphQLElementTypes.PAREN_R)) { return PARENTHESES_KEYS; } else if (tokenType.equals(GraphQLElementTypes.BRACKET_L) || tokenType.equals(GraphQLElementTypes.BRACKET_R)) { return BRACKETS_KEYS; } else if (tokenType.equals(GraphQLElementTypes.SPREAD)) { return SPREAD_KEYS; } else if(tokenType.equals(GraphQLElementTypes.COLON)) { return COLON_KEYS; } else if(tokenType.equals(GraphQLElementTypes.BANG)) { return BANG_KEYS; } else if(tokenType.equals(GraphQLElementTypes.PIPE)) { return PIPE_KEYS; } else if(tokenType.equals(GraphQLElementTypes.AMP)) { return AMP_KEYS; } else if (tokenType.equals(TokenType.BAD_CHARACTER)) { return BAD_CHARACTER_KEYS; } else { return EMPTY_KEYS; } }
Example 14
Source File: MelSyntaxHighlighter.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
@NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { if (tokenType == null) { return new TextAttributesKey[0]; } else if (tokenType.equals(MelTypes.INTEGER_LITERAL) | tokenType.equals(MelTypes.DOUBLE_LITERAL)) { return new TextAttributesKey[]{NUMBER}; } else if (tokenType.equals(MelTypes.COMMA) || tokenType.equals(MelTypes.COLON)) { return new TextAttributesKey[]{COMMA}; } else if (tokenType.equals(MelTypes.TRUE_KEYWORD) || tokenType.equals(MelTypes.FALSE_KEYWORD) || tokenType.equals(MelTypes.INSTANCEOF_KEYWORD) || tokenType.equals(MelTypes.FOR) || tokenType.equals(MelTypes.DEF) || tokenType.equals(MelTypes.IF) || tokenType.equals(MelTypes.DO) || tokenType.equals(MelTypes.ELSE) || tokenType.equals(MelTypes.WHILE) || tokenType.equals(MelTypes.IN) || tokenType.equals(MelTypes.NEW_KEYWORD) || tokenType.equals(MelTypes.IMPORT) || tokenType.equals(MelTypes.RETURN) ) { return new TextAttributesKey[]{KEYWORD}; } else if (tokenType.equals(MelTypes.STRING_LITERAL)) { return new TextAttributesKey[]{STRING}; } else if (tokenType.equals(MelTypes.LINE_COMMENT)) { return new TextAttributesKey[]{COMMENT}; } else { return new TextAttributesKey[0]; } }
Example 15
Source File: HaxeConditionalExpression.java From intellij-haxe with Apache License 2.0 | 5 votes |
private boolean areTokensBalanced(IElementType leftToken, IElementType rightToken) { LOG.assertLog(leftToken != rightToken, "Cannot balance tokens of the same type."); int tokenCount = 0; for (ASTNode t : tokens) { IElementType type = t.getElementType(); if (type.equals(leftToken)) { tokenCount++; } else if (type.equals(rightToken)) { tokenCount--; } } return tokenCount == 0; }
Example 16
Source File: ORLineBreakpointType.java From reasonml-idea-plugin with MIT License | 5 votes |
@Override public boolean process(@NotNull PsiElement element) { IElementType elementType = element.getNode().getElementType(); if (elementType.equals(TokenType.WHITE_SPACE) || elementType.equals(m_types.SINGLE_COMMENT) || elementType.equals(m_types.MULTI_COMMENT)) { return true; } if (elementType.equals(m_types.LET)) { m_isLineBreakpointAvailable = true; return false; } return true; }
Example 17
Source File: HaxeAstUtil.java From intellij-haxe with Apache License 2.0 | 5 votes |
public static boolean isOfType(@Nullable ASTNode t, IElementType... types) { if (t != null) { IElementType nodetype = t.getElementType(); for (IElementType type : types) { if (type.equals(nodetype)) { return true; } } } return false; }
Example 18
Source File: JsonnetSyntaxHighlighter.java From intellij-jsonnet with Apache License 2.0 | 4 votes |
@NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { if (tokenType.equals(JsonnetTypes.BLOCK_COMMENT)) { return COMMENT_KEYS; } else if (tokenType.equals(JsonnetTypes.LINE_COMMENT)) { return COMMENT_KEYS; } else if ( tokenType.equals(JsonnetTypes.TRUE) || tokenType.equals(JsonnetTypes.FALSE) || tokenType.equals(JsonnetTypes.NULL) || tokenType.equals(JsonnetTypes.IMPORT) || tokenType.equals(JsonnetTypes.IMPORTSTR) || tokenType.equals(JsonnetTypes.LOCAL) || tokenType.equals(JsonnetTypes.FUNCTION) || tokenType.equals(JsonnetTypes.IN) || tokenType.equals(JsonnetTypes.IF) || tokenType.equals(JsonnetTypes.THEN) || tokenType.equals(JsonnetTypes.ELSE) || tokenType.equals(JsonnetTypes.SUPER) || tokenType.equals(JsonnetTypes.ERROR) || tokenType.equals(JsonnetTypes.SELF) || tokenType.equals(JsonnetTypes.FOR) || tokenType.equals(JsonnetTypes.ASSERT) || tokenType.equals(JsonnetTypes.DOLLAR) ) { return KEYWORD_KEYS; } else if (tokenType.equals(JsonnetTypes.NUMBER)) { return NUMBER_KEYS; } else if ( tokenType.equals(JsonnetTypes.SINGLE_QUOTED_STRING) || tokenType.equals(JsonnetTypes.DOUBLE_QUOTED_STRING) || tokenType.equals(JsonnetTypes.VERBATIM_DOUBLE_QUOTED_STRING) || tokenType.equals(JsonnetTypes.VERBATIM_SINGLE_QUOTED_STRING) || tokenType.equals(JsonnetTypes.TRIPLE_BAR_QUOTED_STRING)) { return STRING_KEYS; } else if (tokenType.equals(TokenType.BAD_CHARACTER)) { return BAD_CHAR_KEYS; } else { return EMPTY_KEYS; } }
Example 19
Source File: DustSyntaxHighlighter.java From Intellij-Dust with MIT License | 4 votes |
private static boolean isPartOfComment(IElementType tokenType) { return tokenType.equals(DustTypes.COMMENT); }
Example 20
Source File: HaxeConditionalExpression.java From intellij-haxe with Apache License 2.0 | 4 votes |
@NotNull private Object applyUnary(ASTNode op, Object value) throws CalculationException { IElementType optype = op.getElementType(); if (optype.equals(ONOT)) { return !objectIsTrue(value); } throw new CalculationException("Unexpected unary operator encountered: " + op.toString()); }