-
Notifications
You must be signed in to change notification settings - Fork 226
Updated the ir lowering phase to lazily add namespaces. #1175
Conversation
@@ -64,16 +54,31 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument) | |||
|
|||
visitor.VisitBlock(syntaxTree.Root); | |||
|
|||
// In each lowering piece above, namespaces were tracked. We render them here to ensure every | |||
// lowering action has a chance to add a source location to a namespace. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also mention here that the closest wins. We want to use the using
from the main source file if possible.
|
||
builder.Insert(i++, @using); | ||
} | ||
|
||
codeDocument.SetIRDocument(document); | ||
} | ||
|
||
private class LoweringVisitor : ParserVisitor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unit test?
var @using = new UsingStatementIRNode() | ||
{ | ||
Content = @namespace.Key, | ||
Source = @namespace.Value, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When there are multiple identical usings, any chance one with null source appear later and overwrite one with source?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in this phase 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one question
92695a2
to
4be7a20
Compare
- The lazy addition of namespaces gives the main document lowering phase an opportunity to add source location information which we then add after the main lowering. - Re-generated csharp to capture addition of using statements that were previously overridden by defaults/imports. #1174
4be7a20
to
72dfb1d
Compare
#1174