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


Java PsiClassType.ClassResolveResult方法代码示例

本文整理汇总了Java中com.intellij.psi.PsiClassType.ClassResolveResult方法的典型用法代码示例。如果您正苦于以下问题:Java PsiClassType.ClassResolveResult方法的具体用法?Java PsiClassType.ClassResolveResult怎么用?Java PsiClassType.ClassResolveResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.PsiClassType的用法示例。


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

示例1: create

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
@Nullable
public static TargetType create(final PsiClassType classType) {
  final PsiClassType.ClassResolveResult resolvedGenerics = classType.resolveGenerics();
  final PsiClass resolvedClass = resolvedGenerics.getElement();
  if (resolvedClass == null) {
    return null;
  }
  final String classQName = resolvedClass.getQualifiedName();
  if (classQName == null) {
    return null;
  }
  if (resolvedClass.hasTypeParameters()) {
    return null;
  }
  return new TargetType(classQName, false, classType);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:TargetType.java

示例2: getReferenceElements

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
@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()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:GrThrowsClauseImpl.java

示例3: extractTypeParameters

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
@NotNull
public static PsiType[] extractTypeParameters(@NotNull PsiType psiType, @NotNull PsiManager psiManager) {
  if (!(psiType instanceof PsiClassType)) {
    return PsiType.EMPTY_ARRAY;
  }

  final PsiClassType classType = (PsiClassType) psiType;
  final PsiClassType.ClassResolveResult classResolveResult = classType.resolveGenerics();
  final PsiClass psiClass = classResolveResult.getElement();
  if (psiClass == null) {
    return PsiType.EMPTY_ARRAY;
  }
  final PsiSubstitutor psiSubstitutor = classResolveResult.getSubstitutor();

  final PsiTypeParameter[] typeParameters = psiClass.getTypeParameters();

  final PsiType[] psiTypes = PsiType.createArray(typeParameters.length);
  for (int i = 0; i < typeParameters.length; i++) {
    PsiType psiSubstituteKeyType = psiSubstitutor.substitute(typeParameters[i]);
    if (null == psiSubstituteKeyType) {
      psiSubstituteKeyType = PsiType.getJavaLangObject(psiManager, GlobalSearchScope.allScope(psiManager.getProject()));
    }
    psiTypes[i] = psiSubstituteKeyType;
  }
  return psiTypes;
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:27,代码来源:PsiTypeUtil.java

示例4: visitType

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
private void visitType(@NotNull PsiClassType type, Map<PsiClass, PsiClassType.ClassResolveResult> map)
{
	PsiClassType.ClassResolveResult resolveResult = type.resolveGenerics();
	PsiClass psiClass = resolveResult.getElement();
	if(psiClass == null || InheritanceImplUtil.hasObjectQualifiedName(psiClass) || map.containsKey(psiClass))
	{
		return;
	}

	map.put(psiClass, resolveResult);

	for(PsiType superType : getSuperTypes(psiClass))
	{
		superType = type.isRaw() && superType instanceof PsiClassType ? ((PsiClassType) superType).rawType() : resolveResult.getSubstitutor().substitute(superType);
		superType = PsiClassImplUtil.correctType(superType, myResolveScope);
		if(superType instanceof PsiClassType)
		{
			visitType((PsiClassType) superType, map);
		}
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:22,代码来源:ScopedClassHierarchy.java

示例5: getSuperClassSubstitutor

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
@Nullable
static PsiSubstitutor getSuperClassSubstitutor(@NotNull PsiClass derivedClass, @NotNull GlobalSearchScope scope, @NotNull PsiClass superClass)
{
	ScopedClassHierarchy hierarchy = getHierarchy(derivedClass, scope);
	Map<PsiClass, PsiClassType.ClassResolveResult> map = hierarchy.mySupersWithSubstitutors;
	if(map == null)
	{
		map = ContainerUtil.newTroveMap(CLASS_HASHING_STRATEGY);
		RecursionGuard.StackStamp stamp = ourGuard.markStack();
		hierarchy.visitType(JavaPsiFacade.getElementFactory(derivedClass.getProject()).createType(derivedClass, PsiSubstitutor.EMPTY), map);
		if(stamp.mayCacheNow())
		{
			hierarchy.mySupersWithSubstitutors = map;
		}
	}
	PsiClassType.ClassResolveResult resolveResult = map.get(superClass);
	if(resolveResult == null)
	{
		return null;
	}

	PsiClass cachedClass = assertNotNull(resolveResult.getElement());
	PsiSubstitutor cachedSubstitutor = resolveResult.getSubstitutor();
	return cachedClass == superClass ? cachedSubstitutor : mirrorSubstitutor(superClass, cachedClass, cachedSubstitutor);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:26,代码来源:ScopedClassHierarchy.java

示例6: getImmediateSupersWithCapturing

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
@NotNull
List<PsiClassType.ClassResolveResult> getImmediateSupersWithCapturing()
{
	List<PsiClassType.ClassResolveResult> list = myImmediateSupersWithCapturing;
	if(list == null)
	{
		RecursionGuard.StackStamp stamp = ourGuard.markStack();
		list = ourGuard.doPreventingRecursion(this, true, new Computable<List<PsiClassType.ClassResolveResult>>()
		{
			@Override
			public List<PsiClassType.ClassResolveResult> compute()
			{
				return calcImmediateSupersWithCapturing();
			}
		});
		if(list == null)
		{
			return Collections.emptyList();
		}
		if(stamp.mayCacheNow())
		{
			myImmediateSupersWithCapturing = list;
		}
	}
	return list;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:27,代码来源:ScopedClassHierarchy.java

示例7: calcImmediateSupersWithCapturing

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
@NotNull
private List<PsiClassType.ClassResolveResult> calcImmediateSupersWithCapturing()
{
	List<PsiClassType.ClassResolveResult> list;
	list = ContainerUtil.newArrayList();
	for(PsiClassType type : myPlaceClass.getSuperTypes())
	{
		PsiClassType corrected = PsiClassImplUtil.correctType(type, myResolveScope);
		if(corrected == null)
		{
			continue;
		}

		PsiClassType.ClassResolveResult result = ((PsiClassType) PsiUtil.captureToplevelWildcards(corrected, myPlaceClass)).resolveGenerics();
		PsiClass superClass = result.getElement();
		if(superClass == null || !PsiSearchScopeUtil.isInScope(myResolveScope, superClass))
		{
			continue;
		}

		list.add(result);
	}
	return list;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:25,代码来源:ScopedClassHierarchy.java

示例8: visitClassType

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
public X visitClassType(final PsiClassType classType) {
  super.visitClassType(classType);
  final PsiClassType.ClassResolveResult result = classType.resolveGenerics();

  if (result.getElement() != null) {
    for (final PsiType type : result.getSubstitutor().getSubstitutionMap().values()) {
      if (type != null) {
        type.accept(this);
      }
    }
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:PsiExtendedTypeVisitor.java

示例9: from

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
@NotNull
public static GroovyResolveResult from(@NotNull PsiClassType.ClassResolveResult classResolveResult) {
  if (classResolveResult.getElement() == null) return GroovyResolveResult.EMPTY_RESULT;
  return new GroovyResolveResultImpl(
    classResolveResult.getElement(),
    null,
    null,
    classResolveResult.getSubstitutor(),
    classResolveResult.isAccessible(),
    classResolveResult.isStaticsScopeCorrect(),
    false,
    classResolveResult.isValidResult()
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:GroovyResolveResultImpl.java

示例10: suggestVariantsForCollectionMembers

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
private List<FieldExpression> suggestVariantsForCollectionMembers(PsiType nextExtensionBaseType, int depth, String nexpr) {
  List<FieldExpression> result = new LinkedList<FieldExpression>();
  PsiClass nextExtensionBase = PsiUtil.resolveClassInType(nextExtensionBaseType);
  if (nextExtensionBase != null) {
    result.addAll(suggestVariants(nextExtensionBase, nexpr, depth - 1));

    final String nexprComp = nexpr + "[0]";
    if (nextExtensionBaseType instanceof PsiArrayType) {
      result.add(new FieldExpression(fieldDefinition, nexprComp));

      PsiType compType = ((PsiArrayType) nextExtensionBaseType).getComponentType();
      PsiClass compClass = PsiUtil.resolveClassInType(compType);
      if (compClass != null) {
        result.addAll(suggestVariants(compClass, nexprComp, depth - 1));
      }
    }
    else if (isOfTypeList(nextExtensionBase)) {
      PsiClassType listClassType = (PsiClassType) nextExtensionBaseType;
      if (listClassType.hasParameters()) {
        PsiClassType.ClassResolveResult resolveResult = listClassType.resolveGenerics();
        PsiType paramType = resolveResult.getSubstitutor().substitute(listClassType.getParameters()[0]);
        if (paramType instanceof PsiClassType) {
          PsiClass paramClass = PsiUtil.resolveClassInType(paramType);
          result.addAll(suggestVariants(paramClass, nexprComp, depth - 1));
        }
      }
      result.add(new FieldExpression(fieldDefinition, nexprComp));
    }
  }
  return result;
}
 
开发者ID:hypoport,项目名称:idea-dozer-plugin,代码行数:32,代码来源:FieldExpression.java

示例11: addMethodsOfType

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
private void addMethodsOfType(PsiType psiType, Collection<Pair<PsiMethod, PsiSubstitutor>> allMethods) {
  final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(psiType);

  final PsiClass psiClass = resolveResult.getElement();
  if (null != psiClass) {
    collectAllMethods(allMethods, psiClass, resolveResult.getSubstitutor());
  }
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:9,代码来源:DelegateHandler.java

示例12: getPsiClass

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
private static PsiClass getPsiClass(PsiClass wrapperClass, PsiType psiFieldType) {
  PsiClassType psiClassType = (PsiClassType) psiFieldType;

  PsiClassType.ClassResolveResult classResolveResult = psiClassType.resolveGenerics();
  PsiClass outerClass = classResolveResult.getElement();

  // If Lazy<Foo> or Provider<Foo>, extract Foo as the interesting type.
  if (PsiConsultantImpl.isLazyOrProvider(outerClass)) {
    PsiType genericType = extractFirstTypeParameter(psiClassType);
    // Convert genericType to its PsiClass and store in psiClass
    wrapperClass = getClass(genericType);
  }

  return wrapperClass;
}
 
开发者ID:square,项目名称:dagger-intellij-plugin,代码行数:16,代码来源:PsiConsultantImpl.java

示例13: isUncheckedConversion

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
public static boolean isUncheckedConversion(final PsiType t, final PsiType s)
{
	if(t instanceof PsiClassType && !((PsiClassType) t).isRaw() && s instanceof PsiClassType)
	{
		final PsiClassType.ClassResolveResult tResult = ((PsiClassType) t).resolveGenerics();
		final PsiClassType.ClassResolveResult sResult = ((PsiClassType) s).resolveGenerics();
		final PsiClass tClass = tResult.getElement();
		final PsiClass sClass = sResult.getElement();
		if(tClass != null && sClass != null && !(sClass instanceof InferenceVariable))
		{
			final PsiSubstitutor sSubstitutor = TypeConversionUtil.getClassSubstitutor(tClass, sClass, sResult.getSubstitutor());
			if(sSubstitutor != null)
			{
				if(PsiUtil.isRawSubstitutor(tClass, sSubstitutor))
				{
					return true;
				}
			}
			else if(tClass instanceof InferenceVariable && ((PsiClassType) s).isRaw() && tClass.isInheritor(sClass, true))
			{
				return true;
			}
		}
	}
	else if(t instanceof PsiArrayType && t.getArrayDimensions() == s.getArrayDimensions())
	{
		return isUncheckedConversion(t.getDeepComponentType(), s.getDeepComponentType());
	}
	return false;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:31,代码来源:TypeCompatibilityConstraint.java

示例14: getCollectionClassType

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
@NotNull
public static PsiClassType getCollectionClassType(@NotNull PsiClassType psiType, @NotNull Project project, @NotNull String qualifiedName) {
  final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
  final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
  final GlobalSearchScope globalsearchscope = GlobalSearchScope.allScope(project);

  PsiClass genericClass = facade.findClass(qualifiedName, globalsearchscope);
  if (null != genericClass) {
    final PsiClassType.ClassResolveResult classResolveResult = psiType.resolveGenerics();
    final PsiSubstitutor derivedSubstitutor = classResolveResult.getSubstitutor();

    final List<PsiType> typeList = new ArrayList<PsiType>(2);
    final Map<String, PsiType> nameTypeMap = new HashMap<String, PsiType>();
    for (Map.Entry<PsiTypeParameter, PsiType> entry : derivedSubstitutor.getSubstitutionMap().entrySet()) {
      final PsiType entryValue = entry.getValue();
      if (null != entryValue) {
        nameTypeMap.put(entry.getKey().getName(), entryValue);
        typeList.add(entryValue);
      }
    }

    PsiSubstitutor genericSubstitutor = PsiSubstitutor.EMPTY;
    final PsiTypeParameter[] typeParameters = genericClass.getTypeParameters();
    for (int i = 0; i < typeParameters.length; i++) {
      final PsiTypeParameter psiTypeParameter = typeParameters[i];
      PsiType mappedType = nameTypeMap.get(psiTypeParameter.getName());
      if (null == mappedType && typeList.size() > i) {
        mappedType = typeList.get(i);
      }
      if (null == mappedType) {
        mappedType = PsiType.getJavaLangObject(PsiManager.getInstance(project), globalsearchscope);
      }

      if (mappedType instanceof PsiWildcardType) {
        mappedType = ((PsiWildcardType) mappedType).getBound();
      }
      genericSubstitutor = genericSubstitutor.put(psiTypeParameter, mappedType);
    }
    return elementFactory.createType(genericClass, genericSubstitutor);
  }
  return elementFactory.createTypeByFQClassName(qualifiedName, globalsearchscope);
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:43,代码来源:PsiTypeUtil.java

示例15: getType

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
@Nullable
public <T extends PsiExpression> PsiType getType(@NotNull T expr, @NotNull Function<T, PsiType> f)
{
	final boolean isOverloadCheck = MethodCandidateInfo.isOverloadCheck() || LambdaUtil.isLambdaParameterCheck();
	final boolean polyExpression = PsiPolyExpressionUtil.isPolyExpression(expr);
	PsiType type = isOverloadCheck && polyExpression ? null : myCalculatedTypes.get(expr);
	if(type == null)
	{
		final RecursionGuard.StackStamp dStackStamp = PsiDiamondType.ourDiamondGuard.markStack();
		type = f.fun(expr);
		if(!dStackStamp.mayCacheNow())
		{
			return type;
		}

		//cache standalone expression types as they do not depend on the context
		if(isOverloadCheck && polyExpression)
		{
			return type;
		}

		if(type == null)
		{
			type = TypeConversionUtil.NULL_TYPE;
		}
		myCalculatedTypes.put(expr, type);

		if(type instanceof PsiClassReferenceType)
		{
			// convert reference-based class type to the PsiImmediateClassType, since the reference may become invalid
			PsiClassType.ClassResolveResult result = ((PsiClassReferenceType) type).resolveGenerics();
			PsiClass psiClass = result.getElement();
			type = psiClass == null ? type // for type with unresolved reference, leave it in the cache
					// for clients still might be able to retrieve its getCanonicalText() from the reference text
					: new PsiImmediateClassType(psiClass, result.getSubstitutor(), ((PsiClassReferenceType) type).getLanguageLevel(), type.getAnnotationProvider());
		}
	}

	if(!type.isValid())
	{
		if(expr.isValid())
		{
			PsiJavaCodeReferenceElement refInside = type instanceof PsiClassReferenceType ? ((PsiClassReferenceType) type).getReference() : null;
			@NonNls String typeinfo = type + " (" + type.getClass() + ")" + (refInside == null ? "" : "; ref inside: " + refInside + " (" + refInside.getClass() + ") valid:" + refInside.isValid
					());
			LOG.error("Type is invalid: " + typeinfo + "; expr: '" + expr + "' (" + expr.getClass() + ") is valid");
		}
		else
		{
			LOG.error("Expression: '" + expr + "' is invalid, must not be used for getType()");
		}
	}

	return type == TypeConversionUtil.NULL_TYPE ? null : type;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:56,代码来源:JavaResolveCache.java


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