Search in sources :

Example 1 with JavaPsiFacade

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

the class GroovyConsoleUtil method hasGroovyAll.

static boolean hasGroovyAll(Module module) {
    final GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
    final JavaPsiFacade facade = JavaPsiFacade.getInstance(module.getProject());
    return (facade.findClass("org.apache.commons.cli.CommandLineParser", scope) != null || facade.findClass("groovyjarjarcommonscli.CommandLineParser", scope) != null) && facade.findClass("groovy.ui.GroovyMain", scope) != null;
}
Also used : JavaPsiFacade(com.intellij.psi.JavaPsiFacade) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope)

Example 2 with JavaPsiFacade

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

the class SceneBuilderImpl method prepareCustomComponents.

@NotNull
private Collection<CustomComponent> prepareCustomComponents(Collection<PsiClass> psiClasses) {
    final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(myProject);
    final GlobalSearchScope scope = GlobalSearchScope.allScope(myProject);
    final Map<String, BuiltinComponent> builtinComponents = loadBuiltinComponents(className -> psiFacade.findClass(className, scope) != null);
    final List<CustomComponent> customComponents = new ArrayList<>();
    for (PsiClass psiClass : psiClasses) {
        final String qualifiedName = psiClass.getQualifiedName();
        final String name = psiClass.getName();
        if (qualifiedName != null && name != null) {
            BuiltinComponent parentComponent = null;
            for (PsiClass aClass = psiClass; aClass != null; aClass = aClass.getSuperClass()) {
                final BuiltinComponent component = builtinComponents.get(aClass.getQualifiedName());
                if (component != null) {
                    parentComponent = component;
                    break;
                }
            }
            final String moduleName = getComponentModuleName(psiClass);
            final Map<String, String> attributes = parentComponent != null ? parentComponent.getAttributes() : Collections.emptyMap();
            customComponents.add(new CustomComponent(name, qualifiedName, moduleName, attributes));
        }
    }
    return customComponents;
}
Also used : JavaPsiFacade(com.intellij.psi.JavaPsiFacade) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) PsiClass(com.intellij.psi.PsiClass) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with JavaPsiFacade

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

the class SpringLoadedPositionManagerFactory method usesSpringLoaded.

private static boolean usesSpringLoaded(@NotNull final DebugProcess process) {
    Boolean force = process.getProcessHandler().getUserData(FORCE_SPRINGLOADED);
    if (force == Boolean.TRUE)
        return true;
    try (AccessToken ignored = ApplicationManager.getApplication().acquireReadActionLock()) {
        JavaPsiFacade facade = JavaPsiFacade.getInstance(process.getProject());
        if (facade.findPackage("com.springsource.loaded") != null || facade.findPackage("org.springsource.loaded") != null) {
            return true;
        }
    }
    // Check spring loaded for remote process
    VirtualMachineProxy proxy = process.getVirtualMachineProxy();
    return !proxy.classesByName("com.springsource.loaded.agent.SpringLoadedAgent").isEmpty() || !proxy.classesByName("org.springsource.loaded.agent.SpringLoadedAgent").isEmpty();
}
Also used : JavaPsiFacade(com.intellij.psi.JavaPsiFacade) VirtualMachineProxy(com.intellij.debugger.engine.jdi.VirtualMachineProxy) AccessToken(com.intellij.openapi.application.AccessToken)

Example 4 with JavaPsiFacade

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

the class DefaultGroovyShellRunner method hasGroovyWithNeededJars.

public static boolean hasGroovyWithNeededJars(Module module) {
    GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
    JavaPsiFacade facade = JavaPsiFacade.getInstance(module.getProject());
    for (String className : REQUIRED_GROOVY_CLASSES) {
        if (facade.findClass(className, scope) == null) {
            return false;
        }
    }
    return true;
}
Also used : JavaPsiFacade(com.intellij.psi.JavaPsiFacade) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope)

Example 5 with JavaPsiFacade

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

the class MavenPluginCustomParameterValueConverter method getConverter.

@Override
public Converter getConverter(@NotNull GenericDomValue domElement) {
    Project project = domElement.getManager().getProject();
    JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
    PsiClass psiClass = psiFacade.findClass(myType, GlobalSearchScope.allScope(project));
    if (psiClass != null) {
        GenericDomValueConvertersRegistry convertersRegistry = MavenDomConvertersRegistry.getInstance().getConvertersRegistry();
        return convertersRegistry.getConverter(domElement, psiFacade.getElementFactory().createType(psiClass));
    }
    return null;
}
Also used : JavaPsiFacade(com.intellij.psi.JavaPsiFacade) Project(com.intellij.openapi.project.Project) GenericDomValueConvertersRegistry(com.intellij.util.xml.converters.values.GenericDomValueConvertersRegistry) PsiClass(com.intellij.psi.PsiClass)

Aggregations

JavaPsiFacade (com.intellij.psi.JavaPsiFacade)52 PsiClass (com.intellij.psi.PsiClass)30 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)20 Module (com.intellij.openapi.module.Module)15 Project (com.intellij.openapi.project.Project)12 PsiPackage (com.intellij.psi.PsiPackage)8 LanguageLevel (com.intellij.pom.java.LanguageLevel)7 PsiElement (com.intellij.psi.PsiElement)7 Nullable (org.jetbrains.annotations.Nullable)6 NotNull (org.jetbrains.annotations.NotNull)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 PsiMethod (com.intellij.psi.PsiMethod)4 PsiType (com.intellij.psi.PsiType)4 File (java.io.File)3 List (java.util.List)3 Configuration (com.android.tools.idea.configurations.Configuration)2 MergedManifest (com.android.tools.idea.model.MergedManifest)2 CompletionParameters (com.intellij.codeInsight.completion.CompletionParameters)2 LookupElement (com.intellij.codeInsight.lookup.LookupElement)2 ClassFilter (com.intellij.ide.util.ClassFilter)2