Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrading to LSP 5.3.0 and Monaco 0.17.0 #5901

Merged
merged 2 commits into from
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions dev-packages/application-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@
"test": "theiaext test"
},
"dependencies": {
"@babel/core": "^7.5.5",
"@babel/plugin-transform-classes": "^7.5.5",
"@babel/plugin-transform-runtime": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"@theia/application-package": "^0.10.0",
"@types/fs-extra": "^4.0.2",
"babel-loader": "^8.0.6",
"bunyan": "^1.8.10",
"circular-dependency-plugin": "^5.0.0",
"copy-webpack-plugin": "^4.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,26 @@ module.exports = {
test: /\\.plist$/,
loader: "file-loader",
},
{
test: /\\.js$/,
// include only es6 dependencies to transpile them to es5 classes
include: /monaco-languageclient|vscode-ws-jsonrpc|vscode-jsonrpc|vscode-languageserver-protocol|vscode-languageserver-types|vscode-languageclient/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: [
// reuse runtime babel lib instead of generating it in each js file
'@babel/plugin-transform-runtime',
// ensure that classes are transpiled
'@babel/plugin-transform-classes'
],
// see https://github.com/babel/babel/issues/8900#issuecomment-431240426
sourceType: 'unambiguous',
cacheDirectory: true
}
}
}
]
},
resolve: {
Expand Down
10 changes: 7 additions & 3 deletions packages/callhierarchy/src/browser/callhierarchy-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { ILanguageClient } from '@theia/languages/lib/browser';
import {
ReferencesRequest, DocumentSymbolRequest, DefinitionRequest, TextDocumentPositionParams,
TextDocumentIdentifier, SymbolInformation, Location, Position, DocumentSymbol, ReferenceParams
TextDocumentIdentifier, SymbolInformation, Location, Position, DocumentSymbol, ReferenceParams, LocationLink
} from 'monaco-languageclient/lib/services';
import * as utils from './utils';
import { ILogger, Disposable } from '@theia/core';
Expand Down Expand Up @@ -59,7 +59,7 @@ export class CallHierarchyContext implements Disposable {

// Definition can be null
// tslint:disable-next-line:no-null-keyword
let locations: Location | Location[] | null = null;
let locations: Location | Location[] | LocationLink[] | null = null;
try {
locations = await this.languageClient.sendRequest(DefinitionRequest.type, <TextDocumentPositionParams>{
position: Position.create(line, character),
Expand All @@ -71,7 +71,11 @@ export class CallHierarchyContext implements Disposable {
if (!locations) {
return undefined;
}
return Array.isArray(locations) ? locations[0] : locations;
const targetLocation = Array.isArray(locations) ? locations[0] : locations;
return LocationLink.is(targetLocation) ? {
uri: targetLocation.targetUri,
range: targetLocation.targetSelectionRange
} : targetLocation;
}

async getCallerReferences(definition: Location): Promise<Location[]> {
Expand Down
6 changes: 3 additions & 3 deletions packages/console/src/browser/console-keybinding-contexts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class ConsoleNavigationBackEnabled extends ConsoleInputFocusContext {
return false;
}
const editor = console.input.getControl();
return editor.getPosition().equals({ lineNumber: 1, column: 1 });
return editor.getPosition()!.equals({ lineNumber: 1, column: 1 });
}

}
Expand All @@ -98,10 +98,10 @@ export class ConsoleNavigationForwardEnabled extends ConsoleInputFocusContext {
return false;
}
const editor = console.input.getControl();
const model = console.input.getControl().getModel();
const model = console.input.getControl().getModel()!;
const lineNumber = model.getLineCount();
const column = model.getLineMaxColumn(lineNumber);
return editor.getPosition().equals({ lineNumber, column });
return editor.getPosition()!.equals({ lineNumber, column });
}

}
4 changes: 2 additions & 2 deletions packages/console/src/browser/console-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ export class ConsoleWidget extends BaseWidget implements StatefulWidget {
const value = this.history.next || '';
const editor = this.input.getControl();
editor.setValue(value);
const lineNumber = editor.getModel().getLineCount();
const column = editor.getModel().getLineMaxColumn(lineNumber);
const lineNumber = editor.getModel()!.getLineCount();
const column = editor.getModel()!.getLineMaxColumn(lineNumber);
editor.setPosition({ lineNumber, column });
}

Expand Down
5 changes: 3 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"main": "lib/common/index.js",
"typings": "lib/common/index.d.ts",
"dependencies": {
"@babel/runtime": "^7.5.5",
"@phosphor/widgets": "^1.5.0",
"@primer/octicons-react": "^9.0.0",
"@theia/application-package": "^0.10.0",
Expand Down Expand Up @@ -39,9 +40,9 @@
"reconnecting-websocket": "^3.0.7",
"reflect-metadata": "^0.1.10",
"route-parser": "^0.0.5",
"vscode-languageserver-types": "^3.10.0",
"vscode-languageserver-types": "^3.15.0-next",
"vscode-uri": "^1.0.8",
"vscode-ws-jsonrpc": "^0.0.2-1",
"vscode-ws-jsonrpc": "^0.1.1",
"ws": "^5.2.2",
"yargs": "^11.1.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/browser/keybinding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export class KeybindingRegistry {
containsKeybinding(bindings: Keybinding[], binding: Keybinding): boolean {
const bindingKeySequence = this.resolveKeybinding(binding);
const collisions = this.getKeySequenceCollisions(bindings, bindingKeySequence)
.filter(b => b.context === binding.context);
.filter(b => b.context === binding.context && !b.when && !binding.when);

if (collisions.full.length > 0) {
this.logger.warn('Collided keybinding is ignored; ',
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/node/messaging/ipc-bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const writer = new IPCMessageWriter(process);
const logger = new ConsoleLogger();
const connection = createMessageConnection(reader, writer, logger);
connection.trace(Trace.Off, {
log: (message, data) => console.log(`${message} ${data}`)
// tslint:disable-next-line:no-any
log: (message: any, data?: string) => console.log(message, data)
});

const entryPoint = require(ipcEntryPoint!).default as IPCEntryPoint;
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/node/messaging/ipc-connection-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ export class IPCConnectionProvider {
log: (message: string) => this.logger.info(`[${options.serverName}: ${childProcess.pid}] ${message}`)
});
connection.trace(Trace.Off, {
log: (message, data) => this.logger.info(`[${options.serverName}: ${childProcess.pid}] ${message} ${data}`)
// tslint:disable-next-line:no-any
log: (message: any, data?: string) => this.logger.info(`[${options.serverName}: ${childProcess.pid}] ${message}` + (typeof data === 'string' ? ' ' + data : ''))
});
return connection;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/debug/src/browser/debug-configuration-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export class DebugConfigurationManager {
},
onArrayBegin: offset => {
if (lastProperty === 'configurations' && depthInArray === 0) {
position = editor.getModel().getPositionAt(offset + 1);
position = editor.getModel()!.getPositionAt(offset + 1);
}
depthInArray++;
},
Expand All @@ -220,12 +220,12 @@ export class DebugConfigurationManager {
return;
}
// Check if there are more characters on a line after a "configurations": [, if yes enter a newline
if (editor.getModel().getLineLastNonWhitespaceColumn(position.lineNumber) > position.column) {
if (editor.getModel()!.getLineLastNonWhitespaceColumn(position.lineNumber) > position.column) {
editor.setPosition(position);
editor.trigger('debug', 'lineBreakInsert', undefined);
}
// Check if there is already an empty line to insert suggest, if yes just place the cursor
if (editor.getModel().getLineLastNonWhitespaceColumn(position.lineNumber + 1) === 0) {
if (editor.getModel()!.getLineLastNonWhitespaceColumn(position.lineNumber + 1) === 0) {
editor.setPosition({ lineNumber: position.lineNumber + 1, column: 1 << 30 });
await commandService.executeCommand('editor.action.deleteLines');
}
Expand Down
34 changes: 23 additions & 11 deletions packages/debug/src/browser/editor/debug-breakpoint-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,39 @@ export class DebugBreakpointWidget implements Disposable {
return;
}
this.toDispose.push(input);
this.toDispose.push(monaco.modes.SuggestRegistry.register({ scheme: input.uri.scheme }, {
this.toDispose.push(monaco.modes.CompletionProviderRegistry.register({ scheme: input.uri.scheme }, {
provideCompletionItems: async (model, position, context, token) => {
const suggestions = [];
if ((this.context === 'condition' || this.context === 'logMessage')
&& input.uri.toString() === model.uri.toString()) {
const editor = this.editor.getControl();
const items = await monaco.suggest.provideSuggestionItems(
editor.getModel(),
new monaco.Position(editor.getPosition().lineNumber, 1),
'none', undefined, context, token);
for (const { suggestion } of items) {
suggestion.overwriteAfter = 0;
suggestion.overwriteBefore = position.column - 1;
suggestions.push(suggestion);
editor.getModel()!,
new monaco.Position(editor.getPosition()!.lineNumber, 1),
new monaco.suggest.CompletionOptions(undefined, new Set<monaco.languages.CompletionItemKind>().add(monaco.languages.CompletionItemKind.Snippet)),
context, token);
let overwriteBefore = 0;
if (this.context === 'condition') {
overwriteBefore = position.column - 1;
} else {
// Inside the currly brackets, need to count how many useful characters are behind the position so they would all be taken into account
const value = editor.getModel()!.getValue();
while ((position.column - 2 - overwriteBefore >= 0)
&& value[position.column - 2 - overwriteBefore] !== '{' && value[position.column - 2 - overwriteBefore] !== ' ') {
overwriteBefore++;
}
}
for (const { completion } of items) {
completion.range = monaco.Range.fromPositions(position.delta(0, -overwriteBefore), position);
suggestions.push(completion);
}
}
return { suggestions };
}
}));
this.toDispose.push(this.zone.onDidLayoutChange(dimension => this.layout(dimension)));
this.toDispose.push(input.getControl().onDidChangeModelContent(() => {
const heightInLines = input.getControl().getModel().getLineCount() + 1;
const heightInLines = input.getControl().getModel()!.getLineCount() + 1;
this.zone.layout(heightInLines);
this.updatePlaceholder();
}));
Expand Down Expand Up @@ -152,9 +163,9 @@ export class DebugBreakpointWidget implements Disposable {
const afterLineNumber = breakpoint ? breakpoint.line : position!.lineNumber;
const afterColumn = breakpoint ? breakpoint.column : position!.column;
const editor = this._input.getControl();
const heightInLines = editor.getModel().getLineCount() + 1;
const heightInLines = editor.getModel()!.getLineCount() + 1;
this.zone.show({ afterLineNumber, afterColumn, heightInLines, frameWidth: 1 });
editor.setPosition(editor.getModel().getPositionAt(editor.getModel().getValueLength()));
editor.setPosition(editor.getModel()!.getPositionAt(editor.getModel()!.getValueLength()));
this._input.focus();
}

Expand Down Expand Up @@ -207,6 +218,7 @@ export class DebugBreakpointWidget implements Disposable {
}
const value = this._input.getControl().getValue();
const decorations: monaco.editor.IDecorationOptions[] = !!value ? [] : [{
color: undefined,
range: {
startLineNumber: 0,
endLineNumber: 0,
Expand Down
26 changes: 13 additions & 13 deletions packages/debug/src/browser/editor/debug-editor-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ export class DebugEditorModel implements Disposable {

@postConstruct()
protected init(): void {
this.uri = new URI(this.editor.getControl().getModel().uri.toString());
this.uri = new URI(this.editor.getControl().getModel()!.uri.toString());
this.toDispose.pushAll([
this.hover,
this.breakpointWidget,
this.editor.getControl().onMouseDown(event => this.handleMouseDown(event)),
this.editor.getControl().onMouseMove(event => this.handleMouseMove(event)),
this.editor.getControl().onMouseLeave(event => this.handleMouseLeave(event)),
this.editor.getControl().onKeyDown(() => this.hover.hide({ immediate: false })),
this.editor.getControl().getModel().onDidChangeDecorations(() => this.updateBreakpoints()),
this.editor.getControl().getModel()!.onDidChangeDecorations(() => this.updateBreakpoints()),
this.sessions.onDidChange(() => this.renderFrames())
]);
this.renderFrames();
Expand Down Expand Up @@ -176,7 +176,7 @@ export class DebugEditorModel implements Disposable {
protected updateBreakpointRanges(): void {
this.breakpointRanges.clear();
for (const decoration of this.breakpointDecorations) {
const range = this.editor.getControl().getModel().getDecorationRange(decoration);
const range = this.editor.getControl().getModel()!.getDecorationRange(decoration)!;
this.breakpointRanges.set(decoration, range);
}
}
Expand Down Expand Up @@ -214,7 +214,7 @@ export class DebugEditorModel implements Disposable {
return false;
}
for (const decoration of this.breakpointDecorations) {
const range = this.editor.getControl().getModel().getDecorationRange(decoration);
const range = this.editor.getControl().getModel()!.getDecorationRange(decoration);
const oldRange = this.breakpointRanges.get(decoration)!;
if (!range || !range.equalsRange(oldRange)) {
return true;
Expand All @@ -227,7 +227,7 @@ export class DebugEditorModel implements Disposable {
const lines = new Set<number>();
const breakpoints: SourceBreakpoint[] = [];
for (const decoration of this.breakpointDecorations) {
const range = this.editor.getControl().getModel().getDecorationRange(decoration);
const range = this.editor.getControl().getModel()!.getDecorationRange(decoration);
if (range && !lines.has(range.startLineNumber)) {
const line = range.startLineNumber;
const oldRange = this.breakpointRanges.get(decoration);
Expand All @@ -242,7 +242,7 @@ export class DebugEditorModel implements Disposable {

protected _position: monaco.Position | undefined;
get position(): monaco.Position {
return this._position || this.editor.getControl().getPosition();
return this._position || this.editor.getControl().getPosition()!;
}
get breakpoint(): DebugBreakpoint | undefined {
return this.getBreakpoint();
Expand Down Expand Up @@ -285,12 +285,12 @@ export class DebugEditorModel implements Disposable {
protected handleMouseDown(event: monaco.editor.IEditorMouseEvent): void {
if (event.target && event.target.type === monaco.editor.MouseTargetType.GUTTER_GLYPH_MARGIN) {
if (event.event.rightButton) {
this._position = event.target.position;
this._position = event.target.position!;
this.contextMenu.render(DebugEditorModel.CONTEXT_MENU, event.event.browserEvent, () =>
setTimeout(() => this._position = undefined)
);
} else {
this.doToggleBreakpoint(event.target.position);
this.doToggleBreakpoint(event.target.position!);
}
}
this.hintBreakpoint(event);
Expand All @@ -299,7 +299,7 @@ export class DebugEditorModel implements Disposable {
this.showHover(event);
this.hintBreakpoint(event);
}
protected handleMouseLeave(event: monaco.editor.IEditorMouseEvent): void {
protected handleMouseLeave(event: monaco.editor.IPartialEditorMouseEvent): void {
this.hideHover(event);
this.deltaHintDecorations([]);
}
Expand All @@ -313,7 +313,7 @@ export class DebugEditorModel implements Disposable {
this.hintDecorations = this.deltaDecorations(this.hintDecorations, hintDecorations);
}
protected createHintDecorations(event: monaco.editor.IEditorMouseEvent): monaco.editor.IModelDeltaDecoration[] {
if (event.target && event.target.type === monaco.editor.MouseTargetType.GUTTER_GLYPH_MARGIN) {
if (event.target && event.target.type === monaco.editor.MouseTargetType.GUTTER_GLYPH_MARGIN && event.target.position) {
const lineNumber = event.target.position.lineNumber;
if (!!this.sessions.getBreakpoint(this.uri, lineNumber)) {
return [];
Expand All @@ -337,14 +337,14 @@ export class DebugEditorModel implements Disposable {
}
if (targetType === monaco.editor.MouseTargetType.CONTENT_TEXT) {
this.hover.show({
selection: mouseEvent.target.range,
selection: mouseEvent.target.range!,
immediate: false
});
} else {
this.hover.hide({ immediate: false });
}
}
protected hideHover({ event }: monaco.editor.IEditorMouseEvent): void {
protected hideHover({ event }: monaco.editor.IPartialEditorMouseEvent): void {
const rect = this.hover.getDomNode().getBoundingClientRect();
if (event.posx < rect.left || event.posx > rect.right || event.posy < rect.top || event.posy > rect.bottom) {
this.hover.hide({ immediate: false });
Expand All @@ -354,7 +354,7 @@ export class DebugEditorModel implements Disposable {
protected deltaDecorations(oldDecorations: string[], newDecorations: monaco.editor.IModelDeltaDecoration[]): string[] {
this.updatingDecorations = true;
try {
return this.editor.getControl().getModel().deltaDecorations(oldDecorations, newDecorations);
return this.editor.getControl().getModel()!.deltaDecorations(oldDecorations, newDecorations);
} finally {
this.updatingDecorations = false;
}
Expand Down
8 changes: 4 additions & 4 deletions packages/debug/src/browser/editor/debug-editor-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class DebugEditorService {
if (!(editor instanceof MonacoEditor)) {
return;
}
const uri = editor.getControl().getModel().uri.toString();
const uri = editor.getControl().getModel()!.uri.toString();
const debugModel = this.factory(editor);
this.models.set(uri, debugModel);
editor.getControl().onDidDispose(() => {
Expand Down Expand Up @@ -122,15 +122,15 @@ export class DebugEditorService {
showHover(): void {
const { model } = this;
if (model) {
const selection = model.editor.getControl().getSelection();
const selection = model.editor.getControl().getSelection()!;
model.hover.show({ selection, focus: true });
}
}
canShowHover(): boolean {
const { model } = this;
if (model) {
const selection = model.editor.getControl().getSelection();
return !!model.editor.getControl().getModel().getWordAtPosition(selection.getStartPosition());
const selection = model.editor.getControl().getSelection()!;
return !!model.editor.getControl().getModel()!.getWordAtPosition(selection.getStartPosition());
}
return false;
}
Expand Down
Loading