Skip to content

Commit

Permalink
Code enhancements (#179)
Browse files Browse the repository at this point in the history
- Use method references.
  • Loading branch information
khatchad authored Apr 9, 2024
1 parent eb59763 commit 5dbf07c
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import org.antlr.runtime.ANTLRInputStream;
import org.antlr.runtime.CharStream;
import org.python.antlr.ast.ImportFrom;
import org.python.antlr.ast.Name;
import org.python.antlr.ast.alias;

public class PythonModuleParser extends PythonParser<ModuleEntry> {

Expand Down Expand Up @@ -63,10 +65,7 @@ protected PythonParser<ModuleEntry>.CAstVisitor makeVisitor(
public CAstNode visitImportFrom(ImportFrom importFrom) throws Exception {
Optional<String> s =
importFrom.getInternalModuleNames().stream()
.map(
n -> {
return n.getInternalId();
})
.map(Name::getInternalId)
.reduce(
(a, b) -> {
return a + "/" + b;
Expand All @@ -89,7 +88,7 @@ public CAstNode visitImportFrom(ImportFrom importFrom) throws Exception {
return Ast.makeNode(
CAstNode.BLOCK_STMT,
importFrom.getInternalNames().stream()
.map(a -> a.getInternalName())
.map(alias::getInternalName)
.map(
n ->
Ast.makeNode(
Expand Down

0 comments on commit 5dbf07c

Please sign in to comment.