org.eclipse.jdt.internal.compiler.batch.Main Java Examples

The following examples show how to use org.eclipse.jdt.internal.compiler.batch.Main. 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: Compiler.java    From APDE with GNU General Public License v2.0 6 votes vote down vote up
@Override
public int logProblems(CategorizedProblem[] problems, char[] unitSource, Main currentMain) {
	int localErrorCount = 0;
	
	for (CategorizedProblem problem : problems) {
		if (problem != null) {
			handleProblem(problem);
			
			// These counters are necessary for ECJ to function properly
			if (problem.isError()) {
				localErrorCount++;
				currentMain.globalErrorsCount++;
			} else if (problem.getID() == IProblem.Task) {
				currentMain.globalTasksCount++;
			} else {
				currentMain.globalWarningsCount++;
			}
		}
	}
	
	return localErrorCount;
}
 
Example #2
Source File: Compiler.java    From APDE with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void loggingExtraProblems(Main currentMain) {
	// Unknown whether or not this is actually necessary
	ArrayList<CategorizedProblem> problems = compiler.getExtraProblems();
	if (problems != null) {
		for (CategorizedProblem problem : problems) {
			handleProblem(problem);
			
			// These counters are necessary for ECJ to function properly
			if (problem.isError()) {
				currentMain.globalErrorsCount++;
			}  else {
				currentMain.globalWarningsCount++;
			}
		}
	}
}
 
Example #3
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void addFilesFrom(File javaHome, String propertyName, String defaultPath, ArrayList<File> files) {
	String extdirsStr = System.getProperty(propertyName);
	File[] directoriesToCheck = null;
	if (extdirsStr == null) {
		if (javaHome != null) {
			directoriesToCheck = new File[] { new File(javaHome, defaultPath) };
		}
	} else {
		StringTokenizer tokenizer = new StringTokenizer(extdirsStr, File.pathSeparator);
		ArrayList<String> paths = new ArrayList<String>();
		while (tokenizer.hasMoreTokens()) {
			paths.add(tokenizer.nextToken());
		}
		if (paths.size() != 0) {
			directoriesToCheck = new File[paths.size()];
			for (int i = 0; i < directoriesToCheck.length; i++)  {
				directoriesToCheck[i] = new File(paths.get(i));
			}
		}
	}
	if (directoriesToCheck != null) {
		addFiles(Main.getLibrariesFiles(directoriesToCheck), files);
	}
	
}
 
Example #4
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void addFilesFrom(File javaHome, String propertyName, String defaultPath, ArrayList<File> files) {
	String extdirsStr = System.getProperty(propertyName);
	File[] directoriesToCheck = null;
	if (extdirsStr == null) {
		if (javaHome != null) {
			directoriesToCheck = new File[] { new File(javaHome, defaultPath) };
		}
	} else {
		StringTokenizer tokenizer = new StringTokenizer(extdirsStr, File.pathSeparator);
		ArrayList<String> paths = new ArrayList<String>();
		while (tokenizer.hasMoreTokens()) {
			paths.add(tokenizer.nextToken());
		}
		if (paths.size() != 0) {
			directoriesToCheck = new File[paths.size()];
			for (int i = 0; i < directoriesToCheck.length; i++)  {
				directoriesToCheck[i] = new File(paths.get(i));
			}
		}
	}
	if (directoriesToCheck != null) {
		addFiles(Main.getLibrariesFiles(directoriesToCheck), files);
	}
	
}
 
Example #5
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private Iterable<? extends File> getPathsFrom(String path) {
	ArrayList<FileSystem.Classpath> paths = new ArrayList<FileSystem.Classpath>();
	ArrayList<File> files = new ArrayList<File>();
	try {
		this.processPathEntries(Main.DEFAULT_SIZE_CLASSPATH, paths, path, this.charset.name(), false, false);
	} catch (IllegalArgumentException e) {
		return null;
	}
	for (FileSystem.Classpath classpath : paths) {
		files.add(new File(classpath.getPath()));
	}
	return files;
}
 
Example #6
Source File: Compiler.java    From APDE with GNU General Public License v2.0 5 votes vote down vote up
protected ArrayList<CategorizedProblem> getExtraProblems() {
	// This field might not actually be used, but I don't know for sure
	try {
		Field field = Main.class.getField("extraProblems");
		field.setAccessible(true);
		return (ArrayList<CategorizedProblem>) field.get(this);
	} catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}
 
