Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
3,800
ProjectDescriptor (final BuildLoggingManager buildLoggingManager) { try { BuildTargetRegistryImpl targetRegistry = new BuildTargetRegistryImpl(myModel); ModuleExcludeIndex index = new ModuleExcludeIndexImpl(myModel); IgnoredFileIndexImpl ignoredFileIndex = new IgnoredFileIndexImpl(myModel); BuildDataPaths dataPaths = new BuildDataPathsImpl(myDataStorageRoot); BuildRootIndexImpl buildRootIndex = new BuildRootIndexImpl(targetRegistry, myModel, index, dataPaths, ignoredFileIndex); BuildTargetIndexImpl targetIndex = new BuildTargetIndexImpl(targetRegistry, buildRootIndex); BuildTargetsState targetsState = new BuildTargetsState(dataPaths, myModel, buildRootIndex); PathRelativizerService relativizer = new PathRelativizerService(myModel.getProject()); ProjectStamps projectStamps = new ProjectStamps(myDataStorageRoot, targetsState, relativizer); BuildDataManager dataManager = new BuildDataManager(dataPaths, targetsState, relativizer); return new ProjectDescriptor(myModel, new BuildFSState(true), projectStamps, dataManager, buildLoggingManager, index, targetIndex, buildRootIndex, ignoredFileIndex); } catch (IOException e) { throw new RuntimeException(e); } }
createProjectDescriptor
3,801
void (String projectPath) { loadProject(projectPath, Collections.emptyMap()); }
loadProject
3,802
void (String projectPath, Map<String, String> pathVariables) { try { String testDataRootPath = getTestDataRootPath(); String fullProjectPath = FileUtil.toSystemDependentName(testDataRootPath != null ? testDataRootPath + "/" + projectPath : projectPath); Map<String, String> allPathVariables = new HashMap<>(pathVariables.size() + 1); allPathVariables.putAll(pathVariables); allPathVariables.put(PathMacroUtil.APPLICATION_HOME_DIR, PathManager.getHomePath()); allPathVariables.putAll(getAdditionalPathVariables()); JpsProjectLoader.loadProject(myProject, allPathVariables, Paths.get(fullProjectPath)); final JpsJavaCompilerConfiguration config = JpsJavaExtensionService.getInstance().getCompilerConfiguration(myProject); config.getCompilerOptions(JavaCompilers.JAVAC_ID).PREFER_TARGET_JDK_COMPILER = false; } catch (IOException e) { throw new RuntimeException(e); } }
loadProject
3,803
String () { return null; }
getTestDataRootPath
3,804
void () { doBuild(CompileScopeTestBuilder.rebuild().allModules()).assertSuccessful(); }
rebuildAllModules
3,805
void () { doBuild(CompileScopeTestBuilder.rebuild().all()).assertSuccessful(); }
rebuildAll
3,806
BuildResult () { return doBuild(make().allModules()); }
buildAllModules
3,807
BuildResult () { return doBuild(make().all()); }
makeAll
3,808
BuildResult (CompileScopeTestBuilder scope) { ProjectDescriptor descriptor = createProjectDescriptor(new BuildLoggingManager(myLogger)); try { myLogger.clearFilesData(); return doBuild(descriptor, scope); } finally { descriptor.release(); } }
doBuild
3,809
void () { myLogger.clearLog(); }
clearBuildLog
3,810
void (String builderName, String... paths) { myLogger.assertCompiled(builderName, new File[]{myProjectDir, myDataStorageRoot}, paths); }
assertCompiled
3,811
void (File expectedLogFile) { assertSameLinesWithFile(expectedLogFile.getAbsolutePath(), myLogger.getFullLog(myProjectDir, myDataStorageRoot)); }
checkFullLog
3,812
void (String... paths) { myLogger.assertDeleted(new File[]{myProjectDir, myDataStorageRoot}, paths); }
assertDeleted
3,813
BuildResult (final ProjectDescriptor descriptor, CompileScopeTestBuilder scopeBuilder) { IncProjectBuilder builder = new IncProjectBuilder(descriptor, BuilderRegistry.getInstance(), myBuildParams, CanceledStatus.NULL, true); BuildResult result = new BuildResult(); builder.addMessageHandler(result); try { beforeBuildStarted(descriptor); builder.build(scopeBuilder.build(), false); result.storeMappingsDump(descriptor); } catch (RebuildRequestedException | IOException e) { throw new RuntimeException(e); } finally { // the following code models module index reload after each make session JavaModuleIndex moduleIndex = JpsJavaExtensionService.getInstance().getJavaModuleIndex(descriptor.getProject()); if (moduleIndex instanceof JavaModuleIndexImpl) { ((JavaModuleIndexImpl)moduleIndex).dropCache(); } } return result; }
doBuild
3,814
void (@NotNull ProjectDescriptor descriptor) { }
beforeBuildStarted
3,815
void (String relativePath) { delete(new File(getOrCreateProjectDir(), relativePath).getAbsolutePath()); }
deleteFile
3,816
void (String relativePath) { changeFile(relativePath, null); }
changeFile
3,817
void (String relativePath, String newContent) { change(new File(getOrCreateProjectDir(), relativePath).getAbsolutePath(), newContent); }
changeFile
3,818
String (String relativePath) { return createFile(relativePath, ""); }
createFile
3,819
String (String relativePath) { File dir = new File(getOrCreateProjectDir(), relativePath); boolean created = dir.mkdirs(); if (!created && !dir.isDirectory()) { fail("Cannot create " + dir.getAbsolutePath() + " directory"); } return FileUtil.toSystemIndependentName(dir.getAbsolutePath()); }
createDir
3,820
String (String relativePath, final String text) { try { File file = new File(getOrCreateProjectDir(), relativePath); FileUtil.writeToFile(file, text); return FileUtil.toSystemIndependentName(file.getAbsolutePath()); } catch (IOException e) { throw new RuntimeException(e); } }
createFile
3,821
String (String relativeSourcePath, String relativeTargetPath) { File source = findFindUnderProjectHome(relativeSourcePath); String fullTargetPath = getAbsolutePath(relativeTargetPath); File target = new File(fullTargetPath); try { FileUtil.copyFileOrDir(source, target); } catch (IOException e) { throw new RuntimeException(e); } return fullTargetPath; }
copyToProject
3,822
File (String relativeSourcePath) { return PathManagerEx.findFileUnderProjectHome(relativeSourcePath, getClass()); }
findFindUnderProjectHome
3,823
File () { if (myProjectDir == null) { try { myProjectDir = doGetProjectDir(); } catch (IOException e) { throw new RuntimeException(e); } } return myProjectDir; }
getOrCreateProjectDir
3,824
String (final String pathRelativeToProjectRoot) { return FileUtil.toSystemIndependentName(new File(getOrCreateProjectDir(), pathRelativeToProjectRoot).getAbsolutePath()); }
getAbsolutePath
3,825
String (@NotNull String pathRelativeToProjectRoot) { return JpsPathUtil.pathToUrl(getAbsolutePath(pathRelativeToProjectRoot)); }
getUrl
3,826
JpsModule (String moduleName, String... srcPaths) { return addModule(moduleName, srcPaths, getAbsolutePath(getModuleOutputRelativePath(moduleName)), null, getJdk()); }
addModule
3,827
JpsSdk<JpsDummyElement> () { if (myJdk == null) { myJdk = addJdk("1.6"); } return myJdk; }
getJdk
3,828
File (JpsModule module) { String outputUrl = JpsJavaExtensionService.getInstance().getOutputUrl(module, false); return JpsPathUtil.urlToFile(outputUrl); }
getModuleOutput
3,829
String (JpsModule module) { return getModuleOutputRelativePath(module.getName()); }
getModuleOutputRelativePath
3,830
String (String moduleName) { return "out/production/" + moduleName; }
getModuleOutputRelativePath
3,831
void (BuildResult makeResult) { String makeDump = makeResult.getMappingsDump(); BuildResult rebuildResult = doBuild(CompileScopeTestBuilder.rebuild().allModules()); rebuildResult.assertSuccessful(); String rebuildDump = rebuildResult.getMappingsDump(); assertEquals(rebuildDump, makeDump); }
checkMappingsAreSameAfterRebuild
3,832
void () { String srcRoot = PathUtil.getParentPath(createFile("src/A.java", "class A{ { new B(); } }")); String b = createFile("depSrc/B.java", "public class B{}"); JpsModule main = addModule("main", srcRoot); JpsModule dep = addModule("dep", PathUtil.getParentPath(b)); main.getDependenciesList().addModuleDependency(dep); rebuildAllModules(); change(b, "public class B{ public B(int i){} }"); doBuild(CompileScopeTestBuilder.recompile().module(dep)).assertSuccessful(); doBuild(CompileScopeTestBuilder.make().module(main)).assertFailed(); }
testRecompileDependentAfterForcedCompilation
3,833
void () { String srcRoot = PathUtil.getParentPath(createFile("src/A.java", "class A{ }")); JpsModule main = addModule("main", srcRoot); rebuildAllModules(); File b = new File(createFile(getModuleOutputRelativePath(main) + "/a.txt", "qwerty")); buildAllModules(); assertExists(b); doBuild(CompileScopeTestBuilder.recompile().module(main)).assertSuccessful(); assertDoesntExist(b); }
testClearModuleOutputOnForcedCompilation
3,834
void () { JpsModule m1 = addModule("m1", PathUtil.getParentPath(createFile("src/A.java", "class A{ }"))); JpsModule m2 = addModule("m2", PathUtil.getParentPath(createFile("src/B.java", "class B{ }"))); JpsJavaModuleExtension m1Ext = JpsJavaExtensionService.getInstance().getOrCreateModuleExtension(m1); JpsJavaModuleExtension m2Ext = JpsJavaExtensionService.getInstance().getOrCreateModuleExtension(m2); m2Ext.setOutputUrl(m1Ext.getOutputUrl()); m2Ext.setTestOutputUrl(m1Ext.getOutputUrl()); rebuildAllModules(); File b = new File(createFile(getModuleOutputRelativePath(m1) + "/a.txt", "qwerty")); buildAllModules(); assertExists(b); assertExists(new File(getOrCreateProjectDir(), getModuleOutputRelativePath(m1) + "/A.class")); assertExists(new File(getOrCreateProjectDir(), getModuleOutputRelativePath(m1) + "/B.class")); doBuild(CompileScopeTestBuilder.recompile().module(m1)).assertSuccessful(); assertExists(b); assertExists(new File(getOrCreateProjectDir(), getModuleOutputRelativePath(m1) + "/A.class")); assertExists(new File(getOrCreateProjectDir(), getModuleOutputRelativePath(m1) + "/B.class")); }
testDontClearModuleOutputOnForcedCompilation
3,835
void () { String a1 = createFile("src1/A.java", "class A{}"); String b = createFile("src2/B.java", "class B{}"); JpsModule m = addModule("m", PathUtil.getParentPath(a1), PathUtil.getParentPath(b)); buildAllModules(); assertOutput(m, fs().file("A.class").file("B.class")); delete(a1); String a2 = createFile("src2/A.java", "class A{}"); buildAllModules(); assertOutput(m, fs().file("A.class").file("B.class")); delete(a2); buildAllModules(); assertOutput(m, fs().file("B.class")); }
testMoveClassAndDelete
3,836
void () { String file = createFile("src/A.java", "public class A {}"); String excludedFile = createFile("src/excluded.java", "public class excluded {}"); JpsModule m = addModule("m"); m.addSourceRoot(JpsPathUtil.pathToUrl(PathUtil.getParentPath(file)), JavaSourceRootType.SOURCE); JpsJavaExtensionService.getInstance().getCompilerConfiguration(myProject).getCompilerExcludes().addExcludedFile( "file://" + FileUtil.toSystemIndependentName(excludedFile) ); rebuildAllModules(); assertOutput(m, fs().file("A.class")); }
testExcludedFileInSourceRoot
3,837
void () { String file = createFile("src/A.java", "public class A {}"); String excludedFile = createFile("src/data/excluded.java", "public class excluded {}"); JpsModule m = addModule("m"); m.addSourceRoot(JpsPathUtil.pathToUrl(PathUtil.getParentPath(file)), JavaSourceRootType.SOURCE); JpsJavaExtensionService.getInstance().getCompilerConfiguration(myProject).getCompilerExcludes().addExcludedDirectory( JpsPathUtil.pathToUrl(PathUtil.getParentPath(excludedFile)), false ); rebuildAllModules(); assertOutput(m, fs().file("A.class")); }
testExcludedDirInSourceRoot
3,838
void () { String file = createFile("src/A.java", "public class A {}"); String excludedFile = createFile("src/data/excluded.java", "public class excluded {}"); createFile("src/data/pkg/excluded.java", "package pkg; public class excluded {}"); JpsModule m = addModule("m"); m.addSourceRoot(JpsPathUtil.pathToUrl(PathUtil.getParentPath(file)), JavaSourceRootType.SOURCE); JpsJavaExtensionService.getInstance().getCompilerConfiguration(myProject).getCompilerExcludes().addExcludedDirectory( JpsPathUtil.pathToUrl(PathUtil.getParentPath(excludedFile)), true ); rebuildAllModules(); assertOutput(m, fs().file("A.class")); }
testRecursivelyExcludedDirInSourceRoot
3,839
void () { JpsJavaExtensionService.getInstance().getCompilerConfiguration(myProject).addResourcePattern("*.txt"); String file = createFile(JavadocSnippetsSkipFilter.SNIPPETS_FOLDER + "/src/A.java", "public class A {}"); createFile(JavadocSnippetsSkipFilter.SNIPPETS_FOLDER + "/src/res.txt", "COPIED RESOURCE"); createFile(JavadocSnippetsSkipFilter.SNIPPETS_FOLDER + "/src/" + JavadocSnippetsSkipFilter.SNIPPETS_FOLDER + "/B.java", "public class B {}"); createFile(JavadocSnippetsSkipFilter.SNIPPETS_FOLDER + "/src/" + JavadocSnippetsSkipFilter.SNIPPETS_FOLDER + "/res.txt", "FILTERED RESOURCE"); JpsModule m = addModule("m"); m.addSourceRoot(JpsPathUtil.pathToUrl(PathUtil.getParentPath(file)), JavaSourceRootType.SOURCE); rebuildAllModules(); assertOutput(m, fs().file("A.class").file("res.txt", "COPIED RESOURCE")); }
testJavadocSnippetsExcludedInSourceRoot
3,840
void () { String depRoot = PathUtil.getParentPath(createFile("dep/A.java", "class A{}")); String mainRoot = PathUtil.getParentPath(createFile("main/B.java", "class B extends A{}")); JpsModule main = addModule("main", mainRoot); JpsModule dep = addModule("dep", depRoot); main.getDependenciesList().addModuleDependency(dep); rebuildAllModules(); }
testSimpleDependency
3,841
void () { String depRoot = PathUtil.getParentPath(createFile("dep/A.java", "class A{}")); String testRoot = PathUtil.getParentPath(createFile("test/B.java", "class B extends A{}")); JpsModule main = addModule("main"); main.addSourceRoot(JpsPathUtil.pathToUrl(testRoot), JavaSourceRootType.TEST_SOURCE); JpsModule dep = addModule("dep", depRoot); main.getDependenciesList().addModuleDependency(dep); rebuildAllModules(); }
testTestOnProductionDependency
3,842
void () { String depRoot = PathUtil.getParentPath(createFile("dep/A.java", "class A{}")); String mainRoot = PathUtil.getParentPath(createFile("main/B.java", "class B extends A{}")); JpsModule main = addModule("main", mainRoot); JpsModule dep = addModule("dep", depRoot); JpsModule dummy = addModule("dummy"); JpsModule dummy2 = addModule("dummy2"); dep.getDependenciesList().addModuleDependency(main);//force 'main' to be built before 'dep' unless transitive dependency is correctly considered main.getDependenciesList().addModuleDependency(dummy); addExportedDependency(dummy, dummy2); addExportedDependency(dummy2, dep); dummy2.getDependenciesList().addModuleDependency(dummy); //if dummy targets are completely ignored, compilation of 'main' module will fail because 'dep' module won't be compiled rebuildAllModules(); }
testTransitiveDependencyViaDummyModule
3,843
void () { String mSrcRoot = PathUtil.getParentPath(createFile("m/src/A.java", "class A{}")); String mTestRoot = PathUtil.getParentPath(createFile("m/test/Test.java", "class Test{}")); String tSrcRoot = PathUtil.getParentPath(createFile("t/T.java", "class T{}")); JpsModule m = addModule("m", mSrcRoot); m.addSourceRoot(JpsPathUtil.pathToUrl(mTestRoot), JavaSourceRootType.TEST_SOURCE); JpsModule t = addModule("t", tSrcRoot); JpsModuleRootModificationUtil.addDependency(t, m); JpsModuleRootModificationUtil.addDependency(m, t, JpsJavaDependencyScope.TEST, false); CompileScope scope = CompileScopeTestBuilder.rebuild().allModules().build(); ProjectDescriptor descriptor = createProjectDescriptor(BuildLoggingManager.DEFAULT); try { BuildTargetIndex targetIndex = descriptor.getBuildTargetIndex(); CompileContext context = CompileContextImpl.createContextForTests(scope, descriptor); List<BuildTargetChunk> chunks = targetIndex.getSortedTargetChunks(context); for (BuildTargetChunk chunk : chunks) { assertTrue("Circular dependency between build targets " + chunk.getTargets(), chunk.getTargets().size() == 1); } assertEmpty(targetIndex.getDependencies(new ModuleBuildTarget(t, JavaModuleBuildTargetType.TEST), context)); } finally { descriptor.release(); } }
testIgnoreDependenciesFromDummyTargets
3,844
void () { String srcRoot = PathUtil.getParentPath(createFile("main/A.java", "class A{}")); JpsModule main = addModule("main", srcRoot); rebuildAllModules(); main.removeSourceRoot(JpsPathUtil.pathToUrl(srcRoot), JavaSourceRootType.SOURCE); doBuild(CompileScopeTestBuilder.make().module(main)).assertSuccessful(); assertDoesntExist(new File(getOrCreateProjectDir(), getModuleOutputRelativePath(main) + "/A.class")); }
testCleanOutputForDeletedModuleTarget
3,845
void (JpsModule main, JpsModule dep) { JpsModuleDependency dependency = main.getDependenciesList().addModuleDependency(dep); JpsJavaExtensionService.getInstance().getOrCreateDependencyExtension(dependency).setExported(true); }
addExportedDependency
3,846
void (DependencyContext context, PrintStream stream) { }
toStream
3,847
Set<Recompile> (NamingContext context, ProtoMethodEntity method, Difference.Specifier<TypeRepr.ClassType, Difference> annotationsDiff, Difference.Specifier<ParamAnnotation, Difference> paramAnnotationsDiff) { //return RECOMPILE_NONE; return handleChanges(context, Iterators.flat(List.of(annotationsDiff.added(), annotationsDiff.removed(), Iterators.map(paramAnnotationsDiff.added(), pc -> pc.type), Iterators.map(paramAnnotationsDiff.removed(), pc -> pc.type)))); }
methodAnnotationsChanged
3,848
Set<Recompile> (NamingContext context, ProtoFieldEntity field, Difference.Specifier<TypeRepr.ClassType, Difference> annotationsDiff) { //return RECOMPILE_NONE; return handleChanges(context, Iterators.flat(annotationsDiff.added(), annotationsDiff.removed())); }
fieldAnnotationsChanged
3,849
Set<Recompile> (NamingContext context, ClassRepr aClass, Difference.Specifier<TypeRepr.ClassType, Difference> annotationsDiff) { //return RECOMPILE_NONE; return handleChanges(context, Iterators.flat(annotationsDiff.added(), annotationsDiff.removed())); }
classAnnotationsChanged
3,850
Set<Recompile> (NamingContext context, Iterable<TypeRepr.ClassType> changes) { final int annot = context.get(ANOTATION_NAME); final Set<Recompile> result = EnumSet.noneOf(Recompile.class); if (containsAnnotation(annot, changes)) { result.add(Recompile.USAGES); } final int hierarchyAnnot = context.get(HIERARCHY_ANOTATION_NAME); if (containsAnnotation(hierarchyAnnot, changes)) { result.add(Recompile.SUBCLASSES); } return result; }
handleChanges
3,851
boolean (int annotationName, Iterable<TypeRepr.ClassType> classes) { return !Iterators.isEmpty(Iterators.filter(classes, type -> annotationName == type.className)); }
containsAnnotation
3,852
void () { String file = createFile("src/a.xml"); JpsModule m = addModule("m", PathUtil.getParentPath(file)); rebuildAllModules(); assertOutput(m, fs().file("a.xml")); }
testSimple
3,853
void () { String source = createFile("src/a.xml"); final File sourceFile = new File(source); assertTrue("Unable to make file readonly: ", sourceFile.setWritable(false)); JpsModule m = addModule("m", PathUtil.getParentPath(source)); rebuildAllModules(); assertOutput(m, fs().file("a.xml")); final File outputFile = new File(getModuleOutput(m), "a.xml"); assertTrue(outputFile.exists()); assertFalse(Files.isWritable(outputFile.toPath())); sourceFile.setWritable(true); // need this to perform the change change(source, "changed content"); assertTrue("Unable to make file readonly: ", sourceFile.setWritable(false)); buildAllModules().assertSuccessful(); assertTrue(outputFile.exists()); assertFalse(Files.isWritable(outputFile.toPath())); }
testReadonly
3,854
void () { String file = createFile("src/a.xml"); JpsModule m = addModule("m", PathUtil.getParentPath(file)); rebuildAllModules(); assertOutput(m, fs().file("a.xml")); rename(file, "A.xml"); buildAllModules(); assertOutput(m, fs().file("A.xml")); }
testCaseChange
3,855
void () { String file = createFile("src/a.xml"); JpsModule m = addModule("m", PathUtil.getParentPath(file)); JpsModuleSourceRoot sourceRoot = assertOneElement(m.getSourceRoots()); JpsTypedModuleSourceRoot<JavaSourceRootProperties> typed = sourceRoot.asTyped(JavaSourceRootType.SOURCE); assertNotNull(typed); typed.getProperties().setPackagePrefix("xxx"); rebuildAllModules(); assertOutput(m, fs().dir("xxx").file("a.xml")); }
testPackagePrefix
3,856
void () { String file = createFile("res/A.java", "xxx"); JpsModule m = addModule("m"); m.addSourceRoot(JpsPathUtil.pathToUrl(PathUtil.getParentPath(file)), JavaResourceRootType.RESOURCE); rebuildAllModules(); assertOutput(m, fs().file("A.java", "xxx")); }
testResourceRoot
3,857
void () { String file = createFile("res/A.java", "xxx"); String snippetFile = createFile("res/snippet-files/A.java", "XXX"); JpsModule m = addModule("m"); m.addSourceRoot(JpsPathUtil.pathToUrl(PathUtil.getParentPath(file)), JavaResourceRootType.RESOURCE); rebuildAllModules(); assertOutput(m, fs().file("A.java", "xxx").dir("snippet-files").file("A.java", "XXX")); }
testResourceRootWithJavadocSnippet
3,858
void () { String file = createFile("res/A.java", "xxx"); String excludedFile = createFile("res/excluded.java", "XXX"); JpsModule m = addModule("m"); m.addSourceRoot(JpsPathUtil.pathToUrl(PathUtil.getParentPath(file)), JavaResourceRootType.RESOURCE); JpsJavaExtensionService.getInstance().getCompilerConfiguration(myProject).getCompilerExcludes().addExcludedFile( "file://" + FileUtil.toSystemIndependentName(excludedFile) ); rebuildAllModules(); assertOutput(m, fs().file("A.java", "xxx")); }
testExcludesInResourceRoot
3,859
void () { File out = new File(myRoot, "out"); getJavaService().getOrCreateProjectExtension(myProject).setOutputUrl(JpsPathUtil.pathToUrl(out.getAbsolutePath())); JpsModule module1 = addModule(); getJavaService().getOrCreateModuleExtension(module1).setInheritOutput(true); JpsModule module2 = addModule(); addContentRoot(module2, out); getJavaService().getOrCreateModuleExtension(module2).setInheritOutput(true); assertNotExcluded(myRoot); assertExcluded(out); assertEmpty(getModuleExcludes(module1)); assertSameElements(getModuleExcludes(module2), out); }
testProjectOutput
3,860
void () { File out = new File(myRoot, "out"); JpsModule module = addModule(); JpsJavaModuleExtension extension = getJavaService().getOrCreateModuleExtension(module); extension.setExcludeOutput(true); extension.setOutputUrl(JpsPathUtil.pathToUrl(out.getAbsolutePath())); assertNotExcluded(myRoot); assertExcluded(out); assertSameElements(getModuleExcludes(module), out); extension.setExcludeOutput(false); assertNotExcluded(out); assertEmpty(getModuleExcludes(module)); }
testModuleOutput
3,861
void () { File exc = new File(myRoot, "exc"); JpsModule module = addModule(); addExcludedRoot(module, exc); assertNotExcluded(myRoot); assertExcluded(exc); assertSameElements(getModuleExcludes(module), exc); }
testExcludedFolder
3,862
void () { File contentRoot = new File(myRoot, "project"); File excluded = new File(contentRoot, "exc"); File unexcluded = new File(excluded, "src"); JpsModule module = addModule(); addContentRoot(module, contentRoot); addExcludedRoot(module, excluded); addContentRoot(module, unexcluded); assertNotExcluded(contentRoot); assertExcluded(excluded); assertNotExcluded(unexcluded); ModuleExcludeIndexImpl index = createIndex(); assertFalse(index.isExcludedFromModule(contentRoot, module)); assertTrue(index.isExcludedFromModule(excluded, module)); assertFalse(index.isExcludedFromModule(unexcluded, module)); }
testContentRootUnderExcluded
3,863
void () { File outerRoot = new File(myRoot, "outer"); File inner1Root = new File(outerRoot, "inner1"); File inner2Root = new File(outerRoot, "inner2"); JpsModule outer = addModule("outer"); addContentRoot(outer, outerRoot); JpsModule inner1 = addModule("inner1"); JpsModule inner2 = addModule("inner2"); addContentRoot(inner1, inner1Root); addContentRoot(inner2, inner2Root); assertNotExcluded(outerRoot); assertNotExcluded(inner1Root); assertNotExcluded(inner2Root); assertSameElements(getModuleExcludes(outer), inner1Root, inner2Root); assertEmpty(getModuleExcludes(inner1)); assertEmpty(getModuleExcludes(inner2)); ModuleExcludeIndexImpl index = createIndex(); assertTrue(index.isExcludedFromModule(inner1Root, outer)); assertTrue(index.isExcludedFromModule(inner2Root, outer)); assertFalse(index.isExcludedFromModule(inner1Root, inner1)); assertFalse(index.isExcludedFromModule(inner2Root, inner2)); }
testInnerModules
3,864
void () { File outerRoot = new File(myRoot, "outer"); File exc = new File(outerRoot, "exc"); File innerRoot = new File(exc, "inner"); JpsModule outer = addModule("outer"); addContentRoot(outer, outerRoot); addExcludedRoot(outer, exc); JpsModule inner = addModule("inner"); addContentRoot(inner, innerRoot); assertNotExcluded(outerRoot); assertNotExcluded(innerRoot); assertSameElements(getModuleExcludes(outer), exc, innerRoot); assertEmpty(getModuleExcludes(inner)); ModuleExcludeIndexImpl index = createIndex(); assertTrue(index.isExcludedFromModule(innerRoot, outer)); assertFalse(index.isExcludedFromModule(innerRoot, inner)); }
testInnerModuleUnderExcludedRoot
3,865
void () { File project = new File(myRoot, "project"); File exc = new File(project, "exc"); File src = new File(exc, "src"); JpsModule module = addModule(); addContentRoot(module, project); addExcludedRoot(module, exc); addSourceRoot(module, src); assertNotExcluded(src); addExcludedRoot(module, src); assertExcluded(src); }
testSourceRootUnderExcluded
3,866
void () { File root1 = new File(myRoot, "root1"); File root2 = new File(myRoot, "root2"); JpsModule module = addModule(); addContentRoot(module, root1); addContentRoot(module, root2); assertSame(FileFilters.EVERYTHING, createIndex().getModuleFileFilterHonorExclusionPatterns(module)); module.addExcludePattern(JpsPathUtil.pathToUrl(root1.getAbsolutePath()), "*.txt"); module.addExcludePattern(JpsPathUtil.pathToUrl(root2.getAbsolutePath()), "out"); assertExcluded(new File(root1, "a.txt")); assertExcluded(new File(root1, "dir/a.txt")); assertNotExcluded(new File(root1, "A.java")); assertNotExcluded(new File(root2, "a.txt")); assertExcluded(new File(root2, "out")); assertExcluded(new File(root2, "out/A.java")); assertExcluded(new File(root2, "dir/out/A.java")); FileFilter moduleFilter = createIndex().getModuleFileFilterHonorExclusionPatterns(module); assertTrue(moduleFilter.accept(new File(root1, "A.java"))); assertTrue(moduleFilter.accept(new File(root2, "a.txt"))); assertFalse(moduleFilter.accept(new File(root1, "a.txt"))); assertFalse(moduleFilter.accept(new File(root1, "dir/a.txt"))); }
testExcludeByPattern
3,867
void (JpsModule module, File src) { module.addSourceRoot(JpsPathUtil.pathToUrl(src.getAbsolutePath()), JavaSourceRootType.SOURCE); }
addSourceRoot
3,868
void (JpsModule module, File root) { module.getExcludeRootsList().addUrl(JpsPathUtil.pathToUrl(root.getAbsolutePath())); }
addExcludedRoot
3,869
void (JpsModule module, File root) { module.getContentRootsList().addUrl(JpsPathUtil.pathToUrl(root.getAbsolutePath())); }
addContentRoot
3,870
Collection<File> (JpsModule module) { return createIndex().getModuleExcludes(module); }
getModuleExcludes
3,871
void (File file) { assertTrue(createIndex().isExcluded(file)); }
assertExcluded
3,872
void (File file) { assertFalse(createIndex().isExcluded(file)); }
assertNotExcluded
3,873
ModuleExcludeIndexImpl () { return new ModuleExcludeIndexImpl(myModel); }
createIndex
3,874
File (@NotNull String fileName) { return new File(PathManagerEx.findFileUnderCommunityHome("jps/jps-builders/testData/cacheLoader"), fileName); }
getTestDataFile
3,875
FileSource (String fileName) { return new FileSource(new File("src/" + fileName + ".java")); }
createNodeSource
3,876
void () { // dependencies Map<String, Iterable<String>> nodes = new HashMap<>(); nodes.put("A", List.of("B", "C", "D")); nodes.put("B", List.of("E", "F")); nodes.put("C", List.of("E", "G")); nodes.put("D", List.of("H")); nodes.put("E", List.of("I")); nodes.put("I", List.of("A")); runTraversal("Recurse including head", "A,B,C,D,E,F,I,G,H", Iterators.recurse("A", n -> Iterators.filter(nodes.get(n), Objects::nonNull), true)); runTraversal("Recurse without head", "B,C,D,E,F,I,G,H", Iterators.recurse("A", n -> Iterators.filter(nodes.get(n), Objects::nonNull), false)); runTraversal("RecurseDeep including head", "A,B,E,I,F,C,G,D,H", Iterators.recurseDepth("A", n -> Iterators.filter(nodes.get(n), Objects::nonNull), true)); runTraversal("RecurseDeep without head", "B,E,I,F,C,G,D,H", Iterators.recurseDepth("A", n -> Iterators.filter(nodes.get(n), Objects::nonNull), false)); }
testRecurseIterator
3,877
void (String message, String expected, Iterable<String> sequence) { assertEquals("1. " + message, expected, traverse(sequence)); assertEquals("2. " + message, expected, traverse(sequence)); assertEquals("3. " + message, expected, traverse(sequence)); }
runTraversal
3,878
String (Iterable<String> sequence) { StringBuilder buf = new StringBuilder(); for (String s : sequence) { if (!buf.isEmpty()) { buf.append(","); } buf.append(s); } return buf.toString(); }
traverse
3,879
JvmClass () { TypeRepr.ClassType annotation1 = new TypeRepr.ClassType(ANNOTATION1_NAME); TypeRepr.ClassType annotation2 = new TypeRepr.ClassType(ANNOTATION2_NAME); Iterable<TypeRepr.ClassType> annotations = Arrays.asList(annotation1, annotation2); JVMFlags jvmFlags = new JVMFlags(JVM_FLAGS_VALUE); JvmField firstJvmField = new JvmField(jvmFlags, SIGNATURE, NAME, DESCRIPTOR, annotations, FIRST_JVM_FIELD_VALUE); JvmField secondJvmField = new JvmField(jvmFlags, SIGNATURE2, NAME2, DESCRIPTOR2, annotations, SECOND_JVM_FIELD_VALUE); Iterable<JvmField> fields = Arrays.asList(firstJvmField, secondJvmField); Set<ParamAnnotation> paramAnnotations = new HashSet<>(Arrays.asList(PARAM_ANNOTATION1, PARAM_ANNOTATION2)); JvmMethod jvmMethod1 = new JvmMethod(jvmFlags, SIGNATURE, NAME, DESCRIPTOR, annotations, paramAnnotations, List.of(EXCEPTION1, EXCEPTION2), FIRST_JVM_METHOD_VALUE); JvmMethod jvmMethod2 = new JvmMethod(jvmFlags, SIGNATURE2, NAME2, DESCRIPTOR2, annotations, paramAnnotations, List.of(EXCEPTION3, EXCEPTION4), SECOND_JVM_METHOD_VALUE); Iterable<JvmMethod> methods = List.of(jvmMethod1, jvmMethod2); Iterable<TypeRepr.ClassType> classAnnotations = Arrays.asList(new TypeRepr.ClassType(CLASS_TYPE_1), new TypeRepr.ClassType(CLASS_TYPE_2)); Iterable<Usage> usages = Arrays.asList(new ClassNewUsage(CLASS_NEW_USAGE)); Iterable<ElemType> annotationTargets = Arrays.asList(ElemType.TYPE_USE, ElemType.PACKAGE); return new JvmClass(jvmFlags, SIGNATURE, FQ_NAME, OUT_FILE_PATH, SUPER_FQ_NAME, OUTER_FQ_NAME, Arrays.asList(INTERFACE_1, INTERFACE_2), fields, methods, classAnnotations, annotationTargets, null, usages); }
createJvmClassNode
3,880
void (JvmClass jvmClass1, JvmClass jvmClass2) { assertEquals(jvmClass1.getSuperFqName(), jvmClass2.getSuperFqName()); assertEquals(jvmClass1.getOuterFqName(), jvmClass2.getOuterFqName()); assertIterableEquals(jvmClass1.getInterfaces(), jvmClass2.getInterfaces()); checkJvmFields(jvmClass1.getFields(), jvmClass2.getFields()); checkJvmMethodsEquals(jvmClass1.getMethods(), jvmClass2.getMethods()); assertIterableEquals(jvmClass1.getAnnotationTargets(), jvmClass2.getAnnotationTargets()); assertEquals(jvmClass1.getRetentionPolicy(), jvmClass2.getRetentionPolicy()); }
checkJvmClassEquals
3,881
void (Iterable<JvmField> jvmFieldIterable1, Iterable<JvmField> jvmFieldIterable2) { Iterator<JvmField> iterator = jvmFieldIterable2.iterator(); for (JvmField jvmField : jvmFieldIterable1) { JvmField jvmField2 = iterator.next(); assertEquals(jvmField.getFlags(), jvmField2.getFlags()); assertEquals(jvmField.getSignature(), jvmField2.getSignature()); assertEquals(jvmField.getName(), jvmField2.getName()); assertEquals(jvmField.getType(), jvmField2.getType()); assertIterableEquals(jvmField.getAnnotations(), jvmField2.getAnnotations()); assertEquals(jvmField.getValue(), jvmField2.getValue()); } }
checkJvmFields
3,882
void (Iterable<JvmMethod> jvmMethodIterable, Iterable<JvmMethod> jvmMethodIterable2) { Iterator<JvmMethod> iterator2 = jvmMethodIterable2.iterator(); for (JvmMethod jvmMethod1 : jvmMethodIterable) { JvmMethod jvmMethod2 = iterator2.next(); assertEquals(jvmMethod1.getFlags(), jvmMethod2.getFlags()); assertEquals(jvmMethod1.getSignature(), jvmMethod2.getSignature()); assertEquals(jvmMethod1.getName(), jvmMethod2.getName()); assertEquals(jvmMethod1.getType(), jvmMethod2.getType()); assertIterableEquals(jvmMethod1.getAnnotations(), jvmMethod2.getAnnotations()); assertEquals(jvmMethod1.getValue(), jvmMethod2.getValue()); assertIterableEquals(jvmMethod1.getArgTypes(), jvmMethod2.getArgTypes()); assertIterableEquals(jvmMethod1.getParamAnnotations(), jvmMethod2.getParamAnnotations()); assertIterableEquals(jvmMethod1.getExceptions(), jvmMethod2.getExceptions()); assertEquals(jvmMethod1.getDescriptor(), jvmMethod2.getDescriptor()); } }
checkJvmMethodsEquals
3,883
void () { final int totalInvocationCount = 42; final int skipCount = 5; final int expectedInvocations = totalInvocationCount / skipCount; final AtomicInteger operationInvocations = new AtomicInteger(0); final Runnable operation = Utils.asCountedRunnable(skipCount, operationInvocations::incrementAndGet); for (int i = 0; i < totalInvocationCount; i++) { operation.run(); } assertEquals(expectedInvocations, operationInvocations.get()); }
testCounterRunnable
3,884
void () { final String aFile = createFile("aaa.txt", "a"); final String bFile = createFile("bbb.txt", "b"); final JpsArtifact a = addArtifact( root() .archive("x.jar").fileCopy(aFile).end() .archive("x.jar") .fileCopy(bFile)); buildAll(); assertOutput(a, fs() .archive("x.jar") .file("aaa.txt", "a") ); buildAllAndAssertUpToDate(); change(aFile, "a2"); buildAll(); assertDeletedAndCopied("out/artifacts/a/x.jar", "aaa.txt"); assertOutput(a, fs().archive("x.jar").file("aaa.txt", "a2")); buildAllAndAssertUpToDate(); change(bFile, "b2"); buildAllAndAssertUpToDate(); delete(bFile); buildAllAndAssertUpToDate(); }
testOverwriteArchives
3,885
void () { final String cFile = createFile("c.txt", "c"); final String eFile = createFile("e.txt", "e"); final JpsArtifact a = addArtifact( root() .archive("a.jar").archive("b.jar").fileCopy(cFile).end().end() .archive("a.jar").archive("d.jar").fileCopy(eFile)); buildAll(); assertOutput(a, fs().archive("a.jar").archive("b.jar").file("c.txt", "c")); buildAllAndAssertUpToDate(); change(eFile, "e2"); buildAllAndAssertUpToDate(); change(cFile, "c2"); buildAll(); assertDeletedAndCopied("out/artifacts/a/a.jar", "c.txt"); assertOutput(a, fs().archive("a.jar").archive("b.jar").file("c.txt", "c2")); buildAllAndAssertUpToDate(); delete(eFile); buildAllAndAssertUpToDate(); }
testOverwriteNestedArchive
3,886
void () { final String xFile = createFile("x.txt", "1"); final String jarFile = createFile("lib/junit.jar", "123"); JpsArtifact a = addArtifact(root() .archive("junit.jar").fileCopy(xFile).end().parentDirCopy(jarFile)); buildAll(); assertOutput(a, fs().archive("junit.jar").file("x.txt", "1")); buildAllAndAssertUpToDate(); change(xFile, "2"); buildAll(); assertDeletedAndCopied("out/artifacts/a/junit.jar", "x.txt"); assertOutput(a, fs().archive("junit.jar").file("x.txt", "2")); buildAllAndAssertUpToDate(); change(jarFile, "321"); buildAllAndAssertUpToDate(); delete(jarFile); buildAllAndAssertUpToDate(); }
testOverwriteFileByArchive
3,887
void () { final String xFile = createFile("d/x.txt", "1"); final String jarFile = createFile("lib/jdom.jar", "123"); JpsArtifact a = addArtifact(root().parentDirCopy(jarFile) .archive("jdom.jar").parentDirCopy(xFile)); buildAll(); assertOutput(a, fs().file("jdom.jar", "123")); buildAllAndAssertUpToDate(); change(xFile, "2"); buildAllAndAssertUpToDate(); change(jarFile, "321"); buildAll(); assertDeletedAndCopied("out/artifacts/a/jdom.jar", "lib/jdom.jar"); assertOutput(a, fs().file("jdom.jar", "321")); buildAllAndAssertUpToDate(); delete(xFile); buildAllAndAssertUpToDate(); }
testOverwriteArchiveByFile
3,888
void () { String jar = createArchive("x.jar", "x.txt", "1"); String file = createFile("x.txt", "2"); JpsArtifact a = addArtifact(root().extractedDir(jar, "").fileCopy(file)); buildAll(); assertOutput(a, fs().file("x.txt", "1")); buildAllAndAssertUpToDate(); change(file, "3"); buildAllAndAssertUpToDate(); assertOutput(a, fs().file("x.txt", "1")); delete(jar); createArchive("x.jar", "x.txt", "4"); buildAll(); assertOutput(a, fs().file("x.txt", "4")); delete(jar); buildAll(); assertOutput(a, fs().file("x.txt", "3")); }
testOverwriteCopiedFileByExtracted
3,889
void () { String file = createFile("x.txt", "1"); String jar = createArchive("x.jar", "x.txt", "2"); JpsArtifact a = addArtifact(root().fileCopy(file).extractedDir(jar, "")); buildAll(); assertOutput(a, fs().file("x.txt", "1")); buildAllAndAssertUpToDate(); delete(jar); createArchive("x.jar", "x.txt", "3"); buildAll(); assertOutput(a, fs().file("x.txt", "1")); delete(file); buildAll(); assertOutput(a, fs().file("x.txt", "3")); }
testOverwriteExtractedFileByCopied
3,890
String (String relativeArchivePath, String fileNameInArchive, String text) { File file = new File(getOrCreateProjectDir(), relativeArchivePath); try (ZipOutputStream output = new ZipOutputStream(new FileOutputStream(file))) { output.putNextEntry(new ZipEntry(fileNameInArchive)); output.write(text.getBytes(StandardCharsets.UTF_8)); output.closeEntry(); } catch (IOException e) { throw new RuntimeException(e); } return FileUtil.toSystemIndependentName(file.getAbsolutePath()); }
createArchive
3,891
void () { final String firstFile = createFile("d1/xxx.txt", "first"); final String secondFile = createFile("d2/xxx.txt", "second"); final String fooFile = createFile("d3/xxx.txt", "foo"); final JpsArtifact a = addArtifact( root().dir("ddd") .dirCopy(PathUtil.getParentPath(firstFile)) .dirCopy(PathUtil.getParentPath(fooFile)).parentDirCopy(secondFile).end() ); buildAll(); assertOutput(a, fs().dir("ddd").file("xxx.txt", "first")); buildAllAndAssertUpToDate(); change(firstFile, "first2"); buildAll(); assertDeletedAndCopied("out/artifacts/a/ddd/xxx.txt", "d1/xxx.txt"); assertOutput(a, fs().dir("ddd").file("xxx.txt", "first2")); buildAllAndAssertUpToDate(); change(secondFile); buildAllAndAssertUpToDate(); change(fooFile); buildAllAndAssertUpToDate(); delete(fooFile); buildAllAndAssertUpToDate(); delete(secondFile); buildAllAndAssertUpToDate(); }
testFileOrder
3,892
void () { final String firstFile = createFile("d1/xxx.txt", "1"); final String secondFile = createFile("d2/xxx.txt", "2"); final JpsArtifact a = addArtifact("a", root().dir("ddd").dirCopy(PathUtil.getParentPath(firstFile)).parentDirCopy(secondFile).fileCopy(createFile("y.txt")) ); buildAll(); assertOutput(a, fs().dir("ddd").file("xxx.txt", "1").file("y.txt")); delete(firstFile); buildAll(); assertDeletedAndCopied("out/artifacts/a/ddd/xxx.txt", "d2/xxx.txt"); assertOutput(a, fs().dir("ddd").file("xxx.txt", "2").file("y.txt")); buildAllAndAssertUpToDate(); delete(secondFile); buildAll(); assertDeleted("out/artifacts/a/ddd/xxx.txt"); assertOutput(a, fs().dir("ddd").file("y.txt")); }
testDeleteOverwritingFiles
3,893
void () { final String manifestText1 = "Manifest-Version: 1.0\r\nMain-Class: A\r\n\r\n"; final String manifest = createFile("d/MANIFEST.MF", manifestText1); final JpsArtifact a = addArtifact("a", root().archive("a.jar").dir("META-INF").parentDirCopy(manifest).fileCopy(createFile("a.txt"))); buildAll(); assertOutput(a, fs().archive("a.jar").dir("META-INF").file("MANIFEST.MF", manifestText1).file("a.txt")); final String manifestText2 = "Manifest-Version: 1.0\r\nMain-Class: B\r\n\r\n"; change(manifest, manifestText2); buildAll(); assertDeletedAndCopied("out/artifacts/a/a.jar", "d/MANIFEST.MF", "a.txt"); assertOutput(a, fs().archive("a.jar").dir("META-INF").file("MANIFEST.MF", manifestText2).file("a.txt")); buildAllAndAssertUpToDate(); delete(manifest); buildAll(); assertDeletedAndCopied("out/artifacts/a/a.jar", "a.txt"); assertOutput(a, fs().archive("a.jar").dir("META-INF").file("a.txt")); }
testUpdateManifest
3,894
void () { JpsArtifact a = addArtifact(root().fileCopy(createFile("a.txt"))); buildArtifacts(a); createFileInArtifactOutput(a, "b.txt"); assertOutput(a, fs().file("a.txt").file("b.txt")); rebuildAllModulesAndArtifacts(); assertOutput(a, fs().file("a.txt").file("b.txt")); }
testCleanOutput
3,895
void () { JpsJavaExtensionService.getInstance().getCompilerConfiguration(myProject).setClearOutputDirectoryOnRebuild(false); JpsArtifact a = addArtifact(root().fileCopy(createFile("a.txt"))); buildArtifacts(a); createFileInArtifactOutput(a, "b.txt"); rebuildAllModulesAndArtifacts(); assertOutput(a, fs().file("a.txt").file("b.txt")); }
testDoNotCleanOnRebuildIfOptionIsSwitchedOff
3,896
void () { JpsArtifact a = addArtifact(root().fileCopy(createFile("a.txt"))); addModule("m", a.getOutputPath() + "/src"); buildArtifacts(a); createFileInArtifactOutput(a, "b.txt"); rebuildAllModulesAndArtifacts(); assertOutput(a, fs().file("a.txt").file("b.txt")); }
testDoNotCleanIfContainsSourceFolder
3,897
void () { JpsModule m = addModule("m"); String resDir = PathUtil.getParentPath(createFile("res/a.txt")); m.getContentRootsList().addUrl(JpsPathUtil.pathToUrl(resDir)); JpsArtifact a = addArtifact(root().dirCopy(resDir)); a.setOutputPath(resDir); buildArtifacts(a); assertOutput(a, fs().file("a.txt")); createFile("res/b.txt"); rebuildAllModulesAndArtifacts(); assertOutput(a, fs().file("a.txt").file("b.txt")); }
testDoNotCleanIfContainsArtifactRoot
3,898
void () { JpsArtifact included = addArtifact("b", root().fileCopy(createFile("a.txt"))); JpsArtifact a = addArtifact(root().artifact(included)); buildArtifacts(a, included); createFileInArtifactOutput(included, "b.txt"); assertOutput(included, fs().file("a.txt").file("b.txt")); rebuildAllModulesAndArtifacts(); assertOutput(included, fs().file("a.txt").file("b.txt")); }
testCleanArtifactOutputIfItIsIncludedIntoAnotherArtifact
3,899
void () { String file = createFile("src/A.java", "class A{}"); JpsModule m = addModule("m", PathUtil.getParentPath(file)); JpsArtifact a = addArtifact(root().module(m)); buildArtifacts(a); createFileInModuleOutput(m, "b.txt"); assertOutput(m, fs().file("A.class").file("b.txt")); rebuildAllModulesAndArtifacts(); assertOutput(m, fs().file("A.class")); }
testCleanModuleOutputIfItIsIncludedInArtifact