external help file | online version | schema |
---|---|---|
PowerShellEditorServices.Commands-help.xml |
2.0.0 |
Combine multiple ScriptExtent objects into a single ScriptExtent.
Join-ScriptExtent [[-Extent] <IScriptExtent[]>] [<CommonParameters>]
The Join-ScriptExtent function will combine all ScriptExtent objects piped to it into a single extent. This can be used combine multiple ASTs, tokens, or other script elements into a single object that can then be manipulated or used for more targeted searches.
$ast = Find-Ast { $_.Arguments.Count -gt 4 } -First
$ast.Arguments[0..1] | Join-ScriptExtent | Set-ScriptExtent -Text ''
Finds the first InvokeMemberExpression ast that has over 4 arguments and removes the first two.
Specifies the extents to combine. If a single extent is passed, it will be returned as is. If no extents are passed nothing will be returned. Extents passed from the pipeline are processed after pipeline input completes.
Type: IScriptExtent[]
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
You can pass ScriptExtent objects to this function. You can also pass objects with a property named "Extent" such as ASTs from Find-Ast or tokens from Get-Token.
The combined ScriptExtent object is returned.
ConvertTo-ScriptExtent ConvertFrom-ScriptExtent Test-ScriptExtent Set-ScriptExtent