Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Template Proposal does not fully work
Template Proposal does not fully work [message #1385163] Wed, 04 June 2014 16:59
Arne Johanson is currently offline Arne JohansonFriend
Messages: 3
Registered: May 2014
Junior Member

I am using Xtext to implement a DSL. As Xtext itself does not provide means to implement context-sensitive template proposals for content assist, I am forced to use JFace's TemplateProposal (which I have no knowledge of). The idea is to create a JFace TemplateProposal and pass it as an argument to the accept method of an implementation of ICompletionProposalAcceptor that is provided by Xtext.
All of this works fine except for the fact that the ${cursor} variable is not replaced with an empty string in the document but appears as "cursor" (but apart fro that does its job). Additionally, once I accept a proposal, the whitespace behind the insertion point of the proposal gets messed up sometimes (i.e., new lines get deleted). As I received no answer in the Xtext forum I wanted to show my implementation to you and ask whether you have any idea what goes wrong.

Thanks in advance!

This is my helper function to create a TemplateProposal (written in Xtend):
def TemplateProposal createTemplateProposal(
	String template,
	String name,
	String description,
	String contextTypeId,
	String icon,
	int relevance,
	ContentAssistContext context
) {
	new TemplateProposal(
		new Template(name, description, contextTypeId, template, true),
		new DocumentTemplateContext(
			new TemplateContextType(contextTypeId, name),

It gets called by this:
override completeEntity_Attributes(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
def String recordSkeletonProposal() '''
	record "${description}" @${frequency} : ${cursor}
def TemplateProposal createRecordTemplateProposal(ContentAssistContext context) {
		"Record expression",

Previous Topic:CommonViewer / CommonNavigator with default EditActions
Next Topic:Help icon in JFace Wizard
Goto Forum:

Current Time: Thu Apr 22 12:22:38 GMT 2021

Powered by FUDForum. Page generated in 0.02190 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top