@Override public PsiAnnotationMemberValue getDefaultValue() { final PsiMethodStub stub = getStub(); if (stub != null) { final String text = stub.getDefaultValueText(); if (StringUtil.isEmpty(text)) return null; PsiAnnotationMemberValue value = SoftReference.dereference(myCachedDefaultValue); if (value != null) { return value; } value = JavaPsiFacade.getElementFactory(getProject()).createAnnotationFromText("@Foo(" + text + ")", this).findAttributeValue(null); myCachedDefaultValue = new SoftReference<PsiAnnotationMemberValue>(value); return value; } myCachedDefaultValue = null; final ASTNode node = getNode().findChildByRole(ChildRole.ANNOTATION_DEFAULT_VALUE); if (node == null) return null; return (PsiAnnotationMemberValue)node.getPsi(); }
@Override public ASTNode findChildByRole(int role) { LOG.assertTrue(ChildRole.isUnique(role)); switch(role){ default: return null; case ChildRole.SWITCH_KEYWORD: return findChildByType(SWITCH_KEYWORD); case ChildRole.LPARENTH: return findChildByType(LPARENTH); case ChildRole.SWITCH_EXPRESSION: return findChildByType(EXPRESSION_BIT_SET); case ChildRole.RPARENTH: return findChildByType(RPARENTH); case ChildRole.SWITCH_BODY: return findChildByType(CODE_BLOCK); } }
@Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); IElementType i = child.getElementType(); if (i == ASSERT_KEYWORD) { return ChildRole.ASSERT_KEYWORD; } else if (i == COLON) { return ChildRole.COLON; } else if (i == SEMICOLON) { return ChildRole.CLOSING_SEMICOLON; } else { if (EXPRESSION_BIT_SET.contains(child.getElementType())) { int role = getChildRole(child, ChildRole.CONDITION); if (role != ChildRoleBase.NONE) return role; return ChildRole.ASSERT_DESCRIPTION; } return ChildRoleBase.NONE; } }
@Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); IElementType i = child.getElementType(); if (i == CASE_KEYWORD) { return ChildRole.CASE_KEYWORD; } else if (i == DEFAULT_KEYWORD) { return ChildRole.DEFAULT_KEYWORD; } else if (i == COLON) { return ChildRole.COLON; } else { if (EXPRESSION_BIT_SET.contains(child.getElementType())) { return ChildRole.CASE_EXPRESSION; } else { return ChildRoleBase.NONE; } } }
@Override public ASTNode findChildByRole(int role) { LOG.assertTrue(ChildRole.isUnique(role)); switch(role){ default: return null; case ChildRole.STATEMENT: return PsiImplUtil.findStatementChild(this); case ChildRole.COLON: return findChildByType(COLON); case ChildRole.LABEL_NAME: return getFirstChildNode(); } }
@Override public ASTNode findChildByRole(int role) { LOG.assertTrue(ChildRole.isUnique(role)); switch (role) { default: return null; case ChildRole.QUALIFIER: return getFirstChildNode().getElementType() == JAVA_CODE_REFERENCE ? getFirstChildNode() : null; case ChildRole.DOT: return findChildByType(DOT); case ChildRole.SUPER_KEYWORD: return getLastChildNode(); } }
@Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); IElementType i = child.getElementType(); if (i == JAVA_CODE_REFERENCE) { return ChildRole.QUALIFIER; } else if (i == DOT) { return ChildRole.DOT; } else if (i == SUPER_KEYWORD) { return ChildRole.SUPER_KEYWORD; } else { return ChildRoleBase.NONE; } }
@Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); IElementType i = child.getElementType(); if (i == RETURN_KEYWORD) { return ChildRole.RETURN_KEYWORD; } else if (i == SEMICOLON) { return ChildRole.CLOSING_SEMICOLON; } else { if (EXPRESSION_BIT_SET.contains(child.getElementType())) { return ChildRole.RETURN_VALUE; } else { return ChildRoleBase.NONE; } } }
@Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); IElementType i = child.getElementType(); if (i == TYPE) { return ChildRole.TYPE; } else if (i == DOT) { return ChildRole.DOT; } else if (i == CLASS_KEYWORD) { return ChildRole.CLASS_KEYWORD; } else { return ChildRoleBase.NONE; } }
@Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); IElementType i = child.getElementType(); if (i == JavaTokenType.IMPORT_KEYWORD) { return ChildRole.IMPORT_KEYWORD; } else if (i == JavaElementType.JAVA_CODE_REFERENCE) { return ChildRole.IMPORT_REFERENCE; } else if (i == JavaTokenType.DOT) { return ChildRole.IMPORT_ON_DEMAND_DOT; } else if (i == JavaTokenType.ASTERISK) { return ChildRole.IMPORT_ON_DEMAND_ASTERISK; } else if (i == JavaTokenType.SEMICOLON) { return ChildRole.CLOSING_SEMICOLON; } else { return ChildRoleBase.NONE; } }
@Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); IElementType i = child.getElementType(); if (i == JavaTokenType.IMPLEMENTS_KEYWORD) { return ChildRole.IMPLEMENTS_KEYWORD; } else if (i == JavaTokenType.COMMA) { return ChildRole.COMMA; } else if (i == JavaElementType.JAVA_CODE_REFERENCE) { return ChildRole.REFERENCE_IN_LIST; } else { return ChildRoleBase.NONE; } }
@Override public ASTNode findChildByRole(int role) { LOG.assertTrue(ChildRole.isUnique(role)); switch(role){ default: return null; case ChildRole.SYNCHRONIZED_KEYWORD: return findChildByType(SYNCHRONIZED_KEYWORD); case ChildRole.LPARENTH: return findChildByType(LPARENTH); case ChildRole.LOCK: return findChildByType(EXPRESSION_BIT_SET); case ChildRole.RPARENTH: return findChildByType(RPARENTH); case ChildRole.BLOCK: return findChildByType(CODE_BLOCK); } }
@Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); IElementType i = child.getElementType(); if (i == SYNCHRONIZED_KEYWORD) { return ChildRole.SYNCHRONIZED_KEYWORD; } else if (i == LPARENTH) { return ChildRole.LPARENTH; } else if (i == RPARENTH) { return ChildRole.RPARENTH; } else if (i == CODE_BLOCK) { return ChildRole.BLOCK; } else { if (EXPRESSION_BIT_SET.contains(child.getElementType())) { return ChildRole.LOCK; } return ChildRoleBase.NONE; } }
@Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); IElementType i = child.getElementType(); if (i == JavaElementType.MODIFIER_LIST) { return ChildRole.MODIFIER_LIST; } else if (i == JavaElementType.TYPE) { return getChildRole(child, ChildRole.TYPE); } else if (i == JavaTokenType.IDENTIFIER) { return getChildRole(child, ChildRole.NAME); } else { return ChildRoleBase.NONE; } }
@Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); IElementType i = child.getElementType(); if (i == LPARENTH) { return ChildRole.LPARENTH; } else if (i == RPARENTH) { return ChildRole.RPARENTH; } else { if (EXPRESSION_BIT_SET.contains(child.getElementType())) { return ChildRole.EXPRESSION; } return ChildRoleBase.NONE; } }
@Override public ASTNode findChildByRole(int role) { LOG.assertTrue(ChildRole.isUnique(role)); switch (role) { default: return null; case ChildRole.LOPERAND: return getFirstChildNode(); case ChildRole.ROPERAND: return ElementType.EXPRESSION_BIT_SET.contains(getLastChildNode().getElementType()) ? getLastChildNode() : null; case ChildRole.OPERATION_SIGN: return findChildByType(OUR_OPERATIONS_BIT_SET); } }
@Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); IElementType i = child.getElementType(); if (i == PARAMETER) { return ChildRole.PARAMETER; } else if (i == CODE_BLOCK) { return ChildRole.CATCH_BLOCK; } else if (i == CATCH_KEYWORD) { return ChildRole.CATCH_KEYWORD; } else if (i == LPARENTH) { return ChildRole.CATCH_BLOCK_PARAMETER_LPARENTH; } else if (i == RPARENTH) { return ChildRole.CATCH_BLOCK_PARAMETER_RPARENTH; } return ChildRoleBase.NONE; }
@Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); IElementType i = child.getElementType(); if (i == JavaTokenType.EXTENDS_KEYWORD) { return ChildRole.EXTENDS_KEYWORD; } else if (i == JavaTokenType.COMMA) { return ChildRole.COMMA; } else if (i == JavaElementType.JAVA_CODE_REFERENCE) { return ChildRole.REFERENCE_IN_LIST; } else { return ChildRoleBase.NONE; } }
@Override public ASTNode findChildByRole(int role) { LOG.assertTrue(ChildRole.isUnique(role)); switch(role){ default: return null; case ChildRole.QUALIFIER: if (getFirstChildNode().getElementType() == JAVA_CODE_REFERENCE){ return getFirstChildNode(); } else{ return null; } case ChildRole.DOT: return findChildByType(DOT); case ChildRole.THIS_KEYWORD: return getLastChildNode(); } }
@Override public boolean isConstructor() { final PsiMethodStub stub = getStub(); if (stub != null) { return stub.isConstructor(); } return getNode().findChildByRole(ChildRole.TYPE) == null; }
@Override public ASTNode findChildByRole(int role) { LOG.assertTrue(ChildRole.isUnique(role)); switch(role){ default: return null; case ChildRole.ASSERT_KEYWORD: return findChildByType(ASSERT_KEYWORD); case ChildRole.CONDITION: return findChildByType(EXPRESSION_BIT_SET); case ChildRole.COLON: return findChildByType(COLON); case ChildRole.ASSERT_DESCRIPTION: { ASTNode colon = findChildByRole(ChildRole.COLON); if (colon == null) return null; ASTNode child; for(child = colon.getTreeNext(); child != null; child = child.getTreeNext()){ if (EXPRESSION_BIT_SET.contains(child.getElementType())) break; } return child; } case ChildRole.CLOSING_SEMICOLON: return findChildByType(SEMICOLON); } }
@Override public ASTNode findChildByRole(int role) { LOG.assertTrue(ChildRole.isUnique(role)); switch(role){ default: return null; case ChildRole.CONDITION: return getFirstChildNode(); case ChildRole.QUEST: return findChildByType(JavaTokenType.QUEST); case ChildRole.THEN_EXPRESSION: ASTNode quest = findChildByRole(ChildRole.QUEST); ASTNode child = quest.getTreeNext(); while(true){ if (child == null) return null; if (ElementType.EXPRESSION_BIT_SET.contains(child.getElementType())) break; child = child.getTreeNext(); } return child; case ChildRole.COLON: return findChildByType(JavaTokenType.COLON); case ChildRole.ELSE_EXPRESSION: ASTNode colon = findChildByRole(ChildRole.COLON); if (colon == null) return null; return ElementType.EXPRESSION_BIT_SET.contains(getLastChildNode().getElementType()) ? getLastChildNode() : null; } }
@Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); if (child == getFirstChildNode()) return ChildRole.OPERATION_SIGN; if (child == getLastChildNode() && ElementType.EXPRESSION_BIT_SET.contains(child.getElementType())) return ChildRole.OPERAND; return ChildRoleBase.NONE; }
@Override public ASTNode findChildByRole(int role) { LOG.assertTrue(ChildRole.isUnique(role)); switch(role){ default: return null; case ChildRole.EXPRESSION_LIST: return findChildByType(EXPRESSION_LIST); case ChildRole.CLOSING_SEMICOLON: return TreeUtil.findChildBackward(this, SEMICOLON); } }
@Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); IElementType i = child.getElementType(); if (i == EXPRESSION_LIST) { return ChildRole.EXPRESSION_LIST; } else if (i == SEMICOLON) { return ChildRole.CLOSING_SEMICOLON; } else { return ChildRoleBase.NONE; } }
@Override public ASTNode findChildByRole(int role) { LOG.assertTrue(ChildRole.isUnique(role)); switch(role){ default: return null; case ChildRole.THROWS_KEYWORD: return findChildByType(JavaTokenType.THROWS_KEYWORD); } }
@Override public ASTNode findChildByRole(int role){ LOG.assertTrue(ChildRole.isUnique(role)); switch(role){ default: return null; case ChildRole.DO_KEYWORD: return findChildByType(DO_KEYWORD); case ChildRole.LOOP_BODY: return PsiImplUtil.findStatementChild(this); case ChildRole.WHILE_KEYWORD: return findChildByType(WHILE_KEYWORD); case ChildRole.LPARENTH: return findChildByType(LPARENTH); case ChildRole.CONDITION: return findChildByType(EXPRESSION_BIT_SET); case ChildRole.RPARENTH: return findChildByType(RPARENTH); case ChildRole.CLOSING_SEMICOLON: return TreeUtil.findChildBackward(this, SEMICOLON); } }
@Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); if (ElementType.EXPRESSION_BIT_SET.contains(child.getElementType())) { if (child == getFirstChildNode()) return ChildRole.LOPERAND; if (child == getLastChildNode()) return ChildRole.ROPERAND; return ChildRoleBase.NONE; } else if (OUR_OPERATIONS_BIT_SET.contains(child.getElementType())) { return ChildRole.OPERATION_SIGN; } else { return ChildRoleBase.NONE; } }
@Override public int getChildRole(ASTNode child) { final IElementType elType = child.getElementType(); if (elType == JavaTokenType.ARROW) { return ChildRole.ARROW; } else if (elType == JavaElementType.PARAMETER_LIST) { return ChildRole.PARAMETER_LIST; } else if (elType == JavaElementType.CODE_BLOCK) { return ChildRole.LBRACE; } else { return ChildRole.EXPRESSION; } }
@Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); IElementType i = child.getElementType(); if (i == IF_KEYWORD) { return ChildRole.IF_KEYWORD; } else if (i == ELSE_KEYWORD) { return ChildRole.ELSE_KEYWORD; } else if (i == LPARENTH) { return ChildRole.LPARENTH; } else if (i == RPARENTH) { return ChildRole.RPARENTH; } else { if (ElementType.EXPRESSION_BIT_SET.contains(child.getElementType())) { return ChildRole.CONDITION; } else if (child.getPsi() instanceof PsiStatement) { if (findChildByRoleAsPsiElement(ChildRole.THEN_BRANCH) == child) { return ChildRole.THEN_BRANCH; } else { return ChildRole.ELSE_BRANCH; } } else { return ChildRoleBase.NONE; } } }
@Override public boolean isInterface() { final PsiClassStub stub = getStub(); if (stub != null) { return stub.isInterface(); } ASTNode keyword = getNode().findChildByRole(ChildRole.CLASS_OR_INTERFACE_KEYWORD); return keyword != null && keyword.getElementType() == JavaTokenType.INTERFACE_KEYWORD; }
@Override public ASTNode findChildByRole(int role) { LOG.assertTrue(ChildRole.isUnique(role)); switch(role){ default: return null; case ChildRole.BLOCK: return findChildByType(JavaElementType.CODE_BLOCK); } }
@Override public ASTNode findChildByRole(int role) { LOG.assertTrue(ChildRole.isUnique(role)); switch(role){ default: return null; case ChildRole.IF_KEYWORD: return findChildByType(IF_KEYWORD); case ChildRole.LPARENTH: return findChildByType(LPARENTH); case ChildRole.CONDITION: return findChildByType(EXPRESSION_BIT_SET); case ChildRole.RPARENTH: return findChildByType(RPARENTH); case ChildRole.THEN_BRANCH: return PsiImplUtil.findStatementChild(this); case ChildRole.ELSE_KEYWORD: return findChildByType(ELSE_KEYWORD); case ChildRole.ELSE_BRANCH: { ASTNode elseKeyword = findChildByRole(ChildRole.ELSE_KEYWORD); if (elseKeyword == null) return null; for(ASTNode child = elseKeyword.getTreeNext(); child != null; child = child.getTreeNext()){ if (child.getPsi() instanceof PsiStatement) return child; } return null; } } }
@Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); if (ElementType.EXPRESSION_BIT_SET.contains(child.getElementType())) { if (child == getFirstChildNode()) return ChildRole.LOPERAND; if (child == getLastChildNode()) return ChildRole.ROPERAND; return ChildRoleBase.NONE; } if (OUR_OPERATIONS_BIT_SET.contains(child.getElementType())) { return ChildRole.OPERATION_SIGN; } return ChildRoleBase.NONE; }
@Override public ASTNode findChildByRole(int role) { LOG.assertTrue(ChildRole.isUnique(role)); switch(role){ default: return null; case ChildRole.EXTENDS_KEYWORD: return findChildByType(JavaTokenType.EXTENDS_KEYWORD); } }
@Override @NotNull public PsiExpressionList getArgumentList() { PsiExpressionList list = (PsiExpressionList)findChildByRoleAsPsiElement(ChildRole.ARGUMENT_LIST); if (list == null) { LOG.error("Invalid PSI for'" + getText() + ". Parent:" + DebugUtil.psiToString(getParent(), false)); } return list; }
@Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); IElementType i = child.getElementType(); if (i == JavaElementType.EXPRESSION_LIST) { return ChildRole.ARGUMENT_LIST; } else { if (ElementType.EXPRESSION_BIT_SET.contains(child.getElementType())) { return ChildRole.METHOD_EXPRESSION; } return ChildRoleBase.NONE; } }
@Override public ASTNode findChildByRole(int role) { if (role == ChildRole.ANNOTATION_DEFAULT_VALUE) { return findChildByType(ANNOTATION_MEMBER_VALUE_BIT_SET); } return super.findChildByRole(role); }
@Override public int getChildRole(ASTNode child) { LOG.assertTrue(child.getTreeParent() == this); IElementType i = child.getElementType(); if (i == FOR_KEYWORD) { return ChildRole.FOR_KEYWORD; } else if (i == LPARENTH) { return ChildRole.LPARENTH; } else if (i == RPARENTH) { return ChildRole.RPARENTH; } else if (i == PARAMETER) { return ChildRole.FOR_ITERATION_PARAMETER; } else if (i == COLON) { return ChildRole.COLON; } else { if (EXPRESSION_BIT_SET.contains(child.getElementType())) { return ChildRole.FOR_ITERATED_VALUE; } else if (child.getPsi() instanceof PsiStatement) { return ChildRole.LOOP_BODY; } else { return ChildRoleBase.NONE; } } }
@Override public ASTNode findChildByRole(int role) { final ASTNode result = super.findChildByRole(role); if (result != null) return result; switch (role) { default: return null; case ChildRole.IMPORT_REFERENCE: return findChildByType(JavaElementType.JAVA_CODE_REFERENCE); } }