本文整理汇总了Java中com.intellij.psi.PsiPackage.getDirectories方法的典型用法代码示例。如果您正苦于以下问题:Java PsiPackage.getDirectories方法的具体用法?Java PsiPackage.getDirectories怎么用?Java PsiPackage.getDirectories使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiPackage
的用法示例。
在下文中一共展示了PsiPackage.getDirectories方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: spansMultipleModules
import com.intellij.psi.PsiPackage; //导入方法依赖的package包/类
private boolean spansMultipleModules() {
final String qualifiedName = getConfiguration().getPackage();
if (qualifiedName != null) {
final Project project = getConfiguration().getProject();
final PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage(qualifiedName);
if (aPackage != null) {
final TestSearchScope scope = getScope();
if (scope != null) {
final SourceScope sourceScope = scope.getSourceScope(getConfiguration());
if (sourceScope != null) {
final GlobalSearchScope configurationSearchScope = GlobalSearchScopesCore.projectTestScope(project).intersectWith(
sourceScope.getGlobalSearchScope());
final PsiDirectory[] directories = aPackage.getDirectories(configurationSearchScope);
return directories.length > 1;
}
}
}
}
return false;
}
示例2: getData
import com.intellij.psi.PsiPackage; //导入方法依赖的package包/类
@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;
}
示例3: performAction
import com.intellij.psi.PsiPackage; //导入方法依赖的package包/类
private void performAction(String[] packageNames, String newPackageName) throws Exception {
final PsiPackage[] packages = new PsiPackage[packageNames.length];
for (int i = 0; i < packages.length; i++) {
String packageName = packageNames[i];
packages[i] = JavaPsiFacade.getInstance(myPsiManager.getProject()).findPackage(packageName);
assertNotNull("Package " + packageName + " not found", packages[i]);
}
PsiPackage newParentPackage = JavaPsiFacade.getInstance(myPsiManager.getProject()).findPackage(newPackageName);
assertNotNull(newParentPackage);
final PsiDirectory[] dirs = newParentPackage.getDirectories();
assertEquals(dirs.length, 1);
new MoveClassesOrPackagesProcessor(myProject, packages,
new SingleSourceRootMoveDestination(PackageWrapper.create(newParentPackage), dirs[0]),
true, false, null).run();
FileDocumentManager.getInstance().saveAllDocuments();
}
示例4: collectExtensions
import com.intellij.psi.PsiPackage; //导入方法依赖的package包/类
public Couple<List<String>> collectExtensions(GlobalSearchScope resolveScope) {
PsiPackage aPackage = JavaPsiFacade.getInstance(myProject).findPackage("META-INF.services");
if (aPackage == null) {
return Couple.of(Collections.<String>emptyList(), Collections.<String>emptyList());
}
List<String> instanceClasses = new ArrayList<String>();
List<String> staticClasses = new ArrayList<String>();
for (PsiDirectory directory : aPackage.getDirectories(resolveScope)) {
PsiFile file = directory.findFile(ORG_CODEHAUS_GROOVY_RUNTIME_EXTENSION_MODULE);
if (file instanceof PropertiesFile) {
IProperty inst = ((PropertiesFile)file).findPropertyByKey("extensionClasses");
IProperty stat = ((PropertiesFile)file).findPropertyByKey("staticExtensionClasses");
if (inst != null) collectClasses(inst, instanceClasses);
if (stat != null) collectClasses(stat, staticClasses);
}
}
return Couple.of(instanceClasses, staticClasses);
}
示例5: getDirectories
import com.intellij.psi.PsiPackage; //导入方法依赖的package包/类
public PsiDirectory[] getDirectories() {
String qName = myQualifiedName;
while (qName.endsWith(".")) {
qName = StringUtil.trimEnd(qName, ".");
}
final PsiPackage aPackage = JavaPsiFacade.getInstance(myManager.getProject()).findPackage(qName);
if (aPackage != null) {
return aPackage.getDirectories();
} else {
return PsiDirectory.EMPTY_ARRAY;
}
}
示例6: getInspectionScopeImpl
import com.intellij.psi.PsiPackage; //导入方法依赖的package包/类
@Nullable
private static AnalysisScope getInspectionScopeImpl(DataContext dataContext) {
//Possible scopes: package, project, module.
Project projectContext = PlatformDataKeys.PROJECT_CONTEXT.getData(dataContext);
if (projectContext != null) {
return null;
}
Module moduleContext = LangDataKeys.MODULE_CONTEXT.getData(dataContext);
if (moduleContext != null) {
return null;
}
final Module [] modulesArray = LangDataKeys.MODULE_CONTEXT_ARRAY.getData(dataContext);
if (modulesArray != null && modulesArray.length > 0) {
return new AnalysisScope(modulesArray);
}
PsiElement psiTarget = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
if (psiTarget instanceof PsiDirectory) {
PsiDirectory psiDirectory = (PsiDirectory)psiTarget;
if (!psiDirectory.getManager().isInProject(psiDirectory)) return null;
return new AnalysisScope(psiDirectory);
}
else if (psiTarget instanceof PsiPackage) {
PsiPackage pack = (PsiPackage)psiTarget;
PsiDirectory[] dirs = pack.getDirectories(GlobalSearchScope.projectScope(pack.getProject()));
if (dirs.length == 0) return null;
return new JavaAnalysisScope(pack, LangDataKeys.MODULE.getData(dataContext));
}
return null;
}
示例7: elementContainsFile
import com.intellij.psi.PsiPackage; //导入方法依赖的package包/类
@Override
public boolean elementContainsFile(final Object element, final VirtualFile vFile) {
if (element instanceof PackageElement) {
final Set<Boolean> find = new HashSet<Boolean>();
final ContentIterator contentIterator = new ContentIterator() {
@Override
public boolean processFile(VirtualFile fileOrDir) {
if (fileOrDir != null && fileOrDir.getPath().equals(vFile.getPath())) {
find.add(Boolean.TRUE);
}
return true;
}
};
final PackageElement packageElement = (PackageElement)element;
final PsiPackage aPackage = packageElement.getPackage();
final Project project = aPackage.getProject();
final GlobalSearchScope scope = packageElement.getModule() != null
? GlobalSearchScope.moduleScope(packageElement.getModule())
: GlobalSearchScope.projectScope(project);
final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
final PsiDirectory[] directories = aPackage.getDirectories(scope);
for (PsiDirectory directory : directories) {
projectFileIndex.iterateContentUnderDirectory(directory.getVirtualFile(), contentIterator);
}
return !find.isEmpty();
}
return false;
}
示例8: getDescriptionsDirs
import com.intellij.psi.PsiPackage; //导入方法依赖的package包/类
public static PsiDirectory[] getDescriptionsDirs(Module module,
DescriptionType descriptionType) {
final JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(module.getProject());
final PsiPackage psiPackage = javaPsiFacade.findPackage(descriptionType.getDescriptionFolder());
if (psiPackage != null) {
return psiPackage.getDirectories(GlobalSearchScope.moduleWithDependenciesScope(module));
}
return PsiDirectory.EMPTY_ARRAY;
}