use of com.github.javaparser.ast.expr.Expression in project javaparser by javaparser.
the class XmlPrinterTest method testList.
@Test
public void testList() {
Expression expression = JavaParser.parseExpression("a(1,2)");
XmlPrinter xmlOutput = new XmlPrinter(true);
String output = xmlOutput.output(expression);
assertEquals("<root type='MethodCallExpr'><name type='SimpleName' identifier='a'></name><arguments><argument type='IntegerLiteralExpr' value='1'></argument><argument type='IntegerLiteralExpr' value='2'></argument></arguments></root>", output);
}
use of com.github.javaparser.ast.expr.Expression in project javaparser by javaparser.
the class YamlPrinterTest method testWithType.
@Test
public void testWithType() {
String expectedOutput = "---" + System.lineSeparator();
expectedOutput += "root(Type=MethodCallExpr): " + System.lineSeparator();
expectedOutput += " name(Type=SimpleName): " + System.lineSeparator();
expectedOutput += " identifier: \"x\"" + System.lineSeparator();
expectedOutput += " arguments: " + System.lineSeparator();
expectedOutput += " - argument(Type=IntegerLiteralExpr): " + System.lineSeparator();
expectedOutput += " value: \"1\"" + System.lineSeparator();
expectedOutput += " - argument(Type=IntegerLiteralExpr): " + System.lineSeparator();
expectedOutput += " value: \"1\"" + System.lineSeparator();
expectedOutput += "...";
YamlPrinter yamlPrinter = new YamlPrinter(true);
Expression expression = JavaParser.parseExpression("x(1,1)");
String output = yamlPrinter.output(expression);
assertEquals(expectedOutput, output);
}
use of com.github.javaparser.ast.expr.Expression in project javaparser by javaparser.
the class YamlPrinterTest method testWithColonFollowedByLineSeparatorInValue.
@Test
public void testWithColonFollowedByLineSeparatorInValue() {
String expectedOutput = "---" + System.lineSeparator();
expectedOutput += "root(Type=StringLiteralExpr): " + System.lineSeparator();
expectedOutput += " value: \"a\\\\:\\\\nb\"" + System.lineSeparator();
expectedOutput += "...";
YamlPrinter yamlPrinter = new YamlPrinter(true);
Expression expression = JavaParser.parseExpression("\"a\\\\:\\\\nb\"");
String output = yamlPrinter.output(expression);
assertEquals(expectedOutput, output);
}
use of com.github.javaparser.ast.expr.Expression in project javaparser by javaparser.
the class YamlPrinterTest method testWithoutType.
@Test
public void testWithoutType() {
String expectedOutput = "---" + System.lineSeparator();
expectedOutput += "root: " + System.lineSeparator();
expectedOutput += " operator: \"PLUS\"" + System.lineSeparator();
expectedOutput += " left: " + System.lineSeparator();
expectedOutput += " value: \"1\"" + System.lineSeparator();
expectedOutput += " right: " + System.lineSeparator();
expectedOutput += " value: \"1\"" + System.lineSeparator();
expectedOutput += "...";
YamlPrinter yamlPrinter = new YamlPrinter(false);
Expression expression = JavaParser.parseExpression("1+1");
String output = yamlPrinter.output(expression);
assertEquals(expectedOutput, output);
}
use of com.github.javaparser.ast.expr.Expression in project javaparser by javaparser.
the class Issue144 method issue144.
@Test(expected = UnsolvedSymbolException.class)
public void issue144() {
CompilationUnit cu = parseSampleWithStandardExtension("issue144/HelloWorld");
ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "HelloWorld");
ExpressionStmt expressionStmt = (ExpressionStmt) clazz.getMethodsByName("main").get(0).getBody().get().getStatement(0);
MethodCallExpr methodCallExpr = (MethodCallExpr) expressionStmt.getExpression();
Expression firstParameter = methodCallExpr.getArgument(0);
JavaParserFacade javaParserFacade = JavaParserFacade.get(typeSolver);
javaParserFacade.solve(firstParameter).isSolved();
}
Aggregations