MCPcopy
hub / github.com/hashicorp/hcl / PartitionIncludingComments

Method PartitionIncludingComments

hclwrite/parser.go:114–125  ·  view source on GitHub ↗

PartitionIncludeComments is like Partition except the returned "within" range includes any lead and line comments associated with the range.

(rng hcl.Range)

Source from the content-addressed store, hash-verified

112// PartitionIncludeComments is like Partition except the returned "within"
113// range includes any lead and line comments associated with the range.
114func (it inputTokens) PartitionIncludingComments(rng hcl.Range) (before, within, after inputTokens) {
115 start, end := partitionTokens(it.nativeTokens, rng)
116 start = partitionLeadCommentTokens(it.nativeTokens[:start])
117 _, afterNewline := partitionLineEndTokens(it.nativeTokens[end:])
118 end += afterNewline
119
120 before = it.Slice(0, start)
121 within = it.Slice(start, end)
122 after = it.Slice(end, len(it.nativeTokens))
123 return
124
125}
126
127// PartitionBlockItem is similar to PartitionIncludeComments but it returns
128// the comments as separate token sequences so that they can be captured into

Callers 1

parseBodyFunction · 0.80

Calls 4

SliceMethod · 0.95
partitionTokensFunction · 0.85
partitionLineEndTokensFunction · 0.85

Tested by

no test coverage detected