** * Unlike the utilities `setTextRange`, this checks if the `location` we're trying to set on `range` is within the * same file as the active context. If not, the range is not applied. This prevents us from copying ranges across files, * which will confuse the node printer (as it assumes all node r
(range_ *ast.Node, location *ast.Node)
| 1354 | * It also calls `setOriginalNode` to setup a `.original` pointer, since you basically *always* want these in the node builder. |
| 1355 | */ |
| 1356 | func (b *NodeBuilderImpl) setTextRange(range_ *ast.Node, location *ast.Node) *ast.Node { |
| 1357 | if range_ == nil { |
| 1358 | return range_ |
| 1359 | } |
| 1360 | if !ast.NodeIsSynthesized(range_) || (range_.Flags&ast.NodeFlagsSynthesized == 0) || b.ctx.enclosingFile == nil || b.ctx.enclosingFile != ast.GetSourceFileOfNode(b.e.MostOriginal(range_)) { |
| 1361 | original := range_ |
| 1362 | range_ = range_.Clone(b.f) // if `range` is synthesized or originates in another file, copy it so it definitely has synthetic positions |
| 1363 | range_.Loc = core.NewTextRange(-1, -1) |
| 1364 | if symbol, ok := b.idToSymbol[original]; ok { |
| 1365 | b.idToSymbol[range_] = symbol |
| 1366 | } |
| 1367 | } |
| 1368 | if range_ == location || location == nil { |
| 1369 | return range_ |
| 1370 | } |
| 1371 | // Don't overwrite the original node if `range` has an `original` node that points either directly or indirectly to `location` |
| 1372 | original := b.e.Original(range_) |
| 1373 | for original != nil && original != location { |
| 1374 | original = b.e.Original(original) |
| 1375 | } |
| 1376 | if original == nil { |
| 1377 | b.e.SetOriginalEx(range_, location, true) |
| 1378 | } |
| 1379 | |
| 1380 | // only set positions if range comes from the same file since copying text across files isn't supported by the emitter |
| 1381 | if b.ctx.enclosingFile != nil && b.ctx.enclosingFile == ast.GetSourceFileOfNode(b.e.MostOriginal(location)) { |
| 1382 | range_.Loc = location.Loc |
| 1383 | return range_ |
| 1384 | } else { |
| 1385 | range_.Loc = core.NewTextRange(-1, -1) |
| 1386 | } |
| 1387 | return range_ |
| 1388 | } |
| 1389 | |
| 1390 | func (b *NodeBuilderImpl) typeParameterShadowsOtherTypeParameterInScope(name string, typeParameter *Type) bool { |
| 1391 | result := b.ch.resolveName(b.ctx.enclosingDeclaration, name, ast.SymbolFlagsType, nil, false, false) |
no test coverage detected