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

The following examples show how to use org.eclipse.wst.jsdt.core.dom.JavaScriptUnit#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: JavascriptFunctionCounter.java    From api-mining with GNU General Public License v3.0 6 votes vote down vote up
public static void countFunctions(final File projectDir) throws IOException {

		System.out.println("\n===== Project " + projectDir);
		final MethodClassCountVisitor mccv = new MethodClassCountVisitor();
		final JavascriptASTExtractor astExtractor = new JavascriptASTExtractor(
				false);

		final List<File> files = (List<File>) FileUtils.listFiles(projectDir,
				new String[] { "js" }, true);

		int count = 0;
		for (final File file : files) {

			final JavaScriptUnit cu = astExtractor.getAST(file);
			cu.accept(mccv);

			if (count % 1000 == 0)
				System.out.println("At file " + count + " of " + files.size());
			count++;
		}

		System.out.println("Project " + projectDir);
		System.out.println("No. *.js files " + files.size());
		System.out.println("No. Functions: " + mccv.noFunctions);
	}
 
Example 2
Source File: JavascriptFunctionCounter.java    From tassal with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static void countFunctions(final File projectDir) throws IOException {

		System.out.println("\n===== Project " + projectDir);
		final MethodClassCountVisitor mccv = new MethodClassCountVisitor();
		final JavascriptASTExtractor astExtractor = new JavascriptASTExtractor(
				false);

		final List<File> files = (List<File>) FileUtils.listFiles(projectDir,
				new String[] { "js" }, true);

		int count = 0;
		for (final File file : files) {

			final JavaScriptUnit cu = astExtractor.getAST(file);
			cu.accept(mccv);

			if (count % 1000 == 0)
				System.out.println("At file " + count + " of " + files.size());
			count++;
		}

		System.out.println("Project " + projectDir);
		System.out.println("No. *.js files " + files.size());
		System.out.println("No. Functions: " + mccv.noFunctions);
	}
 
Example 3
Source File: JavascriptFunctionCounter.java    From codemining-core with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static void countFunctions(final File projectDir) throws IOException {

		System.out.println("\n===== Project " + projectDir);
		final MethodClassCountVisitor mccv = new MethodClassCountVisitor();
		final JavascriptASTExtractor astExtractor = new JavascriptASTExtractor(
				false);

		final List<File> files = (List<File>) FileUtils.listFiles(projectDir,
				new String[] { "js" }, true);

		int count = 0;
		for (final File file : files) {

			final JavaScriptUnit cu = astExtractor.getAST(file);
			cu.accept(mccv);

			if (count % 1000 == 0)
				System.out.println("At file " + count + " of " + files.size());
			count++;
		}

		System.out.println("Project " + projectDir);
		System.out.println("No. *.js files " + files.size());
		System.out.println("No. Functions: " + mccv.noFunctions);
	}
 
Example 4
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 File file) throws IOException {
	final JavascriptASTExtractor astExtractor = new JavascriptASTExtractor(
			false);
	final FunctionRetriever m = new FunctionRetriever();
	final JavaScriptUnit cu = astExtractor.getAST(file);
	cu.accept(m);
	return m.functions;
}
 
Example 5
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 File file) throws IOException {
	final JavascriptASTExtractor astExtractor = new JavascriptASTExtractor(
			false);
	final FunctionRetriever m = new FunctionRetriever();
	final JavaScriptUnit cu = astExtractor.getAST(file);
	cu.accept(m);
	return m.functions;
}
 
Example 6
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 File file) throws IOException {
	final JavascriptASTExtractor astExtractor = new JavascriptASTExtractor(
			false);
	final FunctionRetriever m = new FunctionRetriever();
	final JavaScriptUnit cu = astExtractor.getAST(file);
	cu.accept(m);
	return m.functions;
}