|
36 | 36 | import org.eclipse.tm4e.core.internal.grammar.raw.RawGrammarReader; |
37 | 37 | import org.eclipse.tm4e.core.internal.oniguruma.OnigRegExp; |
38 | 38 | import org.eclipse.tm4e.core.internal.utils.ResourceUtils; |
| 39 | +import org.eclipse.tm4e.core.registry.IGrammarSource; |
| 40 | +import org.eclipse.tm4e.core.registry.Registry; |
39 | 41 | import org.junit.jupiter.api.MethodOrderer; |
40 | 42 | import org.junit.jupiter.api.Test; |
41 | 43 | import org.junit.jupiter.api.TestMethodOrder; |
@@ -235,18 +237,28 @@ void testLanguagePackGrammars() throws IOException { |
235 | 237 | Files.walkFileTree(Paths.get("../org.eclipse.tm4e.language_pack"), new SimpleFileVisitor<Path>() { |
236 | 238 | @Override |
237 | 239 | public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException { |
238 | | - if (file.getFileName().toString().endsWith("tmLanguage.json")) { |
239 | | - try (var input = Files.newBufferedReader(file)) { |
| 240 | + final var fileName = file.getFileName().toString().toLowerCase(); |
| 241 | + if (fileName.endsWith("tmlanguage.yaml") || fileName.endsWith("tmlanguage.json") || fileName.endsWith("plist") |
| 242 | + || fileName.endsWith("tmlanguage")) { |
| 243 | + try { |
240 | 244 | System.out.println("Parsing [" + file + "]..."); |
241 | | - final var grammar = TMParserJSON.INSTANCE.parse(input, RawGrammarReader.OBJECT_FACTORY); |
| 245 | + final var rawGrammar = RawGrammarReader.readGrammar(IGrammarSource.fromFile(file)); |
242 | 246 | count.incrementAndGet(); |
243 | | - assertFalse(grammar.getScopeName().isBlank()); |
244 | | - assertNotNull(grammar.getFileTypes()); |
245 | | - assertNotNull(grammar.getRepository()); |
| 247 | + assertFalse(rawGrammar.getScopeName().isBlank()); |
| 248 | + assertNotNull(rawGrammar.getFileTypes()); |
| 249 | + assertNotNull(rawGrammar.getRepository()); |
246 | 250 |
|
247 | | - final var patterns = castNonNull(grammar.getPatterns()); |
| 251 | + final var patterns = castNonNull(rawGrammar.getPatterns()); |
248 | 252 | assertFalse(patterns.isEmpty()); |
249 | 253 | assertParseablePatterns(patterns); |
| 254 | + |
| 255 | + final var reg = new Registry(); |
| 256 | + final var grammar = reg.addGrammar(IGrammarSource.fromFile(file)); |
| 257 | + assertEquals(grammar.getName(), rawGrammar.getName()); |
| 258 | + assertEquals(grammar.getScopeName(), rawGrammar.getScopeName()); |
| 259 | + assertEquals(grammar.getFileTypes(), rawGrammar.getFileTypes()); |
| 260 | + grammar.tokenizeLine(""); |
| 261 | + |
250 | 262 | } catch (final Exception ex) { |
251 | 263 | throw new RuntimeException(ex); |
252 | 264 | } |
|
0 commit comments