protected static CompilerOptions getCompilerOptions(Map options, boolean statementsRecovery) { CompilerOptions compilerOptions = new CompilerOptions(options); compilerOptions.performMethodsFullRecovery = statementsRecovery; compilerOptions.performStatementsRecovery = statementsRecovery; compilerOptions.parseLiteralExpressionsAsConstants = false; compilerOptions.storeAnnotations = true /*store annotations in the bindings*/; compilerOptions.ignoreSourceFolderWarningOption = true; return compilerOptions; } /*
protected static CompilerOptions getCompilerOptions(Map settings, boolean creatingAST, boolean statementsRecovery) { CompilerOptions compilerOptions = new CompilerOptions(settings); compilerOptions.performMethodsFullRecovery = statementsRecovery; compilerOptions.performStatementsRecovery = statementsRecovery; compilerOptions.parseLiteralExpressionsAsConstants = !creatingAST; /*parse literal expressions as constants only if not creating a DOM AST*/ compilerOptions.storeAnnotations = creatingAST; /*store annotations in the bindings if creating a DOM AST*/ return compilerOptions; }
protected CompilerOptions ecjCompilerOptions() { CompilerOptions options = new CompilerOptions(); options.complianceLevel = ClassFileConstants.JDK1_6; options.sourceLevel = ClassFileConstants.JDK1_6; options.targetJDK = ClassFileConstants.JDK1_6; options.parseLiteralExpressionsAsConstants = true; return options; }
public static CompilerOptions getDefaultCompilerOptions() { String javaSpecVersion = System.getProperty("java.specification.version"); if (javaSpecVersion.equals("1.8")) { javaSpecVersion = "1.7"; } Map<String, Object> settings = Maps.newHashMap(); settings.put(CompilerOptions.OPTION_Source, javaSpecVersion); settings.put(CompilerOptions.OPTION_TargetPlatform, javaSpecVersion); settings.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.IGNORE); return new CompilerOptions(settings); }
public EclipseCompiler() { Map<String, String> settings = new HashMap<String, String>(); settings.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.GENERATE); settings.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); settings.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); settings.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE); settings.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE); settings.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE); compilerOptions = new CompilerOptions(settings); }
/** * Creates a new parser. */ protected DocumentElementParser getParser(Map settings) { return new DocumentElementParser(this, new DefaultProblemFactory(), new CompilerOptions(settings)); } /**
private Parser getParser() { Map<String,String> opts = new HashMap<String, String>(); opts.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_9); return new Parser( new ProblemReporter(DefaultErrorHandlingPolicies.exitOnFirstError(), new CompilerOptions(opts), new DefaultProblemFactory(Locale.getDefault())), false); } @Override
public InMemoryJavaCompiler(final ClassLoader parent, final CompilerOptions compilerOptions) { InMemoryJavaCompiler.ClassLoaderBasedNameEnvironment _classLoaderBasedNameEnvironment = new InMemoryJavaCompiler.ClassLoaderBasedNameEnvironment(parent); this.nameEnv = _classLoaderBasedNameEnvironment; this.parentClassLoader = parent; Map<String, String> _map = compilerOptions.getMap(); CompilerOptions _compilerOptions = new CompilerOptions(_map); this.compilerOptions = _compilerOptions; }
private ScanContext getScanContext(int begin) { if (!isInModuleDeclaration()) return ScanContext.INACTIVE; if (begin == 0) return ScanContext.EXPECTING_KEYWORD; CompilerOptions options = new CompilerOptions(); options.complianceLevel = this.complianceLevel; options.sourceLevel = this.sourceLevel; ScanContextDetector parser = new ScanContextDetector(options); return parser.getScanContext(this.source, begin - 1); }
private ScanContext getScanContext(int begin) { if (!isInModuleDeclaration()) return ScanContext.INACTIVE; if (begin == 0) return ScanContext.EXPECTING_KEYWORD; CompilerOptions options = new CompilerOptions(); options.complianceLevel = this.complianceLevel; options.sourceLevel = this.sourceLevel; ScanContextDetector parser = new ScanContextDetector(options); return parser.getScanContext(this.source, begin - 1); }
public Engine(Map<String, String> settings){ this.options = new AssistOptions(settings); this.compilerOptions = new CompilerOptions(settings); this.forbiddenReferenceIsError = (this.compilerOptions.getSeverity(CompilerOptions.ForbiddenReference) & ProblemSeverities.Error) != 0; this.discouragedReferenceIsError = (this.compilerOptions.getSeverity(CompilerOptions.DiscouragedReference) & ProblemSeverities.Error) != 0; }
public Engine(Map settings){ this.options = new AssistOptions(settings); this.compilerOptions = new CompilerOptions(settings); this.forbiddenReferenceIsError = (this.compilerOptions.getSeverity(CompilerOptions.ForbiddenReference) & ProblemSeverities.Error) != 0; this.discouragedReferenceIsError = (this.compilerOptions.getSeverity(CompilerOptions.DiscouragedReference) & ProblemSeverities.Error) != 0; }
environment = getLibraryAccess(); CompilerOptions compilerOptions = new CompilerOptions(this.options); compilerOptions.parseLiteralExpressionsAsConstants = false;
public HierarchyResolver(INameEnvironment nameEnvironment, Map settings, HierarchyBuilder builder, IProblemFactory problemFactory) { // create a problem handler with the 'exit after all problems' handling policy this.options = new CompilerOptions(settings); IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.exitAfterAllProblems(); ProblemReporter problemReporter = new ProblemReporter(policy, this.options, problemFactory); LookupEnvironment environment = new LookupEnvironment(this, this.options, problemReporter, nameEnvironment); environment.mayTolerateMissingType = true; setEnvironment(environment, builder); } public HierarchyResolver(LookupEnvironment lookupEnvironment, HierarchyBuilder builder) {
public HierarchyResolver(INameEnvironment nameEnvironment, Map settings, HierarchyBuilder builder, IProblemFactory problemFactory) { // create a problem handler with the 'exit after all problems' handling policy this.options = new CompilerOptions(settings); IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.exitAfterAllProblems(); ProblemReporter problemReporter = new ProblemReporter(policy, this.options, problemFactory); LookupEnvironment environment = new LookupEnvironment(this, this.options, problemReporter, nameEnvironment); environment.mayTolerateMissingType = true; setEnvironment(environment, builder); } public HierarchyResolver(LookupEnvironment lookupEnvironment, HierarchyBuilder builder) {
public HierarchyResolver(INameEnvironment nameEnvironment, Map settings, HierarchyBuilder builder, IProblemFactory problemFactory) { // create a problem handler with the 'exit after all problems' handling policy this.options = new CompilerOptions(settings); IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.exitAfterAllProblems(); ProblemReporter problemReporter = new ProblemReporter(policy, this.options, problemFactory); LookupEnvironment environment = new LookupEnvironment(this, this.options, problemReporter, nameEnvironment); environment.mayTolerateMissingType = true; setEnvironment(environment, builder); } public HierarchyResolver(LookupEnvironment lookupEnvironment, HierarchyBuilder builder) {
public HierarchyResolver(INameEnvironment nameEnvironment, Map settings, HierarchyBuilder builder, IProblemFactory problemFactory) { // create a problem handler with the 'exit after all problems' handling policy this.options = new CompilerOptions(settings); IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.exitAfterAllProblems(); ProblemReporter problemReporter = new ProblemReporter(policy, this.options, problemFactory); setEnvironment( new LookupEnvironment(this, this.options, problemReporter, nameEnvironment), builder); } public HierarchyResolver(LookupEnvironment lookupEnvironment, HierarchyBuilder builder) {
private Parser getParser() { if (this.parser == null) { this.compilerOptions = new CompilerOptions(JavaCore.getOptions()); ProblemReporter problemReporter = new ProblemReporter( DefaultErrorHandlingPolicies.proceedWithAllProblems(), this.compilerOptions, new DefaultProblemFactory()); this.parser = new Parser(problemReporter, true); } return this.parser; }
static class IntArrayList { public int[] list = new int[5]; public int length = 0; public void add(int i) { if (this.list.length == this.length) { System.arraycopy(this.list, 0, this.list = new int[this.length*2], 0, this.length); } this.list[this.length++] = i; } }
static class IntArrayList { public int[] list = new int[5]; public int length = 0; public void add(int i) { if (this.list.length == this.length) { System.arraycopy(this.list, 0, this.list = new int[this.length*2], 0, this.length); } this.list[this.length++] = i; } }