claude-flow-novice 2.3.5 → 2.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/booster/performance-benchmark.js +1 -1
- package/dist/src/booster/wasm-demo.js +1 -1
- package/dist/src/cli/command-registry.js +2 -2
- package/dist/src/cli/help-formatter.js +137 -109
- package/dist/src/cli/simple-cli.js +2528 -2121
- package/dist/src/cli/simple-commands/sparc/refinement.js +3 -3
- package/dist/src/cli/validation-helper.js +98 -49
- package/dist/src/commands/suggest-templates.js +4 -4
- package/dist/src/core/version.js +23 -15
- package/dist/src/memory/swarm-memory.js +603 -470
- package/dist/src/slash-commands/fullstack.js +2 -2
- package/dist/src/slash-commands/parse-epic.js +1 -1
- package/package.json +1 -1
- package/scripts/postinstall.js +40 -6
- package/dist/scripts/.claude-flow/metrics/agent-metrics.json +0 -1
- package/dist/scripts/.claude-flow/metrics/performance.json +0 -9
- package/dist/scripts/.claude-flow/metrics/task-metrics.json +0 -10
- package/dist/scripts/CLEANUP_OPTIMIZATION_REPORT.json +0 -312
- package/dist/scripts/CLEANUP_PERFORMANCE_OPTIMIZATION.md +0 -387
- package/dist/scripts/CLEANUP_QUICK_START.md +0 -268
- package/dist/scripts/CLEANUP_TEST_RESULTS.md +0 -205
- package/dist/scripts/README.md +0 -339
- package/dist/scripts/ace-query.sh +0 -384
- package/dist/scripts/agent-token-analysis.js +0 -430
- package/dist/scripts/auto-setup.js +0 -332
- package/dist/scripts/build/README.md +0 -167
- package/dist/scripts/build/build-config.js +0 -27
- package/dist/scripts/build/build-prompt-copier.sh +0 -30
- package/dist/scripts/build/performance-monitor.js +0 -869
- package/dist/scripts/build/prepare-publish.js +0 -150
- package/dist/scripts/build/typescript-fixer.js +0 -621
- package/dist/scripts/build/unified-builder.sh +0 -428
- package/dist/scripts/build/update-bin-version.js +0 -32
- package/dist/scripts/build/validate-agents.js +0 -238
- package/dist/scripts/build-index.js +0 -43
- package/dist/scripts/build-orchestrator.js +0 -320
- package/dist/scripts/check-routing-stats.cjs +0 -122
- package/dist/scripts/ci-validation.js +0 -375
- package/dist/scripts/cleanup-blocking-coordination.sh +0 -420
- package/dist/scripts/cleanup-idle-sessions.sh +0 -118
- package/dist/scripts/collect-build-metrics.js +0 -65
- package/dist/scripts/demo/README.md +0 -79
- package/dist/scripts/demo/autoscaling-demo-simplified.js +0 -963
- package/dist/scripts/demo/comprehensive-dashboard-test.js +0 -693
- package/dist/scripts/demo/confidence-log.js +0 -87
- package/dist/scripts/demo/confidence-report.js +0 -82
- package/dist/scripts/demo/demo-multi-swarm-coordination.js +0 -325
- package/dist/scripts/demo/demo-production-deployment.js +0 -399
- package/dist/scripts/demo/demo-visualization-system.js +0 -149
- package/dist/scripts/demo/performance-analysis.cjs +0 -71
- package/dist/scripts/demo/performance-analysis.js +0 -71
- package/dist/scripts/demo/test-autoscaling-demo.js +0 -314
- package/dist/scripts/dependency-optimizer.js +0 -349
- package/dist/scripts/dependency-security-assessment.js +0 -331
- package/dist/scripts/deploy-sdk.sh +0 -176
- package/dist/scripts/deployment-readiness-report.json +0 -179
- package/dist/scripts/dev/README.md +0 -264
- package/dist/scripts/dev/claude-flow-wrapper.sh +0 -35
- package/dist/scripts/dev/claude-monitor.py +0 -419
- package/dist/scripts/dev/claude-sparc.sh +0 -562
- package/dist/scripts/dev/claude-wrapper.sh +0 -17
- package/dist/scripts/dev/demo-phase3-compliance.js +0 -172
- package/dist/scripts/dev/demo-task-system.ts +0 -224
- package/dist/scripts/dev/deployment-validator.js +0 -315
- package/dist/scripts/dev/spawn-claude-terminal.sh +0 -32
- package/dist/scripts/dev/start-portal.sh +0 -506
- package/dist/scripts/dev/start-web-ui.js +0 -15
- package/dist/scripts/dev/stop-portal.sh +0 -311
- package/dist/scripts/dev/validate-examples.ts +0 -288
- package/dist/scripts/dev/validate-phase2.cjs +0 -451
- package/dist/scripts/dev/validate-phase2.js +0 -785
- package/dist/scripts/dev/validate-phase3.cjs +0 -208
- package/dist/scripts/dev/validate-security-remediation.js +0 -1
- package/dist/scripts/ecosystem.config.cjs +0 -90
- package/dist/scripts/enhanced-memory-spiral-killer.sh +0 -221
- package/dist/scripts/fix-js-extensions.js +0 -167
- package/dist/scripts/generate-basic-types.js +0 -73
- package/dist/scripts/generate-changelog.js +0 -318
- package/dist/scripts/git-hooks/pre-commit.sh +0 -143
- package/dist/scripts/health-checks.js +0 -634
- package/dist/scripts/hook-wrapper.sh +0 -54
- package/dist/scripts/install/README.md +0 -375
- package/dist/scripts/install/REDIS_SETUP_VALIDATION.json +0 -245
- package/dist/scripts/install/check-prerequisites.js +0 -303
- package/dist/scripts/install/config-wizard.js +0 -606
- package/dist/scripts/install/dependency-checker.js +0 -385
- package/dist/scripts/install/health-check.js +0 -765
- package/dist/scripts/install/install.js +0 -256
- package/dist/scripts/install/installation-benchmark.js +0 -461
- package/dist/scripts/install/quick-install.js +0 -720
- package/dist/scripts/install/quick-start-wizard.js +0 -295
- package/dist/scripts/install/redis-cli.js +0 -289
- package/dist/scripts/install/redis-install-guides.md +0 -407
- package/dist/scripts/install/redis-setup.js +0 -559
- package/dist/scripts/install/redis-test.js +0 -278
- package/dist/scripts/install/service-manager.js +0 -672
- package/dist/scripts/install/setup.js +0 -832
- package/dist/scripts/install/uninstall.js +0 -526
- package/dist/scripts/install/update.js +0 -461
- package/dist/scripts/install-pre-commit-hook.sh +0 -127
- package/dist/scripts/legacy/README.md +0 -272
- package/dist/scripts/legacy/batch-fix-ts.sh +0 -54
- package/dist/scripts/legacy/build-migration.sh +0 -105
- package/dist/scripts/legacy/build-monitor.js +0 -209
- package/dist/scripts/legacy/build-with-filter.sh +0 -84
- package/dist/scripts/legacy/build-workaround.sh +0 -71
- package/dist/scripts/legacy/fix-ts-advanced.js +0 -358
- package/dist/scripts/legacy/fix-ts-final.sh +0 -50
- package/dist/scripts/legacy/fix-ts-targeted.sh +0 -49
- package/dist/scripts/legacy/fix-typescript-errors.js +0 -305
- package/dist/scripts/legacy/force-build.sh +0 -63
- package/dist/scripts/legacy/optimize-performance.js +0 -400
- package/dist/scripts/legacy/performance-monitor.js +0 -263
- package/dist/scripts/legacy/performance-monitoring.js +0 -532
- package/dist/scripts/legacy/performance-test-runner.js +0 -645
- package/dist/scripts/legacy/quick-fix-ts.js +0 -281
- package/dist/scripts/legacy/safe-build.sh +0 -63
- package/dist/scripts/memory-monitor-coordinator.js +0 -451
- package/dist/scripts/migrate-to-sdk.sh +0 -520
- package/dist/scripts/migration/QUICK-START.md +0 -189
- package/dist/scripts/migration/QUICK-START.md.backup-1760135091363 +0 -189
- package/dist/scripts/migration/README.md +0 -464
- package/dist/scripts/migration/TASK-1.3.2-COMPLETION-REPORT.md +0 -500
- package/dist/scripts/migration/TASK-1.3.2-COMPLETION-REPORT.md.backup-1760135091348 +0 -500
- package/dist/scripts/migration/UPDATE-PATHS-README.md +0 -464
- package/dist/scripts/migration/UPDATE-PATHS-README.md.backup-1760135091337 +0 -464
- package/dist/scripts/migration/example-patterns.json +0 -19
- package/dist/scripts/migration/install-arm64.js +0 -78
- package/dist/scripts/migration/install.js +0 -83
- package/dist/scripts/migration/migrate-hooks.js +0 -173
- package/dist/scripts/migration/migration-examples.ts +0 -318
- package/dist/scripts/migration/reorganize-workspace.js +0 -504
- package/dist/scripts/migration/test-update-paths.js +0 -359
- package/dist/scripts/migration/update-paths.js +0 -664
- package/dist/scripts/migration/validate-migration.js +0 -647
- package/dist/scripts/monitor-loop.sh +0 -65
- package/dist/scripts/monitor-memory.sh +0 -47
- package/dist/scripts/monitor-migration.js +0 -339
- package/dist/scripts/monitor.py +0 -43
- package/dist/scripts/monitoring/README.md +0 -178
- package/dist/scripts/monitoring/alert-monitor.sh +0 -220
- package/dist/scripts/monitoring/analyze-resources.sh +0 -199
- package/dist/scripts/monitoring/dashboards/rate-limiting-dashboard.json +0 -211
- package/dist/scripts/monitoring/dynamic-monitor.sh +0 -85
- package/dist/scripts/monitoring/launch-stability-test.sh +0 -184
- package/dist/scripts/monitoring/monitor-test.sh +0 -93
- package/dist/scripts/monitoring/pre-test-validation.sh +0 -208
- package/dist/scripts/monitoring/quick-test-alerting.sh +0 -118
- package/dist/scripts/monitoring/quick-test-rate-limiting.sh +0 -206
- package/dist/scripts/monitoring/rate-limiting-monitor.sh +0 -380
- package/dist/scripts/monitoring/resource-monitor.sh +0 -126
- package/dist/scripts/monitoring/stability-monitor.js +0 -429
- package/dist/scripts/monitoring/test-monitor-quick.sh +0 -54
- package/dist/scripts/monitoring/view-alerts.sh +0 -307
- package/dist/scripts/npm-metrics-collector.js +0 -482
- package/dist/scripts/npm-package-validation.cjs +0 -299
- package/dist/scripts/optimization/build-optimizer.js +0 -438
- package/dist/scripts/optimization/config-validator.js +0 -761
- package/dist/scripts/optimization/test-optimization.js +0 -432
- package/dist/scripts/optimization/unified-activation.js +0 -839
- package/dist/scripts/optimize-package-swarm.js +0 -54
- package/dist/scripts/performance/ACTIVATION_COMMANDS.md +0 -292
- package/dist/scripts/performance/sqlite-enhanced-activation.sh +0 -583
- package/dist/scripts/performance/test-enhanced-backend.sh +0 -504
- package/dist/scripts/performance-monitor.js +0 -644
- package/dist/scripts/performance-test-runner.js +0 -698
- package/dist/scripts/post-deployment-monitoring.js +0 -350
- package/dist/scripts/post-edit-pipeline.js +0 -2091
- package/dist/scripts/post-install-claude-md.js +0 -78
- package/dist/scripts/postinstall.js +0 -60
- package/dist/scripts/pre-publish-validation.cjs +0 -212
- package/dist/scripts/pre-publish-validation.js +0 -429
- package/dist/scripts/redis-lua/cleanup-blocking-coordination.lua +0 -198
- package/dist/scripts/release-announcement.js +0 -425
- package/dist/scripts/release-notification.js +0 -248
- package/dist/scripts/release-rollback.js +0 -376
- package/dist/scripts/release-validation.js +0 -460
- package/dist/scripts/rollback-sdk.sh +0 -66
- package/dist/scripts/run-production-validation.ts +0 -590
- package/dist/scripts/run-stability-validation.sh +0 -687
- package/dist/scripts/security/README.md +0 -339
- package/dist/scripts/security/deployment-validation.cjs +0 -279
- package/dist/scripts/security/envelope-encryption-confidence-report.cjs +0 -422
- package/dist/scripts/security/install-git-hooks.sh +0 -132
- package/dist/scripts/security/install-git-secrets.sh +0 -295
- package/dist/scripts/security/rotate-api-keys.js +0 -469
- package/dist/scripts/security/ruv-swarm-safe.js +0 -74
- package/dist/scripts/security/security-audit.cjs +0 -538
- package/dist/scripts/security/setup-redis-auth.sh +0 -397
- package/dist/scripts/security/validate-envelope-encryption.cjs +0 -340
- package/dist/scripts/security-scan.js +0 -492
- package/dist/scripts/src/web/frontend/.claude-flow/metrics/agent-metrics.json +0 -1
- package/dist/scripts/src/web/frontend/.claude-flow/metrics/performance.json +0 -9
- package/dist/scripts/src/web/frontend/.claude-flow/metrics/task-metrics.json +0 -10
- package/dist/scripts/switch-api.sh +0 -159
- package/dist/scripts/sync-agents.js +0 -290
- package/dist/scripts/test/50-agent-test.js +0 -625
- package/dist/scripts/test/NEW_STABILITY_TEST_GUIDE.md +0 -407
- package/dist/scripts/test/README.md +0 -236
- package/dist/scripts/test/STABILITY_TEST_EXAMPLE.md +0 -347
- package/dist/scripts/test/STABILITY_TEST_README.md +0 -480
- package/dist/scripts/test/agent-worker.js +0 -309
- package/dist/scripts/test/ai-coordination-test.js +0 -650
- package/dist/scripts/test/ai-mesh-coordination-test.js +0 -416
- package/dist/scripts/test/check-links.ts +0 -274
- package/dist/scripts/test/check-performance-regression.ts +0 -168
- package/dist/scripts/test/cli-agent-coordination-test.js +0 -313
- package/dist/scripts/test/coordinator-multilingual-test.js +0 -396
- package/dist/scripts/test/coordinator-transparency-demo.js +0 -585
- package/dist/scripts/test/coverage-report.ts +0 -692
- package/dist/scripts/test/generate-swarm-tests.js +0 -633
- package/dist/scripts/test/integration-test-validation.cjs +0 -253
- package/dist/scripts/test/load-test-swarm.js +0 -576
- package/dist/scripts/test/mesh-coordination-zero-overlap-test.js +0 -740
- package/dist/scripts/test/multilingual-hello-world-test.js +0 -390
- package/dist/scripts/test/quick-multilingual-demo.js +0 -464
- package/dist/scripts/test/real-agent-test.js +0 -312
- package/dist/scripts/test/run-phase3-compliance-tests.js +0 -427
- package/dist/scripts/test/run-stability-test-examples.sh +0 -292
- package/dist/scripts/test/stability-results/stability-metrics.jsonl +0 -83
- package/dist/scripts/test/stability-results/stability-test-report.json +0 -128
- package/dist/scripts/test/stability-results/stability-test.log +0 -1827
- package/dist/scripts/test/stability-test-50-agents.js +0 -734
- package/dist/scripts/test/test-batch-tasks.ts +0 -29
- package/dist/scripts/test/test-byzantine-resolution.js +0 -246
- package/dist/scripts/test/test-claude-spawn-options.sh +0 -63
- package/dist/scripts/test/test-cli-wizard.js +0 -331
- package/dist/scripts/test/test-comprehensive.js +0 -401
- package/dist/scripts/test/test-coordination-features.ts +0 -238
- package/dist/scripts/test/test-fallback-systems.js +0 -276
- package/dist/scripts/test/test-init-command.ts +0 -302
- package/dist/scripts/test/test-mcp.ts +0 -251
- package/dist/scripts/test/test-runner.ts +0 -568
- package/dist/scripts/test/test-swarm-integration.sh +0 -92
- package/dist/scripts/test/test-swarm.ts +0 -142
- package/dist/scripts/test/validation-summary.ts +0 -408
- package/dist/scripts/test-cleanup-performance.sh +0 -416
- package/dist/scripts/test-dashboard-auth.cjs +0 -203
- package/dist/scripts/test-docker-deployment.sh +0 -207
- package/dist/scripts/test-npm-package.cjs +0 -167
- package/dist/scripts/test-provider-routing.cjs +0 -226
- package/dist/scripts/test-routing-telemetry.cjs +0 -147
- package/dist/scripts/test-runner.cjs +0 -154
- package/dist/scripts/test-zai-10k.cjs +0 -81
- package/dist/scripts/test-zai-api.cjs +0 -191
- package/dist/scripts/test-zai-diagnostic.cjs +0 -151
- package/dist/scripts/test-zai-final.cjs +0 -128
- package/dist/scripts/test-zai-with-env.cjs +0 -85
- package/dist/scripts/toggle-cost-savings.cjs +0 -302
- package/dist/scripts/unified-memory-monitor.js +0 -526
- package/dist/scripts/utils/README.md +0 -261
- package/dist/scripts/utils/clean-build-artifacts.sh +0 -94
- package/dist/scripts/utils/cleanup-root.sh +0 -69
- package/dist/scripts/utils/fix-cliffy-imports.js +0 -307
- package/dist/scripts/utils/fix-duplicate-imports.js +0 -114
- package/dist/scripts/utils/fix-error-handling.cjs +0 -70
- package/dist/scripts/utils/fix-import-paths.js +0 -104
- package/dist/scripts/utils/fix-imports.js +0 -116
- package/dist/scripts/utils/fix-shebang.js +0 -78
- package/dist/scripts/utils/fix-test-modules.js +0 -27
- package/dist/scripts/utils/fix-timezone-issue-246.js +0 -200
- package/dist/scripts/utils/fix-ts-comprehensive.py +0 -182
- package/dist/scripts/utils/fix-ts-targeted-batch.js +0 -250
- package/dist/scripts/utils/remove-benchmark-conflicts.sh +0 -140
- package/dist/scripts/utils/simple-test-fixer.js +0 -190
- package/dist/scripts/utils/validate-metrics-structure.cjs +0 -144
- package/dist/scripts/validate-agent-hooks.js +0 -506
- package/dist/scripts/validate-changelog.js +0 -241
- package/dist/scripts/validate-coordination-cli.js +0 -69
- package/dist/scripts/validate-coordination-toggle-integration.cjs +0 -501
- package/dist/scripts/validate-docker-infrastructure.sh +0 -502
- package/dist/scripts/validate-entry-points.js +0 -300
- package/dist/scripts/validate-memory-monitoring.sh +0 -225
- package/dist/scripts/validate-stage3-performance.ts +0 -377
- package/dist/scripts/validate-template-bundling.js +0 -180
- package/dist/scripts/validation/README.md +0 -33
- package/dist/scripts/validation/acl-security-validation.cjs +0 -214
- package/dist/scripts/validation/acl-security-validation.js +0 -402
- package/dist/scripts/validation/byzantine-verification.js +0 -407
- package/dist/scripts/validation/final-phase-2-consensus.cjs +0 -219
- package/dist/scripts/validation/final-security-validation.js +0 -791
- package/dist/scripts/validation/final-wasm-validation.cjs +0 -840
- package/dist/scripts/validation/integration-test-analysis.js +0 -105
- package/dist/scripts/validation/phase-0-comprehensive-validation.js +0 -474
- package/dist/scripts/validation/phase-0-consensus-report.js +0 -139
- package/dist/scripts/validation/phase-0-final-report.js +0 -112
- package/dist/scripts/validation/phase-0-redis-consensus-report.js +0 -129
- package/dist/scripts/validation/phase-0-validation-improved.js +0 -490
- package/dist/scripts/validation/phase-0-validation-test.js +0 -65
- package/dist/scripts/validation/phase-1-consensus-report.cjs +0 -342
- package/dist/scripts/validation/phase-1-consensus-validation.cjs +0 -551
- package/dist/scripts/validation/phase-1-consensus-validation.js +0 -551
- package/dist/scripts/validation/phase-2-consensus-report.cjs +0 -186
- package/dist/scripts/validation/phase-2-validation.cjs +0 -171
- package/dist/scripts/validation/phase-2-validation.js +0 -171
- package/dist/scripts/validation/phase-4-consensus-report.js +0 -181
- package/dist/scripts/validation/phase-4-final-validation.js +0 -351
- package/dist/scripts/validation/phase-5-consensus-report.cjs +0 -113
- package/dist/scripts/validation/phase-5-consensus-report.js +0 -113
- package/dist/scripts/validation/security-analysis.js +0 -49
- package/dist/scripts/validation/security-validation.js +0 -492
- package/dist/scripts/validation/simple-security-validation.js +0 -464
- package/dist/scripts/verify-installation.js +0 -112
- package/dist/scripts/verify-mcp-server.js +0 -86
- package/dist/scripts/verify-sdk-phase1.cjs +0 -293
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/accessibility/browser/accessibilityService.js +0 -88
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/accessibility/common/accessibility.js +0 -9
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/action/common/action.js +0 -7
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/action/common/actionCommonCategories.js +0 -13
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actionWidget/browser/actionList.js +0 -276
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actionWidget/browser/actionWidget.js +0 -248
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actionWidget/common/actionWidget.js +0 -5
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actions/common/actions.js +0 -409
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/audioCues/browser/audioCueService.js +0 -176
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/clipboard/browser/clipboardService.js +0 -141
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/clipboard/common/clipboardService.js +0 -6
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/commands/common/commands.js +0 -80
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configuration.js +0 -86
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configurationModels.js +0 -554
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configurationRegistry.js +0 -317
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configurations.js +0 -41
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextkey/browser/contextKeyService.js +0 -432
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextkey/common/contextkey.js +0 -1547
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextkey/common/contextkeys.js +0 -18
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextMenuHandler.js +0 -124
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextMenuService.js +0 -101
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextView.js +0 -7
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextViewService.js +0 -72
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/dialogs/common/dialogs.js +0 -2
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/dnd/browser/dnd.js +0 -36
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/editor/common/editor.js +0 -17
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/environment/common/environment.js +0 -2
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/extensions/common/extensions.js +0 -47
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/files/common/files.js +0 -9
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/history/browser/contextScopedHistoryWidget.js +0 -105
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/instantiation/common/descriptors.js +0 -11
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/instantiation/common/extensions.js +0 -15
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/keybinding/common/abstractKeybindingService.js +0 -277
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/keybinding/common/baseResolvedKeybinding.js +0 -53
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/quickinput/browser/commandsQuickAccess.js +0 -354
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/theme/browser/defaultStyles.js +0 -162
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/theme/common/colorRegistry.js +0 -482
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/abap/abap.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/apex/apex.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/azcli/azcli.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/bat/bat.js +0 -10
- package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/bicep/bicep.js +0 -11
|
@@ -1,1547 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { isChrome, isEdge, isFirefox, isLinux, isMacintosh, isSafari, isWeb, isWindows } from '../../../base/common/platform.js';
|
|
6
|
-
import { isFalsyOrWhitespace } from '../../../base/common/strings.js';
|
|
7
|
-
import { Scanner } from './scanner.js';
|
|
8
|
-
import { createDecorator } from '../../instantiation/common/instantiation.js';
|
|
9
|
-
import { localize } from '../../../nls.js';
|
|
10
|
-
const CONSTANT_VALUES = new Map();
|
|
11
|
-
CONSTANT_VALUES.set('false', false);
|
|
12
|
-
CONSTANT_VALUES.set('true', true);
|
|
13
|
-
CONSTANT_VALUES.set('isMac', isMacintosh);
|
|
14
|
-
CONSTANT_VALUES.set('isLinux', isLinux);
|
|
15
|
-
CONSTANT_VALUES.set('isWindows', isWindows);
|
|
16
|
-
CONSTANT_VALUES.set('isWeb', isWeb);
|
|
17
|
-
CONSTANT_VALUES.set('isMacNative', isMacintosh && !isWeb);
|
|
18
|
-
CONSTANT_VALUES.set('isEdge', isEdge);
|
|
19
|
-
CONSTANT_VALUES.set('isFirefox', isFirefox);
|
|
20
|
-
CONSTANT_VALUES.set('isChrome', isChrome);
|
|
21
|
-
CONSTANT_VALUES.set('isSafari', isSafari);
|
|
22
|
-
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
23
|
-
const defaultConfig = {
|
|
24
|
-
regexParsingWithErrorRecovery: true
|
|
25
|
-
};
|
|
26
|
-
const errorEmptyString = localize('contextkey.parser.error.emptyString', "Empty context key expression");
|
|
27
|
-
const hintEmptyString = localize('contextkey.parser.error.emptyString.hint', "Did you forget to write an expression? You can also put 'false' or 'true' to always evaluate to false or true, respectively.");
|
|
28
|
-
const errorNoInAfterNot = localize('contextkey.parser.error.noInAfterNot', "'in' after 'not'.");
|
|
29
|
-
const errorClosingParenthesis = localize('contextkey.parser.error.closingParenthesis', "closing parenthesis ')'");
|
|
30
|
-
const errorUnexpectedToken = localize('contextkey.parser.error.unexpectedToken', "Unexpected token");
|
|
31
|
-
const hintUnexpectedToken = localize('contextkey.parser.error.unexpectedToken.hint', "Did you forget to put && or || before the token?");
|
|
32
|
-
const errorUnexpectedEOF = localize('contextkey.parser.error.unexpectedEOF', "Unexpected end of expression");
|
|
33
|
-
const hintUnexpectedEOF = localize('contextkey.parser.error.unexpectedEOF.hint', "Did you forget to put a context key?");
|
|
34
|
-
/**
|
|
35
|
-
* A parser for context key expressions.
|
|
36
|
-
*
|
|
37
|
-
* Example:
|
|
38
|
-
* ```ts
|
|
39
|
-
* const parser = new Parser();
|
|
40
|
-
* const expr = parser.parse('foo == "bar" && baz == true');
|
|
41
|
-
*
|
|
42
|
-
* if (expr === undefined) {
|
|
43
|
-
* // there were lexing or parsing errors
|
|
44
|
-
* // process lexing errors with `parser.lexingErrors`
|
|
45
|
-
* // process parsing errors with `parser.parsingErrors`
|
|
46
|
-
* } else {
|
|
47
|
-
* // expr is a valid expression
|
|
48
|
-
* }
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
export class Parser {
|
|
52
|
-
constructor(_config = defaultConfig) {
|
|
53
|
-
this._config = _config;
|
|
54
|
-
// lifetime note: `_scanner` lives as long as the parser does, i.e., is not reset between calls to `parse`
|
|
55
|
-
this._scanner = new Scanner();
|
|
56
|
-
// lifetime note: `_tokens`, `_current`, and `_parsingErrors` must be reset between calls to `parse`
|
|
57
|
-
this._tokens = [];
|
|
58
|
-
this._current = 0; // invariant: 0 <= this._current < this._tokens.length ; any incrementation of this value must first call `_isAtEnd`
|
|
59
|
-
this._parsingErrors = [];
|
|
60
|
-
this._flagsGYRe = /g|y/g;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Parse a context key expression.
|
|
64
|
-
*
|
|
65
|
-
* @param input the expression to parse
|
|
66
|
-
* @returns the parsed expression or `undefined` if there's an error - call `lexingErrors` and `parsingErrors` to see the errors
|
|
67
|
-
*/
|
|
68
|
-
parse(input) {
|
|
69
|
-
if (input === '') {
|
|
70
|
-
this._parsingErrors.push({ message: errorEmptyString, offset: 0, lexeme: '', additionalInfo: hintEmptyString });
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
this._tokens = this._scanner.reset(input).scan();
|
|
74
|
-
// @ulugbekna: we do not stop parsing if there are lexing errors to be able to reconstruct regexes with unescaped slashes; TODO@ulugbekna: make this respect config option for recovery
|
|
75
|
-
this._current = 0;
|
|
76
|
-
this._parsingErrors = [];
|
|
77
|
-
try {
|
|
78
|
-
const expr = this._expr();
|
|
79
|
-
if (!this._isAtEnd()) {
|
|
80
|
-
const peek = this._peek();
|
|
81
|
-
const additionalInfo = peek.type === 17 /* TokenType.Str */ ? hintUnexpectedToken : undefined;
|
|
82
|
-
this._parsingErrors.push({ message: errorUnexpectedToken, offset: peek.offset, lexeme: Scanner.getLexeme(peek), additionalInfo });
|
|
83
|
-
throw Parser._parseError;
|
|
84
|
-
}
|
|
85
|
-
return expr;
|
|
86
|
-
}
|
|
87
|
-
catch (e) {
|
|
88
|
-
if (!(e === Parser._parseError)) {
|
|
89
|
-
throw e;
|
|
90
|
-
}
|
|
91
|
-
return undefined;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
_expr() {
|
|
95
|
-
return this._or();
|
|
96
|
-
}
|
|
97
|
-
_or() {
|
|
98
|
-
const expr = [this._and()];
|
|
99
|
-
while (this._matchOne(16 /* TokenType.Or */)) {
|
|
100
|
-
const right = this._and();
|
|
101
|
-
expr.push(right);
|
|
102
|
-
}
|
|
103
|
-
return expr.length === 1 ? expr[0] : ContextKeyExpr.or(...expr);
|
|
104
|
-
}
|
|
105
|
-
_and() {
|
|
106
|
-
const expr = [this._term()];
|
|
107
|
-
while (this._matchOne(15 /* TokenType.And */)) {
|
|
108
|
-
const right = this._term();
|
|
109
|
-
expr.push(right);
|
|
110
|
-
}
|
|
111
|
-
return expr.length === 1 ? expr[0] : ContextKeyExpr.and(...expr);
|
|
112
|
-
}
|
|
113
|
-
_term() {
|
|
114
|
-
if (this._matchOne(2 /* TokenType.Neg */)) {
|
|
115
|
-
const peek = this._peek();
|
|
116
|
-
switch (peek.type) {
|
|
117
|
-
case 11 /* TokenType.True */:
|
|
118
|
-
this._advance();
|
|
119
|
-
return ContextKeyFalseExpr.INSTANCE;
|
|
120
|
-
case 12 /* TokenType.False */:
|
|
121
|
-
this._advance();
|
|
122
|
-
return ContextKeyTrueExpr.INSTANCE;
|
|
123
|
-
case 0 /* TokenType.LParen */: {
|
|
124
|
-
this._advance();
|
|
125
|
-
const expr = this._expr();
|
|
126
|
-
this._consume(1 /* TokenType.RParen */, errorClosingParenthesis);
|
|
127
|
-
return expr === null || expr === void 0 ? void 0 : expr.negate();
|
|
128
|
-
}
|
|
129
|
-
case 17 /* TokenType.Str */:
|
|
130
|
-
this._advance();
|
|
131
|
-
return ContextKeyNotExpr.create(peek.lexeme);
|
|
132
|
-
default:
|
|
133
|
-
throw this._errExpectedButGot(`KEY | true | false | '(' expression ')'`, peek);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return this._primary();
|
|
137
|
-
}
|
|
138
|
-
_primary() {
|
|
139
|
-
const peek = this._peek();
|
|
140
|
-
switch (peek.type) {
|
|
141
|
-
case 11 /* TokenType.True */:
|
|
142
|
-
this._advance();
|
|
143
|
-
return ContextKeyExpr.true();
|
|
144
|
-
case 12 /* TokenType.False */:
|
|
145
|
-
this._advance();
|
|
146
|
-
return ContextKeyExpr.false();
|
|
147
|
-
case 0 /* TokenType.LParen */: {
|
|
148
|
-
this._advance();
|
|
149
|
-
const expr = this._expr();
|
|
150
|
-
this._consume(1 /* TokenType.RParen */, errorClosingParenthesis);
|
|
151
|
-
return expr;
|
|
152
|
-
}
|
|
153
|
-
case 17 /* TokenType.Str */: {
|
|
154
|
-
// KEY
|
|
155
|
-
const key = peek.lexeme;
|
|
156
|
-
this._advance();
|
|
157
|
-
// =~ regex
|
|
158
|
-
if (this._matchOne(9 /* TokenType.RegexOp */)) {
|
|
159
|
-
// @ulugbekna: we need to reconstruct the regex from the tokens because some extensions use unescaped slashes in regexes
|
|
160
|
-
const expr = this._peek();
|
|
161
|
-
if (!this._config.regexParsingWithErrorRecovery) {
|
|
162
|
-
this._advance();
|
|
163
|
-
if (expr.type !== 10 /* TokenType.RegexStr */) {
|
|
164
|
-
throw this._errExpectedButGot(`REGEX`, expr);
|
|
165
|
-
}
|
|
166
|
-
const regexLexeme = expr.lexeme;
|
|
167
|
-
const closingSlashIndex = regexLexeme.lastIndexOf('/');
|
|
168
|
-
const flags = closingSlashIndex === regexLexeme.length - 1 ? undefined : this._removeFlagsGY(regexLexeme.substring(closingSlashIndex + 1));
|
|
169
|
-
let regexp;
|
|
170
|
-
try {
|
|
171
|
-
regexp = new RegExp(regexLexeme.substring(1, closingSlashIndex), flags);
|
|
172
|
-
}
|
|
173
|
-
catch (e) {
|
|
174
|
-
throw this._errExpectedButGot(`REGEX`, expr);
|
|
175
|
-
}
|
|
176
|
-
return ContextKeyRegexExpr.create(key, regexp);
|
|
177
|
-
}
|
|
178
|
-
switch (expr.type) {
|
|
179
|
-
case 10 /* TokenType.RegexStr */:
|
|
180
|
-
case 19 /* TokenType.Error */: { // also handle an ErrorToken in case of smth such as /(/file)/
|
|
181
|
-
const lexemeReconstruction = [expr.lexeme]; // /REGEX/ or /REGEX/FLAGS
|
|
182
|
-
this._advance();
|
|
183
|
-
let followingToken = this._peek();
|
|
184
|
-
let parenBalance = 0;
|
|
185
|
-
for (let i = 0; i < expr.lexeme.length; i++) {
|
|
186
|
-
if (expr.lexeme.charCodeAt(i) === 40 /* CharCode.OpenParen */) {
|
|
187
|
-
parenBalance++;
|
|
188
|
-
}
|
|
189
|
-
else if (expr.lexeme.charCodeAt(i) === 41 /* CharCode.CloseParen */) {
|
|
190
|
-
parenBalance--;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
while (!this._isAtEnd() && followingToken.type !== 15 /* TokenType.And */ && followingToken.type !== 16 /* TokenType.Or */) {
|
|
194
|
-
switch (followingToken.type) {
|
|
195
|
-
case 0 /* TokenType.LParen */:
|
|
196
|
-
parenBalance++;
|
|
197
|
-
break;
|
|
198
|
-
case 1 /* TokenType.RParen */:
|
|
199
|
-
parenBalance--;
|
|
200
|
-
break;
|
|
201
|
-
case 10 /* TokenType.RegexStr */:
|
|
202
|
-
case 18 /* TokenType.QuotedStr */:
|
|
203
|
-
for (let i = 0; i < followingToken.lexeme.length; i++) {
|
|
204
|
-
if (followingToken.lexeme.charCodeAt(i) === 40 /* CharCode.OpenParen */) {
|
|
205
|
-
parenBalance++;
|
|
206
|
-
}
|
|
207
|
-
else if (expr.lexeme.charCodeAt(i) === 41 /* CharCode.CloseParen */) {
|
|
208
|
-
parenBalance--;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
if (parenBalance < 0) {
|
|
213
|
-
break;
|
|
214
|
-
}
|
|
215
|
-
lexemeReconstruction.push(Scanner.getLexeme(followingToken));
|
|
216
|
-
this._advance();
|
|
217
|
-
followingToken = this._peek();
|
|
218
|
-
}
|
|
219
|
-
const regexLexeme = lexemeReconstruction.join('');
|
|
220
|
-
const closingSlashIndex = regexLexeme.lastIndexOf('/');
|
|
221
|
-
const flags = closingSlashIndex === regexLexeme.length - 1 ? undefined : this._removeFlagsGY(regexLexeme.substring(closingSlashIndex + 1));
|
|
222
|
-
let regexp;
|
|
223
|
-
try {
|
|
224
|
-
regexp = new RegExp(regexLexeme.substring(1, closingSlashIndex), flags);
|
|
225
|
-
}
|
|
226
|
-
catch (e) {
|
|
227
|
-
throw this._errExpectedButGot(`REGEX`, expr);
|
|
228
|
-
}
|
|
229
|
-
return ContextKeyExpr.regex(key, regexp);
|
|
230
|
-
}
|
|
231
|
-
case 18 /* TokenType.QuotedStr */: {
|
|
232
|
-
const serializedValue = expr.lexeme;
|
|
233
|
-
this._advance();
|
|
234
|
-
// replicate old regex parsing behavior
|
|
235
|
-
let regex = null;
|
|
236
|
-
if (!isFalsyOrWhitespace(serializedValue)) {
|
|
237
|
-
const start = serializedValue.indexOf('/');
|
|
238
|
-
const end = serializedValue.lastIndexOf('/');
|
|
239
|
-
if (start !== end && start >= 0) {
|
|
240
|
-
const value = serializedValue.slice(start + 1, end);
|
|
241
|
-
const caseIgnoreFlag = serializedValue[end + 1] === 'i' ? 'i' : '';
|
|
242
|
-
try {
|
|
243
|
-
regex = new RegExp(value, caseIgnoreFlag);
|
|
244
|
-
}
|
|
245
|
-
catch (_e) {
|
|
246
|
-
throw this._errExpectedButGot(`REGEX`, expr);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
if (regex === null) {
|
|
251
|
-
throw this._errExpectedButGot('REGEX', expr);
|
|
252
|
-
}
|
|
253
|
-
return ContextKeyRegexExpr.create(key, regex);
|
|
254
|
-
}
|
|
255
|
-
default:
|
|
256
|
-
throw this._errExpectedButGot('REGEX', this._peek());
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
// [ 'not' 'in' value ]
|
|
260
|
-
if (this._matchOne(14 /* TokenType.Not */)) {
|
|
261
|
-
this._consume(13 /* TokenType.In */, errorNoInAfterNot);
|
|
262
|
-
const right = this._value();
|
|
263
|
-
return ContextKeyExpr.notIn(key, right);
|
|
264
|
-
}
|
|
265
|
-
// [ ('==' | '!=' | '<' | '<=' | '>' | '>=' | 'in') value ]
|
|
266
|
-
const maybeOp = this._peek().type;
|
|
267
|
-
switch (maybeOp) {
|
|
268
|
-
case 3 /* TokenType.Eq */: {
|
|
269
|
-
this._advance();
|
|
270
|
-
const right = this._value();
|
|
271
|
-
if (this._previous().type === 18 /* TokenType.QuotedStr */) { // to preserve old parser behavior: "foo == 'true'" is preserved as "foo == 'true'", but "foo == true" is optimized as "foo"
|
|
272
|
-
return ContextKeyExpr.equals(key, right);
|
|
273
|
-
}
|
|
274
|
-
switch (right) {
|
|
275
|
-
case 'true':
|
|
276
|
-
return ContextKeyExpr.has(key);
|
|
277
|
-
case 'false':
|
|
278
|
-
return ContextKeyExpr.not(key);
|
|
279
|
-
default:
|
|
280
|
-
return ContextKeyExpr.equals(key, right);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
case 4 /* TokenType.NotEq */: {
|
|
284
|
-
this._advance();
|
|
285
|
-
const right = this._value();
|
|
286
|
-
if (this._previous().type === 18 /* TokenType.QuotedStr */) { // same as above with "foo != 'true'"
|
|
287
|
-
return ContextKeyExpr.notEquals(key, right);
|
|
288
|
-
}
|
|
289
|
-
switch (right) {
|
|
290
|
-
case 'true':
|
|
291
|
-
return ContextKeyExpr.not(key);
|
|
292
|
-
case 'false':
|
|
293
|
-
return ContextKeyExpr.has(key);
|
|
294
|
-
default:
|
|
295
|
-
return ContextKeyExpr.notEquals(key, right);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
// TODO: ContextKeyExpr.smaller(key, right) accepts only `number` as `right` AND during eval of this node, we just eval to `false` if `right` is not a number
|
|
299
|
-
// consequently, package.json linter should _warn_ the user if they're passing undesired things to ops
|
|
300
|
-
case 5 /* TokenType.Lt */:
|
|
301
|
-
this._advance();
|
|
302
|
-
return ContextKeySmallerExpr.create(key, this._value());
|
|
303
|
-
case 6 /* TokenType.LtEq */:
|
|
304
|
-
this._advance();
|
|
305
|
-
return ContextKeySmallerEqualsExpr.create(key, this._value());
|
|
306
|
-
case 7 /* TokenType.Gt */:
|
|
307
|
-
this._advance();
|
|
308
|
-
return ContextKeyGreaterExpr.create(key, this._value());
|
|
309
|
-
case 8 /* TokenType.GtEq */:
|
|
310
|
-
this._advance();
|
|
311
|
-
return ContextKeyGreaterEqualsExpr.create(key, this._value());
|
|
312
|
-
case 13 /* TokenType.In */:
|
|
313
|
-
this._advance();
|
|
314
|
-
return ContextKeyExpr.in(key, this._value());
|
|
315
|
-
default:
|
|
316
|
-
return ContextKeyExpr.has(key);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
case 20 /* TokenType.EOF */:
|
|
320
|
-
this._parsingErrors.push({ message: errorUnexpectedEOF, offset: peek.offset, lexeme: '', additionalInfo: hintUnexpectedEOF });
|
|
321
|
-
throw Parser._parseError;
|
|
322
|
-
default:
|
|
323
|
-
throw this._errExpectedButGot(`true | false | KEY \n\t| KEY '=~' REGEX \n\t| KEY ('==' | '!=' | '<' | '<=' | '>' | '>=' | 'in' | 'not' 'in') value`, this._peek());
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
_value() {
|
|
327
|
-
const token = this._peek();
|
|
328
|
-
switch (token.type) {
|
|
329
|
-
case 17 /* TokenType.Str */:
|
|
330
|
-
case 18 /* TokenType.QuotedStr */:
|
|
331
|
-
this._advance();
|
|
332
|
-
return token.lexeme;
|
|
333
|
-
case 11 /* TokenType.True */:
|
|
334
|
-
this._advance();
|
|
335
|
-
return 'true';
|
|
336
|
-
case 12 /* TokenType.False */:
|
|
337
|
-
this._advance();
|
|
338
|
-
return 'false';
|
|
339
|
-
case 13 /* TokenType.In */: // we support `in` as a value, e.g., "when": "languageId == in" - exists in existing extensions
|
|
340
|
-
this._advance();
|
|
341
|
-
return 'in';
|
|
342
|
-
default:
|
|
343
|
-
// this allows "when": "foo == " which's used by existing extensions
|
|
344
|
-
// we do not call `_advance` on purpose - we don't want to eat unintended tokens
|
|
345
|
-
return '';
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
_removeFlagsGY(flags) {
|
|
349
|
-
return flags.replaceAll(this._flagsGYRe, '');
|
|
350
|
-
}
|
|
351
|
-
// careful: this can throw if current token is the initial one (ie index = 0)
|
|
352
|
-
_previous() {
|
|
353
|
-
return this._tokens[this._current - 1];
|
|
354
|
-
}
|
|
355
|
-
_matchOne(token) {
|
|
356
|
-
if (this._check(token)) {
|
|
357
|
-
this._advance();
|
|
358
|
-
return true;
|
|
359
|
-
}
|
|
360
|
-
return false;
|
|
361
|
-
}
|
|
362
|
-
_advance() {
|
|
363
|
-
if (!this._isAtEnd()) {
|
|
364
|
-
this._current++;
|
|
365
|
-
}
|
|
366
|
-
return this._previous();
|
|
367
|
-
}
|
|
368
|
-
_consume(type, message) {
|
|
369
|
-
if (this._check(type)) {
|
|
370
|
-
return this._advance();
|
|
371
|
-
}
|
|
372
|
-
throw this._errExpectedButGot(message, this._peek());
|
|
373
|
-
}
|
|
374
|
-
_errExpectedButGot(expected, got, additionalInfo) {
|
|
375
|
-
const message = localize('contextkey.parser.error.expectedButGot', "Expected: {0}\nReceived: '{1}'.", expected, Scanner.getLexeme(got));
|
|
376
|
-
const offset = got.offset;
|
|
377
|
-
const lexeme = Scanner.getLexeme(got);
|
|
378
|
-
this._parsingErrors.push({ message, offset, lexeme, additionalInfo });
|
|
379
|
-
return Parser._parseError;
|
|
380
|
-
}
|
|
381
|
-
_check(type) {
|
|
382
|
-
return this._peek().type === type;
|
|
383
|
-
}
|
|
384
|
-
_peek() {
|
|
385
|
-
return this._tokens[this._current];
|
|
386
|
-
}
|
|
387
|
-
_isAtEnd() {
|
|
388
|
-
return this._peek().type === 20 /* TokenType.EOF */;
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
// Note: this doesn't produce an exact syntax tree but a normalized one
|
|
392
|
-
// ContextKeyExpression's that we use as AST nodes do not expose constructors that do not normalize
|
|
393
|
-
Parser._parseError = new Error();
|
|
394
|
-
export class ContextKeyExpr {
|
|
395
|
-
static false() {
|
|
396
|
-
return ContextKeyFalseExpr.INSTANCE;
|
|
397
|
-
}
|
|
398
|
-
static true() {
|
|
399
|
-
return ContextKeyTrueExpr.INSTANCE;
|
|
400
|
-
}
|
|
401
|
-
static has(key) {
|
|
402
|
-
return ContextKeyDefinedExpr.create(key);
|
|
403
|
-
}
|
|
404
|
-
static equals(key, value) {
|
|
405
|
-
return ContextKeyEqualsExpr.create(key, value);
|
|
406
|
-
}
|
|
407
|
-
static notEquals(key, value) {
|
|
408
|
-
return ContextKeyNotEqualsExpr.create(key, value);
|
|
409
|
-
}
|
|
410
|
-
static regex(key, value) {
|
|
411
|
-
return ContextKeyRegexExpr.create(key, value);
|
|
412
|
-
}
|
|
413
|
-
static in(key, value) {
|
|
414
|
-
return ContextKeyInExpr.create(key, value);
|
|
415
|
-
}
|
|
416
|
-
static notIn(key, value) {
|
|
417
|
-
return ContextKeyNotInExpr.create(key, value);
|
|
418
|
-
}
|
|
419
|
-
static not(key) {
|
|
420
|
-
return ContextKeyNotExpr.create(key);
|
|
421
|
-
}
|
|
422
|
-
static and(...expr) {
|
|
423
|
-
return ContextKeyAndExpr.create(expr, null, true);
|
|
424
|
-
}
|
|
425
|
-
static or(...expr) {
|
|
426
|
-
return ContextKeyOrExpr.create(expr, null, true);
|
|
427
|
-
}
|
|
428
|
-
static deserialize(serialized) {
|
|
429
|
-
if (serialized === undefined || serialized === null) { // an empty string needs to be handled by the parser to get a corresponding parsing error reported
|
|
430
|
-
return undefined;
|
|
431
|
-
}
|
|
432
|
-
const expr = this._parser.parse(serialized);
|
|
433
|
-
return expr;
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
ContextKeyExpr._parser = new Parser({ regexParsingWithErrorRecovery: false });
|
|
437
|
-
export function expressionsAreEqualWithConstantSubstitution(a, b) {
|
|
438
|
-
const aExpr = a ? a.substituteConstants() : undefined;
|
|
439
|
-
const bExpr = b ? b.substituteConstants() : undefined;
|
|
440
|
-
if (!aExpr && !bExpr) {
|
|
441
|
-
return true;
|
|
442
|
-
}
|
|
443
|
-
if (!aExpr || !bExpr) {
|
|
444
|
-
return false;
|
|
445
|
-
}
|
|
446
|
-
return aExpr.equals(bExpr);
|
|
447
|
-
}
|
|
448
|
-
function cmp(a, b) {
|
|
449
|
-
return a.cmp(b);
|
|
450
|
-
}
|
|
451
|
-
export class ContextKeyFalseExpr {
|
|
452
|
-
constructor() {
|
|
453
|
-
this.type = 0 /* ContextKeyExprType.False */;
|
|
454
|
-
}
|
|
455
|
-
cmp(other) {
|
|
456
|
-
return this.type - other.type;
|
|
457
|
-
}
|
|
458
|
-
equals(other) {
|
|
459
|
-
return (other.type === this.type);
|
|
460
|
-
}
|
|
461
|
-
substituteConstants() {
|
|
462
|
-
return this;
|
|
463
|
-
}
|
|
464
|
-
evaluate(context) {
|
|
465
|
-
return false;
|
|
466
|
-
}
|
|
467
|
-
serialize() {
|
|
468
|
-
return 'false';
|
|
469
|
-
}
|
|
470
|
-
keys() {
|
|
471
|
-
return [];
|
|
472
|
-
}
|
|
473
|
-
negate() {
|
|
474
|
-
return ContextKeyTrueExpr.INSTANCE;
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
ContextKeyFalseExpr.INSTANCE = new ContextKeyFalseExpr();
|
|
478
|
-
export class ContextKeyTrueExpr {
|
|
479
|
-
constructor() {
|
|
480
|
-
this.type = 1 /* ContextKeyExprType.True */;
|
|
481
|
-
}
|
|
482
|
-
cmp(other) {
|
|
483
|
-
return this.type - other.type;
|
|
484
|
-
}
|
|
485
|
-
equals(other) {
|
|
486
|
-
return (other.type === this.type);
|
|
487
|
-
}
|
|
488
|
-
substituteConstants() {
|
|
489
|
-
return this;
|
|
490
|
-
}
|
|
491
|
-
evaluate(context) {
|
|
492
|
-
return true;
|
|
493
|
-
}
|
|
494
|
-
serialize() {
|
|
495
|
-
return 'true';
|
|
496
|
-
}
|
|
497
|
-
keys() {
|
|
498
|
-
return [];
|
|
499
|
-
}
|
|
500
|
-
negate() {
|
|
501
|
-
return ContextKeyFalseExpr.INSTANCE;
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
ContextKeyTrueExpr.INSTANCE = new ContextKeyTrueExpr();
|
|
505
|
-
export class ContextKeyDefinedExpr {
|
|
506
|
-
static create(key, negated = null) {
|
|
507
|
-
const constantValue = CONSTANT_VALUES.get(key);
|
|
508
|
-
if (typeof constantValue === 'boolean') {
|
|
509
|
-
return constantValue ? ContextKeyTrueExpr.INSTANCE : ContextKeyFalseExpr.INSTANCE;
|
|
510
|
-
}
|
|
511
|
-
return new ContextKeyDefinedExpr(key, negated);
|
|
512
|
-
}
|
|
513
|
-
constructor(key, negated) {
|
|
514
|
-
this.key = key;
|
|
515
|
-
this.negated = negated;
|
|
516
|
-
this.type = 2 /* ContextKeyExprType.Defined */;
|
|
517
|
-
}
|
|
518
|
-
cmp(other) {
|
|
519
|
-
if (other.type !== this.type) {
|
|
520
|
-
return this.type - other.type;
|
|
521
|
-
}
|
|
522
|
-
return cmp1(this.key, other.key);
|
|
523
|
-
}
|
|
524
|
-
equals(other) {
|
|
525
|
-
if (other.type === this.type) {
|
|
526
|
-
return (this.key === other.key);
|
|
527
|
-
}
|
|
528
|
-
return false;
|
|
529
|
-
}
|
|
530
|
-
substituteConstants() {
|
|
531
|
-
const constantValue = CONSTANT_VALUES.get(this.key);
|
|
532
|
-
if (typeof constantValue === 'boolean') {
|
|
533
|
-
return constantValue ? ContextKeyTrueExpr.INSTANCE : ContextKeyFalseExpr.INSTANCE;
|
|
534
|
-
}
|
|
535
|
-
return this;
|
|
536
|
-
}
|
|
537
|
-
evaluate(context) {
|
|
538
|
-
return (!!context.getValue(this.key));
|
|
539
|
-
}
|
|
540
|
-
serialize() {
|
|
541
|
-
return this.key;
|
|
542
|
-
}
|
|
543
|
-
keys() {
|
|
544
|
-
return [this.key];
|
|
545
|
-
}
|
|
546
|
-
negate() {
|
|
547
|
-
if (!this.negated) {
|
|
548
|
-
this.negated = ContextKeyNotExpr.create(this.key, this);
|
|
549
|
-
}
|
|
550
|
-
return this.negated;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
export class ContextKeyEqualsExpr {
|
|
554
|
-
static create(key, value, negated = null) {
|
|
555
|
-
if (typeof value === 'boolean') {
|
|
556
|
-
return (value ? ContextKeyDefinedExpr.create(key, negated) : ContextKeyNotExpr.create(key, negated));
|
|
557
|
-
}
|
|
558
|
-
const constantValue = CONSTANT_VALUES.get(key);
|
|
559
|
-
if (typeof constantValue === 'boolean') {
|
|
560
|
-
const trueValue = constantValue ? 'true' : 'false';
|
|
561
|
-
return (value === trueValue ? ContextKeyTrueExpr.INSTANCE : ContextKeyFalseExpr.INSTANCE);
|
|
562
|
-
}
|
|
563
|
-
return new ContextKeyEqualsExpr(key, value, negated);
|
|
564
|
-
}
|
|
565
|
-
constructor(key, value, negated) {
|
|
566
|
-
this.key = key;
|
|
567
|
-
this.value = value;
|
|
568
|
-
this.negated = negated;
|
|
569
|
-
this.type = 4 /* ContextKeyExprType.Equals */;
|
|
570
|
-
}
|
|
571
|
-
cmp(other) {
|
|
572
|
-
if (other.type !== this.type) {
|
|
573
|
-
return this.type - other.type;
|
|
574
|
-
}
|
|
575
|
-
return cmp2(this.key, this.value, other.key, other.value);
|
|
576
|
-
}
|
|
577
|
-
equals(other) {
|
|
578
|
-
if (other.type === this.type) {
|
|
579
|
-
return (this.key === other.key && this.value === other.value);
|
|
580
|
-
}
|
|
581
|
-
return false;
|
|
582
|
-
}
|
|
583
|
-
substituteConstants() {
|
|
584
|
-
const constantValue = CONSTANT_VALUES.get(this.key);
|
|
585
|
-
if (typeof constantValue === 'boolean') {
|
|
586
|
-
const trueValue = constantValue ? 'true' : 'false';
|
|
587
|
-
return (this.value === trueValue ? ContextKeyTrueExpr.INSTANCE : ContextKeyFalseExpr.INSTANCE);
|
|
588
|
-
}
|
|
589
|
-
return this;
|
|
590
|
-
}
|
|
591
|
-
evaluate(context) {
|
|
592
|
-
// Intentional ==
|
|
593
|
-
// eslint-disable-next-line eqeqeq
|
|
594
|
-
return (context.getValue(this.key) == this.value);
|
|
595
|
-
}
|
|
596
|
-
serialize() {
|
|
597
|
-
return `${this.key} == '${this.value}'`;
|
|
598
|
-
}
|
|
599
|
-
keys() {
|
|
600
|
-
return [this.key];
|
|
601
|
-
}
|
|
602
|
-
negate() {
|
|
603
|
-
if (!this.negated) {
|
|
604
|
-
this.negated = ContextKeyNotEqualsExpr.create(this.key, this.value, this);
|
|
605
|
-
}
|
|
606
|
-
return this.negated;
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
export class ContextKeyInExpr {
|
|
610
|
-
static create(key, valueKey) {
|
|
611
|
-
return new ContextKeyInExpr(key, valueKey);
|
|
612
|
-
}
|
|
613
|
-
constructor(key, valueKey) {
|
|
614
|
-
this.key = key;
|
|
615
|
-
this.valueKey = valueKey;
|
|
616
|
-
this.type = 10 /* ContextKeyExprType.In */;
|
|
617
|
-
this.negated = null;
|
|
618
|
-
}
|
|
619
|
-
cmp(other) {
|
|
620
|
-
if (other.type !== this.type) {
|
|
621
|
-
return this.type - other.type;
|
|
622
|
-
}
|
|
623
|
-
return cmp2(this.key, this.valueKey, other.key, other.valueKey);
|
|
624
|
-
}
|
|
625
|
-
equals(other) {
|
|
626
|
-
if (other.type === this.type) {
|
|
627
|
-
return (this.key === other.key && this.valueKey === other.valueKey);
|
|
628
|
-
}
|
|
629
|
-
return false;
|
|
630
|
-
}
|
|
631
|
-
substituteConstants() {
|
|
632
|
-
return this;
|
|
633
|
-
}
|
|
634
|
-
evaluate(context) {
|
|
635
|
-
const source = context.getValue(this.valueKey);
|
|
636
|
-
const item = context.getValue(this.key);
|
|
637
|
-
if (Array.isArray(source)) {
|
|
638
|
-
return source.includes(item);
|
|
639
|
-
}
|
|
640
|
-
if (typeof item === 'string' && typeof source === 'object' && source !== null) {
|
|
641
|
-
return hasOwnProperty.call(source, item);
|
|
642
|
-
}
|
|
643
|
-
return false;
|
|
644
|
-
}
|
|
645
|
-
serialize() {
|
|
646
|
-
return `${this.key} in '${this.valueKey}'`;
|
|
647
|
-
}
|
|
648
|
-
keys() {
|
|
649
|
-
return [this.key, this.valueKey];
|
|
650
|
-
}
|
|
651
|
-
negate() {
|
|
652
|
-
if (!this.negated) {
|
|
653
|
-
this.negated = ContextKeyNotInExpr.create(this.key, this.valueKey);
|
|
654
|
-
}
|
|
655
|
-
return this.negated;
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
export class ContextKeyNotInExpr {
|
|
659
|
-
static create(key, valueKey) {
|
|
660
|
-
return new ContextKeyNotInExpr(key, valueKey);
|
|
661
|
-
}
|
|
662
|
-
constructor(key, valueKey) {
|
|
663
|
-
this.key = key;
|
|
664
|
-
this.valueKey = valueKey;
|
|
665
|
-
this.type = 11 /* ContextKeyExprType.NotIn */;
|
|
666
|
-
this._negated = ContextKeyInExpr.create(key, valueKey);
|
|
667
|
-
}
|
|
668
|
-
cmp(other) {
|
|
669
|
-
if (other.type !== this.type) {
|
|
670
|
-
return this.type - other.type;
|
|
671
|
-
}
|
|
672
|
-
return this._negated.cmp(other._negated);
|
|
673
|
-
}
|
|
674
|
-
equals(other) {
|
|
675
|
-
if (other.type === this.type) {
|
|
676
|
-
return this._negated.equals(other._negated);
|
|
677
|
-
}
|
|
678
|
-
return false;
|
|
679
|
-
}
|
|
680
|
-
substituteConstants() {
|
|
681
|
-
return this;
|
|
682
|
-
}
|
|
683
|
-
evaluate(context) {
|
|
684
|
-
return !this._negated.evaluate(context);
|
|
685
|
-
}
|
|
686
|
-
serialize() {
|
|
687
|
-
return `${this.key} not in '${this.valueKey}'`;
|
|
688
|
-
}
|
|
689
|
-
keys() {
|
|
690
|
-
return this._negated.keys();
|
|
691
|
-
}
|
|
692
|
-
negate() {
|
|
693
|
-
return this._negated;
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
export class ContextKeyNotEqualsExpr {
|
|
697
|
-
static create(key, value, negated = null) {
|
|
698
|
-
if (typeof value === 'boolean') {
|
|
699
|
-
if (value) {
|
|
700
|
-
return ContextKeyNotExpr.create(key, negated);
|
|
701
|
-
}
|
|
702
|
-
return ContextKeyDefinedExpr.create(key, negated);
|
|
703
|
-
}
|
|
704
|
-
const constantValue = CONSTANT_VALUES.get(key);
|
|
705
|
-
if (typeof constantValue === 'boolean') {
|
|
706
|
-
const falseValue = constantValue ? 'true' : 'false';
|
|
707
|
-
return (value === falseValue ? ContextKeyFalseExpr.INSTANCE : ContextKeyTrueExpr.INSTANCE);
|
|
708
|
-
}
|
|
709
|
-
return new ContextKeyNotEqualsExpr(key, value, negated);
|
|
710
|
-
}
|
|
711
|
-
constructor(key, value, negated) {
|
|
712
|
-
this.key = key;
|
|
713
|
-
this.value = value;
|
|
714
|
-
this.negated = negated;
|
|
715
|
-
this.type = 5 /* ContextKeyExprType.NotEquals */;
|
|
716
|
-
}
|
|
717
|
-
cmp(other) {
|
|
718
|
-
if (other.type !== this.type) {
|
|
719
|
-
return this.type - other.type;
|
|
720
|
-
}
|
|
721
|
-
return cmp2(this.key, this.value, other.key, other.value);
|
|
722
|
-
}
|
|
723
|
-
equals(other) {
|
|
724
|
-
if (other.type === this.type) {
|
|
725
|
-
return (this.key === other.key && this.value === other.value);
|
|
726
|
-
}
|
|
727
|
-
return false;
|
|
728
|
-
}
|
|
729
|
-
substituteConstants() {
|
|
730
|
-
const constantValue = CONSTANT_VALUES.get(this.key);
|
|
731
|
-
if (typeof constantValue === 'boolean') {
|
|
732
|
-
const falseValue = constantValue ? 'true' : 'false';
|
|
733
|
-
return (this.value === falseValue ? ContextKeyFalseExpr.INSTANCE : ContextKeyTrueExpr.INSTANCE);
|
|
734
|
-
}
|
|
735
|
-
return this;
|
|
736
|
-
}
|
|
737
|
-
evaluate(context) {
|
|
738
|
-
// Intentional !=
|
|
739
|
-
// eslint-disable-next-line eqeqeq
|
|
740
|
-
return (context.getValue(this.key) != this.value);
|
|
741
|
-
}
|
|
742
|
-
serialize() {
|
|
743
|
-
return `${this.key} != '${this.value}'`;
|
|
744
|
-
}
|
|
745
|
-
keys() {
|
|
746
|
-
return [this.key];
|
|
747
|
-
}
|
|
748
|
-
negate() {
|
|
749
|
-
if (!this.negated) {
|
|
750
|
-
this.negated = ContextKeyEqualsExpr.create(this.key, this.value, this);
|
|
751
|
-
}
|
|
752
|
-
return this.negated;
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
export class ContextKeyNotExpr {
|
|
756
|
-
static create(key, negated = null) {
|
|
757
|
-
const constantValue = CONSTANT_VALUES.get(key);
|
|
758
|
-
if (typeof constantValue === 'boolean') {
|
|
759
|
-
return (constantValue ? ContextKeyFalseExpr.INSTANCE : ContextKeyTrueExpr.INSTANCE);
|
|
760
|
-
}
|
|
761
|
-
return new ContextKeyNotExpr(key, negated);
|
|
762
|
-
}
|
|
763
|
-
constructor(key, negated) {
|
|
764
|
-
this.key = key;
|
|
765
|
-
this.negated = negated;
|
|
766
|
-
this.type = 3 /* ContextKeyExprType.Not */;
|
|
767
|
-
}
|
|
768
|
-
cmp(other) {
|
|
769
|
-
if (other.type !== this.type) {
|
|
770
|
-
return this.type - other.type;
|
|
771
|
-
}
|
|
772
|
-
return cmp1(this.key, other.key);
|
|
773
|
-
}
|
|
774
|
-
equals(other) {
|
|
775
|
-
if (other.type === this.type) {
|
|
776
|
-
return (this.key === other.key);
|
|
777
|
-
}
|
|
778
|
-
return false;
|
|
779
|
-
}
|
|
780
|
-
substituteConstants() {
|
|
781
|
-
const constantValue = CONSTANT_VALUES.get(this.key);
|
|
782
|
-
if (typeof constantValue === 'boolean') {
|
|
783
|
-
return (constantValue ? ContextKeyFalseExpr.INSTANCE : ContextKeyTrueExpr.INSTANCE);
|
|
784
|
-
}
|
|
785
|
-
return this;
|
|
786
|
-
}
|
|
787
|
-
evaluate(context) {
|
|
788
|
-
return (!context.getValue(this.key));
|
|
789
|
-
}
|
|
790
|
-
serialize() {
|
|
791
|
-
return `!${this.key}`;
|
|
792
|
-
}
|
|
793
|
-
keys() {
|
|
794
|
-
return [this.key];
|
|
795
|
-
}
|
|
796
|
-
negate() {
|
|
797
|
-
if (!this.negated) {
|
|
798
|
-
this.negated = ContextKeyDefinedExpr.create(this.key, this);
|
|
799
|
-
}
|
|
800
|
-
return this.negated;
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
function withFloatOrStr(value, callback) {
|
|
804
|
-
if (typeof value === 'string') {
|
|
805
|
-
const n = parseFloat(value);
|
|
806
|
-
if (!isNaN(n)) {
|
|
807
|
-
value = n;
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
if (typeof value === 'string' || typeof value === 'number') {
|
|
811
|
-
return callback(value);
|
|
812
|
-
}
|
|
813
|
-
return ContextKeyFalseExpr.INSTANCE;
|
|
814
|
-
}
|
|
815
|
-
export class ContextKeyGreaterExpr {
|
|
816
|
-
static create(key, _value, negated = null) {
|
|
817
|
-
return withFloatOrStr(_value, (value) => new ContextKeyGreaterExpr(key, value, negated));
|
|
818
|
-
}
|
|
819
|
-
constructor(key, value, negated) {
|
|
820
|
-
this.key = key;
|
|
821
|
-
this.value = value;
|
|
822
|
-
this.negated = negated;
|
|
823
|
-
this.type = 12 /* ContextKeyExprType.Greater */;
|
|
824
|
-
}
|
|
825
|
-
cmp(other) {
|
|
826
|
-
if (other.type !== this.type) {
|
|
827
|
-
return this.type - other.type;
|
|
828
|
-
}
|
|
829
|
-
return cmp2(this.key, this.value, other.key, other.value);
|
|
830
|
-
}
|
|
831
|
-
equals(other) {
|
|
832
|
-
if (other.type === this.type) {
|
|
833
|
-
return (this.key === other.key && this.value === other.value);
|
|
834
|
-
}
|
|
835
|
-
return false;
|
|
836
|
-
}
|
|
837
|
-
substituteConstants() {
|
|
838
|
-
return this;
|
|
839
|
-
}
|
|
840
|
-
evaluate(context) {
|
|
841
|
-
if (typeof this.value === 'string') {
|
|
842
|
-
return false;
|
|
843
|
-
}
|
|
844
|
-
return (parseFloat(context.getValue(this.key)) > this.value);
|
|
845
|
-
}
|
|
846
|
-
serialize() {
|
|
847
|
-
return `${this.key} > ${this.value}`;
|
|
848
|
-
}
|
|
849
|
-
keys() {
|
|
850
|
-
return [this.key];
|
|
851
|
-
}
|
|
852
|
-
negate() {
|
|
853
|
-
if (!this.negated) {
|
|
854
|
-
this.negated = ContextKeySmallerEqualsExpr.create(this.key, this.value, this);
|
|
855
|
-
}
|
|
856
|
-
return this.negated;
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
export class ContextKeyGreaterEqualsExpr {
|
|
860
|
-
static create(key, _value, negated = null) {
|
|
861
|
-
return withFloatOrStr(_value, (value) => new ContextKeyGreaterEqualsExpr(key, value, negated));
|
|
862
|
-
}
|
|
863
|
-
constructor(key, value, negated) {
|
|
864
|
-
this.key = key;
|
|
865
|
-
this.value = value;
|
|
866
|
-
this.negated = negated;
|
|
867
|
-
this.type = 13 /* ContextKeyExprType.GreaterEquals */;
|
|
868
|
-
}
|
|
869
|
-
cmp(other) {
|
|
870
|
-
if (other.type !== this.type) {
|
|
871
|
-
return this.type - other.type;
|
|
872
|
-
}
|
|
873
|
-
return cmp2(this.key, this.value, other.key, other.value);
|
|
874
|
-
}
|
|
875
|
-
equals(other) {
|
|
876
|
-
if (other.type === this.type) {
|
|
877
|
-
return (this.key === other.key && this.value === other.value);
|
|
878
|
-
}
|
|
879
|
-
return false;
|
|
880
|
-
}
|
|
881
|
-
substituteConstants() {
|
|
882
|
-
return this;
|
|
883
|
-
}
|
|
884
|
-
evaluate(context) {
|
|
885
|
-
if (typeof this.value === 'string') {
|
|
886
|
-
return false;
|
|
887
|
-
}
|
|
888
|
-
return (parseFloat(context.getValue(this.key)) >= this.value);
|
|
889
|
-
}
|
|
890
|
-
serialize() {
|
|
891
|
-
return `${this.key} >= ${this.value}`;
|
|
892
|
-
}
|
|
893
|
-
keys() {
|
|
894
|
-
return [this.key];
|
|
895
|
-
}
|
|
896
|
-
negate() {
|
|
897
|
-
if (!this.negated) {
|
|
898
|
-
this.negated = ContextKeySmallerExpr.create(this.key, this.value, this);
|
|
899
|
-
}
|
|
900
|
-
return this.negated;
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
export class ContextKeySmallerExpr {
|
|
904
|
-
static create(key, _value, negated = null) {
|
|
905
|
-
return withFloatOrStr(_value, (value) => new ContextKeySmallerExpr(key, value, negated));
|
|
906
|
-
}
|
|
907
|
-
constructor(key, value, negated) {
|
|
908
|
-
this.key = key;
|
|
909
|
-
this.value = value;
|
|
910
|
-
this.negated = negated;
|
|
911
|
-
this.type = 14 /* ContextKeyExprType.Smaller */;
|
|
912
|
-
}
|
|
913
|
-
cmp(other) {
|
|
914
|
-
if (other.type !== this.type) {
|
|
915
|
-
return this.type - other.type;
|
|
916
|
-
}
|
|
917
|
-
return cmp2(this.key, this.value, other.key, other.value);
|
|
918
|
-
}
|
|
919
|
-
equals(other) {
|
|
920
|
-
if (other.type === this.type) {
|
|
921
|
-
return (this.key === other.key && this.value === other.value);
|
|
922
|
-
}
|
|
923
|
-
return false;
|
|
924
|
-
}
|
|
925
|
-
substituteConstants() {
|
|
926
|
-
return this;
|
|
927
|
-
}
|
|
928
|
-
evaluate(context) {
|
|
929
|
-
if (typeof this.value === 'string') {
|
|
930
|
-
return false;
|
|
931
|
-
}
|
|
932
|
-
return (parseFloat(context.getValue(this.key)) < this.value);
|
|
933
|
-
}
|
|
934
|
-
serialize() {
|
|
935
|
-
return `${this.key} < ${this.value}`;
|
|
936
|
-
}
|
|
937
|
-
keys() {
|
|
938
|
-
return [this.key];
|
|
939
|
-
}
|
|
940
|
-
negate() {
|
|
941
|
-
if (!this.negated) {
|
|
942
|
-
this.negated = ContextKeyGreaterEqualsExpr.create(this.key, this.value, this);
|
|
943
|
-
}
|
|
944
|
-
return this.negated;
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
export class ContextKeySmallerEqualsExpr {
|
|
948
|
-
static create(key, _value, negated = null) {
|
|
949
|
-
return withFloatOrStr(_value, (value) => new ContextKeySmallerEqualsExpr(key, value, negated));
|
|
950
|
-
}
|
|
951
|
-
constructor(key, value, negated) {
|
|
952
|
-
this.key = key;
|
|
953
|
-
this.value = value;
|
|
954
|
-
this.negated = negated;
|
|
955
|
-
this.type = 15 /* ContextKeyExprType.SmallerEquals */;
|
|
956
|
-
}
|
|
957
|
-
cmp(other) {
|
|
958
|
-
if (other.type !== this.type) {
|
|
959
|
-
return this.type - other.type;
|
|
960
|
-
}
|
|
961
|
-
return cmp2(this.key, this.value, other.key, other.value);
|
|
962
|
-
}
|
|
963
|
-
equals(other) {
|
|
964
|
-
if (other.type === this.type) {
|
|
965
|
-
return (this.key === other.key && this.value === other.value);
|
|
966
|
-
}
|
|
967
|
-
return false;
|
|
968
|
-
}
|
|
969
|
-
substituteConstants() {
|
|
970
|
-
return this;
|
|
971
|
-
}
|
|
972
|
-
evaluate(context) {
|
|
973
|
-
if (typeof this.value === 'string') {
|
|
974
|
-
return false;
|
|
975
|
-
}
|
|
976
|
-
return (parseFloat(context.getValue(this.key)) <= this.value);
|
|
977
|
-
}
|
|
978
|
-
serialize() {
|
|
979
|
-
return `${this.key} <= ${this.value}`;
|
|
980
|
-
}
|
|
981
|
-
keys() {
|
|
982
|
-
return [this.key];
|
|
983
|
-
}
|
|
984
|
-
negate() {
|
|
985
|
-
if (!this.negated) {
|
|
986
|
-
this.negated = ContextKeyGreaterExpr.create(this.key, this.value, this);
|
|
987
|
-
}
|
|
988
|
-
return this.negated;
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
export class ContextKeyRegexExpr {
|
|
992
|
-
static create(key, regexp) {
|
|
993
|
-
return new ContextKeyRegexExpr(key, regexp);
|
|
994
|
-
}
|
|
995
|
-
constructor(key, regexp) {
|
|
996
|
-
this.key = key;
|
|
997
|
-
this.regexp = regexp;
|
|
998
|
-
this.type = 7 /* ContextKeyExprType.Regex */;
|
|
999
|
-
this.negated = null;
|
|
1000
|
-
//
|
|
1001
|
-
}
|
|
1002
|
-
cmp(other) {
|
|
1003
|
-
if (other.type !== this.type) {
|
|
1004
|
-
return this.type - other.type;
|
|
1005
|
-
}
|
|
1006
|
-
if (this.key < other.key) {
|
|
1007
|
-
return -1;
|
|
1008
|
-
}
|
|
1009
|
-
if (this.key > other.key) {
|
|
1010
|
-
return 1;
|
|
1011
|
-
}
|
|
1012
|
-
const thisSource = this.regexp ? this.regexp.source : '';
|
|
1013
|
-
const otherSource = other.regexp ? other.regexp.source : '';
|
|
1014
|
-
if (thisSource < otherSource) {
|
|
1015
|
-
return -1;
|
|
1016
|
-
}
|
|
1017
|
-
if (thisSource > otherSource) {
|
|
1018
|
-
return 1;
|
|
1019
|
-
}
|
|
1020
|
-
return 0;
|
|
1021
|
-
}
|
|
1022
|
-
equals(other) {
|
|
1023
|
-
if (other.type === this.type) {
|
|
1024
|
-
const thisSource = this.regexp ? this.regexp.source : '';
|
|
1025
|
-
const otherSource = other.regexp ? other.regexp.source : '';
|
|
1026
|
-
return (this.key === other.key && thisSource === otherSource);
|
|
1027
|
-
}
|
|
1028
|
-
return false;
|
|
1029
|
-
}
|
|
1030
|
-
substituteConstants() {
|
|
1031
|
-
return this;
|
|
1032
|
-
}
|
|
1033
|
-
evaluate(context) {
|
|
1034
|
-
const value = context.getValue(this.key);
|
|
1035
|
-
return this.regexp ? this.regexp.test(value) : false;
|
|
1036
|
-
}
|
|
1037
|
-
serialize() {
|
|
1038
|
-
const value = this.regexp
|
|
1039
|
-
? `/${this.regexp.source}/${this.regexp.flags}`
|
|
1040
|
-
: '/invalid/';
|
|
1041
|
-
return `${this.key} =~ ${value}`;
|
|
1042
|
-
}
|
|
1043
|
-
keys() {
|
|
1044
|
-
return [this.key];
|
|
1045
|
-
}
|
|
1046
|
-
negate() {
|
|
1047
|
-
if (!this.negated) {
|
|
1048
|
-
this.negated = ContextKeyNotRegexExpr.create(this);
|
|
1049
|
-
}
|
|
1050
|
-
return this.negated;
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
export class ContextKeyNotRegexExpr {
|
|
1054
|
-
static create(actual) {
|
|
1055
|
-
return new ContextKeyNotRegexExpr(actual);
|
|
1056
|
-
}
|
|
1057
|
-
constructor(_actual) {
|
|
1058
|
-
this._actual = _actual;
|
|
1059
|
-
this.type = 8 /* ContextKeyExprType.NotRegex */;
|
|
1060
|
-
//
|
|
1061
|
-
}
|
|
1062
|
-
cmp(other) {
|
|
1063
|
-
if (other.type !== this.type) {
|
|
1064
|
-
return this.type - other.type;
|
|
1065
|
-
}
|
|
1066
|
-
return this._actual.cmp(other._actual);
|
|
1067
|
-
}
|
|
1068
|
-
equals(other) {
|
|
1069
|
-
if (other.type === this.type) {
|
|
1070
|
-
return this._actual.equals(other._actual);
|
|
1071
|
-
}
|
|
1072
|
-
return false;
|
|
1073
|
-
}
|
|
1074
|
-
substituteConstants() {
|
|
1075
|
-
return this;
|
|
1076
|
-
}
|
|
1077
|
-
evaluate(context) {
|
|
1078
|
-
return !this._actual.evaluate(context);
|
|
1079
|
-
}
|
|
1080
|
-
serialize() {
|
|
1081
|
-
return `!(${this._actual.serialize()})`;
|
|
1082
|
-
}
|
|
1083
|
-
keys() {
|
|
1084
|
-
return this._actual.keys();
|
|
1085
|
-
}
|
|
1086
|
-
negate() {
|
|
1087
|
-
return this._actual;
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
/**
|
|
1091
|
-
* @returns the same instance if nothing changed.
|
|
1092
|
-
*/
|
|
1093
|
-
function eliminateConstantsInArray(arr) {
|
|
1094
|
-
// Allocate array only if there is a difference
|
|
1095
|
-
let newArr = null;
|
|
1096
|
-
for (let i = 0, len = arr.length; i < len; i++) {
|
|
1097
|
-
const newExpr = arr[i].substituteConstants();
|
|
1098
|
-
if (arr[i] !== newExpr) {
|
|
1099
|
-
// something has changed!
|
|
1100
|
-
// allocate array on first difference
|
|
1101
|
-
if (newArr === null) {
|
|
1102
|
-
newArr = [];
|
|
1103
|
-
for (let j = 0; j < i; j++) {
|
|
1104
|
-
newArr[j] = arr[j];
|
|
1105
|
-
}
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
if (newArr !== null) {
|
|
1109
|
-
newArr[i] = newExpr;
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
if (newArr === null) {
|
|
1113
|
-
return arr;
|
|
1114
|
-
}
|
|
1115
|
-
return newArr;
|
|
1116
|
-
}
|
|
1117
|
-
export class ContextKeyAndExpr {
|
|
1118
|
-
static create(_expr, negated, extraRedundantCheck) {
|
|
1119
|
-
return ContextKeyAndExpr._normalizeArr(_expr, negated, extraRedundantCheck);
|
|
1120
|
-
}
|
|
1121
|
-
constructor(expr, negated) {
|
|
1122
|
-
this.expr = expr;
|
|
1123
|
-
this.negated = negated;
|
|
1124
|
-
this.type = 6 /* ContextKeyExprType.And */;
|
|
1125
|
-
}
|
|
1126
|
-
cmp(other) {
|
|
1127
|
-
if (other.type !== this.type) {
|
|
1128
|
-
return this.type - other.type;
|
|
1129
|
-
}
|
|
1130
|
-
if (this.expr.length < other.expr.length) {
|
|
1131
|
-
return -1;
|
|
1132
|
-
}
|
|
1133
|
-
if (this.expr.length > other.expr.length) {
|
|
1134
|
-
return 1;
|
|
1135
|
-
}
|
|
1136
|
-
for (let i = 0, len = this.expr.length; i < len; i++) {
|
|
1137
|
-
const r = cmp(this.expr[i], other.expr[i]);
|
|
1138
|
-
if (r !== 0) {
|
|
1139
|
-
return r;
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
return 0;
|
|
1143
|
-
}
|
|
1144
|
-
equals(other) {
|
|
1145
|
-
if (other.type === this.type) {
|
|
1146
|
-
if (this.expr.length !== other.expr.length) {
|
|
1147
|
-
return false;
|
|
1148
|
-
}
|
|
1149
|
-
for (let i = 0, len = this.expr.length; i < len; i++) {
|
|
1150
|
-
if (!this.expr[i].equals(other.expr[i])) {
|
|
1151
|
-
return false;
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
return true;
|
|
1155
|
-
}
|
|
1156
|
-
return false;
|
|
1157
|
-
}
|
|
1158
|
-
substituteConstants() {
|
|
1159
|
-
const exprArr = eliminateConstantsInArray(this.expr);
|
|
1160
|
-
if (exprArr === this.expr) {
|
|
1161
|
-
// no change
|
|
1162
|
-
return this;
|
|
1163
|
-
}
|
|
1164
|
-
return ContextKeyAndExpr.create(exprArr, this.negated, false);
|
|
1165
|
-
}
|
|
1166
|
-
evaluate(context) {
|
|
1167
|
-
for (let i = 0, len = this.expr.length; i < len; i++) {
|
|
1168
|
-
if (!this.expr[i].evaluate(context)) {
|
|
1169
|
-
return false;
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
return true;
|
|
1173
|
-
}
|
|
1174
|
-
static _normalizeArr(arr, negated, extraRedundantCheck) {
|
|
1175
|
-
const expr = [];
|
|
1176
|
-
let hasTrue = false;
|
|
1177
|
-
for (const e of arr) {
|
|
1178
|
-
if (!e) {
|
|
1179
|
-
continue;
|
|
1180
|
-
}
|
|
1181
|
-
if (e.type === 1 /* ContextKeyExprType.True */) {
|
|
1182
|
-
// anything && true ==> anything
|
|
1183
|
-
hasTrue = true;
|
|
1184
|
-
continue;
|
|
1185
|
-
}
|
|
1186
|
-
if (e.type === 0 /* ContextKeyExprType.False */) {
|
|
1187
|
-
// anything && false ==> false
|
|
1188
|
-
return ContextKeyFalseExpr.INSTANCE;
|
|
1189
|
-
}
|
|
1190
|
-
if (e.type === 6 /* ContextKeyExprType.And */) {
|
|
1191
|
-
expr.push(...e.expr);
|
|
1192
|
-
continue;
|
|
1193
|
-
}
|
|
1194
|
-
expr.push(e);
|
|
1195
|
-
}
|
|
1196
|
-
if (expr.length === 0 && hasTrue) {
|
|
1197
|
-
return ContextKeyTrueExpr.INSTANCE;
|
|
1198
|
-
}
|
|
1199
|
-
if (expr.length === 0) {
|
|
1200
|
-
return undefined;
|
|
1201
|
-
}
|
|
1202
|
-
if (expr.length === 1) {
|
|
1203
|
-
return expr[0];
|
|
1204
|
-
}
|
|
1205
|
-
expr.sort(cmp);
|
|
1206
|
-
// eliminate duplicate terms
|
|
1207
|
-
for (let i = 1; i < expr.length; i++) {
|
|
1208
|
-
if (expr[i - 1].equals(expr[i])) {
|
|
1209
|
-
expr.splice(i, 1);
|
|
1210
|
-
i--;
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
if (expr.length === 1) {
|
|
1214
|
-
return expr[0];
|
|
1215
|
-
}
|
|
1216
|
-
// We must distribute any OR expression because we don't support parens
|
|
1217
|
-
// OR extensions will be at the end (due to sorting rules)
|
|
1218
|
-
while (expr.length > 1) {
|
|
1219
|
-
const lastElement = expr[expr.length - 1];
|
|
1220
|
-
if (lastElement.type !== 9 /* ContextKeyExprType.Or */) {
|
|
1221
|
-
break;
|
|
1222
|
-
}
|
|
1223
|
-
// pop the last element
|
|
1224
|
-
expr.pop();
|
|
1225
|
-
// pop the second to last element
|
|
1226
|
-
const secondToLastElement = expr.pop();
|
|
1227
|
-
const isFinished = (expr.length === 0);
|
|
1228
|
-
// distribute `lastElement` over `secondToLastElement`
|
|
1229
|
-
const resultElement = ContextKeyOrExpr.create(lastElement.expr.map(el => ContextKeyAndExpr.create([el, secondToLastElement], null, extraRedundantCheck)), null, isFinished);
|
|
1230
|
-
if (resultElement) {
|
|
1231
|
-
expr.push(resultElement);
|
|
1232
|
-
expr.sort(cmp);
|
|
1233
|
-
}
|
|
1234
|
-
}
|
|
1235
|
-
if (expr.length === 1) {
|
|
1236
|
-
return expr[0];
|
|
1237
|
-
}
|
|
1238
|
-
// resolve false AND expressions
|
|
1239
|
-
if (extraRedundantCheck) {
|
|
1240
|
-
for (let i = 0; i < expr.length; i++) {
|
|
1241
|
-
for (let j = i + 1; j < expr.length; j++) {
|
|
1242
|
-
if (expr[i].negate().equals(expr[j])) {
|
|
1243
|
-
// A && !A case
|
|
1244
|
-
return ContextKeyFalseExpr.INSTANCE;
|
|
1245
|
-
}
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
if (expr.length === 1) {
|
|
1249
|
-
return expr[0];
|
|
1250
|
-
}
|
|
1251
|
-
}
|
|
1252
|
-
return new ContextKeyAndExpr(expr, negated);
|
|
1253
|
-
}
|
|
1254
|
-
serialize() {
|
|
1255
|
-
return this.expr.map(e => e.serialize()).join(' && ');
|
|
1256
|
-
}
|
|
1257
|
-
keys() {
|
|
1258
|
-
const result = [];
|
|
1259
|
-
for (const expr of this.expr) {
|
|
1260
|
-
result.push(...expr.keys());
|
|
1261
|
-
}
|
|
1262
|
-
return result;
|
|
1263
|
-
}
|
|
1264
|
-
negate() {
|
|
1265
|
-
if (!this.negated) {
|
|
1266
|
-
const result = [];
|
|
1267
|
-
for (const expr of this.expr) {
|
|
1268
|
-
result.push(expr.negate());
|
|
1269
|
-
}
|
|
1270
|
-
this.negated = ContextKeyOrExpr.create(result, this, true);
|
|
1271
|
-
}
|
|
1272
|
-
return this.negated;
|
|
1273
|
-
}
|
|
1274
|
-
}
|
|
1275
|
-
export class ContextKeyOrExpr {
|
|
1276
|
-
static create(_expr, negated, extraRedundantCheck) {
|
|
1277
|
-
return ContextKeyOrExpr._normalizeArr(_expr, negated, extraRedundantCheck);
|
|
1278
|
-
}
|
|
1279
|
-
constructor(expr, negated) {
|
|
1280
|
-
this.expr = expr;
|
|
1281
|
-
this.negated = negated;
|
|
1282
|
-
this.type = 9 /* ContextKeyExprType.Or */;
|
|
1283
|
-
}
|
|
1284
|
-
cmp(other) {
|
|
1285
|
-
if (other.type !== this.type) {
|
|
1286
|
-
return this.type - other.type;
|
|
1287
|
-
}
|
|
1288
|
-
if (this.expr.length < other.expr.length) {
|
|
1289
|
-
return -1;
|
|
1290
|
-
}
|
|
1291
|
-
if (this.expr.length > other.expr.length) {
|
|
1292
|
-
return 1;
|
|
1293
|
-
}
|
|
1294
|
-
for (let i = 0, len = this.expr.length; i < len; i++) {
|
|
1295
|
-
const r = cmp(this.expr[i], other.expr[i]);
|
|
1296
|
-
if (r !== 0) {
|
|
1297
|
-
return r;
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
return 0;
|
|
1301
|
-
}
|
|
1302
|
-
equals(other) {
|
|
1303
|
-
if (other.type === this.type) {
|
|
1304
|
-
if (this.expr.length !== other.expr.length) {
|
|
1305
|
-
return false;
|
|
1306
|
-
}
|
|
1307
|
-
for (let i = 0, len = this.expr.length; i < len; i++) {
|
|
1308
|
-
if (!this.expr[i].equals(other.expr[i])) {
|
|
1309
|
-
return false;
|
|
1310
|
-
}
|
|
1311
|
-
}
|
|
1312
|
-
return true;
|
|
1313
|
-
}
|
|
1314
|
-
return false;
|
|
1315
|
-
}
|
|
1316
|
-
substituteConstants() {
|
|
1317
|
-
const exprArr = eliminateConstantsInArray(this.expr);
|
|
1318
|
-
if (exprArr === this.expr) {
|
|
1319
|
-
// no change
|
|
1320
|
-
return this;
|
|
1321
|
-
}
|
|
1322
|
-
return ContextKeyOrExpr.create(exprArr, this.negated, false);
|
|
1323
|
-
}
|
|
1324
|
-
evaluate(context) {
|
|
1325
|
-
for (let i = 0, len = this.expr.length; i < len; i++) {
|
|
1326
|
-
if (this.expr[i].evaluate(context)) {
|
|
1327
|
-
return true;
|
|
1328
|
-
}
|
|
1329
|
-
}
|
|
1330
|
-
return false;
|
|
1331
|
-
}
|
|
1332
|
-
static _normalizeArr(arr, negated, extraRedundantCheck) {
|
|
1333
|
-
let expr = [];
|
|
1334
|
-
let hasFalse = false;
|
|
1335
|
-
if (arr) {
|
|
1336
|
-
for (let i = 0, len = arr.length; i < len; i++) {
|
|
1337
|
-
const e = arr[i];
|
|
1338
|
-
if (!e) {
|
|
1339
|
-
continue;
|
|
1340
|
-
}
|
|
1341
|
-
if (e.type === 0 /* ContextKeyExprType.False */) {
|
|
1342
|
-
// anything || false ==> anything
|
|
1343
|
-
hasFalse = true;
|
|
1344
|
-
continue;
|
|
1345
|
-
}
|
|
1346
|
-
if (e.type === 1 /* ContextKeyExprType.True */) {
|
|
1347
|
-
// anything || true ==> true
|
|
1348
|
-
return ContextKeyTrueExpr.INSTANCE;
|
|
1349
|
-
}
|
|
1350
|
-
if (e.type === 9 /* ContextKeyExprType.Or */) {
|
|
1351
|
-
expr = expr.concat(e.expr);
|
|
1352
|
-
continue;
|
|
1353
|
-
}
|
|
1354
|
-
expr.push(e);
|
|
1355
|
-
}
|
|
1356
|
-
if (expr.length === 0 && hasFalse) {
|
|
1357
|
-
return ContextKeyFalseExpr.INSTANCE;
|
|
1358
|
-
}
|
|
1359
|
-
expr.sort(cmp);
|
|
1360
|
-
}
|
|
1361
|
-
if (expr.length === 0) {
|
|
1362
|
-
return undefined;
|
|
1363
|
-
}
|
|
1364
|
-
if (expr.length === 1) {
|
|
1365
|
-
return expr[0];
|
|
1366
|
-
}
|
|
1367
|
-
// eliminate duplicate terms
|
|
1368
|
-
for (let i = 1; i < expr.length; i++) {
|
|
1369
|
-
if (expr[i - 1].equals(expr[i])) {
|
|
1370
|
-
expr.splice(i, 1);
|
|
1371
|
-
i--;
|
|
1372
|
-
}
|
|
1373
|
-
}
|
|
1374
|
-
if (expr.length === 1) {
|
|
1375
|
-
return expr[0];
|
|
1376
|
-
}
|
|
1377
|
-
// resolve true OR expressions
|
|
1378
|
-
if (extraRedundantCheck) {
|
|
1379
|
-
for (let i = 0; i < expr.length; i++) {
|
|
1380
|
-
for (let j = i + 1; j < expr.length; j++) {
|
|
1381
|
-
if (expr[i].negate().equals(expr[j])) {
|
|
1382
|
-
// A || !A case
|
|
1383
|
-
return ContextKeyTrueExpr.INSTANCE;
|
|
1384
|
-
}
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
if (expr.length === 1) {
|
|
1388
|
-
return expr[0];
|
|
1389
|
-
}
|
|
1390
|
-
}
|
|
1391
|
-
return new ContextKeyOrExpr(expr, negated);
|
|
1392
|
-
}
|
|
1393
|
-
serialize() {
|
|
1394
|
-
return this.expr.map(e => e.serialize()).join(' || ');
|
|
1395
|
-
}
|
|
1396
|
-
keys() {
|
|
1397
|
-
const result = [];
|
|
1398
|
-
for (const expr of this.expr) {
|
|
1399
|
-
result.push(...expr.keys());
|
|
1400
|
-
}
|
|
1401
|
-
return result;
|
|
1402
|
-
}
|
|
1403
|
-
negate() {
|
|
1404
|
-
if (!this.negated) {
|
|
1405
|
-
const result = [];
|
|
1406
|
-
for (const expr of this.expr) {
|
|
1407
|
-
result.push(expr.negate());
|
|
1408
|
-
}
|
|
1409
|
-
// We don't support parens, so here we distribute the AND over the OR terminals
|
|
1410
|
-
// We always take the first 2 AND pairs and distribute them
|
|
1411
|
-
while (result.length > 1) {
|
|
1412
|
-
const LEFT = result.shift();
|
|
1413
|
-
const RIGHT = result.shift();
|
|
1414
|
-
const all = [];
|
|
1415
|
-
for (const left of getTerminals(LEFT)) {
|
|
1416
|
-
for (const right of getTerminals(RIGHT)) {
|
|
1417
|
-
all.push(ContextKeyAndExpr.create([left, right], null, false));
|
|
1418
|
-
}
|
|
1419
|
-
}
|
|
1420
|
-
result.unshift(ContextKeyOrExpr.create(all, null, false));
|
|
1421
|
-
}
|
|
1422
|
-
this.negated = ContextKeyOrExpr.create(result, this, true);
|
|
1423
|
-
}
|
|
1424
|
-
return this.negated;
|
|
1425
|
-
}
|
|
1426
|
-
}
|
|
1427
|
-
export class RawContextKey extends ContextKeyDefinedExpr {
|
|
1428
|
-
static all() {
|
|
1429
|
-
return RawContextKey._info.values();
|
|
1430
|
-
}
|
|
1431
|
-
constructor(key, defaultValue, metaOrHide) {
|
|
1432
|
-
super(key, null);
|
|
1433
|
-
this._defaultValue = defaultValue;
|
|
1434
|
-
// collect all context keys into a central place
|
|
1435
|
-
if (typeof metaOrHide === 'object') {
|
|
1436
|
-
RawContextKey._info.push({ ...metaOrHide, key });
|
|
1437
|
-
}
|
|
1438
|
-
else if (metaOrHide !== true) {
|
|
1439
|
-
RawContextKey._info.push({ key, description: metaOrHide, type: defaultValue !== null && defaultValue !== undefined ? typeof defaultValue : undefined });
|
|
1440
|
-
}
|
|
1441
|
-
}
|
|
1442
|
-
bindTo(target) {
|
|
1443
|
-
return target.createKey(this.key, this._defaultValue);
|
|
1444
|
-
}
|
|
1445
|
-
getValue(target) {
|
|
1446
|
-
return target.getContextKeyValue(this.key);
|
|
1447
|
-
}
|
|
1448
|
-
toNegated() {
|
|
1449
|
-
return this.negate();
|
|
1450
|
-
}
|
|
1451
|
-
isEqualTo(value) {
|
|
1452
|
-
return ContextKeyEqualsExpr.create(this.key, value);
|
|
1453
|
-
}
|
|
1454
|
-
}
|
|
1455
|
-
RawContextKey._info = [];
|
|
1456
|
-
export const IContextKeyService = createDecorator('contextKeyService');
|
|
1457
|
-
function cmp1(key1, key2) {
|
|
1458
|
-
if (key1 < key2) {
|
|
1459
|
-
return -1;
|
|
1460
|
-
}
|
|
1461
|
-
if (key1 > key2) {
|
|
1462
|
-
return 1;
|
|
1463
|
-
}
|
|
1464
|
-
return 0;
|
|
1465
|
-
}
|
|
1466
|
-
function cmp2(key1, value1, key2, value2) {
|
|
1467
|
-
if (key1 < key2) {
|
|
1468
|
-
return -1;
|
|
1469
|
-
}
|
|
1470
|
-
if (key1 > key2) {
|
|
1471
|
-
return 1;
|
|
1472
|
-
}
|
|
1473
|
-
if (value1 < value2) {
|
|
1474
|
-
return -1;
|
|
1475
|
-
}
|
|
1476
|
-
if (value1 > value2) {
|
|
1477
|
-
return 1;
|
|
1478
|
-
}
|
|
1479
|
-
return 0;
|
|
1480
|
-
}
|
|
1481
|
-
/**
|
|
1482
|
-
* Returns true if it is provable `p` implies `q`.
|
|
1483
|
-
*/
|
|
1484
|
-
export function implies(p, q) {
|
|
1485
|
-
if (p.type === 0 /* ContextKeyExprType.False */ || q.type === 1 /* ContextKeyExprType.True */) {
|
|
1486
|
-
// false implies anything
|
|
1487
|
-
// anything implies true
|
|
1488
|
-
return true;
|
|
1489
|
-
}
|
|
1490
|
-
if (p.type === 9 /* ContextKeyExprType.Or */) {
|
|
1491
|
-
if (q.type === 9 /* ContextKeyExprType.Or */) {
|
|
1492
|
-
// `a || b || c` can only imply something like `a || b || c || d`
|
|
1493
|
-
return allElementsIncluded(p.expr, q.expr);
|
|
1494
|
-
}
|
|
1495
|
-
return false;
|
|
1496
|
-
}
|
|
1497
|
-
if (q.type === 9 /* ContextKeyExprType.Or */) {
|
|
1498
|
-
for (const element of q.expr) {
|
|
1499
|
-
if (implies(p, element)) {
|
|
1500
|
-
return true;
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
return false;
|
|
1504
|
-
}
|
|
1505
|
-
if (p.type === 6 /* ContextKeyExprType.And */) {
|
|
1506
|
-
if (q.type === 6 /* ContextKeyExprType.And */) {
|
|
1507
|
-
// `a && b && c` implies `a && c`
|
|
1508
|
-
return allElementsIncluded(q.expr, p.expr);
|
|
1509
|
-
}
|
|
1510
|
-
for (const element of p.expr) {
|
|
1511
|
-
if (implies(element, q)) {
|
|
1512
|
-
return true;
|
|
1513
|
-
}
|
|
1514
|
-
}
|
|
1515
|
-
return false;
|
|
1516
|
-
}
|
|
1517
|
-
return p.equals(q);
|
|
1518
|
-
}
|
|
1519
|
-
/**
|
|
1520
|
-
* Returns true if all elements in `p` are also present in `q`.
|
|
1521
|
-
* The two arrays are assumed to be sorted
|
|
1522
|
-
*/
|
|
1523
|
-
function allElementsIncluded(p, q) {
|
|
1524
|
-
let pIndex = 0;
|
|
1525
|
-
let qIndex = 0;
|
|
1526
|
-
while (pIndex < p.length && qIndex < q.length) {
|
|
1527
|
-
const cmp = p[pIndex].cmp(q[qIndex]);
|
|
1528
|
-
if (cmp < 0) {
|
|
1529
|
-
// an element from `p` is missing from `q`
|
|
1530
|
-
return false;
|
|
1531
|
-
}
|
|
1532
|
-
else if (cmp === 0) {
|
|
1533
|
-
pIndex++;
|
|
1534
|
-
qIndex++;
|
|
1535
|
-
}
|
|
1536
|
-
else {
|
|
1537
|
-
qIndex++;
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1540
|
-
return (pIndex === p.length);
|
|
1541
|
-
}
|
|
1542
|
-
function getTerminals(node) {
|
|
1543
|
-
if (node.type === 9 /* ContextKeyExprType.Or */) {
|
|
1544
|
-
return node.expr;
|
|
1545
|
-
}
|
|
1546
|
-
return [node];
|
|
1547
|
-
}
|