From 09bf9c2131897144558c60c1ea95984ce487e2e0 Mon Sep 17 00:00:00 2001 From: Dan Selman Date: Wed, 26 Jun 2019 14:58:44 +0100 Subject: [PATCH] (fix) remove errors on files by type Signed-off-by: Dan Selman --- client/out/src/extension.js | 6 +- client/out/src/extension.js.map | 2 +- client/package.json | 3 +- client/server/src/server.js | 112 +++++++++++++++++++++-------- client/server/src/server.js.map | 2 +- client/src/extension.ts | 6 +- server/src/server.ts | 124 +++++++++++++++++++++++--------- 7 files changed, 185 insertions(+), 70 deletions(-) diff --git a/client/out/src/extension.js b/client/out/src/extension.js index 9841cc7..6ec5dae 100644 --- a/client/out/src/extension.js +++ b/client/out/src/extension.js @@ -33,7 +33,11 @@ function activate(context) { documentSelector: [ { scheme: 'file', language: 'ergo' }, { scheme: 'file', language: 'concerto' }, - { scheme: 'file', language: 'ciceroTemplate' } + { scheme: 'file', language: 'ciceroTemplate' }, + { + scheme: 'file', language: 'plaintext', + pattern: '**/sample.txt', + } ], synchronize: { // Synchronize the setting section 'languageServerExample' to the server diff --git a/client/out/src/extension.js.map b/client/out/src/extension.js.map index d545d90..f734171 100644 --- a/client/out/src/extension.js.map +++ b/client/out/src/extension.js.map @@ -1 +1 @@ -{"version":3,"file":"extension.js","sourceRoot":"","sources":["../../src/extension.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;EAYE;AACF,YAAY,CAAC;;AAEb,6BAA6B;AAE7B,mCAAqD;AACrD,iEAA4G;AAE5G,kBAAyB,OAAyB;IAEjD,oCAAoC;IACpC,IAAI,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC;IAChF,mCAAmC;IACnC,IAAI,YAAY,GAAG,EAAE,QAAQ,EAAE,CAAC,UAAU,EAAE,gBAAgB,CAAC,EAAE,CAAC;IAEhE,oFAAoF;IACpF,qCAAqC;IACrC,IAAI,aAAa,GAAkB;QAClC,GAAG,EAAG,EAAE,MAA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gBAAgB,CAAC,EAAE,CAAC;IAEhE,oFAAoF;IACpF,qCAAqC;IACrC,IAAI,aAAa,GAAkB;QAClC,GAAG,EAAG,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,qCAAa,CAAC,GAAG,EAAE;QAC5D,KAAK,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,qCAAa,CAAC,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE;KACpF,CAAA;IAED,yCAAyC;IACzC,IAAI,aAAa,GAA0B;QAC1C,+CAA+C;QAC/C,gBAAgB,EAAE;YACjB,EAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAC;YAClC,EAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAC;YACtC,EAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAC;YAC5C;gBACC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW;gBACrC,OAAO,EAAE,eAAe;aACxB;SACD;QACD,WAAW,EAAE;YACZ,wEAAwE;YACxE,oBAAoB,EAAE,QAAQ;YAC9B,oFAAoF;YACpF,UAAU,EAAE,kBAAS,CAAC,uBAAuB,CAAC,cAAc,CAAC;SAC7D;KACD,CAAA;IAED,mDAAmD;IACnD,IAAI,UAAU,GAAG,IAAI,sCAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC,KAAK,EAAE,CAAC;IAE9F,kEAAkE;IAClE,sDAAsD;IACtD,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACxC,CAAC;AAxCD,4BAwCC"} \ No newline at end of file diff --git a/client/package.json b/client/package.json index e3c762c..e3143aa 100755 --- a/client/package.json +++ b/client/package.json @@ -49,7 +49,8 @@ "activationEvents": [ "onLanguage:ergo", "onLanguage:concerto", - "onLanguage:ciceroTemplate" + "onLanguage:ciceroTemplate", + "onLanguage:plaintext" ], "main": "./out/src/extension", "contributes": { diff --git a/client/server/src/server.js b/client/server/src/server.js index af2be85..8c6fc96 100644 --- a/client/server/src/server.js +++ b/client/server/src/server.js @@ -171,8 +171,18 @@ function pushError(textDocument, error, type, diagnosticMap) { * @param fileName the uri of the file * @param diagnosticMap the diagnostic map */ -function validFile(fileName, diagnosticMap) { - diagnosticMap[fileName] = new Set(); +function clearErrors(fileName, type, diagnosticMap) { + const errors = diagnosticMap[fileName]; + if (!errors) { + diagnosticMap[fileName] = new Set(); + } + else { + errors.forEach(function (error) { + if (error.source === type) { + errors.delete(error); + } + }); + } } /** * Called when a document is opened @@ -207,6 +217,11 @@ documents.onDidChangeContent((change) => __awaiter(this, void 0, void 0, functio // Revalidate any open text documents documents.all().forEach(validateTextDocument); })); +/** + * A cache of TemplateLogic/template instances. The keys are the root folder names. + * Values have a templateLogic and a template property + */ +const templateCache = {}; /** * Called when the contents of a document changes * @@ -216,10 +231,6 @@ function validateTextDocument(textDocument) { return __awaiter(this, void 0, void 0, function* () { try { connection.console.log(`*** Document modified: ${textDocument.uri}`); - /** - * A cache of TemplateLogic instances. The keys are the root folder names. - */ - const templateCache = {}; /** * Map of diagnostics, with the key being the document URI * and the value being a Set of Diagnostic instances @@ -238,7 +249,7 @@ function validateTextDocument(textDocument) { const ergoValid = yield compileErgoFiles(textDocument, diagnosticMap, templateCache); // if ergo is valid we proceed to check the template if (ergoValid) { - yield validateTemplateFile(textDocument, diagnosticMap); + yield validateTemplateFile(textDocument, diagnosticMap, templateCache); } break; case '.ergo': @@ -247,7 +258,11 @@ function validateTextDocument(textDocument) { break; case '.tem': // if a template file has changed, we check we can build the template - yield validateTemplateFile(textDocument, diagnosticMap); + yield validateTemplateFile(textDocument, diagnosticMap, templateCache); + break; + case '.txt': + // if a txt file has changed we try to parse it + yield parseSampleFile(textDocument, diagnosticMap, templateCache); break; } } @@ -280,12 +295,12 @@ function compileErgoFiles(textDocument, diagnosticMap, templateCache) { } try { // get the template logic from cache - let templateLogic = templateCache[parentDir]; + let templateLogic = templateCache[parentDir].templateLogic; connection.console.log(`Compiling ergo files under: ${parentDir}`); // Find all ergo files in ./ relative to this file const ergoFiles = glob_1.glob.sync(`{${folder},${parentDir}/lib/}**/*.ergo`); for (const file of ergoFiles) { - validFile(file, diagnosticMap); + clearErrors(file, 'logic', diagnosticMap); if (file === pathStr) { // Update the current file being edited connection.console.log(`**** using contents for: ${textDocument.uri}`); @@ -328,10 +343,17 @@ function validateModels(textDocument, diagnosticMap, templateCache) { } connection.console.log(`Validating model files under: ${parentDir}`); // get the template logic from cache - let templateLogic = templateCache[parentDir]; - if (!templateLogic) { + let templateCacheEntry = templateCache[parentDir]; + let templateLogic = null; + if (!templateCacheEntry) { templateLogic = new ergo_compiler_1.TemplateLogic('cicero'); - templateCache[parentDir] = templateLogic; + templateCache[parentDir] = { + templateLogic, + template: null + }; + } + else { + templateLogic = templateCacheEntry.templateLogic; } const modelManager = templateLogic.getModelManager(); modelManager.clearModelFiles(); @@ -340,7 +362,7 @@ function validateModels(textDocument, diagnosticMap, templateCache) { // validate the model files try { for (const file of modelFiles) { - validFile(file, diagnosticMap); + clearErrors(file, 'model', diagnosticMap); let contents = null; if (file === pathStr) { // Update the current file being edited @@ -374,12 +396,12 @@ function validateModels(textDocument, diagnosticMap, templateCache) { }); } /** - * Validate that we can build the template archive and parse sample.txt + * Validate that we can build the template archive * * @param textDocument - a TextDocument - * @return Promise true the template and sample.txt are valid + * @return Promise true the template is valid */ -function validateTemplateFile(textDocument, diagnosticMap) { +function validateTemplateFile(textDocument, diagnosticMap, templateCache) { return __awaiter(this, void 0, void 0, function* () { try { const pathStr = path.resolve(fileUriToPath_1.default(textDocument.uri)); @@ -389,23 +411,13 @@ function validateTemplateFile(textDocument, diagnosticMap) { } try { connection.console.log(`Validating template under: ${parentDir}`); - validFile(parentDir + '/grammar/template.tem', diagnosticMap); + clearErrors(parentDir + '/grammar/template.tem', 'template', diagnosticMap); const template = yield cicero_core_1.Template.fromDirectory(parentDir); template.parserManager.buildGrammar(textDocument.getText()); template.validate(); - try { - connection.console.log(`Built template: ${template.getIdentifier()}`); - validFile(parentDir + '/sample.txt', diagnosticMap); - const sample = fs.readFileSync(parentDir + '/sample.txt', 'utf8'); - const clause = new cicero_core_1.Clause(template); - clause.parse(sample); - connection.console.log(`Parsed sample.text: ${JSON.stringify(clause.getData(), null, 2)}`); - return true; - } - catch (error) { - error.fileName = parentDir + '/sample.txt'; - pushError(textDocument, error, 'sample', diagnosticMap); - } + templateCache[parentDir].template = template; + connection.console.log(`==> saved template: ${template.getIdentifier()}`); + return true; } catch (error) { error.fileName = parentDir + '/grammar/template.tem'; @@ -419,5 +431,43 @@ function validateTemplateFile(textDocument, diagnosticMap) { return false; }); } +/** + * Parse sample.txt + * + * @param textDocument - a TextDocument + * @return Promise true the template and sample.txt are valid + */ +function parseSampleFile(textDocument, diagnosticMap, templateCache) { + return __awaiter(this, void 0, void 0, function* () { + try { + const pathStr = path.resolve(fileUriToPath_1.default(textDocument.uri)); + const parentDir = getTemplateRoot(pathStr, textDocument, diagnosticMap); + if (!parentDir || !templateCache[parentDir] || !templateCache[parentDir].template) { + return false; + } + const template = templateCache[parentDir].template; + if (!template) { + return false; + } + connection.console.log(`Parsing text file using template: ${template.getIdentifier()}`); + clearErrors(textDocument.uri, 'sample', diagnosticMap); + try { + const clause = new cicero_core_1.Clause(template); + clause.parse(textDocument.getText()); + connection.console.log(`Parsed sample.text: ${JSON.stringify(clause.getData(), null, 2)}`); + return true; + } + catch (error) { + error.fileName = textDocument.uri; + pushError(textDocument, error, 'sample', diagnosticMap); + } + } + catch (error) { + connection.console.error(error.message); + connection.console.error(error.stack); + } + return false; + }); +} connection.listen(); //# sourceMappingURL=server.js.map \ No newline at end of file diff --git a/client/server/src/server.js.map b/client/server/src/server.js.map index 3652875..cb517f4 100644 --- a/client/server/src/server.js.map +++ b/client/server/src/server.js.map @@ -1 +1 @@ -{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../server/src/server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,aAAa,CAAC,CAAC;aAC3D;SACJ;QACD,OAAM,KAAK,EAAE;YACT,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACxC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SACzC;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;CAAA;AAED,UAAU,CAAC,MAAM,EAAE,CAAC"} \ No newline at end of file diff --git a/client/src/extension.ts b/client/src/extension.ts index 5f677c3..a31690f 100755 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -38,7 +38,11 @@ export function activate(context: ExtensionContext) { documentSelector: [ {scheme: 'file', language: 'ergo'}, {scheme: 'file', language: 'concerto'}, - {scheme: 'file', language: 'ciceroTemplate'} + {scheme: 'file', language: 'ciceroTemplate'}, + { + scheme: 'file', language: 'plaintext', + pattern: '**/sample.txt', + } ], synchronize: { // Synchronize the setting section 'languageServerExample' to the server diff --git a/server/src/server.ts b/server/src/server.ts index 3dea773..fd04af5 100755 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -192,8 +192,20 @@ function pushError(textDocument: TextDocument, error : any, type : string, diagn * @param fileName the uri of the file * @param diagnosticMap the diagnostic map */ -function validFile(fileName, diagnosticMap) { - diagnosticMap[fileName] = new Set(); +function clearErrors(fileName, type, diagnosticMap) { + + const errors = diagnosticMap[fileName]; + + if(!errors) { + diagnosticMap[fileName] = new Set(); + } + else { + errors.forEach(function(error){ + if (error.source === type) { + errors.delete(error); + } + }); + } } /** @@ -233,6 +245,12 @@ documents.onDidChangeContent(async (change) => { documents.all().forEach(validateTextDocument); }); +/** + * A cache of TemplateLogic/template instances. The keys are the root folder names. + * Values have a templateLogic and a template property + */ +const templateCache = {}; + /** * Called when the contents of a document changes * @@ -243,11 +261,6 @@ async function validateTextDocument(textDocument: TextDocument): Promise { try { connection.console.log(`*** Document modified: ${textDocument.uri}`); - /** - * A cache of TemplateLogic instances. The keys are the root folder names. - */ - const templateCache = {}; - /** * Map of diagnostics, with the key being the document URI * and the value being a Set of Diagnostic instances @@ -271,7 +284,7 @@ async function validateTextDocument(textDocument: TextDocument): Promise { // if ergo is valid we proceed to check the template if(ergoValid) { - await validateTemplateFile(textDocument, diagnosticMap); + await validateTemplateFile(textDocument, diagnosticMap, templateCache); } break; case '.ergo': @@ -280,9 +293,13 @@ async function validateTextDocument(textDocument: TextDocument): Promise { break; case '.tem': // if a template file has changed, we check we can build the template - await validateTemplateFile(textDocument, diagnosticMap); + await validateTemplateFile(textDocument, diagnosticMap, templateCache); + break; + case '.txt': + // if a txt file has changed we try to parse it + await parseSampleFile(textDocument, diagnosticMap, templateCache); break; - } + } } // send all the diagnostics we have accumulated back to the client @@ -316,13 +333,13 @@ async function compileErgoFiles(textDocument: TextDocument, diagnosticMap, templ try { // get the template logic from cache - let templateLogic = templateCache[parentDir]; + let templateLogic = templateCache[parentDir].templateLogic; connection.console.log(`Compiling ergo files under: ${parentDir}`); // Find all ergo files in ./ relative to this file const ergoFiles = glob.sync(`{${folder},${parentDir}/lib/}**/*.ergo`); for (const file of ergoFiles) { - validFile(file, diagnosticMap); + clearErrors(file, 'logic', diagnosticMap); if (file === pathStr) { // Update the current file being edited connection.console.log(`**** using contents for: ${textDocument.uri}`); @@ -365,11 +382,18 @@ async function validateModels(textDocument: TextDocument, diagnosticMap, templat connection.console.log(`Validating model files under: ${parentDir}`); // get the template logic from cache - let templateLogic = templateCache[parentDir]; + let templateCacheEntry = templateCache[parentDir]; + let templateLogic = null; - if(!templateLogic) { + if(!templateCacheEntry) { templateLogic = new TemplateLogic('cicero'); - templateCache[parentDir] = templateLogic; + templateCache[parentDir] = { + templateLogic, + template: null + } + } + else { + templateLogic = templateCacheEntry.templateLogic; } const modelManager = templateLogic.getModelManager(); @@ -381,7 +405,7 @@ async function validateModels(textDocument: TextDocument, diagnosticMap, templat // validate the model files try { for (const file of modelFiles) { - validFile(file, diagnosticMap); + clearErrors(file, 'model', diagnosticMap); let contents = null; if (file === pathStr) { // Update the current file being edited @@ -416,12 +440,12 @@ async function validateModels(textDocument: TextDocument, diagnosticMap, templat } /** - * Validate that we can build the template archive and parse sample.txt + * Validate that we can build the template archive * * @param textDocument - a TextDocument - * @return Promise true the template and sample.txt are valid + * @return Promise true the template is valid */ -async function validateTemplateFile(textDocument: TextDocument, diagnosticMap): Promise { +async function validateTemplateFile(textDocument: TextDocument, diagnosticMap, templateCache): Promise { try { const pathStr = path.resolve(fileUriToPath(textDocument.uri)); @@ -432,24 +456,13 @@ async function validateTemplateFile(textDocument: TextDocument, diagnosticMap): try { connection.console.log(`Validating template under: ${parentDir}`); - validFile(parentDir + '/grammar/template.tem', diagnosticMap); + clearErrors(parentDir + '/grammar/template.tem', 'template', diagnosticMap); const template = await Template.fromDirectory(parentDir); template.parserManager.buildGrammar(textDocument.getText()); template.validate(); - - try { - connection.console.log(`Built template: ${template.getIdentifier()}`); - validFile(parentDir + '/sample.txt', diagnosticMap); - const sample = fs.readFileSync(parentDir + '/sample.txt', 'utf8'); - const clause = new Clause(template); - clause.parse(sample); - connection.console.log(`Parsed sample.text: ${JSON.stringify(clause.getData(), null, 2)}`); - return true; - } - catch(error) { - error.fileName = parentDir + '/sample.txt'; - pushError(textDocument, error, 'sample', diagnosticMap); - } + templateCache[parentDir].template = template; + connection.console.log(`==> saved template: ${template.getIdentifier()}`); + return true; } catch(error) { error.fileName = parentDir + '/grammar/template.tem'; @@ -464,4 +477,47 @@ async function validateTemplateFile(textDocument: TextDocument, diagnosticMap): return false; } +/** + * Parse sample.txt + * + * @param textDocument - a TextDocument + * @return Promise true the template and sample.txt are valid + */ +async function parseSampleFile(textDocument: TextDocument, diagnosticMap, templateCache): Promise { + + try { + const pathStr = path.resolve(fileUriToPath(textDocument.uri)); + const parentDir = getTemplateRoot(pathStr, textDocument, diagnosticMap); + if(!parentDir || !templateCache[parentDir] || !templateCache[parentDir].template) { + return false; + } + + const template = templateCache[parentDir].template; + + if(!template) { + return false; + } + + connection.console.log(`Parsing text file using template: ${template.getIdentifier()}`); + clearErrors(textDocument.uri, 'sample', diagnosticMap); + + try { + const clause = new Clause(template); + clause.parse(textDocument.getText()); + connection.console.log(`Parsed sample.text: ${JSON.stringify(clause.getData(), null, 2)}`); + return true; + } + catch(error) { + error.fileName = textDocument.uri; + pushError(textDocument, error, 'sample', diagnosticMap); + } + } + catch(error) { + connection.console.error(error.message); + connection.console.error(error.stack); + } + + return false; +} + connection.listen(); \ No newline at end of file