*/
private List<ASTEntry> getLocalOccurrences(String occurencesFor, SimpleNode simpleNode, RefactoringStatus status) {
List<ASTEntry> ret = new ArrayList<ASTEntry>();
//get the entry for the function itself
ASTEntry functionDefEntry = getOriginalFunctionInAst(simpleNode);
if (functionDefEntry == null) {
status.addFatalError("Unable to find the original definition for the function definition.");
return ret;
}
if (functionDefEntry.parent != null) {
//it has some parent
final SimpleNode parentNode = functionDefEntry.parent.node;
if (parentNode instanceof ClassDef) {
//ok, we're in a class, the first thing is to add the reference to the function just gotten
ret.add(new ASTEntry(functionDefEntry, ((FunctionDef) functionDefEntry.node).name));
//get the entry for the self.xxx that access that attribute in the class
SequencialASTIteratorVisitor classVisitor = SequencialASTIteratorVisitor.create(parentNode);
Iterator<ASTEntry> it = classVisitor.getIterator(Attribute.class);
while (it.hasNext()) {
ASTEntry entry = it.next();
List<SimpleNode> parts = NodeUtils.getAttributeParts((Attribute) entry.node);
if (!(parts.get(1) instanceof Attribute)) {
final String rep0 = NodeUtils.getRepresentationString(parts.get(0));
final String rep1 = NodeUtils.getRepresentationString(parts.get(1));
if (rep0 != null && rep1 != null && rep0.equals("self") && rep1.equals(occurencesFor)) {