use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class JsonPrinterTest method testEscaping.
@Test
public void testEscaping() {
JsonPrinter jsonPrinter = new JsonPrinter(false);
CompilationUnit expression = parse("class X {//hi\"" + EOL + "int x;}");
String output = jsonPrinter.output(expression);
assertEquals("{\"types\":[{\"isInterface\":\"false\",\"name\":{\"identifier\":\"X\",\"comment\":{\"content\":\"hi\\\"\"}},\"members\":[{\"variables\":[{\"name\":{\"identifier\":\"x\"},\"type\":{\"type\":\"INT\"}}]}]}]}", output);
}
use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class JsonPrinterTest method issue1338.
@Test
public void issue1338() {
String code = "class Test {" + " public void method() {" + " String.format(\"I'm using %s\", \"JavaParser\");" + " }" + "}";
CompilationUnit unit = parse(code);
JsonPrinter printer = new JsonPrinter(true);
printer.output(unit);
}
use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class VisitorSteps method whenTheCompilationUnitIsVisitedByTheVistor.
@When("the CompilationUnit is visited by the to uppercase visitor")
public void whenTheCompilationUnitIsVisitedByTheVistor() {
CompilationUnit compilationUnit = (CompilationUnit) state.get("cu1");
toUpperCaseVariableNameVisitor.visit(compilationUnit, null);
state.put("cu1", compilationUnit);
}
use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class VisitorSteps method whenTheCompilationUnitIsVisitedByTheVariableNameCollectorVisitor.
@When("the CompilationUnit is visited by the variable name collector visitor")
public void whenTheCompilationUnitIsVisitedByTheVariableNameCollectorVisitor() {
CompilationUnit compilationUnit = (CompilationUnit) state.get("cu1");
collectedVariableName = new AtomicReference<>("");
collectVariableNameVisitor.visit(compilationUnit, collectedVariableName);
}
use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class VisitorSteps method whenTheCompilationUnitIsVisitedByTheVisitorThatReturnsAllVariableNames.
@When("the CompilationUnit is visited by the visitor that returns all variable names")
public void whenTheCompilationUnitIsVisitedByTheVisitorThatReturnsAllVariableNames() {
CompilationUnit compilationUnit = (CompilationUnit) state.get("cu1");
returnedVariableNames = allNameReturningVisitor.visit(compilationUnit, null);
}
Aggregations