ziga
ziga

Reputation: 109

remove <unnamed> fields in outline view of xtext eclipse

I have started working on eclipse recently. In eclipse xtext my grammar is:

regGrp:
    reg_type=reg_type1 "{" reg_definition+=reg_definition1+ "}"
    ;

reg_type1 :
    name="CONTROL_REGISTERS"
    ;

reg_definition1:
    name=ID '[' regSize=INT ']''{' (regFieldssss=regFieldsdefRule) '}'
    ;

regFieldsdefRule:
    name="DESCRIPTION" '=' descStr=STRING ';'
    ;

Then after Run_as -> Eclipse_application in final.sts file I can write a code as:

CONTROL_REGISTERS {
    reg [5] { 
        DESCRIPTION = "register" ;
    }
}

In the outline view I will get tree as below:

         ->final
           -> <unnamed>
             -> <unnamed>
               CONTROL_REGISTERS
             -> reg
               -> <unnamed>
                  DESCRIPTION

I wanted to remove those fields in outline tree. Finally outline tree should look something like:

                ->final
                  ->CONTROL_REGISTERS
                    ->reg
                      ->DESCRIPTION

Please anyone can tell me how to implement this?

Upvotes: 5

Views: 1882

Answers (1)

A.H.
A.H.

Reputation: 66263

The outline is computed by an IOutlineTreeProvider. The default Xtext project setup generates an empty stub for you in the *.ui project (named MydslnameOulineTreeProvider). This stub inherits inherits from DefaultOutlineTreeProvider. Inside the stub you can add customizations. Please refer to the documentation here at for the details of this customization.

Upvotes: 6

Related Questions