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

Vala parser (in progress) #2677

Draft
wants to merge 44 commits into
base: master
Choose a base branch
from
Draft

Conversation

masatake
Copy link
Member

@masatake masatake commented Oct 25, 2020

@coveralls
Copy link

coveralls commented Oct 25, 2020

Coverage Status

Coverage increased (+0.02%) to 87.216% when pulling a8a03f2 on masatake:vala into 165f7e3 on universal-ctags:master.

@codecov
Copy link

codecov bot commented Oct 25, 2020

Codecov Report

Attention: 32 lines in your changes are missing coverage. Please review.

Comparison is base (0ae4783) 85.02% compared to head (bb54fdb) 85.10%.
Report is 140 commits behind head on master.

Files Patch % Lines
parsers/vala.c 93.49% 24 Missing ⚠️
main/tokeninfo.c 79.48% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2677      +/-   ##
==========================================
+ Coverage   85.02%   85.10%   +0.07%     
==========================================
  Files         228      229       +1     
  Lines       53901    54345     +444     
==========================================
+ Hits        45832    46252     +420     
- Misses       8069     8093      +24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@masatake
Copy link
Member Author

@rrthomas, I need your help.

var x = 1;

For x in the input, which "kind" I should assign to it.

I tried anjuta-tags installed via Fedora's repository. However, it seems that it has no Vala parser.

The kinds set of the vala parser we are working on is based on anjuta-tags.
The kinds we have in the vala parser are:

#LETTER NAME        ENABLED REFONLY NROLES MASTER DESCRIPTION
E       errordomain yes     no      0      NONE   error domains
S       signal      yes     no      0      NONE   signals
c       class       yes     no      0      NONE   classes
d       delegate    yes     no      0      NONE   delegates
e       enum        yes     no      0      NONE   enumerations
f       field       yes     no      0      NONE   fields
i       interface   yes     no      0      NONE   interfaces
l       local       no      no      0      NONE   local variables
m       method      yes     no      0      NONE   methods
n       namespace   yes     no      0      NONE   namespace
p       property    yes     no      0      NONE   properties
r       errorcode   yes     no      0      NONE   error codes
s       struct      yes     no      0      NONE   structures
v       enumvalue   yes     no      0      NONE   enumeration Values

I cannot find variable kind. Should I add variable kind? or should I use the "field" kind instead?
In this case, how I should fill the "scope:" field?
Does vala have "main" or "top-level" something implicit namespace for dealing with a variable as a member?

@masatake
Copy link
Member Author

/*
 * vala HelloWorld
 */
void main(string[] args) {
    print("Hello, World\n");
}

In this test case, main is tagged as a method.
So the x should be recorded as a field.

@rrthomas
Copy link
Contributor

@masatake: anjuta-tags uses libvala's Vala parser.

Your analysis sounds right: it looks like it's a field.

@masatake
Copy link
Member Author

# public domain
# This one is for https://gitlab.gnome.org/GNOME/vala/-/blob/master/doc/manual/manual.xml
--langdef=valaManualXML
--map-valaManualXML=+(manual.xml)
--kinddef-valaManualXML=r,rule,syntax rules
--regex-valaManualXML=/<para>([^:]+):<\/para>/\1/r/

@masatake
Copy link
Member Author

@rrthomas, thank you.

anjuta-tags uses libvala's Vala parser.

It is the reason why anjuta-tags emits nothing for input.vala?
Can I use anjuta-tags for parsing vala input from the command line?

@rrthomas
Copy link
Contributor

It is the reason why anjuta-tags emits nothing for input.vala?

Sorry, I'm not sure what you're referring to. Is input.vala a particular file?

Can I use anjuta-tags for parsing vala input from the command line?

I don't think so, I think anjuta-tags only supports the same options as whatever version of ctags it was forked from. I don't think it exposes the Vala parser directly to the user.

@masatake
Copy link
Member Author

Sorry, I'm not sure what you're referring to. Is input.vala a particular file?

input.vala is u-ctags terminology. It means any input file written in Vala.

