use of org.eclipse.xtext.ui.codetemplates.ui.partialEditing.IPartialEditingContentAssistContextFactory in project xtext-eclipse by eclipse.
the class CodetemplatesProposalProvider method complete_Literal.
@Override
public void complete_Literal(EObject model, RuleCall ruleCall, final ContentAssistContext context, final ICompletionProposalAcceptor acceptor) {
if ((mode & NESTED) != 0) {
final TemplateData data = new TemplateData(model);
if (data.doCreateProposals()) {
final EvaluatedTemplate evaluatedTemplate = new EvaluatedTemplate(data.template);
temporaryResourceProvider.useTemporaryResource(data.template.eResource().getResourceSet(), data.language, data.rule, evaluatedTemplate.getMappedString(), new IUnitOfWork.Void<XtextResource>() {
@Override
public void process(XtextResource resource) throws Exception {
IPartialEditingContentAssistContextFactory delegateFactory = languageRegistry.getPartialContentAssistContextFactory(data.language);
delegateFactory.initializeFor(data.rule);
String mappedInput = evaluatedTemplate.getMappedString();
int mappedOffset = Math.min(mappedInput.length(), evaluatedTemplate.getMappedOffset(context.getOffset()));
DummyDocument document = new DummyDocument(mappedInput);
DummyTextViewer dummyViewer = new DummyTextViewer(TextSelection.emptySelection(), document);
ContentAssistContext[] contexts = delegateFactory.create(dummyViewer, mappedOffset, resource);
ICompletionProposalAcceptor mappingAcceptor = new ProjectionAwareProposalAcceptor(acceptor, evaluatedTemplate);
createNestedProposals(contexts, context.getViewer(), mappingAcceptor, data);
}
});
}
}
}
Aggregations