Community
Participate
Working Groups
Build Identifier: 20100917-0705 I've implemented a formatter based on AbstractDeclarativeFormatter. It's behaving strangely. For example, I have a grammar rule: ------------------------------------------------------------------------------- EntityDeclaration: 'entity' name=Identifier 'is' ... 'end' 'entity'? end_name=[EntityDeclaration]? ';'; ------------------------------------------------------------------------------- And a function in my formatter that configures the some formatting (I have a lot other such functions but I don't see how they could interfere): ------------------------------------------------------------------------------- static private void configureEntityDeclaration(FormattingConfig c, VHDLLangGrammarAccess f) { EntityDeclarationElements eda = f.getEntityDeclarationAccess(); c.setIndentationIncrement().after(eda.getIsKeyword_2()); c.setIndentationDecrement().before(eda.getEndKeyword_7()); } ------------------------------------------------------------------------------- Prior to formatting the (garbled) input is: ------------------------------------------------------------------------------- ... library ieee;use ieee.std_logic_1164.all; use ieee.numeric_std.all;entity fmvgpwbdcxs is generic( knrjvwspqzm:integer range 2 to 6:= 6; ddqwgtngbxc:integer range 0 to 63:=0;whxdkdmhjwj:integer range 0 to 9:=0; ... ------------------------------------------------------------------------------- After formatting: ------------------------------------------------------------------------------- ... library ieee; use ieee.std_logic_1164.ALL; use ieee.numeric_std.ALL; entity fmvgpwbdcxsis generic ( knrjvwspqzm : integer range 2 to 6 := 6; ddqwgtngbxc : integer range 0 to 63 := 0; whxdkdmhjwj : integer range 0 to 9 := 0; ... ------------------------------------------------------------------------------- Note that the 'is' keyword is gone before the generic. Reproducible: Always
I am using Xtext 2.0 M4
Hi Mark, I tried to reproduce this with Xtext HEAD, but I couldn't. I've used this grammar: --------------- grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals generate myDsl "http://www.xtext.org/example/mydsl/MyDsl" Model: greetings+=EntityDeclaration*; EntityDeclaration: 'entity' name=Identifier 'is' foo+=ID* 'end' 'entity'? end_name=[EntityDeclaration]? ';'; Identifier: ID; ---------------- And this formatter: --------------- public class MyDslFormatter extends AbstractDeclarativeFormatter { @Override protected void configureFormatting(FormattingConfig c) { MyDslGrammarAccess g = (MyDslGrammarAccess) getGrammarAccess(); c.setIndentationIncrement().after( g.getEntityDeclarationAccess().getIsKeyword_2()); c.setIndentationDecrement().before( g.getEntityDeclarationAccess().getEndKeyword_4()); c.setLinewrap().after( g.getEntityDeclarationAccess().getFooAssignment_3()); } } --------------- and this document: --------------- entity fmvgpwbdcxs is foo bar baz end fmvgpwbdcxs ; ---------------- The document is getting formatted as intended an the keyword "is" is *not* getting lost. Is there anything missing that I need to know to reproduce this?
After taking a closer look at the example I noticed that no token got lost, it's just a white-space that is disappearing: original: ------- fmvgpwbdcxs is generic ------- formatted: ------- fmvgpwbdcxsis generic ------- (note the keyword "is" is still there, however, it erroneously got merged with "fmvgpwbdcxs")
So, is it a bug in the serialization or am I supposed to write my formatting rules differently?
(In reply to comment #4) > So, is it a bug in the serialization or am I supposed to write my formatting > rules differently? Hi Mark, it's a bug and I'm fixing it. As a workaround you can explicitly configure a white-space before the keyword: cfg.setSpace(" ").before(ruleAccess.getIsKeyword());
fixed in master.
Closing all bugs that were set to RESOLVED before Neon.0