@@ -37,9 +37,12 @@ internal class AbsoluteCodeLine
37
37
private List < string > _strings ;
38
38
private List < string > _brackets ;
39
39
40
- public AbsoluteCodeLine ( string code , IIndenterSettings settings )
40
+ public AbsoluteCodeLine ( string code , IIndenterSettings settings ) : this ( code , settings , null ) { }
41
+
42
+ public AbsoluteCodeLine ( string code , IIndenterSettings settings , AbsoluteCodeLine previous )
41
43
{
42
44
_settings = settings ;
45
+ Previous = previous ;
43
46
44
47
if ( code . EndsWith ( StupidLineEnding ) )
45
48
{
@@ -56,6 +59,7 @@ public AbsoluteCodeLine(string code, IIndenterSettings settings)
56
59
ExtractStringLiteralsAndBrackets ( ) ;
57
60
ExtractLineNumber ( ) ;
58
61
ExtractEndOfLineComment ( ) ;
62
+
59
63
_code = Regex . Replace ( _code , StringPlaceholder + "+" , StringPlaceholder . ToString ( CultureInfo . InvariantCulture ) ) ;
60
64
_code = Regex . Replace ( _code , BracketPlaceholder + "+" , BracketPlaceholder . ToString ( CultureInfo . InvariantCulture ) ) . Trim ( ) ;
61
65
_segments = _code . Split ( new [ ] { ": " } , StringSplitOptions . None ) ;
@@ -120,12 +124,15 @@ private void ExtractStringLiteralsAndBrackets()
120
124
121
125
private void ExtractLineNumber ( )
122
126
{
123
- var match = LineNumberRegex . Match ( _code ) ;
124
- if ( match . Success )
127
+ if ( Previous == null || ! Previous . HasContinuation )
125
128
{
126
- _numbered = true ;
127
- _lineNumber = Convert . ToUInt32 ( match . Groups [ "number" ] . Value ) ;
128
- _code = match . Groups [ "code" ] . Value ;
129
+ var match = LineNumberRegex . Match ( _code ) ;
130
+ if ( match . Success )
131
+ {
132
+ _numbered = true ;
133
+ _lineNumber = Convert . ToUInt32 ( match . Groups [ "number" ] . Value ) ;
134
+ _code = match . Groups [ "code" ] . Value ;
135
+ }
129
136
}
130
137
_code = _code . Trim ( ) ;
131
138
}
@@ -142,6 +149,8 @@ private void ExtractEndOfLineComment()
142
149
EndOfLineComment = match . Groups [ "comment" ] . Value . Trim ( ) ;
143
150
}
144
151
152
+ public AbsoluteCodeLine Previous { get ; private set ; }
153
+
145
154
public string Original { get ; private set ; }
146
155
147
156
public string Escaped
@@ -203,7 +212,7 @@ public bool HasDeclarationContinuation
203
212
204
213
public bool HasContinuation
205
214
{
206
- get { return _code . EndsWith ( " _" ) || EndOfLineComment . EndsWith ( " _" ) ; }
215
+ get { return _code . Equals ( "_" ) || _code . EndsWith ( " _" ) || EndOfLineComment . EndsWith ( " _" ) ; }
207
216
}
208
217
209
218
public bool IsPrecompilerDirective
0 commit comments