feat: display all alternative Types
This commit is contained in:
parent
32a7a6e015
commit
43ca14194b
@ -8,6 +8,7 @@ import java.io.IOException;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,7 +75,14 @@ public class TypeFinder {
|
|||||||
for (var method : transferObj.getAst().getAllMethods()) {
|
for (var method : transferObj.getAst().getAllMethods()) {
|
||||||
if (method.name.equals(methodName)) {
|
if (method.name.equals(methodName)) {
|
||||||
if (method.getReturnType().toString().contains("TPH ")) {
|
if (method.getReturnType().toString().contains("TPH ")) {
|
||||||
return typeHashMap.get(method.getReturnType().toString()).getFirst();
|
StringBuilder possibleTypes = new StringBuilder();
|
||||||
|
|
||||||
|
for(var type : typeHashMap.get(method.getReturnType().toString())){
|
||||||
|
possibleTypes.append(" | ").append(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return possibleTypes.toString().substring(3);
|
||||||
}else{
|
}else{
|
||||||
return method.getReturnType().toString();
|
return method.getReturnType().toString();
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,12 @@ public class CompilerInterfaceTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testTypeFinder() throws IOException, ClassNotFoundException {
|
public void testTypeFinder() throws IOException, ClassNotFoundException {
|
||||||
TypeFinder typeFinder = new TypeFinder();
|
TypeFinder typeFinder = new TypeFinder();
|
||||||
var inferedMethods = typeFinder.infereMethodType("import java.lang.Integer;" +
|
var inferedMethods = typeFinder.infereMethodType("import java.lang.Integer; import java.lang.String;" +
|
||||||
"public class test{"+
|
"public class test{"+
|
||||||
"public main(test){"+
|
"public main(test){" +
|
||||||
|
"if(0>1){" +
|
||||||
|
"return \"w\";" +
|
||||||
|
"}"+
|
||||||
"Integer i = 0;"+
|
"Integer i = 0;"+
|
||||||
"return i;"+
|
"return i;"+
|
||||||
"}"+
|
"}"+
|
||||||
|
Loading…
Reference in New Issue
Block a user