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


Java JavaAnalysisScope类代码示例

本文整理汇总了Java中com.intellij.analysis.JavaAnalysisScope的典型用法代码示例。如果您正苦于以下问题:Java JavaAnalysisScope类的具体用法?Java JavaAnalysisScope怎么用?Java JavaAnalysisScope使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JavaAnalysisScope类属于com.intellij.analysis包,在下文中一共展示了JavaAnalysisScope类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testBackwardPackageScope

import com.intellij.analysis.JavaAnalysisScope; //导入依赖的package包/类
public void testBackwardPackageScope(){
   final PsiPackage bPackage = JavaPsiFacade.getInstance(myPsiManager.getProject()).findPackage("com.a");
  final DependenciesBuilder builder = new BackwardDependenciesBuilder(myProject, new JavaAnalysisScope(bPackage, null));
  builder.analyze();
  final Set<PsiFile> searchFor = new HashSet<PsiFile>();
  searchFor.add(myJavaFacade.findClass("com.a.A", GlobalSearchScope.allScope(myProject)).getContainingFile());
  final Set<PsiFile> searchIn = new HashSet<PsiFile>();
  final PsiClass bClass = myJavaFacade.findClass("com.b.B", GlobalSearchScope.allScope(myProject));
  searchIn.add(bClass.getContainingFile());
  final PsiClass cClass = myJavaFacade.findClass("com.a.C", GlobalSearchScope.allScope(myProject));
  searchFor.add(cClass.getContainingFile());
  final UsageInfo[] usagesInfos = FindDependencyUtil.findBackwardDependencies(builder, searchIn, searchFor);
  final UsageInfo2UsageAdapter[] usages = UsageInfo2UsageAdapter.convert(usagesInfos);
  final String [] psiUsages = new String [usagesInfos.length];
  for (int i = 0; i < usagesInfos.length; i++) {
    psiUsages[i] = toString(usages[i]);
  }
  checkResult(new String []{"(4: 3) A myA = new A();", "(4: 15) A myA = new A();", "(5: 3) C myC = new C();", "(5: 15) C myC = new C();", "(7: 9) myA.aa();", "(8: 9) myC.cc();"}, psiUsages);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:UsagesInAnalyzingDependenciesTest.java

示例2: testBackwardPackageScope

import com.intellij.analysis.JavaAnalysisScope; //导入依赖的package包/类
public void testBackwardPackageScope(){
   final PsiJavaPackage bPackage = JavaPsiFacade.getInstance(myPsiManager.getProject()).findPackage("com.a");
  final DependenciesBuilder builder = new BackwardDependenciesBuilder(myProject, new JavaAnalysisScope(bPackage, null));
  builder.analyze();
  final Set<PsiFile> searchFor = new HashSet<PsiFile>();
  searchFor.add(myJavaFacade.findClass("com.a.A", GlobalSearchScope.allScope(myProject)).getContainingFile());
  final Set<PsiFile> searchIn = new HashSet<PsiFile>();
  final PsiClass bClass = myJavaFacade.findClass("com.b.B", GlobalSearchScope.allScope(myProject));
  searchIn.add(bClass.getContainingFile());
  final PsiClass cClass = myJavaFacade.findClass("com.a.C", GlobalSearchScope.allScope(myProject));
  searchFor.add(cClass.getContainingFile());
  final UsageInfo[] usagesInfos = FindDependencyUtil.findBackwardDependencies(builder, searchIn, searchFor);
  final UsageInfo2UsageAdapter[] usages = UsageInfo2UsageAdapter.convert(usagesInfos);
  final String [] psiUsages = new String [usagesInfos.length];
  for (int i = 0; i < usagesInfos.length; i++) {
    psiUsages[i] = toString(usages[i]);
  }
  checkResult(new String []{"(4: 3) A myA = new A();", "(4: 15) A myA = new A();", "(5: 3) C myC = new C();", "(5: 15) C myC = new C();", "(7: 9) myA.aa();", "(8: 9) myC.cc();"}, psiUsages);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:20,代码来源:UsagesInAnalyzingDependenciesTest.java

示例3: getInspectionScopeImpl

import com.intellij.analysis.JavaAnalysisScope; //导入依赖的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

示例4: testForwardPackageScope

import com.intellij.analysis.JavaAnalysisScope; //导入依赖的package包/类
public void testForwardPackageScope(){
  final PsiPackage bPackage = JavaPsiFacade.getInstance(myPsiManager.getProject()).findPackage("com.b");
  final DependenciesBuilder builder = new ForwardDependenciesBuilder(myProject, new JavaAnalysisScope(bPackage, null));
  builder.analyze();
  final Set<PsiFile> searchFor = new HashSet<PsiFile>();
  searchFor.add(myJavaFacade.findClass("com.a.A", GlobalSearchScope.allScope(myProject)).getContainingFile());
  final Set<PsiFile> searchIn = new HashSet<PsiFile>();
  final PsiClass bClass = myJavaFacade.findClass("com.b.B", GlobalSearchScope.allScope(myProject));
  searchIn.add(bClass.getContainingFile());
  final PsiClass cClass = myJavaFacade.findClass("com.b.C", GlobalSearchScope.allScope(myProject));
  searchIn.add(cClass.getContainingFile());
  final UsageInfo[] usagesInfos = FindDependencyUtil.findDependencies(builder, searchIn, searchFor);
  final UsageInfo2UsageAdapter[] usages = UsageInfo2UsageAdapter.convert(usagesInfos);
  final String [] psiUsages = new String [usagesInfos.length];
  for (int i = 0; i < usagesInfos.length; i++) {
    psiUsages[i] = toString(usages[i]);
  }
  checkResult(new String []{
    "(2: 14) import com.a.A;",
    "(4: 3) A myA = new A();",
    "(4: 15) A myA = new A();",
    "(6: 9) myA.aa();",

    "(2: 14) import com.a.A;",
    "(4: 3) A myA = new A();",
    "(4: 15) A myA = new A();",
    "(6: 9) myA.aa();"}, psiUsages);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:UsagesInAnalyzingDependenciesTest.java

示例5: testPackageScope1

import com.intellij.analysis.JavaAnalysisScope; //导入依赖的package包/类
public void testPackageScope1(){
  // com.a<->com.b
  final CyclicDependenciesBuilder builder = new CyclicDependenciesBuilder(myProject,
                                                                          new JavaAnalysisScope(JavaPsiFacade
                                                                            .getInstance(myPsiManager.getProject()).findPackage("com"), null));
  builder.analyze();
  final HashMap<PsiPackage, Set<List<PsiPackage>>> cyclicDependencies = builder.getCyclicDependencies();
  HashMap<String, String[][]> expected = new HashMap<String, String[][]>();
  expected.put("com.b", new String[][]{{"com.a", "com.b"}});
  expected.put("com.a", new String[][]{{"com.b", "com.a"}});
  checkResult(expected, cyclicDependencies);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:CyclicDependenciesTest.java

示例6: testPackageScope2

import com.intellij.analysis.JavaAnalysisScope; //导入依赖的package包/类
public void testPackageScope2() {
  //com.b<->com.a  - find
  //com.c<->com.d  - not in scope
  final CyclicDependenciesBuilder builder = new CyclicDependenciesBuilder(myProject,
                                                                          new JavaAnalysisScope(JavaPsiFacade
                                                                            .getInstance(myPsiManager.getProject()).findPackage(
                                                                            "com.subscope1"), null));
  builder.analyze();
  final HashMap<PsiPackage, Set<List<PsiPackage>>> cyclicDependencies = builder.getCyclicDependencies();
  HashMap<String, String[][]> expected = new HashMap<String, String[][]>();
  expected.put("com.subscope1.b", new String[][]{{"com.subscope1.a", "com.subscope1.b"}});
  expected.put("com.subscope1.a", new String[][]{{"com.subscope1.b", "com.subscope1.a"}});
  checkResult(expected, cyclicDependencies);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:CyclicDependenciesTest.java

示例7: getInspectionScopeImpl

import com.intellij.analysis.JavaAnalysisScope; //导入依赖的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;
  }

  Module [] modulesArray = LangDataKeys.MODULE_CONTEXT_ARRAY.getData(dataContext);
  if (modulesArray != null) {
    return new AnalysisScope(modulesArray);
  }

  PsiElement psiTarget = LangDataKeys.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:lshain-android-source,项目名称:tools-idea,代码行数:34,代码来源:CyclicDependenciesAction.java

示例8: getInspectionScopeImpl

import com.intellij.analysis.JavaAnalysisScope; //导入依赖的package包/类
@Nullable
private static AnalysisScope getInspectionScopeImpl(DataContext dataContext) {
  //Possible scopes: package, project, module.
  Project projectContext = dataContext.getData(PlatformDataKeys.PROJECT_CONTEXT);
  if (projectContext != null) {
    return null;
  }

  Module moduleContext = dataContext.getData(LangDataKeys.MODULE_CONTEXT);
  if (moduleContext != null) {
    return null;
  }

  Module [] modulesArray = dataContext.getData(LangDataKeys.MODULE_CONTEXT_ARRAY);
  if (modulesArray != null) {
    return new AnalysisScope(modulesArray);
  }

  PsiElement psiTarget = dataContext.getData(LangDataKeys.PSI_ELEMENT);
  if (psiTarget instanceof PsiDirectory) {
    PsiDirectory psiDirectory = (PsiDirectory)psiTarget;
    if (!psiDirectory.getManager().isInProject(psiDirectory)) return null;
    return new AnalysisScope(psiDirectory);
  }
  else if (psiTarget instanceof PsiJavaPackage) {
    PsiJavaPackage pack = (PsiJavaPackage)psiTarget;
    PsiDirectory[] dirs = pack.getDirectories(GlobalSearchScope.projectScope(pack.getProject()));
    if (dirs.length == 0) return null;
    return new JavaAnalysisScope(pack, dataContext.getData(LangDataKeys.MODULE));
  }

  return null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:34,代码来源:CyclicDependenciesAction.java

示例9: testForwardPackageScope

import com.intellij.analysis.JavaAnalysisScope; //导入依赖的package包/类
public void testForwardPackageScope(){
  final PsiJavaPackage bPackage = JavaPsiFacade.getInstance(myPsiManager.getProject()).findPackage("com.b");
  final DependenciesBuilder builder = new ForwardDependenciesBuilder(myProject, new JavaAnalysisScope(bPackage, null));
  builder.analyze();
  final Set<PsiFile> searchFor = new HashSet<PsiFile>();
  searchFor.add(myJavaFacade.findClass("com.a.A", GlobalSearchScope.allScope(myProject)).getContainingFile());
  final Set<PsiFile> searchIn = new HashSet<PsiFile>();
  final PsiClass bClass = myJavaFacade.findClass("com.b.B", GlobalSearchScope.allScope(myProject));
  searchIn.add(bClass.getContainingFile());
  final PsiClass cClass = myJavaFacade.findClass("com.b.C", GlobalSearchScope.allScope(myProject));
  searchIn.add(cClass.getContainingFile());
  final UsageInfo[] usagesInfos = FindDependencyUtil.findDependencies(builder, searchIn, searchFor);
  final UsageInfo2UsageAdapter[] usages = UsageInfo2UsageAdapter.convert(usagesInfos);
  final String [] psiUsages = new String [usagesInfos.length];
  for (int i = 0; i < usagesInfos.length; i++) {
    psiUsages[i] = toString(usages[i]);
  }
  checkResult(new String []{
    "(2: 14) import com.a.A;",
    "(4: 3) A myA = new A();",
    "(4: 15) A myA = new A();",
    "(6: 9) myA.aa();",

    "(2: 14) import com.a.A;",
    "(4: 3) A myA = new A();",
    "(4: 15) A myA = new A();",
    "(6: 9) myA.aa();"}, psiUsages);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:29,代码来源:UsagesInAnalyzingDependenciesTest.java

示例10: testPackageScope1

import com.intellij.analysis.JavaAnalysisScope; //导入依赖的package包/类
public void testPackageScope1(){
  // com.a<->com.b
  final CyclicDependenciesBuilder builder = new CyclicDependenciesBuilder(myProject,
                                                                          new JavaAnalysisScope(JavaPsiFacade
                                                                            .getInstance(myPsiManager.getProject()).findPackage("com"), null));
  builder.analyze();
  final HashMap<PsiJavaPackage, Set<List<PsiJavaPackage>>> cyclicDependencies = builder.getCyclicDependencies();
  HashMap<String, String[][]> expected = new HashMap<String, String[][]>();
  expected.put("com.b", new String[][]{{"com.a", "com.b"}});
  expected.put("com.a", new String[][]{{"com.b", "com.a"}});
  checkResult(expected, cyclicDependencies);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:13,代码来源:CyclicDependenciesTest.java

示例11: testPackageScope2

import com.intellij.analysis.JavaAnalysisScope; //导入依赖的package包/类
public void testPackageScope2() {
  //com.b<->com.a  - find
  //com.c<->com.d  - not in scope
  final CyclicDependenciesBuilder builder = new CyclicDependenciesBuilder(myProject,
                                                                          new JavaAnalysisScope(JavaPsiFacade
                                                                            .getInstance(myPsiManager.getProject()).findPackage(
                                                                            "com.subscope1"), null));
  builder.analyze();
  final HashMap<PsiJavaPackage, Set<List<PsiJavaPackage>>> cyclicDependencies = builder.getCyclicDependencies();
  HashMap<String, String[][]> expected = new HashMap<String, String[][]>();
  expected.put("com.subscope1.b", new String[][]{{"com.subscope1.a", "com.subscope1.b"}});
  expected.put("com.subscope1.a", new String[][]{{"com.subscope1.b", "com.subscope1.a"}});
  checkResult(expected, cyclicDependencies);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:15,代码来源:CyclicDependenciesTest.java


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