mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 09:38:38 +01:00
More Thenables and polish
This commit is contained in:
@@ -28,7 +28,7 @@ export class JSONCompletion {
|
||||
this.schemaService = schemaService;
|
||||
}
|
||||
|
||||
public doSuggest(document: ITextDocument, textDocumentPosition: TextDocumentPosition, lines: LinesModel, doc: Parser.JSONDocument): Promise<CompletionItem[]> {
|
||||
public doSuggest(document: ITextDocument, textDocumentPosition: TextDocumentPosition, lines: LinesModel, doc: Parser.JSONDocument): Thenable<CompletionItem[]> {
|
||||
|
||||
var offset = lines.offsetAt(textDocumentPosition.position);
|
||||
var node = doc.getNodeFromOffsetEndInclusive(offset);
|
||||
|
||||
@@ -20,7 +20,7 @@ export class JSONHover {
|
||||
this.schemaService = schemaService;
|
||||
}
|
||||
|
||||
public doHover(document: ITextDocument, textDocumentPosition: TextDocumentPosition, lines: LinesModel, doc: Parser.JSONDocument): Promise<Hover> {
|
||||
public doHover(document: ITextDocument, textDocumentPosition: TextDocumentPosition, lines: LinesModel, doc: Parser.JSONDocument): Thenable<Hover> {
|
||||
|
||||
let offset = lines.offsetAt(textDocumentPosition.position);
|
||||
let node = doc.getNodeFromOffset(offset);
|
||||
|
||||
@@ -53,7 +53,7 @@ documents.listen(connection);
|
||||
// After the server has started the client sends an initilize request. The server receives
|
||||
// in the passed params the rootPath of the workspace plus the client capabilites.
|
||||
let workspaceRoot: URI;
|
||||
connection.onInitialize((params: InitializeResult) => {
|
||||
connection.onInitialize((params: InitializeParams): InitializeResult => {
|
||||
workspaceRoot = URI.parse(params.rootPath);
|
||||
return {
|
||||
capabilities: {
|
||||
|
||||
@@ -27,7 +27,7 @@ suite('JSON Completion', () => {
|
||||
assert.equal(matches, 1, label + " should only existing once");
|
||||
};
|
||||
|
||||
var testSuggestionsFor = function(value: string, stringAfter: string, schema?: JsonSchema.IJSONSchema): Promise<CompletionItem[]> {
|
||||
var testSuggestionsFor = function(value: string, stringAfter: string, schema?: JsonSchema.IJSONSchema): Thenable<CompletionItem[]> {
|
||||
var uri = 'test://test.json';
|
||||
var idx = stringAfter ? value.indexOf(stringAfter) : 0;
|
||||
|
||||
@@ -38,10 +38,7 @@ suite('JSON Completion', () => {
|
||||
schemaService.registerExternalSchema(id, ["*.json"], schema);
|
||||
}
|
||||
|
||||
var document = {
|
||||
getText: () => value,
|
||||
uri: uri
|
||||
}
|
||||
var document = ITextDocument.create(uri, value);
|
||||
var textDocumentLocation = TextDocumentPosition.create(uri, Position.create(0, idx));
|
||||
var lines = createLinesModel(value);
|
||||
var jsonDoc = Parser.parse(value);
|
||||
|
||||
@@ -13,7 +13,7 @@ import {IXHROptions, IXHRResponse} from '../utils/httpRequest';
|
||||
import {create as createLinesModel} from '../utils/lines';
|
||||
import {JSONDocumentSymbols} from '../jsonDocumentSymbols';
|
||||
|
||||
import {SymbolInformation, SymbolKind, TextDocumentIdentifier, TextDocumentPosition, Range, Position, TextEdit} from 'vscode-languageserver';
|
||||
import {SymbolInformation, SymbolKind, TextDocumentIdentifier, ITextDocument, TextDocumentPosition, Range, Position, TextEdit} from 'vscode-languageserver';
|
||||
|
||||
suite('JSON Document Symbols', () => {
|
||||
|
||||
@@ -22,10 +22,7 @@ suite('JSON Document Symbols', () => {
|
||||
|
||||
var symbolProvider = new JSONDocumentSymbols();
|
||||
|
||||
var document = {
|
||||
getText: () => value,
|
||||
uri: uri
|
||||
}
|
||||
var document = ITextDocument.create(uri, value);
|
||||
var lines = createLinesModel(value);
|
||||
var jsonDoc = Parser.parse(value);
|
||||
return symbolProvider.compute(document, lines, jsonDoc);
|
||||
|
||||
@@ -18,7 +18,6 @@ suite('JSON Formatter', () => {
|
||||
let range: Range = null;
|
||||
let uri = 'test://test.json';
|
||||
|
||||
|
||||
let lines = createLinesModel(unformatted);
|
||||
|
||||
let rangeStart = unformatted.indexOf('|');
|
||||
@@ -33,10 +32,7 @@ suite('JSON Formatter', () => {
|
||||
lines = createLinesModel(unformatted);
|
||||
}
|
||||
|
||||
let document = {
|
||||
getText: () => unformatted,
|
||||
uri: uri
|
||||
}
|
||||
var document = ITextDocument.create(uri, unformatted);
|
||||
let edits = Formatter.format(document, lines, range, { tabSize: 2, insertSpaces: insertSpaces });
|
||||
|
||||
let formatted = unformatted;
|
||||
|
||||
@@ -17,7 +17,7 @@ import {Hover, ITextDocument, TextDocumentIdentifier, TextDocumentPosition, Rang
|
||||
|
||||
suite('JSON Hover', () => {
|
||||
|
||||
function testComputeInfo(value: string, schema: JsonSchema.IJSONSchema, position: Position): Promise<Hover> {
|
||||
function testComputeInfo(value: string, schema: JsonSchema.IJSONSchema, position: Position): Thenable<Hover> {
|
||||
var uri = 'test://test.json';
|
||||
|
||||
var schemaService = new SchemaService.JSONSchemaService(requestService);
|
||||
@@ -25,10 +25,7 @@ suite('JSON Hover', () => {
|
||||
var id = "http://myschemastore/test1";
|
||||
schemaService.registerExternalSchema(id, ["*.json"], schema);
|
||||
|
||||
var document = {
|
||||
getText: () => value,
|
||||
uri: uri
|
||||
}
|
||||
var document = ITextDocument.create(uri, value);
|
||||
var textDocumentLocation = TextDocumentPosition.create(uri, position);
|
||||
var lines = createLinesModel(value);
|
||||
var jsonDoc = Parser.parse(value);
|
||||
|
||||
Reference in New Issue
Block a user