Can I use anjuta-tags for parsing vala input from the command line?
I don't think so, I think anjuta-tags only supports the same options as whatever version of ctags it was forked from. I don't think it exposes the Vala parser directly to the user.

I can't find "Vala" in "anjuta-tags --list-languages| grep -i vala".
I wonder the packager of the RPM package disables the parser when building.

@rrthomas
Copy link
Contributor

Sorry, I'm not sure what you're referring to. Is input.vala a particular file?

input.vala is u-ctags terminology. It means any input file written in Vala.

Ah, thanks for explaining.

I can't find "Vala" in "anjuta-tags --list-languages| grep -i vala".

$ anjuta-tags --list-languages|grep -i vala
Vala

I wonder the packager of the RPM package disables the parser when building.

Looks like it.

@albfan
Copy link
Contributor

albfan commented Oct 1, 2022

I'm just using this building as:

./autogen.sh
./configure --prefix /usr
make
DESTDIR=foo make install
sudo cp foo/usr/bin/ctags /usr/bin/ctags-vala

Will provide feedback but looks to parse almost everything. Any known blocker to merge? I think I can contribute again if needed

@masatake
Copy link
Member Author

masatake commented Oct 2, 2022

Will provide feedback but looks to parse almost everything. Any known blocker to merge? I think I can contribute again if needed

Thank you, but I cannot remember why I didn't merge this.

I read test cases to find the incompleteness of the parser.

A. typeref fields for methods should be filled.

void main(string[] args) {
...

The tag entry for the main is:

main	input.vala	/^void main(string[] args) {$/;"	kind:method	line:8	language:Vala	signature:(string [] args)	roles:def	end:13

The return type void should be storin to its typeref field.
I am disappoinhat I didn't implement the code for filling the field.

B. Semantics?

namespace X {
}

public class X.MyObject {

For X.MyObject, which tags should we make "X.MyObject" or "MyObjecRegardingr as reading a test case (qnamed-class.d), I expected ctags makes a tag for "X.MyObject".
However, I cannot convince whether this is a good idea or not.
Users may want to jump the definition of MyObject with an input key "MyObject", not "X.MyObject". Making a tag "X.MyObject" doesn't help the users' wants.

C. kinds having only stubs
K_DELEGATE, K_SIGNAL, K_LOCAL are not implemented. We can remove K_LOCAL. However, the rest of two may be too important.

D. Generics and other language features

B. is the primary blocker.
This is not only about Vala.
I wonder how did we do in the other languages.

Maybe we should make a reference tag for X of X.MyObject.
Then we should make a tag for MyObject which has X as scope.
This is the technique I found and introduced during hacking the JavaScript parser.

This "indirection through a reference tag" technique is nice because it is possible to make a tag for X.MyObject with --extras=+q notion if you want.

It seems in the year 2020, I didn't get the idea.

masatake and others added 9 commits December 10, 2023 05:31
Signed-off-by: Masatake YAMATO <[email protected]>
Fix a misleading comment.

Fix incorrect spacing of close brace.

Remove unnecessary conversion to bool.

Add an “else” before a mutually-exclusive “if”.
Attributes, in matched square brackets, should be ignored, as otherwise they
upset parsing.

Add a test.
Signed-off-by: Masatake YAMATO <[email protected]>
Signed-off-by: Masatake YAMATO <[email protected]>
Signed-off-by: Masatake YAMATO <[email protected]>
Signed-off-by: Masatake YAMATO <[email protected]>
Signed-off-by: Masatake YAMATO <[email protected]>
Signed-off-by: Masatake YAMATO <[email protected]>
Signed-off-by: Masatake YAMATO <[email protected]>
Signed-off-by: Masatake YAMATO <[email protected]>
Signed-off-by: Masatake YAMATO <[email protected]>
@rrthomas
Copy link
Contributor

Amazing work, @masatake!

@masatake
Copy link
Member Author

I added lines to parseClassBody. However, it seems that I should add them to recurseValaTags. I have to restart from 8e16ea9. I extended the test cases that valac accepted. So restarting is not so hard.

@masatake masatake added this to the 6.2 milestone Dec 28, 2023
@masatake masatake modified the milestones: 6.2, 6.3 Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants