You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your enhancement related to a problem? Please describe.
If an anchor isn’t referenced, it’s unused. The language server protocol explicitly supports unused ranges using the Diagnostic#tags. Monaco editor / VS Code also support this by rendering them as faded.
Describe the solution you would like
I would like the yaml validation to report unused anchors in addition to JSON schema validation errors.
I suggest to report them using a diagnostic with the DiagnosticTag.Deprecated tag without a severity.
Describe alternatives you have considered
N/A
Additional context
I already fiddled a bit myself, but I couldn’t find a way to get the anchor range.
import{visit,isNode,Node,isAlias}from'yaml';// Added in https://github.com/redhat-developer/yaml-language-server/blob/13adb0e02199ce673e582bb5387577f9936a66a1/src/languageservice/services/yamlValidation.ts#L89constanchors=newSet<Node>();constusedAnchors=newSet<Node>();visit(currentYAMLDoc.internalDocument,(key,node)=>{if(!isNode(node)){return;}if(node.anchor){anchors.add(node);}if(isAlias(node)){usedAnchors.add(node.resolve(currentYAMLDoc.internalDocument));}});for(constanchorofanchors){if(!usedAnchors.has(anchor)){console.dir(anchor);}}
This finds unused anchors, but I don’t know if this is the right approach. I hope it helps.
The text was updated successfully, but these errors were encountered:
Is your enhancement related to a problem? Please describe.
If an anchor isn’t referenced, it’s unused. The language server protocol explicitly supports unused ranges using the Diagnostic#tags. Monaco editor / VS Code also support this by rendering them as faded.
Describe the solution you would like
I would like the yaml validation to report unused anchors in addition to JSON schema validation errors.
I suggest to report them using a diagnostic with the
DiagnosticTag.Deprecated
tag without a severity.Describe alternatives you have considered
N/A
Additional context
I already fiddled a bit myself, but I couldn’t find a way to get the anchor range.
This finds unused anchors, but I don’t know if this is the right approach. I hope it helps.
The text was updated successfully, but these errors were encountered: