org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator Java Examples
The following examples show how to use
org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: N4JSUiModule.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * Bind custom MarkerResolutionGenerator. */ // ==== BEGIN injection work-around ==== // work-around for an injection problem with MarkerResolutionGenerator: // MarkerResolutionGenerator contains a non-optional injection of IWorkbench which causes problems in // headless tests; we cannot change that in N4JSMarkerResolutionGenerator, because the field is private // // TODO remove work-around when this injection is changed to optional in a future Xtext version // (also remove related hacks in classes ChangeManager and IssueUtilN4 (search for "==== BEGIN")) // // public Class<? extends MarkerResolutionGenerator> bindMarkerResolutionGenerator() { // return N4JSMarkerResolutionGenerator.class; // } public void configureMarkerResolutionGenerator(com.google.inject.Binder binder) { if (org.eclipse.ui.PlatformUI.isWorkbenchRunning()) { binder.bind(MarkerResolutionGenerator.class).to(N4JSMarkerResolutionGenerator.class); } }
Example #2
Source File: XtextGrammarQuickfixProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
private void assertAndApplyAllResolutions(XtextEditor xtextEditor, String issueCode, int issueDataCount, int issueCount, String resolutionLabel) throws CoreException { InternalBuilderTest.setAutoBuild(true); if (xtextEditor.isDirty()) { xtextEditor.doSave(new NullProgressMonitor()); } InternalBuilderTest.fullBuild(); IXtextDocument document = xtextEditor.getDocument(); validateInEditor(document); List<Issue> issues = getIssues(document); assertFalse("Document has no issues, but should.", issues.isEmpty()); issues.iterator().forEachRemaining((issue) -> { assertEquals(issueCode, issue.getCode()); assertNotNull(issue.getData()); assertEquals(issueDataCount, issue.getData().length); }); IResource resource = xtextEditor.getResource(); IMarker[] problems = resource.findMarkers(MarkerTypes.FAST_VALIDATION, true, IResource.DEPTH_INFINITE); assertEquals("Resource should have " + issueCount + " error marker.", issueCount, problems.length); validateInEditor(document); MarkerResolutionGenerator instance = injector.getInstance(MarkerResolutionGenerator.class); List<IMarkerResolution> resolutions = Lists.newArrayList(instance.getResolutions(problems[0])); assertEquals(1, resolutions.size()); IMarkerResolution resolution = resolutions.iterator().next(); assertTrue(resolution instanceof WorkbenchMarkerResolution); WorkbenchMarkerResolution workbenchResolution = (WorkbenchMarkerResolution) resolution; IMarker primaryMarker = problems[0]; List<IMarker> others = Lists.newArrayList(workbenchResolution.findOtherMarkers(problems)); assertFalse(others.contains(primaryMarker)); assertEquals(problems.length - 1, others.size()); others.add(primaryMarker); workbenchResolution.run(others.toArray(new IMarker[others.size()]), new NullProgressMonitor()); if (xtextEditor.isDirty()) { xtextEditor.doSave(null); } InternalBuilderTest.cleanBuild(); problems = resource.findMarkers(MarkerTypes.FAST_VALIDATION, true, IResource.DEPTH_INFINITE); assertEquals("Resource should have no error marker.", 0, problems.length); }
Example #3
Source File: SharedUiModule.java From dsl-devkit with Eclipse Public License 1.0 | 2 votes |
/** * Bind MarkerResolutionGenerator. * * @return WorkbenchMarkerResolutionGenerator */ public Class<? extends MarkerResolutionGenerator> bindIMarkerResolutionGenerator() { return WorkbenchMarkerResolutionGenerator.class; }