I can reproduce the following on 0.5.3.3, 0.5.2.93 and subversion revision 21226.

There seems to be a name collision occurring when a user defined syntax defines terms ‘ClassDec’ or ‘MethodDec’.

Example grammar to reproduce:

%% Grammar for the Test language
%% By default, based on an example "entities" syntax
module Test

imports Common

exports

  context-free start-symbols
    Start

  context-free syntax
  
    ClassDec       -> Start
    
    "module" ID -> ClassDec {cons("ClassDec")}

Contents of -Outliner.esv:

module Test-Outliner

imports Test-Outliner.generated

outliner
  
  // This file can be used for custom outliner rules.
  //
  // See the imported file for a brief introduction and examples.
  
  _.ClassDec

Stack trace:

Exception caught from invocation of language-specific tree model builder implementation
java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
    at java.util.ArrayList.RangeCheck(ArrayList.java:547)
    at java.util.ArrayList.get(ArrayList.java:322)
    at org.strategoxt.imp.runtime.services.LabelProvider.getCaption(LabelProvider.java:46)
    at org.strategoxt.imp.runtime.services.LabelProvider.getText(LabelProvider.java:25)
    at org.strategoxt.imp.runtime.services.TreeModelBuilder.startItem(TreeModelBuilder.java:59)
    at org.strategoxt.imp.runtime.services.TreeModelBuilder$TreeModelVisitor.preVisit(TreeModelBuilder.java:41)
    at org.strategoxt.imp.runtime.parser.ast.AbstractVisitor.preVisit(AbstractVisitor.java:13)
    at org.strategoxt.imp.runtime.parser.ast.AstNode.accept(AstNode.java:255)
    at org.strategoxt.imp.runtime.services.TreeModelBuilder.visitTree(TreeModelBuilder.java:55)
    at org.eclipse.imp.services.base.TreeModelBuilderBase.buildTree(TreeModelBuilderBase.java:30)
    at org.strategoxt.imp.runtime.dynamicloading.DynamicTreeModelBuilder.buildTree(DynamicTreeModelBuilder.java:18)
    at org.eclipse.imp.editor.IMPOutlinePage$3.run(IMPOutlinePage.java:104)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3527)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3174)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    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:369)
    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:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1383)

The same result is obtained if a user created syntax definition produces ‘MethodDec’.

My hunch is that the sdf generator also uses ClassDec and MethodDec and a name collision occurs, causing:

private String getCaption(AstNode node) {
	// TODO: add user-defined outline captions, perhaps just using Stratego
	// HACK: Hardcoded outlining, until we have support for patterns
	String constructor = node == null ? null : node.getConstructor();
	
	if ("MethodDec".equals(constructor)) {
		return node.getChildren().get(0).getChildren().get(3).toString();
	} else if ("ClassDec".equals(constructor)) {
		return node.getChildren().get(0).getChildren().get(1).toString();
	} else if (node.getChildren().size() == 1 && node.getChildren().get(0).isList()) {
		return node.getLeftIToken().toString(); // e.g., "rules", "strategies"
...

to incorrectly think that user defined productions are of the internal type.

Submitted by Vlad Vergu on 14 September 2010 at 18:32

On 14 September 2010 at 18:43 Vlad Vergu commented:

Forgot to mention that the communication of the error to the user happens only on stdout. The Outline only contains the items added until the exception occurred.


On 14 September 2010 at 18:46 Vlad Vergu commented:

Ignore my comment regarding the stdout only. The error DOES show in Error Log view.


On 18 September 2010 at 14:32 Lennart Kats commented:

Alright, we can fix this. For now, don’t do use those constructors :)


On 20 September 2010 at 10:52 Lennart Kats closed this issue.

On 20 September 2010 at 10:52 Lennart Kats commented:

Should be fixed in 0.5.3.4 (to be released).

Log in to post comments