|
Re: Completion proposal with multiple selected regions [message #1384742 is a reply to message #1384706] |
Sat, 31 May 2014 05:56 |
Arne Johanson Messages: 3 Registered: May 2014 |
Junior Member |
|
|
I found useful JFace classes to complete the task. This is my helper function to create a template proposal object that can be passed to an Xtext CompletionProposalAcceptor:
def TemplateProposal createTemplateProposal(
String template,
String name,
String description,
String contextTypeId,
String icon,
ContentAssistContext context
) {
new TemplateProposal(
new Template(name, description, contextTypeId, template, true),
new DocumentTemplateContext(
new TemplateContextType(contextTypeId, name),
context.document,
context.offset,
context.replaceContextLength
),
context.replaceRegion,
loadImage(icon)
)
}
However, a problem remains: if I use the ${cursor} variable to specify the location for the caret after editing, the word "cursor" is actually printed in the content proposal (but otherwise ${cursor} works as intended). Any suggestions why this is the case?
Besides this last question, I would really like to see Xtext-specific abstractions for this task (so that you don't have to fiddle around with JFace classes that -- at least to me -- don't seem to integrate well with the Xtext abstractions (why should I know something about TemplateContextTypes?)).
Cheers
Arne
|
|
|
Powered by
FUDForum. Page generated in 0.03183 seconds