Skip to content

Commit

Permalink
feat: add support for QmlJs via tree-sitter-qmljs
Browse files Browse the repository at this point in the history
  • Loading branch information
itzurabhi committed Jun 21, 2024
1 parent ff46f1c commit 8a32fb3
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
[submodule "3rdparty/tree-sitter-cpp"]
path = 3rdparty/tree-sitter-cpp
url = https://github.com/tree-sitter/tree-sitter-cpp
[submodule "3rdparty/tree-sitter-qmljs"]
path = 3rdparty/tree-sitter-qmljs
url = https://github.com/yuja/tree-sitter-qmljs.git
[submodule "3rdparty/mfc-utils"]
path = 3rdparty-kdab/mfc-utils
url = ssh://codereview.kdab.com:29418/kdab/mfc-utils
Expand Down
6 changes: 6 additions & 0 deletions 3RDPARTY.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ C++ grammar for tree-sitter.<br>
[Home page](https://github.com/tree-sitter/tree-sitter-cpp)<br>
[MIT licensed](LICENSES/MIT.txt)

### tree-sitter-qmljs

QML grammar for the tree-sitter parsing library.<br>
[Home page](https://github.com/yuja/tree-sitter-qmljs)<br>
[MIT licensed](LICENSES/MIT.txt)

## Build-time / CI tests 3rdparty

These dependencies are only used during build or other CI purposes like running tests.
Expand Down
12 changes: 12 additions & 0 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,15 @@ target_link_libraries(${PROJECT_NAME} PRIVATE TreeSitter)
# Always build tree-sitter with optimizations enabled. We shouldn't have to
# debug it and it's performance critical.
target_compile_options(${PROJECT_NAME} PRIVATE -O3)

# TreeSitterQmlJs
# ##############################################################################
check_submodule(tree-sitter-qmljs tree-sitter-qmljs)
project(TreeSitterQmlJs LANGUAGES C)

add_library(${PROJECT_NAME} STATIC tree-sitter-qmljs/src/parser.c
tree-sitter-qmljs/src/scanner.c)
target_link_libraries(${PROJECT_NAME} PRIVATE TreeSitter)
# Always build tree-sitter with optimizations enabled. We shouldn't have to
# debug it and it's performance critical.
target_compile_options(${PROJECT_NAME} PRIVATE -O3)
1 change: 1 addition & 0 deletions 3rdparty/tree-sitter-qmljs
Submodule tree-sitter-qmljs added at febf48
10 changes: 8 additions & 2 deletions src/treesitter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ set(PROJECT_SOURCES node.cpp parser.cpp predicates.cpp query.cpp
transformation.cpp tree.cpp)

add_library(${PROJECT_NAME} STATIC ${PROJECT_SOURCES})
target_link_libraries(${PROJECT_NAME} TreeSitter TreeSitterCpp kdalgorithms
knut-utils Qt${QT_VERSION_MAJOR}::Core)
target_link_libraries(
${PROJECT_NAME}
TreeSitter
TreeSitterCpp
TreeSitterQmlJs
kdalgorithms
knut-utils
Qt${QT_VERSION_MAJOR}::Core)
target_include_directories(${PROJECT_NAME}
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/..)
1 change: 1 addition & 0 deletions src/treesitter/languages.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ struct TSLanguage;

extern "C" {
TSLanguage *tree_sitter_cpp();
TSLanguage *tree_sitter_qmljs();
}

0 comments on commit 8a32fb3

Please sign in to comment.