You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -142,9 +142,9 @@ TM4E is split into three main bundles plus an optional language pack feature:
142
142
143
143
## 🔌 Integrating TM4E
144
144
145
-
If you are an Eclipse plug-in developer or Java tool author and want to consume TM4E:
145
+
If you are an Eclipse plug-in developer or Java tool author and want to integrate TM4E in your own tools:
146
146
147
-
- Start with the [Plugin Developer Guide](docs/plugin-developer-guide.md) for how to depend on TM4E, contribute grammars, themes, and language configurations, and wire TM4E into editors.
147
+
- Start with the [Adopter Guide](docs/adopter-guide.md) for how to depend on TM4E, contribute grammars, themes, and language configurations, and wire TM4E into editors.
148
148
- For integration questions, best practices, and design discussions, use [GitHub discussions](https://github.com/eclipse-tm4e/tm4e/discussions).
149
149
- To report bugs or request new APIs or integration features, file issues in [GitHub issues](https://github.com/eclipse-tm4e/tm4e/issues).
Copy file name to clipboardExpand all lines: docs/adopter-guide.md
+44-2Lines changed: 44 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
-
# TM4E Plugin Developer Guide
1
+
# TM4E Adopter Guide
2
+
3
+
This guide is for Eclipse plug-in and RCP application developers who want to integrate TM4E into Eclipse editors, and
4
+
Java developers who want to use the TM4E core TextMate engine in their own applications outside Eclipse.
2
5
3
-
This guide is for Eclipse plugin developers who want to add TextMate-based syntax highlighting and language configuration features to their editors.
4
6
It explains the main TM4E concepts, how to contribute grammars and themes, how to connect editors to TM4E, and how to use the TM partitioner and language configuration support.
5
7
6
8
@@ -15,6 +17,7 @@ It explains the main TM4E concepts, how to contribute grammars and themes, how t
15
17
1.[Using `TextEditor`](#using-texteditor)
16
18
1.[Using the Generic Editor](#using-the-generic-editor)
17
19
1.[Using the TM Partitioner from Code](#using-the-tm-partitioner-from-code)
1.[Diagnostics: Token and Scope Hover](#diagnostics-token-and-scope-hover)
19
22
1.[Samples and Tools](#samples-and-tools)
20
23
1.[Further Reading](#further-reading)
@@ -284,6 +287,45 @@ Convenience methods such as `TMPartitions.hasPartitioning(doc)` and `TMPartition
284
287
Generic Editor extension points still refer to the editor's primary partitioning via their `partitionType` attribute; you always query TM4E's secondary partitioner from code instead of configuring it directly in the extension XML.
285
288
286
289
290
+
## Handling Conflicting Grammar Registrations
291
+
292
+
In real Eclipse installations it is common for several plug-ins (including the TM4E language pack) to register grammars for the same TextMate scope, or to provide overlapping grammars for a given file type.
293
+
TM4E's registry is designed to handle this without forcing every plug-in to invent unique scope names.
294
+
295
+
At a high level:
296
+
297
+
- Grammars are always selected based on *content types* and their normal Eclipse priorities, not just on the bare scope name.
298
+
- Internally, TM4E qualifies scopes with the contributing plug-in ID to disambiguate registrations, but external code and grammar authors can continue to use the shared, unqualified scope name.
299
+
300
+
### 1) Which grammar wins for a file
301
+
302
+
When an editor is opened, `TMPresentationReconciler` asks the registry for a grammar using the document's content types:
303
+
304
+
- The content types are computed using the usual Eclipse mechanisms (file extension, content-type base types, and priority).
305
+
-`GrammarRegistryManager` looks for a grammar that is explicitly bound to the highest priority content type via `scopeNameContentTypeBinding`.
306
+
- If multiple plug-ins register a grammar for the same TextMate scope (for example `source.batchfile`), each plug-in typically also defines its own content type and binds that content type to the shared scope.
307
+
308
+
From a plug-in author's perspective:
309
+
310
+
- The content type that "wins" according to Eclipse content-type priority rules controls which plug-in's grammar is used for a given document.
311
+
- If you want your grammar to take precedence for a specific file extension, define your own content type for that extension and bind it to your grammar scope via `scopeNameContentTypeBinding`.
312
+
313
+
### 2) Referencing shared scopes from other grammars
314
+
315
+
Grammars often embed other languages via shared scopes, for example an HTML grammar embedding JavaScript using `source.js`.
316
+
When multiple plug-ins provide a grammar for the same embedded scope:
317
+
318
+
- You can continue to reference the shared, unqualified scope (such as `source.js` or `text.html`) in your grammar.
319
+
- TM4E resolves that shared scope to an internal, plug-in-specific variant based on the active registry state and the same content-type bindings described above.
320
+
321
+
This means:
322
+
323
+
- You do not need to create plug-in-specific scope names just to avoid collisions.
324
+
- Embedded language references in your grammars remain stable even when users install additional plug-ins or language packs that also contribute grammars for those scopes.
325
+
326
+
For a deeper, implementation-level description of how the registry qualifies scopes and resolves grammars (including a concrete `source.batchfile` example), see the *Handling Conflicting Grammar Registrations* section in the contributor guide (`docs/contributor-guide.md`).
327
+
328
+
287
329
## Diagnostics: Token and Scope Hover
288
330
289
331
When debugging grammars, themes, or partitioning, it is often helpful to see exactly which TextMate token and scopes TM4E has computed at a given location in the editor.
Copy file name to clipboardExpand all lines: docs/user-guide.md
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,7 +68,7 @@ For advanced users, some editors expose a TextMate token hover that shows the to
68
68
69
69

70
70
71
-
For details on how to use the token hover and other diagnostics when developing plugins, see the [TM4E Plugin Developer Guide](plugin-developer-guide.md).
71
+
For details on how to use the token hover and other diagnostics when developing plugins, see the [TM4E Adopter Guide](adopter-guide.md).
72
72
73
73
74
74
## Language Pack and Additional Grammars
@@ -87,7 +87,8 @@ Most user-facing configuration lives under the `TextMate` section in the Eclipse
87
87
88
88
1. The main `TextMate` page provides an overview and general switches.
89
89
1.`TextMate > Grammar` lets you manage available grammars and their associations to Eclipse content types (the way Eclipse classifies file types).
90
-
Here you can enable or disable grammars and control which grammar applies to a file type.\
90
+
Here you can enable or disable grammars and control which grammar applies to a file type.
91
+
For each selected grammar you can also inspect details, adjust the content types it applies to, configure grammar injections, and manage per-grammar theme associations using the built-in preview.\
1.`TextMate > Language Configuration` lets you control language-configuration based features and attach additional configuration files:
@@ -101,7 +102,7 @@ Most user-facing configuration lives under the `TextMate` section in the Eclipse
101
102
1.`TextMate > Task Tags` lets you define tags in comments (such as `TODO` or `FIXME`) that should be treated as tasks or problems, and configure how they are marked in the workspace.\
1.`TextMate > Themes` lets you choose between built-in Light and Dark themes and any additional themes contributed by installed plugins.
105
+
1.`TextMate > Themes` lets you choose between built-in Light and Dark themes and any additional themes contributed by installed plugins, as well as import extra theme files and set the default theme for light and dark modes.
105
106
You can also switch themes from the editor's context menu under `TextMate`.\
106
107

107
108
@@ -118,6 +119,7 @@ This is useful if a plugin does not already provide a configuration file for tha
118
119
119
120
Themes are contributed by plugins and selected on the `TextMate > Themes` page.
120
121
Built-in themes cover common Light and Dark appearances, while plugin-provided themes can add alternative color schemes.
122
+
You can also use the `New...` button on that page to import additional TextMate theme files from disk and mark one as the default for Light or Dark mode.
121
123
If you are interested in authoring themes or grammars yourself, see the Plugin Developer Guide for extension point and authoring details.
122
124
123
125
@@ -136,12 +138,12 @@ If you are interested in authoring themes or grammars yourself, see the Plugin D
136
138
If the Generic Editor shows TM4E-based highlighting while a custom editor does not, the custom editor may not be wired to TM4E or may rely solely on its own partitioning or language server integration.
137
139
138
140
-**Collecting diagnostics for bug reports**:
139
-
When you need to provide more technical information, enable extra tracing by adding `org.eclipse.tm4e.ui/trace=true` to a debug options file (usually named `debug.options`) and starting Eclipse with `-debug /path/to/debug.options`.
140
-
To capture text events and generate a Java test skeleton, add `org.eclipse.tm4e.ui/debug/log/GenerateTest=true` to the same file and close an editor that uses TM4E; the test skeleton is written to the error output stream.
141
+
To capture text events and generate a Java test skeleton, add `org.eclipse.tm4e.ui/debug/log/GenerateTest=true` to a debug options file (usually named `debug.options`) and start Eclipse with `-debug /path/to/debug.options`; the test skeleton is written to the error output stream when you close an editor that uses TM4E.
142
+
If you need TM4E to fail fast when no grammar is found for a document (for example when isolating a bug), you can additionally set `org.eclipse.tm4e.ui/debug/log/ThrowError=true`, which causes an exception to be thrown instead of silently disabling TM4E for that document.
141
143
142
144
143
145
## Further Reading
144
146
145
147
For additional background on what TM4E provides in Eclipse and how it fits into the IDE, see the Eclipse newsletter article "TM4E" (June 2018): https://www.eclipse.org/community/eclipse_newsletter/2018/june/tm4e.php
146
148
147
-
If you plan to implement your own TM4E-based editor or customize integration at the plugin level, switch to the [TM4E Plugin Developer Guide](plugin-developer-guide.md), which is targeted specifically at plugin authors.
149
+
If you plan to implement your own TM4E-based editor or customize integration at the plugin level, switch to the [TM4E Adopter Guide](adopter-guide.md), which is targeted specifically at plugin adopters and plug-in authors.
0 commit comments