This repository was archived by the owner on Oct 18, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed
src/test/java/com/itsaky/androidide/treesitter Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ android {
5353
5454dependencies {
5555 testImplementation(project(path = " :tree-sitter-java" ))
56+ testImplementation(project(path = " :tree-sitter-json" ))
5657 testImplementation(project(path = " :tree-sitter-xml" ))
5758 testImplementation(project(path = " :tree-sitter-python" ))
5859 testImplementation(" com.google.truth:truth:1.1.3" )
Original file line number Diff line number Diff line change 2121import static com .itsaky .androidide .treesitter .TestUtils .readString ;
2222
2323import com .itsaky .androidide .treesitter .java .TSLanguageJava ;
24+ import com .itsaky .androidide .treesitter .json .TSLanguageJson ;
2425import com .itsaky .androidide .treesitter .python .TSLanguagePython ;
2526
2627import org .junit .Test ;
@@ -111,4 +112,32 @@ public void testIncrementalParsing() throws UnsupportedEncodingException {
111112 }
112113 }
113114 }
115+
116+ @ Test
117+ public void testJsonGrammar () {
118+ try (final var parser = new TSParser ()) {
119+ parser .setLanguage (TSLanguageJson .newInstance ());
120+
121+ final var source = "{\n " +
122+ " \" string\" : \" value\" ,\n " +
123+ " \" boolean\" : true,\n " +
124+ " \" number\" : 1234,\n " +
125+ " \" null\" : null,\n " +
126+ "\n " +
127+ " \" object\" : {\n " +
128+ "\n " +
129+ " },\n " +
130+ "\n " +
131+ " \" array\" : [\n " +
132+ " \" array_element\" \n " +
133+ " ]\n " +
134+ "}" ;
135+
136+ try (final var tree = parser .parseString (source )) {
137+ final var rootNode = tree .getRootNode ();
138+ assertThat (rootNode ).isNotNull ();
139+ assertThat (rootNode .getChildCount ()).isGreaterThan (0 );
140+ }
141+ }
142+ }
114143}
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ public class TreeSitterTest {
2626 String hostDir = System .getProperty ("user.dir" ) + "/../build/host" ;
2727 System .load (hostDir + "/libandroid-tree-sitter.so" );
2828 System .load (hostDir + "/libtree-sitter-java.so" );
29+ System .load (hostDir + "/libtree-sitter-json.so" );
2930 System .load (hostDir + "/libtree-sitter-xml.so" );
3031 System .load (hostDir + "/libtree-sitter-python.so" );
3132 }
You can’t perform that action at this time.
0 commit comments