Skip to content

Commit

Permalink
revert: parse import
Browse files Browse the repository at this point in the history
  • Loading branch information
heowc committed Nov 17, 2024
1 parent 2af34d0 commit d30dd04
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.github.javaparser.ParseResult;
import com.github.javaparser.ParseStart;
import com.github.javaparser.Providers;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.ImportDeclaration;
import com.github.javaparser.ast.nodeTypes.NodeWithName;

Expand Down Expand Up @@ -90,15 +91,17 @@ private DependentModule createDependentModule(Module module, Map<String, Module>

private Stream<ImportDeclaration> parseImports(Module module) {
try {
final ParseResult<ImportDeclaration> parsed =
javaParser.parse(ParseStart.IMPORT_DECLARATION,
final ParseResult<CompilationUnit> parsed =
javaParser.parse(ParseStart.COMPILATION_UNIT,
Providers.provider(module.getPath(),
javaParser.getParserConfiguration().getCharacterEncoding()));

if (!parsed.isSuccessful()) {
return Stream.empty();
}
return parsed.getResult().stream();
return parsed.getResult().orElseThrow()
.getImports()
.stream();
} catch (IOException e) {
return Stream.empty();
}
Expand Down

0 comments on commit d30dd04

Please sign in to comment.