Java源码示例:org.eclipse.xtext.ui.editor.model.edit.IssueModificationContext

示例1
@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);
			}
		}
	});
}
 
示例2
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;
}
 
示例3
@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, "");
				}
			}
		}
	});
}
 
示例4
@Inject
public IssueResolutionAcceptor(IssueModificationContext.Factory modificationContextFactory) {
	this.modificationContextFactory = modificationContextFactory;
}
 
示例5
/**
 * @since 2.0
 */
protected IssueModificationContext.Factory getModificationContextFactory() {
	return modificationContextFactory;
}
 
示例6
public Class<? extends IssueModificationContext> bindIssueModificationContext() {
	return TestIssueModificationContext.class;
}