Improve documentation and error message for InsertTokensBefore/After and ReplaceToken methods #80691
+106
−18
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.
Plan for Improving InsertTokensBefore/After and ReplaceToken Documentation and Error Messages
Based on the issue analysis:
Update XML documentation for
InsertTokensBefore
,InsertTokensAfter
, andReplaceToken(tokenInList, IEnumerable<SyntaxToken>)
methods to clearly state:tokenInList
parameter must be a direct element of aSyntaxTokenList
SyntaxTokenList
Keep the original
MissingListItem
error message for nodesAdd new
MissingTokenListItem
error message specifically for tokensUpdate
TokenListEditor.VisitToken
in both C# and VB to use the new token-specific error messageUpdate .xlf localization files for the new error message
Verify tests still pass and error messages are improved
All changes complete! The original
MissingListItem
error message has been preserved for nodes, and a newMissingTokenListItem
error message has been added specifically for tokens. The error message for tokens is now: "The specified token must be a direct element of a SyntaxTokenList (such as a modifier in a list of modifiers). The token cannot be an arbitrary token from the syntax tree."Original prompt
Fixes #3082
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.