<div dir="ltr"><div>On Mon, Aug 29, 2016 at 5:14 AM, Matthew Brush <span dir="ltr"><<a href="mailto:mbrush@codebrainz.ca" target="_blank">mbrush@codebrainz.ca</a>></span> wrote:<br></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi All,<br>
<br>
Related to my previous mail, and assuming it is somewhat reasonable, I would like to propose a list of initial features that will be useful to allow plugins to provide, in no particular order:<br>
<br>
----<br>
<br>
Syntax Highlighting<br>
-------------------<br>
<br>
Most likely using an API based on/similar to Scintilla's "container lexers".<br>
<br>
At the minimum, it could have a callback something like:<br>
<br>
    gboolean (*highlight)(GeanyPlugin*, GeanyDocument*,<br>
        guint start_pos, guint end_pos, gpointer user_data);<br>
<br>
As with Scintilla's "container lexer", it would just tell the provider what and where to highlight. It might be pointless providing `end_pos` it could probably just highlight a whole line at time (maybe like Scintilla's 'style-needed' notification).<br>
<br>
If the providers are to setup their own colour schemes and such, then it may be required to add a callback such as:<br>
<br>
    gboolean (*init_styles)(GeanyPlugin*, GeanyDocument*,<br>
        gpointer user_data);<br>
<br>
for the plugin to configure all the Scintilla styles as it wishes. This will probably require some kind of conflict avoidance scheme if it is to support multiple providers providing the same feature. Perhaps it could also pass the start style ID the provider can use, and it could tell Geany the maximum style that it ended up using.<br>
<br>
Sidebar Symbol Tree<br>
-------------------<br>
<br>
Could provide some API functions to populate the tree by plugins providing the needed information. The nesting could be handled by passing a scope path similar to GtkTreePath or TagManager's `::` delimited scope string, which would be parsed/expanded to apply to the right tree node.<br>
<br>
The callback function for the provider might be like:<br>
<br>
    gboolean (*populate_symbols_tree)(Geany<wbr>Plugin*, GeanyDocument*,<br>
        guint cursor_pos, gchar **current_node_path /* out */,<br>
        gpointer user_data);<br>
<br>
When the providers are called in to, they could use a function something like this:<br>
<br>
    void tagbar_add_node(const gchar *name, guint line,<br>
        const gchar *signature, const gchar *scope_path,<br>
        GeanySidebarIcon icon);<br>
<br>
I haven't looked closely at the existing sidebar/symbols code yet, maybe it already provides such a function that could be used. It has also been mentioned that this could be done using the TagManager API. Plugins would walk their own internal ASTs or tag lists and build up the TM tag array, and Geany would use it for updating the symbols tree as it currently does (IIUC). I don't know much about TM so I can't really give an example callback for such an API.<br>
<br>
Auto-Completion/Intellisense<br>
----------------------------<br>
<br>
This could be triggered at the exact same time in the same way it is now (and re-using the same preferences). It could call a callback function in the ft-plugins like:<br>
<br>
    gboolean (*complete_at)(GeanyPlugin *, GeanyDocument *,<br>
        guint position, const gchar *partial_word,<br>
        GPtrArray completion_list /* out */, gpointer user_data);<br>
<br>
The `completion_list` would be filled in with whatever the provider thinks could be completed at `position`. It could be made more advanced in the future like allowing plugins to give icons, argument lists, documentation comment text, etc. For now it could just give strings to directly populate Scintilla's auto-complete listbox.<br>
<br>
Calltips<br>
--------<br>
<br>
To provide calltips, a provider could be called into like:<br>
<br>
    gboolean (*provide_calltips)(GeanyPlugi<wbr>n*, GeanyDocument*,<br>
        guint position, const gchar *symbol,<br>
        GPtrArray *overloads /* out */, gpointer user_data);<br>
<br>
The `overloads` array would populated by the provider with the various overloads for the given `symbol` (function). As with auto-completion, at first this could just be a list of overloads represented as strings which directly populate Scintilla's calltip infos. This could be enhanced in the future to provide documentation comment text and placeholder insertion points into the editor in the future, but for now should be kept simple (see GtkSourceView, XCode, etc).<br>
<br>
Go To Declaration/Definition<br>
----------------------------<br>
<br>
This could be either single callback passing a parameter to tell whether declaration or definition, or two separate callbacks. An example of the callbacks could be:<br>
<br>
    struct SourceLocation { gchar *filename; guint position; };<br>
