@@ -50,28 +50,37 @@ public override IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string file
5050 }
5151
5252 // TODO Should have the following options
53- // * no-empty-line -before
53+ // * no-empty-lines -before
5454 // * align (if close brance and open brace on new lines align with open brace,
5555 // if close brace is on new line but open brace is not align with the first keyword on open brace line)
5656
5757 var tokens = Helper . Instance . Tokens ;
5858 var diagnosticRecords = new List < DiagnosticRecord > ( ) ;
59- var openBracePosStack = new Stack < int > ( ) ;
59+ var curlyStack = new Stack < Tuple < Token , int > > ( ) ;
6060
6161 for ( int k = 0 ; k < tokens . Length ; k ++ )
6262 {
6363 var token = tokens [ k ] ;
64- if ( token . Kind == TokenKind . LCurly )
64+ if ( token . Kind == TokenKind . LCurly || token . Kind == TokenKind . AtCurly )
6565 {
66- openBracePosStack . Push ( k ) ;
66+ curlyStack . Push ( new Tuple < Token , int > ( token , k ) ) ;
6767 continue ;
6868 }
6969
7070 if ( token . Kind == TokenKind . RCurly )
7171 {
72- if ( openBracePosStack . Count > 0 )
72+ if ( curlyStack . Count > 0 )
7373 {
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+
7584 AddToDiagnosticRecords (
7685 GetViolationForBraceOnSameLine ( tokens , k , openBracePos , fileName ) ,
7786 ref diagnosticRecords ) ;
0 commit comments