From 5dbf07cc942b3060045f8d7a479301f57bd9f80a Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Tue, 9 Apr 2024 13:37:15 -0400 Subject: [PATCH] Code enhancements (#179) - Use method references. --- .../ibm/wala/cast/python/parser/PythonModuleParser.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/com.ibm.wala.cast.python.jython3/source/com/ibm/wala/cast/python/parser/PythonModuleParser.java b/com.ibm.wala.cast.python.jython3/source/com/ibm/wala/cast/python/parser/PythonModuleParser.java index e48388e1e..6c1d3bac1 100644 --- a/com.ibm.wala.cast.python.jython3/source/com/ibm/wala/cast/python/parser/PythonModuleParser.java +++ b/com.ibm.wala.cast.python.jython3/source/com/ibm/wala/cast/python/parser/PythonModuleParser.java @@ -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 { @@ -63,10 +65,7 @@ protected PythonParser.CAstVisitor makeVisitor( public CAstNode visitImportFrom(ImportFrom importFrom) throws Exception { Optional s = importFrom.getInternalModuleNames().stream() - .map( - n -> { - return n.getInternalId(); - }) + .map(Name::getInternalId) .reduce( (a, b) -> { return a + "/" + b; @@ -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(