}
@SuppressWarnings("unchecked")
@Test public void
finds_covered_node() throws IOException, CoreException {
RunScript runScript = new RunScript(getWindow());
String methodCallText = "person.setName(\"Bob\")";
IType personType = getJavaProject().findType("com.example.Person");
String personSource = personType.getCompilationUnit().getSource();
int offsetOfCall = personSource.indexOf(methodCallText);
runScript.withContents(
"var person = Find.typeByName('Person');\n" +
"var ast = AST.parseCompilationUnit(person.getCompilationUnit());\n" +
"var node = AST.findCoveredNode(ast, " + offsetOfCall + ", " + methodCallText.length() + ");\n"
, null, "inline script");
MethodInvocation node = runScript.getProperty(MethodInvocation.class, "node");
assertThat(node, is(notNullValue()));
assertThat(node.getExpression().toString(), is("person"));
assertThat(node.getName().toString(), is("setName"));
assertThat((List<ASTNode>) node.arguments(),