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