-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Variable declaration addition #3152
Conversation
@@ -39,24 +41,151 @@ public HttpSyntaxTree Parse() | |||
{ | |||
_tokens = new HttpLexer(_sourceText, _syntaxTree).Lex(); | |||
|
|||
var unmatchedComments = new List<HttpCommentNode>(); |
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'd probably just call this comments
. They're matched, they're just not parented yet. Or maybe something like commentsToPrepend
?
|
||
} | ||
|
||
private HttpVariableValueNode? ParseVariableExpression() |
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.
private HttpVariableValueNode? ParseVariableExpression() | |
private HttpVariableValueNode? ParseVariableValue() |
{ | ||
break; | ||
} | ||
}*/ |
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.
Feel free to delete leftover comments.
return null; | ||
} | ||
|
||
private HttpSyntaxToken? GetNextNodeType() |
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.
This name looks inaccurate. How is this different from GetNextSignificantToken
?
if (MoreTokens() && CurrentToken is { Kind: HttpTokenKind.Punctuation } and { Text: "#" }) | ||
{ | ||
return true; | ||
} else if (MoreTokens() && CurrentToken is { Kind: HttpTokenKind.Punctuation } and { Text: "/" } && |
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.
You can refactor this to dedupe the MoreTokens
call.
{ | ||
return true; | ||
} | ||
else if (MoreTokens() && CurrentToken is { Kind: HttpTokenKind.Punctuation } and { Text: "/" } && |
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.
You can refactor this to dedupe the MoreTokens
call.
{ | ||
public HttpVariableDeclarationNode? DeclarationNode { get; private set; } | ||
public HttpVariableAssignmentNode? AssignmentNode { get; private set; } | ||
public HttpVariableValueNode? ExpressionNode { get; private set; } |
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.
Calling this property ValueNode
is probably a better match to the property's type name at this point.
yield return diagnostic; | ||
} | ||
|
||
yield return base.CreateDiagnostic("Variable name expected."); |
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.
This looks like a bug (and presumably a missing test?) unless there's a condition around it, e.g. if (Span.Length ==0)
.
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 don't fully get what you mean here
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.
This will always return a diagnostic even if the node is perfectly valid.
src/Microsoft.DotNet.Interactive.HttpRequestParser/HttpVariableDeclarationNode.cs
Show resolved
Hide resolved
Head branch was pushed to by a user without write access
No description provided.