use of com.intellij.psi.impl.java.stubs.JavaClassReferenceListElementType in project intellij-community by JetBrains.
the class PsiClassReferenceListStubImpl method getReferencedTypes.
@NotNull
@Override
public PsiClassType[] getReferencedTypes() {
if (myTypes != null)
return myTypes;
if (myNames.length == 0) {
myTypes = PsiClassType.EMPTY_ARRAY;
return myTypes;
}
PsiClassType[] types = new PsiClassType[myNames.length];
final boolean compiled = ((JavaClassReferenceListElementType) getStubType()).isCompiled(this);
if (compiled) {
for (int i = 0; i < types.length; i++) {
types[i] = new PsiClassReferenceType(new ClsJavaCodeReferenceElementImpl(getPsi(), myNames[i]), null);
}
} else {
final PsiElementFactory factory = JavaPsiFacade.getInstance(getProject()).getElementFactory();
int nullCount = 0;
final PsiReferenceList psi = getPsi();
for (int i = 0; i < types.length; i++) {
try {
final PsiJavaCodeReferenceElement ref = factory.createReferenceFromText(myNames[i], psi);
((PsiJavaCodeReferenceElementImpl) ref).setKindWhenDummy(PsiJavaCodeReferenceElementImpl.CLASS_NAME_KIND);
types[i] = factory.createType(ref);
} catch (IncorrectOperationException e) {
types[i] = null;
nullCount++;
}
}
if (nullCount > 0) {
PsiClassType[] newTypes = new PsiClassType[types.length - nullCount];
int cnt = 0;
for (PsiClassType type : types) {
if (type != null)
newTypes[cnt++] = type;
}
types = newTypes;
}
}
myTypes = types;
return types.clone();
}
Aggregations