Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: extract reference tags #3579

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Tmain/json-output-format.d/stdout-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
{"_type": "ptag", "name": "TAG_KIND_DESCRIPTION", "parserName": "Man", "path": "s,section", "pattern": "sections"}
{"_type": "ptag", "name": "TAG_KIND_DESCRIPTION", "parserName": "Man", "path": "t,title", "pattern": "titles"}
{"_type": "ptag", "name": "TAG_KIND_DESCRIPTION", "parserName": "Python", "path": "I,namespace", "pattern": "name referring a module defined in other file"}
{"_type": "ptag", "name": "TAG_KIND_DESCRIPTION", "parserName": "Python", "path": "Y,unknown", "pattern": "name referring a class/variable/function/module defined in other module"}
{"_type": "ptag", "name": "TAG_KIND_DESCRIPTION", "parserName": "Python", "path": "Y,unknown", "pattern": "unknwon name"}
{"_type": "ptag", "name": "TAG_KIND_DESCRIPTION", "parserName": "Python", "path": "c,class", "pattern": "classes"}
{"_type": "ptag", "name": "TAG_KIND_DESCRIPTION", "parserName": "Python", "path": "f,function", "pattern": "functions"}
{"_type": "ptag", "name": "TAG_KIND_DESCRIPTION", "parserName": "Python", "path": "i,module", "pattern": "modules"}
Expand All @@ -97,6 +97,7 @@
{"_type": "ptag", "name": "TAG_ROLE_DESCRIPTION", "parserName": "C", "kindName": "struct", "path": "foreigndecl", "pattern": "declared in foreign languages"}
{"_type": "ptag", "name": "TAG_ROLE_DESCRIPTION", "parserName": "Go", "kindName": "package", "path": "imported", "pattern": "imported package"}
{"_type": "ptag", "name": "TAG_ROLE_DESCRIPTION", "parserName": "Go", "kindName": "unknown", "path": "receiverType", "pattern": "receiver type"}
{"_type": "ptag", "name": "TAG_ROLE_DESCRIPTION", "parserName": "Python", "kindName": "class", "path": "super", "pattern": "super class"}
{"_type": "ptag", "name": "TAG_ROLE_DESCRIPTION", "parserName": "Python", "kindName": "module", "path": "imported", "pattern": "imported modules"}
{"_type": "ptag", "name": "TAG_ROLE_DESCRIPTION", "parserName": "Python", "kindName": "module", "path": "indirectlyImported", "pattern": "module imported in alternative name"}
{"_type": "ptag", "name": "TAG_ROLE_DESCRIPTION", "parserName": "Python", "kindName": "module", "path": "namespace", "pattern": "namespace from where classes/variables/functions are imported"}
Expand Down
4 changes: 4 additions & 0 deletions Tmain/list-roles.d/stdout-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ Protobuf D/protodef imported on imported
Protobuf m/message extension on extending the message
Python Y/unknown imported on imported from the other module
Python Y/unknown indirectlyImported on classes/variables/functions/modules imported in alternative name
Python Y/unknown ref off (EXPERIMENTAL)referenced anyhow
Python c/class super on super class
Python i/module imported on imported modules
Python i/module indirectlyImported on module imported in alternative name
Python i/module namespace on namespace from where classes/variables/functions are imported
Expand Down Expand Up @@ -224,6 +226,8 @@ Protobuf D/protodef imported on imported
Protobuf m/message extension on extending the message
Python Y/unknown imported on imported from the other module
Python Y/unknown indirectlyImported on classes/variables/functions/modules imported in alternative name
Python Y/unknown ref off (EXPERIMENTAL)referenced anyhow
Python c/class super on super class
Python i/module imported on imported modules
Python i/module indirectlyImported on module imported in alternative name
Python i/module namespace on namespace from where classes/variables/functions are imported
Expand Down
5 changes: 5 additions & 0 deletions Units/parser-python.r/reftag.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
--sort=no
--extras=+r
--fields=+r
--kinds-Python=*
--roles-Python.{unknown}=+{ref}
20 changes: 20 additions & 0 deletions Units/parser-python.r/reftag.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
a.b input.py /^import a.b$/;" i roles:imported
object input.py /^class X(object):$/;" c roles:super
X input.py /^class X(object):$/;" c roles:def
__init__ input.py /^ def __init__(self, n):$/;" m class:X roles:def
self input.py /^ def __init__(self, n):$/;" z member:X.__init__ file: roles:def
n input.py /^ def __init__(self, n):$/;" z member:X.__init__ file: roles:def
n input.py /^ self.n = n$/;" Y member:X.__init__ roles:ref
n input.py /^ self.n = n$/;" Y member:X.__init__ roles:ref
val input.py /^ def val(self):$/;" m class:X roles:def
self input.py /^ def val(self):$/;" z member:X.val file: roles:def
n input.py /^ return self.n$/;" Y member:X.val roles:ref
one input.py /^def one():$/;" f roles:def
X input.py /^ return X(1)$/;" Y function:one roles:ref
two input.py /^def two():$/;" f roles:def
X input.py /^ return X(2)$/;" Y function:two roles:ref
print input.py /^print (one().val() + two().val())$/;" Y roles:ref
one input.py /^print (one().val() + two().val())$/;" Y roles:ref
val input.py /^print (one().val() + two().val())$/;" Y roles:ref
two input.py /^print (one().val() + two().val())$/;" Y roles:ref
val input.py /^print (one().val() + two().val())$/;" Y roles:ref
18 changes: 18 additions & 0 deletions Units/parser-python.r/reftag.d/input.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import a.b

