Search in sources :

Example 71 with PsiClass

use of com.intellij.psi.PsiClass in project intellij-community by JetBrains.

the class PyJavaImportResolver method resolveImportReference.

@Nullable
public PsiElement resolveImportReference(QualifiedName name, PyQualifiedNameResolveContext context, boolean withRoots) {
    String fqn = name.toString();
    final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(context.getProject());
    final PsiPackage aPackage = psiFacade.findPackage(fqn);
    if (aPackage != null) {
        return aPackage;
    }
    Module module = context.getModule();
    if (module != null) {
        final PsiClass aClass = psiFacade.findClass(fqn, module.getModuleWithDependenciesAndLibrariesScope(false));
        if (aClass != null)
            return aClass;
    }
    return null;
}
Also used : JavaPsiFacade(com.intellij.psi.JavaPsiFacade) PsiClass(com.intellij.psi.PsiClass) PsiPackage(com.intellij.psi.PsiPackage) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Example 72 with PsiClass

use of com.intellij.psi.PsiClass in project intellij-community by JetBrains.

the class PyJavaPackageType method getCompletionVariants.

@Override
public Object[] getCompletionVariants(String completionPrefix, PsiElement location, ProcessingContext context) {
    List<Object> variants = new ArrayList<>();
    final GlobalSearchScope scope = getScope(location.getProject());
    final PsiClass[] classes = myPackage.getClasses(scope);
    for (PsiClass psiClass : classes) {
        variants.add(LookupElementBuilder.create(psiClass).withIcon(psiClass.getIcon(0)));
    }
    final PsiPackage[] subPackages = myPackage.getSubPackages(scope);
    for (PsiPackage subPackage : subPackages) {
        variants.add(LookupElementBuilder.create(subPackage).withIcon(subPackage.getIcon(0)));
    }
    return ArrayUtil.toObjectArray(variants);
}
Also used : GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) ArrayList(java.util.ArrayList) PsiClass(com.intellij.psi.PsiClass) PsiPackage(com.intellij.psi.PsiPackage)

Example 73 with PsiClass

use of com.intellij.psi.PsiClass in project intellij-community by JetBrains.

the class PyJavaSuperMethodsSearchExecutor method execute.

public boolean execute(@NotNull final PySuperMethodsSearch.SearchParameters queryParameters, @NotNull final Processor<PsiElement> consumer) {
    PyFunction func = queryParameters.getDerivedMethod();
    PyClass containingClass = func.getContainingClass();
    if (containingClass != null) {
        for (PyClassLikeType type : containingClass.getSuperClassTypes(TypeEvalContext.codeInsightFallback(containingClass.getProject()))) {
            if (type instanceof PyJavaClassType) {
                final PsiClass psiClass = ((PyJavaClassType) type).getPsiClass();
                PsiMethod[] methods = psiClass.findMethodsByName(func.getName(), true);
                // the Python method actually does override/implement all of Java super methods with the same name
                if (!ContainerUtil.process(methods, consumer))
                    return false;
            }
        }
    }
    return true;
}
Also used : PyClass(com.jetbrains.python.psi.PyClass) PyFunction(com.jetbrains.python.psi.PyFunction) PsiMethod(com.intellij.psi.PsiMethod) PsiClass(com.intellij.psi.PsiClass) PyClassLikeType(com.jetbrains.python.psi.types.PyClassLikeType)

Example 74 with PsiClass

use of com.intellij.psi.PsiClass in project intellij-community by JetBrains.

the class MvcTargetDialogCompletionUtils method completeClassesAndPackages.

public static List<LookupElement> completeClassesAndPackages(@NotNull String prefix, @NotNull GlobalSearchScope scope) {
    if (scope.getProject() == null)
        return Collections.emptyList();
    JavaPsiFacade facade = JavaPsiFacade.getInstance(scope.getProject());
    final List<LookupElement> res = new ArrayList<>();
    // Complete class names if prefix is a package name with dot at end.
    if (prefix.endsWith(".") && prefix.length() > 1) {
        PsiPackage p = facade.findPackage(prefix.substring(0, prefix.length() - 1));
        if (p != null) {
            for (PsiClass aClass : p.getClasses(scope)) {
                String qualifiedName = aClass.getQualifiedName();
                if (qualifiedName != null) {
                    res.add(LookupElementBuilder.create(aClass, qualifiedName));
                }
            }
        }
    }
    PsiPackage defaultPackage = facade.findPackage("");
    if (defaultPackage != null) {
        collectClassesAndPackageNames(res, defaultPackage, scope);
    }
    return res;
}
Also used : JavaPsiFacade(com.intellij.psi.JavaPsiFacade) PsiClass(com.intellij.psi.PsiClass) PsiPackage(com.intellij.psi.PsiPackage) LookupElement(com.intellij.codeInsight.lookup.LookupElement)

Example 75 with PsiClass

use of com.intellij.psi.PsiClass in project smali by JesusFreke.

the class SmalideaClassProvider method getClassDef.

@Nullable
@Override
public ClassDef getClassDef(String type) {
    ResolveScopeManager manager = ResolveScopeManager.getInstance(project);
    PsiClass psiClass = NameUtils.resolveSmaliType(project, manager.getDefaultResolveScope(file), type);
    if (psiClass != null) {
        return new SmalideaClassDef(psiClass);
    }
    return null;
}
Also used : ResolveScopeManager(com.intellij.psi.impl.ResolveScopeManager) PsiClass(com.intellij.psi.PsiClass) SmalideaClassDef(org.jf.smalidea.dexlib.SmalideaClassDef) Nullable(javax.annotation.Nullable)

Aggregations

PsiClass (com.intellij.psi.PsiClass)598 PsiElement (com.intellij.psi.PsiElement)113 PsiMethod (com.intellij.psi.PsiMethod)97 Nullable (org.jetbrains.annotations.Nullable)75 NotNull (org.jetbrains.annotations.NotNull)60 Project (com.intellij.openapi.project.Project)59 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)57 Module (com.intellij.openapi.module.Module)55 PsiFile (com.intellij.psi.PsiFile)49 VirtualFile (com.intellij.openapi.vfs.VirtualFile)47 ArrayList (java.util.ArrayList)37 PsiField (com.intellij.psi.PsiField)36 JavaPsiFacade (com.intellij.psi.JavaPsiFacade)25 Location (com.intellij.execution.Location)20 File (java.io.File)16 HashSet (java.util.HashSet)16 PsiClassType (com.intellij.psi.PsiClassType)15 PsiPackage (com.intellij.psi.PsiPackage)15 List (java.util.List)15 PsiType (com.intellij.psi.PsiType)13