org.eclipse.xtext.ui.editor.model.edit.IssueModificationContext Java Examples
The following examples show how to use
org.eclipse.xtext.ui.editor.model.edit.IssueModificationContext.
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: QuickfixCrossrefTestLanguageQuickfixProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Fix(QuickfixCrossrefTestLanguageValidator.LOWERCASE) public void fixLowercase(final Issue issue, IssueResolutionAcceptor acceptor) { acceptor.accept(issue, "fix lowercase", "fix lowercase", null, new ITextualMultiModification() { @Override public void apply(IModificationContext context) throws Exception { if (context instanceof IssueModificationContext) { Issue theIssue = ((IssueModificationContext) context).getIssue(); IXtextDocument document = context.getXtextDocument(); String upperCase = document.get(theIssue.getOffset(), theIssue.getLength()).toUpperCase(); // uppercase + duplicate => allows offset change tests document.replace(theIssue.getOffset(), theIssue.getLength(), upperCase + "_" +upperCase); } } }); }
Example #2
Source File: N4JSMarkerResolutionGenerator.java From n4js with Eclipse Public License 1.0 | 5 votes |
private MultiResolutionAdapter(IssueResolution resolution) { if (!(resolution.getModificationContext() instanceof IssueModificationContext)) throw new IllegalArgumentException( "the resolution's modification context must be an IssueModificationContext"); this.issue = ((IssueModificationContext) resolution.getModificationContext()).getIssue(); this.resolution = resolution; }
Example #3
Source File: XtendQuickfixProvider.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Fix(IssueCodes.UNNECESSARY_MODIFIER) public void removeUnnecessaryModifier(final Issue issue, IssueResolutionAcceptor acceptor) { String[] issueData = issue.getData(); if(issueData==null || issueData.length==0) { return; } // use the same label, description and image // to be able to use the quickfixes (issue resolution) in batch mode String label = "Remove the unnecessary modifier."; String description = "The modifier is unnecessary and could be removed."; String image = "fix_indent.gif"; acceptor.accept(issue, label, description, image, new ITextualMultiModification() { @Override public void apply(IModificationContext context) throws Exception { if (context instanceof IssueModificationContext) { Issue theIssue = ((IssueModificationContext) context).getIssue(); Integer offset = theIssue.getOffset(); IXtextDocument document = context.getXtextDocument(); document.replace(offset, theIssue.getLength(), ""); while (Character.isWhitespace(document.getChar(offset))) { document.replace(offset, 1, ""); } } } }); }
Example #4
Source File: IssueResolutionAcceptor.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Inject public IssueResolutionAcceptor(IssueModificationContext.Factory modificationContextFactory) { this.modificationContextFactory = modificationContextFactory; }
Example #5
Source File: DefaultQuickfixProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
/** * @since 2.0 */ protected IssueModificationContext.Factory getModificationContextFactory() { return modificationContextFactory; }
Example #6
Source File: TestQuickfixXbaseUIModule.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public Class<? extends IssueModificationContext> bindIssueModificationContext() { return TestIssueModificationContext.class; }