Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 92871 Details for
Bug 217233
[compiler] Add compiler API to call the batch compiler from a stand-alone application
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Same patch with CompilerProgress renamed to CompilationProgress
217233_v7.txt (text/plain), 50.89 KB, created by
Jerome Lanneluc
on 2008-03-19 04:16:08 EDT
(
hide
)
Description:
Same patch with CompilerProgress renamed to CompilationProgress
Filename:
MIME Type:
Creator:
Jerome Lanneluc
Created:
2008-03-19 04:16:08 EDT
Size:
50.89 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java,v >retrieving revision 1.48 >diff -u -r1.48 ModifyingResourceTests.java >--- src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java 26 Feb 2008 10:11:57 -0000 1.48 >+++ src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java 19 Mar 2008 08:13:57 -0000 >@@ -16,8 +16,8 @@ > import org.eclipse.core.resources.*; > import org.eclipse.core.runtime.*; > import org.eclipse.jdt.core.*; >+import org.eclipse.jdt.core.compiler.batch.BatchCompiler; > import org.eclipse.jdt.core.tests.util.Util; >-import org.eclipse.jdt.internal.compiler.batch.Main; > import org.eclipse.jdt.internal.core.JavaElement; > > public class ModifyingResourceTests extends AbstractJavaModelTests { >@@ -65,7 +65,7 @@ > public static void generateClassFile(String className, String javaSource) throws IOException { > String cu = "d:/temp/" + className + ".java"; > Util.createFile(cu, javaSource); >- Main.compile(cu + " -d d:/temp -classpath " + System.getProperty("java.home") + "/lib/rt.jar"); >+ BatchCompiler.compile(cu + " -d d:/temp -classpath " + System.getProperty("java.home") + "/lib/rt.jar", new PrintWriter(System.out), new PrintWriter(System.err), null/*progress*/); > FileInputStream input = new FileInputStream("d:/temp/" + className + ".class"); > try { > System.out.println("{"); >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileComparatorTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileComparatorTest.java,v >retrieving revision 1.12 >diff -u -r1.12 ClassFileComparatorTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileComparatorTest.java 29 Mar 2006 03:50:22 -0000 1.12 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileComparatorTest.java 19 Mar 2008 08:14:09 -0000 >@@ -12,8 +12,10 @@ > > import junit.framework.Test; > import java.io.*; >+ > import junit.framework.Assert; > >+import org.eclipse.jdt.core.compiler.batch.BatchCompiler; > import org.eclipse.jdt.core.tests.util.Util; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException; >@@ -60,7 +62,7 @@ > .append(Util.getJavaClassLibsAsString()) > .append(SOURCE_DIRECTORY) > .append("\""); >- org.eclipse.jdt.internal.compiler.batch.Main.compile(buffer.toString()); >+ BatchCompiler.compile(buffer.toString(), new PrintWriter(System.out), new PrintWriter(System.err), null/*progress*/); > } > > private boolean areStructurallyDifferent(String classFile1, String classFile2, boolean orderRequired, boolean excludeSynthetic) { >Index: src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java,v >retrieving revision 1.80 >diff -u -r1.80 AbstractRegressionTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java 17 Jan 2008 13:01:33 -0000 1.80 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java 19 Mar 2008 08:14:00 -0000 >@@ -30,6 +30,7 @@ > import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.Path; > import org.eclipse.jdt.core.ToolFactory; >+import org.eclipse.jdt.core.compiler.batch.BatchCompiler; > import org.eclipse.jdt.core.search.SearchDocument; > import org.eclipse.jdt.core.search.SearchParticipant; > import org.eclipse.jdt.core.tests.junit.extension.StopableTestCase; >@@ -258,7 +259,7 @@ > .append(Util.getJavaClassLibsAsString()) > .append(SOURCE_DIRECTORY) > .append("\""); >- org.eclipse.jdt.internal.compiler.batch.Main.compile(buffer.toString()); >+ BatchCompiler.compile(buffer.toString(), new PrintWriter(System.out), new PrintWriter(System.err), null/*progress*/); > } > > /* >Index: src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java,v >retrieving revision 1.151 >diff -u -r1.151 BatchCompilerTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 17 Mar 2008 09:18:28 -0000 1.151 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 19 Mar 2008 08:14:08 -0000 >@@ -25,7 +25,9 @@ > import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.jdt.core.JavaCore; > import org.eclipse.jdt.core.compiler.CharOperation; >+import org.eclipse.jdt.core.compiler.CompilationProgress; > import org.eclipse.jdt.core.compiler.InvalidInputException; >+import org.eclipse.jdt.core.compiler.batch.BatchCompiler; > import org.eclipse.jdt.core.tests.util.Util; > import org.eclipse.jdt.internal.compiler.batch.ClasspathJar; > import org.eclipse.jdt.internal.compiler.batch.ClasspathLocation; >@@ -35,7 +37,7 @@ > public class BatchCompilerTest extends AbstractRegressionTest { > public static final String OUTPUT_DIR_PLACEHOLDER = "---OUTPUT_DIR_PLACEHOLDER---"; > static final String JRE_HOME_DIR = Util.getJREDirectory(); >- private static final Main MAIN = new Main(null, null, false); >+ private static final Main MAIN = new Main(null/*outWriter*/, null/*errWriter*/, false/*systemExit*/, null/*options*/, null/*progress*/); > > static { > // TESTS_NAMES = new String[] { "test000" }; >@@ -90,7 +92,7 @@ > * file names are relative to the output directory > * @param commandLine > * the command line to pass to >- * {@link Main#compile(String) Main#compile} >+ * {@link BatchCompiler#compile(String, PrintWriter, PrintWriter, org.eclipse.jdt.core.compiler.CompilationProgress) BatchCompiler#compile} > * @param expectedSuccessOutOutputString > * the expected contents of the standard output stream; pass null > * to bypass the comparison >@@ -106,7 +108,7 @@ > String expectedSuccessErrOutputString, > boolean shouldFlushOutputDirectory) { > runTest(true, testFiles, commandLine, expectedSuccessOutOutputString, >- expectedSuccessErrOutputString, shouldFlushOutputDirectory); >+ expectedSuccessErrOutputString, shouldFlushOutputDirectory, null/*progress*/); > } > > /** >@@ -118,7 +120,7 @@ > * file names are relative to the output directory > * @param commandLine > * the command line to pass to >- * {@link Main#compile(String) Main#compile} >+ * {@link BatchCompiler#compile(String, PrintWriter, PrintWriter, org.eclipse.jdt.core.compiler.CompilationProgress) BatchCompiler#compile} > * @param expectedFailureOutOutputString > * the expected contents of the standard output stream; pass null > * to bypass the comparison >@@ -134,9 +136,36 @@ > String expectedFailureErrOutputString, > boolean shouldFlushOutputDirectory) { > runTest(false, testFiles, commandLine, expectedFailureOutOutputString, >- expectedFailureErrOutputString, shouldFlushOutputDirectory); >+ expectedFailureErrOutputString, shouldFlushOutputDirectory, null/*progress*/); > } > >+ private void runProgressTest( >+ String[] testFiles, >+ String commandLine, >+ String expectedOutOutputString, >+ String expectedErrOutputString, >+ String expectedProgress) { >+ runTest(true/*shouldCompileOK*/, testFiles, commandLine, expectedOutOutputString, expectedErrOutputString, true/*shouldFlushOutputDirectory*/, new TestCompilationProgress()); >+ } >+ >+ private void runProgressTest( >+ boolean shouldCompileOK, >+ String[] testFiles, >+ String commandLine, >+ String expectedOutOutputString, >+ String expectedErrOutputString, >+ TestCompilationProgress progress, >+ String expectedProgress) { >+ runTest(shouldCompileOK, testFiles, commandLine, expectedOutOutputString, expectedErrOutputString, true/*shouldFlushOutputDirectory*/, progress); >+ String actualProgress = progress.toString(); >+ if (!semiNormalizedComparison(expectedProgress, actualProgress, outputDirNormalizer)) { >+ System.out.println(Util.displayString(outputDirNormalizer.normalized(actualProgress), 2)); >+ assertEquals( >+ "Unexpected progress", >+ expectedProgress, >+ actualProgress); >+ } >+ } > /** > * Worker method for runConformTest and runNegativeTest. > * >@@ -148,7 +177,7 @@ > * file names are relative to the output directory > * @param commandLine > * the command line to pass to >- * {@link Main#compile(String) Main#compile} >+ * {@link BatchCompiler#compile(String, PrintWriter, PrintWriter, org.eclipse.jdt.core.compiler.CompilationProgress) BatchCompiler#compile} > * @param expectedOutOutputString > * the expected contents of the standard output stream; pass null > * to bypass the comparison >@@ -162,7 +191,8 @@ > private void runTest(boolean shouldCompileOK, String[] testFiles, String commandLine, > String expectedOutOutputString, > String expectedErrOutputString, >- boolean shouldFlushOutputDirectory) { >+ boolean shouldFlushOutputDirectory, >+ TestCompilationProgress progress) { > File outputDirectory = new File(OUTPUT_DIR); > if (shouldFlushOutputDirectory) > Util.flushDirectoryContent(outputDirectory); >@@ -199,7 +229,7 @@ > try { > out = new PrintWriter(new FileOutputStream(outFileName)); > err = new PrintWriter(new FileOutputStream(errFileName)); >- batchCompiler = new Main(out, err, false); >+ batchCompiler = new Main(out, err, false/*systemExit*/, null/*options*/, progress); > } catch (FileNotFoundException e) { > System.out.println(getClass().getName() + '#' + getName()); > e.printStackTrace(); >@@ -293,7 +323,7 @@ > } > ArrayList paths = new ArrayList(Main.DEFAULT_SIZE_CLASSPATH); > try { >- (new Main(new PrintWriter(System.out), new PrintWriter(System.err), true)). >+ (new Main(new PrintWriter(System.out), new PrintWriter(System.err), true/*systemExit*/, null/*options*/, null/*progress*/)). > processPathEntries(Main.DEFAULT_SIZE_CLASSPATH, paths, classpathInput, null /* customEncoding */, true /* isSourceOnly */, false /* rejectDestinationPathOnJars*/); > } catch (InvalidInputException e) { > // e.printStackTrace(); >@@ -408,6 +438,31 @@ > } > } > >+ static class TestCompilationProgress extends CompilationProgress { >+ boolean isCanceled = false; >+ int workedSoFar = 0; >+ StringBuffer buffer = new StringBuffer(); >+ public void begin(int remainingWork) { >+ this.buffer.append("----------\n[worked: 0 - remaining: ").append(remainingWork).append("]\n"); >+ } >+ public void done() { >+ this.buffer.append("----------\n"); >+ } >+ public boolean isCanceled() { >+ return this.isCanceled; >+ } >+ public void setTaskName(String name) { >+ this.buffer.append(name).append('\n'); >+ } >+ public String toString() { >+ return this.buffer.toString(); >+ } >+ public void worked(int workIncrement, int remainingWork) { >+ this.workedSoFar += workIncrement; >+ this.buffer.append("[worked: ").append(this.workedSoFar).append(" - remaining: ").append(remainingWork).append("]\n"); >+ } >+ } >+ > /** > * This normalizer replaces the whole classpaths section of a log file with > * a normalized placeholder. >@@ -617,6 +672,7 @@ > // return keep.equals(normalizer.normalized(normalize)); > return equals(keep, normalizer.normalized(normalize)); > } >+ > private static boolean equals(String a, String b) { > StringBuffer aBuffer = new StringBuffer(a), bBuffer = new StringBuffer(b); > int length = aBuffer.length(), bLength; >@@ -8476,7 +8532,8 @@ > "Zork cannot be resolved to a type\n" + > "----------\n" + > "1 problem (1 error)" /* expectedErrOutputString */, >- false /* shouldFlushOutputDirectory */); >+ false /* shouldFlushOutputDirectory */, >+ null /* progress */); > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=216684 > // .java/.class files precedence depending on sourcepath >@@ -8521,7 +8578,8 @@ > "Zork cannot be resolved to a type\n" + > "----------\n" + > "1 problem (1 error)" /* expectedErrOutputString */, >- false /* shouldFlushOutputDirectory */); >+ false /* shouldFlushOutputDirectory */, >+ null /* progress */); > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=216684 > // different from javac: repeated -classpath concatenate entries, while javac >@@ -8597,7 +8655,8 @@ > + " -proc:none -d \"" + OUTPUT_DIR + "\"", > "" /* expectedOutOutputString */, > "" /* expectedErrOutputString */, >- true /* shouldFlushOutputDirectory */); >+ true /* shouldFlushOutputDirectory */, >+ null /* progress */); > // using only classpath, both ecj and javac find X and Z > runTest( > true /* shouldCompileOK */, >@@ -8608,7 +8667,8 @@ > + " -proc:none -d \"" + OUTPUT_DIR + "\"", > "" /* expectedOutOutputString */, > "" /* expectedErrOutputString */, >- false /* shouldFlushOutputDirectory */); >+ false /* shouldFlushOutputDirectory */, >+ null /* progress */); > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=216684 > // different from javac: with javac, newer class file down the classpath wins >@@ -8635,7 +8695,8 @@ > + " -proc:none -d \"" + OUTPUT_DIR + "\"", > "" /* expectedOutOutputString */, > "" /* expectedErrOutputString */, >- true /* shouldFlushOutputDirectory */); >+ true /* shouldFlushOutputDirectory */, >+ null /* progress */); > // X.class found before X.java in classpath order entry > runTest( > true /* shouldCompileOK */, >@@ -8653,7 +8714,8 @@ > "[1 unit compiled]\n" + > "[1 .class file generated]\n" /* expectedOutOutputString */, > "" /* expectedErrOutputString */, >- false /* shouldFlushOutputDirectory */); >+ false /* shouldFlushOutputDirectory */, >+ null /* progress */); > // X.java found before X.class in classpath order entry; javac would select > // X.class since it is more recent (except if using -Xprefer:source) > runTest( >@@ -8680,6 +8742,131 @@ > "Zork cannot be resolved to a type\n" + > "----------\n" + > "1 problem (1 error)" /* expectedErrOutputString */, >- false /* shouldFlushOutputDirectory */); >+ false /* shouldFlushOutputDirectory */, >+ null /* progress */); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=217233 >+// compiler progress test (1 unit) >+public void test236_progress() { >+ runProgressTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ "}\n", >+ }, >+ "\"" + OUTPUT_DIR + File.separator + "X.java\"" >+ + " -d \"" + OUTPUT_DIR + "\"", >+ ""/*out output*/, >+ ""/*err output*/, >+ "----------\n" + >+ "[worked: 0 - remaining: 1]\n" + >+ "Beginning to compile\n" + >+ "Processing ---OUTPUT_DIR_PLACEHOLDER---/X.java\n" + >+ "[worked: 1 - remaining: 0]\n" + >+ "----------\n" >+ ); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=217233 >+// compiler progress test (2 units) >+public void test237_progress() { >+ runProgressTest( >+ new String[] { >+ "Y.java", >+ "public class Y {\n" + >+ "}\n", >+ "X.java", >+ "public class X extends Y {\n" + >+ "}\n", >+ }, >+ "\"" + OUTPUT_DIR + File.separator + "X.java\"" >+ + " -cp " + File.pathSeparator + File.pathSeparator + "\"" + OUTPUT_DIR + "\"" >+ + " -d \"" + OUTPUT_DIR + "\"", >+ ""/*out output*/, >+ ""/*err output*/, >+ "----------\n" + >+ "[worked: 0 - remaining: 1]\n" + >+ "Beginning to compile\n" + >+ "Processing ---OUTPUT_DIR_PLACEHOLDER---/X.java\n" + >+ "[worked: 1 - remaining: 1]\n" + >+ "Processing ---OUTPUT_DIR_PLACEHOLDER---/Y.java\n" + >+ "[worked: 2 - remaining: 0]\n" + >+ "----------\n" >+ ); >+} >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=217233 >+// compiler progress test (multiple iterations) >+public void test238_progress() { >+ runProgressTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ "}\n", >+ "Y.java", >+ "public class Y {\n" + >+ "}\n", >+ }, >+ "\"" + OUTPUT_DIR + File.separator + "X.java\"" >+ + " \"" + OUTPUT_DIR + File.separator + "Y.java\"" >+ + " -cp " + File.pathSeparator + File.pathSeparator + "\"" + OUTPUT_DIR + "\"" >+ + " -d \"" + OUTPUT_DIR + "\"" >+ + " -repeat 3", >+ "[repetition 1/3]\n" + >+ "[repetition 2/3]\n" + >+ "[repetition 3/3]\n"/*out output*/, >+ ""/*err output*/, >+ "----------\n" + >+ "[worked: 0 - remaining: 6]\n" + >+ "Beginning to compile\n" + >+ "Processing ---OUTPUT_DIR_PLACEHOLDER---/X.java\n" + >+ "[worked: 1 - remaining: 5]\n" + >+ "Processing ---OUTPUT_DIR_PLACEHOLDER---/Y.java\n" + >+ "[worked: 2 - remaining: 4]\n" + >+ "Beginning to compile\n" + >+ "Processing ---OUTPUT_DIR_PLACEHOLDER---/X.java\n" + >+ "[worked: 3 - remaining: 3]\n" + >+ "Processing ---OUTPUT_DIR_PLACEHOLDER---/Y.java\n" + >+ "[worked: 4 - remaining: 2]\n" + >+ "Beginning to compile\n" + >+ "Processing ---OUTPUT_DIR_PLACEHOLDER---/X.java\n" + >+ "[worked: 5 - remaining: 1]\n" + >+ "Processing ---OUTPUT_DIR_PLACEHOLDER---/Y.java\n" + >+ "[worked: 6 - remaining: 0]\n" + >+ "----------\n" >+ ); >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=217233 >+// compiler progress test (cancellation) >+public void test239_progress() { >+ TestCompilationProgress progress = new TestCompilationProgress() { >+ public void worked(int workIncrement, int remainingWork) { >+ if (remainingWork == 1) >+ this.isCanceled = true; >+ super.worked(workIncrement, remainingWork); >+ } >+ }; >+ runProgressTest( >+ false/*shouldCompileOK*/, >+ new String[] { >+ "Y.java", >+ "public class Y {\n" + >+ "}\n", >+ "X.java", >+ "public class X extends Y {\n" + >+ "}\n", >+ }, >+ "\"" + OUTPUT_DIR + File.separator + "X.java\"" >+ + " -cp " + File.pathSeparator + File.pathSeparator + "\"" + OUTPUT_DIR + "\"" >+ + " -d \"" + OUTPUT_DIR + "\"", >+ ""/*out output*/, >+ ""/*err output*/, >+ progress, >+ "----------\n" + >+ "[worked: 0 - remaining: 1]\n" + >+ "Beginning to compile\n" + >+ "Processing ---OUTPUT_DIR_PLACEHOLDER---/X.java\n" + >+ "[worked: 1 - remaining: 1]\n" + >+ "----------\n" >+ ); > } > } >Index: src/org/eclipse/jdt/core/tests/eval/DebugEvaluationTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/DebugEvaluationTest.java,v >retrieving revision 1.35 >diff -u -r1.35 DebugEvaluationTest.java >--- src/org/eclipse/jdt/core/tests/eval/DebugEvaluationTest.java 16 Oct 2007 10:24:52 -0000 1.35 >+++ src/org/eclipse/jdt/core/tests/eval/DebugEvaluationTest.java 19 Mar 2008 08:14:12 -0000 >@@ -14,12 +14,14 @@ > import java.io.File; > import java.io.FileWriter; > import java.io.IOException; >+import java.io.PrintWriter; > import java.util.ArrayList; > import java.util.Map; > > import junit.framework.Test; > > import org.eclipse.jdt.core.compiler.CategorizedProblem; >+import org.eclipse.jdt.core.compiler.batch.BatchCompiler; > import org.eclipse.jdt.core.tests.runtime.LocalVMLauncher; > import org.eclipse.jdt.core.tests.runtime.TargetInterface; > import org.eclipse.jdt.core.tests.util.CompilerTestSetup; >@@ -105,7 +107,7 @@ > .append(Util.getJavaClassLibsAsString()) > .append(SOURCE_DIRECTORY) > .append("\""); >- org.eclipse.jdt.internal.compiler.batch.Main.compile(buffer.toString()); >+ BatchCompiler.compile(buffer.toString(), new PrintWriter(System.out), new PrintWriter(System.err), null/*progress*/); > } > public void compileAndDeploy15(String source, String className) { > resetEnv(); // needed to reinitialize the caches >@@ -136,7 +138,7 @@ > .append(Util.getJavaClassLibsAsString()) > .append(SOURCE_DIRECTORY) > .append("\""); >- org.eclipse.jdt.internal.compiler.batch.Main.compile(buffer.toString()); >+ BatchCompiler.compile(buffer.toString(), new PrintWriter(System.out), new PrintWriter(System.err), null/*progress*/); > } > /** > * Generate local variable attribute for these tests. >Index: src/org/eclipse/jdt/core/tests/junit/extension/TestCase.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/TestCase.java,v >retrieving revision 1.36 >diff -u -r1.36 TestCase.java >--- src/org/eclipse/jdt/core/tests/junit/extension/TestCase.java 21 Jan 2008 12:00:20 -0000 1.36 >+++ src/org/eclipse/jdt/core/tests/junit/extension/TestCase.java 19 Mar 2008 08:14:13 -0000 >@@ -75,7 +75,7 @@ > System.err.println("Note that tests will be run sorted using alphabetical reverse order..."); > break; > case RANDOM_ORDER_JDT: >- String version = new Main(null, null, false).bind("compiler.version"); >+ String version = new Main(null/*outWriter*/, null/*errWriter*/, false/*systemExit*/, null/*options*/, null/*progress*/).bind("compiler.version"); > try { > String v_number = version.substring(2, 5); > ordering = Long.parseLong(v_number); >Index: src/org/eclipse/jdt/core/tests/util/TestVerifier.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/TestVerifier.java,v >retrieving revision 1.21 >diff -u -r1.21 TestVerifier.java >--- src/org/eclipse/jdt/core/tests/util/TestVerifier.java 6 Mar 2007 04:42:13 -0000 1.21 >+++ src/org/eclipse/jdt/core/tests/util/TestVerifier.java 19 Mar 2008 08:14:14 -0000 >@@ -10,6 +10,7 @@ > *******************************************************************************/ > package org.eclipse.jdt.core.tests.util; > >+import org.eclipse.jdt.core.compiler.batch.BatchCompiler; > import org.eclipse.jdt.core.tests.runtime.*; > import java.io.*; > import java.net.*; >@@ -84,7 +85,7 @@ > } > String fileName = dir + File.separator + simpleName + ".java"; > Util.writeToFile(this.getVerifyTestsCode(), fileName); >- org.eclipse.jdt.internal.compiler.batch.Main.compile("\"" + fileName + "\" -d \"" + verifierDir + "\" -classpath \"" + Util.getJavaClassLibsAsString() + "\""); >+ BatchCompiler.compile("\"" + fileName + "\" -d \"" + verifierDir + "\" -classpath \"" + Util.getJavaClassLibsAsString() + "\"", new PrintWriter(System.out), new PrintWriter(System.err), null/*progress*/); > } > public void execute(String className, String[] classpaths) { > this.outputBuffer = new StringBuffer(); >#P org.eclipse.jdt.compiler.tool >Index: src/org/eclipse/jdt/internal/compiler/tool/EclipseCompiler.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.compiler.tool/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompiler.java,v >retrieving revision 1.20 >diff -u -r1.20 EclipseCompiler.java >--- src/org/eclipse/jdt/internal/compiler/tool/EclipseCompiler.java 5 Jul 2007 13:52:56 -0000 1.20 >+++ src/org/eclipse/jdt/internal/compiler/tool/EclipseCompiler.java 19 Mar 2008 08:14:17 -0000 >@@ -109,7 +109,7 @@ > eclipseCompiler = new EclipseCompilerImpl(writerOut, writerErr, false); > this.threadCache.put(currentThread, eclipseCompiler); > } else { >- eclipseCompiler.initialize(writerOut, writerErr, false, null); >+ eclipseCompiler.initialize(writerOut, writerErr, false, null/*options*/, null/*progress*/); > } > final EclipseCompilerImpl eclipseCompiler2 = new EclipseCompilerImpl(writerOut, writerErr, false); > eclipseCompiler2.compilationUnits = compilationUnits; >@@ -212,7 +212,7 @@ > * java.io.OutputStream, java.lang.String[]) > */ > public int run(InputStream in, OutputStream out, OutputStream err, String... arguments) { >- boolean succeed = new Main(new PrintWriter(new OutputStreamWriter(out)), new PrintWriter(new OutputStreamWriter(err)), true).compile(arguments); >+ boolean succeed = new Main(new PrintWriter(new OutputStreamWriter(out)), new PrintWriter(new OutputStreamWriter(err)), true/*systemExit*/, null/*options*/, null/*progress*/).compile(arguments); > return succeed ? 0 : -1; > } > } >Index: src/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerImpl.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.compiler.tool/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerImpl.java,v >retrieving revision 1.4 >diff -u -r1.4 EclipseCompilerImpl.java >--- src/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerImpl.java 7 Mar 2008 16:50:56 -0000 1.4 >+++ src/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerImpl.java 19 Mar 2008 08:14:17 -0000 >@@ -30,6 +30,7 @@ > > import org.eclipse.jdt.core.compiler.CategorizedProblem; > import org.eclipse.jdt.core.compiler.CharOperation; >+import org.eclipse.jdt.core.compiler.CompilationProgress; > import org.eclipse.jdt.core.compiler.InvalidInputException; > import org.eclipse.jdt.internal.compiler.ClassFile; > import org.eclipse.jdt.internal.compiler.CompilationResult; >@@ -55,7 +56,7 @@ > public DiagnosticListener<? super JavaFileObject> diagnosticListener; > > public EclipseCompilerImpl(PrintWriter out, PrintWriter err, boolean systemExitWhenFinished) { >- super(out, err, systemExitWhenFinished); >+ super(out, err, systemExitWhenFinished, null/*options*/, null/*progress*/); > } > > public boolean call() { >@@ -67,7 +68,7 @@ > this.globalTasksCount = 0; > this.exportedClassFilesCounter = 0; > // request compilation >- performCompilation(); >+ performCompilation(1/*remaining iterations including this one*/); > } > } catch (InvalidInputException e) { > this.logger.logException(e); >@@ -219,8 +220,8 @@ > > @Override > @SuppressWarnings("unchecked") >- protected void initialize(PrintWriter outWriter, PrintWriter errWriter, boolean systemExit, Map customDefaultOptions) { >- super.initialize(outWriter, errWriter, systemExit, customDefaultOptions); >+ protected void initialize(PrintWriter outWriter, PrintWriter errWriter, boolean systemExit, Map customDefaultOptions, CompilationProgress progress) { >+ super.initialize(outWriter, errWriter, systemExit, customDefaultOptions, null); > this.javaFileObjectMap = new HashMap<CompilationUnit, JavaFileObject>(); > } > >#P org.eclipse.jdt.core.tests.performance >Index: src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceBuildTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceBuildTests.java,v >retrieving revision 1.26 >diff -u -r1.26 FullSourceWorkspaceBuildTests.java >--- src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceBuildTests.java 30 May 2007 14:59:46 -0000 1.26 >+++ src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceBuildTests.java 19 Mar 2008 08:14:19 -0000 >@@ -272,7 +272,7 @@ > StringWriter errStrWriter = new StringWriter(); > PrintWriter err = new PrintWriter(errStrWriter); > PrintWriter out = new PrintWriter(new StringWriter()); >- Main warmup = new Main(out, err, false); >+ Main warmup = new Main(out, err, false/*systemExit*/, null/*options*/, null/*progress*/); > for (int i=1; i<WARMUP_COUNT; i++) { > warmup.compile(Main.tokenize(cmdLine)); > } >@@ -298,7 +298,7 @@ > for (int i = 0; i < MEASURES_COUNT; i++) { > runGc(); > NullPrintWriter nullPrint= new NullPrintWriter(); >- Main main = new Main(nullPrint, nullPrint, false); >+ Main main = new Main(nullPrint, nullPrint, false/*systemExit*/, null/*options*/, null/*progress*/); > startMeasuring(); > main.compile(Main.tokenize(cmdLine)); > stopMeasuring(); >Index: src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java,v >retrieving revision 1.47 >diff -u -r1.47 FullSourceWorkspaceTests.java >--- src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java 21 Sep 2007 13:16:42 -0000 1.47 >+++ src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java 19 Mar 2008 08:14:20 -0000 >@@ -200,7 +200,7 @@ > // Main version which is logged > protected final static String LOG_VERSION; > static { >- String version = new Main(null, null, false).bind("compiler.version"); >+ String version = new Main(null/*outWriter*/, null/*errWriter*/, false/*systemExit*/, null/*options*/, null/*progress*/).bind("compiler.version"); > version = version.substring(0, version.indexOf(',')); > if (version.startsWith("0.")) { > version = "v_"+version.substring(2); >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/messages.properties,v >retrieving revision 1.8 >diff -u -r1.8 messages.properties >--- compiler/org/eclipse/jdt/internal/compiler/messages.properties 4 Sep 2007 22:17:51 -0000 1.8 >+++ compiler/org/eclipse/jdt/internal/compiler/messages.properties 19 Mar 2008 08:14:28 -0000 >@@ -21,6 +21,8 @@ > compilation_units = [{0} units compiled] > compilation_unit = [{0} unit compiled] > compilation_internalError = Internal compiler error >+compilation_beginningToCompile=Beginning to compile >+compilation_processing=Processing {0} > > ### output > output_isFile = Regular file {0} cannot be used as output directory >Index: compiler/org/eclipse/jdt/internal/compiler/Compiler.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java,v >retrieving revision 1.101 >diff -u -r1.101 Compiler.java >--- compiler/org/eclipse/jdt/internal/compiler/Compiler.java 7 Mar 2008 16:09:58 -0000 1.101 >+++ compiler/org/eclipse/jdt/internal/compiler/Compiler.java 19 Mar 2008 08:14:27 -0000 >@@ -29,6 +29,8 @@ > public ProblemReporter problemReporter; > protected PrintWriter out; // output for messages that are not sent to problemReporter > public CompilerStats stats; >+ public CompilationProgress progress; >+ public int remainingIterations = 1; > > // management of unit to be processed > //public CompilationUnitResult currentCompilationUnitResult; >@@ -99,7 +101,7 @@ > Map settings, > final ICompilerRequestor requestor, > IProblemFactory problemFactory) { >- this(environment, policy, new CompilerOptions(settings), requestor, problemFactory, null); >+ this(environment, policy, new CompilerOptions(settings), requestor, problemFactory, null /* printwriter */, null /* progress */); > } > > /** >@@ -151,7 +153,7 @@ > final ICompilerRequestor requestor, > IProblemFactory problemFactory, > boolean parseLiteralExpressionsAsConstants) { >- this(environment, policy, new CompilerOptions(settings, parseLiteralExpressionsAsConstants), requestor, problemFactory, null); >+ this(environment, policy, new CompilerOptions(settings, parseLiteralExpressionsAsConstants), requestor, problemFactory, null /* printwriter */, null /* progress */); > } > > /** >@@ -196,7 +198,7 @@ > CompilerOptions options, > final ICompilerRequestor requestor, > IProblemFactory problemFactory) { >- this(environment, policy, options, requestor, problemFactory, null); >+ this(environment, policy, options, requestor, problemFactory, null /* printwriter */, null /* progress */); > } > > /** >@@ -234,6 +236,7 @@ > * order to avoid object conversions. Note that the factory is not supposed > * to accumulate the created problems, the compiler will gather them all and hand > * them back as part of the compilation unit result. >+ * @deprecated > */ > public Compiler( > INameEnvironment environment, >@@ -242,8 +245,20 @@ > final ICompilerRequestor requestor, > IProblemFactory problemFactory, > PrintWriter out) { >+ this(environment, policy, options, requestor, problemFactory, out, null /* progress */); >+ } >+ >+ public Compiler( >+ INameEnvironment environment, >+ IErrorHandlingPolicy policy, >+ CompilerOptions options, >+ final ICompilerRequestor requestor, >+ IProblemFactory problemFactory, >+ PrintWriter out, >+ CompilationProgress progress) { > > this.options = options; >+ this.progress = progress; > > // wrap requestor in DebugRequestor if one is specified > if(DebugRequestor == null) { >@@ -360,6 +375,34 @@ > } > > /** >+ * Checks whether the compilation has been canceled and reports the given progress to the compiler progress. >+ */ >+ private void reportProgress(String taskDecription) { >+ if (this.progress != null) { >+ if (this.progress.isCanceled()) { >+ // Only AbortCompilation can stop the compiler cleanly. >+ // We check cancellation again following the call to compile. >+ throw new AbortCompilation(true, null); >+ } >+ this.progress.setTaskName(taskDecription); >+ } >+ } >+ >+ /** >+ * Checks whether the compilation has been canceled and reports the given work increment to the compiler progress. >+ */ >+ private void reportWorked(int workIncrement, int currentUnitIndex) { >+ if (this.progress != null) { >+ if (this.progress.isCanceled()) { >+ // Only AbortCompilation can stop the compiler cleanly. >+ // We check cancellation again following the call to compile. >+ throw new AbortCompilation(true, null); >+ } >+ this.progress.worked(workIncrement, (this.totalUnits* this.remainingIterations) - currentUnitIndex - 1); >+ } >+ } >+ >+ /** > * General API > * -> compile each of supplied files > * -> recompile any required types for which we have an incomplete principle structure >@@ -370,6 +413,7 @@ > int i = 0; > try { > // build and record parsed units >+ reportProgress(Messages.compilation_beginningToCompile); > > beginToCompile(sourceUnits); > >@@ -383,6 +427,7 @@ > // process all units (some more could be injected in the loop by the lookup environment) > for (; i < this.totalUnits; i++) { > unit = unitsToProcess[i]; >+ reportProgress(Messages.bind(Messages.compilation_processing, new String(unit.getFileName()))); > try { > if (options.verbose) > this.out.println( >@@ -398,6 +443,8 @@ > unit.cleanUp(); > } > unitsToProcess[i] = null; // release reference to processed unit declaration >+ >+ reportWorked(1, i); > this.stats.lineCount += unit.compilationResult.lineSeparatorPositions.length; > long acceptStart = System.currentTimeMillis(); > requestor.acceptResult(unit.compilationResult.tagAsAccepted()); >Index: compiler/org/eclipse/jdt/internal/compiler/util/Messages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Messages.java,v >retrieving revision 1.12 >diff -u -r1.12 Messages.java >--- compiler/org/eclipse/jdt/internal/compiler/util/Messages.java 4 Sep 2007 22:17:54 -0000 1.12 >+++ compiler/org/eclipse/jdt/internal/compiler/util/Messages.java 19 Mar 2008 08:14:28 -0000 >@@ -87,6 +87,8 @@ > public static String compilation_units; > public static String compilation_unit; > public static String compilation_internalError; >+ public static String compilation_beginningToCompile; >+ public static String compilation_processing; > public static String output_isFile; > public static String output_notValidAll; > public static String output_notValid; >Index: batch/org/eclipse/jdt/internal/compiler/batch/Main.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java,v >retrieving revision 1.320 >diff -u -r1.320 Main.java >--- batch/org/eclipse/jdt/internal/compiler/batch/Main.java 7 Mar 2008 16:09:58 -0000 1.320 >+++ batch/org/eclipse/jdt/internal/compiler/batch/Main.java 19 Mar 2008 08:14:27 -0000 >@@ -42,8 +42,10 @@ > > import org.eclipse.jdt.core.compiler.CategorizedProblem; > import org.eclipse.jdt.core.compiler.CharOperation; >+import org.eclipse.jdt.core.compiler.CompilationProgress; > import org.eclipse.jdt.core.compiler.IProblem; > import org.eclipse.jdt.core.compiler.InvalidInputException; >+import org.eclipse.jdt.core.compiler.batch.BatchCompiler; > import org.eclipse.jdt.internal.compiler.AbstractAnnotationProcessorManager; > import org.eclipse.jdt.internal.compiler.ClassFile; > import org.eclipse.jdt.internal.compiler.CompilationResult; >@@ -1263,7 +1265,8 @@ > protected FileSystem.Classpath[] checkedClasspaths; > > public Locale compilerLocale; >- public CompilerOptions compilerOptions; // read-only >+ public CompilerOptions compilerOptions; // read-only >+ public CompilationProgress progress; > public String destinationPath; > public String[] destinationPaths; > // destination path for compilation units that get no more specific >@@ -1325,22 +1328,30 @@ > > public static final String NONE = "none"; //$NON-NLS-1$ > >-/* >- * Internal IDE API >+/** >+ * @deprecated - use {@link BatchCompiler#compile(String, PrintWriter, PrintWriter, CompilationProgress)} instead >+ * e.g. BatchCompiler.compile(commandLine, new PrintWriter(System.out), new PrintWriter(System.err), null); > */ > public static boolean compile(String commandLine) { >- >- return compile(commandLine, new PrintWriter(System.out), new PrintWriter(System.err)); >+ return new Main(new PrintWriter(System.out), new PrintWriter(System.err), false /* systemExit */, null /* options */, null /* progress */).compile(tokenize(commandLine)); > } > >-/* >- * Internal IDE API for test harness purpose >+/** >+ * @deprecated - use {@link BatchCompiler#compile(String, PrintWriter, PrintWriter, CompilationProgress)} instead >+ * e.g. BatchCompiler.compile(commandLine, outWriter, errWriter, null); > */ > public static boolean compile(String commandLine, PrintWriter outWriter, PrintWriter errWriter) { >+ return new Main(outWriter, errWriter, false /* systemExit */, null /* options */, null /* progress */).compile(tokenize(commandLine)); >+} > >- return new Main(outWriter, errWriter, false).compile(tokenize(commandLine)); >+/* >+ * Internal API for public API BatchCompiler#compile(String, PrintWriter, PrintWriter, CompilerProgress) >+ */ >+public static boolean compile(String commandLine, PrintWriter outWriter, PrintWriter errWriter, CompilationProgress progress) { >+ return new Main(outWriter, errWriter, false /* systemExit */, null /* options */, progress).compile(tokenize(commandLine)); > } > >+ > public static File[][] getLibrariesFiles(File[] files) { > FilenameFilter filter = new FilenameFilter() { > public boolean accept(File dir, String name) { >@@ -1363,7 +1374,7 @@ > } > > public static void main(String[] argv) { >- new Main(new PrintWriter(System.out), new PrintWriter(System.err), true).compile(argv); >+ new Main(new PrintWriter(System.out), new PrintWriter(System.err), true/*systemExit*/, null/*options*/, null/*progress*/).compile(argv); > } > > public static String[] tokenize(String commandLine) { >@@ -1420,14 +1431,27 @@ > return arguments; > } > >+/** >+ * @deprecated - use {@link #Main(PrintWriter, PrintWriter, boolean, Map, CompilationProgress)} instead >+ * e.g. Main(outWriter, errWriter, systemExitWhenFinished, null, null) >+ */ > public Main(PrintWriter outWriter, PrintWriter errWriter, boolean systemExitWhenFinished) { >- this(outWriter, errWriter, systemExitWhenFinished, null); >+ this(outWriter, errWriter, systemExitWhenFinished, null /* options */, null /* progress */); > } > >+/** >+ * @deprecated - use {@link #Main(PrintWriter, PrintWriter, boolean, Map, CompilationProgress)} instead >+ * e.g. Main(outWriter, errWriter, systemExitWhenFinished, customDefaultOptions, null) >+ */ > public Main(PrintWriter outWriter, PrintWriter errWriter, boolean systemExitWhenFinished, Map customDefaultOptions) { >- this.initialize(outWriter, errWriter, systemExitWhenFinished, customDefaultOptions); >+ this(outWriter, errWriter, systemExitWhenFinished, customDefaultOptions, null /* progress */); >+} >+ >+public Main(PrintWriter outWriter, PrintWriter errWriter, boolean systemExitWhenFinished, Map customDefaultOptions, CompilationProgress compilationProgress) { >+ this.initialize(outWriter, errWriter, systemExitWhenFinished, customDefaultOptions, compilationProgress); > this.relocalize(); > } >+ > public void addExtraProblems(CategorizedProblem problem) { > if (this.extraProblems == null) { > this.extraProblems = new ArrayList(); >@@ -1619,6 +1643,8 @@ > // decode command line arguments > try { > configure(argv); >+ if (this.progress != null) >+ this.progress.begin(this.filenames == null ? 0 : this.filenames.length * this.maxRepetition); > if (this.proceed) { > // if (this.verbose) { > // System.out.println(new CompilerOptions(this.options)); >@@ -1636,7 +1662,7 @@ > this.logger.logRepetition(this.currentRepetition, this.maxRepetition); > } > // request compilation >- performCompilation(); >+ performCompilation(this.maxRepetition-this.currentRepetition/*remaining iterations including this one*/); > } > if (this.compilerStats != null) { > this.logger.logAverage(); >@@ -1667,8 +1693,10 @@ > } finally { > this.logger.flush(); > this.logger.close(); >+ if (this.progress != null) >+ this.progress.done(); > } >- if (this.globalErrorsCount == 0) >+ if (this.globalErrorsCount == 0 && (this.progress == null || !this.progress.isCanceled())) > return true; > return false; > } >@@ -3350,24 +3378,28 @@ > addPendingErrors(this.bind("configure.invalidWarning", token)); //$NON-NLS-1$ > } > } >-/* >- * External API >+/** >+ * @deprecated - use {@link #initialize(PrintWriter, PrintWriter, boolean, Map, CompilationProgress)} instead >+ * e.g. initialize(outWriter, errWriter, systemExit, null, null) > */ >-protected void initialize(PrintWriter outWriter, >- PrintWriter errWriter, >- boolean systemExit) { >- this.initialize(outWriter, errWriter, systemExit, null); >-} >-protected void initialize(PrintWriter outWriter, >- PrintWriter errWriter, >- boolean systemExit, >- Map customDefaultOptions) { >+protected void initialize(PrintWriter outWriter, PrintWriter errWriter, boolean systemExit) { >+ this.initialize(outWriter, errWriter, systemExit, null /* options */, null /* progress */); >+} >+/** >+ * @deprecated - use {@link #initialize(PrintWriter, PrintWriter, boolean, Map, CompilationProgress)} instead >+ * e.g. initialize(outWriter, errWriter, systemExit, customDefaultOptions, null) >+ */ >+protected void initialize(PrintWriter outWriter, PrintWriter errWriter, boolean systemExit, Map customDefaultOptions) { >+ this.initialize(outWriter, errWriter, systemExit, customDefaultOptions, null /* progress */); >+} >+protected void initialize(PrintWriter outWriter, PrintWriter errWriter, boolean systemExit, Map customDefaultOptions, CompilationProgress compilationProgress) { > this.logger = new Logger(this, outWriter, errWriter); > this.proceed = true; > this.out = outWriter; > this.err = errWriter; > this.systemExitWhenFinished = systemExit; > this.options = new CompilerOptions().getMap(); >+ this.progress = compilationProgress; > if (customDefaultOptions != null) { > this.didSpecifySource = customDefaultOptions.get(CompilerOptions.OPTION_Source) != null; > this.didSpecifyTarget = customDefaultOptions.get(CompilerOptions.OPTION_TargetPlatform) != null; >@@ -3468,7 +3500,7 @@ > /* > * Low-level API performing the actual compilation > */ >-public void performCompilation() throws InvalidInputException { >+public void performCompilation(int remainingIterations/*including the current iteration*/) throws InvalidInputException { > > this.startTime = System.currentTimeMillis(); > >@@ -3483,7 +3515,9 @@ > this.compilerOptions, > getBatchRequestor(), > getProblemFactory(), >- this.out); >+ this.out, >+ this.progress); >+ this.batchCompiler.remainingIterations = remainingIterations; > > if (this.compilerOptions.complianceLevel >= ClassFileConstants.JDK1_6 > && this.compilerOptions.processAnnotations) { >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/META-INF/MANIFEST.MF,v >retrieving revision 1.28 >diff -u -r1.28 MANIFEST.MF >--- META-INF/MANIFEST.MF 23 Jan 2008 10:08:42 -0000 1.28 >+++ META-INF/MANIFEST.MF 19 Mar 2008 08:14:23 -0000 >@@ -9,6 +9,7 @@ > Bundle-Localization: plugin > Export-Package: org.eclipse.jdt.core, > org.eclipse.jdt.core.compiler, >+ org.eclipse.jdt.core.compiler.batch, > org.eclipse.jdt.core.dom, > org.eclipse.jdt.core.dom.rewrite, > org.eclipse.jdt.core.eval, >Index: compiler/org/eclipse/jdt/core/compiler/CompilationProgress.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/core/compiler/CompilationProgress.java >diff -N compiler/org/eclipse/jdt/core/compiler/CompilationProgress.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/core/compiler/CompilationProgress.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,87 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.core.compiler; >+ >+import org.eclipse.jdt.core.compiler.batch.BatchCompiler; >+ >+/** >+ * A compilation progress is used by the {@link BatchCompiler} to report progress during compilation. >+ * It is also used to request cancellation of the compilation. >+ * Clients of the {@link BatchCompiler} should subclass this class, instantiate the subclass and pass this instance to >+ * {@link BatchCompiler#compile(String, java.io.PrintWriter, java.io.PrintWriter, CompilationProgress)}. >+ * <p> >+ * This class is intended to be instantiated and subclassed by clients. >+ * </p> >+ * >+ * @since 3.4 >+ */ >+ >+public abstract class CompilationProgress { >+ >+ /** >+ * Notifies that the compilation is beginning. This is called exactly once per batch compilation. >+ * An estimated amount of remaining work is given. This amount will change as the compilation >+ * progresses. The new estimated amount of remaining work is reported using {@link #worked(int, int)}. >+ * <p> >+ * Clients should not call this method. >+ * </p> >+ * >+ * @param remainingWork the estimated amount of remaining work. >+ */ >+ public abstract void begin(int remainingWork); >+ >+ /** >+ * Notifies that the work is done; that is, either the compilation is completed >+ * or a cancellation was requested. This is called exactly once per batch compilation. >+ * <p> >+ * Clients should not call this method. >+ * </p> >+ */ >+ public abstract void done(); >+ >+ /** >+ * Returns whether cancellation of the compilation has been requested. >+ * >+ * @return <code>true</code> if cancellation has been requested, >+ * and <code>false</code> otherwise >+ */ >+ public abstract boolean isCanceled(); >+ >+ /** >+ * Reports the name (or description) of the current task. >+ * <p> >+ * Clients should not call this method. >+ * </p> >+ * >+ * @param name the name (or description) of the current task >+ */ >+ public abstract void setTaskName(String name); >+ >+ >+ /** >+ * Notifies that a given amount of work of the compilation >+ * has been completed. Note that this amount represents an >+ * installment, as opposed to a cumulative amount of work done >+ * to date. >+ * Also notifies an estimated amount of remaining work. Note that this >+ * amount of remaining work may be greater than the previous estimated >+ * amount as new compilation units are injected in the compile loop. >+ * <p> >+ * Clients should not call this method. >+ * </p> >+ * >+ * @param workIncrement a non-negative amount of work just completed >+ * @param remainingWork a non-negative amount of estimated remaining work >+ */ >+ public abstract void worked(int workIncrement, int remainingWork); >+ >+ >+} >Index: batch/org/eclipse/jdt/core/compiler/batch/BatchCompiler.java >=================================================================== >RCS file: batch/org/eclipse/jdt/core/compiler/batch/BatchCompiler.java >diff -N batch/org/eclipse/jdt/core/compiler/batch/BatchCompiler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ batch/org/eclipse/jdt/core/compiler/batch/BatchCompiler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,48 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.core.compiler.batch; >+ >+import java.io.PrintWriter; >+ >+import org.eclipse.jdt.core.compiler.CompilationProgress; >+import org.eclipse.jdt.internal.compiler.batch.Main; >+ >+/** >+ * A public API for invoking the Eclipse Compiler for Java. E.g. >+ * <pre> >+ * BatchCompiler.compile("C:\\mySources\\X.java -d C:\\myOutput", new PrintWriter(System.out), new PrintWriter(System.err), null); >+ * </pre> >+ * <p> >+ * This class is not intended to be instantiated or subclassed by clients. >+ * </p> >+ * >+ * @since 3.4 >+ */ >+public final class BatchCompiler { >+ >+ /** >+ * Invoke 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. >+ * <p> >+ * The specification of the command line argument 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 Main.compile(commandLine, outWriter, errWriter, progress); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 217233
:
92829
|
92871
|
93047