-
Notifications
You must be signed in to change notification settings - Fork 13.8k
[api] Add hasTrailingComma getter in the RemoteNodeList class
#63957
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
Open
Tom Mrazauskas (mrazauskas)
wants to merge
4
commits into
microsoft:main
Choose a base branch
from
mrazauskas:add-hasTrailingComma
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ const ( | |
| NodeOffsetParent | ||
| NodeOffsetData | ||
| NodeOffsetFlags | ||
| NodeOffsetHasTrailingComma | ||
| // NodeSize is the number of bytes that represents a single node in the encoded format. | ||
| NodeSize | ||
| ) | ||
|
|
@@ -63,7 +64,7 @@ const ( | |
| ) | ||
|
|
||
| const ( | ||
| ProtocolVersion uint8 = 7 | ||
| ProtocolVersion uint8 = 8 | ||
|
mrazauskas marked this conversation as resolved.
|
||
| ) | ||
|
|
||
| // Source File Binary Format | ||
|
|
@@ -84,7 +85,7 @@ const ( | |
| // | String data | variable | UTF-8 encoded string data. | | ||
| // | Extended node data | variable | Extra data for some kinds of nodes. | | ||
| // | Structured data | variable | Msgpack-encoded metadata blobs (e.g. file references). | | ||
| // | Nodes | 28 bytes per node | Defines the AST structure of the file, with references to strings and extended data. | | ||
| // | Nodes | 32 bytes per node | Defines the AST structure of the file, with references to strings and extended data. | | ||
| // | ||
| // Header (44 bytes) | ||
| // ----------------- | ||
|
|
@@ -179,7 +180,7 @@ const ( | |
| // | ||
| // An offset of 0xFFFFFFFF indicates no data (empty array). | ||
| // | ||
| // Nodes (28 bytes per node) | ||
| // Nodes (32 bytes per node) | ||
| // ------------------------- | ||
| // | ||
| // The nodes section contains the AST structure of the file. Nodes are represented in a flat array in source order, | ||
|
|
@@ -195,8 +196,9 @@ const ( | |
| // | 16-20 | uint32 | Node index of parent | | ||
| // | 20-24 | | Node data | | ||
| // | 24-28 | uint32 | Node flags | | ||
| // | 28-32 | uint32 | HasTrailingComma (NodeList only; reserved/0 otherwise) | | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By the way, |
||
| // | ||
| // The first 28 bytes of the nodes section are zeros representing a nil node, such that nodes without a parent or next | ||
| // The first 32 bytes of the nodes section are zeros representing a nil node, such that nodes without a parent or next | ||
| // sibling can unambiuously use `0` for those indices. | ||
| // | ||
| // NodeLists are represented as normal nodes with the special `kind` value `0xff_ff_ff_ff`. They are considered the parent | ||
|
|
@@ -502,7 +504,7 @@ func encodeTree(rootNode *ast.Node, sourceFile *ast.SourceFile) ([]byte, *NodeIn | |
| nodes[prevIndex*NodeSize+NodeOffsetNext+3] = b3 | ||
| } | ||
|
|
||
| nodes = appendUint32s(nodes, SyntaxKindNodeList, utf16(nodeList.Pos()), utf16(nodeList.End()), 0, parentIndex, uint32(len(nodeList.Nodes)), 0) | ||
| nodes = appendUint32s(nodes, SyntaxKindNodeList, utf16(nodeList.Pos()), utf16(nodeList.End()), 0, parentIndex, uint32(len(nodeList.Nodes)), 0, uint32(boolToByte(nodeList.HasTrailingComma()))) | ||
|
|
||
| saveParentIndex := parentIndex | ||
|
|
||
|
|
@@ -535,7 +537,7 @@ func encodeTree(rootNode *ast.Node, sourceFile *ast.SourceFile) ([]byte, *NodeIn | |
| nodes[prevIndex*NodeSize+NodeOffsetNext+3] = b3 | ||
| } | ||
|
|
||
| nodes = appendUint32s(nodes, uint32(node.Kind), utf16(node.Pos()), utf16(node.End()), 0, parentIndex, getNodeData(node, strs, positionMap, &extendedData, &structuredData), uint32(node.Flags)) | ||
| nodes = appendUint32s(nodes, uint32(node.Kind), utf16(node.Pos()), utf16(node.End()), 0, parentIndex, getNodeData(node, strs, positionMap, &extendedData, &structuredData), uint32(node.Flags), 0) | ||
|
|
||
| if nodeIndexMap != nil { | ||
| if _, ok := nodeIndexMap[node]; ok { | ||
|
|
@@ -559,14 +561,14 @@ func encodeTree(rootNode *ast.Node, sourceFile *ast.SourceFile) ([]byte, *NodeIn | |
| return node | ||
| } | ||
|
|
||
| nodes = appendUint32s(nodes, 0, 0, 0, 0, 0, 0, 0) | ||
| nodes = appendUint32s(nodes, 0, 0, 0, 0, 0, 0, 0, 0) | ||
|
|
||
| nodeCount++ | ||
| parentIndex++ | ||
| nodeTable = append(nodeTable, rootNode) // index 1 = root node | ||
|
|
||
| sfExtendedDataOffset = len(extendedData) | ||
| nodes = appendUint32s(nodes, uint32(rootNode.Kind), utf16(rootNode.Pos()), utf16(rootNode.End()), 0, 0, getNodeData(rootNode, strs, positionMap, &extendedData, &structuredData), uint32(rootNode.Flags)) | ||
| nodes = appendUint32s(nodes, uint32(rootNode.Kind), utf16(rootNode.Pos()), utf16(rootNode.End()), 0, 0, getNodeData(rootNode, strs, positionMap, &extendedData, &structuredData), uint32(rootNode.Flags), 0) | ||
|
|
||
| visitor.VisitEachChild(rootNode) | ||
| if sourceFile != nil { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.