當前位置: 首頁>>代碼示例>>Java>>正文


Java JavaCore.getOptions方法代碼示例

本文整理匯總了Java中org.eclipse.jdt.core.JavaCore.getOptions方法的典型用法代碼示例。如果您正苦於以下問題:Java JavaCore.getOptions方法的具體用法?Java JavaCore.getOptions怎麽用?Java JavaCore.getOptions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jdt.core.JavaCore的用法示例。


在下文中一共展示了JavaCore.getOptions方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parse

import org.eclipse.jdt.core.JavaCore; //導入方法依賴的package包/類
public void parse() throws ParseException {
    ASTParser parser = ASTParser.newParser(AST.JLS8);
    parser.setSource(source.toCharArray());
    Map<String, String> options = JavaCore.getOptions();
    options.put("org.eclipse.jdt.core.compiler.source", "1.8");
    parser.setCompilerOptions(options);
    parser.setKind(ASTParser.K_COMPILATION_UNIT);
    parser.setUnitName("Program.java");
    parser.setEnvironment(new String[] { classpath != null? classpath : "" },
            new String[] { "" }, new String[] { "UTF-8" }, true);
    parser.setResolveBindings(true);
    cu = (CompilationUnit) parser.createAST(null);

    List<IProblem> problems = Arrays.stream(cu.getProblems()).filter(p ->
                                        p.isError() &&
                                        p.getID() != IProblem.PublicClassMustMatchFileName && // we use "Program.java"
                                        p.getID() != IProblem.ParameterMismatch // Evidence varargs
                                    ).collect(Collectors.toList());
    if (problems.size() > 0)
        throw new ParseException(problems);
}
 
開發者ID:capergroup,項目名稱:bayou,代碼行數:22,代碼來源:Parser.java

示例2: createCompilationUnitParser

import org.eclipse.jdt.core.JavaCore; //導入方法依賴的package包/類
private static ASTParser createCompilationUnitParser() {
  ASTParser parser = ASTParser.newParser(AST.JLS8);
  Map options = JavaCore.getOptions();
  JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, options);
  parser.setCompilerOptions(options);
  parser.setKind(ASTParser.K_COMPILATION_UNIT);
  return parser;
}
 
開發者ID:bazelbuild,項目名稱:BUILD_file_generator,代碼行數:9,代碼來源:ReferencedClassesParser.java

示例3: createProject

import org.eclipse.jdt.core.JavaCore; //導入方法依賴的package包/類
private synchronized IProject createProject(String projectName) {
  final IProject project = this.workspace.getRoot().getProject(projectName);

  Object cmpl = JavaCore.getOption(CompilerOptions.OPTION_Compliance);
  Object src  = JavaCore.getOption(CompilerOptions.OPTION_Source);
  Object tgt  = JavaCore.getOption(CompilerOptions.OPTION_TargetPlatform);

  try {
    IWorkspaceRunnable create = new IWorkspaceRunnable() {
      public void run(IProgressMonitor monitor) throws CoreException {
        project.create(null, null);
        project.open(null);
      }
    };
    this.workspace.run(create, null);
    this.projects.put(projectName, project);
    addBuilderSpecs(projectName);
  } catch (CoreException e) {
    handle(e);
  } finally {
    // restore workspace settings
    Hashtable options = JavaCore.getOptions();
    options.put(CompilerOptions.OPTION_Compliance,cmpl);
    options.put(CompilerOptions.OPTION_Source,src);
    options.put(CompilerOptions.OPTION_TargetPlatform,tgt);
    JavaCore.setOptions(options);
  }
  return project;
}
 
開發者ID:RuiChen08,項目名稱:dacapobench,代碼行數:30,代碼來源:TestingEnvironment.java

示例4: buildAstParser

import org.eclipse.jdt.core.JavaCore; //導入方法依賴的package包/類
private static ASTParser buildAstParser(String[] sourceFolders) {
	ASTParser parser = ASTParser.newParser(AST.JLS8);
	parser.setKind(ASTParser.K_COMPILATION_UNIT);
	Map options = JavaCore.getOptions();
	JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, options);
	parser.setCompilerOptions(options);
	parser.setResolveBindings(true);
	parser.setBindingsRecovery(true);
	parser.setEnvironment(new String[0], sourceFolders, null, true);
	// parser.setEnvironment(new String[0], new String[]{"tmp\\refactoring-toy-example\\src"}, null, false);
	return parser;
}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:13,代碼來源:SDModelBuilder.java

示例5: buildAstParser

import org.eclipse.jdt.core.JavaCore; //導入方法依賴的package包/類
private static ASTParser buildAstParser(String[] sourceFolders) {
	ASTParser parser = ASTParser.newParser(AST.JLS8);
	parser.setKind(ASTParser.K_COMPILATION_UNIT);
	Map options = JavaCore.getOptions();
	JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, options);
	parser.setCompilerOptions(options);
	parser.setResolveBindings(true);
	parser.setBindingsRecovery(true);
	parser.setEnvironment(new String[0], sourceFolders, null, true);
	//parser.setEnvironment(new String[0], new String[]{"tmp\\refactoring-toy-example\\src"}, null, false);
	return parser;
}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:13,代碼來源:SDModelBuilder.java

示例6: JavaSourceParser

import org.eclipse.jdt.core.JavaCore; //導入方法依賴的package包/類
private JavaSourceParser(String source, String className) {
	this.source = source.toCharArray();
	parser = ASTParser.newParser(AST.JLS8);
	parser.setResolveBindings(true);
	parser.setKind(ASTParser.K_COMPILATION_UNIT);		
	parser.setEnvironment(null, new String[] {}, new String[] {}, true);
	parser.setUnitName(className);
	parser.setSource(this.source);
	Map<String, String> options = JavaCore.getOptions();
	options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED);
	parser.setCompilerOptions(options);
}
 
開發者ID:andre-santos-pt,項目名稱:pandionj,代碼行數:13,代碼來源:JavaSourceParser.java

示例7: parse

import org.eclipse.jdt.core.JavaCore; //導入方法依賴的package包/類
/**
 * Parse the code and generate the JSON in outJ
 *
 * @param source String to parses
 * @return CompilationUnit of the AST
 * @throws IOException if anything related to I/O or Json generation failed
 */
public CompilationUnit parse(final String source) throws IOException {
    parser.setSource(source.toCharArray());
    Map options = JavaCore.getOptions();
    JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, options);
    parser.setCompilerOptions(options);
    return (CompilationUnit) parser.createAST(null);
}
 
開發者ID:bblfsh,項目名稱:java-driver,代碼行數:15,代碼來源:EclipseParser.java


注:本文中的org.eclipse.jdt.core.JavaCore.getOptions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。