ContextCpp questions

Discussion about CodeLite development process and patches
jfouche
CodeLite Guru
Posts: 351
Joined: Mon Oct 20, 2008 7:26 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

ContextCpp questions

Post by jfouche »

Due to this problem, I need some clues about the ContextCpp class.

1 : What is the exact goal of the ContextCpp::GetExpression method ? Most of the time, it returns an empty string. And reading the code source, I don't understand what is the expected output regarding the caret position.
2 : What is the expression used for ?

Thanks
Jérémie
User avatar
eranif
CodeLite Plugin
Posts: 6373
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: ContextCpp questions

Post by eranif »

jfouche wrote:: What is the exact goal of the ContextCpp::GetExpression method ? Most of the time, it returns an empty string. And reading the code source, I don't understand what is the expected output regarding the caret position.
There are 2 main functions that being used for code-completion (and all other related functionalities, like 'goto declaration' etc):

Code: Select all

bool TagsManager::AutoCompleteCandidates(const wxFileName &fileName, int lineno, const wxString& expr, const wxString& text, std::vector<TagEntryPtr>& candidates)
bool TagsManager::WordCompletionCandidates(const wxFileName &fileName, int lineno, const wxString& expr, const wxString& text, const wxString &word, std::vector<TagEntryPtr> &candidates)
Both of this functions accept 'expr' as the third argument. An example would make it clear:

Assuming this code snippet:

Code: Select all

wxString str;
str.BeforeFirst(wxT('/')).B| // the | represents the caret current position
If you hit 'Ctrl-SPACE' at the caret position the expression is set to: 'str.BeforeFirst(wxT('/')).B'
The function 'ContextCpp::GetExpression' is responsible for extracting it from the editor and passing it 'TagsManager'

Just place a breakpoint at one of the two functions above (TagsManager::AutoCompleteCandidates & TagsManager::WordCompletionCandidates) and see the value of 'expr'

You could take a look at the 'CodeCompletionTests' workspace to see a simplified version of how these two methods are being used

Eran
Make sure you have read the HOW TO POST thread
Post Reply