本文整理汇总了Java中com.intellij.psi.PsiWildcardType类的典型用法代码示例。如果您正苦于以下问题:Java PsiWildcardType类的具体用法?Java PsiWildcardType怎么用?Java PsiWildcardType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PsiWildcardType类属于com.intellij.psi包,在下文中一共展示了PsiWildcardType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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));
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}