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

Conversation

@ajaybhargavb
Copy link
Contributor

Another file with lots of tests

@@ -1,7 +1,7 @@
Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [26] )
Code span at (2:1,0 [2] ) (Accepts:Any) - Parent: Directive block at (2:1,0 [24] )
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can I fight for this? I don't get why the whitespace prior to a directive needs to be part of the directive. The way I designed it, the directive starts with a transition@.

Copy link
Member

Choose a reason for hiding this comment

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

I'll let @NTaylorMullen weigh in on this.

Choose a reason for hiding this comment

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

How do you plan to implement trivia for directives? In my mind the leading whitespace of a directive should have the following characteristics:

  • Cannot contain any content
  • Should have 0 intellisense/completion at design time
  • Can be 0+ whitespace characters long.

With whatever trivia approach you have in mind would it make the above characteristics easy to implement/understand?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From what I understand from Roslyn, "trivia" is generally associated with tokens rather than specific nodes. Leading trivia of any node is basically the leading trivia of its first token. https://github.com/dotnet/roslyn/blob/master/src/Compilers/Core/Portable/Syntax/SyntaxNode.cs#L911.
It does make sense to have the leading whitespace as the leading trivia for the transition @. But don't we already allow comments before the start of a directive? Not sure if it makes sense to have that as part of trivia. Having said that, I haven't given a lot of thought to how we want to do trivia yet. So, this might need more discussion.

Choose a reason for hiding this comment

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

But don't we already allow comments before the start of a directive?

Nah

image

Do you think it makes sense to design (not implement) the plans for trivia now so we can make better choices with the SyntaxTree? Or does it make sense to wait and do reactive changes later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Spoke to @NTaylorMullen offline. We are not going to make this consistent with the old world because the old world already has different behavior depending on the contents of the previous line. I plan to keep this change and test this in the editor to make sure we didn't break anything.

@@ -1,7 +1,7 @@
Markup span at (0:0,0 [2] ) (Accepts:Any) - Parent: Markup block at (0:0,0 [46] )
Code span at (2:1,0 [2] ) (Accepts:Any) - Parent: Directive block at (2:1,0 [44] )
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ditto

Identifier;[Encoding];
Dot;[.];
Identifier;[ASCIIEncoding];
MarkupEphemeralTextLiteral - [42..44)::2 - [LF] - Gen<None> - SpanEditHandler;Accepts:Whitespace
Copy link
Member

Choose a reason for hiding this comment

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

I see this and I lol? What is this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Naming is hard! I had originally named it MarkupHiddenTextLiteral. This is basically content that is necessary for design time but we don't want them rendered in output.

Copy link
Member

Choose a reason for hiding this comment

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

It seems like I have a lot to learn

@ajaybhargavb ajaybhargavb force-pushed the ajbaaska/razordirectivestest branch from e3517b0 to 15426c7 Compare October 17, 2018 21:54
@ajaybhargavb ajaybhargavb force-pushed the ajbaaska/razordirectivestest branch from 15426c7 to 1b25ad9 Compare November 2, 2018 18:42
CSharpTransition - [0..1)::1 - Gen<None> - SpanEditHandler;Accepts:None
Transition;[@];
RazorDirectiveBody - [1..17)::16
RazorMetaCode - [1..13)::12 - Gen<None> - SpanEditHandler;Accepts:None

Choose a reason for hiding this comment

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

Might eventually make sense to lift this outside of the directive body since it represents the directive identifier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CSharpStatementLiteral - [8..15)::7 - [string?] - Gen<DirectiveToken {;Type;Opt:False}> - DirectiveTokenEditHandler;Accepts:NonWhitespace
Keyword;[string];
QuestionMark;[?];
CSharpStatementLiteral - [15..16)::1 - [ ] - Gen<None> - SpanEditHandler;Accepts:Whitespace

Choose a reason for hiding this comment

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

Ya we'll also eventually want to change these whitespace markers to be a different type of significant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

MarkupBlock - [0..19)::19
MarkupTextLiteral - [0..0)::0 - [] - Gen<Markup> - SpanEditHandler;Accepts:Any
Marker;[];
CSharpCodeBlock - [0..19)::19

Choose a reason for hiding this comment

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

Still hate that we wrap things like this in code blocks but it's something we'll probably never change

@ajaybhargavb ajaybhargavb merged commit 1b25ad9 into feature/razor-parser Nov 2, 2018
@ajaybhargavb ajaybhargavb deleted the ajbaaska/razordirectivestest branch November 2, 2018 22:02
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.

4 participants