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

项目:intellij-ce-playground    文件:PsiMethodImpl.java   
@Override
public PsiType getReturnType() {
  if (isConstructor()) return null;

  final PsiMethodStub stub = getStub();
  if (stub != null) {
    PsiType type = SoftReference.dereference(myCachedType);
    if (type != null) return type;

    final String typeText = TypeInfo.createTypeText(stub.getReturnTypeText(true));
    if (typeText == null) return null;

    try {
      type = JavaPsiFacade.getInstance(getProject()).getElementFactory().createTypeFromText(typeText, this);
      myCachedType = new SoftReference<PsiType>(type);
      return type;
    }
    catch (IncorrectOperationException e) {
      LOG.error("stub: " + stub + "; method: " + getText(), e);
      return null;
    }
  }

  myCachedType = null;
  PsiTypeElement typeElement = getReturnTypeElement();
  if (typeElement == null) return null;
  PsiParameterList parameterList = getParameterList();
  return JavaSharedImplUtil.getType(typeElement, parameterList);
}
项目:consulo-java    文件:PsiFieldImpl.java   
@Override
public void normalizeDeclaration() throws IncorrectOperationException
{
    CheckUtil.checkWritable(this);

    final PsiTypeElement type = getTypeElement();
    PsiElement modifierList = getModifierList();
    ASTNode field = SourceTreeToPsiMap.psiElementToTree(type.getParent());
    while(true)
    {
        ASTNode comma = PsiImplUtil.skipWhitespaceAndComments(field.getTreeNext());
        if(comma == null || comma.getElementType() != JavaTokenType.COMMA)
        {
            break;
        }
        ASTNode nextField = PsiImplUtil.skipWhitespaceAndComments(comma.getTreeNext());
        if(nextField == null || nextField.getElementType() != JavaElementType.FIELD)
        {
            break;
        }

        TreeElement semicolon = Factory.createSingleLeafElement(JavaTokenType.SEMICOLON, ";", 0, 1, null, getManager());
        CodeEditUtil.addChild(field, semicolon, null);

        CodeEditUtil.removeChild(comma.getTreeParent(), comma);

        PsiElement typeClone = type.copy();
        CodeEditUtil.addChild(nextField, SourceTreeToPsiMap.psiElementToTree(typeClone), nextField.getFirstChildNode());

        PsiElement modifierListClone = modifierList.copy();
        CodeEditUtil.addChild(nextField, SourceTreeToPsiMap.psiElementToTree(modifierListClone), nextField.getFirstChildNode());

        field = nextField;
    }

    JavaSharedImplUtil.normalizeBrackets(this);
}
项目:intellij-ce-playground    文件:PsiReceiverParameterImpl.java   
@NotNull
@Override
public PsiType getType() {
  return JavaSharedImplUtil.getType(getTypeElement(), getIdentifier());
}
项目:intellij-ce-playground    文件:PsiParameterImpl.java   
@Override
public void normalizeDeclaration() throws IncorrectOperationException {
  CheckUtil.checkWritable(this);
  JavaSharedImplUtil.normalizeBrackets(this);
}
项目:tools-idea    文件:PsiParameterImpl.java   
@Override
public void normalizeDeclaration() throws IncorrectOperationException {
  CheckUtil.checkWritable(this);
  JavaSharedImplUtil.normalizeBrackets(this);
}
项目:consulo-java    文件:PsiLocalVariableImpl.java   
@Override
public void setInitializer(PsiExpression initializer) throws IncorrectOperationException {
  JavaSharedImplUtil.setInitializer(this, initializer);
}
项目:consulo-java    文件:PsiLocalVariableImpl.java   
@Override
@NotNull
public PsiType getType() {
  return JavaSharedImplUtil.getType(getTypeElement(), getNameIdentifier());
}
项目:consulo-java    文件:PsiReceiverParameterImpl.java   
@NotNull
@Override
public PsiType getType()
{
    return JavaSharedImplUtil.getType(getTypeElement(), getIdentifier());
}
项目:consulo-java    文件:PsiParameterImpl.java   
@Override
public void normalizeDeclaration() throws IncorrectOperationException
{
    CheckUtil.checkWritable(this);
    JavaSharedImplUtil.normalizeBrackets(this);
}
项目:consulo-java    文件:PsiFieldImpl.java   
@Override
public void setInitializer(PsiExpression initializer) throws IncorrectOperationException
{
    JavaSharedImplUtil.setInitializer(this, initializer);
}