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

Function MoveRangePastModifiers

internal/transformers/utilities.go:308–322  ·  view source on GitHub ↗

MoveRangePastModifiers returns a text range that starts past any modifiers on the node.

(node *ast.Node)

Source from the content-addressed store, hash-verified

306
307// MoveRangePastModifiers returns a text range that starts past any modifiers on the node.
308func MoveRangePastModifiers(node *ast.Node) core.TextRange {
309 if ast.IsPropertyDeclaration(node) || ast.IsMethodDeclaration(node) {
310 return core.NewTextRange(node.Name().Pos(), node.End())
311 }
312
313 var lastModifier *ast.Node
314 if ast.CanHaveModifiers(node) {
315 lastModifier = core.LastOrNil(node.ModifierNodes())
316 }
317
318 if lastModifier != nil && !ast.PositionIsSynthesized(lastModifier.End()) {
319 return core.NewTextRange(lastModifier.End(), node.End())
320 }
321 return MoveRangePastDecorators(node)
322}
323
324// MoveRangePastDecorators returns a text range that starts past any decorators on the node.
325func MoveRangePastDecorators(node *ast.Node) core.TextRange {

Calls 12

EndMethod · 0.95
IsPropertyDeclarationFunction · 0.92
IsMethodDeclarationFunction · 0.92
NewTextRangeFunction · 0.92
CanHaveModifiersFunction · 0.92
LastOrNilFunction · 0.92
PositionIsSynthesizedFunction · 0.92
MoveRangePastDecoratorsFunction · 0.85
ModifierNodesMethod · 0.80
PosMethod · 0.65
NameMethod · 0.65
EndMethod · 0.65

Tested by

no test coverage detected