There are many node types that are only valid in a specific context. For example, a dictionary pair (key : value) is only valid within a dictionary node. Sometimes the error recovery can handle these cases, but in other cases it can't.
Possible solutions
Use the outer node when parsing
We can try to somehow use the syntax snippets in order to create the proper context, i.e. put the pair in a {} if the outer node is a dictionary.
Custom parser
We can define a parser where all node types are valid at the top level. This would require a custom parser, which is not viable currently, but may be down the line.
Temporary solution: store the type of a fragment on copy
This would only work for nodes copied with a tree-edit function, but would be an easier temporary fix. Would be a good optimization as well
There are many node types that are only valid in a specific context. For example, a dictionary pair (
key : value
) is only valid within a dictionary node. Sometimes the error recovery can handle these cases, but in other cases it can't.Possible solutions
Use the outer node when parsing
We can try to somehow use the syntax snippets in order to create the proper context, i.e. put the pair in a
{}
if the outer node is a dictionary.Custom parser
We can define a parser where all node types are valid at the top level. This would require a custom parser, which is not viable currently, but may be down the line.
Temporary solution: store the type of a fragment on copy
This would only work for nodes copied with a tree-edit function, but would be an easier temporary fix. Would be a good optimization as well