Source extends File { public List<String> readImports() throws IOException { final List<String> imports = new ArrayList<>(); try (final BufferedReader sourceIn = open()) { return readNextImports(sourceIn); } catch (final NoSuchFileException e) { logger.trace("{} not found", location); return emptyList(); } } Source(final Project project, final String location); @Override List<Resource> getDependencies(final ResourceManager resourceManager); List<String> readImports(); Text getBody(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testReadImports() throws IOException { final ProjectFile projectFile = new ProjectFile(); final Project project = new Project(randomUUID().toString(), projectFile); final Source source = new Source(project, randomUUID().toString()); source.setContentProvider(() -> openWithExtensionAs("lua")); final List<String> libraries = source.readImports(); assertEquals(3, libraries.size()); }