MethodScope extends AbstractJavaScope { public String getName() { if (node instanceof ASTConstructorDeclaration) { return this.getEnclosingScope(ClassScope.class).getClassName(); } return node.getChild(1).getImage(); } MethodScope(Node node); Map<VariableNameDeclaration, List<NameOccurrence>> getVariableDeclarations(); @Override Set<NameDeclaration> addNameOccurrence(NameOccurrence occurrence); @Override void addDeclaration(NameDeclaration variableDecl); @Override Set<NameDeclaration> findVariableHere(JavaNameOccurrence occurrence); String getName(); @Override String toString();  }
@Test public void testMethodName() { ASTCompilationUnit acu = parseCode(TEST1); ASTMethodDeclaration meth = acu.findDescendantsOfType(ASTMethodDeclaration.class).get(0); MethodScope ms = (MethodScope) meth.getScope(); assertEquals(ms.getName(), "foo"); }