Skip to content

Commit f5b9061

Browse files
committed
feat: extend updater (use peb templates, register external injections)
1 parent 7790c95 commit f5b9061

18 files changed

Lines changed: 501 additions & 290 deletions

org.eclipse.tm4e.language_pack/README.md

Lines changed: 12 additions & 12 deletions
Large diffs are not rendered by default.

org.eclipse.tm4e.language_pack/about.html

Lines changed: 61 additions & 61 deletions
Large diffs are not rendered by default.

org.eclipse.tm4e.language_pack/plugin.xml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -691,16 +691,16 @@
691691
<!-- json/snippets: Code Snippets -->
692692
<!-- ======================================== -->
693693
<extension point="org.eclipse.core.contenttype.contentTypes">
694-
<content-type id="org.eclipse.tm4e.language_pack.samples" name="Code Snippets" base-type="org.eclipse.tm4e.language_pack.basetype" priority="low"
694+
<content-type id="org.eclipse.tm4e.language_pack.snippets" name="Code Snippets" base-type="org.eclipse.tm4e.language_pack.basetype" priority="low"
695695
file-extensions="code-snippets" file-patterns="**/User/profiles/*/snippets/*.json,**/User/snippets/*.json" />
696696
</extension>
697697
<extension point="org.eclipse.tm4e.registry.grammars">
698-
<grammar scopeName="source.json.comments.samples" path="syntaxes/json/snippets.tmLanguage.json" />
699-
<scopeNameContentTypeBinding scopeName="source.json.comments.samples" contentTypeId="org.eclipse.tm4e.language_pack.samples" />
698+
<grammar scopeName="source.json.comments.snippets" path="syntaxes/json/snippets.tmLanguage.json" />
699+
<scopeNameContentTypeBinding scopeName="source.json.comments.snippets" contentTypeId="org.eclipse.tm4e.language_pack.snippets" />
700700
</extension>
701701

702702
<extension point="org.eclipse.tm4e.languageconfiguration.languageConfigurations">
703-
<languageConfiguration contentTypeId="org.eclipse.tm4e.language_pack.samples" path="syntaxes/json/snippets.language-configuration.json" />
703+
<languageConfiguration contentTypeId="org.eclipse.tm4e.language_pack.snippets" path="syntaxes/json/snippets.language-configuration.json" />
704704
</extension>
705705

706706
<!-- ======================================== -->
@@ -920,8 +920,11 @@
920920
<!-- ======================================== -->
921921
<extension point="org.eclipse.tm4e.registry.grammars">
922922
<grammar scopeName="markdown.math.block" path="syntaxes/markdown-math/markdown.math.block.tmLanguage.json" />
923+
<injection scopeName="markdown.math.block" injectTo="text.html.markdown" />
923924
<grammar scopeName="markdown.math.codeblock" path="syntaxes/markdown-math/markdown.math.codeblock.tmLanguage.json" />
925+
<injection scopeName="markdown.math.codeblock" injectTo="text.html.markdown" />
924926
<grammar scopeName="markdown.math.inline" path="syntaxes/markdown-math/markdown.math.inline.tmLanguage.json" />
927+
<injection scopeName="markdown.math.inline" injectTo="text.html.markdown" />
925928
</extension>
926929

927930
<!-- ======================================== -->
@@ -1367,7 +1370,11 @@
13671370
<!-- ======================================== -->
13681371
<extension point="org.eclipse.tm4e.registry.grammars">
13691372
<grammar scopeName="documentation.injection.js.jsx" path="syntaxes/typescript/documentation.injection.js.jsx.tmLanguage.json" />
1373+
<injection scopeName="documentation.injection.js.jsx" injectTo="source.js" />
1374+
<injection scopeName="documentation.injection.js.jsx" injectTo="source.js.jsx" />
13701375
<grammar scopeName="documentation.injection.ts" path="syntaxes/typescript/documentation.injection.ts.tmLanguage.json" />
1376+
<injection scopeName="documentation.injection.ts" injectTo="source.ts" />
1377+
<injection scopeName="documentation.injection.ts" injectTo="source.tsx" />
13711378
</extension>
13721379

13731380
<!-- ======================================== -->

org.eclipse.tm4e.language_pack/updater/pom.xml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,36 @@
3333
<!-- for JSON/YAML file support -->
3434
<groupId>com.fasterxml.jackson.dataformat</groupId>
3535
<artifactId>jackson-dataformat-yaml</artifactId>
36-
<version>2.16.1</version>
36+
<version>2.18.3</version>
3737
</dependency>
3838
<dependency>
3939
<!-- for *.ico image support -->
4040
<groupId>com.twelvemonkeys.imageio</groupId>
4141
<artifactId>imageio-bmp</artifactId>
42-
<version>3.11.0</version>
42+
<version>3.12.0</version>
4343
</dependency>
4444
<dependency>
4545
<!-- for *.svg image support -->
4646
<groupId>com.twelvemonkeys.imageio</groupId>
4747
<artifactId>imageio-batik</artifactId>
48-
<version>3.11.0</version>
48+
<version>3.12.0</version>
4949
</dependency>
5050
<dependency>
5151
<!-- for *.svg image support -->
5252
<groupId>org.apache.xmlgraphics</groupId>
5353
<artifactId>batik-transcoder</artifactId>
54-
<version>1.17</version>
54+
<version>1.18</version>
5555
<exclusions>
5656
<exclusion>
5757
<groupId>xml-apis</groupId>
5858
<artifactId>xml-apis</artifactId>
5959
</exclusion>
6060
</exclusions>
6161
</dependency>
62+
<dependency>
63+
<groupId>io.pebbletemplates</groupId>
64+
<artifactId>pebble</artifactId>
65+
<version>3.2.4</version>
66+
</dependency>
6267
</dependencies>
6368
</project>

