From a5438e63df8d3102c6533207285d522bca00a1b6 Mon Sep 17 00:00:00 2001 From: Angelinsky7 Date: Mon, 4 Apr 2016 16:23:42 +0200 Subject: [PATCH 1/2] Update extension.js add error handling during css parsing --- html-css-class-completion/extension.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/html-css-class-completion/extension.js b/html-css-class-completion/extension.js index 0289e23..6f959e7 100644 --- a/html-css-class-completion/extension.js +++ b/html-css-class-completion/extension.js @@ -11,16 +11,16 @@ function activate(context) { vscode.window.showInformationMessage('HTML CSS Class Completion: Fetching CSS rules from CSS files, please wait.'); // fetches the css files excluding the ones within node_modules folders that are within another node_modules folder vscode.workspace.findFiles('**/*.css', 'node_modules/**/node_modules/**/*').then(function (uris) { - // will contain all the css files concatenated - var cssFilesConcatenated = ""; + // extracts the text of the file and directly parse it. + // if an error occurs during the parse hide the error (it could be shown into an error log) + try { + fetchClasses(textDocument.getText(), classes); + } catch (err) { } // goes through each css file found and open it uris.forEach(function (uri, index) { vscode.workspace.openTextDocument(uri).then(function (textDocument) { - // extracts the text of the file and concatenates it - cssFilesConcatenated += textDocument.getText(); if (uris.length == index + 1) { - // after finishing the process the css classes are fetched from this large string and added to the classes array - fetchClasses(cssFilesConcatenated, classes); + // Display message to user vscode.window.showInformationMessage("HTML CSS Class Completion: Finished fetching CSS rules from CSS files."); } }); @@ -146,4 +146,4 @@ exports.activate = activate; // this method is called when your extension is deactivated function deactivate() { } -exports.deactivate = deactivate; \ No newline at end of file +exports.deactivate = deactivate; From bd8c1e17c80c1aadd8a59494cac9d6291843408d Mon Sep 17 00:00:00 2001 From: Angelinsky7 Date: Mon, 4 Apr 2016 16:39:37 +0200 Subject: [PATCH 2/2] Update extension.js Add command to refresh completion --- html-css-class-completion/extension.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/html-css-class-completion/extension.js b/html-css-class-completion/extension.js index 6f959e7..a5e2888 100644 --- a/html-css-class-completion/extension.js +++ b/html-css-class-completion/extension.js @@ -138,6 +138,12 @@ function activate(context) { }); context.subscriptions.push(disposable); + var disposable = vscode.commands.registerCommand('extension.html-css-class-completion.refresh', () => { + fetchAllCssRulesInCssFiles(); + }); + + context.subscriptions.push(disposable); + fetchAllCssRulesInCssFiles(); //fetchAllCssRulesInHtmlFiles(); }