use of com.github.javaparser.ast.stmt.ReturnStmt in project javaparser by javaparser.
the class TransformationsTest method exampleParam5.
@Test
public void exampleParam5() throws IOException {
considerExample("Example_param3_original");
MethodDeclaration md = (MethodDeclaration) cu.getClassByName("A").get().getMember(0).asMethodDeclaration();
md.setType(PrimitiveType.intType());
assertTransformed("Example_param5b", cu);
md.getBody().get().getStatements().add(new ReturnStmt(new NameExpr("p1")));
assertTransformed("Example_param5", cu);
}
use of com.github.javaparser.ast.stmt.ReturnStmt in project javaparser by javaparser.
the class Issue200 method issue200.
@Test
public void issue200() {
CompilationUnit cu = parseSample("Issue200");
ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "JavaTest");
MethodDeclaration methodDeclaration = Navigator.demandMethod(clazz, "foo");
TypeSolver typeSolver = new ReflectionTypeSolver();
JavaParserFacade javaParserFacade = JavaParserFacade.get(typeSolver);
List<ReturnStmt> nodesByType = methodDeclaration.findAll(ReturnStmt.class);
assertEquals("java.util.stream.Stream<JavaTest.Solved>", javaParserFacade.getType((nodesByType.get(0)).getExpression().get()).describe());
}
use of com.github.javaparser.ast.stmt.ReturnStmt in project javaparser by javaparser.
the class TokenKindGenerator method generateValueOfEntry.
private void generateValueOfEntry(SwitchStmt valueOfSwitch, String name, IntegerLiteralExpr kind) {
final SwitchEntryStmt entry = new SwitchEntryStmt(kind, new NodeList<>(new ReturnStmt(name)));
valueOfSwitch.getEntries().addFirst(entry);
}
use of com.github.javaparser.ast.stmt.ReturnStmt in project javaparser by javaparser.
the class GenericsResolutionTest method typeParamOnReturnType.
@Test
public void typeParamOnReturnType() {
CompilationUnit cu = parseSample("TypeParamOnReturnType");
ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "TypeParamOnReturnType");
MethodDeclaration method = Navigator.demandMethod(clazz, "nodeEquals");
ReturnStmt returnStmt = Navigator.findReturnStmt(method);
ResolvedType type = JavaParserFacade.get(new ReflectionTypeSolver()).getType(returnStmt.getExpression().get());
assertEquals(false, type.isTypeVariable());
assertEquals("boolean", type.describe());
}
use of com.github.javaparser.ast.stmt.ReturnStmt in project javaparser by javaparser.
the class GenericsResolutionTest method genericCollectionWithWildcards.
@Test
public void genericCollectionWithWildcards() {
CompilationUnit cu = parseSample("GenericCollection");
ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "Foo");
MethodDeclaration method = Navigator.demandMethod(clazz, "bar");
ReturnStmt returnStmt = Navigator.findReturnStmt(method);
TypeSolver typeSolver = new ReflectionTypeSolver();
Expression returnStmtExpr = returnStmt.getExpression().get();
JavaParserFacade javaParserFacade = JavaParserFacade.get(typeSolver);
ResolvedType type = javaParserFacade.getType(returnStmtExpr);
assertEquals(false, type.isTypeVariable());
assertEquals("boolean", type.describe());
}
Aggregations