Fixes #3204: [json] project.json intellisense broken due to server change

This commit is contained in:
Martin Aeschlimann
2016-03-03 16:09:16 +01:00
parent c29826b209
commit 63c9d46cde
6 changed files with 248 additions and 147 deletions

View File

@@ -39,6 +39,24 @@ export class JSONHover {
if (!node) {
return Promise.resolve(void 0);
}
var createHover = (contents: MarkedString[]) => {
let range = Range.create(document.positionAt(node.start), document.positionAt(node.end));
let result: Hover = {
contents: contents,
range: range
};
return result;
};
let location = node.getNodeLocation();
for (let i = this.contributions.length - 1; i >= 0; i--) {
let contribution = this.contributions[i];
let promise = contribution.getInfoContribution(textDocumentPosition.uri, location);
if (promise) {
return promise.then(htmlContent => createHover(htmlContent));
}
}
return this.schemaService.getSchemaForResource(textDocumentPosition.uri, doc).then((schema) => {
if (schema) {
@@ -46,33 +64,12 @@ export class JSONHover {
doc.validate(schema.schema, matchingSchemas, node.start);
let description: string = null;
let contributonId: string = null;
matchingSchemas.every((s) => {
if (s.node === node && !s.inverted && s.schema) {
description = description || s.schema.description;
contributonId = contributonId || s.schema.id;
}
return true;
});
var createHover = (contents: MarkedString[]) => {
let range = Range.create(document.positionAt(node.start), document.positionAt(node.end));
let result: Hover = {
contents: contents,
range: range
};
return result;
};
let location = node.getNodeLocation();
for (let i = this.contributions.length - 1; i >= 0; i--) {
let contribution = this.contributions[i];
let promise = contribution.getInfoContribution(textDocumentPosition.uri, location);
if (promise) {
return promise.then(htmlContent => createHover(htmlContent));
}
}
if (description) {
return createHover([description]);
}