public static PsiType getDefaultParameterizedType( PsiType type, PsiManager mgr ) { if( type.getArrayDimensions() > 0 ) { PsiType defType = getDefaultParameterizedType( ((PsiArrayType)type).getComponentType(), mgr ); if( !defType.equals( type ) ) { return new PsiArrayType( defType ); } return type; } if( type instanceof PsiIntersectionType ) { return makeDefaultParameterizedTypeForCompoundType( (PsiIntersectionType)type, mgr ); } if( type instanceof PsiDisjunctionType ) { return getDefaultParameterizedType( PsiTypesUtil.getLowestUpperBoundClassType( (PsiDisjunctionType)type ), mgr ); } if( !isGenericType( type ) && !isParameterizedType( type ) ) { return type; } type = ((PsiClassType)type).rawType(); return makeDefaultParameterizedType( type ); }
@Nullable private PsiClass getPsiClass() { if (myContext instanceof PsiClassObjectAccessExpression) { return PsiTypesUtil.getPsiClass(((PsiClassObjectAccessExpression)myContext).getOperand().getType()); } else if (myContext instanceof PsiMethodCallExpression) { final PsiMethod method = ((PsiMethodCallExpression)myContext).resolveMethod(); if (method != null && "forName".equals(method.getName()) && isClass(method.getContainingClass())) { final PsiExpression[] expressions = ((PsiMethodCallExpression)myContext).getArgumentList().getExpressions(); if (expressions.length == 1 && expressions[0] instanceof PsiLiteralExpression) { final Object value = ((PsiLiteralExpression)expressions[0]).getValue(); if (value instanceof String) { final Project project = myContext.getProject(); return JavaPsiFacade.getInstance(project).findClass(String.valueOf(value), GlobalSearchScope.allScope(project)); } } } } return null; }
@Nullable private static PsiType getPlaceExpectedType(PsiElement parent) { PsiType type = PsiTypesUtil.getExpectedTypeByParent((PsiExpression)parent); if (type == null) { final PsiElement arg = PsiUtil.skipParenthesizedExprUp(parent); final PsiElement gParent = arg.getParent(); if (gParent instanceof PsiExpressionList) { int i = ArrayUtilRt.find(((PsiExpressionList)gParent).getExpressions(), arg); final PsiElement pParent = gParent.getParent(); if (pParent instanceof PsiCallExpression) { final PsiMethod method = ((PsiCallExpression)pParent).resolveMethod(); if (method != null) { final PsiParameter[] parameters = method.getParameterList().getParameters(); if (i >= parameters.length) { if (method.isVarArgs()) { return ((PsiEllipsisType)parameters[parameters.length - 1].getType()).getComponentType(); } } else { return parameters[i].getType(); } } } } } return type; }
private static boolean isExtensionPointNameDeclarationField(PsiField psiField) { // *do* allow non-public if (!psiField.hasModifierProperty(PsiModifier.FINAL) || !psiField.hasModifierProperty(PsiModifier.STATIC) || psiField.hasModifierProperty(PsiModifier.ABSTRACT)) { return false; } if (!psiField.hasInitializer()) { return false; } final PsiExpression initializer = psiField.getInitializer(); if (!(initializer instanceof PsiMethodCallExpression) && !(initializer instanceof PsiNewExpression)) { return false; } final PsiClass fieldClass = PsiTypesUtil.getPsiClass(psiField.getType()); if (fieldClass == null) { return false; } return ExtensionPointName.class.getName().equals(fieldClass.getQualifiedName()); }
@Override public String getQuickNavigateInfo(PsiElement element, PsiElement originalElement) { ExtensionPoint extensionPoint = findExtensionPoint(element); if (extensionPoint == null) return null; final XmlFile epDeclarationFile = (XmlFile)extensionPoint.getXmlTag().getContainingFile(); final Module epModule = ModuleUtilCore.findModuleForFile(epDeclarationFile.getVirtualFile(), element.getProject()); final String epPrefix = extensionPoint.getNamePrefix(); final PsiClass epClass = getExtensionPointClass(extensionPoint); StringBuilder epClassText = new StringBuilder(); if (epClass != null) { JavaDocInfoGenerator.generateType(epClassText, PsiTypesUtil.getClassType(epClass), epClass, true); } else { epClassText.append("<unknown>"); } return (epModule == null ? "" : "[" + epModule.getName() + "]") + (epPrefix == null ? "" : " " + epPrefix) + "<br/>" + "<b>" + extensionPoint.getEffectiveName() + "</b>" + " (" + epDeclarationFile.getName() + ")<br/>" + epClassText.toString(); }
private static void generateVariableNameByTypeInner(PsiType type, Set<String> possibleNames, NameValidator validator) { String unboxed = PsiTypesUtil.unboxIfPossible(type.getCanonicalText()); if (unboxed != null && !unboxed.equals(type.getCanonicalText())) { String name = generateNameForBuiltInType(unboxed); name = validator.validateName(name, true); if (GroovyNamesUtil.isIdentifier(name)) { possibleNames.add(name); } } else if (type instanceof PsiIntersectionType) { for (PsiType psiType : ((PsiIntersectionType)type).getConjuncts()) { generateByType(psiType, possibleNames, validator); } } else { generateByType(type, possibleNames, validator); } }
@Override public Color getColorFrom(@NotNull PsiElement element) { if (element instanceof PsiNewExpression && element.getLanguage() == JavaLanguage.INSTANCE) { final PsiNewExpression expr = (PsiNewExpression)element; final PsiType type = expr.getType(); if (type != null) { final PsiClass aClass = PsiTypesUtil.getPsiClass(type); if (aClass != null) { final String fqn = aClass.getQualifiedName(); if ("java.awt.Color".equals(fqn) || "javax.swing.plaf.ColorUIResource".equals(fqn)) { return getColor(expr.getArgumentList()); } } } } return null; }
@Override public void visitField(PsiField field) { PsiExpression initializer = field.getInitializer(); if(initializer != null) { initializeVariable(field, initializer); } else if(!field.hasModifier(JvmModifier.FINAL)) { // initialize with default value DfaVariableValue dfaVariable = myFactory.getVarFactory().createVariableValue(field, false); addInstruction(new PushInstruction(dfaVariable, null, true)); addInstruction(new PushInstruction(myFactory.getConstFactory().createFromValue(PsiTypesUtil.getDefaultValue(field.getType()), field.getType(), null), null)); addInstruction(new AssignInstruction(null, dfaVariable)); addInstruction(new PopInstruction()); } }
@Nullable static HighlightInfo checkParametersCompatible(PsiLambdaExpression expression, PsiParameter[] methodParameters, PsiSubstitutor substitutor) { final PsiParameter[] lambdaParameters = expression.getParameterList().getParameters(); String incompatibleTypesMessage = "Incompatible parameter types in lambda expression: "; if(lambdaParameters.length != methodParameters.length) { incompatibleTypesMessage += "wrong number of parameters: expected " + methodParameters.length + " but found " + lambdaParameters.length; return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression.getParameterList()).descriptionAndTooltip(incompatibleTypesMessage).create(); } boolean hasFormalParameterTypes = expression.hasFormalParameterTypes(); for(int i = 0; i < lambdaParameters.length; i++) { PsiParameter lambdaParameter = lambdaParameters[i]; PsiType lambdaParameterType = lambdaParameter.getType(); PsiType substitutedParamType = substitutor.substitute(methodParameters[i].getType()); if(hasFormalParameterTypes && !PsiTypesUtil.compareTypes(lambdaParameterType, substitutedParamType, true) || !TypeConversionUtil.isAssignable(substitutedParamType, lambdaParameterType)) { final String expectedType = substitutedParamType != null ? substitutedParamType.getPresentableText() : null; final String actualType = lambdaParameterType.getPresentableText(); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression.getParameterList()).descriptionAndTooltip(incompatibleTypesMessage + "expected " + expectedType + " " + "but found " + actualType).create(); } } return null; }
@Override public void visitReturnStatement(PsiReturnStatement statement) { super.visitReturnStatement(statement); if(IGNORE_UNCHECKED_ASSIGNMENT) { return; } final PsiType returnType = PsiTypesUtil.getMethodReturnType(statement); if(returnType != null && !PsiType.VOID.equals(returnType)) { final PsiExpression returnValue = statement.getReturnValue(); if(returnValue != null) { final PsiType valueType = returnValue.getType(); if(valueType != null) { final PsiElement psiElement = PsiTreeUtil.getParentOfType(statement, PsiMethod.class, PsiLambdaExpression.class); LocalQuickFix[] fixes = psiElement instanceof PsiMethod ? new LocalQuickFix[]{QuickFixFactory.getInstance().createMethodReturnFix((PsiMethod) psiElement, valueType, true)} : LocalQuickFix.EMPTY_ARRAY; checkRawToGenericsAssignment(returnValue, returnValue, returnType, valueType, false, fixes); } } } }
public static boolean isColorType(@Nullable PsiType type) { if(type != null) { final PsiClass aClass = PsiTypesUtil.getPsiClass(type); if(aClass != null) { final String fqn = aClass.getQualifiedName(); if("java.awt.Color".equals(fqn) || "javax.swing.plaf.ColorUIResource".equals(fqn)) { return true; } } } return false; }
@Override public boolean isAvailable(@NotNull Project project, @NotNull PsiFile file, @NotNull PsiElement startElement, @NotNull PsiElement endElement) { final PsiMethod myMethod = (PsiMethod) startElement; final PsiType myReturnType = myReturnTypePointer.getType(); if(myMethod.getManager().isInProject(myMethod) && myReturnType != null && myReturnType.isValid() && !TypeConversionUtil.isNullType(myReturnType)) { final PsiType returnType = myMethod.getReturnType(); if(returnType != null && returnType.isValid() && !Comparing.equal(myReturnType, returnType)) { return PsiTypesUtil.allTypeParametersResolved(myMethod, myReturnType); } } return false; }
private boolean typeContainsTypeParameters(@Nullable PsiType type, @NotNull Set<PsiTypeParameter> excluded) { if(!(type instanceof PsiClassType)) { return false; } PsiTypesUtil.TypeParameterSearcher searcher = new PsiTypesUtil.TypeParameterSearcher(); type.accept(searcher); for(PsiTypeParameter parameter : searcher.getTypeParameters()) { if(!excluded.contains(parameter) && !myDisappearedTypeParameters.contains(parameter)) { return true; } } return false; }
boolean typeIsTooGeneric(PsiType type) { PsiClass clazz = PsiTypesUtil.getPsiClass(type); if (clazz == null) { return true; } String qualifiedName = clazz.getQualifiedName(); return qualifiedName == null || qualifiedName.startsWith("java.lang") || qualifiedName.startsWith("java.io") || qualifiedName.startsWith("java.util"); }
public List<PsiReference> findReferences(PsiField field, int maxNumberOfResults) { PsiClass fieldClass = PsiTypesUtil.getPsiClass(field.getType()); if (fieldClass == null) { return Collections.emptyList(); } Project project = field.getProject(); PsiManager manager = PsiManager.getInstance(project); JGivenUsageProvider usageProvider = new JGivenUsageProvider(scenarioStateProvider, resolutionHandler, new ReferenceFactory(manager)); StateReferenceProcessor processor = new StateReferenceProcessor(field, maxNumberOfResults, usageProvider); SearchScope scope = GlobalSearchScope.everythingScope(project).intersectWith(javaFilesScope(project)); findPsiFields(project, (GlobalSearchScope) scope, processor); return processor.getResults(); }
/** * Checks that the given type is an implementer of the given canonicalName with the given typed parameters * * @param type what we're checking against * @param canonicalName the type must extend/implement this generic * @param canonicalParamNames the type that the generic(s) must be (in this order) * @return */ public static boolean isTypedClass(PsiType type, String canonicalName, String... canonicalParamNames) { PsiClass parameterClass = PsiTypesUtil.getPsiClass(type); if (parameterClass == null) { return false; } // This is a safe cast, for if parameterClass != null, the type was checked in PsiTypesUtil#getPsiClass(...) PsiClassType pct = (PsiClassType) type; // Main class name doesn't match; exit early if (!canonicalName.equals(parameterClass.getQualifiedName())) { return false; } List<PsiType> psiTypes = new ArrayList<PsiType>(pct.resolveGenerics().getSubstitutor().getSubstitutionMap().values()); for (int i = 0; i < canonicalParamNames.length; i++) { if (!isOfType(psiTypes.get(i), canonicalParamNames[i])) { return false; } } // Passed all screenings; must be a match! return true; }
@Nullable private static PsiType getResultType(PsiMethodCallExpression call, PsiReferenceExpression methodExpression, JavaResolveResult result, @NotNull final LanguageLevel languageLevel) { final PsiMethod method = (PsiMethod)result.getElement(); if (method == null) return null; boolean is15OrHigher = languageLevel.compareTo(LanguageLevel.JDK_1_5) >= 0; final PsiType getClassReturnType = PsiTypesUtil.patchMethodGetClassReturnType(call, methodExpression, method, new Condition<IElementType>() { @Override public boolean value(IElementType type) { return type != JavaElementType.CLASS; } }, languageLevel); if (getClassReturnType != null) { return getClassReturnType; } PsiType ret = method.getReturnType(); if (ret == null) return null; if (ret instanceof PsiClassType) { ret = ((PsiClassType)ret).setLanguageLevel(languageLevel); } if (is15OrHigher) { return captureReturnType(call, method, ret, result, languageLevel); } return TypeConversionUtil.erasure(ret); }
@Nullable static HighlightInfo checkParametersCompatible(PsiLambdaExpression expression, PsiParameter[] methodParameters, PsiSubstitutor substitutor) { final PsiParameter[] lambdaParameters = expression.getParameterList().getParameters(); String incompatibleTypesMessage = "Incompatible parameter types in lambda expression: "; if (lambdaParameters.length != methodParameters.length) { incompatibleTypesMessage += "wrong number of parameters: expected " + methodParameters.length + " but found " + lambdaParameters.length; return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR) .range(expression.getParameterList()) .descriptionAndTooltip(incompatibleTypesMessage) .create(); } boolean hasFormalParameterTypes = expression.hasFormalParameterTypes(); for (int i = 0; i < lambdaParameters.length; i++) { PsiParameter lambdaParameter = lambdaParameters[i]; PsiType lambdaParameterType = lambdaParameter.getType(); PsiType substitutedParamType = substitutor.substitute(methodParameters[i].getType()); if (hasFormalParameterTypes &&!PsiTypesUtil.compareTypes(lambdaParameterType, substitutedParamType, true) || !TypeConversionUtil.isAssignable(substitutedParamType, lambdaParameterType)) { final String expectedType = substitutedParamType != null ? substitutedParamType.getPresentableText() : null; final String actualType = lambdaParameterType.getPresentableText(); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR) .range(expression.getParameterList()) .descriptionAndTooltip(incompatibleTypesMessage + "expected " + expectedType + " but found " + actualType) .create(); } } return null; }
private static boolean hasCreateUIMethod(PsiClass aClass) { for (PsiMethod method : aClass.findMethodsByName("createUI", false)) { if (method.hasModifierProperty(PsiModifier.STATIC)) { final PsiParameter[] parameters = method.getParameterList().getParameters(); if (parameters.length == 1) { final PsiType type = parameters[0].getType(); final PsiClass typeClass = PsiTypesUtil.getPsiClass(type); return typeClass != null && "javax.swing.JComponent".equals(typeClass.getQualifiedName()); } } } return false; }
public static boolean isColorType(@Nullable PsiType type) { if (type != null) { final PsiClass aClass = PsiTypesUtil.getPsiClass(type); if (aClass != null) { final String fqn = aClass.getQualifiedName(); if ("java.awt.Color".equals(fqn) || "javax.swing.plaf.ColorUIResource".equals(fqn)) { return true; } } } return false; }
private String suggestReturnValue() { PsiType type = myMethod.getReturnType(); // first try to find suitable local variable PsiVariable[] variables = getDeclaredVariables(myMethod); for (PsiVariable variable : variables) { PsiType varType = variable.getType(); if (varType.equals(type)) { return variable.getName(); } } return PsiTypesUtil.getDefaultValueOfType(type); }
@Override public void visitMethodCallExpression(PsiMethodCallExpression expression) { super.visitMethodCallExpression(expression); final PsiExpressionList argumentList = expression.getArgumentList(); final PsiExpression[] arguments = argumentList.getExpressions(); if (arguments.length != 1) { return; } if (!(arguments[0].getType() instanceof PsiPrimitiveType)) { return; } final PsiReferenceExpression methodExpression = expression.getMethodExpression(); @NonNls final String referenceName = methodExpression.getReferenceName(); if (!"valueOf".equals(referenceName)) { return; } final PsiExpression qualifierExpression = methodExpression.getQualifierExpression(); if (!(qualifierExpression instanceof PsiReferenceExpression)) { return; } final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)qualifierExpression; final String canonicalText = referenceExpression.getCanonicalText(); if (PsiTypesUtil.unboxIfPossible(canonicalText) == canonicalText || !canBeUnboxed(expression)) { return; } registerError(expression); }
public static String[] getArgumentsTypes(List<ParamInfo> listOfPairs) { final List<String> result = new ArrayList<String>(); if (listOfPairs == null) return ArrayUtil.EMPTY_STRING_ARRAY; for (ParamInfo listOfPair : listOfPairs) { String type = PsiTypesUtil.unboxIfPossible(listOfPair.type); result.add(type); } return ArrayUtil.toStringArray(result); }
public static boolean runContributors(@NotNull PsiType qualifierType, @NotNull PsiScopeProcessor processor, @NotNull PsiElement place, @NotNull ResolveState state) { MyDelegatingScopeProcessor delegatingProcessor = new MyDelegatingScopeProcessor(processor); ensureInit(); final PsiClass aClass = PsiTypesUtil.getPsiClass(qualifierType); if (aClass != null) { for (String superClassName : ClassUtil.getSuperClassesWithCache(aClass).keySet()) { for (NonCodeMembersContributor enhancer : ourClassSpecifiedContributors.get(superClassName)) { ProgressManager.checkCanceled(); enhancer.processDynamicElements(qualifierType, aClass, delegatingProcessor, place, state); if (!delegatingProcessor.wantMore) { return false; } } } } for (NonCodeMembersContributor contributor : ourAllTypeContributors) { ProgressManager.checkCanceled(); contributor.processDynamicElements(qualifierType, aClass, delegatingProcessor, place, state); if (!delegatingProcessor.wantMore) { return false; } } return GroovyDslFileIndex.processExecutors(qualifierType, place, processor, state); }
@Nullable @Override protected PsiType calculateReturnType(@NotNull GrMethodCall callExpression, @NotNull PsiMethod resolvedMethod) { if (!"withTraits".equals(resolvedMethod.getName())) return null; if (resolvedMethod instanceof GrGdkMethod) { resolvedMethod = ((GrGdkMethod)resolvedMethod).getStaticMethod(); } GrExpression invokedExpression = callExpression.getInvokedExpression(); if (!(invokedExpression instanceof GrReferenceExpression)) return null; GrExpression originalObject = ((GrReferenceExpression)invokedExpression).getQualifierExpression(); if (originalObject == null) return null; PsiType invokedType = originalObject.getType(); if (!(invokedType instanceof PsiClassType)) return null; PsiClass containingClass = resolvedMethod.getContainingClass(); if (containingClass == null || !GroovyCommonClassNames.DEFAULT_GROOVY_METHODS.equals(containingClass.getQualifiedName())) return null; List<PsiClassType> traits = ContainerUtil.newArrayList(); GrExpression[] args = callExpression.getArgumentList().getExpressionArguments(); for (GrExpression arg : args) { PsiType type = arg.getType(); PsiType classItem = PsiUtil.substituteTypeParameter(type, CommonClassNames.JAVA_LANG_CLASS, 0, false); PsiClass psiClass = PsiTypesUtil.getPsiClass(classItem); if (GrTraitUtil.isTrait(psiClass)) { traits.add((PsiClassType)classItem); } } return GrTraitType.createTraitClassType(callExpression, (PsiClassType)invokedType, traits, callExpression.getResolveScope()); }
private static void setupOverridingMethodBody(Project project, PsiMethod method, GrMethod resultMethod, FileTemplate template, PsiSubstitutor substitutor) { final PsiType returnType = substitutor.substitute(getSuperReturnType(method)); String returnTypeText = ""; if (returnType != null) { returnTypeText = returnType.getPresentableText(); } Properties properties = FileTemplateManager.getInstance(project).getDefaultProperties(); properties.setProperty(FileTemplate.ATTRIBUTE_RETURN_TYPE, returnTypeText); properties.setProperty(FileTemplate.ATTRIBUTE_DEFAULT_RETURN_VALUE, PsiTypesUtil.getDefaultValueOfType(returnType)); properties.setProperty(FileTemplate.ATTRIBUTE_CALL_SUPER, callSuper(method, resultMethod)); JavaTemplateUtil.setClassAndMethodNameProperties(properties, method.getContainingClass(), resultMethod); try { String bodyText = StringUtil.replace(template.getText(properties), ";", ""); GroovyFile file = GroovyPsiElementFactory.getInstance(project).createGroovyFile("\n " + bodyText + "\n", false, null); GrOpenBlock block = resultMethod.getBlock(); block.getNode().addChildren(file.getFirstChild().getNode(), null, block.getRBrace().getNode()); } catch (IOException e) { LOG.error(e); } }
@Nullable private static String getInferredTypes(PsiType functionalInterfaceType, final PsiLambdaExpression lambdaExpression, boolean useFQN) { final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(functionalInterfaceType); final StringBuilder buf = new StringBuilder(); buf.append("("); final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(functionalInterfaceType); LOG.assertTrue(interfaceMethod != null); final PsiParameter[] parameters = interfaceMethod.getParameterList().getParameters(); final PsiParameter[] lambdaParameters = lambdaExpression.getParameterList().getParameters(); if (parameters.length != lambdaParameters.length) return null; for (int i = 0; i < parameters.length; i++) { PsiParameter parameter = parameters[i]; final PsiType psiType = LambdaUtil.getSubstitutor(interfaceMethod, resolveResult).substitute(parameter.getType()); if (!PsiTypesUtil.isDenotableType(psiType)) return null; if (psiType != null) { buf.append(useFQN ? psiType.getCanonicalText() : psiType.getPresentableText()).append(" ").append(lambdaParameters[i].getName()); } else { buf.append(lambdaParameters[i].getName()); } if (i < parameters.length - 1) { buf.append(", "); } } buf.append(")"); return buf.toString(); }
@Nullable public static PsiClass getElementType(final PsiType psiType) { final PsiType elementType; if (psiType instanceof PsiArrayType) elementType = ((PsiArrayType)psiType).getComponentType(); else if (psiType instanceof PsiClassType) { final PsiType[] types = ((PsiClassType)psiType).getParameters(); elementType = types.length == 1? types[0] : null; } else elementType = null; return PsiTypesUtil.getPsiClass(elementType); }
private static void setupOverridingMethodBody(Project project, PsiMethod method, GrMethod resultMethod, FileTemplate template, PsiSubstitutor substitutor) { final PsiType returnType = substitutor.substitute(getSuperReturnType(method)); String returnTypeText = ""; if (returnType != null) { returnTypeText = returnType.getPresentableText(); } Properties properties = FileTemplateManager.getInstance().getDefaultProperties(project); properties.setProperty(FileTemplate.ATTRIBUTE_RETURN_TYPE, returnTypeText); properties.setProperty(FileTemplate.ATTRIBUTE_DEFAULT_RETURN_VALUE, PsiTypesUtil.getDefaultValueOfType(returnType)); properties.setProperty(FileTemplate.ATTRIBUTE_CALL_SUPER, callSuper(method, resultMethod)); JavaTemplateUtil.setClassAndMethodNameProperties(properties, method.getContainingClass(), resultMethod); try { String bodyText = StringUtil.replace(template.getText(properties), ";", ""); final GrCodeBlock newBody = GroovyPsiElementFactory.getInstance(project).createMethodBodyFromText("\n " + bodyText + "\n"); resultMethod.setBlock(newBody); } catch (IOException e) { LOG.error(e); } }
private static void processSuperTypes(PsiType type, Set<LookupElement> result) { String text = type.getCanonicalText(); String unboxed = PsiTypesUtil.unboxIfPossible(text); if (unboxed != null && !unboxed.equals(text)) { result.add(LookupElementBuilder.create(unboxed).bold()); } else { PsiTypeLookupItem item = PsiTypeLookupItem.createLookupItem(type, null, PsiTypeLookupItem.isDiamond(type), IMPORT_FIXER); result.add(item); } PsiType[] superTypes = type.getSuperTypes(); for (PsiType superType : superTypes) { processSuperTypes(superType, result); } }
public static boolean runContributors(@NotNull final PsiType qualifierType, @NotNull PsiScopeProcessor processor, @NotNull final PsiElement place, @NotNull final ResolveState state) { MyDelegatingScopeProcessor delegatingProcessor = new MyDelegatingScopeProcessor(processor); ensureInit(); final PsiClass aClass = PsiTypesUtil.getPsiClass(qualifierType); if (aClass != null) { for (String superClassName : TypesUtil.getSuperClassesWithCache(aClass).keySet()) { for (NonCodeMembersContributor enhancer : ourClassSpecifiedContributors.get(superClassName)) { enhancer.processDynamicElements(qualifierType, aClass, delegatingProcessor, place, state); if (!delegatingProcessor.wantMore) { return false; } } } } for (NonCodeMembersContributor contributor : ourAllTypeContributors) { contributor.processDynamicElements(qualifierType, aClass, delegatingProcessor, place, state); if (!delegatingProcessor.wantMore) { return false; } } return GroovyDslFileIndex.processExecutors(qualifierType, place, processor, state); }
private boolean validateRecursion(PsiType psiType, ProblemBuilder builder) { final PsiClass psiClass = PsiTypesUtil.getPsiClass(psiType); if (null != psiClass) { final DelegateAnnotationElementVisitor delegateAnnotationElementVisitor = new DelegateAnnotationElementVisitor(psiType, builder); psiClass.acceptChildren(delegateAnnotationElementVisitor); return delegateAnnotationElementVisitor.isValid(); } return true; }