本文整理汇总了Java中org.eclipse.xtext.ui.editor.model.edit.IModification类的典型用法代码示例。如果您正苦于以下问题:Java IModification类的具体用法?Java IModification怎么用?Java IModification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IModification类属于org.eclipse.xtext.ui.editor.model.edit包,在下文中一共展示了IModification类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setOverride
import org.eclipse.xtext.ui.editor.model.edit.IModification; //导入依赖的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: removeOverride
import org.eclipse.xtext.ui.editor.model.edit.IModification; //导入依赖的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;
}
});
}
});
}
示例3: fixCatalogName
import org.eclipse.xtext.ui.editor.model.edit.IModification; //导入依赖的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);
}
}
});
}
示例4: fixIllegalDefaultSeverity
import org.eclipse.xtext.ui.editor.model.edit.IModification; //导入依赖的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);
}
});
}
}
}
示例5: fixSeverityToMaxSeverity
import org.eclipse.xtext.ui.editor.model.edit.IModification; //导入依赖的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);
}
});
}
}
}
示例6: capitalizeEntityNameFirstLetter
import org.eclipse.xtext.ui.editor.model.edit.IModification; //导入依赖的package包/类
@Fix(EntitiesValidator.INVALID_ENTITY_NAME)
public void capitalizeEntityNameFirstLetter(final Issue issue, final IssueResolutionAcceptor acceptor) {
String[] _data = issue.getData();
String _get = _data[0];
String _plus = ("Capitalize first letter of \'" + _get);
String _plus_1 = (_plus + "\'");
final IModification _function = new IModification() {
@Override
public void apply(final IModificationContext context) throws Exception {
final IXtextDocument xtextDocument = context.getXtextDocument();
Integer _offset = issue.getOffset();
final String firstLetter = xtextDocument.get((_offset).intValue(), 1);
Integer _offset_1 = issue.getOffset();
String _firstUpper = StringExtensions.toFirstUpper(firstLetter);
xtextDocument.replace((_offset_1).intValue(), 1, _firstUpper);
}
};
acceptor.accept(issue,
"Capitalize first letter", _plus_1,
"Entity.gif", _function);
}
示例7: raiseSalary
import org.eclipse.xtext.ui.editor.model.edit.IModification; //导入依赖的package包/类
@Fix(IOIJavaValidator.SALARY_TOO_LOW)
public void raiseSalary(final Issue issue, IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, "Raise Salary", "Raise Salary.", "", new IModification() {
public void apply(IModificationContext context) throws BadLocationException {
IXtextDocument xtextDocument = context.getXtextDocument();
//String firstLetter = xtextDocument.get(issue.getOffset(), 1);
xtextDocument.replace(issue.getOffset(), issue.getLength(), issue.getData()[0]);
}
});
}
示例8: cutSalary
import org.eclipse.xtext.ui.editor.model.edit.IModification; //导入依赖的package包/类
@Fix(IOIJavaValidator.SALARY_TOO_HIGH)
public void cutSalary(final Issue issue, IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, "Cut Salary", "Cut Salary.", "", new IModification() {
public void apply(IModificationContext context) throws BadLocationException {
IXtextDocument xtextDocument = context.getXtextDocument();
//String firstLetter = xtextDocument.get(issue.getOffset(), 1);
xtextDocument.replace(issue.getOffset(), issue.getLength(), issue.getData()[0]);
}
});
}
示例9: arreglarNombre
import org.eclipse.xtext.ui.editor.model.edit.IModification; //导入依赖的package包/类
@Fix(RestauranteValidator.NOMBRE_MUY_LARGO)
public void arreglarNombre(final Issue issue, final IssueResolutionAcceptor acceptor) {
final IModification _function = (IModificationContext context) -> {
final IXtextDocument xtextDocument = context.getXtextDocument();
final String nombreActual = xtextDocument.get((issue.getOffset()).intValue(), (issue.getLength()).intValue());
Integer _offset = issue.getOffset();
Integer _length = issue.getLength();
String _substring = nombreActual.substring(0, 18);
String _plus = (_substring + "\'");
xtextDocument.replace((_offset).intValue(), (_length).intValue(), _plus);
};
acceptor.accept(issue, "Reducir nombre", "Se limitar� el tama�o de nombre al m�ximo sugerido", "ingrediente.ico", _function);
}
示例10: arreglarFecha
import org.eclipse.xtext.ui.editor.model.edit.IModification; //导入依赖的package包/类
@Fix(RestauranteValidator.FECHA_INVALIDA)
public void arreglarFecha(final Issue issue, final IssueResolutionAcceptor acceptor) {
SimpleDateFormat formateadorFecha = new SimpleDateFormat("dd-MM-yyyy");
Calendar calendario = Calendar.getInstance();
final String fecha = formateadorFecha.format(calendario.getTime());
final IModification _function = (IModificationContext context) -> {
final IXtextDocument xtextDocument = context.getXtextDocument();
xtextDocument.replace((issue.getOffset()).intValue(), (issue.getLength()).intValue(), fecha);
};
acceptor.accept(issue, "Actualizar fecha", "Se pondr� la fecha de hoy para corregir el problema", "fecha.png", _function);
}
示例11: addGrammarRule
import org.eclipse.xtext.ui.editor.model.edit.IModification; //导入依赖的package包/类
/**
* Syntactic quickfix creating a rule.
*
* @param issue
* the issue
* @param acceptor
* the acceptor
*/
@Fix(FormatJavaValidator.GRAMMAR_RULE_MISSING_CODE)
public void addGrammarRule(final Issue issue, final IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, "Create rule", "Create rule " + issue.getData()[0], null, new IModification() {
@Override
public void apply(final IModificationContext context) throws BadLocationException {
final IXtextDocument xtextDocument = context.getXtextDocument();
xtextDocument.replace(xtextDocument.getLength(), 0, "\n" + issue.getData()[0] + " {\n\t\n}");
}
});
}
示例12: fixGuardStatement
import org.eclipse.xtext.ui.editor.model.edit.IModification; //导入依赖的package包/类
/**
* Replaces a guard by an if-expression.
*
* @param issue
* the issue
* @param acceptor
* the acceptor
*/
@Fix(IssueCodes.GUARDS_DEPRECATED)
public void fixGuardStatement(final Issue issue, final IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, Messages.CheckQuickfixProvider_GUARD_DEPRECATED_LABEL, Messages.CheckQuickfixProvider_GUARD_DEPRECATED_DESCN, NO_IMAGE, new IModification() {
@Override
public void apply(final IModificationContext context) throws BadLocationException {
IXtextDocument xtextDocument = context.getXtextDocument();
String expr = xtextDocument.get(issue.getOffset(), issue.getLength());
expr = expr.replaceFirst("^guard(\\s*)", "if (!(") + ")) {return}";
xtextDocument.replace(issue.getOffset(), issue.getLength(), expr);
}
});
}
示例13: fixPackageName
import org.eclipse.xtext.ui.editor.model.edit.IModification; //导入依赖的package包/类
/**
* Fixes the wrong package name.
*
* @param issue
* the issue
* @param acceptor
* the acceptor
*/
@Fix(IssueCodes.WRONG_PACKAGE)
public void fixPackageName(final Issue issue, final IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, Messages.CheckQuickfixProvider_CORRECT_PKG_NAME_LABEL, Messages.CheckQuickfixProvider_CORRECT_PKG_NAME_DESCN, NO_IMAGE, new IModification() {
@Override
public void apply(final IModificationContext context) throws BadLocationException {
IXtextDocument xtextDocument = context.getXtextDocument();
final String packageName = resourceUtil.getNameOfContainingPackage(xtextDocument);
if (packageName != null) {
xtextDocument.replace(issue.getOffset(), issue.getLength(), packageName);
}
}
});
}
示例14: addIssueExpression
import org.eclipse.xtext.ui.editor.model.edit.IModification; //导入依赖的package包/类
/**
* Adds an {@code issue} statement to a constraint. If the constraint already contains other expressions, {@code issue} is appended to the end.
*
* @param issue
* the issue
* @param acceptor
* the acceptor
*/
@Fix(IssueCodes.MISSING_ISSUE_EXPRESSION)
public void addIssueExpression(final Issue issue, final IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, Messages.CheckQuickfixProvider_ADD_ISSUE_EXPR_LABEL, Messages.CheckQuickfixProvider_ADD_ISSUE_EXPR_DESCN, NO_IMAGE, new IModification() {
@Override
public void apply(final IModificationContext context) throws BadLocationException {
IXtextDocument xtextDocument = context.getXtextDocument();
xtextDocument.replace(issue.getOffset() + issue.getLength() - 1, 0, ' ' + "issue" + ' ');
}
});
}
示例15: IssueResolution
import org.eclipse.xtext.ui.editor.model.edit.IModification; //导入依赖的package包/类
/**
* @since 2.4
*/
public IssueResolution(String label, String description, String image, IModificationContext modificationContext, IModification modification, int relevance) {
this.description = description;
this.label = label;
this.image = image;
this.modificationContext = modificationContext;
this.modification = modification;
this.relevance = relevance;
}