本文整理汇总了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;
}
示例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);
}