codemining.java.codeutils.binding.AbstractJavaNameBindingsExtractor Java Examples

The following examples show how to use codemining.java.codeutils.binding.AbstractJavaNameBindingsExtractor. 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: JavaBindingsToJson.java    From api-mining with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Extract the bindings from the input folder to the output file, using the
 * bindingExtractor.
 *
 * @param inputFolder
 * @param outputFile
 * @param bindingExtractor
 * @throws IOException
 * @throws JsonIOException
 */
public static void extractBindings(final File inputFolder,
		final File outputFile,
		final AbstractJavaNameBindingsExtractor bindingExtractor)
		throws IOException, JsonIOException {
	final Collection<File> allFiles = FileUtils
			.listFiles(inputFolder, JavaTokenizer.javaCodeFileFilter,
					DirectoryFileFilter.DIRECTORY);
	final List<SerializableResolvedSourceCode> resolvedCode = allFiles
			.parallelStream()
			.map(f -> getResolvedCode(f, bindingExtractor))
			.filter(r -> r != null)
			.map(r -> SerializableResolvedSourceCode
					.fromResolvedSourceCode(r))
			.filter(s -> !s.boundVariables.isEmpty())
			.collect(Collectors.toList());

	final FileWriter writer = new FileWriter(outputFile);
	try {
		final Gson gson = new Gson();
		gson.toJson(resolvedCode, writer);
	} finally {
		writer.close();
	}
}
 
Example #2
Source File: JavaBindingsToJson.java    From api-mining with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param args
 * @throws IOException
 * @throws JsonIOException
 */
public static void main(final String[] args) throws JsonIOException,
		IOException {
	if (args.length != 3) {
		System.err
				.println("Usage <inputFolder> variables|methodinvocations|"
						+ "methodinvocations_typegram|methoddeclarations|methoddeclarations_nooverride"
						+ "methoddeclarations_typegram|types <outputFile>");
		System.exit(-1);
	}

	final File inputFolder = new File(args[0]);
	final File outputFile = new File(args[2]);
	final AbstractJavaNameBindingsExtractor bindingExtractor = getExtractorForName(
			args[1], inputFolder);

	extractBindings(inputFolder, outputFile, bindingExtractor);
}
 
Example #3
Source File: JavaBindingsToJson.java    From tassal with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Extract the bindings from the input folder to the output file, using the
 * bindingExtractor.
 *
 * @param inputFolder
 * @param outputFile
 * @param bindingExtractor
 * @throws IOException
 * @throws JsonIOException
 */
public static void extractBindings(final File inputFolder,
		final File outputFile,
		final AbstractJavaNameBindingsExtractor bindingExtractor)
		throws IOException, JsonIOException {
	final Collection<File> allFiles = FileUtils
			.listFiles(inputFolder, JavaTokenizer.javaCodeFileFilter,
					DirectoryFileFilter.DIRECTORY);
	final List<SerializableResolvedSourceCode> resolvedCode = allFiles
			.parallelStream()
			.map(f -> getResolvedCode(f, bindingExtractor))
			.filter(r -> r != null)
			.map(r -> SerializableResolvedSourceCode
					.fromResolvedSourceCode(r))
			.filter(s -> !s.boundVariables.isEmpty())
			.collect(Collectors.toList());

	final FileWriter writer = new FileWriter(outputFile);
	try {
		final Gson gson = new Gson();
		gson.toJson(resolvedCode, writer);
	} finally {
		writer.close();
	}
}
 
Example #4
Source File: JavaBindingsToJson.java    From tassal with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @param args
 * @throws IOException
 * @throws JsonIOException
 */
public static void main(final String[] args) throws JsonIOException,
		IOException {
	if (args.length != 3) {
		System.err
				.println("Usage <inputFolder> variables|methodinvocations|"
						+ "methodinvocations_typegram|methoddeclarations|methoddeclarations_nooverride"
						+ "methoddeclarations_typegram|types <outputFile>");
		System.exit(-1);
	}

	final File inputFolder = new File(args[0]);
	final File outputFile = new File(args[2]);
	final AbstractJavaNameBindingsExtractor bindingExtractor = getExtractorForName(
			args[1], inputFolder);

	extractBindings(inputFolder, outputFile, bindingExtractor);
}
 
Example #5
Source File: JavaBindingsToJson.java    From codemining-core with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Extract the bindings from the input folder to the output file, using the
 * bindingExtractor.
 *
 * @param inputFolder
 * @param outputFile
 * @param bindingExtractor
 * @throws IOException
 * @throws JsonIOException
 */
public static void extractBindings(final File inputFolder,
		final File outputFile,
		final AbstractJavaNameBindingsExtractor bindingExtractor)
		throws IOException, JsonIOException {
	final Collection<File> allFiles = FileUtils
			.listFiles(inputFolder, JavaTokenizer.javaCodeFileFilter,
					DirectoryFileFilter.DIRECTORY);
	final List<SerializableResolvedSourceCode> resolvedCode = allFiles
			.parallelStream()
			.map(f -> getResolvedCode(f, bindingExtractor))
			.filter(r -> r != null)
			.map(r -> SerializableResolvedSourceCode
					.fromResolvedSourceCode(r))
			.filter(s -> !s.boundVariables.isEmpty())
			.collect(Collectors.toList());

	final FileWriter writer = new FileWriter(outputFile);
	try {
		final Gson gson = new Gson();
		gson.toJson(resolvedCode, writer);
	} finally {
		writer.close();
	}
}
 
Example #6
Source File: JavaBindingsToJson.java    From codemining-core with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @param args
 * @throws IOException
 * @throws JsonIOException
 */
public static void main(final String[] args) throws JsonIOException,
		IOException {
	if (args.length != 3) {
		System.err
				.println("Usage <inputFolder> variables|methodinvocations|"
						+ "methodinvocations_typegram|methoddeclarations|methoddeclarations_nooverride"
						+ "methoddeclarations_typegram|types <outputFile>");
		System.exit(-1);
	}

	final File inputFolder = new File(args[0]);
	final File outputFile = new File(args[2]);
	final AbstractJavaNameBindingsExtractor bindingExtractor = getExtractorForName(
			args[1], inputFolder);

	extractBindings(inputFolder, outputFile, bindingExtractor);
}
 
Example #7
Source File: JavaBindingsToJson.java    From api-mining with GNU General Public License v3.0 5 votes vote down vote up
public static ResolvedSourceCode getResolvedCode(final File f,
		final AbstractJavaNameBindingsExtractor extractor) {
	try {
		return extractor.getResolvedSourceCode(f);
	} catch (final Throwable t) {
		LOGGER.warning("Error for file " + f + ": "
				+ ExceptionUtils.getFullStackTrace(t));
	}
	return null;
}
 
Example #8
Source File: JavaBindingsToJson.java    From tassal with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static ResolvedSourceCode getResolvedCode(final File f,
		final AbstractJavaNameBindingsExtractor extractor) {
	try {
		return extractor.getResolvedSourceCode(f);
	} catch (final Throwable t) {
		LOGGER.warning("Error for file " + f + ": "
				+ ExceptionUtils.getFullStackTrace(t));
	}
	return null;
}
 
Example #9
Source File: JavaBindingsToJson.java    From codemining-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static ResolvedSourceCode getResolvedCode(final File f,
		final AbstractJavaNameBindingsExtractor extractor) {
	try {
		return extractor.getResolvedSourceCode(f);
	} catch (final Throwable t) {
		LOGGER.warning("Error for file " + f + ": "
				+ ExceptionUtils.getFullStackTrace(t));
	}
	return null;
}