(nativeAttr *hclsyntax.Attribute, from, leadComments, lineComments, newline inputTokens)
| 239 | } |
| 240 | |
| 241 | func parseAttribute(nativeAttr *hclsyntax.Attribute, from, leadComments, lineComments, newline inputTokens) *node { |
| 242 | attr := &Attribute{ |
| 243 | inTree: newInTree(), |
| 244 | } |
| 245 | children := attr.children |
| 246 | |
| 247 | { |
| 248 | cn := newNode(newComments(leadComments.Tokens())) |
| 249 | attr.leadComments = cn |
| 250 | children.AppendNode(cn) |
| 251 | } |
| 252 | |
| 253 | before, nameTokens, from := from.Partition(nativeAttr.NameRange) |
| 254 | { |
| 255 | children.AppendUnstructuredTokens(before.Tokens()) |
| 256 | if nameTokens.Len() != 1 { |
| 257 | // Should never happen with valid input |
| 258 | panic("attribute name is not exactly one token") |
| 259 | } |
| 260 | token := nameTokens.Tokens()[0] |
| 261 | in := newNode(newIdentifier(token)) |
| 262 | attr.name = in |
| 263 | children.AppendNode(in) |
| 264 | } |
| 265 | |
| 266 | before, equalsTokens, from := from.Partition(nativeAttr.EqualsRange) |
| 267 | children.AppendUnstructuredTokens(before.Tokens()) |
| 268 | children.AppendUnstructuredTokens(equalsTokens.Tokens()) |
| 269 | |
| 270 | before, exprTokens, from := from.Partition(nativeAttr.Expr.Range()) |
| 271 | { |
| 272 | children.AppendUnstructuredTokens(before.Tokens()) |
| 273 | exprNode := parseExpression(nativeAttr.Expr, exprTokens) |
| 274 | attr.expr = exprNode |
| 275 | children.AppendNode(exprNode) |
| 276 | } |
| 277 | |
| 278 | { |
| 279 | cn := newNode(newComments(lineComments.Tokens())) |
| 280 | attr.lineComments = cn |
| 281 | children.AppendNode(cn) |
| 282 | } |
| 283 | |
| 284 | children.AppendUnstructuredTokens(newline.Tokens()) |
| 285 | |
| 286 | // Collect any stragglers, though there shouldn't be any |
| 287 | children.AppendUnstructuredTokens(from.Tokens()) |
| 288 | |
| 289 | return newNode(attr) |
| 290 | } |
| 291 | |
| 292 | func parseBlock(nativeBlock *hclsyntax.Block, from, leadComments, lineComments, newline inputTokens) *node { |
| 293 | block := &Block{ |
no test coverage detected