blob: 5db7cdaba1481e04d3d0c5ea05bcb5c20d8b99d4 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.astview;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.CompilationUnit;
/**
*
*/
public class TreeInfoCollector {
public static class NodeCounter extends GenericVisitor {
public int numberOfNodes= 0;
protected boolean visitNode(ASTNode node) {
numberOfNodes++;
return true;
}
}
private final CompilationUnit fRoot;
public TreeInfoCollector(CompilationUnit root) {
fRoot= root;
}
public int getSize() {
return fRoot.subtreeBytes();
}
public int getNumberOfNodes() {
NodeCounter counter= new NodeCounter();
fRoot.accept(counter);
return counter.numberOfNodes;
}
}