@@ -85,20 +85,18 @@ public void ImplicitExpressionRejectsWholeIdentifierReplacementToKeyword()
85
85
RazorEngineHost host = CreateHost ( ) ;
86
86
RazorEditorParser parser = new RazorEditorParser ( host , @"C:\This\Is\A\Test\Path" ) ;
87
87
88
- using ( TestParserManager manager = new TestParserManager ( parser ) )
89
- {
90
- StringTextBuffer old = new StringTextBuffer ( "foo @date baz" ) ;
91
- StringTextBuffer changed = new StringTextBuffer ( "foo @if baz" ) ;
92
- TextChange textChange = new TextChange ( 5 , 4 , old , 2 , changed ) ;
93
- manager . InitializeWithDocument ( old ) ;
88
+ TestParserManager manager = new TestParserManager ( parser ) ;
89
+ StringTextBuffer old = new StringTextBuffer ( "foo @date baz" ) ;
90
+ StringTextBuffer changed = new StringTextBuffer ( "foo @if baz" ) ;
91
+ TextChange textChange = new TextChange ( 5 , 4 , old , 2 , changed ) ;
92
+ manager . InitializeWithDocument ( old ) ;
94
93
95
- // Act
96
- PartialParseResult result = manager . CheckForStructureChangesAndWait ( textChange ) ;
94
+ // Act
95
+ PartialParseResult result = manager . CheckForStructureChangesAndWait ( textChange ) ;
97
96
98
- // Assert
99
- Assert . Equal ( PartialParseResult . Rejected , result ) ;
100
- Assert . Equal ( 2 , manager . ParseCount ) ;
101
- }
97
+ // Assert
98
+ Assert . Equal ( PartialParseResult . Rejected , result ) ;
99
+ Assert . Equal ( 2 , manager . ParseCount ) ;
102
100
}
103
101
104
102
[ Fact ]
@@ -108,20 +106,18 @@ public void ImplicitExpressionRejectsWholeIdentifierReplacementToDirective()
108
106
RazorEngineHost host = CreateHost ( ) ;
109
107
RazorEditorParser parser = new RazorEditorParser ( host , @"C:\This\Is\A\Test\Path" ) ;
110
108
111
- using ( var manager = new TestParserManager ( parser ) )
112
- {
113
- StringTextBuffer old = new StringTextBuffer ( "foo @date baz" ) ;
114
- StringTextBuffer changed = new StringTextBuffer ( "foo @inherits baz" ) ;
115
- TextChange textChange = new TextChange ( 5 , 4 , old , 8 , changed ) ;
116
- manager . InitializeWithDocument ( old ) ;
109
+ TestParserManager manager = new TestParserManager ( parser ) ;
110
+ StringTextBuffer old = new StringTextBuffer ( "foo @date baz" ) ;
111
+ StringTextBuffer changed = new StringTextBuffer ( "foo @inherits baz" ) ;
112
+ TextChange textChange = new TextChange ( 5 , 4 , old , 8 , changed ) ;
113
+ manager . InitializeWithDocument ( old ) ;
117
114
118
- // Act
119
- PartialParseResult result = manager . CheckForStructureChangesAndWait ( textChange ) ;
115
+ // Act
116
+ PartialParseResult result = manager . CheckForStructureChangesAndWait ( textChange ) ;
120
117
121
- // Assert
122
- Assert . Equal ( PartialParseResult . Rejected | PartialParseResult . SpanContextChanged , result ) ;
123
- Assert . Equal ( 2 , manager . ParseCount ) ;
124
- }
118
+ // Assert
119
+ Assert . Equal ( PartialParseResult . Rejected | PartialParseResult . SpanContextChanged , result ) ;
120
+ Assert . Equal ( 2 , manager . ParseCount ) ;
125
121
}
126
122
127
123
[ Fact ]
@@ -415,52 +411,50 @@ public void ImplicitExpressionProvisionallyAcceptsCaseInsensitiveDotlessCommitIn
415
411
StringTextBuffer old = new StringTextBuffer ( "foo @date baz" ) ;
416
412
StringTextBuffer changed = new StringTextBuffer ( "foo @date. baz" ) ;
417
413
TextChange textChange = new TextChange ( 9 , 0 , old , 1 , changed ) ;
418
- using ( TestParserManager manager = CreateParserManager ( ) )
414
+ TestParserManager manager = CreateParserManager ( ) ;
415
+ Action < TextChange , PartialParseResult , string > applyAndVerifyPartialChange = ( changeToApply , expectedResult , expectedCode ) =>
419
416
{
420
- Action < TextChange , PartialParseResult , string > applyAndVerifyPartialChange = ( changeToApply , expectedResult , expectedCode ) =>
421
- {
422
- PartialParseResult result = manager . CheckForStructureChangesAndWait ( textChange ) ;
417
+ PartialParseResult result = manager . CheckForStructureChangesAndWait ( textChange ) ;
423
418
424
- // Assert
425
- Assert . Equal ( expectedResult , result ) ;
426
- Assert . Equal ( 1 , manager . ParseCount ) ;
419
+ // Assert
420
+ Assert . Equal ( expectedResult , result ) ;
421
+ Assert . Equal ( 1 , manager . ParseCount ) ;
427
422
428
- ParserTestBase . EvaluateParseTree ( manager . Parser . CurrentParseTree , new MarkupBlock (
429
- factory . Markup ( "foo " ) ,
430
- new ExpressionBlock (
431
- factory . CodeTransition ( ) ,
432
- factory . Code ( expectedCode ) . AsImplicitExpression ( CSharpCodeParser . DefaultKeywords ) . Accepts ( AcceptedCharacters . NonWhiteSpace ) ) ,
433
- factory . Markup ( " baz" ) ) ) ;
434
- } ;
423
+ ParserTestBase . EvaluateParseTree ( manager . Parser . CurrentParseTree , new MarkupBlock (
424
+ factory . Markup ( "foo " ) ,
425
+ new ExpressionBlock (
426
+ factory . CodeTransition ( ) ,
427
+ factory . Code ( expectedCode ) . AsImplicitExpression ( CSharpCodeParser . DefaultKeywords ) . Accepts ( AcceptedCharacters . NonWhiteSpace ) ) ,
428
+ factory . Markup ( " baz" ) ) ) ;
429
+ } ;
435
430
436
- manager . InitializeWithDocument ( textChange . OldBuffer ) ;
431
+ manager . InitializeWithDocument ( textChange . OldBuffer ) ;
437
432
438
- // This is the process of a dotless commit when doing "." insertions to commit intellisense changes.
433
+ // This is the process of a dotless commit when doing "." insertions to commit intellisense changes.
439
434
440
- // @date => @date.
441
- applyAndVerifyPartialChange ( textChange , PartialParseResult . Accepted | PartialParseResult . Provisional , "date." ) ;
435
+ // @date => @date.
436
+ applyAndVerifyPartialChange ( textChange , PartialParseResult . Accepted | PartialParseResult . Provisional , "date." ) ;
442
437
443
- old = changed ;
444
- changed = new StringTextBuffer ( "foo @date baz" ) ;
445
- textChange = new TextChange ( 9 , 1 , old , 0 , changed ) ;
438
+ old = changed ;
439
+ changed = new StringTextBuffer ( "foo @date baz" ) ;
440
+ textChange = new TextChange ( 9 , 1 , old , 0 , changed ) ;
446
441
447
- // @date. => @date
448
- applyAndVerifyPartialChange ( textChange , PartialParseResult . Accepted , "date" ) ;
442
+ // @date. => @date
443
+ applyAndVerifyPartialChange ( textChange , PartialParseResult . Accepted , "date" ) ;
449
444
450
- old = changed ;
451
- changed = new StringTextBuffer ( "foo @DateTime baz" ) ;
452
- textChange = new TextChange ( 5 , 4 , old , 8 , changed ) ;
445
+ old = changed ;
446
+ changed = new StringTextBuffer ( "foo @DateTime baz" ) ;
447
+ textChange = new TextChange ( 5 , 4 , old , 8 , changed ) ;
453
448
454
- // @date => @DateTime
455
- applyAndVerifyPartialChange ( textChange , PartialParseResult . Accepted , "DateTime" ) ;
449
+ // @date => @DateTime
450
+ applyAndVerifyPartialChange ( textChange , PartialParseResult . Accepted , "DateTime" ) ;
456
451
457
- old = changed ;
458
- changed = new StringTextBuffer ( "foo @DateTime. baz" ) ;
459
- textChange = new TextChange ( 13 , 0 , old , 1 , changed ) ;
452
+ old = changed ;
453
+ changed = new StringTextBuffer ( "foo @DateTime. baz" ) ;
454
+ textChange = new TextChange ( 13 , 0 , old , 1 , changed ) ;
460
455
461
- // @DateTime => @DateTime.
462
- applyAndVerifyPartialChange ( textChange , PartialParseResult . Accepted | PartialParseResult . Provisional , "DateTime." ) ;
463
- }
456
+ // @DateTime => @DateTime.
457
+ applyAndVerifyPartialChange ( textChange , PartialParseResult . Accepted | PartialParseResult . Provisional , "DateTime." ) ;
464
458
}
465
459
466
460
[ Fact ]
0 commit comments