Use MarkedString insetad of HTMLContentElement

This commit is contained in:
Martin Aeschlimann
2016-06-24 10:19:12 +02:00
parent 8b60f07f69
commit 51f2d539a6
24 changed files with 204 additions and 206 deletions

View File

@@ -12,7 +12,6 @@ import * as modes from 'vs/editor/common/modes';
import * as types from './extHostTypes';
import {Position as EditorPosition} from 'vs/platform/editor/common/editor';
import {IPosition, ISelection, IRange, IDecorationOptions, ISingleEditOperation} from 'vs/editor/common/editorCommon';
import {IHTMLContentElement} from 'vs/base/common/htmlContent';
import {ITypeBearing} from 'vs/workbench/parts/search/common/search';
import * as vscode from 'vscode';
import URI from 'vs/base/common/uri';
@@ -125,36 +124,6 @@ export function toViewColumn(position?: EditorPosition): vscode.ViewColumn {
}
}
export function fromFormattedString(value: vscode.MarkedString): IHTMLContentElement {
if (typeof value === 'string') {
return { markdown: value };
} else if (typeof value === 'object') {
return { code: value };
}
}
export function toFormattedString(value: IHTMLContentElement): vscode.MarkedString {
if (typeof value.code === 'string') {
return value.code;
}
let {markdown, text} = value;
return markdown || text || '<???>';
}
function isMarkedStringArr(something: vscode.MarkedString | vscode.MarkedString[]): something is vscode.MarkedString[] {
return Array.isArray(something);
}
function fromMarkedStringOrMarkedStringArr(something: vscode.MarkedString | vscode.MarkedString[]): IHTMLContentElement[] {
if (isMarkedStringArr(something)) {
return something.map(msg => fromFormattedString(msg));
} else if (something) {
return [fromFormattedString(something)];
} else {
return [];
}
}
function isDecorationOptions(something: any): something is vscode.DecorationOptions {
return (typeof something.range !== 'undefined');
}
@@ -171,7 +140,7 @@ export function fromRangeOrRangeWithMessage(ranges:vscode.Range[]|vscode.Decorat
return ranges.map((r): IDecorationOptions => {
return {
range: fromRange(r.range),
hoverMessage: fromMarkedStringOrMarkedStringArr(r.hoverMessage),
hoverMessage: r.hoverMessage,
renderOptions: r.renderOptions
};
});
@@ -256,12 +225,12 @@ export const location = {
export function fromHover(hover: vscode.Hover): modes.Hover {
return <modes.Hover>{
range: fromRange(hover.range),
htmlContent: hover.contents.map(fromFormattedString)
contents: hover.contents
};
}
export function toHover(info: modes.Hover): types.Hover {
return new types.Hover(info.htmlContent.map(toFormattedString), toRange(info.range));
return new types.Hover(info.contents, toRange(info.range));
}
export function toDocumentHighlight(occurrence: modes.DocumentHighlight): types.DocumentHighlight {