Java 类com.intellij.psi.impl.source.tree.JavaSourceUtil 实例源码

项目:intellij-ce-playground    文件:JavaImportStatementElementType.java   
@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);
}
项目:consulo-java    文件:JavaImportStatementElementType.java   
@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);
}
项目:consulo-java    文件:JavaPackageAccessibilityStatementElementType.java   
@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);
}
项目:consulo-java    文件:JavaLightStubBuilder.java   
@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);
}
项目:consulo-java    文件:JavaProvidesStatementElementType.java   
@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);
}
项目:consulo-java    文件:JavaUsesStatementElementType.java   
@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);
}
项目:consulo-java    文件:JavaRequiresStatementElementType.java   
@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);
}
项目:consulo-java    文件:PsiJavaCodeReferenceElementImpl.java   
private String getNormalizedText()
{
    String whiteSpaceAndComments = myCachedNormalizedText;
    if(whiteSpaceAndComments == null)
    {
        myCachedNormalizedText = whiteSpaceAndComments = JavaSourceUtil.getReferenceText(this);
    }
    return whiteSpaceAndComments;
}
项目:consulo-java    文件:PsiJavaCodeReferenceElementImpl.java   
@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);
}
项目:consulo-java    文件:PsiReferenceExpressionImpl.java   
private String getCachedNormalizedText()
{
    String whiteSpaceAndComments = myCachedNormalizedText;
    if(whiteSpaceAndComments == null)
    {
        myCachedNormalizedText = whiteSpaceAndComments = JavaSourceUtil.getReferenceText(this);
    }
    return whiteSpaceAndComments;
}
项目:consulo-java    文件:ExpressionPsiElement.java   
@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);
}
项目:consulo-java    文件:AnnotationParamListElement.java   
@Override
public void deleteChildInternal(@NotNull ASTNode child)
{
    if(child.getElementType() == JavaElementType.NAME_VALUE_PAIR)
    {
        JavaSourceUtil.deleteSeparatingComma(this, child);
    }

    super.deleteChildInternal(child);
}
项目:consulo-java    文件:PsiArrayInitializerMemberValueImpl.java   
@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);
}
项目:consulo-java    文件:PsiArrayInitializerMemberValueImpl.java   
@Override
public void deleteChildInternal(@NotNull ASTNode child)
{
    if(MEMBER_SET.contains(child.getElementType()))
    {
        JavaSourceUtil.deleteSeparatingComma(this, child);
    }

    super.deleteChildInternal(child);
}
项目:intellij-haxe    文件:HaxeReferenceImpl.java   
@Override
public String getQualifiedName() {
  return JavaSourceUtil.getReferenceText(this);
}
项目:consulo-java    文件:JavaModuleElementType.java   
@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));
}
项目:consulo-java    文件:PsiReferenceExpressionImpl.java   
@Override
public void fullyQualify(@NotNull PsiClass targetClass)
{
    JavaSourceUtil.fullyQualifyReference(this, targetClass);
}
项目:consulo-java    文件:PsiPackageStatementImpl.java   
@Override
public String getPackageName()
{
    PsiJavaCodeReferenceElement ref = getPackageReference();
    return ref == null ? null : JavaSourceUtil.getReferenceText(ref);
}