Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign

CC plugin interface redesign

<< < (20/28) > >>

dmoore:
alpha: my latest svn rev is now in sync with your branch and now more or less correctly displays call tips with highlighting.

Alpha:

--- Quote from: dmoore on November 03, 2013, 01:59:25 am ---
--- Quote from: Alpha on November 02, 2013, 09:17:42 pm ---
--- Quote from: dmoore on November 02, 2013, 05:49:35 pm ---So it turns out that the old default STC behavior of appending a ? and a number e.g. "print?1" also works.

--- End quote ---
If that works, then the revision you are compiling against is out of date.  Also, it is unnecessary now; instead assign the number to the (new) category member of CCToken.

--- End quote ---
But is there any good reason not to support the stc method? The stc control wants the symbol?category syntax so why not just support that?

--- End quote ---
The stc method is still supported (except it must be '\n'); if you do not set the category member, CCManager will not attempt to append it, so "symbol\ncategory" will work.  I changed both the separator and type separator from defaults because I was becoming frustrated with strange bugs when a returned token contained one of these.  I selected two characters that should never exist in a token: '\n' and '\r'.
Having category as a member, though, will allow CCManager to more easily do things like provide a standard set of icons, and add an offset to the values (planned ideas, no code yet written).


--- Quote from: dmoore on November 03, 2013, 01:59:25 am ---So argsPos is always the stc position of the opening brace?

--- End quote ---
That is my intention.


--- Quote from: dmoore on November 03, 2013, 01:59:25 am ---What if the user presses "," but the cursor is not in a function call (e.g. python tuple or list)? Will GetCallTip be called and should the plugin return nothing?

--- End quote ---
Yes, my thoughts were that: rather than having a ccPlugin check every change to an editor to see if it should take an action, filter it so only the 'interesting' changes notify the plugin(s), and then the plugin can decide if it was a false positive.


--- Quote from: dmoore on November 03, 2013, 01:59:25 am ---No need to - use the time to create doc strings  :). I should be able to keep up with your changes.

--- End quote ---
::) I was writing just for myself for a while... I guess I need to start on some more documentation though.


--- Quote from: dmoore on November 03, 2013, 02:49:16 am ---Neither of those checks return true because it seems that the call occurs before the lexer is set. Also, how will you handle the case where the user changes the highlight language to something else? It looks like your code only checks once for each editor, no? What was wrong with the old mechanism? Surely it wasn't that inefficient to ping a few plugins before each call? (I don't mind you changing as long as it works!)

--- End quote ---
Strange... it seems to work with the main CC plugin.  I will look into it.
It will check editors multiple times; it only skips the check if it is on the same editor that was last called.  I did this because GetProviderStatusFor() could potentially do multiple string comparisons, and I did not want to worry about avoiding calling this multiple times in quick succession.  (Also, the structure is there so I can add some more planned logic into each time a check is called on a new editor.)

dmoore:
If you want to test the provider stuff in my plugin you need to remove the first line of the provider method which immediately returns "active".

Btw, most of this is working really well! When you are happy with this part of the interface and it is stable, I suggest you merge it back to trunk before you move on to symbol browsing.

dmoore:
Re docs, the main thing is to put doc strings in cbplugin.h for the virtual methods that explain the things you have explained to me in this thread. I should be able to help with this.

Alpha:

--- Quote from: dmoore on November 03, 2013, 06:25:01 pm ---If you want to test the provider stuff in my plugin you need to remove the first line of the provider method which immediately returns "active".

--- End quote ---
Should work now.
Some comments on your plugin; I did add default implementations for DoAutocomplete(), so these can be removed (until such a time as you decide to override them).  Avoid calls to control->GetCurrentPos() on any functions where CCManager passes you a position (although the passed position is sometimes the current position, it is not always).  The main CC plugin (@devs: we might need to rename this plugin at some point, to reduce confusion) checks against GetHighlightLanguage() because wxSCI_LEX_CPP lexer is being multipurposed for about seven other languages, but with Python, a simple ID comparison should be fine.

--- Code: ---Index: PythonCodeCompletion.cpp
===================================================================
--- PythonCodeCompletion.cpp (revision 434)
+++ PythonCodeCompletion.cpp (working copy)
@@ -7,7 +7,6 @@
 #include <cbeditor.h>
 #include <cbstyledtextctrl.h>
 #include <editor_hooks.h>
-#include <editorcolourset.h>
 #include <configmanager.h>
 #include <logmanager.h>
 //
@@ -399,10 +398,7 @@
 
 PythonCodeCompletion::CCProviderStatus PythonCodeCompletion::GetProviderStatusFor(cbEditor* ed)
 {
-    return ccpsActive; // WORKAROUND UNTIL ALPHA FIXES THIS
     Manager::Get()->GetLogManager()->Log(_("PYCC: Provider status check"));
-    if (ed->GetLanguage() == ed->GetColourSet()->GetHighlightLanguage(wxSCI_LEX_PYTHON))
-        return ccpsActive;
     if (ed->GetControl()->GetLexer()==wxSCI_LEX_PYTHON)
         return ccpsActive;
     Manager::Get()->GetLogManager()->Log(_("PYCC: Provider status check INACTIVE"));
@@ -529,18 +525,6 @@
     return doc;
 }
 
-/// callbacks for actually autocompleting/writing the token to the editor
-void PythonCodeCompletion::DoAutocomplete(const CCToken& token, cbEditor* ed)
-{
-    return;
-}
-
-void PythonCodeCompletion::DoAutocomplete(const wxString& token, cbEditor* ed)
-{
-    DoAutocomplete(CCToken(-1, token), ed);
-}
-
-
 void PythonCodeCompletion::RequestCompletion(cbStyledTextCtrl *control, int pos, const wxString &filename)
 {
     int line = control->LineFromPosition(pos);
Index: PythonCodeCompletion.h
===================================================================
--- PythonCodeCompletion.h (revision 434)
+++ PythonCodeCompletion.h (working copy)
@@ -121,9 +121,6 @@
         virtual std::vector<CCToken> GetTokenAt(int pos, cbEditor* ed);
         /// dismissPopup is false by default
         virtual wxString OnDocumentationLink(wxHtmlLinkEvent& event, bool& dismissPopup);
-        /// callbacks for actually autocompleting/writing the token to the editor
-        virtual void DoAutocomplete(const CCToken& token, cbEditor* ed);
-        virtual void DoAutocomplete(const wxString& token, cbEditor* ed);
 
     protected:
         /** Any descendent plugin should override this virtual method and
Index: PythonCodeCompletion-unix.cbp
===================================================================
--- PythonCodeCompletion-unix.cbp (revision 434)
+++ PythonCodeCompletion-unix.cbp (working copy)
@@ -23,7 +23,7 @@
  <Option type="3" />
  <Option compiler="gcc" />
  <Option parameters="--debug-log --multiple-instance -ni -v -p debug" />
- <Option host_application="/home/damien/src/codeblocks-cc/src/devel/codeblocks" />
+ <Option host_application="../../codeblocks-cc/src/devel/codeblocks" />
  <Option run_host_application_in_terminal="1" />
  <Compiler>
  <Add option="-ansi" />

--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version