@Override public PsiImportStatementStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) { boolean isOnDemand = false; String refText = null; for (LighterASTNode child : tree.getChildren(node)) { IElementType type = child.getTokenType(); if (type == JavaElementType.JAVA_CODE_REFERENCE || type == JavaElementType.IMPORT_STATIC_REFERENCE) { refText = JavaSourceUtil.getReferenceText(tree, child); } else if (type == JavaTokenType.ASTERISK) { isOnDemand = true; } } byte flags = PsiImportStatementStubImpl.packFlags(isOnDemand, node.getTokenType() == JavaElementType.IMPORT_STATIC_STATEMENT); return new PsiImportStatementStubImpl(parentStub, refText, flags); }
@Override public PsiImportStatementStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) { boolean isOnDemand = false; String refText = null; for(LighterASTNode child : tree.getChildren(node)) { IElementType type = child.getTokenType(); if(type == JavaElementType.JAVA_CODE_REFERENCE || type == JavaElementType.IMPORT_STATIC_REFERENCE) { refText = JavaSourceUtil.getReferenceText(tree, child); } else if(type == JavaTokenType.ASTERISK) { isOnDemand = true; } } byte flags = PsiImportStatementStubImpl.packFlags(isOnDemand, node.getTokenType() == JavaElementType.IMPORT_STATIC_STATEMENT); return new PsiImportStatementStubImpl(parentStub, refText, flags); }
@Override public PsiPackageAccessibilityStatementStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) { String refText = null; List<String> to = ContainerUtil.newSmartList(); for(LighterASTNode child : tree.getChildren(node)) { IElementType type = child.getTokenType(); if(type == JavaElementType.JAVA_CODE_REFERENCE) { refText = JavaSourceUtil.getReferenceText(tree, child); } else if(type == JavaElementType.MODULE_REFERENCE) { to.add(JavaSourceUtil.getReferenceText(tree, child)); } } return new PsiPackageAccessibilityStatementStubImpl(parentStub, this, refText, to); }
@NotNull @Override protected StubElement createStubForFile(@NotNull PsiFile file, @NotNull LighterAST tree) { if(!(file instanceof PsiJavaFile)) { return super.createStubForFile(file, tree); } String refText = ""; LighterASTNode pkg = LightTreeUtil.firstChildOfType(tree, tree.getRoot(), JavaElementType.PACKAGE_STATEMENT); if(pkg != null) { LighterASTNode ref = LightTreeUtil.firstChildOfType(tree, pkg, JavaElementType.JAVA_CODE_REFERENCE); if(ref != null) { refText = JavaSourceUtil.getReferenceText(tree, ref); } } return new PsiJavaFileStubImpl((PsiJavaFile) file, refText, null, false); }
@Override public PsiProvidesStatementStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) { LighterASTNode ref = LightTreeUtil.firstChildOfType(tree, node, JavaElementType.JAVA_CODE_REFERENCE); String refText = ref != null ? JavaSourceUtil.getReferenceText(tree, ref) : null; return new PsiProvidesStatementStubImpl(parentStub, refText); }
@Override public PsiUsesStatementStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) { LighterASTNode ref = LightTreeUtil.firstChildOfType(tree, node, JavaElementType.JAVA_CODE_REFERENCE); String refText = ref != null ? JavaSourceUtil.getReferenceText(tree, ref) : null; return new PsiUsesStatementStubImpl(parentStub, refText); }
@Override public PsiRequiresStatementStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) { LighterASTNode ref = LightTreeUtil.firstChildOfType(tree, node, JavaElementType.MODULE_REFERENCE); String refText = ref != null ? JavaSourceUtil.getReferenceText(tree, ref) : null; return new PsiRequiresStatementStubImpl(parentStub, refText); }
private String getNormalizedText() { String whiteSpaceAndComments = myCachedNormalizedText; if(whiteSpaceAndComments == null) { myCachedNormalizedText = whiteSpaceAndComments = JavaSourceUtil.getReferenceText(this); } return whiteSpaceAndComments; }
@Override public void fullyQualify(@NotNull final PsiClass targetClass) { final int kind = getKind(getContainingFile()); if(kind != CLASS_NAME_KIND && kind != CLASS_OR_PACKAGE_NAME_KIND && kind != CLASS_IN_QUALIFIED_NEW_KIND) { LOG.error("Wrong kind " + kind); return; } JavaSourceUtil.fullyQualifyReference(this, targetClass); }
private String getCachedNormalizedText() { String whiteSpaceAndComments = myCachedNormalizedText; if(whiteSpaceAndComments == null) { myCachedNormalizedText = whiteSpaceAndComments = JavaSourceUtil.getReferenceText(this); } return whiteSpaceAndComments; }
@Override public void replaceChildInternal(@NotNull ASTNode child, @NotNull TreeElement newElement) { if(ElementType.EXPRESSION_BIT_SET.contains(child.getElementType()) && ElementType.EXPRESSION_BIT_SET.contains(newElement.getElementType())) { boolean needParenth = ReplaceExpressionUtil.isNeedParenthesis(child, newElement); if(needParenth) { newElement = JavaSourceUtil.addParenthToReplacedChild(JavaElementType.PARENTH_EXPRESSION, newElement, getManager()); } } super.replaceChildInternal(child, newElement); }
@Override public void deleteChildInternal(@NotNull ASTNode child) { if(child.getElementType() == JavaElementType.NAME_VALUE_PAIR) { JavaSourceUtil.deleteSeparatingComma(this, child); } super.deleteChildInternal(child); }
@Override public TreeElement addInternal(TreeElement first, ASTNode last, ASTNode anchor, Boolean before) { if(MEMBER_SET.contains(first.getElementType()) && MEMBER_SET.contains(last.getElementType())) { TreeElement firstAdded = super.addInternal(first, last, anchor, before); JavaSourceUtil.addSeparatingComma(this, first, MEMBER_SET); return firstAdded; } return super.addInternal(first, last, anchor, before); }
@Override public void deleteChildInternal(@NotNull ASTNode child) { if(MEMBER_SET.contains(child.getElementType())) { JavaSourceUtil.deleteSeparatingComma(this, child); } super.deleteChildInternal(child); }
@Override public String getQualifiedName() { return JavaSourceUtil.getReferenceText(this); }
@Override public PsiJavaModuleStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) { LighterASTNode ref = LightTreeUtil.requiredChildOfType(tree, node, JavaElementType.MODULE_REFERENCE); return new PsiJavaModuleStubImpl(parentStub, JavaSourceUtil.getReferenceText(tree, ref)); }
@Override public void fullyQualify(@NotNull PsiClass targetClass) { JavaSourceUtil.fullyQualifyReference(this, targetClass); }
@Override public String getPackageName() { PsiJavaCodeReferenceElement ref = getPackageReference(); return ref == null ? null : JavaSourceUtil.getReferenceText(ref); }