PartitionIncludeComments is like Partition except the returned "within" range includes any lead and line comments associated with the range.
(rng hcl.Range)
| 112 | // PartitionIncludeComments is like Partition except the returned "within" |
| 113 | // range includes any lead and line comments associated with the range. |
| 114 | func (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 |
no test coverage detected