@@ -40,6 +40,14 @@ export function isCompilerParserEnabled(dc?: DeviceContext) {
40
40
* and keeps the calling context more readable.
41
41
*
42
42
* @param dc The device context of the caller.
43
+ *
44
+ * Possible enhancements:
45
+ *
46
+ * * Parse c++ standard from arduino command line
47
+ *
48
+ * Arduino currently sets the C++ standard during compilation with the
49
+ * flag -std=gnu++11
50
+ *
43
51
*/
44
52
export function makeCompilerParserContext ( dc : DeviceContext ) : ICoCoPaContext {
45
53
@@ -92,29 +100,9 @@ export function makeCompilerParserContext(dc: DeviceContext): ICoCoPaContext {
92
100
* @param dc Current device context used to generate the engines.
93
101
*/
94
102
function makeCompilerParserEngines ( dc : DeviceContext ) {
95
-
96
- let sketch = path . basename ( dc . sketch ) ;
97
- const dotcpp = sketch . endsWith ( ".ino" ) ? ".cpp" : "" ;
98
- sketch = `-o\\s+\\S*${ ccp . regExEscape ( sketch ) } ${ dotcpp } \\.o` ;
99
-
100
- // TODO: handle other architectures here
101
-
102
- const matchPattern = [
103
- // make sure we're running g++
104
- / (?: ^ | - ) g \+ \+ \s + / ,
105
- // make sure we're compiling
106
- / \s + - c \s + / ,
107
- // trigger parser when compiling the main sketch
108
- RegExp ( sketch ) ,
109
- ] ;
110
-
111
- const dontMatchPattern = [
112
- // make sure Arduino's not testing libraries
113
- / - o \s + \/ d e v \/ n u l l / ,
114
- ] ;
115
-
116
- // setup the parser with its engines
117
- const gccParserEngine = new ccp . ParserGcc ( matchPattern , dontMatchPattern ) ;
103
+ const sketch = path . basename ( dc . sketch ) ;
104
+ const trigger = ccp . getTriggerForArduinoGcc ( sketch ) ;
105
+ const gccParserEngine = new ccp . ParserGcc ( trigger ) ;
118
106
return [ gccParserEngine ] ;
119
107
}
120
108
@@ -286,8 +274,10 @@ export class AnalysisManager {
286
274
clearTimeout ( this . _timer ) ;
287
275
}
288
276
this . _timer = setTimeout ( ( ) => {
289
- this . update ( AnalysisEvent . WaitTimeout ) ;
277
+ // reset timer variable first - calling update can cause
278
+ // the timer to be restarted.
290
279
this . _timer = undefined ;
280
+ this . update ( AnalysisEvent . WaitTimeout ) ;
291
281
} , this . _waitPeriodMs ) ;
292
282
}
293
283
0 commit comments