2

In looking for a working example of "Menu" for the DSL I am writing, I tried "Pico". But the following fails:

rascal>import demo::lang::Pico::Plugin;
|plugin://rascal_eclipse/src/org/rascalmpl/eclipse/library/demo/lang/Pico/Plugin.rsc|(1791,48,<71,6>,<71,54>): The called signature: action(str, void (...)),
does not match any of the declared (overloaded) signature patterns:
Menu = action(str,void (Tree, loc))
Menu = action(str,void (str, loc))

If I comment out lines 71-73 of "Plugin.rsc" it loads successfully, but then of course I have no "Menu". Can someone point me to a fix of this (which doesn't require much Eclipse or Java expertise :) or to a different working example of "Menu"?

Thanks

My environment:

Rascal: (I don't know how to print the version, but one of the files is rascal_eclipse_0.7.3.201506091957.jar )

Eclipse: for RCP and RAP Developers Version: Mars Release (4.5.0) Java: version "1.8.0_51" OS: Linux Mint 17 Qiana

Shaminder Singh
  • 1,283
  • 2
  • 18
  • 31
sailco12
  • 87
  • 5

1 Answers1

1

Popup menus can be added as contributions to your registered language using the popup(Menu menu) constructor. After you have created the contributions that you need call the registerContribution(..) (defined in util::IDE) function supplying the constructed Contribution data type.

For example, in Pico the contributions are defined as follows:

public set[Contribution] Pico_CONTRIBS = {
  popup(
    menu("Pico",[
        action("Evaluate Pico program", evalPicoProgram),
        action("Compile Pico to ASM", compilePicoProgram),
        action("Show Control flow graph", visualizePicoProgram)
    ])
  )
};

The signature of the evalPicoProgram, compilePicoProgram and visualizePicoProgram are

public void _name_(Tree x, loc selection) {
  ...
}

Eventually the contributions get registered with the following code:

registerContributions("Pico", Pico_CONTRIBS);

In the Pico example the menu that was registered contained an action constructors with a wrong type. This was indeed a bug in Rascal. The signature of the action constructor changed in the past and the Pico Plugin module was not updated accordingly.

I made the necessary changes and it should be fixed in the newest unstable version of Rascal.