@@ -815,20 +815,35 @@ export class ArduinoApp {
815
815
if ( project !== "disable" && ! globalDisable ||
816
816
project === "enable" ) {
817
817
818
- const parserEngines = this . makeCompilerParserEngines ( dc ) ;
819
- const compilerParser = new ccp . Runner ( parserEngines ) ;
818
+ const engines = this . makeCompilerParserEngines ( dc ) ;
819
+ const runner = new ccp . Runner ( engines ) ;
820
820
821
821
// set up the function to be called after parsing
822
822
const _conclude = ( ) => {
823
- const cppPropsPath = path . join ( ArduinoWorkspace . rootPath , constants . CPP_CONFIG_FILE ) ;
824
- if ( compilerParser . processResult ( cppPropsPath ) ) {
825
- arduinoChannel . info ( "IntelliSense configuration generated successfully." ) ;
826
- } else {
823
+ if ( ! runner . result ) {
827
824
arduinoChannel . warning ( "Failed to generate IntelliSense configuration." ) ;
825
+ return ;
826
+ }
827
+ const pPath = path . join ( ArduinoWorkspace . rootPath , constants . CPP_CONFIG_FILE ) ;
828
+ // TODO: check what kind of result we've got: gcc or other architecture:
829
+ // and instantiate content accordingly (to be implemented within cocopa)
830
+ const content = new ccp . CCppPropertiesContentResult ( runner . result ,
831
+ "Arduino" ,
832
+ ccp . CCppPropertiesISMode . Gcc_X64 ,
833
+ ccp . CCppPropertiesCStandard . C11 ,
834
+ // as of 1.8.11 arduino is on C++11
835
+ ccp . CCppPropertiesCppStandard . Cpp11 ) ;
836
+ const prop = new ccp . CCppProperties ( ) ;
837
+ prop . read ( pPath ) ;
838
+ prop . merge ( content ) ;
839
+ if ( prop . write ( pPath ) ) {
840
+ arduinoChannel . info ( "IntelliSense configuration updated." ) ;
841
+ } else {
842
+ arduinoChannel . info ( "IntelliSense configuration already up to date." ) ;
828
843
}
829
844
} ;
830
845
return {
831
- callback : compilerParser . callback ( ) ,
846
+ callback : runner . callback ( ) ,
832
847
conclude : _conclude ,
833
848
} ;
834
849
}
@@ -849,6 +864,10 @@ export class ArduinoApp {
849
864
sketch = `-o\\s+\\S*${ ccp . regExEscape ( sketch ) } ${ dotcpp } \\.o` ;
850
865
851
866
const matchPattern = [
867
+ // make sure we're running g++
868
+ / (?: ^ | - ) g \+ \+ \s + / ,
869
+ // make sure we're compiling
870
+ / \s + - c \s + / ,
852
871
// trigger parser when compiling the main sketch
853
872
RegExp ( sketch ) ,
854
873
] ;
0 commit comments