• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PsiWildcardType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: resolveCompletions

import com.intellij.psi.PsiWildcardType; //导入依赖的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: maybeGetLowerBound

import com.intellij.psi.PsiWildcardType; //导入依赖的package包/类
private static PsiType maybeGetLowerBound( PsiWildcardType type, TypeVarToTypeMap actualParamByVarName, boolean bKeepTypeVars, LinkedHashSet<PsiType> recursiveTypes )
{
  PsiType lower = type.getSuperBound();
  if( lower != PsiType.NULL && recursiveTypes.size() > 0 )
  {
    // This is a "super" (contravariant) wildcard

    LinkedList<PsiType> list = new LinkedList<>( recursiveTypes );
    PsiType enclType = list.getLast();
    if( isParameterizedType( enclType ) )
    {
      PsiType genType = getActualType( ((PsiClassType)enclType).rawType(), actualParamByVarName, bKeepTypeVars, recursiveTypes );
      if( LambdaUtil.isFunctionalType( genType ) )
      {
        // For functional interfaces we keep the lower bound as an upper bound so that blocks maintain contravariance wrt the single method's parameters
        return lower;
      }
    }
  }
  return null;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:22,代码来源:TypeUtil.java


示例3: guessTypes

import com.intellij.psi.PsiWildcardType; //导入依赖的package包/类
@Nullable
private static PsiType[] guessTypes(Expression[] params, ExpressionContext context) {
  if (params.length != 1) return null;
  final Result result = params[0].calculateResult(context);
  if (result == null) return null;

  Project project = context.getProject();

  PsiExpression expr = MacroUtil.resultToPsiExpression(result, context);
  if (expr == null) return null;
  PsiType[] types = GuessManager.getInstance(project).guessContainerElementType(expr, new TextRange(context.getTemplateStartOffset(), context.getTemplateEndOffset()));
  for (int i = 0; i < types.length; i++) {
    PsiType type = types[i];
    if (type instanceof PsiWildcardType) {
      if (((PsiWildcardType)type).isExtends()) {
        types[i] = ((PsiWildcardType)type).getBound();
      } else {
        types[i] = PsiType.getJavaLangObject(expr.getManager(), expr.getResolveScope());
      }
    }
  }
  return types;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:GuessElementTypeMacro.java


示例4: getClosureParameterType

import com.intellij.psi.PsiWildcardType; //导入依赖的package包/类
@Nullable
@Override
protected PsiType getClosureParameterType(GrClosableBlock closure, int index) {

  PsiFile file = closure.getContainingFile();
  if (file == null || !FileUtilRt.extensionEquals(file.getName(), GradleConstants.EXTENSION)) return null;

  PsiType psiType = super.getClosureParameterType(closure, index);
  if (psiType instanceof PsiWildcardType) {
    PsiWildcardType wildcardType = (PsiWildcardType)psiType;
    if (wildcardType.isSuper() && wildcardType.getBound() != null &&
        wildcardType.getBound().equalsToText(GradleCommonClassNames.GRADLE_API_SOURCE_SET)) {
      return wildcardType.getBound();
    }
    if (wildcardType.isSuper() && wildcardType.getBound() != null &&
        wildcardType.getBound().equalsToText(GradleCommonClassNames.GRADLE_API_DISTRIBUTION)) {
      return wildcardType.getBound();
    }
  }

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


示例5: getName

import com.intellij.psi.PsiWildcardType; //导入依赖的package包/类
public String getName() {
  PsiType type = psiType;
  if (type instanceof PsiWildcardType) {
    type = ((PsiWildcardType)type).getBound();
  }
  if (type instanceof PsiClassType) {
    final PsiClass resolve = ((PsiClassType)type).resolve();
    if (resolve != null) {
      return resolve.getName();
    }
    final String canonicalText = type.getCanonicalText();
    final int i = canonicalText.indexOf('<');
    if (i < 0) return canonicalText;
    return canonicalText.substring(0, i);
  }

  if (type == null) {
    return "";
  }

  return type.getCanonicalText();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:GdslType.java


示例6: extractAllElementType

import com.intellij.psi.PsiWildcardType; //导入依赖的package包/类
@NotNull
public static PsiType extractAllElementType(@NotNull PsiType psiType, @NotNull PsiManager psiManager, final String superClass, final int paramIndex) {
  PsiType oneElementType = PsiUtil.substituteTypeParameter(psiType, superClass, paramIndex, true);
  if (oneElementType instanceof PsiWildcardType) {
    oneElementType = ((PsiWildcardType) oneElementType).getBound();
  }

  PsiType result;
  final PsiClassType javaLangObject = PsiType.getJavaLangObject(psiManager, GlobalSearchScope.allScope(psiManager.getProject()));
  if (null == oneElementType || Comparing.equal(javaLangObject, oneElementType)) {
    result = PsiWildcardType.createUnbounded(psiManager);
  } else {
    result = PsiWildcardType.createExtends(psiManager, oneElementType);
  }

  return result;
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:18,代码来源:PsiTypeUtil.java


示例7: upDown

import com.intellij.psi.PsiWildcardType; //导入依赖的package包/类
/**
 * a = S & a <: T imply S <: T
 * or
 * a = S & T <: a imply T <: S
 * or
 * S <: a & a <: T imply S <: T
 */
private void upDown(Collection<PsiType> eqBounds, Collection<PsiType> upperBounds)
{
	for(PsiType upperBound : upperBounds)
	{
		if(upperBound == null || PsiType.NULL.equals(upperBound) || upperBound instanceof PsiWildcardType)
		{
			continue;
		}

		for(PsiType eqBound : eqBounds)
		{
			if(eqBound == null || PsiType.NULL.equals(eqBound) || eqBound instanceof PsiWildcardType)
			{
				continue;
			}
			if(JAVAC_UNCHECKED_SUBTYPING_DURING_INCORPORATION && TypeCompatibilityConstraint.isUncheckedConversion(upperBound, eqBound))
			{
				continue;
			}

			addConstraint(new StrictSubtypingConstraint(upperBound, eqBound));
		}
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:32,代码来源:InferenceIncorporationPhase.java


示例8: upUp

import com.intellij.psi.PsiWildcardType; //导入依赖的package包/类
/**
 * If two bounds have the form α <: S and α <: T, and if for some generic class or interface, G,
 * there exists a supertype (4.10) of S of the form G<S1, ..., Sn> and a supertype of T of the form G<T1, ..., Tn>,
 * then for all i, 1 ≤ i ≤ n, if Si and Ti are types (not wildcards), the constraint ⟨Si = Ti⟩ is implied.
 */
private boolean upUp(List<PsiType> upperBounds)
{
	return InferenceSession.findParameterizationOfTheSameGenericClass(upperBounds, new Processor<Pair<PsiType, PsiType>>()
	{
		@Override
		public boolean process(Pair<PsiType, PsiType> pair)
		{
			final PsiType sType = pair.first;
			final PsiType tType = pair.second;
			if(!(sType instanceof PsiWildcardType) && !(tType instanceof PsiWildcardType) && sType != null && tType != null)
			{
				addConstraint(new TypeEqualityConstraint(sType, tType));
			}
			return false;
		}
	}) != null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:23,代码来源:InferenceIncorporationPhase.java


示例9: adjustInferredType

import com.intellij.psi.PsiWildcardType; //导入依赖的package包/类
@Override
public PsiType adjustInferredType(PsiManager manager, PsiType guess, ConstraintType constraintType)
{
	if(guess != null && !(guess instanceof PsiWildcardType))
	{
		if(constraintType == ConstraintType.SUPERTYPE)
		{
			return PsiWildcardType.createExtends(manager, guess);
		}
		else if(constraintType == ConstraintType.SUBTYPE)
		{
			return PsiWildcardType.createSuper(manager, guess);
		}
	}
	return guess;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:CompletionParameterTypeInferencePolicy.java


示例10: getType

import com.intellij.psi.PsiWildcardType; //导入依赖的package包/类
@Override
@NotNull
public PsiType getType() {
  final GrTypeElement boundTypeElement = getBoundTypeElement();
  if (boundTypeElement == null) return PsiWildcardType.createUnbounded(getManager());
  if (isExtends()) return PsiWildcardType.createExtends(getManager(), boundTypeElement.getType());
  if (isSuper()) return PsiWildcardType.createSuper(getManager(), boundTypeElement.getType());

  LOG.error("Untested case");
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:GrWildcardTypeArgumentImpl.java


示例11: visitWildcardType

import com.intellij.psi.PsiWildcardType; //导入依赖的package包/类
@Nullable
@Override
public Object visitWildcardType(PsiWildcardType wildcardType) {
    if (wildcardType.getBound() != null) {
        wildcardType.getBound().accept(this);
    }

    typeParameterBuilder.withSubTypes(wildcardType.isExtends());
    typeParameterBuilder.withSuperTypes(wildcardType.isSuper());

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


示例12: getType

import com.intellij.psi.PsiWildcardType; //导入依赖的package包/类
@NotNull
public PsiType getType() {
  final GrTypeElement boundTypeElement = getBoundTypeElement();
  if (boundTypeElement == null) return PsiWildcardType.createUnbounded(getManager());
  if (isExtends()) return PsiWildcardType.createExtends(getManager(), boundTypeElement.getType());
  if (isSuper()) return PsiWildcardType.createSuper(getManager(), boundTypeElement.getType());

  LOG.error("Untested case");
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:11,代码来源:GrWildcardTypeArgumentImpl.java


示例13: extractOneElementType

import com.intellij.psi.PsiWildcardType; //导入依赖的package包/类
@NotNull
public static PsiType extractOneElementType(@NotNull PsiType psiType, @NotNull PsiManager psiManager, final String superClass, final int paramIndex) {
  PsiType oneElementType = PsiUtil.substituteTypeParameter(psiType, superClass, paramIndex, true);
  if (oneElementType instanceof PsiWildcardType) {
    oneElementType = ((PsiWildcardType) oneElementType).getBound();
  }
  if (null == oneElementType) {
    oneElementType = PsiType.getJavaLangObject(psiManager, GlobalSearchScope.allScope(psiManager.getProject()));
  }
  return oneElementType;
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:12,代码来源:PsiTypeUtil.java


示例14: patchGetClass

import com.intellij.psi.PsiWildcardType; //导入依赖的package包/类
@Nullable
private PsiType patchGetClass(@Nullable PsiType type)
{
	if(myMember instanceof PsiMethod && PsiTypesUtil.isGetClass((PsiMethod) myMember) && type instanceof PsiClassType)
	{
		PsiType arg = ContainerUtil.getFirstItem(Arrays.asList(((PsiClassType) type).getParameters()));
		PsiType bound = arg instanceof PsiWildcardType ? TypeConversionUtil.erasure(((PsiWildcardType) arg).getExtendsBound()) : null;
		if(bound != null)
		{
			return PsiTypesUtil.createJavaLangClassType(myMember, bound, false);
		}
	}
	return type;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:15,代码来源:MemberLookupHelper.java


示例15: getInferredTypeWithNoConstraint

import com.intellij.psi.PsiWildcardType; //导入依赖的package包/类
@Override
public Pair<PsiType, ConstraintType> getInferredTypeWithNoConstraint(PsiManager psiManager, PsiType superType)
{
	if(!(superType instanceof PsiWildcardType))
	{
		return new Pair<>(PsiWildcardType.createExtends(psiManager, superType), ConstraintType.EQUALS);
	}
	else
	{
		return Pair.create(superType, ConstraintType.SUBTYPE);
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:13,代码来源:CompletionParameterTypeInferencePolicy.java


示例16: replaceTypeVariableTypeParametersWithBoundingTypes

import com.intellij.psi.PsiWildcardType; //导入依赖的package包/类
public static PsiType replaceTypeVariableTypeParametersWithBoundingTypes( PsiType type, PsiType enclType )
{
  if( isTypeVariable( type ) )
  {
    PsiClass boundingType = getBoundingType( (PsiTypeParameter)((PsiClassType)type).resolve() );

    if( isRecursiveType( (PsiClassType)type, type( boundingType ) ) )
    {
      // short-circuit recursive typevar
      return ((PsiClassType)type( boundingType )).rawType();
    }

    if( enclType != null && isParameterizedType( enclType ) )
    {
      TypeVarToTypeMap map = mapTypeByVarName( enclType, enclType );
      return replaceTypeVariableTypeParametersWithBoundingTypes( getActualType( type( boundingType ), map, true ) );
    }

    return replaceTypeVariableTypeParametersWithBoundingTypes( type( boundingType ), enclType );
  }

  if( type.getArrayDimensions() > 0 )
  {
    return new PsiArrayType( replaceTypeVariableTypeParametersWithBoundingTypes( ((PsiArrayType)type).getComponentType(), enclType ) );
  }

  if( type instanceof PsiIntersectionType )
  {
    PsiType[] types = ((PsiIntersectionType)type).getConjuncts();
    Set<PsiType> newTypes = new HashSet<>();
    for( PsiType t : types )
    {
      newTypes.add( replaceTypeVariableTypeParametersWithBoundingTypes( t ) );
    }
    if( newTypes.size() == 1 )
    {
      return newTypes.iterator().next();
    }
    return PsiIntersectionType.createIntersection( new ArrayList<>( newTypes ) );
  }

  if( isParameterizedType( type ) )
  {
    PsiType[] typeParams = ((PsiClassType)type).getParameters();
    PsiType[] concreteParams = new PsiType[typeParams.length];
    for( int i = 0; i < typeParams.length; i++ )
    {
      concreteParams[i] = replaceTypeVariableTypeParametersWithBoundingTypes( typeParams[i], enclType );
    }
    type = parameterizeType( (PsiClassType)type, concreteParams );
  }
  else if( type instanceof PsiClassType )
  {
    PsiClass psiClass = ((PsiClassType)type).resolve();
    PsiTypeParameter[] typeVars = psiClass.getTypeParameters();
    PsiType[] boundingTypes = new PsiType[typeVars.length];
    for( int i = 0; i < boundingTypes.length; i++ )
    {
      boundingTypes[i] = type( getBoundingType( typeVars[i] ) );

      if( isRecursiveType( (PsiClassType)type( typeVars[i] ), boundingTypes[i] ) )
      {
        return type;
      }
    }
    for( int i = 0; i < boundingTypes.length; i++ )
    {
      boundingTypes[i] = replaceTypeVariableTypeParametersWithBoundingTypes( boundingTypes[i], enclType );
    }
    type = parameterizeType( (PsiClassType)type, boundingTypes );
  }
  else if( type instanceof PsiWildcardType )
  {
    replaceTypeVariableTypeParametersWithBoundingTypes( ((PsiWildcardType)type).getExtendsBound() );
  }
  return type;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:78,代码来源:TypeUtil.java


示例17: getClosureParameterType

import com.intellij.psi.PsiWildcardType; //导入依赖的package包/类
@Nullable
@Override
protected PsiType getClosureParameterType(GrClosableBlock closure, int index) {

  List<PsiType> expectedTypes;

  if (closure.getParent() instanceof GrSafeCastExpression) {
    GrSafeCastExpression safeCastExpression = (GrSafeCastExpression)closure.getParent();
    GrTypeElement typeElement = safeCastExpression.getCastTypeElement();
    if (typeElement != null) {
      PsiType castType = typeElement.getType();
      expectedTypes = ContainerUtil.newArrayList(GroovyExpectedTypesProvider.getDefaultExpectedTypes(safeCastExpression));
      for (Iterator<PsiType> iterator = expectedTypes.iterator(); iterator.hasNext(); ) {
        if (!TypesUtil.isAssignable(iterator.next(), castType, closure)) {
          iterator.remove();
        }
      }

      if (expectedTypes.isEmpty()) expectedTypes.add(castType);
    }
    else {
      expectedTypes = GroovyExpectedTypesProvider.getDefaultExpectedTypes(closure);
    }
  }
  else {
    expectedTypes = GroovyExpectedTypesProvider.getDefaultExpectedTypes(closure);
  }

  for (PsiType constraint : expectedTypes) {
    final PsiType suggestion = GppClosureParameterTypeProvider.getSingleMethodParameterType(constraint, index, closure);
    if (suggestion != null) {
      if (GroovyConfigUtils.getInstance().isVersionAtLeast(closure, GroovyConfigUtils.GROOVY2_3)) {
        if (suggestion instanceof PsiWildcardType && ((PsiWildcardType)suggestion).isSuper()) {
          return ((PsiWildcardType)suggestion).getBound();
        }
      }

      return TypesUtil.substituteAndNormalizeType(suggestion, PsiSubstitutor.EMPTY, null, closure);
    }
  }

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


示例18: getCollectionClassType

import com.intellij.psi.PsiWildcardType; //导入依赖的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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MockX509CRL类代码示例发布时间:2022-05-22
下一篇:
Java SamlCompliantLogoutMessageCreator类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap