Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distinguish between glTF Validator and Language Server errors. #71

Merged
merged 5 commits into from
Nov 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Definition provider allows navigation on any index reference
* View buffer data provided by Accessor (Go to Definition (F12))
* Changed viewing texture data to match VSCode inline viewer.
* Updated to latest glTF Validator and glTF schemas.
* Clarified error sources, from glTF Validator vs glTF Language Server.

### 2.1.1 - 2017-11-15

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
"dependencies": {
"babylonjs": "^3.1.0-beta6",
"gltf-import-export": "^1.0.6",
"gltf-validator": "2.0.0-dev.1.3",
"gltf-validator": "2.0.0-dev.1.6",
"json-source-map": "^0.4.0",
"sprintf-js": "^1.1.1",
"vscode": "^1.1.8",
Expand Down
1 change: 1 addition & 0 deletions schemas/gltf-1.0/asset.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
},
"version" : {
"type" : "string",
"pattern" : "^1\\.",
"description" : "The glTF version."
}
},
Expand Down
2 changes: 1 addition & 1 deletion schemas/gltf-2.0/animation.channel.target.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"description" : "The index of the node to target."
},
"path" : {
"description" : "The name of the node's TRS property to modify, or the \"weights\" of the Morph Targets it instantiates.",
"description" : "The name of the node's TRS property to modify, or the \"weights\" of the Morph Targets it instantiates. For the \"translation\" property, the values that are provided by the sampler are the translation along the x, y, and z axes. For the \"rotation\" property, the values are a quaternion in the order (x, y, z, w), where w is the scalar. For the \"scale\" property, the values are the scaling factors along the x, y, and z axes.",
"anyOf" : [
{
"enum" : [
Expand Down
4 changes: 2 additions & 2 deletions schemas/gltf-2.0/node.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
},
"scale" : {
"type" : "array",
"description" : "The node's non-uniform scale.",
"description" : "The node's non-uniform scale, given as the scaling factors along the x, y, and z axes.",
"items" : {
"type" : "number"
},
Expand All @@ -104,7 +104,7 @@
},
"translation" : {
"type" : "array",
"description" : "The node's translation.",
"description" : "The node's translation along the x, y, and z axes.",
"items" : {
"type" : "number"
},
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"url": "https://github.com/AnalyticalGraphicsInc/gltf-vscode"
},
"dependencies": {
"gltf-validator": "2.0.0-dev.1.3",
"gltf-validator": "2.0.0-dev.1.6",
"json-source-map": "^0.4.0",
"vscode-languageserver": "3.5.0",
"vscode-uri": "^1.0.1"
Expand Down
18 changes: 13 additions & 5 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ function parseTextDocument(parseResult: ParseResult, textDocument: TextDocument)
parseResult.jsonMap = tryGetJsonMap(textDocument);
if (!parseResult.jsonMap) {
parseResult.parseable = false;
let diagnostics: Diagnostic[] = [getDiagnostic({ message: 'Error parsing JSON document.' }, {data: null, pointers: null})];
let diagnostics: Diagnostic[] = [getDiagnostic({
message: 'Error parsing JSON document.',
isFromLanguageServer: true
}, {data: null, pointers: null})];
connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });
return;
}
Expand All @@ -202,6 +205,7 @@ function parseTextDocument(parseResult: ParseResult, textDocument: TextDocument)
if ((!parseResult.jsonMap.data.asset) || (!parseResult.jsonMap.data.asset.version) || (parseResult.jsonMap.data.asset.version[0] === '1')) {
let diagnostics: Diagnostic[] = [getDiagnostic({
message: 'Validation not available for glTF 1.0 files.',
isFromLanguageServer: true,
severity: 2
}, jsonMap)];
connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });
Expand All @@ -216,7 +220,7 @@ function parseTextDocument(parseResult: ParseResult, textDocument: TextDocument)
severityOverrides: currentSettings.Validation.severityOverrides,
externalResourceFunction: (uri) =>
new Promise((resolve, reject) => {
uri = path.resolve(folderName, uri);
uri = path.resolve(folderName, decodeURIComponent(uri));
fs.readFile(uri, (err, data) => {
console.log("Loading external file: " + uri);
if (err) {
Expand All @@ -243,7 +247,8 @@ function parseTextDocument(parseResult: ParseResult, textDocument: TextDocument)

if (result.issues.truncated) {
diagnostics.push(getDiagnostic({
message: 'VALIDATION ABORTED: Too many messages produced.'
message: 'VALIDATION ABORTED: Too many messages produced.',
isFromLanguageServer: true
}, parseResult.jsonMap));
}
}
Expand All @@ -258,7 +263,10 @@ function parseTextDocument(parseResult: ParseResult, textDocument: TextDocument)
// Validator's error
console.warn('glTF Validator failed on: ' + fileName);
console.warn(result);
let diagnostics: Diagnostic[] = [getDiagnostic({ message: 'glTF Validator error: ' + result }, {data: null, pointers: null})];
let diagnostics: Diagnostic[] = [getDiagnostic({
message: 'glTF Validator error: ' + result,
isFromLanguageServer: true
}, {data: null, pointers: null})];
connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });
});
}
Expand Down Expand Up @@ -310,7 +318,7 @@ function getDiagnostic(info: any, map: JsonMap): Diagnostic {
severity: severity,
range,
message: info.message,
source: 'glTF Validator'
source: (info.isFromLanguageServer ? 'glTF Language Server' : 'glTF Validator')
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/validationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export async function validate(sourceFilename: string) {
severityOverrides: currentSettings.severityOverrides,
externalResourceFunction: (uri) =>
new Promise((resolve, reject) => {
uri = path.resolve(folderName, uri);
uri = path.resolve(folderName, decodeURIComponent(uri));
fs.readFile(uri, (err, data) => {
if (err) {
reject(err.toString());
Expand Down
18 changes: 0 additions & 18 deletions util/importSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,29 +130,11 @@ function upgradeDescriptions(data) {
}
}

function upgradeUriRefs(data) {
for (var key in data) {
if (data.hasOwnProperty(key)) {
var val = data[key];
if (typeof(val) === 'object') {
upgradeUriRefs(val);
}
}
}

// See: https://github.com/KhronosGroup/glTF/issues/1149
if (data && data.format && data.format === 'uri') {
console.log('NOTE: uri upgraded to uriref.');
data.format = 'uriref';
}
}

function transformFile(inputFile, outputFile) {
var schema = JSON.parse(fs.readFileSync(inputFile));

transformEnums(schema);
upgradeDescriptions(schema);
upgradeUriRefs(schema);

fs.writeFileSync(outputFile, JSON.stringify(schema, null, ' ').replace(/\"\:/g, '" :') + '\n');
}
Expand Down