当前位置: 首页>>代码示例>>Java>>正文


Java PsiClassReferenceType类代码示例

本文整理汇总了Java中com.intellij.psi.impl.source.PsiClassReferenceType的典型用法代码示例。如果您正苦于以下问题:Java PsiClassReferenceType类的具体用法?Java PsiClassReferenceType怎么用?Java PsiClassReferenceType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PsiClassReferenceType类属于com.intellij.psi.impl.source包,在下文中一共展示了PsiClassReferenceType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolveCompletions

import com.intellij.psi.impl.source.PsiClassReferenceType; //导入依赖的package包/类
@Override
public Stream<LookupElementBuilder> resolveCompletions(String propertyName, PsiType psiType) {
    PsiType[] parameters = ((PsiClassReferenceType) psiType).getParameters();
    Stream<PsiClass> psiClassStream = null;
    if (parameters.length == 1 && parameters[0] instanceof PsiWildcardType) {
        PsiWildcardType psiWildcardType = ((PsiWildcardType) parameters[0]);
        if (psiWildcardType.isBounded()) {
            if (psiWildcardType.isExtends()) {
                psiClassStream = subClasses((PsiClassType) psiWildcardType.getExtendsBound()).stream();
            } else if (psiWildcardType.isSuper()) {
                psiClassStream = superClasses((PsiClassType) psiWildcardType.getSuperBound()).stream();
            }
        }
    }
    if (psiClassStream != null) {
        return psiClassStream.map(this::buildClassLookup).filter(Optional::isPresent).map(Optional::get);
    } else {
        return Stream.empty();
    }
}
 
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:21,代码来源:ClassCompletionResolver.java

示例2: isPsiMethodCamelLanguage

