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

Function getBreakOrContinueOwner

internal/ls/documenthighlights.go:537–563  ·  view source on GitHub ↗
(statement *ast.Node)

Source from the content-addressed store, hash-verified

535}
536
537func getBreakOrContinueOwner(statement *ast.Node) *ast.Node {
538 return ast.FindAncestorOrQuit(statement, func(node *ast.Node) ast.FindAncestorResult {
539 switch node.Kind {
540 case ast.KindSwitchStatement:
541 if statement.Kind == ast.KindContinueStatement {
542 return ast.FindAncestorFalse
543 }
544 fallthrough
545 case ast.KindForStatement,
546 ast.KindForInStatement,
547 ast.KindForOfStatement,
548 ast.KindWhileStatement,
549 ast.KindDoStatement:
550 // If the statement is labeled, check if the node is labeled by the statement's label.
551 if statement.Label() == nil || isLabeledBy(node, statement.Label().Text()) {
552 return ast.FindAncestorTrue
553 }
554 return ast.FindAncestorFalse
555 default:
556 // Don't cross function boundaries.
557 if ast.IsFunctionLike(node) {
558 return ast.FindAncestorQuit
559 }
560 return ast.FindAncestorFalse
561 }
562 })
563}
564
565// Whether or not a 'node' is preceded by a label of the given string.
566// Note: 'node' cannot be a SourceFile.

Calls 5

FindAncestorOrQuitFunction · 0.92
IsFunctionLikeFunction · 0.92
isLabeledByFunction · 0.85
LabelMethod · 0.80
TextMethod · 0.65

Tested by

no test coverage detected