Java Code Examples for org.eclipse.wst.jsdt.core.dom.ASTNode#accept()

The following examples show how to use org.eclipse.wst.jsdt.core.dom.ASTNode#accept() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FunctionRetriever.java    From api-mining with GNU General Public License v3.0 5 votes vote down vote up
public static Map<String, FunctionDeclaration> getFunctionNodes(
		final String file) throws Exception {
	final JavascriptASTExtractor astExtractor = new JavascriptASTExtractor(
			false);
	final FunctionRetriever m = new FunctionRetriever();
	final ASTNode cu = astExtractor.getCompilationUnitAstNode(file);
	cu.accept(m);
	return m.functions;
}
 
Example 2
Source File: JavascriptApproximateVariableBindingExtractor.java    From api-mining with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Set<Set<ASTNode>> getNameBindings(final ASTNode node) {
	final VariableBindingFinder bindingFinder = new VariableBindingFinder();
	node.accept(bindingFinder);

	final Set<Set<ASTNode>> nameBindings = Sets.newHashSet();
	for (final Entry<Integer, List<ASTNode>> variableBindings : bindingFinder.variableBinding
			.entrySet()) {
		final Set<ASTNode> boundNodes = Sets.newIdentityHashSet();
		boundNodes.addAll(variableBindings.getValue());
		nameBindings.add(boundNodes);
	}
	return nameBindings;
}
 
Example 3
Source File: FunctionRetriever.java    From tassal with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static Map<String, FunctionDeclaration> getFunctionNodes(
		final String file) throws Exception {
	final JavascriptASTExtractor astExtractor = new JavascriptASTExtractor(
			false);
	final FunctionRetriever m = new FunctionRetriever();
	final ASTNode cu = astExtractor.getCompilationUnitAstNode(file);
	cu.accept(m);
	return m.functions;
}
 
Example 4
Source File: JavascriptApproximateVariableBindingExtractor.java    From tassal with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Set<Set<ASTNode>> getNameBindings(final ASTNode node) {
	final VariableBindingFinder bindingFinder = new VariableBindingFinder();
	node.accept(bindingFinder);

	final Set<Set<ASTNode>> nameBindings = Sets.newHashSet();
	for (final Entry<Integer, List<ASTNode>> variableBindings : bindingFinder.variableBinding
			.entrySet()) {
		final Set<ASTNode> boundNodes = Sets.newIdentityHashSet();
		boundNodes.addAll(variableBindings.getValue());
		nameBindings.add(boundNodes);
	}
	return nameBindings;
}
 
Example 5
Source File: FunctionRetriever.java    From codemining-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static Map<String, FunctionDeclaration> getFunctionNodes(
		final String file) throws Exception {
	final JavascriptASTExtractor astExtractor = new JavascriptASTExtractor(
			false);
	final FunctionRetriever m = new FunctionRetriever();
	final ASTNode cu = astExtractor.getCompilationUnitAstNode(file);
	cu.accept(m);
	return m.functions;
}
 
Example 6
Source File: JavascriptApproximateVariableBindingExtractor.java    From codemining-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Set<Set<ASTNode>> getNameBindings(final ASTNode node) {
	final VariableBindingFinder bindingFinder = new VariableBindingFinder();
	node.accept(bindingFinder);

	final Set<Set<ASTNode>> nameBindings = Sets.newHashSet();
	for (final Entry<Integer, List<ASTNode>> variableBindings : bindingFinder.variableBinding
			.entrySet()) {
		final Set<ASTNode> boundNodes = Sets.newIdentityHashSet();
		boundNodes.addAll(variableBindings.getValue());
		nameBindings.add(boundNodes);
	}
	return nameBindings;
}
 
Example 7
Source File: JavascriptASTExtractor.java    From api-mining with GNU General Public License v3.0 4 votes vote down vote up
private final FunctionDeclaration getFirstFunctionDeclaration(
		final ASTNode node) {
	final TopFunctionRetriever visitor = new TopFunctionRetriever();
	node.accept(visitor);
	return visitor.topDcl;
}
 
Example 8
Source File: JavascriptCyclomaticCalculator.java    From api-mining with GNU General Public License v3.0 4 votes vote down vote up
@Override
public double getMetricForASTNode(final ASTNode node) {
	final JunctionVisitor visitor = new JunctionVisitor();
	node.accept(visitor);
	return visitor.complexity;
}
 
Example 9
Source File: JavascriptASTExtractor.java    From tassal with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private final FunctionDeclaration getFirstFunctionDeclaration(
		final ASTNode node) {
	final TopFunctionRetriever visitor = new TopFunctionRetriever();
	node.accept(visitor);
	return visitor.topDcl;
}
 
Example 10
Source File: JavascriptCyclomaticCalculator.java    From tassal with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public double getMetricForASTNode(final ASTNode node) {
	final JunctionVisitor visitor = new JunctionVisitor();
	node.accept(visitor);
	return visitor.complexity;
}
 
Example 11
Source File: JavascriptASTExtractor.java    From codemining-core with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private final FunctionDeclaration getFirstFunctionDeclaration(
		final ASTNode node) {
	final TopFunctionRetriever visitor = new TopFunctionRetriever();
	node.accept(visitor);
	return visitor.topDcl;
}
 
Example 12
Source File: JavascriptCyclomaticCalculator.java    From codemining-core with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public double getMetricForASTNode(final ASTNode node) {
	final JunctionVisitor visitor = new JunctionVisitor();
	node.accept(visitor);
	return visitor.complexity;
}
 
Example 13
Source File: NodeFinder.java    From api-mining with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Instantiate a new node finder using the given root node, the given start
 * and the given length.
 * 
 * @param root
 *            the given root node
 * @param start
 *            the given start
 * @param length
 *            the given length
 */
public NodeFinder(final ASTNode root, final int start, final int length) {
	final NodeFinderVisitor nodeFinderVisitor = new NodeFinderVisitor(
			start, length);
	root.accept(nodeFinderVisitor);
	this.fCoveredNode = nodeFinderVisitor.getCoveredNode();
	this.fCoveringNode = nodeFinderVisitor.getCoveringNode();
}
 
Example 14
Source File: NodeFinder.java    From tassal with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * Instantiate a new node finder using the given root node, the given start
 * and the given length.
 * 
 * @param root
 *            the given root node
 * @param start
 *            the given start
 * @param length
 *            the given length
 */
public NodeFinder(final ASTNode root, final int start, final int length) {
	final NodeFinderVisitor nodeFinderVisitor = new NodeFinderVisitor(
			start, length);
	root.accept(nodeFinderVisitor);
	this.fCoveredNode = nodeFinderVisitor.getCoveredNode();
	this.fCoveringNode = nodeFinderVisitor.getCoveringNode();
}
 
Example 15
Source File: NodeFinder.java    From codemining-core with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * Instantiate a new node finder using the given root node, the given start
 * and the given length.
 * 
 * @param root
 *            the given root node
 * @param start
 *            the given start
 * @param length
 *            the given length
 */
public NodeFinder(final ASTNode root, final int start, final int length) {
	final NodeFinderVisitor nodeFinderVisitor = new NodeFinderVisitor(
			start, length);
	root.accept(nodeFinderVisitor);
	this.fCoveredNode = nodeFinderVisitor.getCoveredNode();
	this.fCoveringNode = nodeFinderVisitor.getCoveringNode();
}