org.eclipse.tm4e.language_pack/updater/src/main/java/updater/AbstractSourceHandler.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import static updater.utils.Validation.isURL;
1717

1818
import java.io.IOException;
19-
import java.net.MalformedURLException;
2019
import java.net.URL;
2120
import java.nio.file.Files;
2221
import java.nio.file.Path;
@@ -57,7 +56,7 @@ abstract class AbstractSourceHandler<T extends Source> {
5756
record DownloadContext(String targetNamePrefix, boolean updateExistingFiles, Path targetDir) {
5857
}
5958

60-
void downloadExampleFile(final DownloadContext ctx, final String examplePathOrURL) throws MalformedURLException, IOException {
59+
void downloadExampleFile(final DownloadContext ctx, final String examplePathOrURL) throws IOException {
6160
if (examplePathOrURL != null) {
6261
if (isURL(examplePathOrURL)) {
6362
final var sourceURL = new URL(examplePathOrURL);
@@ -122,8 +121,8 @@ Path downloadTextMateGrammarFile(final DownloadContext ctx, final String grammar
122121

123122
if (isURL(grammarPathOrURL)) {
124123
final var sourceURL = new URL(grammarPathOrURL);
125-
final var targetFile = ctx.targetDir
126-
.resolve(ctx.targetNamePrefix + mapFileExt.apply(getFileExtension(sourceURL.getPath()).toLowerCase()));
124+
final var targetFile = ctx.targetDir.resolve(ctx.targetNamePrefix + mapFileExt.apply(getFileExtension(sourceURL.getPath())
125+
.toLowerCase()));
127126
if (ctx.updateExistingFiles || !Files.exists(targetFile)) {
128127
downloadFile(sourceURL, targetFile);
129128
}

org.eclipse.tm4e.language_pack/updater/src/main/java/updater/CustomSourceHandler.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
import updater.Updater.Config;
2323
import updater.Updater.Config.InlineGrammar;
2424
import updater.Updater.State.ExtensionState;
25+
import updater.Updater.State.InlineGrammarState;
2526
import updater.Updater.State.LanguageState;
27+
import updater.utils.Strings;
2628

2729
/**
2830
* @author Sebastian Thomschke
@@ -55,14 +57,15 @@ void handle() throws IOException {
5557
assertArgNotEmpty("sources/" + sourceId + "/languages/" + langId + "/scope-name", langCfg.scopeName);
5658
assertArgNotEmpty("sources/" + sourceId + "/languages/" + langId + "/grammar", langCfg.grammar);
5759

58-
final var ctx = new DownloadContext(langId, langCfg.update, targetSyntaxDir);
60+
final var ctx = new DownloadContext(Strings.sanitizeFilename(langId), langCfg.update, targetSyntaxDir);
5961
final var grammarFile = downloadTextMateGrammarFile(ctx, langCfg.grammar);
6062
downloadLangConfigurationJSONFile(ctx, langCfg.langcfg);
6163
downloadExampleFile(ctx, langCfg.example);
6264

6365
final var langState = new LanguageState();
6466
langState.label = langCfg.label;
6567
langState.scopeName = langCfg.scopeName;
68+
langState.injectTo = langCfg.injectTo == null ? null : new TreeSet<>(langCfg.injectTo);
6669
langState.fileExtensions = langCfg.fileExtensions == null ? null : new TreeSet<>(langCfg.fileExtensions);
6770
langState.fileNames = langCfg.fileNames == null ? null : new TreeSet<>(langCfg.fileNames);
6871
langState.filePatterns = langCfg.filePatterns == null ? null : new TreeSet<>(langCfg.filePatterns);
@@ -74,9 +77,12 @@ void handle() throws IOException {
7477
final var scopeName = inlineGrammar.getKey();
7578
final var grammarCfg = inlineGrammar.getValue();
7679
assertArgNotEmpty("sources/" + sourceId + "/inline-grammars/" + scopeName + "/grammar", grammarCfg.grammar);
77-
final var ctx = new DownloadContext(scopeName, grammarCfg.update, targetSyntaxDir);
80+
final var ctx = new DownloadContext(Strings.sanitizeFilename(scopeName), grammarCfg.update, targetSyntaxDir);
7881
downloadTextMateGrammarFile(ctx, grammarCfg.grammar);
79-
state.inlineGrammarScopeNames.add(scopeName);
82+
final var inlineGrammarSate = new InlineGrammarState();
83+
inlineGrammarSate.scopeName = scopeName;
84+
inlineGrammarSate.injectTo = grammarCfg.injectTo == null ? null : new TreeSet<>(grammarCfg.injectTo);
85+
state.inlineGrammars.add(inlineGrammarSate);
8086
}
8187
}
8288
}

0 commit comments

Comments
 (0)