Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add powershell builtins #967

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions lib/rouge/lexers/powershell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class Powershell < Shell
Export-BCSecretKey Export-IscsiTargetServerConfiguration
Export-ODataEndpointProxy Export-RDPersonalSessionDesktopAssignment
Export-RDPersonalVirtualDesktopAssignment Export-ScheduledTask
Find-NetIPsecRule Find-NetRoute Format-Hex Format-Volume Get-AppBackgroundTask
Find-NetIPsecRule Find-NetRoute ForEach-Object Format-Hex Format-Volume Get-AppBackgroundTask
Get-AppvVirtualProcess Get-AppxLastError Get-AppxLog Get-AssignedAccess
Get-AutologgerConfig Get-BCClientConfiguration Get-BCContentServerConfiguration
Get-BCDataCache Get-BCDataCacheExtension Get-BCHashCache
Expand Down Expand Up @@ -231,11 +231,11 @@ class Powershell < Shell
New-StorageSubsystemVirtualDisk New-StorageTier New-TemporaryFile
New-VirtualDisk New-VirtualDiskClone New-VirtualDiskSnapshot New-Volume
New-VpnServerAddress Open-NetGPO Optimize-StoragePool Optimize-Volume
Publish-BCFileContent Publish-BCWebContent Publish-SilData Read-PrinterNfcTag
Parse-Path Publish-BCFileContent Publish-BCWebContent Publish-SilData Read-PrinterNfcTag
Register-ClusteredScheduledTask Register-DnsClient Register-IscsiSession
Register-ScheduledTask Register-StorageSubsystem Remove-AutologgerConfig
Remove-BCDataCacheExtension Remove-DAEntryPointTableItem
Remove-DnsClientNrptRule Remove-DscConfigurationDocument
Remove-DnsClientNrptRule Remove-Drive Remove-DscConfigurationDocument
Remove-DtcClusterTMMapping Remove-EtwTraceProvider Remove-EtwTraceSession
Remove-FileShare Remove-InitiatorId Remove-InitiatorIdFromMaskingSet
Remove-IscsiTargetPortal Remove-MaskingSet Remove-MpPreference Remove-MpThreat
Expand Down Expand Up @@ -446,10 +446,10 @@ class Powershell < Shell
Get-CertificateEnrollmentPolicyServer Get-CertificateNotificationTask
Get-ChildItem Get-CimAssociatedInstance Get-CimClass Get-CimInstance
Get-CimSession Get-CIPolicy Get-CIPolicyIdInfo Get-CIPolicyInfo Get-Clipboard
Get-CmsMessage Get-ComputerInfo Get-ComputerRestorePoint Get-Content
Get-CmsMessage Get-Command Get-ComputerInfo Get-ComputerRestorePoint Get-Content
Get-ControlPanelItem Get-Counter Get-Credential Get-Culture Get-DAPolicyChange
Get-Date Get-Event Get-EventLog Get-EventSubscriber Get-ExecutionPolicy
Get-FormatData Get-Host Get-HotFix Get-IISAppPool Get-IISCentralCertProvider
Get-FormatData Get-Help Get-Host Get-HotFix Get-IISAppPool Get-IISCentralCertProvider
Get-IISConfigAttributeValue Get-IISConfigCollection
Get-IISConfigCollectionElement Get-IISConfigElement Get-IISConfigSection
Get-IISServerManager Get-IISSharedConfig Get-IISSite Get-IscsiServerTarget
Expand Down Expand Up @@ -614,7 +614,7 @@ class Powershell < Shell
Unregister-Event Unregister-ScheduledJob Unregister-UevTemplate
Unregister-WindowsDeveloperLicense Update-FormatData Update-List
Update-TypeData Update-UevTemplate Update-WIMBootEntry Use-Transaction
Use-WindowsUnattend Wait-Debugger Wait-Event Wait-Process Write-Debug
Use-WindowsUnattend Wait-Debugger Wait-Event Wait-Process Where-Object Write-Debug
Write-Error Write-EventLog Write-Host Write-Information Write-Output
Write-Progress Write-Verbose Write-Warning \% \? ac asnp cat cd chdir clc clear
clhy cli clp cls clv cnsn compare copy cp cpi cpp curl cvpa dbp del diff dir
Expand Down Expand Up @@ -668,10 +668,12 @@ class Powershell < Shell
rule /#.*$/, Comment::Single
rule /\b(#{OPERATORS})\s*\b/i, Operator
rule /\b(#{ATTRIBUTES})\s*\b/i, Name::Attribute
rule /\b(#{BUILTINS})\s*\b(?!\.)/i, Name::Builtin
rule /\b(#{KEYWORDS})\s*\b/i, Keyword
rule /\b(#{KEYWORDS_TYPE})\s*\b/i, Keyword::Type

rule /\bcase\b/, Keyword, :case
rule /\b(#{BUILTINS})\s*\b(?!\.)/i, Name::Builtin

end
end
end
Expand Down
12 changes: 12 additions & 0 deletions spec/visual/samples/powershell
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,15 @@ try {
} catch {
write-output "something else"
}

ForEach ($i in (1..1E4)) {

$i

} | Measure-Object

ForEach-Object -InputObject (1..1E4) {

$_

} | Measure-Object