public PsiClassReferenceListStubImpl(final JavaClassReferenceListElementType type, final StubElement parent, final String[] names, final PsiReferenceList.Role role) { super(parent, type); myNames = StringRef.createArray(names.length); for (int i = 0; i < names.length; i++) { myNames[i] = StringRef.fromString(names[i]); } myRole = role; }
public PsiClassReferenceListStubImpl(final JavaClassReferenceListElementType type, final StubElement parent, final StringRef[] names, final PsiReferenceList.Role role) { super(parent, type); myNames = names; myRole = role; }
@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(), StringRef.toString(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++) { PsiElement context = psi; if (getParentStub() instanceof PsiClassStub) { context = ((PsiClassImpl)getParentStub().getPsi()).calcBasesResolveContext(PsiNameHelper.getShortClassName(StringRef.toString(myNames[i])), psi); } try { final PsiJavaCodeReferenceElement ref = factory.createReferenceFromText(StringRef.toString(myNames[i]), context); ((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; }
public PsiClassReferenceListStubImpl(@NotNull JavaClassReferenceListElementType type, StubElement parent, @NotNull String[] names) { super(parent, type); ObjectUtils.assertAllElementsNotNull(names); myNames = names; }
@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(); }
@NotNull @Override public PsiReferenceList.Role getRole() { return JavaClassReferenceListElementType.elementTypeToRole(getStubType()); }
private static void newReferenceList(@NotNull JavaClassReferenceListElementType type, StubElement parent, @NotNull String[] types) { new PsiClassReferenceListStubImpl(type, parent, types); }
@Override public Role getRole() { return JavaClassReferenceListElementType.elementTypeToRole(getElementType()); }