use of com.intellij.analysis.AnalysisScope in project intellij-community by JetBrains.
the class FindMethodDuplicatesBaseTest method doTest.
protected void doTest(final boolean shouldSucceed) throws Exception {
final String filePath = getTestFilePath();
configureByFile(filePath);
final PsiElement targetElement = TargetElementUtil.findTargetElement(getEditor(), TargetElementUtil.ELEMENT_NAME_ACCEPTED);
assertTrue("<caret> is not on method name", targetElement instanceof PsiMember);
final PsiMember psiMethod = (PsiMember) targetElement;
try {
MethodDuplicatesHandler.invokeOnScope(getProject(), psiMethod, new AnalysisScope(getFile()));
} catch (RuntimeException e) {
if (shouldSucceed) {
fail("duplicates were not found");
}
return;
}
UIUtil.dispatchAllInvocationEvents();
if (shouldSucceed) {
checkResultByFile(filePath + ".after");
} else {
fail("duplicates found");
}
}
use of com.intellij.analysis.AnalysisScope in project intellij-community by JetBrains.
the class DependenciesPanelTest method testModuleGroups.
public void testModuleGroups() throws Exception {
ModifiableModuleModel model = ModuleManager.getInstance(myProject).getModifiableModel();
model.setModuleGroupPath(myModule, new String[] { "a", "b" });
model.renameModule(myModule, "module");
WriteAction.run(model::commit);
// groups aren't shown for single-module projects so we need to add an empty second module
createModule("util");
DependencyUISettings settings = DependencyUISettings.getInstance();
settings.UI_GROUP_BY_SCOPE_TYPE = false;
settings.UI_SHOW_FILES = false;
settings.SCOPE_TYPE = ProjectPatternProvider.FILE;
doTestDependenciesTrees(new AnalysisScope(myModule), "-Root\n" + " -[a]\n" + " -b\n" + " -module\n" + " -dependencies\n" + " -src\n" + " com/package1\n", "Root\n");
}
use of com.intellij.analysis.AnalysisScope in project intellij-community by JetBrains.
the class UsagesInAnalyzingDependenciesTest method testForwardJdkClasses.
@SuppressWarnings("ConstantConditions")
public void testForwardJdkClasses() {
DependenciesBuilder builder = new ForwardDependenciesBuilder(myProject, new AnalysisScope(myProject));
builder.analyze();
Set<PsiFile> searchIn = new HashSet<>();
PsiClass aClass = myJavaFacade.findClass("A", GlobalSearchScope.allScope(myProject));
searchIn.add(aClass.getContainingFile());
Set<PsiFile> searchFor = new HashSet<>();
PsiClass stringClass = myJavaFacade.findClass("java.lang.String", GlobalSearchScope.allScope(myProject));
searchFor.add((PsiFile) stringClass.getContainingFile().getNavigationElement());
UsageInfo[] usagesInfos = FindDependencyUtil.findDependencies(builder, searchIn, searchFor);
UsageInfo2UsageAdapter[] usages = UsageInfo2UsageAdapter.convert(usagesInfos);
String[] psiUsages = new String[usagesInfos.length];
for (int i = 0; i < usagesInfos.length; i++) {
psiUsages[i] = toString(usages[i]);
}
checkResult(new String[] { "2 String myName;" }, psiUsages);
}
use of com.intellij.analysis.AnalysisScope in project intellij-community by JetBrains.
the class AnalysisScopeTest method testGeneratedSourceRoot.
public void testGeneratedSourceRoot() throws Exception {
VirtualFile genRoot = getVirtualFile(createTempDir("genSrcRoot"));
VirtualFile srcRoot = getVirtualFile(createTempDir("srcRoot"));
JavaSourceRootProperties properties = JpsJavaExtensionService.getInstance().createSourceRootProperties("", true);
PsiTestUtil.addSourceRoot(myModule, genRoot, JavaSourceRootType.SOURCE, properties);
PsiTestUtil.addSourceRoot(myModule, srcRoot);
VirtualFile genClass = VfsTestUtil.createFile(genRoot, "Gen.java", "class Gen{}");
VirtualFile srcClass = VfsTestUtil.createFile(srcRoot, "Src.java", "class Src{}");
AnalysisScope scope = new AnalysisScope(myModule);
assertTrue(scope.contains(srcClass));
assertFalse(scope.contains(genClass));
}
use of com.intellij.analysis.AnalysisScope in project intellij-community by JetBrains.
the class CyclicDependenciesTest method testT4.
public void testT4() {
//com.a<->com.b
//com.a->com.c->com.d->com.a
final CyclicDependenciesBuilder builder = new CyclicDependenciesBuilder(myProject, new AnalysisScope(myProject));
builder.analyze();
final HashMap<PsiPackage, Set<List<PsiPackage>>> cyclicDependencies = builder.getCyclicDependencies();
HashMap<String, String[][]> expected = new HashMap<>();
expected.put("com.b", new String[][] { { "com.a", "com.b" } });
expected.put("com.d", new String[][] { { "com.c", "com.a", "com.d" } });
expected.put("com.c", new String[][] { { "com.a", "com.d", "com.c" } });
expected.put("com.a", new String[][] { { "com.d", "com.c", "com.a" }, { "com.b", "com.a" } });
checkResult(expected, cyclicDependencies, true);
}
Aggregations