Java Code Examples for org.eclipse.jdt.internal.core.util.Util#isJavaLikeFileName()

The following examples show how to use org.eclipse.jdt.internal.core.util.Util#isJavaLikeFileName() . 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: CodeFormatterApplication.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Recursively format the Java source code that is contained in the
 * directory rooted at dir.
 */
private void formatDirTree(File dir, CodeFormatter codeFormatter) {

	File[] files = dir.listFiles();
	if (files == null)
		return;

	for (int i = 0; i < files.length; i++) {
		File file = files[i];
		if (file.isDirectory()) {
			formatDirTree(file, codeFormatter);
		} else if (Util.isJavaLikeFileName(file.getPath())) {
			formatFile(file, codeFormatter);
		}
	}
}
 
Example 2
Source File: CodeFormatterApplication.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Runs the Java code formatter application
 */
public Object start(IApplicationContext context) throws Exception {
	File[] filesToFormat = processCommandLine((String[]) context.getArguments().get(IApplicationContext.APPLICATION_ARGS));

	if (filesToFormat == null) {
		return IApplication.EXIT_OK;
	}

	if (!this.quiet) {
		if (this.configName != null) {
			System.out.println(Messages.bind(Messages.CommandLineConfigFile, this.configName));
		}
		System.out.println(Messages.bind(Messages.CommandLineStart));
	}

	final CodeFormatter codeFormatter = ToolFactory.createCodeFormatter(this.options);
	// format the list of files and/or directories
	for (int i = 0, max = filesToFormat.length; i < max; i++) {
		final File file = filesToFormat[i];
		if (file.isDirectory()) {
			formatDirTree(file, codeFormatter);
		} else if (Util.isJavaLikeFileName(file.getPath())) {
			formatFile(file, codeFormatter);
		}
	}
	if (!this.quiet) {
		System.out.println(Messages.bind(Messages.CommandLineDone));
	}

	return IApplication.EXIT_OK;
}