use of org.eclipse.xtext.xbase.ui.document.DocumentSourceAppender.Factory.OptionalParameters in project xtext-xtend by eclipse.
the class XtendQuickfixProvider method doOverrideMethods.
protected void doOverrideMethods(final Issue issue, IssueResolutionAcceptor acceptor, String label, final String[] operationUris) {
acceptor.accept(issue, label, label, "fix_indent.gif", new ISemanticModification() {
@Override
public void apply(EObject element, IModificationContext context) throws Exception {
XtendTypeDeclaration clazz = (XtendTypeDeclaration) element;
JvmGenericType inferredType = (JvmGenericType) associations.getInferredType(clazz);
ResolvedFeatures resolvedOperations = overrideHelper.getResolvedFeatures(inferredType);
IXtextDocument document = context.getXtextDocument();
final int offset = insertionOffsets.getNewMethodInsertOffset(null, clazz);
int currentIndentation = appendableFactory.getIndentationLevelAtOffset(offset, document, (XtextResource) clazz.eResource());
final int indentationToUse = clazz.getMembers().isEmpty() ? currentIndentation + 1 : currentIndentation;
ReplacingAppendable appendable = appendableFactory.create(document, (XtextResource) clazz.eResource(), offset, 0, new OptionalParameters() {
{
ensureEmptyLinesAround = true;
baseIndentationLevel = indentationToUse;
}
});
boolean isFirst = true;
for (String operationUriAsString : operationUris) {
URI operationURI = URI.createURI(operationUriAsString);
EObject overridden = clazz.eResource().getResourceSet().getEObject(operationURI, true);
if (overridden instanceof JvmOperation) {
if (!isFirst)
appendable.newLine().newLine();
isFirst = false;
superMemberImplementor.appendOverrideFunction(clazz, resolvedOperations.getResolvedOperation((JvmOperation) overridden), appendable);
}
}
appendable.commitChanges();
}
});
}
use of org.eclipse.xtext.xbase.ui.document.DocumentSourceAppender.Factory.OptionalParameters in project xtext-eclipse by eclipse.
the class DocumentRewriter method newSection.
public Section newSection(int offset, int length) {
OptionalParameters parameters = createOptionalParameters();
Section section = factory.sectionFactory.create(document, resource, offset, length, parameters);
addSection(section);
return section;
}
use of org.eclipse.xtext.xbase.ui.document.DocumentSourceAppender.Factory.OptionalParameters in project xtext-eclipse by eclipse.
the class DocumentRewriter method createOptionalParameters.
protected OptionalParameters createOptionalParameters() {
OptionalParameters parameters = new OptionalParameters();
parameters.importSection = importSection;
return parameters;
}
Aggregations