<br>
    gboolean (*get_declaration_location)(Ge<wbr>anyPlugin*, GeanyDocument*,<br>
        guint position, const gchar *symbol,<br>
        GPtrArray *results, gpointer user_data);<br>
<br>
and likewise for `get_definition_location`. The `results` array could be populated with `SourceLocation`s for each possible definition/declaration. For example there might be multiple declarations in different `#if` blocks you could jump to, for C-like languages. Geany already provides a UI popup list to pick where to jump, this should be re-used.<br>
<br>
Build/Run Support<br>
-----------------<br>
<br>
I haven't thought much on this yet, but in general there should be a way for ft-plugins to get called into when a the build/run features are activated.<br>
<br>
Diagnostics<br>
-----------<br>
<br>
I also haven't thought much on this yet. It needs to be possible for ft-plugins, after getting notified of build/run events, to be able to update diagnostics information.<br>
<br>
Some of the diagnostics display might include:<br>
<br>
- Scintilla marker margin icons, indicating the type of diagnostic info present for each line (could be more than one per line).<br>
- Scintilla indicators (little coloured squigglies) showing the specific range(s) of code where the diagnostics apply.<br>
- Scintilla annotations giving further details on request.<br>
- Tooltip messages when hovering over the marker margins or squigglied text giving further details.<br>
- Putting lines of diagnostics info in the msgwin compiler tab (already supported to some extent IIUC).<br>
<br>
Refactoring<br>
-----------<br>
<br>
This is just an idea that is probably long in the future, but ft-plugins could provide some common re-factorings (ex. rename, generate definition code, etc). I haven't thought on this much at all yet.<br>
<br>
----<br>
<br>
Almost surely I have left some out. What do you think?<br>
<br>
Cheers,<br>
Matthew Brush<br>
______________________________<wbr>_________________<br>
Devel mailing list<br>
<a href="mailto:Devel@lists.geany.org" target="_blank">Devel@lists.geany.org</a><br>
<a href="https://lists.geany.org/cgi-bin/mailman/listinfo/devel" rel="noreferrer" target="_blank">https://lists.geany.org/cgi-bi<wbr>n/mailman/listinfo/devel</a></blockquote><div><br></div><div><br></div><div><br></div>Hi Matthew,<div><br></div><div>sounds good. This is much more lightweight than how #1195 and various other discussions sounded, I'm happy :-).</div><div><br></div><div>All the described functions look good to me in principle except the sidebar symbol tree one. The current code is quite complex (I was fixing some minor issues there and spent a lot of time thinking if it could be simplified but I don't think so). The problem is this: if a file is reparsed and you get new symbols, if you just cleared the tree and repopulated it with the new tags, the tree would jump to the beginning no matter where the scrollbar was before. So what the code does now is it compares the old and new tags, removes the tags that aren't present in the new tags array and inserts new tags which weren't present in the old tag array to the right position. If you have a look at the code, this isn't probably something you want to write in a plugin :-). So a plugin should provide the full list of new tags so the tree can do all this diffing and updating.</div><div><br></div><div>Which brings me to a question - do you plan to generate TMTag(s) and feed them to the tag manager instead of the ctags ones? It shouldn't be that hard and if you do this, you could have the sidebar symbols updated for free.</div><div><br></div><div>These fields in TMTag are unused, don't waste time filling them:</div><div><br></div><div><div><span class="" style="white-space:pre">       </span>gboolean local; /**< Is the tag of local scope */</div><div><span class="" style="white-space:pre">       </span>guint pointerOrder;</div><div><span class="" style="white-space:pre">        </span>char *inheritance; /**< Parent classes */</div><div><span class="" style="white-space:pre">       </span>char access; /**< Access type (public/protected/private/etc.) */</div><div><span class="" style="white-space:pre">        </span>char impl; /**< Implementation (e.g. virtual) */</div></div><div><br></div><div>Cheers,</div><div><br></div><div>Jiri </div></div><br></div></div>