Added support for scoped function calltips #1176
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I created function read_scope_prefix which is similar to read_current_word. It gets the scope of the word the cursor is on:
if the user types: ScopeA::ScopeB::Function
it will return ScopeA::ScopeB
Then I used my read_scope_prefix function in editor_show_calltip where find_calltips is called. To find_calltips I added an argument const gchar *scope to send the value over. Then, inside find_calltips the function tm_workspace_find (which then calls fill_find_tags_array) is called. tm_workspace_find & fill_find_tags_array already had a scope argument that was unused, so I just passed in the scope argument.
However, in fill_find_tags_array, when passed a non-null scope it filters any tags that are not exactly equal to that scope. E.g. if you have ClassA { setterFunc(abc) {} } ClassA::setterFunc will work but then ClassA obj.setterFunc will no longer work because scope != NULL. So I added a check inside fill_find_tags_array. First, it loops through the list of tags and attempts to find an exact match for the scope being typed, if it doesn't find a match, the function will just ignore the scope as if it had been set to NULL from the start.