MCPcopy Create free account
hub / github.com/microsoft/typescript-go / isLabeledBy

Function isLabeledBy

internal/ls/documenthighlights.go:567–577  ·  view source on GitHub ↗

Whether or not a 'node' is preceded by a label of the given string. Note: 'node' cannot be a SourceFile.

(node *ast.Node, labelName string)

Source from the content-addressed store, hash-verified

565// Whether or not a 'node' is preceded by a label of the given string.
566// Note: 'node' cannot be a SourceFile.
567func isLabeledBy(node *ast.Node, labelName string) bool {
568 return ast.FindAncestorOrQuit(node.Parent, func(owner *ast.Node) ast.FindAncestorResult {
569 if !ast.IsLabeledStatement(owner) {
570 return ast.FindAncestorQuit
571 }
572 if owner.Label().Text() == labelName {
573 return ast.FindAncestorTrue
574 }
575 return ast.FindAncestorFalse
576 }) != nil
577}
578
579func getBreakOrContinueStatementOccurrences(node *ast.Node, sourceFile *ast.SourceFile) []*ast.Node {
580 if owner := getBreakOrContinueOwner(node); owner != nil {

Callers 1

getBreakOrContinueOwnerFunction · 0.85

Calls 4

FindAncestorOrQuitFunction · 0.92
IsLabeledStatementFunction · 0.92
LabelMethod · 0.80
TextMethod · 0.65

Tested by

no test coverage detected