Bug 184593 - [Template Engine] Need a way to add tool-chain associations to existing templates
Summary: [Template Engine] Need a way to add tool-chain associations to existing templ...
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 4.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.0 M7   Edit
Assignee: Bala Torati CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks: 184457 184462
  Show dependency tree
 
Reported: 2007-04-28 08:12 EDT by Mikhail Sennikovsky CLA
Modified: 2008-06-20 11:26 EDT (History)
4 users (show)

See Also:


Attachments
Patch for changing the common identifier from location to id. (18.88 KB, patch)
2007-05-10 08:57 EDT, Bala Torati CLA
no flags Details | Diff
full patch (48.96 KB, patch)
2007-05-10 09:27 EDT, Bala Torati CLA
bjorn.freeman-benson: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mikhail Sennikovsky CLA 2007-04-28 08:12:56 EDT
Currently it seems impossible to associate additional tool-chains to allready existing template definitions.

Suppose I have a "Hellow World" template defined for the gnu tool-chain.
Now I add one more a new "foo" tool-chain in my "bar" plug-in. How would I associate my "foo" tool-chain with the "Hellow World" template defined in the other (gnu.ui) plug-in without modifying it?

An other thing (I'm not sure this is possible now) is to allow specifying that the template is applicable for all tool-chains, e.g. the "hellow world" or an "empty project" template seem to be quite common to be applicable to any tool-chain

Mikhail
Comment 1 Mikhail Sennikovsky CLA 2007-05-03 08:38:37 EDT
I guess we might have an additional extension point that would allow specifying the "template_id" <-> "tool-chain_ID" associations.

Mikhail
Comment 2 Mikhail Sennikovsky CLA 2007-05-04 06:31:27 EDT
Hi Bala,

Is there any chanse we could fix this for the M7? 
..targetting to M7 for now..

Mikhail
Comment 3 Mikhail Sennikovsky CLA 2007-05-04 06:44:56 EDT
.. I was thinking if we could have only two possible variants of associations for the 4.0:

1. Teplate is associated _only_ with the tool-chains specified in the template definition
2. Template is can be used with _all_ tool-chains in case the template definition specifies no tool-chain ids.

The problems with this approach is that generally no templates could be applicable for _all_ tool-chains, e.g. the "Hellow World" template that generates a HellowWorld.cpp file will not be appplicable for the non-C++ tool-chains, e.g. those not having the C++ compiler.

What do others think? Will the above two variants of template<->tool-chain associations be enough for the 4.0?

Mikhail
Comment 4 Doug Schaefer CLA 2007-05-04 08:43:18 EDT
(In reply to comment #3)
> 1. Teplate is associated _only_ with the tool-chains specified in the template
> definition

Yes.

> 2. Template is can be used with _all_ tool-chains in case the template
> definition specifies no tool-chain ids.

I think you're right. A template that can apply to all toolchains doesn't make sense. I would actually only do #1.
Comment 5 Bala Torati CLA 2007-05-10 06:56:44 EDT
A fix for this is included in the patch attached with bug 184449.
Comment 6 Mikhail Sennikovsky CLA 2007-05-10 07:52:35 EDT
Hi Bala,

I have a question regarding the addToolChainsToTemplate extension-point defined with your patch:
What if I want to associate my tool-chain with the template defined in another plug-in?
Ho would I specify the location of that template in this case?

Also the extension point schema definition does not seem to be correct.

Thanks,
Mikhail
Comment 7 Mikhail Sennikovsky CLA 2007-05-10 07:56:24 EDT
(In reply to comment #6)
> Also the extension point schema definition does not seem to be correct.
I've fixed this, so no need in a new patch..

So the only question left is with specifying the template location..

Mikhail
Comment 8 Bala Torati CLA 2007-05-10 08:28:45 EDT
(In reply to comment #7)
> (In reply to comment #6)
> > Also the extension point schema definition does not seem to be correct.
> I've fixed this, so no need in a new patch..
> So the only question left is with specifying the template location..
> Mikhail

I think instead of working from template location, it would be better to work from 'template id'. I am not very sure whethere we can change the templates extension point definition and add 'id' as an additional mandatory field. If that's ok, then I will change the schema to take the unique id as the attribute, instead of location.
Comment 9 Bala Torati CLA 2007-05-10 08:57:14 EDT
Created attachment 66659 [details]
Patch for changing the common identifier from location to id.

This patch includes changing the common identifier from 'location' to 'id' for templates. 
Mikhail,
This doesn't include the problem you corrected in the 'addToolChainsToTemplate' schema. Please include that.

Thanks,
-Bala
Comment 10 Mikhail Sennikovsky CLA 2007-05-10 09:00:34 EDT
(In reply to comment #8)
> I think instead of working from template location, it would be better to work
> from 'template id'.
I think this is the best approach we can do

> I am not very sure whethere we can change the templates
> extension point definition and add 'id' as an additional mandatory field. If
> that's ok, then I will change the schema to take the unique id as the
> attribute, instead of location.
I guess we could make the "id" attribute as optional and if not specified - use the id specified in the template definition (template.xml). In this case there will be no API breackage.

Mikhail
Comment 11 Mikhail Sennikovsky CLA 2007-05-10 09:08:53 EDT
(In reply to comment #9)
Hi Bala,

How should I merge the changes in this patch with those you sent with the previous one?

Should I apply the previous one first?

Thanks,
Mikhail
Comment 12 Mikhail Sennikovsky CLA 2007-05-10 09:12:37 EDT
(In reply to comment #9)
> Created an attachment (id=66659) [details]
Thanks Bala,

Could we make the id attribute behave as specified in the comment# 10?

Mikhail
Comment 13 Bala Torati CLA 2007-05-10 09:26:21 EDT
(In reply to comment #11)
> (In reply to comment #9)
> Hi Bala,
> How should I merge the changes in this patch with those you sent with the
> previous one?
> Should I apply the previous one first?
> Thanks,
> Mikhail

THe previous patch needs to be applied first. Then apply this patch on top of this. Not sure how the merge will work. Since I can't produce an incremental patch, I just picked the files that are modified as part of this fix, and created the patch.
I am posting a full patch for the three defects together including these changes, just in case if you have trouble merging the earlier patches.



Comment 14 Bala Torati CLA 2007-05-10 09:27:52 EDT
Created attachment 66664 [details]
full patch

This patch also includes implementation as per comment#10.
Comment 15 Mikhail Sennikovsky CLA 2007-05-10 09:41:21 EDT
I'm getting NPE with the latest patch:

steps to reproduce:
1. New Workspace
2. New -> "C++ Project"

Stack-trace below

Thread [main] (Suspended (exception NullPointerException))	
	TemplateCore.<init>(TemplateInfo) line: 81	
	TemplateCore.getTemplate(TemplateInfo) line: 234	
	TemplateEngine.getTemplates() line: 75	
	TemplateEngine.addToolChainsToTemplates() line: 240	
	TemplateEngine.initializeTemplateInfoMap() line: 235	
	TemplateEngine.<init>() line: 61	
	TemplateEngine.<clinit>() line: 49	
	TemplateEngineUI.getTemplates() line: 86	
	TemplateCNewWizard.createItems(boolean, IWizard) line: 33	
	CDTMainWizardPage.updateData(Tree, Composite, Button, IWizardItemsListListener, IWizard) line: 431	
	CDTMainWizardPage.createControl(Composite) line: 116	
	CCProjectWizard(Wizard).createPageControls(Composite) line: 170	
	WizardDialog.createPageControls() line: 669	
	WizardDialog.setWizard(IWizard) line: 1083	
	WizardDialog.updateForPage(IWizardPage) line: 1142	
	WizardDialog.access$2(WizardDialog, IWizardPage) line: 1139	
	WizardDialog$4.run() line: 1128	
	BusyIndicator.showWhile(Display, Runnable) line: 67	
	WizardDialog.showPage(IWizardPage) line: 1126	
	NewWizardSelectionPage.advanceToNextPageOrFinish() line: 71	
	NewWizardNewPage$1.doubleClick(DoubleClickEvent) line: 355	
	StructuredViewer$1.run() line: 799	
	SafeRunner.run(ISafeRunnable) line: 37	
	Platform.run(ISafeRunnable) line: 850	
	JFaceUtil$1.run(ISafeRunnable) line: 46	
	SafeRunnable.run(ISafeRunnable) line: 193	
	TreeViewer(StructuredViewer).fireDoubleClick(DoubleClickEvent) line: 797	
	TreeViewer(AbstractTreeViewer).handleDoubleSelect(SelectionEvent) line: 1369	
	StructuredViewer$4.widgetDefaultSelected(SelectionEvent) line: 1168	
	OpenStrategy.fireDefaultSelectionEvent(SelectionEvent) line: 237	
	OpenStrategy.access$0(OpenStrategy, SelectionEvent) line: 234	
	OpenStrategy$1.handleEvent(Event) line: 295	
	EventTable.sendEvent(Event) line: 66	
	Tree(Widget).sendEvent(Event) line: 938	
	Display.runDeferredEvents() line: 3673	
	Display.readAndDispatch() line: 3284	
	WizardDialog(Window).runEventLoop(Shell) line: 820	
	WizardDialog(Window).open() line: 796	
	NewProjectAction.run() line: 116	
	NewProjectAction(Action).runWithEvent(Event) line: 498	
	ActionContributionItem.handleWidgetSelection(Event, boolean) line: 545	
	ActionContributionItem.access$2(ActionContributionItem, Event, boolean) line: 490	
	ActionContributionItem$5.handleEvent(Event) line: 402	
	EventTable.sendEvent(Event) line: 66	
	MenuItem(Widget).sendEvent(Event) line: 938	
	Display.runDeferredEvents() line: 3673	
	Display.readAndDispatch() line: 3284	
	Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2365	
	Workbench.runUI() line: 2329	
	Workbench.access$4(Workbench) line: 2204	
	Workbench$4.run() line: 466	
	Realm.runWithDefault(Realm, Runnable) line: 289	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 461	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149	
	IDEApplication.start(IApplicationContext) line: 106	
	EclipseAppHandle.run(Object) line: 153	
	EclipseAppLauncher.runApplication(Object) line: 106	
	EclipseAppLauncher.start(Object) line: 76	
	EclipseStarter.run(Object) line: 363	
	EclipseStarter.run(String[], Runnable) line: 176	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
	Method.invoke(Object, Object[]) line: 324	
	Main.invokeFramework(String[], URL[]) line: 497	
	Main.basicRun(String[]) line: 436	
	Main.run(String[]) line: 1162	
	Main.main(String[]) line: 1137	
Comment 16 Mikhail Sennikovsky CLA 2007-05-10 09:46:30 EDT
(In reply to comment #15)
> I'm getting NPE with the latest patch:
I seem to know how to fix this, will postr an update on this soon
Comment 17 Bala Torati CLA 2007-05-10 10:02:22 EDT
(In reply to comment #16)
> (In reply to comment #15)
> > I'm getting NPE with the latest patch:
> I seem to know how to fix this, will postr an update on this soon

Thanks Mikhail, The fix could be like this.
Make the TemplateEngine.getSharedDefaults()' method as static and at the null pointer exception place, take the 'getDefault()' from the templateengine call. ie. call this static method.
Comment 18 Mikhail Sennikovsky CLA 2007-05-10 11:01:58 EDT
(In reply to comment #17)
> Thanks Mikhail, The fix could be like this.
> Make the TemplateEngine.getSharedDefaults()' method as static and at the null
> pointer exception place, take the 'getDefault()' from the templateengine call.
> ie. call this static method.
Thanks Bala,

I've already got a bit alternative fix that seems to work fine.

One additional minor question I have is naming: what about naming the new addToolChainsToTemplate extension point as "templateAssociations"?
This would allow, e.g. add template <-> project type associations via the same extension point once we implement multiple project type associations.
If you are OK with this change, I could do it myself.

Mikhail
Comment 19 Mikhail Sennikovsky CLA 2007-05-10 11:44:24 EDT
(In reply to comment #18)
> One additional minor question I have is naming: what about naming the new
> addToolChainsToTemplate extension point as "templateAssociations"?
> This would allow, e.g. add template <-> project type associations via the same
> extension point once we implement multiple project type associations.
> If you are OK with this change, I could do it myself.
OK, since there are no objections I'm going to procede with this..
Comment 20 Bala Torati CLA 2007-05-10 12:04:09 EDT
(In reply to comment #19)
> (In reply to comment #18)
> > One additional minor question I have is naming: what about naming the new
> > addToolChainsToTemplate extension point as "templateAssociations"?
> > This would allow, e.g. add template <-> project type associations via the same
> > extension point once we implement multiple project type associations.
> > If you are OK with this change, I could do it myself.
> OK, since there are no objections I'm going to procede with this..

Sorry.. Was away on a meeting. The change in name is fine for me.

Comment 21 Mikhail Sennikovsky CLA 2007-05-10 12:09:22 EDT
(In reply to comment #20)
> Sorry.. Was away on a meeting. The change in name is fine for me.
Thanks Bala, and sorry for being hurried ;).. just wanted the functionality to be checked in as soon as possible and thoroughly tested for the M7.

The patch is applied now. 
Closing the bug..

Thanks,
Mikhail