external help file | online version | schema |
---|---|---|
PowerShellEditorServices.Commands-help.xml |
2.0.0 |
Test the position of a ScriptExtent object in relation to another.
Test-ScriptExtent [[-Extent] <IScriptExtent>] [-Inside <IScriptExtent>] [-After <IScriptExtent>]
[-Before <IScriptExtent>] [-PassThru]
The Test-ScriptExtent function can be used to determine if a ScriptExtent object is before, after, or inside another ScriptExtent object. You can also test for any combination of these with separate ScriptExtent objects to test against.
Test-ScriptExtent -Extent $extent1 -Inside $extent2
Test if $extent1 is inside $extent2.
$extentList | Test-ScriptExtent -Before $extent1 -After $extent2 -PassThru
Return all extents in $extentList that are before $extent1 but after $extent2.
Specifies the extent to test against.
Type: IScriptExtent
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
Specifies that the reference extent must be inside this extent for the test to pass.
Type: IScriptExtent
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies that the reference extent must be after this extent for the test to pass.
Type: IScriptExtent
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies that the reference extent must be before this extent for the test to pass.
Type: IScriptExtent
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
If specified this function will return the reference extent if the test passed instead of returning a boolean.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
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 result of the test will be returned to the pipeline.
If the "PassThru" parameter is specified and the test passed, the reference script extent will be returned instead.
ConvertTo-ScriptExtent ConvertFrom-ScriptExtent Set-ScriptExtent Join-ScriptExtent