@@ -449,6 +449,12 @@ interface GoToDirectiveInGroupParams {
449
449
next : boolean ;
450
450
} ;
451
451
452
+ interface SetTemporaryTextDocumentLanguageParams {
453
+ path : string ;
454
+ isC : boolean ;
455
+ isCuda : boolean ;
456
+ }
457
+
452
458
// Requests
453
459
const QueryCompilerDefaultsRequest : RequestType < QueryCompilerDefaultsParams , configs . CompilerDefaults , void , void > = new RequestType < QueryCompilerDefaultsParams , configs . CompilerDefaults , void , void > ( 'cpptools/queryCompilerDefaults' ) ;
454
460
const QueryTranslationUnitSourceRequest : RequestType < QueryTranslationUnitSourceParams , QueryTranslationUnitSourceResult , void , void > = new RequestType < QueryTranslationUnitSourceParams , QueryTranslationUnitSourceResult , void , void > ( 'cpptools/queryTranslationUnitSource' ) ;
@@ -509,6 +515,7 @@ const ShowWarningNotification: NotificationType<ShowWarningParams, void> = new N
509
515
const ReportTextDocumentLanguage : NotificationType < string , void > = new NotificationType < string , void > ( 'cpptools/reportTextDocumentLanguage' ) ;
510
516
const SemanticTokensChanged : NotificationType < string , void > = new NotificationType < string , void > ( 'cpptools/semanticTokensChanged' ) ;
511
517
const IntelliSenseSetupNotification : NotificationType < IntelliSenseSetup , void > = new NotificationType < IntelliSenseSetup , void > ( 'cpptools/IntelliSenseSetup' ) ;
518
+ const SetTemporaryTextDocumentLanguageNotification : NotificationType < SetTemporaryTextDocumentLanguageParams , void > = new NotificationType < SetTemporaryTextDocumentLanguageParams , void > ( 'cpptools/setTemporaryTextDocumentLanguage' ) ;
512
519
513
520
let failureMessageShown : boolean = false ;
514
521
@@ -1971,6 +1978,7 @@ export class DefaultClient implements Client {
1971
1978
this . languageClient . onNotification ( ReportTextDocumentLanguage , ( e ) => this . setTextDocumentLanguage ( e ) ) ;
1972
1979
this . languageClient . onNotification ( SemanticTokensChanged , ( e ) => this . semanticTokensProvider ?. invalidateFile ( e ) ) ;
1973
1980
this . languageClient . onNotification ( IntelliSenseSetupNotification , ( e ) => this . logIntellisenseSetupTime ( e ) ) ;
1981
+ this . languageClient . onNotification ( SetTemporaryTextDocumentLanguageNotification , ( e ) => this . setTemporaryTextDocumentLanguage ( e ) ) ;
1974
1982
setupOutputHandlers ( ) ;
1975
1983
}
1976
1984
@@ -1984,6 +1992,14 @@ export class DefaultClient implements Client {
1984
1992
}
1985
1993
}
1986
1994
1995
+ private async setTemporaryTextDocumentLanguage ( params : SetTemporaryTextDocumentLanguageParams ) : Promise < void > {
1996
+ const languageId : string = params . isC ? "c" : ( params . isCuda ? "cuda-cpp" : "cpp" ) ;
1997
+ const document : vscode . TextDocument = await vscode . workspace . openTextDocument ( params . path ) ;
1998
+ if ( ! ! document && document . languageId !== languageId ) {
1999
+ vscode . languages . setTextDocumentLanguage ( document , languageId ) ;
2000
+ }
2001
+ }
2002
+
1987
2003
private associations_for_did_change ?: Set < string > ;
1988
2004
1989
2005
/**
0 commit comments