import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit;
import net.sourceforge.phpdt.internal.compiler.env.INameEnvironment;
import net.sourceforge.phpdt.internal.compiler.env.ISourceType;
+import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions;
import net.sourceforge.phpdt.internal.compiler.impl.ITypeRequestor;
import net.sourceforge.phpdt.internal.compiler.lookup.LookupEnvironment;
import net.sourceforge.phpdt.internal.compiler.lookup.PackageBinding;
public class Compiler implements ITypeRequestor, ProblemSeverities {
public UnitParser parser;
public ICompilerRequestor requestor;
- // public CompilerOptions options;
+ public CompilerOptions options;
public ProblemReporter problemReporter;
// management of unit to be processed
//public CompilationUnitResult currentCompilationUnitResult;
// name lookup
public LookupEnvironment lookupEnvironment;
// ONCE STABILIZED, THESE SHOULD RETURN TO A FINAL FIELD
- public static boolean DEBUG = false;
+ public static boolean DEBUG = true;
public int parseThreshold = -1;
// number of initial units parsed at once (-1: none)
/*
* problems, the compiler will gather them all and hand them back
* as part of the compilation unit result.
*/
- public Compiler(INameEnvironment environment, IErrorHandlingPolicy policy,
- // Map settings,
- final ICompilerRequestor requestor, IProblemFactory problemFactory) {
+ public Compiler(INameEnvironment environment, IErrorHandlingPolicy policy,
+ Map settings, final ICompilerRequestor requestor,
+ IProblemFactory problemFactory) {
// create a problem handler given a handling policy
- // this.options = new CompilerOptions(settings);
+ this.options = new CompilerOptions(settings);
// wrap requestor in DebugRequestor if one is specified
// if(DebugRequestor == null) {
this.requestor = requestor;
// }
// };
// }
- this.problemReporter = new ProblemReporter(policy, problemFactory);//this.options,
- // problemFactory);
+ this.problemReporter = new ProblemReporter(policy, this.options,
+ problemFactory);
this.lookupEnvironment = new LookupEnvironment(this, problemReporter,
environment); //options, problemReporter, environment);
this.parser = new UnitParser(problemReporter);
* literals or leave them as they are in the source. If you put
* true, "Hello" + " world" will be converted to "Hello world".
*/
- public Compiler(INameEnvironment environment, IErrorHandlingPolicy policy,
- // Map settings,
- final ICompilerRequestor requestor, IProblemFactory problemFactory,
- boolean parseLiteralExpressionsAsConstants) {
+ public Compiler(INameEnvironment environment, IErrorHandlingPolicy policy,
+ Map settings, final ICompilerRequestor requestor,
+ IProblemFactory problemFactory, boolean parseLiteralExpressionsAsConstants) {
// create a problem handler given a handling policy
- // this.options = new CompilerOptions(settings);
+ this.options = new CompilerOptions(settings);
// wrap requestor in DebugRequestor if one is specified
// if(DebugRequestor == null) {
this.requestor = requestor;
// }
// };
// }
- this.problemReporter = new ProblemReporter(policy, problemFactory);//,
- // this.options,
- // problemFactory);
+ this.problemReporter = new ProblemReporter(policy, this.options,
+ problemFactory);
this.lookupEnvironment = new LookupEnvironment(this, problemReporter,
environment);//options, problemReporter, environment);
this.parser = new UnitParser(problemReporter);
// Switch the current policy and compilation result for this unit to the
// requested one.
CompilationResult unitResult = new CompilationResult(sourceUnit,
- totalUnits, totalUnits, 10); //this.options.maxProblemsPerUnit);
+ totalUnits, totalUnits, this.options.maxProblemsPerUnit);
try {
// diet parsing for large collection of unit
CompilationUnitDeclaration parsedUnit;
} else {
parsedUnit = parser.dietParse(sourceUnit, unitResult);
}
- // if (options.verbose) {
- // String count = String.valueOf(totalUnits + 1);
- // System.out.println(
- // Util.bind(
- // "compilation.request" , //$NON-NLS-1$
- // new String[] {
- // count,
- // count,
- // new String(sourceUnit.getFileName())}));
- // }
+ if (options.verbose) {
+ String count = String.valueOf(totalUnits + 1);
+ System.out.println(Util.bind("compilation.request", //$NON-NLS-1$
+ new String[]{count, count, new String(sourceUnit.getFileName())}));
+ }
// initial type binding creation
lookupEnvironment.buildTypeBindings(parsedUnit);
this.addCompilationUnit(sourceUnit, parsedUnit);
for (int i = 0; i < maxUnits; i++) {
CompilationUnitDeclaration parsedUnit;
CompilationResult unitResult = new CompilationResult(sourceUnits[i], i,
- maxUnits, 10);//, this.options.maxProblemsPerUnit);
+ maxUnits, this.options.maxProblemsPerUnit);
try {
// diet parsing for large collection of units
if (totalUnits < parseThreshold) {
} else {
parsedUnit = parser.dietParse(sourceUnits[i], unitResult);
}
- // if (options.verbose) {
- // System.out.println(
- // Util.bind(
- // "compilation.request" , //$NON-NLS-1$
- // new String[] {
- // String.valueOf(i + 1),
- // String.valueOf(maxUnits),
- // new String(sourceUnits[i].getFileName())}));
- // }
+ if (options.verbose) {
+ System.out.println(Util.bind("compilation.request", //$NON-NLS-1$
+ new String[]{String.valueOf(i + 1), String.valueOf(maxUnits),
+ new String(sourceUnits[i].getFileName())}));
+ }
// initial type binding creation
-// lookupEnvironment.buildTypeBindings(parsedUnit);
+ // lookupEnvironment.buildTypeBindings(parsedUnit);
this.addCompilationUnit(sourceUnits[i], parsedUnit);
//} catch (AbortCompilationUnit e) {
//requestor.acceptResult(unitResult.tagAsAccepted());
for (; i < totalUnits; i++) {
unit = unitsToProcess[i];
try {
- // if (options.verbose)
- // System.out.println(
- // Util.bind(
- // "compilation.process" , //$NON-NLS-1$
- // new String[] {
- // String.valueOf(i + 1),
- // String.valueOf(totalUnits),
- // new String(unitsToProcess[i].getFileName())}));
+ if (options.verbose)
+ System.out.println(Util.bind("compilation.process", //$NON-NLS-1$
+ new String[]{String.valueOf(i + 1), String.valueOf(totalUnits),
+ new String(unitsToProcess[i].getFileName())}));
process(unit, i);
} finally {
// cleanup compilation unit result
unit.cleanUp();
- // if (options.verbose)
- // System.out.println(Util.bind("compilation.done", //$NON-NLS-1$
- // new String[] {
- // String.valueOf(i + 1),
- // String.valueOf(totalUnits),
- // new String(unitsToProcess[i].getFileName())}));
+ if (options.verbose)
+ System.out.println(Util.bind("compilation.done", //$NON-NLS-1$
+ new String[]{String.valueOf(i + 1), String.valueOf(totalUnits),
+ new String(unitsToProcess[i].getFileName())}));
}
unitsToProcess[i] = null; // release reference to processed unit
- // declaration
+ // declaration
requestor.acceptResult(unit.compilationResult.tagAsAccepted());
}
- } catch (AbortCompilation e) {
+ } catch (AbortCompilation e) {
this.handleInternalException(e, unit);
} catch (Error e) {
this.handleInternalException(e, unit, null);
*/
public void process(CompilationUnitDeclaration unit, int i) {
getMethodBodies(unit, i);
- // fault in fields & methods
- if (unit.scope != null)
+ // fault in fields & methods
+ if (unit.scope != null)
unit.scope.faultInTypes();
// verify inherited methods
-// if (unit.scope != null)
-// unit.scope.verifyMethods(lookupEnvironment.methodVerifier());
+ // if (unit.scope != null)
+ // unit.scope.verifyMethods(lookupEnvironment.methodVerifier());
// type checking
unit.resolve();
// flow analysis
// if (generateCode) unit.generateCode();
}
unitsToProcess[0] = null; // release reference to processed unit
- // declaration
+ // declaration
requestor.acceptResult(unit.compilationResult.tagAsAccepted());
return unit;
} catch (AbortCompilation e) {