private void registerGuiceBindingsUi() { new GuiceModuleAccess.BindingFactory() .addTypeToType(typeRef(DefaultTemplateProposalProvider.class), typeRef(CooperateTemplateProposalProvider.class)) .contributeTo(getLanguage().getEclipsePluginGenModule()); getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles() .add("de.cooperateproject.modeling.textual.xtext.runtime.ui"); }
protected ICompletionProposal createTemplateProposal( TemplateIssueResolution res) { try { TemplateContextSupplier fac = res.getContextFactory(); IDocument doc = XtextDocumentUtil.get(qaCtx.getSourceViewer()); Position pos = fac.getPosition(doc, qaCtx); String prefix = fac.getPrefix(doc, qaCtx); String postfix = fac.getPostfix(doc, qaCtx); Map<String, String> vars = fac.getVariables(doc, qaCtx); Region r = new Region(pos.getOffset(), pos.getLength()); ContentAssistContext cactx = builderProvider.get() .setOffset(pos.getOffset()).setPrefix(prefix) .setViewer(qaCtx.getSourceViewer()).toContext(); // create a TemplateProposalContext Image i = ((DefaultTemplateProposalProvider) templatePP) .getImage(res.getTemplate()); XtextTemplateContextType type = templateCtxTypeProvider.get(); XtextTemplateContext tplctx = new QuickfixTemplateContext(type, doc, pos, cactx, scopeProvider, prefix, postfix); for (Map.Entry<String, String> e : vars.entrySet()) tplctx.setVariable(e.getKey(), e.getValue()); // create a TemplateProposal XtextTemplateProposal proposal = new XtextTemplateProposal( res.getTemplate(), tplctx, r, i); return proposal; } catch (RuntimeException e1) { throw e1; } catch (Exception e2) { throw new WrappedException(e2); } }
public Class<? extends ITemplateProposalProvider> bindITemplateProposalProvider() { return DefaultTemplateProposalProvider.class; }
public Class<? extends DefaultTemplateProposalProvider> bindDefaultTemplateProposalProvider() { return CooperateTemplateProposalProvider.class; }