I am having trouble getting my proposal provider to work properly. My objective is to provide a list of all possible imports a user can create. I can verify that the class is bound properly and is getting called on assist request from the editor. I can even see proposals being created and passed to the acceptor but nothing shows up in the editor.
So my question may be two part:
- Can you see what I may be doing wrong in the following code as to explain content assist not showing in the editor
- Can you explain the difference between the dispatch methods for Assignment, RuleCall, and Keyword? I find that all three methods are hit for the same content assist request, so what exactly do I code differently and what do they do differently?
Also I am using CodeMirror if that has any effect.
class mydslContentAssist extends IdeContentProposalProvider{
@Inject extension mydslGrammarAccess stAccess
@Inject mydslGlobalScopeProvider sp
@Inject extension IQualifiedNameProvider
override dispatch createProposals(Assignment assignment, ContentAssistContext context, IIdeContentProposalAcceptor acceptor) {
switch(assignment) {
case stAccess.libraryModelAccess.importsAssignment_0: {
var libs = sp.descriptionData.getExportedObjectsByType(ModelPackage.eINSTANCE.libraryModel)
for (lib : libs.filter[(EObjectOrProxy as LibraryModel).name.startsWith(context.prefix)]) {
var proposal = proposalCreator.createProposal('import ' + (lib.EObjectOrProxy as LibraryModel).name + ".*;", context) [
source = lib
description = "import entire library contents"
]
acceptor.accept(proposal, proposalPriorities.getDefaultPriority(proposal))
}
}
default : {
super._createProposals(assignment, context, acceptor)
}
}
}
override dispatch createProposals(RuleCall rulecall, ContentAssistContext context, IIdeContentProposalAcceptor acceptor) {
switch(rulecall.rule) {
case importRule: {
var libs = sp.descriptionData.getExportedObjectsByType(ModelPackage.eINSTANCE.libraryModel)
for (lib : libs) {
var proposal = proposalCreator.createProposal('import ' + (lib.EObjectOrProxy as LibraryModel).name + ".*;", context) [
source = lib
description = "import entire library contents"
]
acceptor.accept(proposal, proposalPriorities.getDefaultPriority(proposal))
}
}
default : {
super._createProposals(rulecall, context, acceptor)
}
}
}
override dispatch createProposals(Keyword keyword, ContentAssistContext context, IIdeContentProposalAcceptor acceptor) {
switch (keyword) {
case stAccess.importAccess.importKeyword_0: {
var libs = sp.descriptionData.getExportedObjectsByType(ModelPackage.eINSTANCE.libraryModel)
for (lib : libs) {
var proposal = proposalCreator.createProposal('import ' + (lib.EObjectOrProxy as LibraryModel).name + ".*;", context) [
source = lib
description = "import entire library contents"
]
acceptor.accept(proposal, proposalPriorities.getDefaultPriority(proposal))
}
}
default: {
super._createProposals(keyword, context, acceptor)
}
}
}
}
EDIT: My code is only being hit when calling content assist when typing the 'import' keyword. But not when typing the importedNamespace string