package com.redhat.ceylon.compiler.typechecker.ui;

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

public class FindDeclarationVisitor extends Visitor {
	
	private final Declaration declaration;
	private Tree.Declaration declarationNode;
	
	public FindDeclarationVisitor(Declaration declaration) {
		this.declaration = declaration;
	}
	
	public Tree.Declaration getDeclarationNode() {
		return declarationNode;
	}
	
	@Override
	public void visit(Tree.Declaration that) {
		if (that.getDeclarationModel()==declaration) {
			declarationNode = that;
		}
		super.visit(that);
	}
	
	public void visitAny(Node node) {
		if (declarationNode==null) {
			super.visitAny(node);
		}
	}
	
}

@@ -602,16 +602,109 @@
 e;%0A%09%7D%0A%09%0A
+    protected boolean equals(Declaration x, Declaration y) %7B%0A        return x==y;%0A    %7D%0A    %0A
 %09@Overri
@@ -755,16 +755,23 @@
  %7B%0A%09%09if 
+(equals
 (that.ge
@@ -789,18 +789,17 @@
 nModel()
-==
+,
 declarat
@@ -798,24 +798,25 @@
 declaration)
+)
  %7B%0A%09%09%09declar

abstract def of equals