Skip to content

Commit

Permalink
Merge branch 'locationLink' into bumpMonacoVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanNikitenko committed Feb 7, 2020
2 parents 1cf39d6 + 9714923 commit 6590ed7
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions client/src/monaco-converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
CompletionParams, CompletionContext, CompletionTriggerKind,
InsertTextFormat, Range, Diagnostic, CompletionItemKind,
Hover, SignatureHelp, SignatureInformation, ParameterInformation,
Definition, Location, DocumentHighlight, DocumentHighlightKind,
Definition, DefinitionLink, Location, LocationLink, DocumentHighlight, DocumentHighlightKind,
SymbolInformation, DocumentSymbolParams, CodeActionContext, DiagnosticSeverity,
Command, CodeLens, FormattingOptions, TextEdit, WorkspaceEdit, DocumentLinkParams, DocumentLink,
MarkedString, MarkupContent, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind,
Expand Down Expand Up @@ -692,14 +692,23 @@ export class ProtocolToMonacoConverter {
}

asDefinitionResult(item: Definition): monaco.languages.Definition;
asDefinitionResult(item: DefinitionLink[]): monaco.languages.Definition;
asDefinitionResult(item: undefined | null): undefined;
asDefinitionResult(item: Definition | undefined | null): monaco.languages.Definition | undefined;
asDefinitionResult(item: Definition | undefined | null): monaco.languages.Definition | undefined {
asDefinitionResult(item: Definition | DefinitionLink[] | undefined | null): monaco.languages.Definition | undefined;
asDefinitionResult(item: Definition | DefinitionLink[] | undefined | null): monaco.languages.Definition | undefined {
if (!item) {
return undefined;
}
if (Is.array(item)) {
return item.map((location) => this.asLocation(location));
if (item.length == 0) {
return undefined;
} else if (LocationLink.is(item[0])) {
let links: LocationLink[] = item as LocationLink[];
return links.map((location) => this.asLocationLink(location));
} else {
let locations: Location[] = item as Location[];
return locations.map((location) => this.asLocation(location));
}
} else {
return this.asLocation(item);
}
Expand All @@ -719,6 +728,24 @@ export class ProtocolToMonacoConverter {
}
}

asLocationLink(item: undefined | null): undefined;
asLocationLink(item: ls.LocationLink): monaco.languages.LocationLink;
asLocationLink(item: ls.LocationLink | undefined | null): monaco.languages.LocationLink | undefined {
if (!item) {
return undefined;
}
let result: monaco.languages.LocationLink = {
uri: monaco.Uri.parse(item.targetUri),
range: this.asRange(item.targetSelectionRange)!, // See issue: https://github.com/Microsoft/vscode/issues/58649
originSelectionRange: this.asRange(item.originSelectionRange),
targetSelectionRange: this.asRange(item.targetSelectionRange)
};
if (!result.targetSelectionRange) {
throw new Error(`targetSelectionRange must not be undefined or null`);
}
return result;
}

asSignatureHelpResult(item: undefined | null): undefined;
asSignatureHelpResult(item: SignatureHelp): monaco.languages.SignatureHelpResult;
asSignatureHelpResult(item: SignatureHelp | undefined | null): monaco.languages.SignatureHelpResult | undefined;
Expand Down

0 comments on commit 6590ed7

Please sign in to comment.