Skip to content

feat: Add symbol listing for Qml - #79

Merged
LeonMatthesKDAB merged 2 commits into
KDAB:mainfrom
itzurabhi:Qml/tree-sitter-queries
Jul 25, 2024
Merged

LeonMatthesKDAB merged 2 commits into
KDAB:mainfrom
itzurabhi:Qml/tree-sitter-queries

Conversation

@itzurabhi

@itzurabhi itzurabhi commented Jul 1, 2024

Copy link
Copy Markdown
Contributor

symbol listing for Qml added.

@narnaud
narnaud self-requested a review July 2, 2024 14:16
@itzurabhi
itzurabhi force-pushed the Qml/tree-sitter-queries branch from 2454abe to 11c72d1 Compare July 5, 2024 09:23

@narnaud narnaud left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is on the right track. I didn't test it (I wonder if you see the symbols in the GUI yet), but the architecture definitely makes sense.

Comment thread src/core/codedocument_p.h Outdated
Comment thread src/core/codedocument_p.h Outdated
Comment thread src/core/cppdocument.h Outdated
Comment thread src/core/qmldocument.h Outdated

@LeonMatthesKDAB LeonMatthesKDAB left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks like a reasonable way forward 👍

One additional thing to consider though is that the FunctionSymbol class also runs a few small queries to figure out the names and types of parameters (see the argumentsFromQueryMatch function).

However, that is of course also C++-specific and won't work with QML.
We should try to find a solution for injecting the right behavior there as well.

Also added some minor nitpicks.

Comment thread src/core/codedocument_p.h
Comment thread src/core/codedocument_p.h Outdated
Comment thread src/core/qmldocument.cpp Outdated
Comment thread src/core/qmldocument.cpp Outdated
Comment thread src/core/qmldocument.cpp Outdated
@itzurabhi
itzurabhi force-pushed the Qml/tree-sitter-queries branch from 11c72d1 to 1cad851 Compare July 10, 2024 13:12
@itzurabhi

Copy link
Copy Markdown
Contributor Author

This is on the right track. I didn't test it (I wonder if you see the symbols in the GUI yet), but the architecture definitely makes sense.

yes we can

Comment thread src/core/qmldocument.cpp Outdated
Comment thread src/core/codedocument_p.h
Comment thread src/core/qmldocument.cpp Outdated
@itzurabhi
itzurabhi force-pushed the Qml/tree-sitter-queries branch from 1cad851 to 548670e Compare July 11, 2024 11:55
@itzurabhi
itzurabhi requested a review from narnaud July 11, 2024 12:06

@LeonMatthesKDAB LeonMatthesKDAB left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The separation of concerns looks clean 👍

What I'd like to see addressed before merging:

  1. Find a way to make FunctionSymbol::arguments compatible with Qml.
    • Currently it's not capturing the individual parameters as @parameter, so the FunctionSymbol will always report 0 arguments
    • The types of the arguments would be extracted incorrectly in the FunctionSymbol::argumentsFromQueryMatch function, which would have to also differentiate between languages.
  2. Add tests for all types of QML symbol extraction. Currently this is entirely untested.

I guess we could also do these in follow-up PRs, but I don't expect much conflict in this part of the codebase at the moment, so it would be preferable to have everything in before merging.

Comment thread src/core/qmldocument.cpp Outdated
@LeonMatthesKDAB

Copy link
Copy Markdown

Hm, I also took another look at the ClassSymbol. I guess that also won't work correctly, as it will probably associate all members from all sub-objects into itself.
It currently doesn't check whether there's another classsymbol that encompasses sub-members 🤔

@itzurabhi
itzurabhi force-pushed the Qml/tree-sitter-queries branch from 548670e to e38b6b2 Compare July 18, 2024 10:34

@LeonMatthesKDAB LeonMatthesKDAB left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going in the right direction, but the testing should be more thorough.

Comment thread tests/tst_qmldocument.cpp Outdated
Comment thread test_data/tst_symbols.qml
Comment thread test_data/tst_symbols.qml
Comment thread tests/tst_qmldocument.cpp
@itzurabhi
itzurabhi force-pushed the Qml/tree-sitter-queries branch from 6beb17d to d49b3ac Compare July 24, 2024 14:46
@itzurabhi
itzurabhi force-pushed the Qml/tree-sitter-queries branch from 6495217 to b2a332d Compare July 24, 2024 15:21

@LeonMatthesKDAB LeonMatthesKDAB left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. We'll want to follow up on this with fixes for FunctionSymbol and ClassSymbol, but a very good start 🥳

@LeonMatthesKDAB
LeonMatthesKDAB merged commit 7898cb9 into KDAB:main Jul 25, 2024
@itzurabhi
itzurabhi deleted the Qml/tree-sitter-queries branch August 12, 2024 06:45
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.

3 participants