Skip to content

Commit 95c9925

Browse files
authored
Merge pull request #199 from TypeFox/bumpMonacoVersion
Bump monaco version
2 parents bc8b38c + 6590ed7 commit 95c9925

12 files changed

Lines changed: 378 additions & 112 deletions

client/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"author": "TypeFox GmbH (http://www.typefox.io)",
66
"license": "MIT",
77
"engines": {
8-
"vscode": "^1.33.0"
8+
"vscode": "^1.41.0"
99
},
1010
"repository": {
1111
"type": "git",
@@ -18,9 +18,9 @@
1818
"typings": "./lib/index",
1919
"dependencies": {
2020
"glob-to-regexp": "^0.3.0",
21-
"vscode-jsonrpc": "^4.1.0-next",
22-
"vscode-languageclient": "^5.3.0-next",
23-
"vscode-uri": "^1.0.5"
21+
"vscode-jsonrpc": "^5.0.0",
22+
"vscode-languageclient": "^6.0.0",
23+
"vscode-uri": "^1.0.8"
2424
},
2525
"scripts": {
2626
"prepare": "yarn run clean && yarn run compile",

client/src/monaco-converter.ts

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
CompletionParams, CompletionContext, CompletionTriggerKind,
1414
InsertTextFormat, Range, Diagnostic, CompletionItemKind,
1515
Hover, SignatureHelp, SignatureInformation, ParameterInformation,
16-
Definition, Location, DocumentHighlight, DocumentHighlightKind,
16+
Definition, DefinitionLink, Location, LocationLink, DocumentHighlight, DocumentHighlightKind,
1717
SymbolInformation, DocumentSymbolParams, CodeActionContext, DiagnosticSeverity,
1818
Command, CodeLens, FormattingOptions, TextEdit, WorkspaceEdit, DocumentLinkParams, DocumentLink,
1919
MarkedString, MarkupContent, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind,
@@ -56,6 +56,12 @@ export namespace ProtocolCompletionItem {
5656
}
5757
}
5858

59+
type RangeReplace = { insert: monaco.IRange; replace: monaco.IRange}
60+
61+
function isRangeReplace(v: Partial<monaco.IRange> | RangeReplace) : v is RangeReplace {
62+
return (v as RangeReplace).insert !== undefined;
63+
}
64+
5965
export class MonacoToProtocolConverter {
6066
asPosition(lineNumber: undefined | null, column: undefined | null): {};
6167
asPosition(lineNumber: number, column: undefined | null): Pick<Position, 'line'>;
@@ -75,21 +81,28 @@ export class MonacoToProtocolConverter {
7581
asRange(range: monaco.IRange): Range;
7682
asRange(range: monaco.IRange | undefined): Range | undefined;
7783
asRange(range: monaco.IRange | null): Range | null;
84+
asRange(range: monaco.IRange | { insert: monaco.IRange; replace: monaco.IRange}) : Range;
7885
asRange(range: Partial<monaco.IRange>): RecursivePartial<Range>;
7986
asRange(range: Partial<monaco.IRange> | undefined): RecursivePartial<Range> | undefined;
8087
asRange(range: Partial<monaco.IRange> | null): RecursivePartial<Range> | null;
81-
asRange(range: Partial<monaco.IRange> | undefined | null): RecursivePartial<Range> | undefined | null {
88+
asRange(range: Partial<monaco.IRange> | undefined | null | RangeReplace): RecursivePartial<Range> | undefined | null {
8289
if (range === undefined) {
8390
return undefined;
8491
}
8592
if (range === null) {
8693
return null;
8794
}
88-
const start = this.asPosition(range.startLineNumber, range.startColumn);
89-
const end = this.asPosition(range.endLineNumber, range.endColumn);
90-
return {
91-
start, end
92-
};
95+
96+
if (isRangeReplace(range)) {
97+
return this.asRange(range.insert);
98+
99+
} else {
100+
const start = this.asPosition(range.startLineNumber, range.startColumn);
101+
const end = this.asPosition(range.endLineNumber, range.endColumn);
102+
return {
103+
start, end
104+
};
105+
}
93106
}
94107

95108
asTextDocumentIdentifier(model: IReadOnlyModel): TextDocumentIdentifier {
@@ -679,14 +692,23 @@ export class ProtocolToMonacoConverter {
679692
}
680693

681694
asDefinitionResult(item: Definition): monaco.languages.Definition;
695+
asDefinitionResult(item: DefinitionLink[]): monaco.languages.Definition;
682696
asDefinitionResult(item: undefined | null): undefined;
683-
asDefinitionResult(item: Definition | undefined | null): monaco.languages.Definition | undefined;
684-
asDefinitionResult(item: Definition | undefined | null): monaco.languages.Definition | undefined {
697+
asDefinitionResult(item: Definition | DefinitionLink[] | undefined | null): monaco.languages.Definition | undefined;
698+
asDefinitionResult(item: Definition | DefinitionLink[] | undefined | null): monaco.languages.Definition | undefined {
685699
if (!item) {
686700
return undefined;
687701
}
688702
if (Is.array(item)) {
689-
return item.map((location) => this.asLocation(location));
703+
if (item.length == 0) {
704+
return undefined;
705+
} else if (LocationLink.is(item[0])) {
706+
let links: LocationLink[] = item as LocationLink[];
707+
return links.map((location) => this.asLocationLink(location));
708+
} else {
709+
let locations: Location[] = item as Location[];
710+
return locations.map((location) => this.asLocation(location));
711+
}
690712
} else {
691713
return this.asLocation(item);
692714
}
@@ -706,6 +728,24 @@ export class ProtocolToMonacoConverter {
706728
}
707729
}
708730

731+
asLocationLink(item: undefined | null): undefined;
732+
asLocationLink(item: ls.LocationLink): monaco.languages.LocationLink;
733+
asLocationLink(item: ls.LocationLink | undefined | null): monaco.languages.LocationLink | undefined {
734+
if (!item) {
735+
return undefined;
736+
}
737+
let result: monaco.languages.LocationLink = {
738+
uri: monaco.Uri.parse(item.targetUri),
739+
range: this.asRange(item.targetSelectionRange)!, // See issue: https://github.com/Microsoft/vscode/issues/58649
740+
originSelectionRange: this.asRange(item.originSelectionRange),
741+
targetSelectionRange: this.asRange(item.targetSelectionRange)
742+
};
743+
if (!result.targetSelectionRange) {
744+
throw new Error(`targetSelectionRange must not be undefined or null`);
745+
}
746+
return result;
747+
}
748+
709749
asSignatureHelpResult(item: undefined | null): undefined;
710750
asSignatureHelpResult(item: SignatureHelp): monaco.languages.SignatureHelpResult;
711751
asSignatureHelpResult(item: SignatureHelp | undefined | null): monaco.languages.SignatureHelpResult | undefined;
@@ -882,7 +922,7 @@ export class ProtocolToMonacoConverter {
882922
}
883923
}
884924

885-
asCompletionItem(item: CompletionItem, defaultRange: monaco.IRange): ProtocolCompletionItem {
925+
asCompletionItem(item: CompletionItem, defaultRange: monaco.IRange | RangeReplace): ProtocolCompletionItem {
886926
const result = <ProtocolCompletionItem>{ label: item.label };
887927
if (item.detail) { result.detail = item.detail; }
888928
if (item.documentation) {
@@ -952,7 +992,8 @@ export class ProtocolToMonacoConverter {
952992
return [CompletionItemKind.Text, value];
953993
}
954994

955-
asCompletionInsertText(item: CompletionItem, defaultRange: monaco.IRange): { insertText: string, range: monaco.IRange, fromEdit: boolean, isSnippet: boolean } {
995+
asCompletionInsertText(item: CompletionItem, defaultRange: monaco.IRange | RangeReplace)
996+
: { insertText: string, range: monaco.IRange | RangeReplace, fromEdit: boolean, isSnippet: boolean } {
956997
const isSnippet = item.insertTextFormat === InsertTextFormat.Snippet;
957998
if (item.textEdit) {
958999
const range = this.asRange(item.textEdit.range);

client/src/monaco-language-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class MonacoLanguageClient extends BaseLanguageClient {
7979
return this.connectionProvider.get(errorHandler, closeHandler, this.outputChannel);
8080
}
8181

82-
protected createMessageTransports(encoding: string): Thenable<MessageTransports> {
82+
protected createMessageTransports(encoding: string): Promise<MessageTransports> {
8383
throw new Error('Unsupported');
8484
}
8585

client/src/services.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ export enum SignatureHelpTriggerKind {
8484
ContentChange = 3
8585
}
8686

87+
// runtime support
88+
export enum VsCodeDiagnosticSeverity {
89+
Error = 0,
90+
Warning = 1,
91+
Information = 2,
92+
Hint = 3
93+
}
94+
8795
export interface SignatureHelpContext {
8896
readonly triggerKind: SignatureHelpTriggerKind;
8997
readonly triggerCharacter?: string;

0 commit comments

Comments
 (0)