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).

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
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

Test Results

   864 files  ±0     864 suites  ±0   54m 8s ⏱️ + 2m 26s
 7 988 tests ±0   7 745 ✅ ±0  243 💤 ±0  0 ❌ ±0 
20 418 runs  ±0  19 763 ✅ ±0  655 💤 ±0  0 ❌ ±0 

Results for commit 0ed74dd. ± Comparison against base commit 956129f.

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.

3 participants