Common TypeInfo usage pattern in toString()'s

This commit is contained in:
Roman Shevchenko
2013-02-28 14:30:09 +01:00
parent 9544d5b9fd
commit d0f37b3c7a
3 changed files with 8 additions and 12 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,9 +57,7 @@ public class PsiFieldStubImpl extends StubBase<PsiField> implements PsiFieldStub
@Override
@NotNull
public TypeInfo getType(boolean doResolve) {
if (!doResolve) return myType;
return addApplicableTypeAnnotationsFromChildModifierList(this, myType);
return doResolve ? addApplicableTypeAnnotationsFromChildModifierList(this, myType) : myType;
}
public static TypeInfo addApplicableTypeAnnotationsFromChildModifierList(StubBase<?> aThis, TypeInfo type) {
@@ -126,13 +124,11 @@ public class PsiFieldStubImpl extends StubBase<PsiField> implements PsiFieldStub
if (isDeprecated() || hasDeprecatedAnnotation()) {
builder.append("deprecated ");
}
if (isEnumConstant()) {
builder.append("enumconst ");
}
TypeInfo type = getType(false); // this can be called from low-level code and we don't want resolve to mess with indexing
builder.append(getName()).append(':').append(TypeInfo.createTypeText(type));
builder.append(myName).append(':').append(myType);
if (myInitializer != null) {
builder.append('=').append(myInitializer);
@@ -99,8 +99,7 @@ public class PsiMethodStubImpl extends StubBase<PsiMethod> implements PsiMethodS
@Override
@NotNull
public TypeInfo getReturnTypeText(boolean doResolve) {
if (!doResolve) return myReturnType;
return PsiFieldStubImpl.addApplicableTypeAnnotationsFromChildModifierList(this, myReturnType);
return doResolve ? PsiFieldStubImpl.addApplicableTypeAnnotationsFromChildModifierList(this, myReturnType) : myReturnType;
}
@Override
@@ -162,6 +161,7 @@ public class PsiMethodStubImpl extends StubBase<PsiMethod> implements PsiMethodS
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("PsiMethodStub[");
if (isConstructor()) {
builder.append("cons ");
}
@@ -175,9 +175,9 @@ public class PsiMethodStubImpl extends StubBase<PsiMethod> implements PsiMethodS
builder.append("deprecated ");
}
builder.append(getName()).append(":").append(TypeInfo.createTypeText(getReturnTypeText(false)));
builder.append(myName).append(":").append(myReturnType);
final String defaultValue = getDefaultValueText();
String defaultValue = getDefaultValueText();
if (defaultValue != null) {
builder.append(" default=").append(defaultValue);
}
@@ -97,6 +97,6 @@ public class PsiParameterStubImpl extends StubBase<PsiParameter> implements PsiP
@Override
public String toString() {
return "PsiParameterStub[" + myName + ':' + TypeInfo.createTypeText(getType(false)) + ']';
return "PsiParameterStub[" + myName + ':' + myType + ']';
}
}