Allow platform:/ URIs in templates extension include element#4029
Allow platform:/ URIs in templates extension include element#4029tobiasmelcher wants to merge 1 commit into
Conversation
|
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.:
This is a small, backwards-compatible extension: plain bundle-relative paths continue to work unchanged. |
merks
left a comment
There was a problem hiding this comment.
Seems like a simple and reasonable change.
0ed74dd to
7bceb6d
Compare
| * @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$ |
There was a problem hiding this comment.
Maybe you want to be even more restrictive and support only platform:/plugin/? I.e., platform:/resource/ probably shouldn't work ever...
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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).
7bceb6d to
397763b
Compare
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).