Skip to content

Commit

Permalink
monaco: upgrade to 1.72.x
Browse files Browse the repository at this point in the history
The commit upgrades monaco to `v1.72.3`.

Signed-off-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
  • Loading branch information
vince-fugnitto committed Nov 7, 2022
1 parent 3e25fc4 commit 562bd7e
Show file tree
Hide file tree
Showing 43 changed files with 403 additions and 228 deletions.
2 changes: 1 addition & 1 deletion examples/api-samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@theia/file-search": "1.31.0",
"@theia/filesystem": "1.31.0",
"@theia/monaco": "1.31.0",
"@theia/monaco-editor-core": "1.67.2",
"@theia/monaco-editor-core": "1.72.3-alpha0",
"@theia/output": "1.31.0",
"@theia/search-in-workspace": "1.31.0",
"@theia/toolbar": "1.31.0",
Expand Down
27 changes: 15 additions & 12 deletions examples/api-tests/src/typescript.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,10 +644,10 @@ SPAN {
editor.getControl().revealPosition({ lineNumber, column });
assert.equal(currentChar(), ';');

/** @type {import('@theia/monaco-editor-core/src/vs/editor/contrib/codeAction/browser/codeActionCommands').QuickFixController} */
const quickFixController = editor.getControl().getContribution('editor.contrib.quickFixController');
/** @type {import('@theia/monaco-editor-core/src/vs/editor/contrib/codeAction/browser/codeActionCommands').CodeActionController} */
const codeActionController = editor.getControl().getContribution('editor.contrib.codeActionController');
const lightBulbNode = () => {
const ui = quickFixController['_ui'].rawValue;
const ui = codeActionController['_ui'].rawValue;
const lightBulb = ui && ui['_lightBulbWidget'].rawValue;
return lightBulb && lightBulb['_domNode'];
};
Expand All @@ -660,10 +660,12 @@ SPAN {
await waitForAnimation(() => lightBulbVisible());

await commands.executeCommand('editor.action.quickFix');
await waitForAnimation(() => !!document.querySelector('.p-Widget.p-Menu'), 5000);
const codeActionSelector = '.codeActionWidget';
assert.isFalse(!!document.querySelector(codeActionSelector), 'codeActionWidget should not be visible');

await waitForAnimation(() => !!document.querySelector(codeActionSelector), 5000);
await animationFrame();

keybindings.dispatchKeyDown('ArrowDown');
keybindings.dispatchKeyDown('Enter');

await waitForAnimation(() => currentChar() === 'd', 5000);
Expand Down Expand Up @@ -737,10 +739,10 @@ SPAN {

it('Can execute code actions', async function () {
const editor = await openEditor(demoFileUri);
/** @type {import('@theia/monaco-editor-core/src/vs/editor/contrib/codeAction/browser/codeActionCommands').QuickFixController} */
const quickFixController = editor.getControl().getContribution('editor.contrib.quickFixController');
/** @type {import('@theia/monaco-editor-core/src/vs/editor/contrib/codeAction/browser/codeActionCommands').CodeActionController} */
const codeActionController = editor.getControl().getContribution('editor.contrib.codeActionController');
const isActionAvailable = () => {
const lightbulbVisibility = quickFixController['_ui'].rawValue?.['_lightBulbWidget'].rawValue?.['_domNode'].style.visibility;
const lightbulbVisibility = codeActionController['_ui'].rawValue?.['_lightBulbWidget'].rawValue?.['_domNode'].style.visibility;
return lightbulbVisibility !== undefined && lightbulbVisibility !== 'hidden';
}
assert.isFalse(isActionAvailable());
Expand All @@ -752,23 +754,24 @@ SPAN {
assert.isTrue(isActionAvailable());

await commands.executeCommand('editor.action.quickFix');
await waitForAnimation(() => Boolean(document.querySelector('.p-Widget.p-Menu')), 5000, 'No context menu appeared. (1)');
await waitForAnimation(() => Boolean(document.querySelector('.context-view-pointerBlock')), 5000, 'No context menu appeared. (1)');
await animationFrame();

keybindings.dispatchKeyDown('ArrowDown');
keybindings.dispatchKeyDown('Enter');

assert.isNotNull(editor.getControl());
assert.isNotNull(editor.getControl().getModel());
console.log(`content: ${editor.getControl().getModel().getLineContent(30)}`);
await waitForAnimation(() => editor.getControl().getModel().getLineContent(30) === 'import * as demoDefinitionsFile from "./demo-definitions-file";', 5000, 'The namespace import did not take effect.');

editor.getControl().setSelection(new Selection(30, 1, 30, 64));
await waitForAnimation(() => isActionAvailable(), 5000, 'No code action available. (2)');

// Change it back: https://github.com/eclipse-theia/theia/issues/11059
await commands.executeCommand('editor.action.quickFix');
await waitForAnimation(() => Boolean(document.querySelector('.p-Widget.p-Menu')), 5000, 'No context menu appeared. (2)');
await waitForAnimation(() => Boolean(document.querySelector('.context-view-pointerBlock')), 5000, 'No context menu appeared. (2)');
await animationFrame();

keybindings.dispatchKeyDown('ArrowDown');
keybindings.dispatchKeyDown('Enter');

await waitForAnimation(() => editor.getControl().getModel().getLineContent(30) === 'import { DefinedInterface } from "./demo-definitions-file";', 5000, 'The named import did not take effect.');
Expand Down
7 changes: 4 additions & 3 deletions examples/playwright/src/theia-text-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,10 @@ export class TheiaTextEditor extends TheiaEditor {
}

protected replaceEditorSymbolsWithSpace(content: string): string | Promise<string | undefined> {
// [ ] &nbsp; => \u00a0
// [·] &middot; => \u00b7
return content.replace(/[\u00a0\u00b7]/g, ' ');
// [ ] &nbsp; => \u00a0 -- NO-BREAK SPACE
// [·] &middot; => \u00b7 -- MIDDLE DOT
// [] &zwnj; => \u200c -- ZERO WIDTH NON-JOINER
return content.replace(/[\u00a0\u00b7]/g, ' ').replace(/[\u200c]/g, '');
}

protected async selectedSuggestion(): Promise<ElementHandle<SVGElement | HTMLElement>> {
Expand Down
2 changes: 1 addition & 1 deletion packages/bulk-edit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"@theia/editor": "1.31.0",
"@theia/filesystem": "1.31.0",
"@theia/monaco": "1.31.0",
"@theia/monaco-editor-core": "1.67.2",
"@theia/monaco-editor-core": "1.72.3-alpha0",
"@theia/workspace": "1.31.0"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"dependencies": {
"@theia/core": "1.31.0",
"@theia/monaco": "1.31.0",
"@theia/monaco-editor-core": "1.67.2",
"@theia/monaco-editor-core": "1.72.3-alpha0",
"anser": "^2.0.1"
},
"publishConfig": {
Expand Down
10 changes: 7 additions & 3 deletions packages/core/src/browser/context-key-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ import { injectable } from 'inversify';
import { Disposable } from '../common';
import { Emitter, Event } from '../common/event';

export interface ContextKey<T> {
export type ContextKeyValue = null | undefined | boolean | number | string
| Array<null | undefined | boolean | number | string>
| Record<string, null | undefined | boolean | number | string>;

export interface ContextKey<T extends ContextKeyValue = ContextKeyValue> {
set(value: T | undefined): void;
reset(): void;
get(): T | undefined;
Expand All @@ -41,7 +45,7 @@ export const ContextKeyService = Symbol('ContextKeyService');
export interface ContextKeyService extends Disposable {
readonly onDidChange: Event<ContextKeyChangeEvent>;

createKey<T>(key: string, defaultValue: T | undefined): ContextKey<T>;
createKey<T extends ContextKeyValue>(key: string, defaultValue: T | undefined): ContextKey<T>;

/**
* Whether the expression is satisfied. If `context` provided, the service will attempt to retrieve a context object associated with that element.
Expand Down Expand Up @@ -82,7 +86,7 @@ export class ContextKeyServiceDummyImpl implements ContextKeyService {
this.onDidChangeEmitter.fire(event);
}

createKey<T>(key: string, defaultValue: T | undefined): ContextKey<T> {
createKey<T extends ContextKeyValue>(key: string, defaultValue: T | undefined): ContextKey<T> {
return ContextKey.None;
}
/**
Expand Down
12 changes: 5 additions & 7 deletions packages/core/src/browser/resource-context-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import { injectable, inject, postConstruct } from 'inversify';
import URI from '../common/uri';
import { URI as Uri } from 'vscode-uri';
import { ContextKeyService, ContextKey } from './context-key-service';
import { LanguageService } from './language-service';

Expand All @@ -29,7 +28,7 @@ export class ResourceContextKey {
@inject(ContextKeyService)
protected readonly contextKeyService: ContextKeyService;

protected resource: ContextKey<Uri>;
protected resource: ContextKey<string>;
protected resourceSchemeKey: ContextKey<string>;
protected resourceFileName: ContextKey<string>;
protected resourceExtname: ContextKey<string>;
Expand All @@ -40,7 +39,7 @@ export class ResourceContextKey {

@postConstruct()
protected init(): void {
this.resource = this.contextKeyService.createKey<Uri>('resource', undefined);
this.resource = this.contextKeyService.createKey<string>('resource', undefined);
this.resourceSchemeKey = this.contextKeyService.createKey<string>('resourceScheme', undefined);
this.resourceFileName = this.contextKeyService.createKey<string>('resourceFilename', undefined);
this.resourceExtname = this.contextKeyService.createKey<string>('resourceExtname', undefined);
Expand All @@ -50,13 +49,12 @@ export class ResourceContextKey {
this.resourceSet = this.contextKeyService.createKey<boolean>('resourceSet', false);
}

get(): URI | undefined {
const codeUri = this.resource.get();
return codeUri && new URI(codeUri);
get(): string | undefined {
return this.resource.get();
}

set(resourceUri: URI | undefined): void {
this.resource.set(resourceUri?.['codeUri']);
this.resource.set(resourceUri?.toString());
this.resourceSchemeKey.set(resourceUri?.scheme);
this.resourceFileName.set(resourceUri?.path.base);
this.resourceExtname.set(resourceUri?.path.ext);
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/browser/shell/application-shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ export class ApplicationShell extends Widget {
}

protected initFocusKeyContexts(): void {
const sideBarFocus = this.contextKeyService.createKey('sideBarFocus', false);
const panelFocus = this.contextKeyService.createKey('panelFocus', false);
const sideBarFocus = this.contextKeyService.createKey<boolean>('sideBarFocus', false);
const panelFocus = this.contextKeyService.createKey<boolean>('panelFocus', false);
const updateFocusContextKeys = () => {
const area = this.activeWidget && this.getAreaFor(this.activeWidget);
sideBarFocus.set(area === 'left');
Expand Down
2 changes: 1 addition & 1 deletion packages/debug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@theia/filesystem": "1.31.0",
"@theia/markers": "1.31.0",
"@theia/monaco": "1.31.0",
"@theia/monaco-editor-core": "1.67.2",
"@theia/monaco-editor-core": "1.72.3-alpha0",
"@theia/output": "1.31.0",
"@theia/process": "1.31.0",
"@theia/task": "1.31.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { Disposable, dispose } from '@theia/monaco-editor-core/esm/vs/base/commo
import { isAbsolute } from '@theia/monaco-editor-core/esm/vs/base/common/path';
import { Constants } from '@theia/monaco-editor-core/esm/vs/base/common/uint';
import { applyFontInfo } from '@theia/monaco-editor-core/esm/vs/editor/browser/config/domFontInfo';
import { createStringBuilder } from '@theia/monaco-editor-core/esm/vs/editor/common/core/stringBuilder';
import { StringBuilder } from '@theia/monaco-editor-core/esm/vs/editor/common/core/stringBuilder';
import { ITextModel } from '@theia/monaco-editor-core/esm/vs/editor/common/model';
import { ITextModelService } from '@theia/monaco-editor-core/esm/vs/editor/common/services/resolverService';
import { IThemeService } from '@theia/monaco-editor-core/esm/vs/platform/theme/common/themeService';
Expand Down Expand Up @@ -92,14 +92,14 @@ export class InstructionRenderer extends Disposable implements ITableRenderer<Di
column.currentElement.element = element;
const instruction = element.instruction;
column.sourcecode.innerText = '';
const sb = createStringBuilder(1000);
const sb = new StringBuilder(1000);

if (this._disassemblyView.isSourceCodeRender && instruction.location?.path && instruction.line) {
const sourceURI = this.getUriFromSource(instruction);

if (sourceURI) {
let textModel: ITextModel | undefined = undefined;
const sourceSB = createStringBuilder(10000);
const sourceSB = new StringBuilder(10000);
const ref = await this.textModelService.createModelReference(sourceURI);
textModel = ref.object.textEditorModel;
column.cellDisposable.push(ref);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ export class DebugBreakpointWidget implements Disposable {
}
}
}];
(this._input.getControl() as unknown as StandaloneCodeEditor).setDecorations('Debug breakpoint placeholder', DebugBreakpointWidget.PLACEHOLDER_DECORATION, decorations);
(this._input.getControl() as unknown as StandaloneCodeEditor)
.setDecorationsByType('Debug breakpoint placeholder', DebugBreakpointWidget.PLACEHOLDER_DECORATION, decorations);
}
protected get placeholder(): string {
if (this.context === 'logMessage') {
Expand Down
4 changes: 2 additions & 2 deletions packages/debug/src/browser/editor/debug-editor-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ export class DebugEditorModel implements Disposable {
this.createInlineValueDecorations()
]);
const codeEditor = this.editor.getControl() as unknown as StandaloneCodeEditor;
codeEditor.removeDecorations(INLINE_VALUE_DECORATION_KEY);
codeEditor.setDecorations('Inline debug decorations', INLINE_VALUE_DECORATION_KEY, inlineValueDecorations);
codeEditor.removeDecorations([INLINE_VALUE_DECORATION_KEY]);
codeEditor.setDecorationsByType('Inline debug decorations', INLINE_VALUE_DECORATION_KEY, inlineValueDecorations);
this.editorDecorations = this.deltaDecorations(this.editorDecorations, newFrameDecorations);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import * as monaco from '@theia/monaco-editor-core';
import { CancellationTokenSource } from '@theia/monaco-editor-core/esm/vs/base/common/cancellation';
import { DEFAULT_WORD_REGEXP } from '@theia/monaco-editor-core/esm/vs/editor/common/core/wordHelper';
import { IDecorationOptions } from '@theia/monaco-editor-core/esm/vs/editor/common/editorCommon';
import { InlineValueContext, StandardTokenType } from '@theia/monaco-editor-core/esm/vs/editor/common/languages';
import { StandardTokenType } from '@theia/monaco-editor-core/esm/vs/editor/common/encodedTokenAttributes';
import { InlineValueContext } from '@theia/monaco-editor-core/esm/vs/editor/common/languages';
import { ITextModel } from '@theia/monaco-editor-core/esm/vs/editor/common/model';
import { ILanguageFeaturesService } from '@theia/monaco-editor-core/esm/vs/editor/common/services/languageFeatures';
import { StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
Expand Down
Loading

0 comments on commit 562bd7e

Please sign in to comment.