Search in sources :

Example 16 with PsiPackage

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

the class CyclicDependenciesTest method testT2.

public void testT2() {
    //com.b<->com.a
    //com.c<->com.d
    final CyclicDependenciesBuilder builder = new CyclicDependenciesBuilder(myProject, new AnalysisScope(myProject));
    builder.analyze();
    final HashMap<PsiPackage, Set<List<PsiPackage>>> cyclicDependencies = builder.getCyclicDependencies();
    HashMap<String, String[][]> expected = new HashMap<>();
    expected.put("com.b", new String[][] { { "com.a", "com.b" } });
    expected.put("com.d", new String[][] { { "com.c", "com.d" } });
    expected.put("com.c", new String[][] { { "com.d", "com.c" } });
    expected.put("com.a", new String[][] { { "com.b", "com.a" } });
    checkResult(expected, cyclicDependencies);
}
Also used : JavaAnalysisScope(com.intellij.analysis.JavaAnalysisScope) AnalysisScope(com.intellij.analysis.AnalysisScope) CyclicDependenciesBuilder(com.intellij.cyclicDependencies.CyclicDependenciesBuilder) PsiPackage(com.intellij.psi.PsiPackage)

Example 17 with PsiPackage

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

the class JavaInheritorsSearchTest method doTest.

private void doTest(String className, @Nullable String packageScopeName, boolean deep, String... expected) {
    SearchScope scope;
    if (packageScopeName != null) {
        PsiPackage aPackage = JavaPsiFacade.getInstance(myFixture.getProject()).findPackage(packageScopeName);
        assertNotNull(aPackage);
        scope = PackageScope.packageScope(aPackage, true).intersectWith(GlobalSearchScope.projectScope(myFixture.getProject()));
    } else {
        scope = GlobalSearchScope.projectScope(myFixture.getProject());
    }
    assertSameElements(getInheritorNames(className, deep, scope), expected);
}
Also used : PsiPackage(com.intellij.psi.PsiPackage)

Example 18 with PsiPackage

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

the class CodeInsightTestCase method findPackage.

@NotNull
protected PsiPackage findPackage(@NotNull final String name) {
    final PsiPackage aPackage = myJavaFacade.findPackage(name);
    assertNotNull("Package " + name + " not found", aPackage);
    return aPackage;
}
Also used : PsiPackage(com.intellij.psi.PsiPackage) NotNull(org.jetbrains.annotations.NotNull)

Example 19 with PsiPackage

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

the class AllInPackageGradleConfigurationProducer method doIsConfigurationFromContext.

@Override
protected boolean doIsConfigurationFromContext(ExternalSystemRunConfiguration configuration, ConfigurationContext context) {
    final PsiPackage psiPackage = JavaRuntimeConfigurationProducerBase.checkPackage(context.getPsiLocation());
    if (psiPackage == null)
        return false;
    if (context.getModule() == null)
        return false;
    if (!StringUtil.equals(ExternalSystemApiUtil.getExternalProjectPath(context.getModule()), configuration.getSettings().getExternalProjectPath())) {
        return false;
    }
    if (!configuration.getSettings().getTaskNames().containsAll(getTasksToRun(context.getModule())))
        return false;
    final String scriptParameters = configuration.getSettings().getScriptParameters() + ' ';
    return psiPackage.getQualifiedName().isEmpty() ? scriptParameters.contains("--tests * ") : scriptParameters.contains(String.format("--tests %s.* ", psiPackage.getQualifiedName()));
}
Also used : PsiPackage(com.intellij.psi.PsiPackage)

Example 20 with PsiPackage

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

the class GroovyUntypedAccessInspection method buildVisitor.

@Override
@NotNull
protected BaseInspectionVisitor buildVisitor() {
    return new BaseInspectionVisitor() {

        @Override
        public void visitReferenceExpression(@NotNull GrReferenceExpression refExpr) {
            super.visitReferenceExpression(refExpr);
            if (PsiUtil.isThisOrSuperRef(refExpr))
                return;
            GroovyResolveResult resolveResult = refExpr.advancedResolve();
            PsiElement resolved = resolveResult.getElement();
            if (resolved != null) {
                if (GrHighlightUtil.isDeclarationAssignment(refExpr) || resolved instanceof PsiPackage)
                    return;
            } else {
                GrExpression qualifier = refExpr.getQualifierExpression();
                if (qualifier == null && GrHighlightUtil.isDeclarationAssignment(refExpr))
                    return;
            }
            final PsiType refExprType = refExpr.getType();
            if (refExprType == null) {
                if (resolved != null) {
                    registerError(refExpr);
                }
            } else if (refExprType instanceof PsiClassType && ((PsiClassType) refExprType).resolve() == null) {
                registerError(refExpr);
            }
        }
    };
}
Also used : PsiClassType(com.intellij.psi.PsiClassType) GroovyResolveResult(org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult) BaseInspectionVisitor(org.jetbrains.plugins.groovy.codeInspection.BaseInspectionVisitor) PsiPackage(com.intellij.psi.PsiPackage) GrExpression(org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression) NotNull(org.jetbrains.annotations.NotNull) PsiElement(com.intellij.psi.PsiElement) GrReferenceExpression(org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression) PsiType(com.intellij.psi.PsiType) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PsiPackage (com.intellij.psi.PsiPackage)93 PsiDirectory (com.intellij.psi.PsiDirectory)24 PsiClass (com.intellij.psi.PsiClass)22 Module (com.intellij.openapi.module.Module)19 Project (com.intellij.openapi.project.Project)14 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)14 VirtualFile (com.intellij.openapi.vfs.VirtualFile)13 JavaAnalysisScope (com.intellij.analysis.JavaAnalysisScope)12 PsiFile (com.intellij.psi.PsiFile)12 PsiElement (com.intellij.psi.PsiElement)11 JavaPsiFacade (com.intellij.psi.JavaPsiFacade)10 NotNull (org.jetbrains.annotations.NotNull)10 CyclicDependenciesBuilder (com.intellij.cyclicDependencies.CyclicDependenciesBuilder)9 Nullable (org.jetbrains.annotations.Nullable)9 AnalysisScope (com.intellij.analysis.AnalysisScope)8 HashSet (java.util.HashSet)6 List (java.util.List)5 LookupElement (com.intellij.codeInsight.lookup.LookupElement)4 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)4 ArrayList (java.util.ArrayList)4