Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
Updated to latest cocopa which features X-platform support and better…
Browse files Browse the repository at this point in the history
… lexer
  • Loading branch information
elektronikworkshop authored and adiazulay committed Jan 19, 2021
1 parent e6c10cd commit 4238e12
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 37 deletions.
44 changes: 32 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
38 changes: 14 additions & 24 deletions src/arduino/intellisense.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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];
}

Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 4238e12

Please sign in to comment.