本文整理汇总了Java中org.eclipse.xtext.ui.editor.model.edit.IModificationContext.getXtextDocument方法的典型用法代码示例。如果您正苦于以下问题:Java IModificationContext.getXtextDocument方法的具体用法?Java IModificationContext.getXtextDocument怎么用?Java IModificationContext.getXtextDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.ui.editor.model.edit.IModificationContext
的用法示例。
在下文中一共展示了IModificationContext.getXtextDocument方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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()));
}
}
});
}
示例2: createMissingEntity
import org.eclipse.xtext.ui.editor.model.edit.IModificationContext; //导入方法依赖的package包/类
@Fix(Diagnostic.LINKING_DIAGNOSTIC)
public void createMissingEntity(final Issue issue, final IssueResolutionAcceptor acceptor) {
final ISemanticModification _function = new ISemanticModification() {
@Override
public void apply(final EObject element, final IModificationContext context) throws Exception {
Entity _containerOfType = EcoreUtil2.<Entity>getContainerOfType(element, Entity.class);
IXtextDocument _xtextDocument = context.getXtextDocument();
Integer _offset = issue.getOffset();
Integer _length = issue.getLength();
String _get = _xtextDocument.get((_offset).intValue(), (_length).intValue());
EntitiesModelUtil.addEntityAfter(_containerOfType, _get);
}
};
acceptor.accept(issue,
"Create missing entity",
"Create missing entity",
"Entity.gif", _function);
}
示例3: capitalizeEntityNameFirstLetter
import org.eclipse.xtext.ui.editor.model.edit.IModificationContext; //导入方法依赖的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);
}
示例4: arreglarNombre
import org.eclipse.xtext.ui.editor.model.edit.IModificationContext; //导入方法依赖的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);
}
示例5: arreglarFecha
import org.eclipse.xtext.ui.editor.model.edit.IModificationContext; //导入方法依赖的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);
}