tokenization.js 1.2 KB

1234567891011121314151617181920212223242526272829
  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 { StopWatch } from '../../../base/common/stopwatch.js';
  6. import { EditorAction, registerEditorAction } from '../../browser/editorExtensions.js';
  7. import * as nls from '../../../nls.js';
  8. class ForceRetokenizeAction extends EditorAction {
  9. constructor() {
  10. super({
  11. id: 'editor.action.forceRetokenize',
  12. label: nls.localize('forceRetokenize', "Developer: Force Retokenize"),
  13. alias: 'Developer: Force Retokenize',
  14. precondition: undefined
  15. });
  16. }
  17. run(accessor, editor) {
  18. if (!editor.hasModel()) {
  19. return;
  20. }
  21. const model = editor.getModel();
  22. model.resetTokenization();
  23. const sw = new StopWatch(true);
  24. model.forceTokenization(model.getLineCount());
  25. sw.stop();
  26. console.log(`tokenization took ${sw.elapsed()}`);
  27. }
  28. }
  29. registerEditorAction(ForceRetokenizeAction);