import com.intellij.psi.impl.source.PsiClassReferenceType; //导入依赖的package包/类
private boolean isPsiMethodCamelLanguage(PsiMethod method) {
    PsiType type = method.getReturnType();
    if (type != null && type instanceof PsiClassReferenceType) {
        PsiClassReferenceType clazz = (PsiClassReferenceType) type;
        PsiClass resolved = clazz.resolve();
        if (resolved != null) {
            boolean language = getCamelIdeaUtils().isCamelExpressionOrLanguage(resolved);
            // try parent using some weird/nasty stub stuff which is how complex IDEA AST
            // is when its parsing the Camel route builder
            if (!language) {
                PsiElement elem = resolved.getParent();
                if (elem instanceof PsiTypeParameterList) {
                    elem = elem.getParent();
                }
                if (elem instanceof PsiClass) {
                    language = getCamelIdeaUtils().isCamelExpressionOrLanguage((PsiClass) elem);
                }
            }
            return language;
        }
    }

    return false;
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:25,代码来源:CamelDocumentationProvider.java

示例3: visitClassType

import com.intellij.psi.impl.source.PsiClassReferenceType; //导入依赖的package包/类
@Override
public SmartTypePointer visitClassType(PsiClassType classType) {
  final PsiClassType.ClassResolveResult resolveResult = classType.resolveGenerics();
  final PsiClass aClass = resolveResult.getElement();
  if (aClass == null) {
    return createClassReferenceTypePointer(classType);
  }
  if (classType instanceof PsiClassReferenceType) {
    classType = ((PsiClassReferenceType)classType).createImmediateCopy();
  }
  final PsiSubstitutor substitutor = resolveResult.getSubstitutor();
  final HashMap<SmartPsiElementPointer, SmartTypePointer> map = new HashMap<SmartPsiElementPointer, SmartTypePointer>();
  for (PsiTypeParameter typeParameter : PsiUtil.typeParametersIterable(aClass)) {
    final PsiType substitutionResult = substitutor.substitute(typeParameter);
    if (substitutionResult != null) {
      final SmartPsiElementPointer pointer = myPsiPointerManager.createSmartPsiElementPointer(typeParameter);
      map.put(pointer, substitutionResult.accept(this));
    }
  }
  return new ClassTypePointer(classType, myPsiPointerManager.createSmartPsiElementPointer(aClass), map);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:SmartTypePointerManagerImpl.java

示例4: getType

import com.intellij.psi.impl.source.PsiClassReferenceType; //导入依赖的package包/类
@Override
public PsiType getType() {
  PsiJavaCodeReferenceElement qualifier = getQualifier();
  if (qualifier != null){
    PsiElement qualifierResolve = qualifier.resolve();
    if (qualifierResolve instanceof PsiClass) return new PsiImmediateClassType((PsiClass)qualifierResolve, PsiSubstitutor.EMPTY);
    return new PsiClassReferenceType(qualifier, null);
  }
  for(PsiElement scope = getContext(); scope != null; scope = scope.getContext()){
    if (scope instanceof PsiClass){
      PsiClass aClass = (PsiClass)scope;
      return new PsiImmediateClassType(aClass, PsiSubstitutor.EMPTY);
    }
    else if (scope instanceof PsiExpressionList && scope.getParent() instanceof PsiAnonymousClass){
      scope = scope.getParent();
    }
    else if (scope instanceof JavaCodeFragment){
      PsiType fragmentThisType = ((JavaCodeFragment)scope).getThisType();
      if (fragmentThisType != null) return fragmentThisType;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:PsiThisExpressionImpl.java

示例5: testParameterListInExtends

import com.intellij.psi.impl.source.PsiClassReferenceType; //导入依赖的package包/类
public void testParameterListInExtends() throws Exception {
  final PsiManager manager = PsiManager.getInstance(myProject);
  final PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
  final PsiClass classFromText = factory.createClassFromText("class X extends Y<Z, W> {}", null);
  final PsiClass classX = classFromText.getInnerClasses()[0];
  final PsiJavaCodeReferenceElement[] extendsOfX = classX.getExtendsList().getReferenceElements();
  assertEquals(1, extendsOfX.length);
  final PsiJavaCodeReferenceElement ref = extendsOfX[0];
  assertEquals("Y<Z,W>", ref.getCanonicalText());
  assertEquals("Y", ref.getReferenceName());
  final PsiTypeElement[] refParams = ref.getParameterList().getTypeParameterElements();
  assertEquals(2, refParams.length);
  assertEquals("Z", refParams[0].getType().getCanonicalText());
  assertEquals("W", refParams[1].getType().getCanonicalText());
  final PsiType refType = factory.createType(ref);
  assertEquals("Y<Z,W>", refType.getCanonicalText());
  final PsiJavaCodeReferenceElement reference = ((PsiClassReferenceType) refType).getReference();
  assertEquals("Y<Z,W>", reference.getCanonicalText());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ReferenceParameterListTest.java

示例6: readMethod

import com.intellij.psi.impl.source.PsiClassReferenceType; //导入依赖的package包/类
@Override
    public void readMethod(PsiCodeBlock methodBody, PsiElementFactory factory, PsiField field) {
        if (null == methodBody) {
            return;
        }

        String fieldName = field.getName();
        String parameterType = ((PsiClassReferenceType) field.getType()).getParameters()[0].getPresentableText();

//        // phones = new ArrayList<>();
//        // in.readTypedList(phones, Phone.CREATOR);
//        methodBody.add(factory.createStatementFromText(fieldName + " = new ArrayList<" + parameterType + ">();", null));
//        methodBody.add(factory.createStatementFromText("in.readTypedList(" + fieldName + ", " + parameterType + ".CREATOR);", null));

        // phones = in.createTypedArrayList(Phone.CREATOR);
        methodBody.add(factory.createStatementFromText(fieldName + " = in.createTypedArrayList(" + parameterType + ".CREATOR);", null));


    }
 
开发者ID:wangjiegulu,项目名称:AndroidParcelablePlugin,代码行数:20,代码来源:ParcelableListGenerator.java

示例7: UnresolvedClassItem

import com.intellij.psi.impl.source.PsiClassReferenceType; //导入依赖的package包/类
UnresolvedClassItem(@NotNull final Converter env, @NotNull final PsiClassReferenceType cls, @Nullable final Parent parent) {
  this.env = env;
  this.cls = cls;
  PsiPackage pkg = Place.getElementPackage(cls.getReference(), env.project);
  _parent = parent == null ? pkg == null ? LocalPkg$.MODULE$ : (Package)env.addContainer(pkg) : parent;

  if (cls instanceof PsiModifierListOwner) {
    _isFinal = ((PsiModifierListOwner)cls).hasModifierProperty(PsiModifier.FINAL);
    _isAbstract = ((PsiModifierListOwner)cls).hasModifierProperty(PsiModifier.ABSTRACT);
    _isStatic = Place.isStatic((PsiModifierListOwner) cls);
  }

  List<TypeArg> jargs = new SmartList<TypeArg>();
  for (PsiType arg : cls.getParameters())
    jargs.add(env.convertTypeArg(arg,parent));
  _targs = scala.collection.JavaConversions.asScalaBuffer(jargs).toList();
}
 
开发者ID:eddysystems,项目名称:eddy,代码行数:18,代码来源:Converter.java

示例8: visitClassType

import com.intellij.psi.impl.source.PsiClassReferenceType; //导入依赖的package包/类
@Nullable
@Override
public TypeBuilder visitClassType(PsiClassType classType) {
    String name = (classType instanceof PsiClassReferenceType) ?
            ((PsiClassReferenceType) classType).getReference().getQualifiedName() :
            classType.getClassName();

    String mappedName = typeParameterMap.containsKey(name) ? typeParameterMap.get(name) : name;

    typeBuilder.withName(mappedName);

    for (PsiType param : classType.getParameters()) {
        PsiTypeParameterConverter converter = new PsiTypeParameterConverter(typeParameterMap);
        param.accept(converter);
        typeBuilder.withTypeBinding(converter.getTypeParameterBuilder());
    }

    return super.visitClassType(classType);
}
 
开发者ID:mistraltechnologies,项目名称:smogen,代码行数:20,代码来源:PsiTypeConverter.java

示例9: matchInflate

import com.intellij.psi.impl.source.PsiClassReferenceType; //导入依赖的package包/类
@Nullable
public static InflateContainer matchInflate(PsiLocalVariable psiLocalVariable) {
    PsiType psiType = psiLocalVariable.getType();
    if(psiType instanceof PsiClassReferenceType) {
        PsiMethodCallExpression psiMethodCallExpression = PsiTreeUtil.findChildOfType(psiLocalVariable, PsiMethodCallExpression.class);
        if(psiMethodCallExpression != null) {
            PsiMethod psiMethod = psiMethodCallExpression.resolveMethod();

            // @TODO: replace "inflate"; resolve method and check nethod calls
            if(psiMethod != null && psiMethod.getName().equals("inflate")) {
                PsiExpression[] expressions = psiMethodCallExpression.getArgumentList().getExpressions();
                if(expressions.length > 0 && expressions[0] instanceof PsiReferenceExpression) {
                    PsiFile xmlFile = AndroidUtils.findXmlResource((PsiReferenceExpression) expressions[0]);
                    if(xmlFile != null) {
                        return new InflateContainer(xmlFile, ((PsiLocalVariable) psiLocalVariable));
                    }
                }
            }
        }
    }

    return null;
}
 
开发者ID:Haehnchen,项目名称:idea-android-studio-plugin,代码行数:24,代码来源:InflateViewAnnotator.java

示例10: visitClassType

import com.intellij.psi.impl.source.PsiClassReferenceType; //导入依赖的package包/类
@Override
public SmartTypePointer visitClassType(PsiClassType classType) {
  final PsiClassType.ClassResolveResult resolveResult = classType.resolveGenerics();
  final PsiClass aClass = resolveResult.getElement();
  if (aClass == null) {
    if (classType instanceof PsiClassReferenceType) {
      return new ClassReferenceTypePointer((PsiClassReferenceType)classType);
    }
    return new SimpleTypePointer(classType);
  }
  if (classType instanceof PsiClassReferenceType) {
    classType = ((PsiClassReferenceType)classType).createImmediateCopy();
  }
  final PsiSubstitutor substitutor = resolveResult.getSubstitutor();
  final HashMap<SmartPsiElementPointer, SmartTypePointer> map = new HashMap<SmartPsiElementPointer, SmartTypePointer>();
  for (PsiTypeParameter typeParameter : PsiUtil.typeParametersIterable(aClass)) {
    final PsiType substitutionResult = substitutor.substitute(typeParameter);
    if (substitutionResult != null) {
      final SmartPsiElementPointer pointer = myPsiPointerManager.createSmartPsiElementPointer(typeParameter);
      map.put(pointer, substitutionResult.accept(this));
    }
  }
  return new ClassTypePointer(classType, myPsiPointerManager.createSmartPsiElementPointer(aClass), map);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:SmartTypePointerManagerImpl.java

示例11: getType

import com.intellij.psi.impl.source.PsiClassReferenceType; //导入依赖的package包/类
@Override
public PsiType getType() {
  PsiJavaCodeReferenceElement qualifier = getQualifier();
  if (qualifier != null){
    PsiClass qualifierResolve = (PsiClass)qualifier.resolve();
    if (qualifierResolve != null) return new PsiImmediateClassType(qualifierResolve, PsiSubstitutor.EMPTY);

    return new PsiClassReferenceType(qualifier, null);
  }
  for(PsiElement scope = getContext(); scope != null; scope = scope.getContext()){
    if (scope instanceof PsiClass){
      PsiClass aClass = (PsiClass)scope;
      return new PsiImmediateClassType(aClass, PsiSubstitutor.EMPTY);
    }
    else if (scope instanceof PsiExpressionList && scope.getParent() instanceof PsiAnonymousClass){
      scope = scope.getParent();
    }
    else if (scope instanceof JavaCodeFragment){
      PsiType fragmentThisType = ((JavaCodeFragment)scope).getThisType();
      if (fragmentThisType != null) return fragmentThisType;
    }
  }
  return null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:25,代码来源:PsiThisExpressionImpl.java

示例12: getTypeText

import com.intellij.psi.impl.source.PsiClassReferenceType; //导入依赖的package包/类
@NotNull
private static String getTypeText(@Nullable PsiType type, boolean isDumb)
{
	// todo PsiTypeVisitor ?
	String result;
	if(type == null)
	{
		result = "";
	}
	else if(!isDumb || type instanceof PsiPrimitiveType)
	{
		result = type.getCanonicalText(false);
	}
	else if(type instanceof PsiClassReferenceType)
	{
		result = ((PsiClassReferenceType) type).getReference().getReferenceName();
	}
	else
	{
		result = "";
	}
	return getShortClassName(notNullize(result));
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:24,代码来源:JavaBreadcrumbsInfoProvider.java

示例13: canHandle

import com.intellij.psi.impl.source.PsiClassReferenceType; //导入依赖的package包/类
@Override
public boolean canHandle(PsiType psiType) {
    if (psiType instanceof PsiClassReferenceType) {
        PsiClass resolved = ((PsiClassReferenceType) psiType).resolve();
        return resolved != null && resolved.isEnum();
    }
    return false;
}
 
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:9,代码来源:EnumCompletionResolver.java

示例14: resolveCompletions

import com.intellij.psi.impl.source.PsiClassReferenceType; //导入依赖的package包/类
@Override
public Stream<LookupElementBuilder> resolveCompletions(String propertyName, PsiType psiType) {
    PsiClass resolved = ((PsiClassReferenceType) psiType).resolve();
    if (resolved != null) {
        return Arrays.stream(resolved.getChildren())
                .filter(child -> child instanceof PsiEnumConstant)
                .map(child -> buildEnumLookup((PsiEnumConstant) child))
                .filter(Optional::isPresent)
                .map(Optional::get);
    }
    return Stream.empty();
}
 
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:13,代码来源:EnumCompletionResolver.java

示例15: canHandle

import com.intellij.psi.impl.source.PsiClassReferenceType; //导入依赖的package包/类
@Override
public boolean canHandle(PsiType psiType) {
    if (psiType instanceof PsiClassReferenceType) {
        PsiClass resolved = ((PsiClassReferenceType) psiType).resolve();
        if (resolved != null && JAVA_LANG_CLASS.equals(resolved.getQualifiedName())) {
            return true;
        }
    }
    return false;
}
 
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:11,代码来源:ClassCompletionResolver.java


注:本文中的com.intellij.psi.impl.source.PsiClassReferenceType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。