Example #7
Source File: Compiler.java    From APDE with GNU General Public License v2.0 5 votes vote down vote up
protected void setLogger(Logger logger) {
	// Reflection might not be necessary here
	try {
		Field field = Main.class.getField("logger");
		field.setAccessible(true);
		field.set(this, logger);
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example #8
Source File: ASTParser.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private List getClasspath() throws IllegalStateException {
	Main main = new Main(new PrintWriter(System.out), new PrintWriter(System.err), false/*systemExit*/, null/*options*/, null/*progress*/);
	ArrayList allClasspaths = new ArrayList();
	try {
		if ((this.bits & CompilationUnitResolver.INCLUDE_RUNNING_VM_BOOTCLASSPATH) != 0) {
			org.eclipse.jdt.internal.compiler.util.Util.collectRunningVMBootclasspath(allClasspaths);
		}
		if (this.sourcepaths != null) {
			for (int i = 0, max = this.sourcepaths.length; i < max; i++) {
				String encoding = this.sourcepathsEncodings == null ? null : this.sourcepathsEncodings[i];
				main.processPathEntries(
						Main.DEFAULT_SIZE_CLASSPATH,
						allClasspaths, this.sourcepaths[i], encoding, true, false);
			}
		}
		if (this.classpaths != null) {
			for (int i = 0, max = this.classpaths.length; i < max; i++) {
				main.processPathEntries(
						Main.DEFAULT_SIZE_CLASSPATH,
						allClasspaths, this.classpaths[i], null, false, false);
			}
		}
		ArrayList pendingErrors = main.pendingErrors;
		if (pendingErrors != null && pendingErrors.size() != 0) {
			throw new IllegalStateException("invalid environment settings"); //$NON-NLS-1$
		}
	} catch (IllegalArgumentException e) {
		throw new IllegalStateException("invalid environment settings"); //$NON-NLS-1$
	}
	return allClasspaths;
}
 
Example #9
Source File: EclipseCompiler.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public int run(InputStream in, OutputStream out, OutputStream err, String... arguments) {
	boolean succeed = new Main(
			new PrintWriter(new OutputStreamWriter(out != null ? out : System.out)),
			new PrintWriter(new OutputStreamWriter(err != null ? err : System.err)),
			true/* systemExit */,
			null/* options */,
			null/* progress */).compile(arguments);
	return succeed ? 0 : -1;
}
 
Example #10
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private String bind(String id, String[] arguments) {
	if (id == null)
		return "No message available"; //$NON-NLS-1$
	String message = null;
	try {
		message = this.bundle.getString(id);
	} catch (MissingResourceException e) {
		// If we got an exception looking for the message, fail gracefully by just returning
		// the id we were looking for.  In most cases this is semi-informative so is not too bad.
		return "Missing message: " + id + " in: " + Main.bundleName; //$NON-NLS-2$ //$NON-NLS-1$
	}
	return MessageFormat.format(message, (Object[]) arguments);
}
 
Example #11
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void setLocale(Locale locale) {
	this.locale = locale == null ? Locale.getDefault() : locale;
	try {
		this.bundle = ResourceBundleFactory.getBundle(this.locale);
	} catch(MissingResourceException e) {
		System.out.println("Missing resource : " + Main.bundleName.replace('.', '/') + ".properties for locale " + locale); //$NON-NLS-1$//$NON-NLS-2$
		throw e;
	}
}
 
Example #12
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private Iterable<? extends File> getExtdirsFrom(String path) {
	ArrayList<FileSystem.Classpath> paths = new ArrayList<FileSystem.Classpath>();
	ArrayList<File> files = new ArrayList<File>();
	try {
		this.processPathEntries(Main.DEFAULT_SIZE_CLASSPATH, paths, path, this.charset.name(), false, false);
	} catch (IllegalArgumentException e) {
		return null;
	}
	for (FileSystem.Classpath classpath : paths) {
		files.add(new File(classpath.getPath()));
	}
	return files;
}
 
Example #13
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private Iterable<? extends File> getEndorsedDirsFrom(String path) {
	ArrayList<FileSystem.Classpath> paths = new ArrayList<FileSystem.Classpath>();
	ArrayList<File> files = new ArrayList<File>();
	try {
		this.processPathEntries(Main.DEFAULT_SIZE_CLASSPATH, paths, path, this.charset.name(), false, false);
	} catch (IllegalArgumentException e) {
		return null;
	}
	for (FileSystem.Classpath classpath : paths) {
		files.add(new File(classpath.getPath()));
	}
	return files;
}
 
Example #14
Source File: CompileJavaTask.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
private boolean runEcj() {
    mBuilder.stdout(TAG + ": Compile java with javac");
    PrintWriter outWriter = new PrintWriter(mBuilder.getStdout());
    PrintWriter errWriter = new PrintWriter(mBuilder.getStderr());
    org.eclipse.jdt.internal.compiler.batch.Main main =
            new org.eclipse.jdt.internal.compiler.batch.Main(outWriter, errWriter,
                    false, null, null);

    Argument argument = new Argument();
    argument.add(mBuilder.isVerbose() ? "-verbose" : "-warn:");
    argument.add("-bootclasspath", mBuilder.getBootClassPath());
    argument.add("-classpath", mProject.getClasspath());
    argument.add("-sourcepath", mProject.getSourcePath());
    argument.add("-" + mCompileOptions.getSourceCompatibility().toString()); //host
    argument.add("-target", mCompileOptions.getTargetCompatibility().toString()); //target
    argument.add("-proc:none"); // Disable annotation processors...
    argument.add("-d", mProject.getDirBuildClasses().getAbsolutePath()); // The location of the output folder

    String[] sourceFiles = getAllSourceFiles(mProject);
    argument.add(sourceFiles);

    Main.Logger logger = main.logger;
    //default output
    logger.setEmacs();

    System.out.println(TAG + ": Compiler arguments " + argument);
    main.logger.endLoggingSource();
    return main.compile(argument.toArray());
}
 
Example #15
Source File: BatchAnnotationProcessorManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void configure(Object batchCompiler, String[] commandLineArguments) {
	if (null != _processingEnv) {
		throw new IllegalStateException(
				"Calling configure() more than once on an AnnotationProcessorManager is not supported"); //$NON-NLS-1$
	}
	BatchProcessingEnvImpl processingEnv = new BatchProcessingEnvImpl(this, (Main) batchCompiler, commandLineArguments);
	_processingEnv = processingEnv;
	_procLoader = processingEnv.getFileManager().getClassLoader(StandardLocation.ANNOTATION_PROCESSOR_PATH);
	parseCommandLine(commandLineArguments);
	_round = 0;
}
 
Example #16
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private String bind(String id, String[] arguments) {
	if (id == null)
		return "No message available"; //$NON-NLS-1$
	String message = null;
	try {
		message = this.bundle.getString(id);
	} catch (MissingResourceException e) {
		// If we got an exception looking for the message, fail gracefully by just returning
		// the id we were looking for.  In most cases this is semi-informative so is not too bad.
		return "Missing message: " + id + " in: " + Main.bundleName; //$NON-NLS-2$ //$NON-NLS-1$
	}
	return MessageFormat.format(message, (Object[]) arguments);
}
 
Example #17
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void setLocale(Locale locale) {
	this.locale = locale == null ? Locale.getDefault() : locale;
	try {
		this.bundle = ResourceBundleFactory.getBundle(this.locale);
	} catch(MissingResourceException e) {
		System.out.println("Missing resource : " + Main.bundleName.replace('.', '/') + ".properties for locale " + locale); //$NON-NLS-1$//$NON-NLS-2$
		throw e;
	}
}
 
Example #18
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private Iterable<? extends File> getExtdirsFrom(String path) {
	ArrayList<FileSystem.Classpath> paths = new ArrayList<FileSystem.Classpath>();
	ArrayList<File> files = new ArrayList<File>();
	try {
		this.processPathEntries(Main.DEFAULT_SIZE_CLASSPATH, paths, path, this.charset.name(), false, false);
	} catch (IllegalArgumentException e) {
		return null;
	}
	for (FileSystem.Classpath classpath : paths) {
		files.add(new File(classpath.getPath()));
	}
	return files;
}
 
Example #19
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private Iterable<? extends File> getEndorsedDirsFrom(String path) {
	ArrayList<FileSystem.Classpath> paths = new ArrayList<FileSystem.Classpath>();
	ArrayList<File> files = new ArrayList<File>();
	try {
		this.processPathEntries(Main.DEFAULT_SIZE_CLASSPATH, paths, path, this.charset.name(), false, false);
	} catch (IllegalArgumentException e) {
		return null;
	}
	for (FileSystem.Classpath classpath : paths) {
		files.add(new File(classpath.getPath()));
	}
	return files;
}
 
Example #20
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private Iterable<? extends File> getPathsFrom(String path) {
	ArrayList<FileSystem.Classpath> paths = new ArrayList<FileSystem.Classpath>();
	ArrayList<File> files = new ArrayList<File>();
	try {
		this.processPathEntries(Main.DEFAULT_SIZE_CLASSPATH, paths, path, this.charset.name(), false, false);
	} catch (IllegalArgumentException e) {
		return null;
	}
	for (FileSystem.Classpath classpath : paths) {
		files.add(new File(classpath.getPath()));
	}
	return files;
}
 
Example #21
Source File: BatchMessagerImpl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public BatchMessagerImpl(BaseProcessingEnvImpl processingEnv, Main compiler) {
	_compiler = compiler;
	_processingEnv = processingEnv;
}
 
Example #22
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@SuppressWarnings({"rawtypes", "unchecked"})
protected void addNewEntry(ArrayList paths, String currentClasspathName,
		ArrayList currentRuleSpecs, String customEncoding,
		String destPath, boolean isSourceOnly,
		boolean rejectDestinationPathOnJars) {

	int rulesSpecsSize = currentRuleSpecs.size();
	AccessRuleSet accessRuleSet = null;
	if (rulesSpecsSize != 0) {
		AccessRule[] accessRules = new AccessRule[currentRuleSpecs.size()];
		boolean rulesOK = true;
		Iterator i = currentRuleSpecs.iterator();
		int j = 0;
		while (i.hasNext()) {
			String ruleSpec = (String) i.next();
			char key = ruleSpec.charAt(0);
			String pattern = ruleSpec.substring(1);
			if (pattern.length() > 0) {
				switch (key) {
					case '+':
						accessRules[j++] = new AccessRule(pattern
								.toCharArray(), 0);
						break;
					case '~':
						accessRules[j++] = new AccessRule(pattern
								.toCharArray(),
								IProblem.DiscouragedReference);
						break;
					case '-':
						accessRules[j++] = new AccessRule(pattern
								.toCharArray(),
								IProblem.ForbiddenReference);
						break;
					case '?':
						accessRules[j++] = new AccessRule(pattern
								.toCharArray(),
								IProblem.ForbiddenReference, true/*keep looking for accessible type*/);
						break;
					default:
						rulesOK = false;
				}
			} else {
				rulesOK = false;
			}
		}
		if (rulesOK) {
    		accessRuleSet = new AccessRuleSet(accessRules, AccessRestriction.COMMAND_LINE, currentClasspathName);
		} else {
			return;
		}
	}
	if (Main.NONE.equals(destPath)) {
		destPath = Main.NONE; // keep == comparison valid
	}
	if (rejectDestinationPathOnJars && destPath != null &&
			(currentClasspathName.endsWith(".jar") || //$NON-NLS-1$
				currentClasspathName.endsWith(".zip"))) { //$NON-NLS-1$
		throw new IllegalArgumentException(
				this.bind("configure.unexpectedDestinationPathEntryFile", //$NON-NLS-1$
							currentClasspathName));
		}
	FileSystem.Classpath currentClasspath = FileSystem.getClasspath(
			currentClasspathName,
			customEncoding,
			isSourceOnly,
			accessRuleSet,
			destPath);
	if (currentClasspath != null) {
		paths.add(currentClasspath);
	}
}
 
Example #23
Source File: EclipseFileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@SuppressWarnings({"rawtypes", "unchecked"})
protected void addNewEntry(ArrayList paths, String currentClasspathName,
		ArrayList currentRuleSpecs, String customEncoding,
		String destPath, boolean isSourceOnly,
		boolean rejectDestinationPathOnJars) {

	int rulesSpecsSize = currentRuleSpecs.size();
	AccessRuleSet accessRuleSet = null;
	if (rulesSpecsSize != 0) {
		AccessRule[] accessRules = new AccessRule[currentRuleSpecs.size()];
		boolean rulesOK = true;
		Iterator i = currentRuleSpecs.iterator();
		int j = 0;
		while (i.hasNext()) {
			String ruleSpec = (String) i.next();
			char key = ruleSpec.charAt(0);
			String pattern = ruleSpec.substring(1);
			if (pattern.length() > 0) {
				switch (key) {
					case '+':
						accessRules[j++] = new AccessRule(pattern
								.toCharArray(), 0);
						break;
					case '~':
						accessRules[j++] = new AccessRule(pattern
								.toCharArray(),
								IProblem.DiscouragedReference);
						break;
					case '-':
						accessRules[j++] = new AccessRule(pattern
								.toCharArray(),
								IProblem.ForbiddenReference);
						break;
					case '?':
						accessRules[j++] = new AccessRule(pattern
								.toCharArray(),
								IProblem.ForbiddenReference, true/*keep looking for accessible type*/);
						break;
					default:
						rulesOK = false;
				}
			} else {
				rulesOK = false;
			}
		}
		if (rulesOK) {
    		accessRuleSet = new AccessRuleSet(accessRules, AccessRestriction.COMMAND_LINE, currentClasspathName);
		} else {
			return;
		}
	}
	if (Main.NONE.equals(destPath)) {
		destPath = Main.NONE; // keep == comparison valid
	}
	if (rejectDestinationPathOnJars && destPath != null &&
			(currentClasspathName.endsWith(".jar") || //$NON-NLS-1$
				currentClasspathName.endsWith(".zip"))) { //$NON-NLS-1$
		throw new IllegalArgumentException(
				this.bind("configure.unexpectedDestinationPathEntryFile", //$NON-NLS-1$
							currentClasspathName));
		}
	FileSystem.Classpath currentClasspath = FileSystem.getClasspath(
			currentClasspathName,
			customEncoding,
			isSourceOnly,
			accessRuleSet,
			destPath);
	if (currentClasspath != null) {
		paths.add(currentClasspath);
	}
}
 
Example #24
Source File: Util.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public static void collectRunningVMBootclasspath(List bootclasspaths) {
	/* no bootclasspath specified
	 * we can try to retrieve the default librairies of the VM used to run
	 * the batch compiler
	 */
	String javaversion = System.getProperty("java.version");//$NON-NLS-1$
	if (javaversion != null && javaversion.equalsIgnoreCase("1.1.8")) { //$NON-NLS-1$
		throw new IllegalStateException();
	}

	/*
	 * Handle >= JDK 1.2.2 settings: retrieve the bootclasspath
	 */
	// check bootclasspath properties for Sun, JRockit and Harmony VMs
	String bootclasspathProperty = System.getProperty("sun.boot.class.path"); //$NON-NLS-1$
	if ((bootclasspathProperty == null) || (bootclasspathProperty.length() == 0)) {
		// IBM J9 VMs
		bootclasspathProperty = System.getProperty("vm.boot.class.path"); //$NON-NLS-1$
		if ((bootclasspathProperty == null) || (bootclasspathProperty.length() == 0)) {
			// Harmony using IBM VME
			bootclasspathProperty = System.getProperty("org.apache.harmony.boot.class.path"); //$NON-NLS-1$
		}
	}
	if ((bootclasspathProperty != null) && (bootclasspathProperty.length() != 0)) {
		StringTokenizer tokenizer = new StringTokenizer(bootclasspathProperty, File.pathSeparator);
		String token;
		while (tokenizer.hasMoreTokens()) {
			token = tokenizer.nextToken();
			FileSystem.Classpath currentClasspath = FileSystem.getClasspath(token, null, null);
			if (currentClasspath != null) {
				bootclasspaths.add(currentClasspath);
			}
		}
	} else {
		// try to get all jars inside the lib folder of the java home
		final File javaHome = getJavaHome();
		if (javaHome != null) {
			File[] directoriesToCheck = null;
			if (System.getProperty("os.name").startsWith("Mac")) {//$NON-NLS-1$//$NON-NLS-2$
				directoriesToCheck = new File[] {
					new File(javaHome, "../Classes"), //$NON-NLS-1$
				};
			} else {
				// fall back to try to retrieve them out of the lib directory
				directoriesToCheck = new File[] {
					new File(javaHome, "lib") //$NON-NLS-1$
				};
			}
			File[][] systemLibrariesJars = Main.getLibrariesFiles(directoriesToCheck);
			if (systemLibrariesJars != null) {
				for (int i = 0, max = systemLibrariesJars.length; i < max; i++) {
					File[] current = systemLibrariesJars[i];
					if (current != null) {
						for (int j = 0, max2 = current.length; j < max2; j++) {
							FileSystem.Classpath classpath =
								FileSystem.getClasspath(current[j].getAbsolutePath(),
									null, false, null, null);
							if (classpath != null) {
								bootclasspaths.add(classpath);
							}
						}
					}
				}
			}
		}
	}
}
 
Example #25
Source File: OnTheFlyJavaCompiler.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected Main getMain() {
	return new Main(new PrintWriter(new OutputStreamWriter(
			System.out)), new PrintWriter(new OutputStreamWriter(
			errorStream)), false /* systemExit */, null /* options */, null);
}
 
Example #26
Source File: OnTheFlyJavaCompiler.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected boolean compile(String arguments) {
	// return BatchCompiler.compile(sb.toString(), new PrintWriter(new
	// OutputStreamWriter(System.out)), new PrintWriter(
	// new OutputStreamWriter(errorStream)), null);
	return getMain().compile(Main.tokenize(arguments));
}
 
Example #27
Source File: OnTheFlyJavaCompiler.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected Main getMain() {
	return new Main(new PrintWriter(new OutputStreamWriter(
			System.out)), new PrintWriter(new OutputStreamWriter(
			errorStream)), false /* systemExit */, null /* options */, null);
}
 
Example #28
Source File: OnTheFlyJavaCompiler.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected boolean compile(String arguments) {
	// return BatchCompiler.compile(sb.toString(), new PrintWriter(new
	// OutputStreamWriter(System.out)), new PrintWriter(
	// new OutputStreamWriter(errorStream)), null);
	return getMain().compile(Main.tokenize(arguments));
}
 
Example #29
Source File: BatchCompiler.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Invokes the Eclipse Compiler for Java with the given command line arguments, using the given writers
 * to print messages, and reporting progress to the given compilation progress. Returns whether
 * the compilation completed successfully.
 * <p>
 * Reasons for a compilation failing to complete successfully include:</p>
 * <ul>
 * <li>an error was reported</li>
 * <li>a runtime exception occurred</li>
 * <li>the compilation was canceled using the compilation progress</li>
 * </ul>
 * <p>
 * The specification of the command line arguments is defined by running the batch compiler's help
 * <pre>BatchCompiler.compile("-help", new PrintWriter(System.out), new PrintWriter(System.err), null);</pre>
 * </p>
 *
 * @param commandLine the command line arguments passed to the compiler
 * @param outWriter the writer used to print standard messages
 * @param errWriter the writer used to print error messages
 * @param progress the object to report progress to and to provide cancellation, or <code>null</code> if no progress is needed
 * @return whether the compilation completed successfully
 */
public static boolean compile(String commandLine, PrintWriter outWriter, PrintWriter errWriter, CompilationProgress progress) {
	return compile(Main.tokenize(commandLine), outWriter, errWriter, progress);
}
 
Example #30
Source File: BatchCompiler.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Invokes the Eclipse Compiler for Java with the given command line arguments, using the given writers
 * to print messages, and reporting progress to the given compilation progress. Returns whether
 * the compilation completed successfully.
 * <p>
 * Reasons for a compilation failing to complete successfully include:</p>
 * <ul>
 * <li>an error was reported</li>
 * <li>a runtime exception occurred</li>
 * <li>the compilation was canceled using the compilation progress</li>
 * </ul>
 * <p>
 * The specification of the command line arguments is defined by running the batch compiler's help
 * <pre>BatchCompiler.compile("-help", new PrintWriter(System.out), new PrintWriter(System.err), null);</pre>
 * </p>
 * Note that a <code>true</code> returned value indicates that no errors were reported, no runtime exceptions
 * occurred and that the compilation was not canceled.
 *
 * @param commandLineArguments the command line arguments passed to the compiler
 * @param outWriter the writer used to print standard messages
 * @param errWriter the writer used to print error messages
 * @param progress the object to report progress to and to provide cancellation, or <code>null</code> if no progress is needed
 * @return whether the compilation completed successfully
 */
public static boolean compile(String[] commandLineArguments, PrintWriter outWriter, PrintWriter errWriter, CompilationProgress progress) {
	return Main.compile(commandLineArguments, outWriter, errWriter, progress);
}