Java Code Examples for codemining.js.codeutils.JavascriptASTExtractor

The following examples show how to use codemining.js.codeutils.JavascriptASTExtractor. These examples are extracted from open source projects. 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
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
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
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
@Override
public List<TokenNameBinding> getNameBindings(final String code) {
	final JavascriptASTExtractor ex = createExtractor();
	try {
		return getNameBindings(ex.getCompilationUnitAstNode(code), code);
	} catch (final Exception e) {
		throw new IllegalArgumentException(e);
	}
}
 
Example 5
@Override
public ResolvedSourceCode getResolvedSourceCode(final File f)
		throws IOException {
	final JavascriptASTExtractor ex = createExtractor();
	return getResolvedSourceCode(FileUtils.readFileToString(f),
			getNameBindings(ex.getAST(f)));
}
 
Example 6
@Override
public ResolvedSourceCode getResolvedSourceCode(final String code) {
	final JavascriptASTExtractor ex = createExtractor();
	try {
		return getResolvedSourceCode(code,
				getNameBindings(ex.getCompilationUnitAstNode(code)));
	} catch (final Exception e) {
		throw new IllegalArgumentException(e);
	}
}
 
Example 7
@Override
public List<TokenNameBinding> getNameBindings(final String code) {
	final JavascriptASTExtractor ex = createExtractor();
	try {
		return getNameBindings(ex.getCompilationUnitAstNode(code), code);
	} catch (final Exception e) {
		throw new IllegalArgumentException(e);
	}
}
 
Example 8
@Override
public ResolvedSourceCode getResolvedSourceCode(final File f)
		throws IOException {
	final JavascriptASTExtractor ex = createExtractor();
	return getResolvedSourceCode(FileUtils.readFileToString(f),
			getNameBindings(ex.getAST(f)));
}
 
Example 9
@Override
public ResolvedSourceCode getResolvedSourceCode(final String code) {
	final JavascriptASTExtractor ex = createExtractor();
	try {
		return getResolvedSourceCode(code,
				getNameBindings(ex.getCompilationUnitAstNode(code)));
	} catch (final Exception e) {
		throw new IllegalArgumentException(e);
	}
}
 
Example 10
@Override
public List<TokenNameBinding> getNameBindings(final String code) {
	final JavascriptASTExtractor ex = createExtractor();
	try {
		return getNameBindings(ex.getCompilationUnitAstNode(code), code);
	} catch (final Exception e) {
		throw new IllegalArgumentException(e);
	}
}
 
Example 11
@Override
public ResolvedSourceCode getResolvedSourceCode(final File f)
		throws IOException {
	final JavascriptASTExtractor ex = createExtractor();
	return getResolvedSourceCode(FileUtils.readFileToString(f),
			getNameBindings(ex.getAST(f)));
}
 
Example 12
@Override
public ResolvedSourceCode getResolvedSourceCode(final String code) {
	final JavascriptASTExtractor ex = createExtractor();
	try {
		return getResolvedSourceCode(code,
				getNameBindings(ex.getCompilationUnitAstNode(code)));
	} catch (final Exception e) {
		throw new IllegalArgumentException(e);
	}
}
 
Example 13
@Override
protected JavascriptASTExtractor createExtractor() {
	return new JavascriptASTExtractor(true);
}
 
Example 14
protected JavascriptASTExtractor createExtractor() {
	return new JavascriptASTExtractor(false);
}
 
Example 15
@Override
public List<TokenNameBinding> getNameBindings(final File f)
		throws IOException {
	final JavascriptASTExtractor ex = createExtractor();
	return getNameBindings(ex.getAST(f), FileUtils.readFileToString(f));
}
 
Example 16
public int getComplexity(final File file) throws IOException {
	final JavascriptASTExtractor ast = new JavascriptASTExtractor(false);
	final JunctionVisitor visitor = new JunctionVisitor();
	ast.getAST(file).accept(visitor);
	return visitor.complexity;
}
 
Example 17
@Override
protected JavascriptASTExtractor createExtractor() {
	return new JavascriptASTExtractor(true);
}
 
Example 18
protected JavascriptASTExtractor createExtractor() {
	return new JavascriptASTExtractor(false);
}
 
Example 19
@Override
public List<TokenNameBinding> getNameBindings(final File f)
		throws IOException {
	final JavascriptASTExtractor ex = createExtractor();
	return getNameBindings(ex.getAST(f), FileUtils.readFileToString(f));
}
 
Example 20
public int getComplexity(final File file) throws IOException {
	final JavascriptASTExtractor ast = new JavascriptASTExtractor(false);
	final JunctionVisitor visitor = new JunctionVisitor();
	ast.getAST(file).accept(visitor);
	return visitor.complexity;
}
 
Example 21
@Override
protected JavascriptASTExtractor createExtractor() {
	return new JavascriptASTExtractor(true);
}
 
Example 22
protected JavascriptASTExtractor createExtractor() {
	return new JavascriptASTExtractor(false);
}
 
Example 23
@Override
public List<TokenNameBinding> getNameBindings(final File f)
		throws IOException {
	final JavascriptASTExtractor ex = createExtractor();
	return getNameBindings(ex.getAST(f), FileUtils.readFileToString(f));
}
 
Example 24
public int getComplexity(final File file) throws IOException {
	final JavascriptASTExtractor ast = new JavascriptASTExtractor(false);
	final JunctionVisitor visitor = new JunctionVisitor();
	ast.getAST(file).accept(visitor);
	return visitor.complexity;
}