DAX Formatting

Nov 5, 2011 at 9:34 AM

I'd like to implement some settings related to DAX formatting.

In particular, I'd like to control:

  • newline for parameters of a function
  • newline for closing parenthesis

In particular, I'd like to avoid closing parenthesis always goes in a new line.

I've seen the code has a "IsLongStringBetweenParenthesiss" function which is no longer used, but the best hint I would need is about the meaning of EolType enum. It seems that keeping the parenthesis in the same line as the last parameter can be done by using EolType.Unknown, but it's not clear to me how to control it - probably I'm missing something in the big picture about how EolType is handled in OnClosingParenthesis code. Probably I will understand it with more study, but in the meantime if you have any hint...

Thanks,

Marco

 

 

Nov 8, 2011 at 12:12 AM

Please try Crtl+K < and Ctrl+K >.  They work better than anything else I saw, so IsLongStringBetweenParenthesiss is not implemented :)  I used something like IsLongStringBetweenParenthesiss in MDX formatter, but DAX formatting is better than in MDX.  And it is natural - in order to understand what query does user usually start with the top level function, than go to the second level functions, etc.

As far as code goes, you are looking at the correct spot.  There are different type of end of file:
- Eol (CR/LF, new text starts from position 0),
- EolIndent (CR/LF + current indent),
- EoLIndentPlus (CR/LF + increased indent) and
-EolHardIndent1(CR/LF, new text starts with one fixed indent).

New formatting options should be defined in DaxFormattingPage class.