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


Java JavaCore.setOptions方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.JavaCore.setOptions方法的典型用法代码示例。如果您正苦于以下问题:Java JavaCore.setOptions方法的具体用法?Java JavaCore.setOptions怎么用?Java JavaCore.setOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.JavaCore的用法示例。


在下文中一共展示了JavaCore.setOptions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: build

import org.eclipse.jdt.core.JavaCore; //导入方法依赖的package包/类
/**
 * Start a build on given project or workspace using given options.
 * 
 * @param javaProject Project which must be (full) build or null if all
 * workspace has to be built.
 * @param options Options used while building
 */
void build(final IJavaProject javaProject, Hashtable options, boolean noWarning) throws IOException, CoreException {
  if (DEBUG)
    System.out.print("\tstart build...");
  JavaCore.setOptions(options);
  if (PRINT)
    System.out.println("JavaCore options: " + options);

  // Build workspace if no project
  if (javaProject == null) {
    // single measure
    ENV.fullBuild();
  } else {
    if (PRINT)
      System.out.println("Project options: " + javaProject.getOptions(false));
    IWorkspaceRunnable compilation = new IWorkspaceRunnable() {
      public void run(IProgressMonitor monitor) throws CoreException {
        ENV.fullBuild(javaProject.getPath());
      }
    };
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    workspace.run(compilation, null/* don't take any lock */, IWorkspace.AVOID_UPDATE, null/*
                                                                                            * no
                                                                                            * progress
                                                                                            * available
                                                                                            * here
                                                                                            */);
  }

  // Verify markers
  IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
  IMarker[] markers = workspaceRoot.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
  List resources = new ArrayList();
  List messages = new ArrayList();
  int warnings = 0;
  for (int i = 0, length = markers.length; i < length; i++) {
    IMarker marker = markers[i];
    switch (((Integer) marker.getAttribute(IMarker.SEVERITY)).intValue()) {
    case IMarker.SEVERITY_ERROR:
      resources.add(marker.getResource().getName());
      messages.add(marker.getAttribute(IMarker.MESSAGE));
      break;
    case IMarker.SEVERITY_WARNING:
      warnings++;
      if (noWarning) {
        resources.add(marker.getResource().getName());
        messages.add(marker.getAttribute(IMarker.MESSAGE));
      }
      break;
    }
  }
  workspaceRoot.deleteMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);

  // Assert result
  int size = messages.size();
  if (size > 0) {
    StringBuffer debugBuffer = new StringBuffer();
    for (int i = 0; i < size; i++) {
      debugBuffer.append(resources.get(i));
      debugBuffer.append(":\n\t");
      debugBuffer.append(messages.get(i));
      debugBuffer.append('\n');
    }
    System.out.println("Unexpected ERROR marker(s):\n" + debugBuffer.toString());
    System.out.println("--------------------");
    String target = javaProject == null ? "workspace" : javaProject.getElementName();
    // assertEquals("Found "+size+" unexpected errors while building "+target,
    // 0, size);
  }
  if (DEBUG)
    System.out.println("done");
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:79,代码来源:FullSourceWorkspaceBuildTests.java


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