use of com.github.javaparser.ast.stmt.Statement in project javaparser by javaparser.
the class SourceFileInfoExtractor method solve.
private void solve(Node node) {
if (node instanceof ClassOrInterfaceDeclaration) {
solveTypeDecl((ClassOrInterfaceDeclaration) node);
} else if (node instanceof Expression) {
if ((requireParentNode(node) instanceof ImportDeclaration) || (requireParentNode(node) instanceof Expression) || (requireParentNode(node) instanceof MethodDeclaration) || (requireParentNode(node) instanceof PackageDeclaration)) {
// skip
} else if ((requireParentNode(node) instanceof Statement) || (requireParentNode(node) instanceof VariableDeclarator)) {
try {
ResolvedType ref = JavaParserFacade.get(typeSolver).getType(node);
out.println(" Line " + node.getRange().get().begin.line + ") " + node + " ==> " + ref.describe());
ok++;
} catch (UnsupportedOperationException upe) {
unsupported++;
err.println(upe.getMessage());
throw upe;
} catch (RuntimeException re) {
ko++;
err.println(re.getMessage());
throw re;
}
}
}
}
use of com.github.javaparser.ast.stmt.Statement in project javaparser by javaparser.
the class ManipulationSteps method thenTheBlockStmtContentIs.
@Then("Statement $position in BlockStmt toString is \"$expectedContent\"")
public void thenTheBlockStmtContentIs(int position, String expectedContent) {
Statement statementUnderTest = blockStmt.getStatement(position - 1);
assertThat(statementUnderTest.toString(), is(expectedContent));
}
use of com.github.javaparser.ast.stmt.Statement in project javaparser by javaparser.
the class ParsingSteps method thenLambdaInStatementInMethodInClassIsParentOfContainedBody.
@Then("lambda in statement $statementPosition in method $methodPosition in class $classPosition is parent of contained body")
public void thenLambdaInStatementInMethodInClassIsParentOfContainedBody(int statementPosition, int methodPosition, int classPosition) {
LambdaExpr lambdaExpr = getLambdaExprInStatementInMethodInClass(statementPosition, methodPosition, classPosition);
Statement body = lambdaExpr.getBody();
assertThat(body.getParentNode().get(), is(lambdaExpr));
}
use of com.github.javaparser.ast.stmt.Statement in project javaparser by javaparser.
the class ParsingSteps method thenLambdaInClassIsCalled.
@Then("lambda in statement $statementPosition in method $methodPosition in class $classPosition is called $expectedName")
public void thenLambdaInClassIsCalled(int statementPosition, int methodPosition, int classPosition, String expectedName) {
Statement statement = getStatementInMethodInClass(statementPosition, methodPosition, classPosition);
VariableDeclarationExpr expression = (VariableDeclarationExpr) ((ExpressionStmt) statement).getExpression();
VariableDeclarator variableDeclarator = expression.getVariable(0);
assertThat(variableDeclarator.getNameAsString(), is(expectedName));
}
use of com.github.javaparser.ast.stmt.Statement in project javaparser by javaparser.
the class ParsingSteps method thenMethodReferenceInStatementInMethodInClassIdentifierIsCompareByAge.
@Then("method reference in statement $statementPosition in method $methodPosition in class $classPosition identifier is $expectedName")
public void thenMethodReferenceInStatementInMethodInClassIdentifierIsCompareByAge(int statementPosition, int methodPosition, int classPosition, String expectedName) {
Statement statementUnderTest = getStatementInMethodInClass(statementPosition, methodPosition, classPosition);
assertEquals(1, statementUnderTest.findAll(MethodReferenceExpr.class).size());
MethodReferenceExpr methodReferenceUnderTest = statementUnderTest.findFirst(MethodReferenceExpr.class).get();
assertThat(methodReferenceUnderTest.getIdentifier(), is(expectedName));
}
Aggregations