@Test public void test() { List<String> files = Arrays.asList("dir1/file1.ts", "dir2/file2.ts", "dir3/file3.ts"); List<InputFile> inputFiles = files.stream().map(f -> TestInputFileBuilder.create("foo", f).build()).collect(Collectors.toList()); List<TsConfigFile> tsConfigFiles = Arrays.asList( new TsConfigFile("dir1/tsconfig.json", singletonList("foo/dir1/file1.ts"), emptyList()), new TsConfigFile("dir2/tsconfig.json", singletonList("foo/dir2/file2.ts"), emptyList()), new TsConfigFile("dir3/tsconfig.json", singletonList("foo/dir3/file3.ts"), emptyList()) ); Map<TsConfigFile, List<InputFile>> result = TsConfigFile.inputFilesByTsConfig(tsConfigFiles, inputFiles); assertThat(result).containsExactly( entry(tsConfigFiles.get(0), singletonList(inputFiles.get(0))), entry(tsConfigFiles.get(1), singletonList(inputFiles.get(1))), entry(tsConfigFiles.get(2), singletonList(inputFiles.get(2))) ); }
static Map<TsConfigFile, List<InputFile>> inputFilesByTsConfig(List<TsConfigFile> tsConfigFiles, List<InputFile> inputFiles) { Map<TsConfigFile, List<InputFile>> result = new LinkedHashMap<>(); inputFiles.forEach(inputFile -> { TsConfigFile tsconfig = tsConfigFiles.stream() .filter(tsConfigFile -> tsConfigFile.test(inputFile)) .findFirst().orElse(UNMATCHED_CONFIG); LOG.debug("{} matched {}", inputFile.absolutePath(), tsconfig); result.computeIfAbsent(tsconfig, t -> new ArrayList<>()).add(inputFile); }); return result; }
TsConfigFile implements Predicate<InputFile> { static Map<TsConfigFile, List<InputFile>> inputFilesByTsConfig(List<TsConfigFile> tsConfigFiles, List<InputFile> inputFiles) { Map<TsConfigFile, List<InputFile>> result = new LinkedHashMap<>(); inputFiles.forEach(inputFile -> { TsConfigFile tsconfig = tsConfigFiles.stream() .filter(tsConfigFile -> tsConfigFile.test(inputFile)) .findFirst().orElse(UNMATCHED_CONFIG); LOG.debug("{} matched {}", inputFile.absolutePath(), tsconfig); result.computeIfAbsent(tsconfig, t -> new ArrayList<>()).add(inputFile); }); return result; } }
TsConfigFile implements Predicate<InputFile> { static Map<TsConfigFile, List<InputFile>> inputFilesByTsConfig(List<TsConfigFile> tsConfigFiles, List<InputFile> inputFiles) { Map<TsConfigFile, List<InputFile>> result = new LinkedHashMap<>(); inputFiles.forEach(inputFile -> { TsConfigFile tsconfig = tsConfigFiles.stream() .filter(tsConfigFile -> tsConfigFile.test(inputFile)) .findFirst().orElse(UNMATCHED_CONFIG); LOG.debug("{} matched {}", inputFile.absolutePath(), tsconfig); result.computeIfAbsent(tsconfig, t -> new ArrayList<>()).add(inputFile); }); return result; } TsConfigFile(String filename, List<String> files, List<String> projectReferences); }
TsConfigFile implements Predicate<InputFile> { static Map<TsConfigFile, List<InputFile>> inputFilesByTsConfig(List<TsConfigFile> tsConfigFiles, List<InputFile> inputFiles) { Map<TsConfigFile, List<InputFile>> result = new LinkedHashMap<>(); inputFiles.forEach(inputFile -> { TsConfigFile tsconfig = tsConfigFiles.stream() .filter(tsConfigFile -> tsConfigFile.test(inputFile)) .findFirst().orElse(UNMATCHED_CONFIG); LOG.debug("{} matched {}", inputFile.absolutePath(), tsconfig); result.computeIfAbsent(tsconfig, t -> new ArrayList<>()).add(inputFile); }); return result; } TsConfigFile(String filename, List<String> files, List<String> projectReferences); @Override boolean test(InputFile inputFile); @Override String toString(); }
TsConfigFile implements Predicate<InputFile> { static Map<TsConfigFile, List<InputFile>> inputFilesByTsConfig(List<TsConfigFile> tsConfigFiles, List<InputFile> inputFiles) { Map<TsConfigFile, List<InputFile>> result = new LinkedHashMap<>(); inputFiles.forEach(inputFile -> { TsConfigFile tsconfig = tsConfigFiles.stream() .filter(tsConfigFile -> tsConfigFile.test(inputFile)) .findFirst().orElse(UNMATCHED_CONFIG); LOG.debug("{} matched {}", inputFile.absolutePath(), tsconfig); result.computeIfAbsent(tsconfig, t -> new ArrayList<>()).add(inputFile); }); return result; } TsConfigFile(String filename, List<String> files, List<String> projectReferences); @Override boolean test(InputFile inputFile); @Override String toString();  }