branch: wip_templates

2 views
Skip to first unread message

David Bernard

unread,
Jun 30, 2010, 1:21:49 PM6/30/10
to scala-...@googlegroups.com
I pushed a branch wip_templates (branch from tycho-reorg). So you can :

* try/review the templates basic support.
* complete the file
org.scala-ide.sdt.core/templates/default-templates.xml with other
template you would like to share

/davidB

Matt Russell

unread,
Jul 1, 2010, 7:58:44 AM7/1/10
to Scala IDE Dev
Hi David,

I was trying this out but not getting much luck, unfortunately. For
example, if I create a Scala file with text:

object Foo {

main

}

and press Ctrl-Space after "main", I don't get any options, even if I
cycle through the various lists. I do get a section in Window -> Scala
-> Templates.

I also got an entry in the error log (see below). Let me know if I can
help debug more, because I'd very much like to use this feature ;-)

-- Matt

Ignoring template 'trycatch' since validation failed.
org.eclipse.jface.text.templates.TemplateException: Template has
incomplete variables. Type '$$' to enter the dollar character.
at
org.eclipse.jface.text.templates.TemplateTranslator.fail(TemplateTranslator.java:
238)
at
org.eclipse.jface.text.templates.TemplateTranslator.parse(TemplateTranslator.java:
190)
at
org.eclipse.jface.text.templates.TemplateTranslator.translate(TemplateTranslator.java:
166)
at
org.eclipse.jface.text.templates.TemplateContextType.validate(TemplateContextType.java:
200)
at
org.eclipse.ui.editors.text.templates.ContributionTemplateStore.validateTemplate(ContributionTemplateStore.java:
194)
at
org.eclipse.ui.editors.text.templates.ContributionTemplateStore.readIncludedTemplates(ContributionTemplateStore.java:
156)
at
org.eclipse.ui.editors.text.templates.ContributionTemplateStore.readContributedTemplates(ContributionTemplateStore.java:
120)
at
org.eclipse.ui.editors.text.templates.ContributionTemplateStore.loadContributedTemplates(ContributionTemplateStore.java:
107)
at
org.eclipse.jface.text.templates.persistence.TemplateStore.load(TemplateStore.java:
108)
at
org.eclipse.ui.texteditor.templates.TemplatePreferencePage.performCancel(TemplatePreferencePage.java:
1450)
at org.eclipse.jface.preference.PreferenceDialog
$1.run(PreferenceDialog.java:260)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.runtime.Platform.run(Platform.java:888)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
at
org.eclipse.jface.preference.PreferenceDialog.cancelPressed(PreferenceDialog.java:
258)
at
org.eclipse.jface.preference.PreferenceDialog.buttonPressed(PreferenceDialog.java:
237)
at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624)
at
org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:
228)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1176)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:
3493)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3112)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
at org.eclipse.jface.window.Window.open(Window.java:801)
at
org.eclipse.ui.internal.dialogs.WorkbenchPreferenceDialog.open(WorkbenchPreferenceDialog.java:
211)
at
org.eclipse.ui.internal.OpenPreferencesAction.run(OpenPreferencesAction.java:
65)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
at
org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:
584)
at org.eclipse.jface.action.ActionContributionItem.access
$2(ActionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem
$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1176)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:
3493)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3112)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
at org.eclipse.jface.window.Window.open(Window.java:801)
at
org.eclipse.ui.internal.views.log.EventDetailsDialog.open(EventDetailsDialog.java:
175)
at
org.eclipse.ui.internal.views.log.EventDetailsDialogAction.run(EventDetailsDialogAction.java:
98)
at org.eclipse.ui.internal.views.log.LogView
$15.doubleClick(LogView.java:535)
at org.eclipse.jface.viewers.StructuredViewer
$1.run(StructuredViewer.java:821)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.runtime.Platform.run(Platform.java:888)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
at
org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:
819)
at
org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSelect(AbstractTreeViewer.java:
1419)
at org.eclipse.jface.viewers.StructuredViewer
$4.widgetDefaultSelected(StructuredViewer.java:1195)
at
org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:
238)
at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:235)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:
296)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1176)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:
3493)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3112)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:
332)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:
493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:
149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:
113)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:
194)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:
110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:
79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:
368)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:
179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
at org.eclipse.equinox.launcher.Main.main(Main.java:1287)

David Bernard

unread,
Jul 1, 2010, 8:32:29 AM7/1/10
to scala-...@googlegroups.com
Thanks for reporting,
I'll take a look.

You could try to remove the trycatch templates from
templates/defaults-templates.xml in case there is relation between
troubles.
But I suppose I forgot to re-connect a method when I create the branch.

David Bernard

unread,
Jul 1, 2010, 8:54:05 AM7/1/10
to scala-...@googlegroups.com
I forgot to commit one file.
I pushed the fixes :

* Ctrl+Espace to propose template
* trycatch syntax error

/davidB

Matt Russell

unread,
Jul 1, 2010, 11:34:47 AM7/1/10
to Scala IDE Dev
Thanks, that now works great for me.

Might be worth seeing if there's any good ideas we could nick from
IntelliJ:

http://confluence.jetbrains.net/display/SCA/Live+Templates

-- Matt

Matt Russell

unread,
Jul 4, 2010, 12:47:29 PM7/4/10
to Scala IDE Dev
I was testing out the new template stuff from a locally-built update
site, and it doesn't look like org.scala-ide.sdt.core/templates/
default-templates.xml is being copied through during the build.

David Bernard

unread,
Jul 7, 2010, 7:50:17 AM7/7/10
to Scala IDE Dev
I install scala-ide from locally-built update-site and didn't notice
this issue.
But I forgot to commit/pushed the updated build.properties.

Fixed now. I also change the way template are added into ContentAssist
(move from eclipse standard way to jdt way)

Sorry.

Matt Russell

unread,
Jul 7, 2010, 8:07:58 AM7/7/10
to Scala IDE Dev
On Jul 7, 12:50 pm, David Bernard <david.bernard...@gmail.com> wrote:
> I install scala-ide from locally-built update-site and didn't notice
> this issue.
> But I forgot to commit/pushed the updated build.properties.
>
> Fixed now.

Thanks David!

I was also going to propose a "pimp" template, something like:

implicit def ${SourceType}2Rich${SourceType}(from: ${SourceType}):
Rich${SourceType} = new Rich${SourceType}(from)

class Rich${SourceType}(from: ${SourceType}) {

${cursor}

}

-- Matt

David Bernard

unread,
Jul 7, 2010, 8:12:56 AM7/7/10
to scala-...@googlegroups.com
feel free to update the default-templates.xml (I'm not a big user of
templates (sysout, main, may be test)).
I created a "templates" component under the assembla tickets (It's to
replace my TODO post-it)
Reply all
Reply to author
Forward
0 new messages