Java 类com.intellij.psi.impl.light.LightClassReference 实例源码

项目:intellij-ce-playground    文件:PsiClassReferenceType.java   
@Override
@NotNull
public PsiClassType rawType() {
  PsiElement resolved = myReference.resolve();
  if (resolved instanceof PsiClass) {
    PsiClass aClass = (PsiClass)resolved;
    if (!PsiUtil.typeParametersIterable(aClass).iterator().hasNext()) return this;
    PsiManager manager = myReference.getManager();
    final PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
    final PsiSubstitutor rawSubstitutor = factory.createRawSubstitutor(aClass);
    return factory.createType(aClass, rawSubstitutor, getLanguageLevel(), getAnnotations());
  }
  String qualifiedName = myReference.getQualifiedName();
  String name = myReference.getReferenceName();
  if (name == null) name = "";
  LightClassReference reference = new LightClassReference(myReference.getManager(), name, qualifiedName, myReference.getResolveScope());
  return new PsiClassReferenceType(reference, null, getAnnotations());
}
项目:intellij-ce-playground    文件:GrThrowsClauseImpl.java   
@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()]);
}
项目:tools-idea    文件:PsiClassReferenceType.java   
@Override
@NotNull
public PsiClassType rawType() {
  PsiElement resolved = myReference.resolve();
  if (resolved instanceof PsiClass) {
    PsiClass aClass = (PsiClass)resolved;
    if (!PsiUtil.typeParametersIterable(aClass).iterator().hasNext()) return this;
    PsiManager manager = myReference.getManager();
    final PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
    final PsiSubstitutor rawSubstitutor = factory.createRawSubstitutor(aClass);
    return factory.createType(aClass, rawSubstitutor, getLanguageLevel(), getAnnotations());
  }
  String qualifiedName = myReference.getQualifiedName();
  String name = myReference.getReferenceName();
  if (name == null) name = "";
  LightClassReference reference = new LightClassReference(myReference.getManager(), name, qualifiedName, myReference.getResolveScope());
  return new PsiClassReferenceType(reference, null, getAnnotations());
}
项目:consulo-javaee    文件:JspxImportStatementImpl.java   
@Nullable
@Override
public PsiJavaCodeReferenceElement getImportReference()
{
    if(myErrorElement != null)
    {
        return null;
    }

    if(isOnDemand())
    {
        return new LightPackageReference(getManager(), myQName);
    }
    else
    {
        return new LightClassReference(getManager(), myQName, myQName, getResolveScope());
    }
}
项目:intellij-ce-playground    文件:PsiImplUtil.java   
@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);
}
项目:intellij-ce-playground    文件:GrLightAnnotation.java   
@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;
  }
}
项目:intellij-ce-playground    文件:GrAnnotationImpl.java   
@Override
@Nullable
public PsiJavaCodeReferenceElement getNameReferenceElement() {
  final GroovyResolveResult resolveResult = resolveWithStub();

  final PsiElement resolved = resolveResult.getElement();
  if (!(resolved instanceof PsiClass)) return null;

  return new LightClassReference(getManager(), getClassReference().getText(), (PsiClass)resolved, resolveResult.getSubstitutor());
}
项目:tools-idea    文件:PsiImplUtil.java   
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);
}
项目:tools-idea    文件:GrLightAnnotation.java   
@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;
  }
}
项目:tools-idea    文件:GrAnnotationImpl.java   
@Nullable
public PsiJavaCodeReferenceElement getNameReferenceElement() {
  final GroovyResolveResult resolveResult = getClassReference().advancedResolve();
  final PsiElement resolved = resolveResult.getElement();

  if (resolved instanceof PsiClass) {
    return new LightClassReference(getManager(), getClassReference().getText(), (PsiClass)resolved, resolveResult.getSubstitutor());
  }
  else {
    return null;
  }
}
项目:consulo-java    文件:PsiElementFactoryImpl.java   
@NotNull
@Override
public PsiJavaCodeReferenceElement createClassReferenceElement(@NotNull final PsiClass aClass)
{
    final String text;
    if(aClass instanceof PsiAnonymousClass)
    {
        text = ((PsiAnonymousClass) aClass).getBaseClassType().getPresentableText();
    }
    else
    {
        text = aClass.getName();
    }
    return new LightClassReference(myManager, text, aClass);
}
项目:consulo-java    文件:PsiElementFactoryImpl.java   
@NotNull
@Override
public PsiJavaCodeReferenceElement createReferenceElementByFQClassName(@NotNull final String qName, @NotNull final GlobalSearchScope resolveScope)
{
    final String shortName = PsiNameHelper.getShortClassName(qName);
    return new LightClassReference(myManager, shortName, qName, resolveScope);
}
项目:consulo-java    文件:PsiClassReferenceType.java   
@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());
}
项目:consulo-java    文件:PsiImplUtil.java   
@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);
}
项目:intellij-ce-playground    文件:PsiEnumConstantInitializerImpl.java   
@Override
@NotNull
public PsiJavaCodeReferenceElement getBaseClassReference() {
  PsiClass containingClass = getBaseClass();
  return new LightClassReference(getManager(), containingClass.getName(), containingClass);
}
项目:tools-idea    文件:PsiEnumConstantInitializerImpl.java   
@Override
@NotNull
public PsiJavaCodeReferenceElement getBaseClassReference() {
  PsiClass containingClass = getBaseClass();
  return new LightClassReference(getManager(), containingClass.getName(), containingClass);
}
项目:consulo-java    文件:PsiElementFactoryImpl.java   
@NotNull
@Override
public PsiJavaCodeReferenceElement createFQClassNameReferenceElement(@NotNull final String qName, @NotNull final GlobalSearchScope resolveScope)
{
    return new LightClassReference(myManager, qName, qName, resolveScope);
}
项目:consulo-java    文件:PsiEnumConstantInitializerImpl.java   
@Override
@NotNull
public PsiJavaCodeReferenceElement getBaseClassReference() {
  PsiClass containingClass = getBaseClass();
  return new LightClassReference(getManager(), containingClass.getName(), containingClass);
}