< prev index next >
src/jdk.jshell/share/classes/jdk/jshell/TreeDissector.java
Print this page
@@ -39,22 +39,23 @@
import com.sun.source.util.Trees;
import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.code.Type.MethodType;
import com.sun.tools.javac.code.Types;
import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
-import com.sun.tools.javac.util.JavacMessages;
import com.sun.tools.javac.util.Name;
import static jdk.jshell.Util.isDoIt;
import jdk.jshell.Wrap.Range;
+
import java.util.List;
-import java.util.Locale;
-import java.util.function.BinaryOperator;
+
import java.util.function.Predicate;
import java.util.stream.Stream;
import javax.lang.model.type.TypeMirror;
import jdk.jshell.Util.Pair;
+import jdk.jshell.TaskFactory.AnalyzeTask;
+
/**
* Utilities for analyzing compiler API parse trees.
* @author Robert Field
*/
@@ -207,23 +208,21 @@
}
return null;
}
- ExpressionInfo typeOfReturnStatement(JavacMessages messages, BinaryOperator<String> fullClassNameAndPackageToClass) {
+ ExpressionInfo typeOfReturnStatement(AnalyzeTask at, JShell state) {
ExpressionInfo ei = new ExpressionInfo();
Tree unitTree = firstStatement();
if (unitTree instanceof ReturnTree) {
ei.tree = ((ReturnTree) unitTree).getExpression();
if (ei.tree != null) {
TreePath viPath = trees().getPath(targetCompilationUnit, ei.tree);
if (viPath != null) {
TypeMirror tm = trees().getTypeMirror(viPath);
if (tm != null) {
- Type type = (Type)tm;
- TypePrinter tp = new TypePrinter(messages, fullClassNameAndPackageToClass, type);
- ei.typeName = tp.visit(type, Locale.getDefault());
+ ei.typeName = TypePrinter.printType(at, state, tm);
switch (tm.getKind()) {
case VOID:
case NONE:
case ERROR:
case OTHER:
< prev index next >