当前位置: 首页>>代码示例>>Java>>正文


Java CompilerOptions类代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.compiler.impl.CompilerOptions的典型用法代码示例。如果您正苦于以下问题:Java CompilerOptions类的具体用法?Java CompilerOptions怎么用?Java CompilerOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CompilerOptions类属于org.eclipse.jdt.internal.compiler.impl包,在下文中一共展示了CompilerOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setSourceLevel

import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; //导入依赖的package包/类
/**
 * sets the source level (see @link(org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants))
 */
private void setSourceLevel(final long jdkVersion) {
  try {
    this.compilerOptions.sourceLevel = jdkVersion;
    try {
      CompilerOptions.class.getField("originalSourceLevel").setLong(this.compilerOptions, jdkVersion);
    } catch (final Throwable _t) {
      if (_t instanceof NoSuchFieldException) {
      } else {
        throw Exceptions.sneakyThrow(_t);
      }
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:InMemoryJavaCompiler.java

示例2: setComplianceLevel

import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; //导入依赖的package包/类
/**
 * sets the compliance level (see @link(org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants))
 */
private void setComplianceLevel(final long jdkVersion) {
  try {
    this.compilerOptions.complianceLevel = jdkVersion;
    try {
      CompilerOptions.class.getField("originalComplianceLevel").setLong(this.compilerOptions, jdkVersion);
    } catch (final Throwable _t) {
      if (_t instanceof NoSuchFieldException) {
      } else {
        throw Exceptions.sneakyThrow(_t);
      }
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:InMemoryJavaCompiler.java

示例3: ecjCompilerOptions

import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; //导入依赖的package包/类
protected CompilerOptions ecjCompilerOptions() {
	CompilerOptions options = new CompilerOptions();
	options.complianceLevel = Eclipse.getLatestEcjCompilerVersionConstant();
	options.sourceLevel = Eclipse.getLatestEcjCompilerVersionConstant();
	options.targetJDK = Eclipse.getLatestEcjCompilerVersionConstant();
	options.docCommentSupport = false;
	options.parseLiteralExpressionsAsConstants = true;
	options.inlineJsrBytecode = true;
	options.reportUnusedDeclaredThrownExceptionExemptExceptionAndThrowable = false;
	options.reportUnusedDeclaredThrownExceptionIncludeDocCommentReference = false;
	options.reportUnusedDeclaredThrownExceptionWhenOverriding = false;
	options.reportUnusedParameterIncludeDocCommentReference = false;
	options.reportUnusedParameterWhenImplementingAbstract = false;
	options.reportUnusedParameterWhenOverridingConcrete = false;
	options.reportDeadCodeInTrivialIfStatement = false;
	options.generateClassFiles = false;
	Map<String, String> warnings = new HashMap<String, String>();
	warnings.put(CompilerOptions.OPTION_ReportUnusedLocal, "ignore");
	warnings.put(CompilerOptions.OPTION_ReportUnusedLabel, "ignore");
	warnings.put(CompilerOptions.OPTION_ReportUnusedImport, "ignore");
	warnings.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, "ignore");
	warnings.put(CompilerOptions.OPTION_Source, "1." + Eclipse.getEcjCompilerVersion());
	options.set(warnings);
	return options;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:26,代码来源:RunTestsViaEcj.java

示例4: performCompilation

import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; //导入依赖的package包/类
@Override
public void performCompilation() {
    if(environment == null) {
        environment = this.getLibraryAccess();
    }

    this.startTime = System.currentTimeMillis();
    this.compilerOptions = new CompilerOptions(this.options);
    this.compilerOptions.performMethodsFullRecovery = false;
    this.compilerOptions.performStatementsRecovery = false;
    this.batchCompiler = new Compiler(environment, this.getHandlingPolicy(), this.compilerOptions, this.getBatchRequestor(), this.getProblemFactory(), this.out, this.progress);
    this.batchCompiler.remainingIterations = this.maxRepetition - this.currentRepetition;
    String setting = System.getProperty("jdt.compiler.useSingleThread");
    this.batchCompiler.useSingleThread = setting != null && setting.equals("true");

    this.compilerOptions.verbose = this.verbose;
    this.compilerOptions.produceReferenceInfo = this.produceRefInfo;

    try {
        this.logger.startLoggingSources();
        this.batchCompiler.compile(this.getCompilationUnits());
    } finally {
        this.logger.endLoggingSources();
    }
    this.logger.printStats();
}
 
开发者ID:STAMP-project,项目名称:dspot,代码行数:27,代码来源:DSpotJDTBatchCompiler.java

示例5: isValidEcj

import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; //导入依赖的package包/类
private static boolean isValidEcj() {
    // When this test is run from within Gradle's testing infrastructure, e.g.
    // via "./gradlew :base:gradle-core:test", Gradle's own *internal* dependencies
    // somehow end up on the classpath, and in particular, an ancient version of
    // (ECJ (3.x)) take priority over our explicit lint dependency which should
    // bring in ECJ 4.
    //
    // This causes the test to fail. For now, make the test only run when a valid
    // ECJ is present.
    try {
        CompilerOptions.class.getField("originalComplianceLevel");
        return true;
    } catch (Throwable t) {
        return false;
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ExtractAnnotationsDriverTest.java

示例6: parse

import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; //导入依赖的package包/类
@Nullable
private static Node parse(String code) {
  CompilerOptions options = new CompilerOptions();
  options.complianceLevel = options.sourceLevel = options.targetJDK = ClassFileConstants.JDK1_7;
  options.parseLiteralExpressionsAsConstants = true;
  ProblemReporter problemReporter = new ProblemReporter(
    DefaultErrorHandlingPolicies.exitOnFirstError(), options, new DefaultProblemFactory());
  Parser parser = new Parser(problemReporter, options.parseLiteralExpressionsAsConstants);
  parser.javadocParser.checkDocComment = false;
  EcjTreeConverter converter = new EcjTreeConverter();
  org.eclipse.jdt.internal.compiler.batch.CompilationUnit sourceUnit =
    new org.eclipse.jdt.internal.compiler.batch.CompilationUnit(code.toCharArray(), "unitTest", "UTF-8");
  CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
  CompilationUnitDeclaration unit = parser.parse(sourceUnit, compilationResult);
  if (unit == null) {
    return null;
  }
  converter.visit(code, unit);
  List<? extends Node> nodes = converter.getAll();
  for (lombok.ast.Node node : nodes) {
    if (node instanceof lombok.ast.CompilationUnit) {
      return node;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:LombokPsiConverterTest.java

示例7: BaseTest

import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; //导入依赖的package包/类
public BaseTest() {
  options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_8);
  options.put(JavaCore.CORE_ENCODING, "UTF-8");
  options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8);
  options.put(CompilerOptions.OPTION_TargetPlatform, JavaCore.VERSION_1_8);
  options.put(AssistOptions.OPTION_PerformVisibilityCheck, AssistOptions.ENABLED);
  options.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING);
  options.put(CompilerOptions.OPTION_TaskTags, CompilerOptions.WARNING);
  options.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.WARNING);
  options.put(CompilerOptions.OPTION_SuppressWarnings, CompilerOptions.DISABLED);
  options.put(JavaCore.COMPILER_TASK_TAGS, "TODO,FIXME,XXX");
  options.put(
      JavaCore.COMPILER_PB_UNUSED_PARAMETER_INCLUDE_DOC_COMMENT_REFERENCE, JavaCore.ENABLED);
  options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED);
  options.put(CompilerOptions.OPTION_Process_Annotations, JavaCore.DISABLED);
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:BaseTest.java

示例8: getSourceElementParser

import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; //导入依赖的package包/类
public SourceElementParser getSourceElementParser(
    IJavaProject project, ISourceElementRequestor requestor) {
  // disable task tags to speed up parsing
  Map options = project.getOptions(true);
  options.put(JavaCore.COMPILER_TASK_TAGS, ""); // $NON-NLS-1$
  try {
    SourceElementParser parser =
        new IndexingParser(
            requestor,
            new DefaultProblemFactory(Locale.getDefault()),
            new CompilerOptions(options),
            true, // index local declarations
            true, // optimize string literals
            false); // do not use source javadoc parser to speed up parsing
    parser.reportOnlyOneSyntaxError = true;

    // Always check javadoc while indexing
    parser.javadocParser.checkDocComment = true;
    parser.javadocParser.reportProblems = false;

    return parser;
  } catch (Exception e) {
    e.printStackTrace();
    return null;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:IndexManager.java

示例9: process

import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; //导入依赖的package包/类
@Override public ASTNode process(Source in, Void irrelevant) throws ConversionProblem {
	CompilerOptions compilerOptions = ecjCompilerOptions();
	Parser parser = new Parser(new ProblemReporter(
			DefaultErrorHandlingPolicies.proceedWithAllProblems(),
			compilerOptions,
			new DefaultProblemFactory()
		), compilerOptions.parseLiteralExpressionsAsConstants);
	parser.javadocParser.checkDocComment = true;
	CompilationUnit sourceUnit = new CompilationUnit(in.getRawInput().toCharArray(), in.getName(), charset.name());
	CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
	CompilationUnitDeclaration cud = parser.parse(sourceUnit, compilationResult);
	
	if (cud.hasErrors()) {
		throw new ConversionProblem(String.format("Can't read file %s due to parse error: %s", in.getName(), compilationResult.getErrors()[0]));
	}
	
	return cud;
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:19,代码来源:Main.java

示例10: createDefaultProblemReporter

import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; //导入依赖的package包/类
private static ProblemReporter createDefaultProblemReporter(CompilerOptions options) {
	return new ProblemReporter(new IErrorHandlingPolicy() {
		public boolean proceedOnErrors() {
			return true;
		}
		
		public boolean stopOnFirstError() {
			return false;
		}
		
		@Override
		public boolean ignoreAllErrors() {
			return false;
		}
	}, options, new DefaultProblemFactory(Locale.ENGLISH));
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:17,代码来源:EcjTreeBuilder.java

示例11: createSilentProblemReporter

import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; //导入依赖的package包/类
private static ProblemReporter createSilentProblemReporter(CompilerOptions options) {
	return new ProblemReporter(new IErrorHandlingPolicy() {
		public boolean proceedOnErrors() {
			return true;
		}
		
		public boolean stopOnFirstError() {
			return false;
		}
		
		@Override
		public boolean ignoreAllErrors() {
			return false;
		}
	}, options, SILENT_PROBLEM_FACTORY);
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:17,代码来源:EcjTreeBuilder.java

示例12: parseWithLombok

import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; //导入依赖的package包/类
@Override
protected ASTNode parseWithLombok(Source source) {
	CompilerOptions compilerOptions = ecjCompilerOptions();
	Parser parser = new Parser(new ProblemReporter(
			DefaultErrorHandlingPolicies.proceedWithAllProblems(),
			compilerOptions,
			new DefaultProblemFactory()
		), compilerOptions.parseLiteralExpressionsAsConstants);
	parser.javadocParser.checkDocComment = true;
	CompilationUnit sourceUnit = new CompilationUnit(source.getRawInput().toCharArray(), source.getName(), "UTF-8");
	CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
	CompilationUnitDeclaration cud = parser.parse(sourceUnit, compilationResult);
	
	if (cud.hasErrors()) return null;
	
	EcjTreeConverter converter = new EcjTreeConverter();
	converter.visit(source.getRawInput(), cud);
	Node lombokized = converter.get();
	
	EcjTreeBuilder builder = new EcjTreeBuilder(source.getRawInput(), source.getName(), ecjCompilerOptions());
	builder.visit(lombokized);
	return builder.get();
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:24,代码来源:EcjTreeConverterType2Test.java

示例13: parseWithTargetCompiler

import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; //导入依赖的package包/类
@Override
protected ASTNode parseWithTargetCompiler(Source source) {
	CompilerOptions compilerOptions = ecjCompilerOptions();
	Parser parser = new Parser(new ProblemReporter(
			DefaultErrorHandlingPolicies.proceedWithAllProblems(),
			compilerOptions,
			new DefaultProblemFactory()
		), compilerOptions.parseLiteralExpressionsAsConstants);
	parser.javadocParser.checkDocComment = true;
	CompilationUnit sourceUnit = new CompilationUnit(source.getRawInput().toCharArray(), source.getName(), "UTF-8");
	CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
	CompilationUnitDeclaration cud = parser.parse(sourceUnit, compilationResult);
	
	if (cud.hasErrors()) return null;
	
	return cud;
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:18,代码来源:EcjTreeConverterType2Test.java

示例14: parseWithTargetCompiler

import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; //导入依赖的package包/类
@Override
protected ASTNode parseWithTargetCompiler(Source source) {
	CompilerOptions compilerOptions = ecjCompilerOptions();
	Parser parser = new Parser(new ProblemReporter(
			DefaultErrorHandlingPolicies.proceedWithAllProblems(),
			compilerOptions,
			new DefaultProblemFactory()
		), compilerOptions.parseLiteralExpressionsAsConstants);
	parser.javadocParser.checkDocComment = true;
	CompilationUnit sourceUnit = new CompilationUnit(source.getRawInput().toCharArray(), source.getName(), "UTF-8");
	CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
	CompilationUnitDeclaration cud = parser.parse(sourceUnit, compilationResult);
	
	if (cud.hasErrors()) return null;
	return cud;
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:17,代码来源:EcjTreeBuilderTest.java

示例15: parseWithTargetCompiler

import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; //导入依赖的package包/类
protected Node parseWithTargetCompiler(Source source) {
	CompilerOptions compilerOptions = ecjCompilerOptions();
	Parser parser = new Parser(new ProblemReporter(
			DefaultErrorHandlingPolicies.proceedWithAllProblems(),
			compilerOptions,
			new DefaultProblemFactory()
		), compilerOptions.parseLiteralExpressionsAsConstants);
	parser.javadocParser.checkDocComment = true;
	CompilationUnit sourceUnit = new CompilationUnit(source.getRawInput().toCharArray(), source.getName(), "UTF-8");
	CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
	CompilationUnitDeclaration cud = parser.parse(sourceUnit, compilationResult);
	
	if (cud.hasErrors()) return null;
	
	EcjTreeConverter converter = new EcjTreeConverter();
	converter.visit(source.getRawInput(), cud);
	return converter.get();
}
 
开发者ID:evant,项目名称:android-retrolambda-lombok,代码行数:19,代码来源:EcjTreeConverterType1Test.java


注:本文中的org.eclipse.jdt.internal.compiler.impl.CompilerOptions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。