close
Skip to content

Allow platform:/ URIs in templates extension include element#4029

Open
tobiasmelcher wants to merge 1 commit into
eclipse-platform:masterfrom
tobiasmelcher:platform_uri_in_templates
Open

Allow platform:/ URIs in templates extension include element#4029
tobiasmelcher wants to merge 1 commit into
eclipse-platform:masterfrom
tobiasmelcher:platform_uri_in_templates

Conversation

@tobiasmelcher
Copy link
Copy Markdown
Contributor

The 'file' and 'translations' attributes of the element in the org.eclipse.ui.editors.templates extension point previously only accepted plug-in local file paths, resolved relative to the contributing bundle via FileLocator.find(Bundle, IPath, Map).

This change extends ContributionTemplateStore.readIncludedTemplates to also accept platform:/ URIs (e.g. platform:/plugin//), allowing a contributor to reference template files that live in another plug-in. Bundle-relative paths continue to work unchanged; platform:/ URIs are resolved via FileLocator.find(URL).

@tobiasmelcher
Copy link
Copy Markdown
Contributor Author

In our product ABAP Development Tools for Eclipse we want to share and reuse code templates across multiple components. To enable this, the template definitions need to live in a non-UI (headless) plug-in so that non-UI consumers can use them as well.

The org.eclipse.ui.editors.templates extension point is — correctly — defined in the UI layer, and the contributing plugin.xml therefore has to sit in a UI plug-in. Today the attribute is resolved only relative to the contributing bundle, which forces the actual template XML file to live in that same UI plug-in.

By allowing platform:/ URIs in the file (and translations) attribute, the UI plug-in can keep the extension contribution but reference the template file from the headless plug-in where it really belongs — e.g.:

<include file="platform:/plugin/com.example.abap.core/templates/abap-templates.xml"/>

This is a small, backwards-compatible extension: plain bundle-relative paths continue to work unchanged.

Copy link
Copy Markdown
Contributor

@merks merks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a simple and reasonable change.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

Test Results

   864 files  ±0     864 suites  ±0   54m 41s ⏱️ +14s
 7 989 tests ±0   7 746 ✅ ±0  243 💤 ±0  0 ❌ ±0 
20 421 runs  ±0  19 766 ✅ ±0  655 💤 ±0  0 ❌ ±0 

Results for commit 397763b. ± Comparison against base commit 55391d7.

♻️ This comment has been updated with latest results.

@BeckerWdf BeckerWdf force-pushed the platform_uri_in_templates branch from 0ed74dd to 7bceb6d Compare June 1, 2026 07:36
@BeckerWdf BeckerWdf added this to the 4.41 M1 milestone Jun 1, 2026
* @return the resolved URL, or <code>null</code> if it could not be found
*/
private static URL resolveResource(Bundle plugin, String location) {
if (location.startsWith("platform:/")) { //$NON-NLS-1$
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you want to be even more restrictive and support only platform:/plugin/? I.e., platform:/resource/ probably shouldn't work ever...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the review. Restricted location to platform:/plugin/ with [397763b] .

if (location.startsWith("platform:/")) { //$NON-NLS-1$
try {
return FileLocator.find(new URI(location).toURL());
} catch (java.net.URISyntaxException | java.net.MalformedURLException e) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why qualified names?

Copy link
Copy Markdown
Contributor Author

@tobiasmelcher tobiasmelcher Jun 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, there is no reason. Removed it with [397763b].

The 'file' and 'translations' attributes of the <include> element in the
org.eclipse.ui.editors.templates extension point previously only
accepted plug-in local file paths, resolved relative to the contributing
bundle via FileLocator.find(Bundle, IPath, Map).

This change extends ContributionTemplateStore.readIncludedTemplates to
also accept platform:/ URIs (e.g. platform:/plugin/<bundle-id>/<path>),
allowing a contributor to reference template files that live in another
plug-in. Bundle-relative paths continue to work unchanged; platform:/
URIs are resolved via FileLocator.find(URL).
@tobiasmelcher tobiasmelcher force-pushed the platform_uri_in_templates branch from 7bceb6d to 397763b Compare June 1, 2026 08:30
Copy link
Copy Markdown
Contributor

@merks merks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants