jsonContributionRegistry.js 1.2 KB

123456789101112131415161718192021222324252627282930
  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 { Emitter } from '../../../base/common/event.js';
  6. import * as platform from '../../registry/common/platform.js';
  7. export const Extensions = {
  8. JSONContribution: 'base.contributions.json'
  9. };
  10. function normalizeId(id) {
  11. if (id.length > 0 && id.charAt(id.length - 1) === '#') {
  12. return id.substring(0, id.length - 1);
  13. }
  14. return id;
  15. }
  16. class JSONContributionRegistry {
  17. constructor() {
  18. this._onDidChangeSchema = new Emitter();
  19. this.schemasById = {};
  20. }
  21. registerSchema(uri, unresolvedSchemaContent) {
  22. this.schemasById[normalizeId(uri)] = unresolvedSchemaContent;
  23. this._onDidChangeSchema.fire(uri);
  24. }
  25. notifySchemaChanged(uri) {
  26. this._onDidChangeSchema.fire(uri);
  27. }
  28. }
  29. const jsonContributionRegistry = new JSONContributionRegistry();
  30. platform.Registry.add(Extensions.JSONContribution, jsonContributionRegistry);