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


Java CompilationUnitEditor.getEditorInput方法代码示例

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


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

示例1: getGWTProblemsInEditor

import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; //导入方法依赖的package包/类
private List<GWTJavaProblem> getGWTProblemsInEditor(CompilationUnitEditor editor)
    throws Exception {
  List<GWTJavaProblem> problems = new ArrayList<GWTJavaProblem>();

  Field annotationProblemField = CompilationUnitDocumentProvider.ProblemAnnotation.class.getDeclaredField("fProblem");
  annotationProblemField.setAccessible(true);

  IEditorInput editorInput = editor.getEditorInput();
  IDocumentProvider documentProvider = editor.getDocumentProvider();
  IAnnotationModel annotationModel = documentProvider.getAnnotationModel(editorInput);
  Iterator<?> iter = annotationModel.getAnnotationIterator();
  while (iter.hasNext()) {
    Object annotation = iter.next();
    if (annotation instanceof CompilationUnitDocumentProvider.ProblemAnnotation) {
      CompilationUnitDocumentProvider.ProblemAnnotation problemAnnotation = (ProblemAnnotation) annotation;
      if (problemAnnotation.getMarkerType().equals(GWTJavaProblem.MARKER_ID)) {
        GWTJavaProblem problem = (GWTJavaProblem) annotationProblemField.get(problemAnnotation);
        problems.add(problem);
      }
    }
  }

  return problems;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:25,代码来源:JavaCompilationParticipantTest.java

示例2: testBuildAddError

import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor; //导入方法依赖的package包/类
public void testBuildAddError() throws Exception {
  IProject project = getTestProject().getProject();

  // Verify that we have 1 existing GWT problem marker
  IMarker[] markers = getGWTProblemMarkers(project);
  assertEquals(1, markers.length);

  ICompilationUnit cu = testClass.getCompilationUnit();

  // Open the test class in the editor
  CompilationUnitEditor editor = (CompilationUnitEditor) JavaUI.openInEditor(cu);
  IEditorInput editorInput = editor.getEditorInput();

  // Edit the document to create a new error (add 'foobar' to the front of
  // the class name in a Java reference)
  IDocument document = editor.getDocumentProvider().getDocument(editorInput);
  TextEdit errorEdit = new InsertEdit(254, "foobar");
  errorEdit.apply(document);
  // Save the changes
  editor.doSave(null);

  // Rebuild the project
  rebuildTestProject();

  // Verify that we now have 2 GWT problem markers
  markers = getGWTProblemMarkers(project);
  assertEquals(2, markers.length);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:29,代码来源:JavaCompilationParticipantTest.java


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