Skip to content

Commit

Permalink
Enable local variable and parameter tag reporting for various languages
Browse files Browse the repository at this point in the history
This patch enables local variable and function parameter reporting for
Python, GDScript, PHP, and Typescript.

Because these are dynamic languages and Geany scope autocompletion
relies on static type information, scope completion doesn't work for
these languages. However, at least we get non-scope autocompletion
for local variables and function parameters.

Local variables in GDScript were previously mapped to tm_tag_other_t
and were displayed in the sidebar. We don't display these tags for
C/C++ in the sidebar and they should also be mapped to
tm_tag_local_var_t which is why there is a diff in unit tests removing
these variables from the output.

The python parser generates a slightly different output when function
parameter parsing is enabled (whitespace only change) which causes
the change of the output of some python unit tests.
  • Loading branch information
techee committed Sep 2, 2022
1 parent 41b4012 commit 06e8bdc
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 66 deletions.
23 changes: 11 additions & 12 deletions src/tagmanager/tm_parser.c
Expand Up @@ -166,7 +166,7 @@ static TMParserMapEntry map_PHP[] = {
{'d', tm_tag_macro_t}, // define
{'f', tm_tag_function_t}, // function
{'i', tm_tag_interface_t}, // interface
{'l', tm_tag_undef_t}, // local
{'l', tm_tag_local_var_t}, // local
{'n', tm_tag_namespace_t}, // namespace
{'t', tm_tag_struct_t}, // trait
{'v', tm_tag_variable_t}, // variable
Expand All @@ -178,7 +178,7 @@ static TMParserMapGroup group_PHP[] = {
{_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
{_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
{_("Constants"), TM_ICON_MACRO, tm_tag_macro_t},
{_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
{_("Variables"), TM_ICON_VAR, tm_tag_variable_t | tm_tag_local_var_t},
{_("Traits"), TM_ICON_STRUCT, tm_tag_struct_t},
};

Expand All @@ -192,14 +192,14 @@ static TMParserMapEntry map_PYTHON[] = {
/* defined as externvar to get those excluded as forward type in symbols.c:goto_tag()
* so we can jump to the real implementation (if known) instead of to the import statement */
{'x', tm_tag_externvar_t}, // unknown
{'z', tm_tag_undef_t}, // parameter
{'l', tm_tag_undef_t}, // local
{'z', tm_tag_local_var_t}, // parameter
{'l', tm_tag_local_var_t}, // local
};
static TMParserMapGroup group_PYTHON[] = {
{_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
{_("Methods"), TM_ICON_MACRO, tm_tag_method_t},
{_("Functions"), TM_ICON_METHOD, tm_tag_function_t},
{_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
{_("Variables"), TM_ICON_VAR, tm_tag_variable_t | tm_tag_local_var_t},
{_("Imports"), TM_ICON_NAMESPACE, tm_tag_externvar_t},
};

Expand Down Expand Up @@ -969,16 +969,15 @@ static TMParserMapEntry map_GDSCRIPT[] = {
{'C', tm_tag_variable_t}, // const
{'g', tm_tag_enum_t}, // enum
{'e', tm_tag_variable_t}, // enumerator
{'z', tm_tag_other_t}, // parameter
{'l', tm_tag_other_t}, // local
{'z', tm_tag_local_var_t}, // parameter
{'l', tm_tag_local_var_t}, // local
{'s', tm_tag_variable_t}, // signal
};
static TMParserMapGroup group_GDSCRIPT[] = {
{_("Classes"), TM_ICON_CLASS, tm_tag_class_t},
{_("Methods"), TM_ICON_MACRO, tm_tag_method_t},
{_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
{_("Variables"), TM_ICON_VAR, tm_tag_variable_t | tm_tag_local_var_t},
{_("Enums"), TM_ICON_STRUCT, tm_tag_enum_t},
{_("Other"), TM_ICON_OTHER, tm_tag_other_t},
};

static TMParserMapEntry map_CLOJURE[] = {
Expand Down Expand Up @@ -1012,10 +1011,10 @@ static TMParserMapEntry map_TYPESCRIPT[] = {
{'e', tm_tag_enumerator_t}, // enumerator
{'m', tm_tag_method_t}, // method
{'n', tm_tag_namespace_t}, // namespace
{'z', tm_tag_undef_t}, // parameter
{'z', tm_tag_local_var_t}, // parameter
{'p', tm_tag_member_t}, // property
{'v', tm_tag_variable_t}, // variable
{'l', tm_tag_undef_t}, // local
{'l', tm_tag_local_var_t}, // local
{'C', tm_tag_macro_t}, // constant
{'G', tm_tag_undef_t}, // generator
{'a', tm_tag_undef_t}, // alias
Expand All @@ -1026,7 +1025,7 @@ static TMParserMapGroup group_TYPESCRIPT[] = {
{_("Interfaces"), TM_ICON_STRUCT, tm_tag_interface_t},
{_("Functions"), TM_ICON_METHOD, tm_tag_function_t | tm_tag_method_t},
{_("Enums"), TM_ICON_STRUCT, tm_tag_enum_t},
{_("Variables"), TM_ICON_VAR, tm_tag_variable_t},
{_("Variables"), TM_ICON_VAR, tm_tag_variable_t | tm_tag_local_var_t},
{_("Constants"), TM_ICON_MACRO, tm_tag_macro_t},
{_("Other"), TM_ICON_MEMBER, tm_tag_member_t | tm_tag_enumerator_t},
};
Expand Down
4 changes: 2 additions & 2 deletions tests/ctags/cython_sample.pyx.tags
Expand Up @@ -4,8 +4,8 @@ StdClass
class: StdClass
__init__�128�(self)�CDefClass�0
method: CDefClass :: __init__(self)
c_method�128�(self,int i)�CDefClass�0
method: CDefClass :: c_method(self,int i)
c_method�128�(self, int i)�CDefClass�0
method: CDefClass :: c_method(self, int i)
identity�16�(x)�0
function: identity(x)
int2string�16�(int i)�0
Expand Down
20 changes: 0 additions & 20 deletions tests/ctags/gdscript-inner-class.gd.tags
Expand Up @@ -22,14 +22,10 @@ _init
method: Peer :: _init(peer_id)
center�16384�Circle2D�0
variable: Circle2D :: center
close�524288�Lobby.leave�0
other: Lobby.leave :: close
color�16384�Circle2D�0
variable: Circle2D :: color
host�16384�Lobby�0�int
variable: int Lobby :: host
host_id�524288�Lobby._init�0�int
other: int Lobby._init :: host_id
id�16384�Peer�0
variable: Peer :: id
join�128�(peer_id, server)�Lobby�0�bool
Expand All @@ -40,16 +36,6 @@ lobbies
variable: Dictionary lobbies
lobby�16384�Peer�0
variable: Peer :: lobby
new_peer�524288�Lobby.join�0�WebSocketPeer
other: WebSocketPeer Lobby.join :: new_peer
peer_id�524288�Lobby.join�0
other: Lobby.join :: peer_id
peer_id�524288�Lobby.leave�0
other: Lobby.leave :: peer_id
peer_id�524288�Lobby.seal�0
other: Lobby.seal :: peer_id
peer_id�524288�Peer._init�0
other: Peer._init :: peer_id
peers�16384�0�Dictionary
variable: Dictionary peers
peers�16384�Lobby�0�Array
Expand All @@ -64,12 +50,6 @@ sealed
variable: bool Lobby :: sealed
server�16384�0�WebSocketServer
variable: WebSocketServer server
server�524288�Lobby.join�0
other: Lobby.join :: server
server�524288�Lobby.leave�0
other: Lobby.leave :: server
server�524288�Lobby.seal�0
other: Lobby.seal :: server
time�16384�Lobby�0
variable: Lobby :: time
time�16384�Peer�0
Expand Down
16 changes: 0 additions & 16 deletions tests/ctags/gdscript-modifiers.gd.tags
@@ -1,26 +1,10 @@
_create_block_collider�128�(block_sub_position)�0
method: _create_block_collider(block_sub_position)
a�524288�id�0
other: id :: a
b�524288�r�0
other: r :: b
block_id�524288�calculate_block_uvs�0
other: calculate_block_uvs :: block_id
block_sub_position�524288�_create_block_collider�0
other: _create_block_collider :: block_sub_position
c�524288�x�0
other: x :: c
calculate_block_uvs�128�(block_id)�0
method: calculate_block_uvs(block_id)
col�524288�calculate_block_uvs�0
other: calculate_block_uvs :: col
collider�524288�_create_block_collider�0
other: _create_block_collider :: collider
id�128�(a)�0
method: id(a)
r�128�(b)�0
method: r(b)
row�524288�calculate_block_uvs�0
other: calculate_block_uvs :: row
x�128�(c)�0
method: x(c)
14 changes: 0 additions & 14 deletions tests/ctags/gdscript-no-implicit-class.gd.tags
Expand Up @@ -38,20 +38,6 @@ foooooooo
method: String Something :: foooooooo()
inferred_type�16384�0
variable: inferred_type
local_var�524288�some_function�0
other: some_function :: local_var
local_var2�524288�some_function�0
other: some_function :: local_var2
lv�524288�_init�0
other: _init :: lv
p1�524288�something�0
other: something :: p1
p2�524288�something�0
other: something :: p2
param1�524288�some_function�0�Vector3
other: Vector3 some_function :: param1
param2�524288�some_function�0�int
other: int some_function :: param2
s�16384�0
variable: s
sig�16384�0
Expand Down
4 changes: 2 additions & 2 deletions tests/ctags/simple.py.tags
Expand Up @@ -26,8 +26,8 @@ deeply_nested
class: _test.ignored_function.more_nesting :: deeply_nested
even_more�128�()�_test.ignored_function.more_nesting.deeply_nested�0
method: _test.ignored_function.more_nesting.deeply_nested :: even_more()
foo�16�( x , y, z)�0
function: foo( x , y, z)
foo�16�( x, y, z)�0
function: foo( x, y, z)
ignored_function�16�()�_test�0
function: _test :: ignored_function()
more_nesting�16�()�_test.ignored_function�0
Expand Down

0 comments on commit 06e8bdc

Please sign in to comment.