Skip to content

Commit

Permalink
update monaco to v0.12.0
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Tugarev <[email protected]>
  • Loading branch information
AlexTugarev committed Apr 27, 2018
1 parent 7e9b208 commit f684585
Show file tree
Hide file tree
Showing 17 changed files with 1,168 additions and 1,188 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const { mode } = yargs.option('mode', {
const development = mode === 'development';${this.ifMonaco(() => `
const monacoEditorPath = development ? '${this.resolve('monaco-editor-core', 'dev/vs')}' : '${this.resolve('monaco-editor-core', 'min/vs')}';
const monacoLanguagesPath = '${this.resolve('monaco-languages', 'release')}';
const monacoLanguagesPath = '${this.resolve('monaco-languages', 'release/min')}';
const monacoCssLanguagePath = '${this.resolve('monaco-css', 'release/min')}';
const monacoJsonLanguagePath = '${this.resolve('monaco-json', 'release/min')}';
const monacoHtmlLanguagePath = '${this.resolve('monaco-html', 'release/min')}';`)}
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/browser/editor-decorations-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export namespace EditorDecorationStyle {
const index = styleSheet.insertRule('.' + selector + '{}', 0);
const rules = styleSheet.cssRules || styleSheet.rules;
const rule = rules.item(index);
if (rule.type === CSSRule.STYLE_RULE) {
if (rule && rule.type === CSSRule.STYLE_RULE) {
const styleRule = rule as CSSStyleRule;
styleProvider(styleRule.style);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ export class EditorconfigDocumentManager {

if (line.length !== trimmedLine.length) {
edits.push({
identifier: undefined!,
forceMoveMarkers: false,
range: new monaco.Range(i, trimmedLine.length + 1, i, line.length + 1),
text: ""
Expand Down Expand Up @@ -268,7 +267,6 @@ export class EditorconfigDocumentManager {

if ("" !== lineContent) {
return {
identifier: undefined!,
forceMoveMarkers: false,
range: new monaco.Range(lines, lineContent.length + 1, lines, lineContent.length + 1),
text: lineEnding
Expand Down
2 changes: 1 addition & 1 deletion packages/languages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"@theia/core": "^0.3.8",
"@theia/output": "^0.3.8",
"@theia/process": "^0.3.8",
"vscode-base-languageclient": "^0.0.1-alpha.3",
"vscode-base-languageclient": "^0.0.1-alpha.5",
"vscode-languageserver-protocol": "^3.6.0"
},
"publishConfig": {
Expand Down
10 changes: 5 additions & 5 deletions packages/monaco/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"@theia/markers": "^0.3.8",
"@theia/outline-view": "^0.3.8",
"@theia/workspace": "^0.3.8",
"monaco-css": "^1.3.3",
"monaco-html": "^1.3.2",
"monaco-json": "^1.3.2",
"monaco-languageclient": "^0.4.0",
"monaco-languages": "^0.9.0"
"monaco-css": "^2.0.1",
"monaco-html": "^2.0.2",
"monaco-json": "^2.0.1",
"monaco-languageclient": "0.6.3",
"monaco-languages": "^1.0.4"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/monaco/src/browser/monaco-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export namespace MonacoCommands {
iconClasses.set(menuItem.command.id, menuItem.command.iconClass);
}
}
for (const command of monaco.editorCommonExtensions.CommonEditorRegistry.getEditorActions()) {
for (const command of monaco.editorExtensions.EditorExtensionsRegistry.getEditorActions()) {
const id = command.id;
if (!EXCLUDE_ACTIONS.has(id)) {
const label = command.label;
Expand Down
2 changes: 1 addition & 1 deletion packages/monaco/src/browser/monaco-diff-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class MonacoDiffEditor extends MonacoEditor {
}

isActionSupported(id: string): boolean {
const action = this._diffEditor.getActions().find(a => a.id === id);
const action = this._diffEditor.getSupportedActions().find(a => a.id === id);
return !!action && action.isSupported() && super.isActionSupported(id);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class MonacoDiffNavigatorFactory {
const navigator = monaco.editor.createDiffNavigator(editor, options);
const ensureInitialized = (fwd: boolean) => {
if (navigator.nextIdx < -1) {
navigator.initIdx(fwd);
navigator._initIdx(fwd);
}
};
return <DiffNavigator>{
Expand Down
10 changes: 6 additions & 4 deletions packages/monaco/src/browser/monaco-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export class MonacoEditor implements TextEditor, IEditorReference {
protected create(options?: IEditorConstructionOptions, override?: monaco.editor.IEditorOverrideServices): Disposable {
return this.editor = monaco.editor.create(this.node, {
...options,
lightbulb: { enabled: true },
fixedOverflowWidgets: true,
scrollbar: {
useShadows: false,
Expand Down Expand Up @@ -149,14 +150,14 @@ export class MonacoEditor implements TextEditor, IEditorReference {
return this.onSelectionChangedEmitter.event;
}

revealPosition(raw: Position, options: RevealPositionOptions = { vertical: 'center', horizontal: true }): void {
revealPosition(raw: Position, options: RevealPositionOptions = { vertical: 'center' }): void {
const position = this.p2m.asPosition(raw);
switch (options.vertical) {
case 'auto':
this.editor.revealPosition(position, false, options.horizontal);
this.editor.revealPosition(position);
break;
case 'center':
this.editor.revealPosition(position, true, options.horizontal);
this.editor.revealPositionInCenter(position);
break;
case 'centerIfOutsideViewport':
this.editor.revealPositionInCenterIfOutsideViewport(position);
Expand Down Expand Up @@ -204,7 +205,8 @@ export class MonacoEditor implements TextEditor, IEditorReference {
* `true` if the suggest widget is visible in the editor. Otherwise, `false`.
*/
isSuggestWidgetVisible(): boolean {
return this.editor.getContribution<SuggestController>('editor.contrib.suggestController')._widget.suggestWidgetVisible.get();
const widget = this.editor.getContribution<SuggestController>('editor.contrib.suggestController')._widget;
return widget ? widget.suggestWidgetVisible.get() : false;
}

/**
Expand Down
14 changes: 7 additions & 7 deletions packages/monaco/src/browser/monaco-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function loadMonaco(vsRequire: any): Promise<void> {
return new Promise<void>(resolve => {
vsRequire(["vs/editor/editor.main"], () => {
vsRequire([
'vs/basic-languages/src/monaco.contribution',
'vs/basic-languages/monaco.contribution',
'vs/language/css/monaco.contribution',
'vs/language/html/monaco.contribution',
'vs/language/json/monaco.contribution',
Expand All @@ -45,7 +45,7 @@ export function loadMonaco(vsRequire: any): Promise<void> {
'vs/platform/keybinding/common/keybindingResolver',
'vs/platform/keybinding/common/usLayoutResolvedKeybinding',
'vs/base/common/keyCodes',
'vs/editor/common/editorCommonExtensions',
'vs/editor/browser/editorExtensions',
'vs/editor/standalone/browser/simpleServices',
'vs/editor/standalone/browser/standaloneServices',
'vs/base/parts/quickopen/common/quickOpen',
Expand All @@ -56,11 +56,11 @@ export function loadMonaco(vsRequire: any): Promise<void> {
'vs/base/common/platform',
'vs/editor/common/modes',
'vs/base/common/cancellation',
'vs/editor/contrib/suggest/browser/suggestController',
'vs/editor/contrib/find/common/findController',
'vs/editor/contrib/rename/browser/rename',
'vs/editor/contrib/suggest/suggestController',
'vs/editor/contrib/find/findController',
'vs/editor/contrib/rename/rename',
], (basic: any, css: any, html: any, json: any, commands: any, actions: any, registry: any, resolver: any, resolvedKeybinding: any,
keyCodes: any, editorCommonExtensions: any, simpleServices: any, standaloneServices: any, quickOpen: any, quickOpenWidget: any, quickOpenModel: any,
keyCodes: any, editorExtensions: any, simpleServices: any, standaloneServices: any, quickOpen: any, quickOpenWidget: any, quickOpenModel: any,
filters: any, styler: any, platform: any, modes: any, cancellation: any, suggestController: any, findController: any, rename: any) => {
const global: any = self;
global.monaco.commands = commands;
Expand All @@ -71,7 +71,7 @@ export function loadMonaco(vsRequire: any): Promise<void> {
global.monaco.filters = filters;
global.monaco.theme = styler;
global.monaco.platform = platform;
global.monaco.editorCommonExtensions = editorCommonExtensions;
global.monaco.editorExtensions = editorExtensions;
global.monaco.modes = modes;
global.monaco.cancellation = cancellation;
global.monaco.suggestController = suggestController;
Expand Down
2 changes: 0 additions & 2 deletions packages/monaco/src/browser/monaco-status-bar-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { injectable, inject } from 'inversify';
import { DisposableCollection } from '@theia/core';
import { FrontendApplicationContribution, FrontendApplication, StatusBar, StatusBarAlignment } from '@theia/core/lib/browser';
import { EditorCommands, EditorManager, EditorWidget } from '@theia/editor/lib/browser';
import { OutlineViewService } from '@theia/outline-view/lib/browser/outline-view-service';
import { MonacoEditor } from './monaco-editor';

@injectable()
Expand All @@ -18,7 +17,6 @@ export class MonacoStatusBarContribution implements FrontendApplicationContribut
protected readonly toDispose = new DisposableCollection();

constructor(
@inject(OutlineViewService) protected readonly outlineViewService: OutlineViewService,
@inject(EditorManager) protected readonly editorManager: EditorManager,
@inject(StatusBar) protected readonly statusBar: StatusBar
) { }
Expand Down
9 changes: 5 additions & 4 deletions packages/monaco/src/browser/monaco-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export class MonacoWorkspace implements lang.Workspace {
identifier: undefined!,
forceMoveMarkers: false,
range: new monaco.Range(edit.range.startLineNumber, edit.range.startColumn, edit.range.endLineNumber, edit.range.endColumn),
text: edit.newText
text: edit.text
}));
// start a fresh operation
model.pushStackElement();
Expand All @@ -226,11 +226,12 @@ export class MonacoWorkspace implements lang.Workspace {
}

protected groupEdits(workspaceEdit: monaco.languages.WorkspaceEdit) {
const result = new Map<string, monaco.languages.IResourceEdit[]>();
const result = new Map<string, monaco.languages.TextEdit[]>();
for (const edit of workspaceEdit.edits) {
const uri = edit.resource.toString();
const resourceTextEdit = edit as monaco.languages.ResourceTextEdit;
const uri = resourceTextEdit.resource.toString();
const edits = result.get(uri) || [];
edits.push(edit);
edits.push(...resourceTextEdit.edits);
result.set(uri, edits);
}
return result;
Expand Down
33 changes: 23 additions & 10 deletions packages/monaco/src/typings/monaco/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* Copyright (C) 2018 TypeFox and others.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/

/// <reference types='monaco-editor-core/monaco'/>

declare module monaco.instantiation {
Expand All @@ -10,14 +17,18 @@ declare module monaco.editor {
export interface IDiffNavigator {
readonly ranges: IDiffRange[];
readonly nextIdx: number;
initIdx(fwd: boolean): void;
readonly revealFirst: boolean;
_initIdx(fwd: boolean): void;
}

export interface IDiffRange {
readonly range: Range;
}

export interface ICommonCodeEditor {
export interface IStandaloneCodeEditor extends CommonCodeEditor {
}

export interface CommonCodeEditor {
readonly _commandService: monaco.commands.ICommandService;
readonly _instantiationService: monaco.instantiation.IInstantiationService;
readonly _contributions: {
Expand Down Expand Up @@ -62,7 +73,7 @@ declare module monaco.editor {
}

export interface IEditorReference {
getControl(): monaco.editor.ICommonCodeEditor;
getControl(): monaco.editor.CommonCodeEditor;
}

export interface IEditorInput {
Expand Down Expand Up @@ -547,15 +558,15 @@ declare module monaco.filters {
export function matchesFuzzy(word: string, wordToMatchAgainst: string, enableSeparateSubstringMatching?: boolean): IMatch[] | undefined;
}

declare module monaco.editorCommonExtensions {
declare module monaco.editorExtensions {

export interface EditorAction {
id: string;
label: string;
alias: string;
}

export module CommonEditorRegistry {
export module EditorExtensionsRegistry {
export function getEditorActions(): EditorAction[];
}
}
Expand Down Expand Up @@ -621,6 +632,12 @@ declare module monaco.cancellation {

declare module monaco.suggestController {

export class SuggestWidget {
suggestWidgetVisible: {
get(): boolean;
};
}

export class SuggestController {

getId(): string;
Expand All @@ -629,11 +646,7 @@ declare module monaco.suggestController {
/**
* This is a hack. The widget has a `private` visibility in the VSCode source.
*/
readonly _widget: {
suggestWidgetVisible: {
get(): boolean;
};
};
readonly _widget: SuggestWidget | undefined;

}

Expand Down
2 changes: 1 addition & 1 deletion packages/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"@theia/core": "^0.3.8",
"@theia/languages": "^0.3.8",
"@theia/monaco": "^0.3.8",
"monaco-typescript": "^2.3.0",
"monaco-typescript": "^3.0.2",
"typescript-language-server": "^0.1.11"
},
"publishConfig": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// tslint:disable:no-var-keyword
// tslint:disable:one-variable-per-declaration
// tslint:disable:prefer-const
import ts = require('monaco-typescript/release/lib/typescriptServices');
import ts = require('monaco-typescript/release/min/lib/typescriptServices');

export enum Language {
TypeScript,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/
declare module 'monaco-typescript/release/lib/typescriptServices';
declare module 'monaco-typescript/release/min/lib/typescriptServices';
Loading

0 comments on commit f684585

Please sign in to comment.