LexSimpleAnalyzerUtils { static Set<String> parseIncludes(Reader fileReader) throws IOException { Set<String> includedFiles = new HashSet<>(); try (LineNumberReader reader = new LineNumberReader(fileReader)) { String line = reader.readLine(); while (line != null) { String includedFile = guessIncluded(line); if (includedFile != null) { includedFiles.add(includedFile); } line = reader.readLine(); } } return includedFiles; } private  LexSimpleAnalyzerUtils();   }
@Test public void parseIncludedFiles() throws Exception { String lex = "\n" + "package org.example;\n" + "\n" + "import java.io.File;\n" + "\n" + "\t%include base.lexh\t \n" + "\n" + "%%\n" + "\n" + " %include two.lexh \n" + "\n" + "%%\n" + "\n" + "%include three.lexh\t \n" + " %include three.lexh\n"; assertThat(parseIncludes(lex)).containsExactly("base.lexh", "two.lexh", "three.lexh"); }