How to define different indentation levels in the same document with Xtext formatter -


is possible format document follows, using xtext formatting? can see, test children indented 4 spaces while external children indented 2 spaces only. using xtext 2.12.0.

test my_prog {     device = "my_device";     param = 0; }  external {   path = "my_path";   file = "my_file"; } 

you try work custom replacers, dont know if work nested block though

def dispatch void format(external model, extension iformattabledocument document) {     model.regionfor.keyword("}").prepend[newline]     (l : model.ids) {         val region = l.regionfor.feature(mydslpackage.literals.idx__name)         region.prepend[newline]         val r = new abstracttextreplacer(document, region) {             override createreplacements(itextreplacercontext it) {                 val offset = region.offset                 it.addreplacement(region.textregionaccess.rewriter.createreplacement(offset, 0, "  "))                             }         }         addreplacer(r)     } } 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -