Community
Participate
Working Groups
I extended the CHelpProvider extension point to provide a few functions for content assist. The code in addProposalsFromCompletionContributors is only executing for contexts of SINGLE_NAME_REFERENCE rather than NULL. The comment indicates "calling functions should only happen within the context of a code body." I don't think SINGLE_NAME_REFERENCE is a valid context. Also in the same function, a completion proposal on a function with arguments, when selected, puts the cursor at the end, rather than inside the brackets. Attaching a proposed patch.
Created attachment 15562 [details] fix for content assist extensibility
Tanya, Do you need this for 2.1 also? Cc:Mikhail can you reviewed the patch, for go or no go. Thanks.
completionNode.getCompletionContext() returns an IASTNode, and SINGLE_NAME_REFERENCE is a CompletionKind, so as it stands content assist will never propose completions from the extension without that change.
Tanya, I have couple of questions: 1) "I extended the CHelpProvider extension point to provide a few functions for content assist." Patch doesn't have changes for CHelpProvider. Do you plan any? 2) Indeed it's no value to compare IASTNode with CompletionKind. Question: Why we should look for completions if CompletionContext IS NULL? IMHO, I would suggest condition (completionNode.getCompletionKind()!= IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE) Thanks, Mikhail.
During a content assist, in addition to the kind, there are 3 things: prefix, scope, and context: void f(){ pre[^] //1 a->pre[^] //2 } For both 1 & 2, prefix == "pre", scope = the IASTFunction for f. in 1, context == null, in 2 context == IASTNode for a. We should probably only ask the extension for proposals when the context == null, since the extension mechanism doesnt allow for qualifying the proposals using ::, ., -> etc. The condition on the kind comes down to what kind of things is the extension going to return. If the extension only ever proposes functions that can be called, then we want kind == SINGLE_NAME_REFERENCE, if it also proposes types then we also want to accept kind == VARIABLE_TYPE At minimum, condition should probably be completionNode.getCompletionContext() == null to further restrict to places where we can call function from, it should be completionNode.getCompletionContext() && completionNode.getCompletionKind() == IASTCompletionNode.CompletionKind.SINGLE_NAME_REFERENCE This should probably be fixed for 2.1 if we want the content assist extension to work at all. We were not planning changes to CHelpProvider, we were just trying to test it wrt content assist.
I think this patch is important and need to be applied for 2.1. Thanks, Mikhail.
Applied. Please test.
Verified that the applied fix worked for my test. However, Andrew's suggestion to further restrict completion condition wasn't included in the patch. We can add that to the Head, but for 2.1 we now have a working content assist extensibility feature.