|
18 | 18 | package com.itsaky.androidide.treesitter; |
19 | 19 |
|
20 | 20 | import static com.google.common.truth.Truth.assertThat; |
21 | | -import static com.itsaky.androidide.treesitter.TestUtils.readString; |
| 21 | +import static com.itsaky.androidide.treesitter.ResourceUtils.readResource; |
22 | 22 |
|
23 | 23 | import android.text.TextUtils; |
24 | 24 | import com.itsaky.androidide.treesitter.aidl.TSLanguageAidl; |
|
29 | 29 | import com.itsaky.androidide.treesitter.python.TSLanguagePython; |
30 | 30 | import com.itsaky.androidide.treesitter.string.UTF16StringFactory; |
31 | 31 | import java.io.UnsupportedEncodingException; |
32 | | -import java.nio.file.Paths; |
33 | 32 | import java.util.ArrayList; |
34 | 33 | import java.util.HashMap; |
35 | 34 | import java.util.List; |
|
46 | 45 | import org.mockito.MockedStatic; |
47 | 46 | import org.mockito.Mockito; |
48 | 47 | import org.robolectric.RobolectricTestRunner; |
49 | | -import static com.itsaky.androidide.treesitter.ResourceUtils.readResource; |
50 | 48 |
|
51 | 49 | @RunWith(RobolectricTestRunner.class) |
52 | 50 | public class ParserTest extends TreeSitterTest { |
@@ -74,7 +72,7 @@ public void releaseMocks() { |
74 | 72 | } |
75 | 73 |
|
76 | 74 | @Test |
77 | | - public void testParse() { |
| 75 | + public void testParse() { |
78 | 76 | try (TSParser parser = TSParser.create()) { |
79 | 77 | parser.setLanguage(TSLanguagePython.getInstance()); |
80 | 78 | try (TSTree tree = parser.parseString("print(\"hi\")")) { |
@@ -181,7 +179,7 @@ public void testKotlinGrammar() { |
181 | 179 | assertThat(rootNode).isNotNull(); |
182 | 180 | assertThat(rootNode.getChildCount()).isGreaterThan(0); |
183 | 181 | assertThat(rootNode.getNodeString()).isEqualTo( |
184 | | - "(source_file (class_declaration name: (type_identifier) body: (class_body (function_declaration name: (simple_identifier) parameters: (function_value_parameters) body: (function_body (statements (call_expression (simple_identifier) (call_suffix (value_arguments (value_argument (string_literal)))))))))))"); |
| 182 | + "(source_file (class_declaration (type_identifier) (class_body (function_declaration (simple_identifier) (function_value_parameters) (function_body (statements (call_expression (simple_identifier) (call_suffix (value_arguments (value_argument (string_literal)))))))))))"); |
185 | 183 | } |
186 | 184 | } |
187 | 185 | } |
@@ -449,10 +447,7 @@ public void testParserParseCallShouldSucceedIfAnotherParseIsInProgressAndCancell |
449 | 447 |
|
450 | 448 | @Test |
451 | 449 | public void testParserParseCallShouldNotFailIfWhenMultipleParsersAreParsing() { |
452 | | - try (final var parser1 = TSParser.create(); |
453 | | - final var parser2 = TSParser.create(); |
454 | | - final var mainParseContent = UTF16StringFactory.newString() |
455 | | - ) { |
| 450 | + try (final var parser1 = TSParser.create(); final var parser2 = TSParser.create(); final var mainParseContent = UTF16StringFactory.newString()) { |
456 | 451 | parser1.setLanguage(TSLanguageJava.getInstance()); |
457 | 452 | parser2.setLanguage(TSLanguageJava.getInstance()); |
458 | 453 |
|
@@ -579,7 +574,8 @@ public void testAwaitedCancellation() { |
579 | 574 | // request parse cancellation and wait till the parse returns |
580 | 575 | final var start = System.currentTimeMillis(); |
581 | 576 | parser.requestCancellationAndWait(); |
582 | | - System.err.println("cancelAndWait() waited for " + (System.currentTimeMillis() - start) + "ms"); |
| 577 | + System.err.println( |
| 578 | + "cancelAndWait() waited for " + (System.currentTimeMillis() - start) + "ms"); |
583 | 579 |
|
584 | 580 | // request another parse |
585 | 581 | try (var tree = parser.parseString(fileContent)) { |
|
0 commit comments