File tree Expand file tree Collapse file tree 2 files changed +36
-5
lines changed
src/main/java/net/seesharpsoft/intellij/plugins/csv/formatter Expand file tree Collapse file tree 2 files changed +36
-5
lines changed Original file line number Diff line number Diff line change @@ -33,10 +33,6 @@ protected List<Block> buildChildren() {
3333 }
3434
3535 IElementType elementType = node .getElementType ();
36- if (elementType == TokenType .ERROR_ELEMENT || elementType == TokenType .BAD_CHARACTER ) {
37- break ;
38- }
39-
4036 todoNodes .add (node .getTreeNext ());
4137 if (elementType == CsvTypes .RECORD ) {
4238 todoNodes .add (node .getFirstChildNode ());
@@ -47,6 +43,8 @@ protected List<Block> buildChildren() {
4743 }
4844 } else if (elementType == CsvTypes .COMMA || elementType == CsvTypes .CRLF ) {
4945 blocks .add (new CsvBlockElement (node , formattingInfo , currentField ));
46+ } else if (elementType != TokenType .WHITE_SPACE && node .getTextLength () > 0 ) {
47+ blocks .add (new CsvDummyBlock (node , formattingInfo ));
5048 }
5149 }
5250 return blocks ;
@@ -61,7 +59,7 @@ public Indent getIndent() {
6159 @ Override
6260 public Spacing getSpacing (@ Nullable Block child1 , @ NotNull Block child2 ) {
6361 Spacing spacing = null ;
64- if (child1 != null ) {
62+ if (child1 != null && !( child1 instanceof CsvDummyBlock ) && !( child2 instanceof CsvDummyBlock ) ) {
6563 CsvBlockElement block1 = (CsvBlockElement ) child1 ;
6664 CsvBlockElement block2 = (CsvBlockElement ) child2 ;
6765 if (formattingInfo .getCsvCodeStyleSettings ().TABULARIZE && isTabularizeSpacingRequired (block1 , block2 )) {
Original file line number Diff line number Diff line change 1+ package net .seesharpsoft .intellij .plugins .csv .formatter ;
2+
3+ import com .intellij .formatting .Block ;
4+ import com .intellij .formatting .Spacing ;
5+ import com .intellij .lang .ASTNode ;
6+ import org .jetbrains .annotations .NotNull ;
7+ import org .jetbrains .annotations .Nullable ;
8+
9+ import java .util .Collections ;
10+ import java .util .List ;
11+
12+ public class CsvDummyBlock extends CsvBlock {
13+
14+ protected CsvDummyBlock (@ NotNull ASTNode node , CsvFormattingInfo formattingInfo ) {
15+ super (node , formattingInfo );
16+ }
17+
18+ @ Override
19+ protected List <Block > buildChildren () {
20+ return Collections .EMPTY_LIST ;
21+ }
22+
23+ @ Nullable
24+ @ Override
25+ public Spacing getSpacing (@ Nullable Block block , @ NotNull Block block1 ) {
26+ return null ;
27+ }
28+
29+ @ Override
30+ public boolean isLeaf () {
31+ return true ;
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments