Bug 77482 - Content extensibility context condition and cursor position bad
Summary: Content extensibility context condition and cursor position bad
Status: VERIFIED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 2.0.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 2.1   Edit
Assignee: Alain Magloire CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2004-11-02 11:06 EST by Tanya Wolff CLA
Modified: 2009-01-09 14:57 EST (History)
3 users (show)

See Also:


Attachments
fix for content assist extensibility (1.96 KB, patch)
2004-11-02 11:12 EST, Tanya Wolff CLA
bjorn.freeman-benson: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tanya Wolff CLA 2004-11-02 11:06:50 EST
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.
Comment 1 Tanya Wolff CLA 2004-11-02 11:12:53 EST
Created attachment 15562 [details]
fix for content assist extensibility
Comment 2 Alain Magloire CLA 2004-11-02 11:41:49 EST
Tanya,
 Do you need this for 2.1 also?

Cc:Mikhail can you reviewed the patch, for go or no go.

Thanks.
Comment 3 Andrew Niefer CLA 2004-11-02 11:56:28 EST
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.
Comment 4 Mikhail Voronin CLA 2004-11-02 13:28:10 EST
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.
Comment 5 Andrew Niefer CLA 2004-11-02 14:03:31 EST
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.
Comment 6 Mikhail Voronin CLA 2004-11-02 16:10:46 EST
I think this patch is important and need to be applied for 2.1.

Thanks,
Mikhail.
Comment 7 Alain Magloire CLA 2004-11-03 10:12:01 EST
Applied.

Please test.
Comment 8 Tanya Wolff CLA 2004-11-03 18:08:06 EST
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.