637451afec343a3a5d81ae1f9867445d4d3b6a4dadfec04e916c1b6f5916cf6d37f63145c5deaed8f51a58682c24ad967b7b2b54b953c4d799a297615d128c 913 B

1234567891011121314151617181920212223
  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. export class InternalEditorAction {
  6. constructor(id, label, alias, precondition, run, contextKeyService) {
  7. this.id = id;
  8. this.label = label;
  9. this.alias = alias;
  10. this._precondition = precondition;
  11. this._run = run;
  12. this._contextKeyService = contextKeyService;
  13. }
  14. isSupported() {
  15. return this._contextKeyService.contextMatchesRules(this._precondition);
  16. }
  17. run() {
  18. if (!this.isSupported()) {
  19. return Promise.resolve(undefined);
  20. }
  21. return this._run();
  22. }
  23. }