Bug 275729 - empty templateAssociation doesn't always work
Summary: empty templateAssociation doesn't always work
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 6.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-11 16:47 EDT by Miwako Tokugawa CLA
Modified: 2020-09-04 15:20 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Miwako Tokugawa CLA 2009-05-11 16:47:31 EDT
Build ID: I20090313-0100

Steps To Reproduce:
Add the following to a plugin.xml that has toolChains defined.
<extension point="org.eclipse.cdt.core.templateAssociations">
<template id="org.eclipse.cdt.build.core.templates.HelloWorldCAnsiProject"></template>
<template id="org.eclipse.cdt.build.core.templates.EmptyProject"></template>
</extension>
From the doc, this should make the template unavailable for the toolChains that are defined in the plugin.xml.
The first template is, but the second one isn't.

A difference seems to be that, while the first template appears under 
   <extension point="org.eclipse.cdt.core.templates">
In org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml 
the second one doesn't.
Both templates show up under 
<extension point="org.eclipse.cdt.core.templateAssociations">


More information:
Comment 1 Miwako Tokugawa CLA 2009-12-21 19:13:42 EST
Also, it seems that the empty templateAssociation only works if there is another non-empty templateAssociation defined.
For example, adding
<extension point="org.eclipse.cdt.core.templateAssociations">
<template
id="org.eclipse.cdt.build.core.templates.MakefileHelloWorldCCProject">
</template>
to my plugin.xml (I'll call it "plugin.xml B") seems to "work" (i.e. this template is not available to any toolchains defined in my plugin.xml) only if the following templateAssociation entry exists in org.eclipse.cdt.managedbuilder.gnu.ui.
If I comment out the following templateAssociation entry, or comment out all toolChains for it, then the template becomes available for all toolchains in "plugin.xml B"

<template id="org.eclipse.cdt.build.core.templates.MakefileHelloWorldCCProject">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.cygwin.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.macosx.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.solaris.base"/>
</template>

Is this behavior consistent with the design or is this a bug?
Comment 2 Miwako Tokugawa CLA 2009-12-23 19:04:36 EST
This report actually captures two problems.

1. (Captured in Comment 1)
Empty toolchain association for a template doesn't work unless the template element exists under the
"org.eclipse.cdt.core.templates" extension point.

2. (Captured in Comment 2) 
Empty toolchain association for a template doesn't work unless the template element with non-empty toolChain exists under
"org.eclipse.cdt.core.templateAssociations" extension point.

I looked more into these issues and here are my thoughts.

Issue 1: (Re: Comment 1)
------------
Since Eclipse help doc on org.eclipse.cdt.build.core.templates extension point says this:
"Any plugin, which intends to contribute XML templates to the Template Engine must extend this extension point, and add the template element."

So I think this is a problem with org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml since EmptyProject only shows up under templateAssociations. 
Now a strange thing is that, if I do add this to the templates extension point, i.e.
<template
            id="org.eclipse.cdt.build.core.templates.EmptyProject"
            filterPattern=".*"
            location="$nl$/templates/projecttemplates/EmptyProject/template.xml"
            projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
      </template>
I get two "Empty Project" under Executable. getTemplates returns only one EmptyProject. It seems to me that there is a bug in addItemsToTree(CDTMainWizardPage) since it's attaching EmptyProject twice to Executable. I'll investigate more and possible submit a patch (or at least file a bug report).

Issue 2: (Re: Comment 2)
------------

The first question here is:
"if a user contributes to org.eclipse.cdt.core.templates extention point,
is (s)he required to contribute to templateAssocations and specify non-empty toolchain sets to go with it"?
I browsed docs but couldn't find the answer.

If the answer is yes, then this again is a problem with gnu plugin.xml that needs to be fixed.

If the answer is no, the next question is:

If a template doesn't have non-empty toolchain templateAssociation, TemplateEngine (addToolChainsToTemplates) associates an empty toolchain set to it. (instead of, say, all toolchains that are defined in the same plugin.xml). And, downstream, managedbuilder ("isToolChainAcceptable" in MBSWizardHandler) assumes the template is available for all toolchains if an empty toolchain set is associated with it (toolChainIDs.length==0).
Is this a correct assumption to make, or should the handler be assuming the template is not available for any toolchains?

If this is a correct assumption, then the next question is: "How does a user specify that (s)he doesn't want a certain template to be available for any of the toolchain?

I'd like to underststand the design/expected behavior of template support so that I can work on Bug 272103.
Comment 3 Miwako Tokugawa CLA 2009-12-24 15:43:59 EST
(In reply to comment #2)
> Now a strange thing is that, if I do add this to the templates extension point,
> i.e.
> <template
>             id="org.eclipse.cdt.build.core.templates.EmptyProject"
>             filterPattern=".*"
>            
> location="$nl$/templates/projecttemplates/EmptyProject/template.xml"
>             projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
>       </template>
> I get two "Empty Project" under Executable. getTemplates returns only one
> EmptyProject. It seems to me that there is a bug in
> addItemsToTree(CDTMainWizardPage) since it's attaching EmptyProject twice to
> Executable. I'll investigate more and possible submit a patch (or at least file
> a bug report).
I opened Bug 298513