Search code examples
rascal

Categorising syntax in Eclipse outline


I'm trying to create an outline for a syntax definition I create in rascal. I've managed to make the various object appear in the outline by simply adding label annotations like recommended in the documentation. However, I would also like to "categorise" these objects so that all the objects of the same type end up under a common collapsible category. Like the way that Rascal's outline is with all the annotations, functions, variables, tests and so on sorted into their own categories. I haven't found anything really in the documentation about it. I've tried applying @Category to the syntax and to the AST, neither really worked

public node ps_outline(Tree x){
    PSGAME g = ps_implode(x);
    
    return g;
}

This is currently the function that I register as my outliner, all that ps_implode does is add a @label and @location annotation to the imploded syntax definition.

new_l @ location = l@location;
new_l @ label = "Level";

Current outline vs Desired outline

The current appearance of the outline Desired outline (mockup)


Solution

  • You can nest nodes like so:

    "Sounds"(["soundData"(...)])
    

    The nesting of the value will be reflected in the outline. Lists will be treated as elements on the same nesting level. The intermediate nodes use the same labels and location information. If a node label appears twice I'm not sure what happens.. it could be that the trees under the same nodes are merged 😎 Cheers!