本文整理汇总了Java中org.eclipse.xtext.ui.editor.model.edit.IModificationContext类的典型用法代码示例。如果您正苦于以下问题:Java IModificationContext类的具体用法?Java IModificationContext怎么用?Java IModificationContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IModificationContext类属于org.eclipse.xtext.ui.editor.model.edit包,在下文中一共展示了IModificationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setOverride
import org.eclipse.xtext.ui.editor.model.edit.IModificationContext; //导入依赖的package包/类
/**
* Semantic quickfix setting the override flag for a rule.
*
* @param issue
* the issue
* @param acceptor
* the acceptor
*/
@Fix(FormatJavaValidator.OVERRIDE_MISSING_CODE)
public void setOverride(final Issue issue, final IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, "Set override", "Set override flag.", null, new IModification() {
@Override
public void apply(final IModificationContext context) throws BadLocationException {
context.getXtextDocument().modify(new IUnitOfWork<Void, XtextResource>() {
@Override
public java.lang.Void exec(final XtextResource state) {
Rule rule = (Rule) state.getEObject(issue.getUriToProblem().fragment());
rule.setOverride(true);
return null;
}
});
}
});
}
示例2: apply
import org.eclipse.xtext.ui.editor.model.edit.IModificationContext; //导入依赖的package包/类
@Override
public final void apply(IModificationContext context) throws Exception {
context.getXtextDocument().modify(new IUnitOfWork.Void<XtextResource>() {
@Override
public void process(XtextResource resource) throws Exception {
final IMarker marker = issue instanceof N4JSIssue ? ((N4JSIssue) issue).getMarker() : null;
final EObject element = resource.getEObject(issue.getUriToProblem().fragment());
final Collection<? extends IChange> changes = modification.computeChanges(
context,
marker,
issue.getOffset(),
issue.getLength(),
element);
modification.computeFinalChanges();
changeManager.applyAll(changes);
}
});
}
示例3: removeOverride
import org.eclipse.xtext.ui.editor.model.edit.IModificationContext; //导入依赖的package包/类
/**
* Semantic quickfix removing the override flag for a rule.
*
* @param issue
* the issue
* @param acceptor
* the acceptor
*/
@Fix(FormatJavaValidator.OVERRIDE_ILLEGAL_CODE)
public void removeOverride(final Issue issue, final IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, "Remove override", "Remove override.", null, new IModification() {
@Override
public void apply(final IModificationContext context) throws BadLocationException {
context.getXtextDocument().modify(new IUnitOfWork<Void, XtextResource>() {
@Override
public java.lang.Void exec(final XtextResource state) {
Rule rule = (Rule) state.getEObject(issue.getUriToProblem().fragment());
rule.setOverride(false);
return null;
}
});
}
});
}
示例4: fixCatalogName
import org.eclipse.xtext.ui.editor.model.edit.IModificationContext; //导入依赖的package包/类
/**
* Fix catalog name.
*
* @param issue
* the issue
* @param acceptor
* the acceptor
*/
@Fix(IssueCodes.WRONG_FILE)
public void fixCatalogName(final Issue issue, final IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, Messages.CheckQuickfixProvider_CORRECT_CATALOG_NAME_LABEL, Messages.CheckQuickfixProvider_CORRECT_CATALOG_NAME_DESCN, NO_IMAGE, new IModification() {
@Override
public void apply(final IModificationContext context) throws BadLocationException {
IXtextDocument xtextDocument = context.getXtextDocument();
IFile file = xtextDocument.getAdapter(IFile.class);
if (file != null) {
final String fileName = file.getName();
final String name = fileName.indexOf('.') > 0 ? fileName.substring(0, fileName.lastIndexOf('.')) : fileName;
xtextDocument.replace(issue.getOffset(), issue.getLength(), name);
}
}
});
}
示例5: apply
import org.eclipse.xtext.ui.editor.model.edit.IModificationContext; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void apply(final IModificationContext context) throws BadLocationException {
final IXtextDocument xtextDocument = context.getXtextDocument();
xtextDocument.readOnly(new IUnitOfWork.Void<XtextResource>() {
@Override
public void process(final XtextResource state) throws Exception { // NOPMD
final EObject target = EcoreUtil2.getContainerOfType(state.getEObject(issue.getUriToProblem().fragment()), type);
if (type.isInstance(target)) {
int offset = NodeModelUtils.findActualNodeFor(target).getOffset();
int lineOfOffset = xtextDocument.getLineOfOffset(offset);
int lineOffset = xtextDocument.getLineOffset(lineOfOffset);
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < (offset - lineOffset); i++) {
buffer.append(' ');
}
xtextDocument.replace(offset, 0, NLS.bind(autodocumentation, buffer.toString()));
}
}
});
}
示例6: removeGuardStatement
import org.eclipse.xtext.ui.editor.model.edit.IModificationContext; //导入依赖的package包/类
/**
* Removes the guard statement occurring at offending position.
*
* @param issue
* the issue
* @param acceptor
* the acceptor
*/
@Fix(IssueCodes.GUARDS_COME_FIRST)
@SuppressWarnings("unchecked")
public void removeGuardStatement(final Issue issue, final IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, Messages.CheckQuickfixProvider_REMOVE_GUARD_LABEL, Messages.CheckQuickfixProvider_REMOVE_GUARD_DESCN, NO_IMAGE, new ISemanticModification() {
@Override
public void apply(final EObject element, final IModificationContext context) {
final XGuardExpression guard = EcoreUtil2.getContainerOfType(element, XGuardExpression.class);
if (guard != null && guard.eContainingFeature().isMany()) {
EList<? extends EObject> holder = (EList<? extends EObject>) guard.eContainer().eGet(guard.eContainingFeature());
if (holder != null && holder.contains(guard)) {
holder.remove(guard);
}
}
}
});
}
示例7: fixSeverityRangeOrder
import org.eclipse.xtext.ui.editor.model.edit.IModificationContext; //导入依赖的package包/类
/**
* Fixes the severity range order by setting the lower severity level kind first and the severity of higher severity level last.
*
* @param issue
* the issue
* @param acceptor
* the acceptor
*/
@Fix(IssueCodes.ILLEGAL_SEVERITY_RANGE_ORDER)
public void fixSeverityRangeOrder(final Issue issue, final IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, Messages.CheckQuickfixProvider_FIX_SEVERITY_RANGE_ORDER_LABEL, Messages.CheckQuickfixProvider_FIX_SEVERITY_RANGE_ORDER_DESCN, NO_IMAGE, new ISemanticModification() {
@Override
public void apply(final EObject element, final IModificationContext context) {
final Check check = EcoreUtil2.getContainerOfType(element, Check.class);
if (check != null && check.getSeverityRange() != null) {
final SeverityRange range = check.getSeverityRange();
SeverityKind oldMinSeverity = range.getMinSeverity();
range.setMinSeverity(range.getMaxSeverity());
range.setMaxSeverity(oldMinSeverity);
}
}
});
}
示例8: fixIllegalDefaultSeverity
import org.eclipse.xtext.ui.editor.model.edit.IModificationContext; //导入依赖的package包/类
/**
* Fixes an illegally set default severity. The default severity must be within given severity range.
*
* @param issue
* the issue
* @param acceptor
* the acceptor
*/
@Fix(IssueCodes.DEFAULT_SEVERITY_NOT_IN_RANGE)
public void fixIllegalDefaultSeverity(final Issue issue, final IssueResolutionAcceptor acceptor) {
if (issue.getData() != null) {
for (final String severityProposal : issue.getData()) {
final String label = NLS.bind(Messages.CheckQuickfixProvider_DEFAULT_SEVERITY_FIX_LABEL, severityProposal);
final String descn = NLS.bind(Messages.CheckQuickfixProvider_DEFAULT_SEVERITY_FIX_DESCN, severityProposal);
acceptor.accept(issue, label, descn, NO_IMAGE, new IModification() {
@Override
public void apply(final IModificationContext context) throws BadLocationException {
IXtextDocument xtextDocument = context.getXtextDocument();
xtextDocument.replace(issue.getOffset(), issue.getLength(), severityProposal);
}
});
}
}
}
示例9: fixSeverityToMaxSeverity
import org.eclipse.xtext.ui.editor.model.edit.IModificationContext; //导入依赖的package包/类
/**
* Fix severity by setting it to a legal value as is defined by severity range of referenced check. Legal
* severities are passed as issue data (org.eclipse.xtext.validation.Issue#getData()).
*
* @param issue
* the issue
* @param acceptor
* the acceptor
*/
@Fix(IssueCodes.SEVERITY_NOT_ALLOWED)
public void fixSeverityToMaxSeverity(final Issue issue, final IssueResolutionAcceptor acceptor) {
if (issue.getData() != null) {
for (final String severityProposal : issue.getData()) {
final String label = NLS.bind(Messages.CheckCfgQuickfixProvider_CORRECT_SEVERITY_LABEL, severityProposal);
final String descn = NLS.bind(Messages.CheckCfgQuickfixProvider_CORRECT_SEVERITY_DESCN, severityProposal);
acceptor.accept(issue, label, descn, NO_IMAGE, new IModification() {
public void apply(final IModificationContext context) throws BadLocationException {
IXtextDocument xtextDocument = context.getXtextDocument();
xtextDocument.replace(issue.getOffset(), issue.getLength(), severityProposal);
}
});
}
}
}
示例10: fixArrayNotDeclared
import org.eclipse.xtext.ui.editor.model.edit.IModificationContext; //导入依赖的package包/类
@Fix(IssueCodes.ARRAY_NOT_DECLARED)
public void fixArrayNotDeclared(final Issue issue, IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, "Remove vector slices", "Removes vector slices from object", null, new ISemanticModification() {
@Override
public void apply(EObject element, IModificationContext context) throws Exception {
if (element instanceof PinAssign) {
((PinAssign) element).setSlices(null);
} else if (element instanceof PortAssign) {
((PortAssign) element).setSlices(null);
} else if (element instanceof ConnectionAssign) {
((ConnectionAssign) element).setSlices(null);
} else if (element instanceof ConnectionRef) {
((ConnectionRef) element).setSlices(null);
}
}
});
}
示例11: fixMissingRequiredAttribute
import org.eclipse.xtext.ui.editor.model.edit.IModificationContext; //导入依赖的package包/类
@Fix(IssueCodes.REQUIRED_ATTRIBUTE_MISSING)
public void fixMissingRequiredAttribute(final Issue issue, IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, "Add missing required attribute", "Add missing '" + issue.getData()[0] + "' required attribute.",
"Attr.gif", new ISemanticModification() {
@Override
public void apply(EObject element, IModificationContext context) throws Exception {
Device device = (Device) element;
Attr attr = PhdlFactory.eINSTANCE.createAttr();
attr.setName(issue.getData()[0].toUpperCase());
if (!issue.getData()[0].equals("REFPREFIX"))
attr.setValue("my" + issue.getData()[0]);
else
attr.setValue("R");
device.getElements().add(attr);
}
});
}
示例12: addImportAlias
import org.eclipse.xtext.ui.editor.model.edit.IModificationContext; //导入依赖的package包/类
@Fix(SadlJavaValidator.MISSING_ALIAS)
public void addImportAlias(final Issue issue, IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, "Add import model alias", "Add an alias for the imported model", null, new ISemanticModification() {
public void apply(EObject element, IModificationContext context)
throws Exception {
String alias = null;
if (element instanceof com.ge.research.sadl.sadl.Import) {
String uri = ((com.ge.research.sadl.sadl.Import)element).getImportURI().trim();
if (uri.endsWith("/")) {
uri = uri.substring(0, uri.length() - 1);
}
int ls = uri.lastIndexOf('/');
if (ls > 0) {
alias = uri.substring(ls + 1);
}
}
if (alias == null) {
alias = "aliasName";
}
((com.ge.research.sadl.sadl.Import)element).setAlias(alias);
}
});
}
示例13: addNSQualifier
import org.eclipse.xtext.ui.editor.model.edit.IModificationContext; //导入依赖的package包/类
@Fix(SadlJavaValidator.AMBIGUOUS_NAME)
public void addNSQualifier(final Issue issue, final IssueResolutionAcceptor acceptor) {
String[] fixes = issue.getData();
Iterator<String> itr = Splitter.on(",").split(fixes[0]).iterator();
while (itr.hasNext()) {
// loop over prefixes
final String prefix = itr.next();
acceptor.accept(issue, prefix, "Add the namespace prefix '" + prefix + "' to disambiguate name", null, new ISemanticModification() {
public void apply(EObject element, IModificationContext context)
throws Exception {
if (element instanceof ResourceByName) {
IXtextDocument xtextDocument = context.getXtextDocument();
if (xtextDocument instanceof XtextDocument) {
int insertAt = issue.getOffset();
xtextDocument.replace(insertAt, issue.getLength(), prefix);
}
}
}
});
}
}
示例14: addImportTemplateFix
import org.eclipse.xtext.ui.editor.model.edit.IModificationContext; //导入依赖的package包/类
public void addImportTemplateFix(final Issue issue, final IssueResolutionAcceptor acceptor, final String linkText) {
boolean _notEquals = (!Objects.equal(linkText, null));
if (_notEquals) {
final ISemanticModification _function = new ISemanticModification() {
public void apply(final EObject element, final IModificationContext context) throws Exception {
if ((element instanceof de.unidue.ecg.characterScript.characterScript.Character)) {
final Characters root = EcoreUtil2.<Characters>getContainerOfType(element, Characters.class);
final Import import_ = CharacterScriptFactory.eINSTANCE.createImport();
import_.setImportedNamespace(linkText);
EList<Import> _imports = root.getImports();
_imports.add(import_);
}
}
};
acceptor.accept(issue, (("Add import for \'" + linkText) + "\'"), (("Add import for \'" + linkText) + "\'"), null, _function);
}
}
示例15: removeSuperType
import org.eclipse.xtext.ui.editor.model.edit.IModificationContext; //导入依赖的package包/类
@Fix(EntitiesValidator.HIERARCHY_CYCLE)
public void removeSuperType(final Issue issue, final IssueResolutionAcceptor acceptor) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("Remove supertype \'");
String[] _data = issue.getData();
String _get = _data[0];
_builder.append(_get, "");
_builder.append("\' ");
final ISemanticModification _function = new ISemanticModification() {
@Override
public void apply(final EObject element, final IModificationContext context) throws Exception {
((Entity) element).setSuperType(null);
}
};
acceptor.accept(issue,
"Remove supertype", _builder.toString(),
"delete_obj.gif", _function);
}