@@ -61,50 +61,52 @@ internal string GetResolvedExpression ()
6161 if ( replacements . Count == 0 )
6262 return expression ;
6363
64- replacements . Sort ( ( Replacement r1 , Replacement r2 ) => r1 . Offset . CompareTo ( r2 . Offset ) ) ;
65- StringBuilder sb = new StringBuilder ( ) ;
64+ replacements . Sort ( ( r1 , r2 ) => r1 . Offset . CompareTo ( r2 . Offset ) ) ;
65+ var resolved = new StringBuilder ( ) ;
6666 int i = 0 ;
6767
68- foreach ( Replacement r in replacements ) {
69- sb . Append ( expression , i , r . Offset - i ) ;
70- sb . Append ( r . NewText ) ;
71- i = r . Offset + r . Length ;
68+ foreach ( var replacement in replacements ) {
69+ resolved . Append ( expression , i , replacement . Offset - i ) ;
70+ resolved . Append ( replacement . NewText ) ;
71+ i = replacement . Offset + replacement . Length ;
7272 }
7373
74- Replacement last = replacements [ replacements . Count - 1 ] ;
75- sb . Append ( expression , last . Offset + last . Length , expression . Length - ( last . Offset + last . Length ) ) ;
74+ var last = replacements [ replacements . Count - 1 ] ;
75+ resolved . Append ( expression , last . Offset + last . Length , expression . Length - ( last . Offset + last . Length ) ) ;
7676
77- return sb . ToString ( ) ;
77+ return resolved . ToString ( ) ;
7878 }
7979
8080 void ReplaceType ( string name , int offset , int length )
8181 {
82- string type = session . ResolveIdentifierAsType ( name , location ) ;
82+ var type = session . ResolveIdentifierAsType ( name , location ) ;
83+
8384 if ( ! string . IsNullOrEmpty ( type ) ) {
8485 type = "global::" + type ;
85- Replacement r = new Replacement ( ) { Offset = offset , Length = length , NewText = type } ;
86- replacements . Add ( r ) ;
86+ var replacement = new Replacement { Offset = offset , Length = length , NewText = type } ;
87+ replacements . Add ( replacement ) ;
8788 }
8889 }
8990
9091 void ReplaceType ( AstType type )
9192 {
9293 int length = type . EndLocation . Column - type . StartLocation . Column ;
93- int offset = type . StartLocation . Column - 1 ;
94-
94+ int offset = type . StartLocation . Column - 1 ;
95+
9596 ReplaceType ( type . ToString ( ) , offset , length ) ;
96- }
97-
98- public override void VisitIdentifierExpression ( IdentifierExpression identifierExpression )
99- {
100- base . VisitIdentifierExpression ( identifierExpression ) ;
101-
102- int length = identifierExpression . IdentifierToken . EndLocation . Column - identifierExpression . IdentifierToken . StartLocation . Column ;
103- int offset = identifierExpression . IdentifierToken . StartLocation . Column - 1 ;
97+ }
98+
99+ public override void VisitIdentifierExpression ( IdentifierExpression identifierExpression )
100+ {
101+ base . VisitIdentifierExpression ( identifierExpression ) ;
102+
103+ int length = identifierExpression . IdentifierToken . EndLocation . Column - identifierExpression . IdentifierToken . StartLocation . Column ;
104+ int offset = identifierExpression . IdentifierToken . StartLocation . Column - 1 ;
105+
104106 if ( identifierExpression . TypeArguments . Count > 0 )
105107 ReplaceType ( identifierExpression . Identifier + "`" + identifierExpression . TypeArguments . Count , offset , length ) ;
106108 else
107- ReplaceType ( identifierExpression . Identifier , offset , length ) ;
109+ ReplaceType ( identifierExpression . Identifier , offset , length ) ;
108110 }
109111
110112 public override void VisitTypeReferenceExpression ( TypeReferenceExpression typeReferenceExpression )
@@ -118,25 +120,26 @@ public override void VisitComposedType (ComposedType composedType)
118120 // call VisitMemberType() or VisitSimpleType() on the ComposedType.BaseType which is all we really
119121 // care to resolve.
120122 base . VisitComposedType ( composedType ) ;
121- }
122-
123- public override void VisitMemberType ( MemberType memberType )
124- {
125- int length = memberType . MemberNameToken . EndLocation . Column - memberType . MemberNameToken . StartLocation . Column ;
126- int offset = memberType . MemberNameToken . StartLocation . Column - 1 ;
127-
123+ }
124+
125+ public override void VisitMemberType ( MemberType memberType )
126+ {
127+ int length = memberType . MemberNameToken . EndLocation . Column - memberType . MemberNameToken . StartLocation . Column ;
128+ int offset = memberType . MemberNameToken . StartLocation . Column - 1 ;
129+
128130 if ( memberType . TypeArguments . Count > 0 )
129131 ReplaceType ( memberType . MemberName + "`" + memberType . TypeArguments . Count , offset , length ) ;
130132 else
131- ReplaceType ( memberType . MemberName , offset , length ) ;
133+ ReplaceType ( memberType . MemberName , offset , length ) ;
132134 }
133135
134136 public override void VisitSimpleType ( SimpleType simpleType )
135- {
136- base . VisitSimpleType ( simpleType ) ;
137- int length = simpleType . IdentifierToken . EndLocation . Column - simpleType . IdentifierToken . StartLocation . Column ;
138- int offset = simpleType . IdentifierToken . StartLocation . Column - 1 ;
139-
137+ {
138+ base . VisitSimpleType ( simpleType ) ;
139+
140+ int length = simpleType . IdentifierToken . EndLocation . Column - simpleType . IdentifierToken . StartLocation . Column ;
141+ int offset = simpleType . IdentifierToken . StartLocation . Column - 1 ;
142+
140143 if ( simpleType . TypeArguments . Count > 0 )
141144 ReplaceType ( simpleType . Identifier + "`" + simpleType . TypeArguments . Count , offset , length ) ;
142145 else
0 commit comments