From 4238e12089560110cf682c25dac3c12106299259 Mon Sep 17 00:00:00 2001 From: Uli Franke Date: Sat, 22 Feb 2020 20:33:16 +0100 Subject: [PATCH] Updated to latest cocopa which features X-platform support and better lexer --- package-lock.json | 44 +++++++++++++++++++++++++++---------- package.json | 2 +- src/arduino/intellisense.ts | 38 ++++++++++++-------------------- 3 files changed, 47 insertions(+), 37 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9c9bab37..28126120 100644 --- a/package-lock.json +++ b/package-lock.json @@ -214,8 +214,7 @@ "@types/color-name": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", - "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", - "dev": true + "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==" }, "@types/compare-versions": { "version": "3.3.0", @@ -541,7 +540,6 @@ "version": "4.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", - "dev": true, "requires": { "@types/color-name": "^1.1.1", "color-convert": "^2.0.1" @@ -551,7 +549,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, "requires": { "color-name": "~1.1.4" } @@ -559,8 +556,7 @@ "color-name": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" } } }, @@ -1563,9 +1559,30 @@ "dev": true }, "cocopa": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/cocopa/-/cocopa-0.0.7.tgz", - "integrity": "sha512-L/BaneLuO56MCjAkbzUFRRZhKf0P37LY+3JClzV/poVQTEDHxS8KWa8Rw5IpCFOdZiGitQvy6r1L/5I/TJt9nA==" + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/cocopa/-/cocopa-0.0.8.tgz", + "integrity": "sha512-owNmofAE5bfJpQcq8j1z5wgvN5QiGSDVuWJoi1bNmpKjpP8CZr/VYQVlQ3uwUEShfiZhxbaJLTWZaE98pNrQKw==", + "requires": { + "chalk": "^3.0.0", + "commander": "^4.1.1", + "shlex": "^2.0.1" + }, + "dependencies": { + "chalk": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", + "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "commander": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==" + } + } }, "code-point-at": { "version": "1.1.0", @@ -7677,6 +7694,11 @@ "resolved": "https://registry.npmjs.org/shimmer/-/shimmer-1.2.1.tgz", "integrity": "sha512-sQTKC1Re/rM6XyFM6fIAGHRPVGvyXfgzIDvzoq608vM+jeyVD0Tu1E6Np0Kc2zAIFWIj963V2800iF/9LPieQw==" }, + "shlex": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/shlex/-/shlex-2.0.2.tgz", + "integrity": "sha512-i4p9nNXgBTILspHwZlBCNsZzwuVWW8SFx5dyIONrjL0R+AbMOPbg7ndqgGfjYivkYRTtZMKqIT8HT+QyOhPQWA==" + }, "signal-exit": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", @@ -8130,7 +8152,6 @@ "version": "7.1.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", - "dev": true, "requires": { "has-flag": "^4.0.0" }, @@ -8138,8 +8159,7 @@ "has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" } } }, diff --git a/package.json b/package.json index 0d39907c..a3246dfb 100644 --- a/package.json +++ b/package.json @@ -604,7 +604,7 @@ }, "dependencies": { "body-parser": "^1.16.1", - "cocopa": "^0.0.7", + "cocopa": "^0.0.8", "compare-versions": "^3.4.0", "eventemitter2": "^4.1.0", "express": "^4.14.1", diff --git a/src/arduino/intellisense.ts b/src/arduino/intellisense.ts index 57f5588c..96c1713a 100644 --- a/src/arduino/intellisense.ts +++ b/src/arduino/intellisense.ts @@ -40,6 +40,14 @@ export function isCompilerParserEnabled(dc?: DeviceContext) { * and keeps the calling context more readable. * * @param dc The device context of the caller. + * + * Possible enhancements: + * + * * Parse c++ standard from arduino command line + * + * Arduino currently sets the C++ standard during compilation with the + * flag -std=gnu++11 + * */ export function makeCompilerParserContext(dc: DeviceContext): ICoCoPaContext { @@ -92,29 +100,9 @@ export function makeCompilerParserContext(dc: DeviceContext): ICoCoPaContext { * @param dc Current device context used to generate the engines. */ function makeCompilerParserEngines(dc: DeviceContext) { - - let sketch = path.basename(dc.sketch); - const dotcpp = sketch.endsWith(".ino") ? ".cpp" : ""; - sketch = `-o\\s+\\S*${ccp.regExEscape(sketch)}${dotcpp}\\.o`; - - // TODO: handle other architectures here - - const matchPattern = [ - // make sure we're running g++ - /(?:^|-)g\+\+\s+/, - // make sure we're compiling - /\s+-c\s+/, - // trigger parser when compiling the main sketch - RegExp(sketch), - ]; - - const dontMatchPattern = [ - // make sure Arduino's not testing libraries - /-o\s+\/dev\/null/, - ]; - - // setup the parser with its engines - const gccParserEngine = new ccp.ParserGcc(matchPattern, dontMatchPattern); + const sketch = path.basename(dc.sketch); + const trigger = ccp.getTriggerForArduinoGcc(sketch); + const gccParserEngine = new ccp.ParserGcc(trigger); return [gccParserEngine]; } @@ -286,8 +274,10 @@ export class AnalysisManager { clearTimeout(this._timer); } this._timer = setTimeout(() => { - this.update(AnalysisEvent.WaitTimeout); + // reset timer variable first - calling update can cause + // the timer to be restarted. this._timer = undefined; + this.update(AnalysisEvent.WaitTimeout); }, this._waitPeriodMs); }