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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations