当前位置: 首页>>代码示例>>Java>>正文


Java PsiPackage.getDirectories方法代码示例

本文整理汇总了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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:JavaTestFrameworkRunnableState.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:AnalysisScopeRule.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:MovePackageTest.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:GroovyExtensionProvider.java

示例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;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:PackageWrapper.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:CyclicDependenciesAction.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:PsiPackageFavoriteNodeProvider.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:DescriptionCheckerUtil.java


注:本文中的com.intellij.psi.PsiPackage.getDirectories方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。