Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Updated the ir lowering phase to lazily add namespaces. #1175

Merged
merged 1 commit into from
Apr 4, 2017

Conversation

NTaylorMullen
Copy link
Member

  • 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

@@ -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.
Copy link
Member

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
Copy link
Member

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,
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in this phase 😄

Copy link
Contributor

@ajaybhargavb ajaybhargavb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one question

- 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
@NTaylorMullen NTaylorMullen merged commit 68554f8 into dev Apr 4, 2017
@NTaylorMullen NTaylorMullen deleted the nimullen/usingimports.1174 branch April 4, 2017 19:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants