本文整理汇总了Java中org.eclipse.xtext.ui.editor.model.edit.IModification类的典型用法代码示例。如果您正苦于以下问题:Java IModification类的具体用法?Java IModification怎么用?Java IModification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IModification类属于org.eclipse.xtext.ui.editor.model.edit包,在下文中一共展示了IModification类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
});
}
});
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:25,代码来源:FormatQuickfixProvider.java
示例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;
}
});
}
});
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:25,代码来源:FormatQuickfixProvider.java
示例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);
}
}
});
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:24,代码来源:CheckQuickfixProvider.java
示例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);
}
});
}
}
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:26,代码来源:CheckQuickfixProvider.java
示例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);
}
});
}
}
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:26,代码来源:CheckCfgQuickfixProvider.java
示例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);
}
开发者ID:LorenzoBettini,项目名称:packtpub-xtext-book-examples,代码行数:22,代码来源:EntitiesQuickfixProvider.java
示例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]);
}
});
}
开发者ID:amritbhat786,项目名称:DocIT,代码行数:11,代码来源:IOIQuickfixProvider.java
示例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]);
}
});
}
开发者ID:amritbhat786,项目名称:DocIT,代码行数:11,代码来源:IOIQuickfixProvider.java
示例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);
}
开发者ID:vicegd,项目名称:org.xtext.dsl.restaurante,代码行数:14,代码来源:RestauranteQuickfixProvider.java
示例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);
}
开发者ID:vicegd,项目名称:org.xtext.dsl.restaurante,代码行数:12,代码来源:RestauranteQuickfixProvider.java
示例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}");
}
});
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:19,代码来源:FormatQuickfixProvider.java
示例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);
}
});
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:21,代码来源:CheckQuickfixProvider.java
示例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);
}
}
});
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:22,代码来源:CheckQuickfixProvider.java
示例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" + ' ');
}
});
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:19,代码来源:CheckQuickfixProvider.java
示例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;
}
开发者ID:cplutte,项目名称:bts,代码行数:12,代码来源:IssueResolution.java
示例16: fixCase
import org.eclipse.xtext.ui.editor.model.edit.IModification; //导入依赖的package包/类
@Fix(IssueCodes.NOT_UPPERCASE)
public void fixCase(final Issue issue, IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, "Convert to UPPERCASE",
"Convert '" + issue.getData()[0] + "' to '" + issue.getData()[0].toUpperCase() + "'", "Upcase.gif", new IModification() {
@Override
public void apply(IModificationContext context) throws BadLocationException {
IXtextDocument document = context.getXtextDocument();
String name = document.get(issue.getOffset(), issue.getLength());
document.replace(issue.getOffset(), issue.getLength(), name.toUpperCase());
}
});
}
开发者ID:timofonic,项目名称:PHDL,代码行数:14,代码来源:PhdlQuickfixProvider.java
示例17: missingHttpPrefix
import org.eclipse.xtext.ui.editor.model.edit.IModification; //导入依赖的package包/类
@Fix(SadlJavaValidator.MISSING_HTTP_PREFIX)
public void missingHttpPrefix(final Issue issue, IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, "Add Prefix", "Add 'http://' to the begining of the model name", null, new IModification() {
public void apply(IModificationContext context) throws BadLocationException {
IXtextDocument xtextDocument = context.getXtextDocument();
String openingQuote = xtextDocument.get(issue.getOffset() + 1, 1);
xtextDocument.replace(issue.getOffset() + 1, 1, openingQuote + "http://");
}
});
}
开发者ID:crapo,项目名称:sadlos2,代码行数:12,代码来源:SadlQuickfixProvider.java
示例18: addModelGlobalAlias
import org.eclipse.xtext.ui.editor.model.edit.IModification; //导入依赖的package包/类
@Fix(SadlJavaValidator.ADD_GLOBAL_ALIAS)
public void addModelGlobalAlias(final Issue issue, IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, "Add Model Global Alias", "Add a global alias to the model", null, new IModification() {
@Override
public void apply(IModificationContext context) throws Exception {
final IXtextDocument doc = context.getXtextDocument();
// assumption: that URI is in same line as 'uri' keyword
// parse the line to create a ModelName
String line = doc.get(issue.getOffset(), doc.getLineLength(issue.getLineNumber()-1));
IParseResult parseResult = parser.parse(parser.getGrammarAccess().getModelNameRule(), new StringReader(line));
ModelName name = (ModelName) parseResult.getRootASTElement();
// compute alias name
URI uri = URI.createURI(name.getBaseUri());
String galias = (uri.segmentCount()>1) ? uri.lastSegment() : "aliasName";
// find insertion offset: Search for end of URI string
int offset = line.indexOf(name.getBaseUri())+name.getBaseUri().length();
// is uri string surrounded by " or ' ?
char stringDelimiter = line.substring(0,offset).indexOf('"')>0 ? '"' : '\'';
// find position of end character
offset = line.indexOf(stringDelimiter, offset)+1;
doc.replace(offset, 0, " alias "+galias);
}
});
}
开发者ID:crapo,项目名称:sadlos2,代码行数:30,代码来源:SadlQuickfixProvider.java
示例19: accept
import org.eclipse.xtext.ui.editor.model.edit.IModification; //导入依赖的package包/类
public void accept(Issue issue, String label, String description, String image, IModification modification) {
issueResolutions.add(new IssueResolution(label, description, image, modificationContextFactory.createModificationContext(issue),
modification));
}
开发者ID:cplutte,项目名称:bts,代码行数:5,代码来源:IssueResolutionAcceptor.java
示例20: getModification
import org.eclipse.xtext.ui.editor.model.edit.IModification; //导入依赖的package包/类
/**
* @since 2.2
*/
public IModification getModification() {
return modification;
}
开发者ID:cplutte,项目名称:bts,代码行数:7,代码来源:IssueResolution.java
注:本文中的org.eclipse.xtext.ui.editor.model.edit.IModification类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论