6623f987c871267f3139fba2c98af7213a644a029420f5bfeddf17a5df0a2ac90c429992a17c1e21c667d8c926cf64054b2834f4bb01806f4a9324df93d848 1.8 KB

1234567891011121314151617181920212223242526272829303132333435
  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 { StandardAutoClosingPairConditional } from '../languageConfiguration.js';
  6. export class CharacterPairSupport {
  7. constructor(config) {
  8. if (config.autoClosingPairs) {
  9. this._autoClosingPairs = config.autoClosingPairs.map(el => new StandardAutoClosingPairConditional(el));
  10. }
  11. else if (config.brackets) {
  12. this._autoClosingPairs = config.brackets.map(b => new StandardAutoClosingPairConditional({ open: b[0], close: b[1] }));
  13. }
  14. else {
  15. this._autoClosingPairs = [];
  16. }
  17. if (config.__electricCharacterSupport && config.__electricCharacterSupport.docComment) {
  18. const docComment = config.__electricCharacterSupport.docComment;
  19. // IDocComment is legacy, only partially supported
  20. this._autoClosingPairs.push(new StandardAutoClosingPairConditional({ open: docComment.open, close: docComment.close || '' }));
  21. }
  22. this._autoCloseBefore = typeof config.autoCloseBefore === 'string' ? config.autoCloseBefore : CharacterPairSupport.DEFAULT_AUTOCLOSE_BEFORE_LANGUAGE_DEFINED;
  23. this._surroundingPairs = config.surroundingPairs || this._autoClosingPairs;
  24. }
  25. getAutoClosingPairs() {
  26. return this._autoClosingPairs;
  27. }
  28. getAutoCloseBeforeSet() {
  29. return this._autoCloseBefore;
  30. }
  31. getSurroundingPairs() {
  32. return this._surroundingPairs;
  33. }
  34. }
  35. CharacterPairSupport.DEFAULT_AUTOCLOSE_BEFORE_LANGUAGE_DEFINED = ';:.,=}])> \n\t';