Search in sources :

Example 21 with PsiPackage

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

the class AnalysisScopeRule method getData.

@Override
public Object getData(final DataProvider dataProvider) {
    final Object psiFile = dataProvider.getData(CommonDataKeys.PSI_FILE.getName());
    if (psiFile instanceof PsiJavaFile) {
        return new JavaAnalysisScope((PsiJavaFile) psiFile);
    }
    Object psiTarget = dataProvider.getData(CommonDataKeys.PSI_ELEMENT.getName());
    if (psiTarget instanceof PsiPackage) {
        PsiPackage pack = (PsiPackage) psiTarget;
        PsiManager manager = pack.getManager();
        if (!manager.isInProject(pack))
            return null;
        PsiDirectory[] dirs = pack.getDirectories(GlobalSearchScope.projectScope(manager.getProject()));
        if (dirs.length == 0)
            return null;
        return new JavaAnalysisScope(pack, (Module) dataProvider.getData(LangDataKeys.MODULE.getName()));
    }
    return null;
}
Also used : PsiDirectory(com.intellij.psi.PsiDirectory) PsiManager(com.intellij.psi.PsiManager) PsiJavaFile(com.intellij.psi.PsiJavaFile) PsiPackage(com.intellij.psi.PsiPackage)

Example 22 with PsiPackage

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

the class PsiMigrationImpl method createPackage.

@Override
public PsiPackage createPackage(String qualifiedName) {
    assertValid();
    ApplicationManager.getApplication().assertWriteAccessAllowed();
    final MigrationPackageImpl migrationPackage = new MigrationPackageImpl(this, qualifiedName);
    final MigrationPackageImpl oldMigrationPackage = myQNameToPackageMap.put(qualifiedName, migrationPackage);
    LOG.assertTrue(oldMigrationPackage == null, qualifiedName);
    final String parentName = parentPackageName(qualifiedName);
    final PsiPackage aPackage = myFacade.findPackage(parentName);
    if (aPackage == null) {
        createPackage(parentName);
    }
    List<PsiPackage> psiPackages = getSubpackagesList(parentName);
    psiPackages.add(migrationPackage);
    myMigrationManager.migrationModified(false);
    return migrationPackage;
}
Also used : PsiPackage(com.intellij.psi.PsiPackage)

Example 23 with PsiPackage

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

the class ContextConfigurationTest method testReusingConfiguration.

public void testReusingConfiguration() {
    RunManagerEx runManager = RunManagerEx.getInstanceEx(myProject);
    PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
    PsiPackage psiPackage = JUnitUtil.getContainingPackage(psiClass);
    ConfigurationContext context = createContext(psiClass);
    assertEquals(null, context.findExisting());
    RunnerAndConfigurationSettings testClass = context.getConfiguration();
    runManager.addConfiguration(testClass, false);
    context = createContext(psiClass);
    assertSame(testClass, context.findExisting());
    runManager.setSelectedConfiguration(testClass);
    context = createContext(psiPackage);
    assertEquals(null, context.findExisting());
    RunnerAndConfigurationSettings testPackage = context.getConfiguration();
    runManager.addConfiguration(testPackage, false);
    context = createContext(psiPackage);
    assertSame(testPackage, context.findExisting());
    assertSame(testClass, runManager.getSelectedConfiguration());
    runManager.setSelectedConfiguration(context.findExisting());
    assertSame(testPackage, runManager.getSelectedConfiguration());
}
Also used : RunManagerEx(com.intellij.execution.RunManagerEx) PsiClass(com.intellij.psi.PsiClass) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) PsiPackage(com.intellij.psi.PsiPackage)

Example 24 with PsiPackage

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

the class ContextConfigurationTest method testJUnitDefaultPackage.

public void testJUnitDefaultPackage() {
    PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
    PsiPackage psiPackage = JUnitUtil.getContainingPackage(psiClass);
    PsiPackage defaultPackage = psiPackage.getParentPackage();
    final Module module = ModuleUtil.findModuleForPsiElement(psiClass);
    final MapDataContext dataContext = new MapDataContext();
    dataContext.put(DataConstants.MODULE, module);
    JUnitConfiguration configuration = createJUnitConfiguration(defaultPackage, AllInPackageConfigurationProducer.class, dataContext);
    checkTestObject(JUnitConfiguration.TEST_PACKAGE, configuration);
    checkPackage("", configuration);
    checkGeneretedName(configuration, "All in " + module.getName());
}
Also used : MapDataContext(com.intellij.testFramework.MapDataContext) PsiClass(com.intellij.psi.PsiClass) PsiPackage(com.intellij.psi.PsiPackage) Module(com.intellij.openapi.module.Module)

Example 25 with PsiPackage

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

the class TreeModelBuilder method getFileParentNode.

@Nullable
public PackageDependenciesNode getFileParentNode(VirtualFile vFile) {
    LOG.assertTrue(vFile != null);
    final VirtualFile containingDirectory = vFile.getParent();
    LOG.assertTrue(containingDirectory != null);
    PsiPackage aPackage = null;
    final String packageName = myFileIndex.getPackageNameByDirectory(containingDirectory);
    if (packageName != null) {
        aPackage = myJavaPsiFacade.findPackage(packageName);
    }
    if (aPackage != null) {
        if (myFileIndex.isInLibrarySource(vFile) || myFileIndex.isInLibraryClasses(vFile)) {
            return getLibraryDirNode(aPackage, getLibraryForFile(vFile));
        } else {
            return getModuleDirNode(aPackage, myFileIndex.getModuleForFile(vFile), getFileScopeType(vFile));
        }
    }
    return myFileIndex.isInLibrarySource(vFile) ? null : getModuleNode(myFileIndex.getModuleForFile(vFile), getFileScopeType(vFile));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiPackage(com.intellij.psi.PsiPackage) Nullable(org.jetbrains.annotations.Nullable)

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