package com.redhat.ceylon.eclipse.util;

import java.util.HashSet;
import java.util.Set;

import com.redhat.ceylon.compiler.typechecker.model.Declaration;
import com.redhat.ceylon.compiler.typechecker.tree.Tree;
import com.redhat.ceylon.compiler.typechecker.tree.Visitor;

public class FindRefinementsVisitor extends Visitor {
	
	private final Declaration declaration;
	private Set<Tree.Declaration> declarationNodes = new HashSet<Tree.Declaration>();
	
	public FindRefinementsVisitor(Declaration declaration) {
		this.declaration = declaration;
	}
	
	public Set<Tree.Declaration> getDeclarationNodes() {
		return declarationNodes;
	}
	
    protected boolean isRefinement(Declaration dec) {
        return dec!=null && dec.refines(declaration);
    }
    
	@Override
	public void visit(Tree.Declaration that) {
		if (isRefinement(that.getDeclarationModel())) {
			declarationNodes.add(that);
		}
		super.visit(that);
	}
		
}

@@ -148,16 +148,76 @@
 ration;%0A
+import com.redhat.ceylon.compiler.typechecker.model.Setter;%0A
 import c
@@ -796,16 +796,132 @@
 aration)
+ %7C%7C%0A                dec instanceof Setter && ((Setter)dec).getGetter()%0A                        .refines(declaration)
 ;%0A    %7D%0A

fix #135