Skip to content

Commit e710e84

Browse files
committed
failsafe wasn't in except for analysis, add new test.
1 parent 2292e5f commit e710e84

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

java/src/org/antlr/codebuff/Formatter.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ public void processToken(int indexIntoRealTokens, int tokenIndexInStream) {
9696
int indent = indentClassifier.classify(k, features, corpus.indent, CollectFeatures.MAX_CONTEXT_DIFF_THRESHOLD);
9797
int ws = wsClassifier.classify(k, features, corpus.injectWS, CollectFeatures.MAX_CONTEXT_DIFF_THRESHOLD);
9898

99+
if ( ws==0 && cannotJoin(realTokens.get(indexIntoRealTokens-1), curToken) ) { // failsafe!
100+
ws = 1;
101+
}
102+
99103
TokenPositionAnalysis tokenPositionAnalysis =
100104
getTokenAnalysis(features, indexIntoRealTokens, tokenIndexInStream, injectNewline, alignWithPrevious, indent, ws);
101105
analysis.setSize(tokenIndexInStream+1);

samples/Switch.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
public class T {
2+
void f() {
3+
switch ( x ) {
4+
case 0 :
5+
x=y;
6+
break;
7+
case 1 :
8+
break;
9+
default :
10+
}
11+
int y;
12+
}
13+
}

0 commit comments

Comments
 (0)