package antipatternsrecovery.parsingElements;

import java.util.ArrayList;
import java.util.Collection;
import org.eclipse.jdt.core.dom.ASTVisitor;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.TypeDeclaration;

public class MethodVisitor extends ASTVisitor {
	
	private Collection<MethodDeclaration> methodNodes;
	private boolean firstTime;
	
	public MethodVisitor(Collection<MethodDeclaration> pMethodNodes) {
		methodNodes = pMethodNodes;
		firstTime = true;
	}
	
	public MethodVisitor() {
		methodNodes = new ArrayList<MethodDeclaration>();
	}
	
	public boolean visit(MethodDeclaration pMethodNode) { 
		methodNodes.add(pMethodNode);
		return true;
	}
	
	public boolean visit(TypeDeclaration pClassNode) {
		if (firstTime) {
			firstTime = false;
			return true;
		}
		return firstTime;
	}
	
}
