diff --git a/pom.xml b/pom.xml index e66a558..1471d43 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.github.hadii-tech clarpse - 7.1.0 + 7.1.1 jar ${project.groupId}:${project.artifactId} diff --git a/src/main/java/com/hadii/clarpse/compiler/ProjectFiles.java b/src/main/java/com/hadii/clarpse/compiler/ProjectFiles.java index 3611eb1..db85fe2 100644 --- a/src/main/java/com/hadii/clarpse/compiler/ProjectFiles.java +++ b/src/main/java/com/hadii/clarpse/compiler/ProjectFiles.java @@ -173,6 +173,12 @@ public final Collection files(Lang language) { return this.langToFilesMap.getOrDefault(language, new ArrayList<>()); } + public final Collection files() { + Set allFiles = new HashSet<>(); + this.langToFilesMap.forEach((lang, files) -> allFiles.addAll(files)); + return allFiles; + } + public String projectDir() { if (this.projectDir != null && !this.projectDir.isEmpty()) { return this.projectDir; diff --git a/src/test/java/com/hadii/test/ProjectFilesTest.java b/src/test/java/com/hadii/test/ProjectFilesTest.java index 93eb104..5921f9c 100644 --- a/src/test/java/com/hadii/test/ProjectFilesTest.java +++ b/src/test/java/com/hadii/test/ProjectFilesTest.java @@ -136,6 +136,47 @@ public void testProjectFilesSize() { assertEquals(2, pfs.size()); } + @Test + public void testGetAllFiles() { + ProjectFiles pfs = new ProjectFiles(); + pfs.insertFile(new ProjectFile("/test.java", "{}")); + pfs.insertFile(new ProjectFile("/tester.go", "{}")); + assertEquals(2, pfs.files().size()); + } + + @Test + public void testGetAllGoFiles() { + ProjectFiles pfs = new ProjectFiles(); + pfs.insertFile(new ProjectFile("/test.java", "{}")); + pfs.insertFile(new ProjectFile("/tester.go", "{}")); + assertEquals(1, pfs.files(Lang.GOLANG).size()); + } + + @Test + public void testGetAllFilesForNonExistentLang() { + ProjectFiles pfs = new ProjectFiles(); + pfs.insertFile(new ProjectFile("/test.java", "{}")); + pfs.insertFile(new ProjectFile("/tester.go", "{}")); + assertEquals(0, pfs.files(Lang.JAVASCRIPT).size()); + } + + @Test + public void testGetAllJavaFiles() { + ProjectFiles pfs = new ProjectFiles(); + pfs.insertFile(new ProjectFile("/test.java", "{}")); + pfs.insertFile(new ProjectFile("/tester.go", "{}")); + assertEquals(1, pfs.files(Lang.JAVA).size()); + } + + @Test + public void testGetAllJSFiles() { + ProjectFiles pfs = new ProjectFiles(); + pfs.insertFile(new ProjectFile("/test.js", "{}")); + pfs.insertFile(new ProjectFile("/tester.go", "{}")); + assertEquals(1, pfs.files(Lang.JAVASCRIPT).size()); + } + + @Test public void testEmptyProjectFilesSize() { ProjectFiles pfs = new ProjectFiles();