Java Code Examples for org.eclipse.xtext.ui.editor.quickfix.IssueResolution#apply()
The following examples show how to use
org.eclipse.xtext.ui.editor.quickfix.IssueResolution#apply() .
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: LinkingErrorTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testQuickfixTurnaround() throws Exception { IFile dslFile = dslFile(MODEL_WITH_LINKING_ERROR); XtextEditor xtextEditor = openEditor(dslFile); IXtextDocument document = xtextEditor.getDocument(); List<Issue> issues = getAllValidationIssues(document); assertFalse(issues.isEmpty()); Issue issue = issues.get(0); assertNotNull(issue); List<IssueResolution> resolutions = issueResolutionProvider.getResolutions(issue); assertEquals(1, resolutions.size()); IssueResolution resolution = resolutions.get(0); assertEquals("Change to 'Bar'", resolution.getLabel()); resolution.apply(); issues = getAllValidationIssues(document); assertTrue(issues.isEmpty()); }
Example 2
Source File: LinkingErrorTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testBug361509() throws Exception { IFile dslFile = dslFile(MODEL_WITH_LINKING_ERROR_361509); XtextEditor xtextEditor = openEditor(dslFile); IXtextDocument document = xtextEditor.getDocument(); List<Issue> issues = getAllValidationIssues(document); assertFalse(issues.isEmpty()); Issue issue = issues.get(0); assertNotNull(issue); List<IssueResolution> resolutions = issueResolutionProvider.getResolutions(issue); assertEquals(1, resolutions.size()); IssueResolution resolution = resolutions.get(0); assertEquals("Change to 'ref'", resolution.getLabel()); resolution.apply(); issues = getAllValidationIssues(document); assertTrue(issues.isEmpty()); assertEquals(MODEL_WITH_LINKING_ERROR_361509.replace("raf", "^ref"), document.get()); }
Example 3
Source File: LinkingErrorTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testSemanticIssueResolution() throws Exception { IFile dslFile = dslFile(MODEL_WITH_LINKING_ERROR); XtextEditor xtextEditor = openEditor(dslFile); URI uriToProblem = xtextEditor.getDocument().readOnly(new IUnitOfWork<URI, XtextResource>() { @Override public URI exec(XtextResource state) throws Exception { Main main = (Main) state.getContents().get(0); Element element = main.getElements().get(1); return EcoreUtil.getURI(element); } }); Issue.IssueImpl issue = new Issue.IssueImpl(); issue.setUriToProblem(uriToProblem); issue.setCode(QuickfixCrossrefTestLanguageQuickfixProvider.SEMANTIC_FIX_ID); List<IssueResolution> resolutions = issueResolutionProvider.getResolutions(issue); assertEquals(1, resolutions.size()); IssueResolution issueResolution = resolutions.get(0); issueResolution.apply(); xtextEditor.doSave(null); List<Issue> issues = getAllValidationIssues(xtextEditor.getDocument()); assertTrue(issues.isEmpty()); }
Example 4
Source File: XtextGrammarQuickfixProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
private void assertAndApplySingleResolution(XtextEditor xtextEditor, String issueCode, int issueDataCount, String resolutionLabel, boolean isCleanAfterApply) { IXtextDocument document = xtextEditor.getDocument(); List<Issue> issues = getIssues(document); assertFalse(issues.toString(), issues.isEmpty()); Issue issue = issues.iterator().next(); assertEquals(issueCode, issue.getCode()); assertNotNull(issue.getData()); assertEquals(issueDataCount, issue.getData().length); List<IssueResolution> resolutions = issueResolutionProvider.getResolutions(issue); assertEquals(1, resolutions.size()); IssueResolution resolution = resolutions.iterator().next(); assertEquals(resolutionLabel, resolution.getLabel()); try { resolution.apply(); assertEquals(getIssues(document).toString(), isCleanAfterApply, getIssues(document).isEmpty()); } finally { // Save xtextEditor in any case. Otherwise test will stuck, // because the "save changed resource dialog" waits for user input. xtextEditor.doSave(new NullProgressMonitor()); } }
Example 5
Source File: QuickfixTestBuilder.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
public QuickfixTestBuilder assertModelAfterQuickfix(final CharSequence expectedModel) { QuickfixTestBuilder _xblockexpression = null; { final Function1<Issue, List<IssueResolution>> _function = (Issue it) -> { return this._issueResolutionProvider.getResolutions(it); }; final List<IssueResolution> resolutions = IterableExtensions.<IssueResolution>toList(Iterables.<IssueResolution>concat(IterableExtensions.<Issue, List<IssueResolution>>map(this.getIssuesAtCaret(), _function))); final String originalModel = this.editor.getDocument().get(); final IssueResolution resolution = IterableExtensions.<IssueResolution>head(resolutions); Assert.assertNotNull(resolution); resolution.apply(); Assert.assertEquals(expectedModel.toString(), this.editor.getDocument().get()); this.editor.getDocument().set(originalModel); this._syncUtil.waitForReconciler(this.editor); _xblockexpression = this; } return _xblockexpression; }
Example 6
Source File: WorkbenchMarkerResolutionGenerator.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * If we have a Core resolution execute in current thread, otherwise run in UI thread. * * @param markerResolution * the marker resolution to apply */ protected void applyResolution(final IMarkerResolution markerResolution) { final IssueResolution issueResolution = ((WorkbenchResolutionAdapter) markerResolution).getResolution(); if (issueResolution instanceof IssueResolutionWrapper) { issueResolution.apply(); } else { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { issueResolution.apply(); } }); } }