class X(object):
def __init__(self, n):
self.n = n

def val(self):
return self.n

def one():
return X(1)

def two():
return X(2)

print (one().val() + two().val())


4 changes: 4 additions & 0 deletions Units/parser-python.r/simple.py.d/expected.tags
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ this input.py /^ @blah class this is seen???$/;" kind:class l
_test.ignored_function.more_nesting.deeply_nested.even_more.this input.py /^ @blah class this is seen???$/;" kind:class line:41 language:Python scope:member:_test.ignored_function.more_nesting.deeply_nested.even_more file: inherits: access:private roles:def extras:qualified end:42 decorators:blah
this input.py /^ @bleh def this also? good!$/;" kind:member line:42 language:Python scope:class:_test.ignored_function.more_nesting.deeply_nested.even_more.this access:public roles:def end:42 decorators:bleh
_test.ignored_function.more_nesting.deeply_nested.even_more.this.this input.py /^ @bleh def this also? good!$/;" kind:member line:42 language:Python scope:class:_test.ignored_function.more_nesting.deeply_nested.even_more.this access:public roles:def extras:qualified end:42 decorators:bleh
one input.py /^class two (one):$/;" kind:class line:46 language:Python roles:super extras:reference
two input.py /^class two (one):$/;" kind:class line:46 language:Python inherits:one access:public roles:def end:48
only input.py /^ def only(arg):$/;" kind:member line:48 language:Python scope:class:two access:public signature:(arg) roles:def end:48
two.only input.py /^ def only(arg):$/;" kind:member line:48 language:Python scope:class:two access:public signature:(arg) roles:def extras:qualified end:48
A input.py /^(A, B,$/;" kind:class line:53 language:Python roles:super extras:reference
B input.py /^(A, B,$/;" kind:class line:53 language:Python roles:super extras:reference
C input.py /^C):$/;" kind:class line:54 language:Python roles:super extras:reference
three input.py /^three\\$/;" kind:class line:52 language:Python inherits:A, B, C access:public roles:def end:54
foo input.py /^foo($/;" kind:function line:57 language:Python access:public signature:( x , y, z) roles:def end:60
input.py input.py 1;" kind:file line:1 language:Python roles:def extras:inputFile end:60
Loading