Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit 89b9ede

Browse files
committed
feat: add tree-sitter-json
1 parent c62a6eb commit 89b9ede

File tree

12 files changed

+205
-0
lines changed

12 files changed

+205
-0
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@
1010
[submodule "tree-sitter-xml/src/main/cpp/grammar"]
1111
path = tree-sitter-xml/src/main/cpp/grammar
1212
url = https://github.com/AndroidIDEOfficial/tree-sitter-xml
13+
[submodule "tree-sitter-json/src/main/cpp/grammar"]
14+
path = tree-sitter-json/src/main/cpp/grammar
15+
url = https://github.com/tree-sitter/tree-sitter-json.git

.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,6 @@ include ':android-tree-sitter'
5454

5555
// =========== Grammars ============
5656
include ':tree-sitter-java'
57+
include ':tree-sitter-json'
5758
include ':tree-sitter-python'
5859
include ':tree-sitter-xml'

tree-sitter-json/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

tree-sitter-json/build.gradle.kts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* This file is part of android-tree-sitter.
3+
*
4+
* android-tree-sitter library is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Lesser General Public
6+
* License as published by the Free Software Foundation; either
7+
* version 2.1 of the License, or (at your option) any later version.
8+
*
9+
* android-tree-sitter library is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with android-tree-sitter. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
import com.itsaky.androidide.treesitter.TreeSitterPlugin
19+
import com.itsaky.androidide.treesitter.TsGrammarPlugin
20+
21+
plugins {
22+
id("com.android.library")
23+
id("com.vanniktech.maven.publish.base")
24+
}
25+
26+
apply {
27+
plugin(TreeSitterPlugin::class.java)
28+
plugin(TsGrammarPlugin::class.java)
29+
}
30+
31+
val rootProjDir: String = rootProject.projectDir.absolutePath
32+
val tsDir = "${rootProjDir}/tree-sitter-lib"
33+
34+
android {
35+
namespace = "com.itsaky.androidide.treesitter.json"
36+
ndkVersion = "24.0.8215888"
37+
38+
defaultConfig {
39+
externalNativeBuild { cmake { arguments("-DPROJECT_DIR=${rootProjDir}", "-DTS_DIR=${tsDir}") } }
40+
}
41+
42+
buildTypes {
43+
release {
44+
isMinifyEnabled = false
45+
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
46+
}
47+
}
48+
49+
externalNativeBuild {
50+
cmake {
51+
path = file("src/main/cpp/CMakeLists.txt")
52+
version = "3.22.1"
53+
}
54+
}
55+
}
56+
57+
dependencies { implementation(project(":android-tree-sitter")) }

tree-sitter-json/consumer-rules.pro

Whitespace-only changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ This file is part of android-tree-sitter.
4+
~
5+
~ android-tree-sitter library is free software; you can redistribute it and/or
6+
~ modify it under the terms of the GNU Lesser General Public
7+
~ License as published by the Free Software Foundation; either
8+
~ version 2.1 of the License, or (at your option) any later version.
9+
~
10+
~ android-tree-sitter library is distributed in the hope that it will be useful,
11+
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
~ Lesser General Public License for more details.
14+
~
15+
~ You should have received a copy of the GNU General Public License
16+
~ along with android-tree-sitter. If not, see <https://www.gnu.org/licenses/>.
17+
-->
18+
19+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
20+
21+
</manifest>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# This file is part of android-tree-sitter.
3+
#
4+
# android-tree-sitter library is free software; you can redistribute it and/or
5+
# modify it under the terms of the GNU Lesser General Public
6+
# License as published by the Free Software Foundation; either
7+
# version 2.1 of the License, or (at your option) any later version.
8+
#
9+
# android-tree-sitter library is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
# Lesser General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with android-tree-sitter. If not, see <https://www.gnu.org/licenses/>.
16+
#
17+
18+
cmake_minimum_required(VERSION 3.22.1)
19+
20+
project("tree-sitter-json")
21+
22+
# Include common configuration
23+
include(../../../../cmake/common-config.cmake)
24+
25+
# This includes the header file for the parser
26+
include_directories(grammar/src)
27+
28+
# add tree-sitter-java library
29+
add_library(${CMAKE_PROJECT_NAME} SHARED
30+
grammar/src/parser.c
31+
tree-sitter-json.cpp)
Submodule grammar added at 7307675

0 commit comments

Comments
 (0)