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


Java PsiUtil.resolveClassInClassTypeOnly方法代码示例

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


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

示例1: addBound

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
public boolean addBound(PsiType classType, InferenceBound inferenceBound) {
  if (inferenceBound == InferenceBound.EQ &&
      PsiUtil.resolveClassInClassTypeOnly(classType) == this) {
    return false;
  }
  List<PsiType> list = myBounds.get(inferenceBound);
  if (list == null) {
    list = new ArrayList<PsiType>();
    myBounds.put(inferenceBound, list);
  }
  final int idx = list.indexOf(classType);
  if (idx < 0) {
    list.add(classType);
    return true;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:InferenceVariable.java

示例2: inferGenericArgType

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Nullable
private static PsiType inferGenericArgType(@NotNull GrClosureSignature signature,
                                           @NotNull PsiType targetType,
                                           int genericIndex,
                                           int param) {
  if (targetType instanceof PsiClassType) {
    final PsiClassType.ClassResolveResult result = ((PsiClassType)targetType).resolveGenerics();
    final PsiClass psiClass = result.getElement();
    if (psiClass != null) {
      final PsiSubstitutor substitutor = result.getSubstitutor();

      final PsiType baseType = signature.getParameters()[param].getType();
      final PsiClass baseClass = PsiUtil.resolveClassInClassTypeOnly(baseType);

      if (baseClass != null && InheritanceUtil.isInheritorOrSelf(psiClass, baseClass, true)) {
        final PsiTypeParameter[] typeParameters = baseClass.getTypeParameters();
        if (genericIndex < typeParameters.length) {
          final PsiSubstitutor superClassSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(baseClass, psiClass, substitutor);
          return superClassSubstitutor.substitute(typeParameters[genericIndex]);
        }
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:GrDelegatesToUtil.java

示例3: isInheritor

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Override
public boolean isInheritor(@NotNull PsiClass baseClass, boolean checkDeep) {
  for (PsiType type : getBounds(InferenceBound.UPPER)) {
    PsiClass psiClass = PsiUtil.resolveClassInClassTypeOnly(type);
    if (psiClass != null) {
      if (getManager().areElementsEquivalent(baseClass, psiClass)) return true;
      if (checkDeep && psiClass.isInheritor(baseClass, true)) return true;
    }
  }
  
  return super.isInheritor(baseClass, checkDeep);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:InferenceVariable.java

示例4: addCollectConversion

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
static void addCollectConversion(PsiReferenceExpression ref, Collection<ExpectedTypeInfo> expectedTypes, Consumer<LookupElement> consumer) {
  final PsiExpression qualifier = ref.getQualifierExpression();
  PsiType component = qualifier == null ? null : PsiUtil.substituteTypeParameter(qualifier.getType(), JAVA_UTIL_STREAM_STREAM, 0, true);
  if (component == null) return;

  JavaPsiFacade facade = JavaPsiFacade.getInstance(ref.getProject());
  GlobalSearchScope scope = ref.getResolveScope();
  PsiClass list = facade.findClass(JAVA_UTIL_LIST, scope);
  PsiClass set = facade.findClass(JAVA_UTIL_SET, scope);
  if (facade.findClass(JAVA_UTIL_STREAM_COLLECTORS, scope) == null || list == null || set == null) return;

  boolean hasList = false;
  boolean hasSet = false;
  for (ExpectedTypeInfo info : expectedTypes) {
    PsiType type = info.getDefaultType();
    PsiClass expectedClass = PsiUtil.resolveClassInClassTypeOnly(type);
    PsiType expectedComponent = PsiUtil.extractIterableTypeParameter(type, true);
    if (expectedClass == null || expectedComponent == null || !TypeConversionUtil.isAssignable(expectedComponent, component)) continue;

    if (!hasList && InheritanceUtil.isInheritorOrSelf(list, expectedClass, true)) {
      hasList = true;
      consumer.consume(new MyLookupElement("toList", type));
    }

    if (!hasSet && InheritanceUtil.isInheritorOrSelf(set, expectedClass, true)) {
      hasSet = true;
      consumer.consume(new MyLookupElement("toSet", type));
    }

  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:CollectConversion.java

示例5: registerSingleClass

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
public void registerSingleClass(@Nullable InheritorsHolder inheritors) {
  if (inheritors != null && myTypeItems.size() == 1) {
    PsiType type = myTypeItems.get(0).getType();
    PsiClass aClass = PsiUtil.resolveClassInClassTypeOnly(type);
    if (aClass != null && !aClass.hasTypeParameters()) {
      myTypeItems.get(0).setShowPackage();
      inheritors.registerClass(aClass);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:TypeArgumentCompletionProvider.java

示例6: accepts

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Override
public boolean accepts(@NotNull PsiSwitchStatement psiSwitchStatement, ProcessingContext context) {
  final PsiExpression expression = psiSwitchStatement.getExpression();
  if(expression == null) return false;
  PsiClass aClass = PsiUtil.resolveClassInClassTypeOnly(expression.getType());
  return aClass != null && aClass.isEnum();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:JavaCompletionContributor.java

示例7: filterAssignableFrom

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
protected static List<PsiClass> filterAssignableFrom(PsiType type, List<PsiClass> candidates) {
  final PsiClass actualClass = PsiUtil.resolveClassInClassTypeOnly(type);
  if (actualClass != null) {
    return ContainerUtil.findAll(candidates, new Condition<PsiClass>() {
      @Override
      public boolean value(PsiClass psiClass) {
        return InheritanceUtil.isInheritorOrSelf(psiClass, actualClass, true);
      }
    });
  }
  return candidates;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ImportClassFixBase.java

示例8: getTargetClasses

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@NotNull
@Override
protected List<PsiClass> getTargetClasses(PsiElement element) {
  final List<PsiClass> classes = super.getTargetClasses(element);
  PsiClass enumClass = null;
  for (PsiClass aClass : classes) {
    if (aClass.isEnum()) {
      if (enumClass == null) {
        enumClass = aClass;
      } else {
        enumClass = null;
        break;
      }
    }
  }

  if (enumClass != null) {
    return Collections.singletonList(enumClass);
  }
  ExpectedTypeInfo[] typeInfos = CreateFromUsageUtils.guessExpectedTypes(myReferenceExpression, false);
  for (final ExpectedTypeInfo typeInfo : typeInfos) {
    final PsiClass psiClass = PsiUtil.resolveClassInClassTypeOnly(typeInfo.getType());
    if (psiClass != null && psiClass.isEnum()) {
      return Collections.singletonList(psiClass);
    }
  }
  return Collections.emptyList();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:CreateEnumConstantFromUsageFix.java

示例9: getResolvedClass

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Nullable
private static PsiClass getResolvedClass(PsiElement element, PsiMember resolved) {
  PsiClass aClass = resolved.getContainingClass();
  if (aClass != null && !PsiUtil.isAccessible(aClass.getProject(), aClass, element, null)) {
    final PsiElement qualifier = ((PsiJavaCodeReferenceElement)element.getParent()).getQualifier();
    if (qualifier instanceof PsiReferenceExpression) {
      final PsiElement qResolved = ((PsiReferenceExpression)qualifier).resolve();
      if (qResolved instanceof PsiVariable) {
        aClass = PsiUtil.resolveClassInClassTypeOnly(((PsiVariable)qResolved).getType());
      }
    }
  }
  return aClass;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:AddSingleMemberStaticImportAction.java

示例10: isParameterized

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Override
public boolean isParameterized(PsiClass clazz) {
  final PsiAnnotation annotation = AnnotationUtil.findAnnotation(clazz, JUnitUtil.RUN_WITH);
  if (annotation != null) {
    final PsiAnnotationMemberValue value = annotation.findAttributeValue(PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME);
    if (value instanceof PsiClassObjectAccessExpression) {
      final PsiTypeElement operand = ((PsiClassObjectAccessExpression)value).getOperand();
      final PsiClass psiClass = PsiUtil.resolveClassInClassTypeOnly(operand.getType());
      return psiClass != null && "org.junit.runners.Parameterized".equals(psiClass.getQualifiedName());
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:JUnit4Framework.java

示例11: resolveExtensionPointClass

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Nullable
private static PsiClass resolveExtensionPointClass(PsiField psiField) {
  final PsiType typeParameter = PsiUtil.substituteTypeParameter(psiField.getType(),
                                                                ExtensionPointName.class.getName(),
                                                                0, false);
  return PsiUtil.resolveClassInClassTypeOnly(typeParameter);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:ExtensionPointDeclarationRelatedItemLineMarkerProvider.java

示例12: processDynamicElements

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Override
public void processDynamicElements(@NotNull final PsiType qualifierType,
                                   @NotNull PsiScopeProcessor processor,
                                   @NotNull final PsiElement place,
                                   @NotNull ResolveState state) {
  if (isInAnnotation(place)) return;

  final PsiClass aClass = PsiUtil.resolveClassInClassTypeOnly(qualifierType);
  if (aClass == null) return;

  final PsiModifierList modifierList = aClass.getModifierList();
  if (modifierList == null) return;

  List<PsiClass> mixins = new ArrayList<PsiClass>();
  for (PsiAnnotation annotation : getAllMixins(modifierList)) {
    final PsiAnnotationMemberValue value = annotation.findAttributeValue("value");

    if (value instanceof GrAnnotationArrayInitializer) {
      final GrAnnotationMemberValue[] initializers = ((GrAnnotationArrayInitializer)value).getInitializers();
      for (GrAnnotationMemberValue initializer : initializers) {
        addMixin(initializer, mixins);
      }
    }
    else if (value instanceof GrExpression) {
      addMixin((GrExpression)value, mixins);
    }
  }

  final MixinProcessor delegate = new MixinProcessor(processor, qualifierType, place);
  for (PsiClass mixin : mixins) {
    if (!mixin.processDeclarations(delegate, state, null, place)) {
      return;
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:MixinMemberContributor.java

示例13: isValidTypeForSwitchSelector

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
private static boolean isValidTypeForSwitchSelector(@NotNull PsiType type) {
  if (TypeConversionUtil.getTypeRank(type) <= TypeConversionUtil.INT_RANK) {
    return true;
  }

  PsiClass aClass = PsiUtil.resolveClassInClassTypeOnly(type);
  if (aClass != null && aClass.isEnum()) {
    return true;
  }

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

示例14: isInferenceVariableOrFreshTypeParameter

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
private static Boolean isInferenceVariableOrFreshTypeParameter(PsiType eqBound) {
  final PsiClass psiClass = PsiUtil.resolveClassInClassTypeOnly(eqBound);
  if (psiClass instanceof InferenceVariable ||
      psiClass instanceof PsiTypeParameter && InferenceSession.isFreshVariable((PsiTypeParameter)psiClass)) return true;
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:InferenceIncorporationPhase.java

示例15: visitTypeCastExpression

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Override
public void visitTypeCastExpression(PsiTypeCastExpression expression) {
  PsiExpression operandExpr = expression.getOperand();
  if (operandExpr == null) {
    throwExpressionInvalid(expression);
  }
  operandExpr.accept(this);
  Evaluator operandEvaluator = myResult;
  PsiTypeElement castTypeElem = expression.getCastType();
  if (castTypeElem == null) {
    throwExpressionInvalid(expression);
  }
  PsiType castType = castTypeElem.getType();
  PsiType operandType = operandExpr.getType();

  // if operand type can not be resolved in current context - leave it for runtime checks
  if (operandType != null &&
      !TypeConversionUtil.areTypesConvertible(operandType, castType) &&
      PsiUtil.resolveClassInType(operandType) != null) {
    throw new EvaluateRuntimeException(
      new EvaluateException(JavaErrorMessages.message("inconvertible.type.cast", JavaHighlightUtil.formatType(operandType), JavaHighlightUtil
        .formatType(castType)))
    );
  }

  boolean shouldPerformBoxingConversion = operandType != null && TypeConversionUtil.boxingConversionApplicable(castType, operandType);
  final boolean castingToPrimitive = castType instanceof PsiPrimitiveType;
  if (shouldPerformBoxingConversion && castingToPrimitive) {
    operandEvaluator = new UnBoxingEvaluator(operandEvaluator);
  }

  final boolean performCastToWrapperClass = shouldPerformBoxingConversion && !castingToPrimitive;

  if (!(PsiUtil.resolveClassInClassTypeOnly(castType) instanceof PsiTypeParameter)) {
    String castTypeName = castType.getCanonicalText();
    if (performCastToWrapperClass) {
      final PsiPrimitiveType unboxedType = PsiPrimitiveType.getUnboxedType(castType);
      if (unboxedType != null) {
        castTypeName = unboxedType.getCanonicalText();
      }
    }

    myResult = new TypeCastEvaluator(operandEvaluator, castTypeName, castingToPrimitive);
  }

  if (performCastToWrapperClass) {
    myResult = new BoxingEvaluator(myResult);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:50,代码来源:EvaluatorBuilderImpl.java


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