@@ -1157,19 +1157,27 @@ namespace ts.server {
1157
1157
this . projectService . getScriptInfoEnsuringProjectsUptoDate ( args . file ) :
1158
1158
this . projectService . getScriptInfo ( args . file ) ;
1159
1159
if ( ! scriptInfo ) {
1160
- return ignoreNoProjectError ? emptyArray : Errors . ThrowNoProject ( ) ;
1160
+ if ( ignoreNoProjectError ) return emptyArray ;
1161
+ this . logErrorForScriptInfoNotFound ( args . file ) ;
1162
+ return Errors . ThrowNoProject ( ) ;
1161
1163
}
1162
1164
projects = scriptInfo . containingProjects ;
1163
1165
symLinkedProjects = this . projectService . getSymlinkedProjects ( scriptInfo ) ;
1164
1166
}
1165
1167
// filter handles case when 'projects' is undefined
1166
1168
projects = filter ( projects , p => p . languageServiceEnabled && ! p . isOrphan ( ) ) ;
1167
1169
if ( ! ignoreNoProjectError && ( ! projects || ! projects . length ) && ! symLinkedProjects ) {
1170
+ this . logErrorForScriptInfoNotFound ( args . file ) ;
1168
1171
return Errors . ThrowNoProject ( ) ;
1169
1172
}
1170
1173
return symLinkedProjects ? { projects : projects ! , symLinkedProjects } : projects ! ; // TODO: GH#18217
1171
1174
}
1172
1175
1176
+ private logErrorForScriptInfoNotFound ( fileName : string ) : void {
1177
+ this . logger . msg ( `Could not find file ${ JSON . stringify ( fileName ) } .\n` +
1178
+ `All files are: ${ JSON . stringify ( this . projectService . allScriptInfoFileNamesForDebug ( ) ) } ` , Msg . Err ) ;
1179
+ }
1180
+
1173
1181
private getDefaultProject ( args : protocol . FileRequestArgs ) {
1174
1182
if ( args . projectFileName ) {
1175
1183
const project = this . getProject ( args . projectFileName ) ;
@@ -1912,8 +1920,7 @@ namespace ts.server {
1912
1920
const scriptInfo = this . projectService . getScriptInfoOrConfig ( textChanges . fileName ) ;
1913
1921
if ( ! ! textChanges . isNewFile === ! ! scriptInfo ) {
1914
1922
if ( ! scriptInfo ) { // and !isNewFile
1915
- this . logger . msg ( `Could not find file ${ JSON . stringify ( textChanges . fileName ) } and 'isNewFile' not set.\n` +
1916
- `All files are: ${ JSON . stringify ( this . projectService . allScriptInfoFileNamesForDebug ( ) ) } ` , Msg . Err ) ;
1923
+ this . logErrorForScriptInfoNotFound ( textChanges . fileName ) ;
1917
1924
}
1918
1925
Debug . fail ( "Expected isNewFile for (only) new files. " + JSON . stringify ( { isNewFile : ! ! textChanges . isNewFile , hasScriptInfo : ! ! scriptInfo } ) ) ;
1919
1926
}
0 commit comments