use of org.eclipse.xtext.xbase.ui.contentassist.ReplacingAppendable in project xtext-xtend by eclipse.
the class ReplacingAppendableTest method insertListField.
protected XtextDocument insertListField(final String model, final String fieldName) throws Exception {
final int cursorPosition = model.indexOf('|');
String actualModel = model.replace("|", " ");
final XtendFile file = testHelper.xtendFile("Foo", actualModel);
final XtextDocument document = documentProvider.get();
document.set(actualModel);
XtextResource xtextResource = (XtextResource) file.eResource();
document.setInput(xtextResource);
final EObject context = eObjectAtOffsetHelper.resolveElementAt(xtextResource, cursorPosition);
document.modify(new IUnitOfWork.Void<XtextResource>() {
@Override
public void process(XtextResource state) throws Exception {
ReplacingAppendable a = appendableFactory.create(document, state, cursorPosition, 1);
ITypeReferenceOwner owner = new StandardTypeReferenceOwner(services, context);
LightweightTypeReference typeRef = owner.toLightweightTypeReference(services.getTypeReferences().getTypeForName(List.class, context, typesFactory.createJvmWildcardTypeReference()));
a.append(typeRef);
a.append(" ").append(fieldName);
a.commitChanges();
}
});
return document;
}
Aggregations