@@ -50,28 +50,37 @@ public override IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string file
50
50
}
51
51
52
52
// TODO Should have the following options
53
- // * no-empty-line -before
53
+ // * no-empty-lines -before
54
54
// * align (if close brance and open brace on new lines align with open brace,
55
55
// if close brace is on new line but open brace is not align with the first keyword on open brace line)
56
56
57
57
var tokens = Helper . Instance . Tokens ;
58
58
var diagnosticRecords = new List < DiagnosticRecord > ( ) ;
59
- var openBracePosStack = new Stack < int > ( ) ;
59
+ var curlyStack = new Stack < Tuple < Token , int > > ( ) ;
60
60
61
61
for ( int k = 0 ; k < tokens . Length ; k ++ )
62
62
{
63
63
var token = tokens [ k ] ;
64
- if ( token . Kind == TokenKind . LCurly )
64
+ if ( token . Kind == TokenKind . LCurly || token . Kind == TokenKind . AtCurly )
65
65
{
66
- openBracePosStack . Push ( k ) ;
66
+ curlyStack . Push ( new Tuple < Token , int > ( token , k ) ) ;
67
67
continue ;
68
68
}
69
69
70
70
if ( token . Kind == TokenKind . RCurly )
71
71
{
72
- if ( openBracePosStack . Count > 0 )
72
+ if ( curlyStack . Count > 0 )
73
73
{
74
- var openBracePos = openBracePosStack . Pop ( ) ;
74
+ var openBraceToken = curlyStack . Peek ( ) . Item1 ;
75
+ var openBracePos = curlyStack . Pop ( ) . Item2 ;
76
+
77
+ // Ignore if a one line hashtable
78
+ if ( openBraceToken . Kind == TokenKind . AtCurly
79
+ && openBraceToken . Extent . StartLineNumber == token . Extent . StartLineNumber )
80
+ {
81
+ continue ;
82
+ }
83
+
75
84
AddToDiagnosticRecords (
76
85
GetViolationForBraceOnSameLine ( tokens , k , openBracePos , fileName ) ,
77
86
ref diagnosticRecords ) ;
0 commit comments