@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); }
@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); }
@NotNull @Override public PsiType getType() { return JavaSharedImplUtil.getType(getTypeElement(), getIdentifier()); }
@Override public void normalizeDeclaration() throws IncorrectOperationException { CheckUtil.checkWritable(this); JavaSharedImplUtil.normalizeBrackets(this); }
@Override public void setInitializer(PsiExpression initializer) throws IncorrectOperationException { JavaSharedImplUtil.setInitializer(this, initializer); }
@Override @NotNull public PsiType getType() { return JavaSharedImplUtil.getType(getTypeElement(), getNameIdentifier()); }