use of com.intellij.psi.impl.light.LightClassReference in project intellij-community by JetBrains.
the class PsiClassReferenceType method rawType.
@Override
@NotNull
public PsiClassType rawType() {
PsiJavaCodeReferenceElement reference = getReference();
PsiElement resolved = reference.resolve();
if (resolved instanceof PsiClass) {
PsiClass aClass = (PsiClass) resolved;
if (!PsiUtil.typeParametersIterable(aClass).iterator().hasNext())
return this;
PsiManager manager = reference.getManager();
final PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
final PsiSubstitutor rawSubstitutor = factory.createRawSubstitutor(aClass);
return new PsiImmediateClassType(aClass, rawSubstitutor, getLanguageLevel(), getAnnotationProvider());
}
String qualifiedName = reference.getQualifiedName();
String name = reference.getReferenceName();
if (name == null)
name = "";
LightClassReference lightReference = new LightClassReference(reference.getManager(), name, qualifiedName, reference.getResolveScope());
return new PsiClassReferenceType(lightReference, null, getAnnotationProvider());
}
use of com.intellij.psi.impl.light.LightClassReference in project intellij-community by JetBrains.
the class GrThrowsClauseImpl method getReferenceElements.
@Override
@NotNull
public PsiJavaCodeReferenceElement[] getReferenceElements() {
PsiClassType[] types = getReferencedTypes();
if (types.length == 0)
return PsiJavaCodeReferenceElement.EMPTY_ARRAY;
PsiManagerEx manager = getManager();
List<PsiJavaCodeReferenceElement> result = ContainerUtil.newArrayList();
for (PsiClassType type : types) {
PsiClassType.ClassResolveResult resolveResult = type.resolveGenerics();
PsiClass resolved = resolveResult.getElement();
if (resolved != null) {
result.add(new LightClassReference(manager, type.getCanonicalText(), resolved, resolveResult.getSubstitutor()));
}
}
return result.toArray(new PsiJavaCodeReferenceElement[result.size()]);
}
use of com.intellij.psi.impl.light.LightClassReference in project intellij-community by JetBrains.
the class GrAnnotationImpl method getNameReferenceElement.
@Override
@Nullable
public PsiJavaCodeReferenceElement getNameReferenceElement() {
final GroovyResolveResult resolveResult = getClassReference().advancedResolve();
final PsiElement resolved = resolveResult.getElement();
if (!(resolved instanceof PsiClass))
return null;
return new LightClassReference(getManager(), getClassReference().getText(), (PsiClass) resolved, resolveResult.getSubstitutor());
}
use of com.intellij.psi.impl.light.LightClassReference in project intellij-community by JetBrains.
the class GrLightAnnotation method getNameReferenceElement.
@Override
public PsiJavaCodeReferenceElement getNameReferenceElement() {
final GroovyResolveResult resolveResult = myRef.advancedResolve();
final PsiElement resolved = resolveResult.getElement();
if (resolved instanceof PsiClass) {
return new LightClassReference(getManager(), getClassReference().getText(), (PsiClass) resolved, resolveResult.getSubstitutor());
} else {
return null;
}
}
use of com.intellij.psi.impl.light.LightClassReference in project intellij-community by JetBrains.
the class PsiImplUtil method getType.
@NotNull
public static PsiType getType(@NotNull PsiClassObjectAccessExpression classAccessExpression) {
GlobalSearchScope resolveScope = classAccessExpression.getResolveScope();
PsiManager manager = classAccessExpression.getManager();
final PsiClass classClass = JavaPsiFacade.getInstance(manager.getProject()).findClass("java.lang.Class", resolveScope);
if (classClass == null) {
return new PsiClassReferenceType(new LightClassReference(manager, "Class", "java.lang.Class", resolveScope), null);
}
if (!PsiUtil.isLanguageLevel5OrHigher(classAccessExpression)) {
//Raw java.lang.Class
return JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createType(classClass);
}
PsiSubstitutor substitutor = PsiSubstitutor.EMPTY;
PsiType operandType = classAccessExpression.getOperand().getType();
if (operandType instanceof PsiPrimitiveType && !PsiType.NULL.equals(operandType)) {
if (PsiType.VOID.equals(operandType)) {
operandType = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createTypeByFQClassName("java.lang.Void", classAccessExpression.getResolveScope());
} else {
operandType = ((PsiPrimitiveType) operandType).getBoxedType(classAccessExpression);
}
}
final PsiTypeParameter[] typeParameters = classClass.getTypeParameters();
if (typeParameters.length == 1) {
substitutor = substitutor.put(typeParameters[0], operandType);
}
return new PsiImmediateClassType(classClass, substitutor);
}
Aggregations