Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign
ClangComplete plugin
Alpha:
--- Quote from: Lalaland on November 20, 2011, 04:14:59 am ---Feature requesting is a little premature, I have to get the plugin working first.
--- End quote ---
You are right, I am quite early, sorry (although, it is sometimes hard to be patient... I will try to save these for later :)).
ollydbg:
--- Quote from: Lalaland on November 20, 2011, 04:14:59 am ---
--- Quote ---@Lalaland: I have a feature suggestion/request; assuming Clang reports whenever/wherever there is a parsing error, would it be possible for the ClangComplete plugin to put a red marker by the line(s) with errors, or underline (like spell-check) the specific token the error occurs in?
--- End quote ---
Feature requesting is a little premature, I have to get the plugin working first.
God, this issue of the menu not popping up in the middle of the word is getting stranger and stranger. The actual issue seems to be that wxScintilla thinks that the word is not being matched(and this is for code completion at the start as well). At the same time, other random words(such as double or class) seem to work. And what really is strange is that the words which works changes determining on where you do the completion.
Here is a video showing what is happening. I turned off autohide, so you can see how wxScintilla does not think anything is matched. I am also using a keyboard shortcut to start autocompletion.
http://youtu.be/kAjb2RwxGqg
(The text at the bottom is showing the string I am passing to show, with '|' set as the separator)
I also double checked the length of the strings churned out by clang. They are the right length as both cstrings and wxStrings, and seem to be fine when printed out(I even tried removing the first character by increasing the cstring by 1, and that worked as expected).
Following the debugger showed that I am putting the right value for the distance to the start of the word, so that is obviously not the issue.
I am truly stumped.
Does anyone have any clue about what is happening?
--- End quote ---
I have watch your video two times, but I have no idea what's your problem is........ :(
Edit:
I have see that you get code completion in comments?
You can simply filter it out, some code like:
--- Code: ---
// skip string or comment
const int style = control->GetStyleAt(Your_osition);
if (control->IsString(style) || control->IsComment(style))
{
do some thing;
}
--- End code ---
Lalaland:
All of those words I type in(double , struct, class) etc should cause the menu to jump to and highlight the right entry.
Normally, when it does not work, the dialog simply goes away. I just set the setting that makes the codecompletion list stay, but show no highlighted entry.
Notice the failed attempts at typing in double and char the first time, despite them being clearly visible in the list.
Struct does work, and you can see it jump and highlight the right entry.
Then, when I switch to another location, typing in the start of "double" immediately jumps to the double keyword, and struct fails to work.
This is what causes my codecompletion inside a word to seem to fail, it is correctly creating the list, but it believes there are no matches for that start of the word and hides the list immediately(when I have the normal autohide setting enabled).
EDIT: You are right, only things typed in the default style should be auto-completed. I just added that now. Exceptions can be added as they are found.
ollydbg:
I'm not sure what is the logic you show the auto completion list.
Edit:Oh, I see you use the similar code: https://github.com/Lalaland/ClangComplete/blob/master/ClangComplete.cpp
--- Code: ---clang_disposeCodeCompleteResults(results);
wxString final = GetStringFromArray(items, _("|"));
final.RemoveLast();
//control->CallTipShow(control->GetCurrentPos(), _("This is confusing"));
control->AutoCompSetIgnoreCase(true);
control->AutoCompSetCancelAtStart(false);
control->AutoCompSetAutoHide(false);
control->AutoCompSetSeparator('|');
control->AutoCompStops(_(""));
// final.RemoveLast();
//final = _("Hello boo");
control->AutoCompShow(pos-start,final );
wxString nums = _("pos: ");
nums<<pos ;
nums<<_(" start:");
nums<<start;
Manager::Get()->GetLogManager()->Log(final);
return 0;
--- End code ---
I just have a look at the current Codecompletion plugin's source code, see:
codecompletion.cpp line 1167.
--- Code: --- ed->GetControl()->AutoCompSetIgnoreCase(!caseSens);
ed->GetControl()->AutoCompSetCancelAtStart(true);
ed->GetControl()->AutoCompSetFillUps(m_CCFillupChars);
ed->GetControl()->AutoCompSetChooseSingle(m_IsAutoPopup ? false : m_CCAutoSelectOne);
ed->GetControl()->AutoCompSetAutoHide(true);
ed->GetControl()->AutoCompSetDropRestOfWord(m_IsAutoPopup ? false : true);
wxString final = GetStringFromArray(items, _T(" "));
final.RemoveLast(); // remove last space
ed->GetControl()->AutoCompShow(pos - start, final);
return 0;
}
--- End code ---
You see:
the items were the collected tokens strings. and the most important call is:
--- Code: ---ed->GetControl()->AutoCompShow(pos - start, final);
--- End code ---
This will do what you would like in your clang code completion.
see its declaration:
--- Code: --- // Display a auto-completion list.
// The lenEntered parameter indicates how many characters before
// the caret should be used to provide context.
void AutoCompShow(int lenEntered, const wxString& itemList);
--- End code ---
Hope this helps. :D
Edit:
This is the sample code I used to test CC:
--- Code: ---int abcd111;
int abcd212;
int abcd213;
int abcd414;
int abcd515;
abcd
--- End code ---
Lalaland:
God, the problem is solved. AutoCompShow needs the passed strings to be alphabetically sorted.
This fails because I sort my strings by priority.
Oh well, at least autocomplete in the middle of words works reliably now. I will post some pictures of this soon.
EDIT: And can we please add this to the doc
This ↓ tells me nothing about any sorting.
--- Code: --- // Display a auto-completion list.
// The lenEntered parameter indicates how many characters before
// the caret should be used to provide context.
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version