@@ -68,6 +68,11 @@ export interface ConfigurationErrors {
6868 compilerPath ?: string ;
6969 includePath ?: string ;
7070 intelliSenseMode ?: string ;
71+ macFrameworkPath ?: string ;
72+ forcedInclude ?: string ;
73+ compileCommands ?: string ;
74+ browsePath ?: string ;
75+ databaseFilename ?: string ;
7176}
7277
7378export interface Browse {
@@ -907,7 +912,6 @@ export class CppProperties {
907912 private getErrorsForConfigUI ( configIndex : number ) : ConfigurationErrors {
908913 let errors : ConfigurationErrors = { } ;
909914 const isWindows : boolean = os . platform ( ) === 'win32' ;
910-
911915 let config : Configuration = this . configurationJson . configurations [ configIndex ] ;
912916
913917 // Validate compilerPath
@@ -971,51 +975,79 @@ export class CppProperties {
971975 }
972976 }
973977
974- // Validate includePath
975- let includePathErrors : string [ ] = [ ] ;
976- if ( config . includePath ) {
977- for ( let includePath of config . includePath ) {
978- let pathExists : boolean = true ;
979- let resolvedIncludePath : string = this . resolvePath ( includePath , isWindows ) ;
980- if ( ! resolvedIncludePath ) {
981- continue ;
982- }
978+ // Validate paths (directories)
979+ errors . includePath = this . validatePath ( config . includePath ) ;
980+ errors . macFrameworkPath = this . validatePath ( config . macFrameworkPath ) ;
981+ errors . browsePath = this . validatePath ( config . browse ? config . browse . path : undefined ) ;
983982
984- // Check if resolved path exists
985- if ( ! fs . existsSync ( resolvedIncludePath ) ) {
986- // Check for relative path if resolved path does not exists
987- const relativePath : string = this . rootUri . fsPath + path . sep + resolvedIncludePath ;
988- if ( ! fs . existsSync ( relativePath ) ) {
989- pathExists = false ;
990- } else {
991- resolvedIncludePath = relativePath ;
992- }
993- }
983+ // Validate files
984+ errors . forcedInclude = this . validatePath ( config . forcedInclude , false ) ;
985+ errors . compileCommands = this . validatePath ( config . compileCommands , false ) ;
986+ errors . databaseFilename = this . validatePath ( ( config . browse ? config . browse . databaseFilename : undefined ) , false ) ;
994987
995- if ( ! pathExists ) {
996- let message : string = `Cannot find: ${ resolvedIncludePath } ` ;
997- includePathErrors . push ( message ) ;
998- continue ;
999- }
988+ // Validate intelliSenseMode
989+ if ( isWindows && ! this . isCompilerIntelliSenseModeCompatible ( config ) ) {
990+ errors . intelliSenseMode = `IntelliSense mode ${ config . intelliSenseMode } is incompatible with compiler path.` ;
991+ }
992+
993+ return errors ;
994+ }
1000995
1001- // Check if path is a directory
1002- if ( ! util . checkDirectoryExistsSync ( resolvedIncludePath ) ) {
1003- let message : string = `Path is not a directory: ${ resolvedIncludePath } ` ;
1004- includePathErrors . push ( message ) ;
996+ private validatePath ( input : string | string [ ] , isDirectory : boolean = true ) : string {
997+ if ( ! input ) {
998+ return undefined ;
999+ }
1000+
1001+ const isWindows : boolean = os . platform ( ) === 'win32' ;
1002+ let errorMsg : string = undefined ;
1003+ let errors : string [ ] = [ ] ;
1004+ let paths : string [ ] = [ ] ;
1005+
1006+ if ( util . isString ( input ) ) {
1007+ paths . push ( input ) ;
1008+ } else {
1009+ paths = input ;
1010+ }
1011+
1012+ for ( let p of paths ) {
1013+ let pathExists : boolean = true ;
1014+ let resolvedPath : string = this . resolvePath ( p , isWindows ) ;
1015+ if ( ! resolvedPath ) {
1016+ continue ;
1017+ }
1018+
1019+ // Check if resolved path exists
1020+ if ( ! fs . existsSync ( resolvedPath ) ) {
1021+ // Check for relative path if resolved path does not exists
1022+ const relativePath : string = this . rootUri . fsPath + path . sep + resolvedPath ;
1023+ if ( ! fs . existsSync ( relativePath ) ) {
1024+ pathExists = false ;
1025+ } else {
1026+ resolvedPath = relativePath ;
10051027 }
10061028 }
10071029
1008- if ( includePathErrors . length > 0 ) {
1009- errors . includePath = includePathErrors . join ( '\n' ) ;
1030+ if ( ! pathExists ) {
1031+ let message : string = `Cannot find: ${ resolvedPath } ` ;
1032+ errors . push ( message ) ;
1033+ continue ;
1034+ }
1035+
1036+ // Check if path is a directory or file
1037+ if ( isDirectory && ! util . checkDirectoryExistsSync ( resolvedPath ) ) {
1038+ let message : string = `Path is not a directory: ${ resolvedPath } ` ;
1039+ errors . push ( message ) ;
1040+ } else if ( ! isDirectory && ! util . checkFileExistsSync ( resolvedPath ) ) {
1041+ let message : string = `Path is not a file: ${ resolvedPath } ` ;
1042+ errors . push ( message ) ;
10101043 }
10111044 }
10121045
1013- // Validate intelliSenseMode
1014- if ( isWindows && ! this . isCompilerIntelliSenseModeCompatible ( config ) ) {
1015- errors . intelliSenseMode = `IntelliSense mode ${ config . intelliSenseMode } is incompatible with compiler path.` ;
1046+ if ( errors . length > 0 ) {
1047+ errorMsg = errors . join ( '\n' ) ;
10161048 }
10171049
1018- return errors ;
1050+ return errorMsg ;
10191051 }
10201052
10211053 private handleSquiggles ( ) : void {
0 commit comments