@@ -11,6 +11,7 @@ import ts from 'typescript';
1111import { GetComponentLocationsForTemplateResponse , GetTcbResponse , GetTemplateLocationForComponentResponse , isNgLanguageService , NgLanguageService } from '../api' ;
1212
1313import { LanguageService } from './language_service' ;
14+ import { isTypeScriptFile } from './utils' ;
1415
1516export function create ( info : ts . server . PluginCreateInfo ) : NgLanguageService {
1617 const { project, languageService, config} = info ;
@@ -23,15 +24,15 @@ export function create(info: ts.server.PluginCreateInfo): NgLanguageService {
2324
2425 function getSemanticDiagnostics ( fileName : string ) : ts . Diagnostic [ ] {
2526 const diagnostics : ts . Diagnostic [ ] = [ ] ;
26- if ( ! angularOnly ) {
27+ if ( ! angularOnly && isTypeScriptFile ( fileName ) ) {
2728 diagnostics . push ( ...tsLS . getSemanticDiagnostics ( fileName ) ) ;
2829 }
2930 diagnostics . push ( ...ngLS . getSemanticDiagnostics ( fileName ) ) ;
3031 return diagnostics ;
3132 }
3233
3334 function getQuickInfoAtPosition ( fileName : string , position : number ) : ts . QuickInfo | undefined {
34- if ( angularOnly ) {
35+ if ( angularOnly || ! isTypeScriptFile ( fileName ) ) {
3536 return ngLS . getQuickInfoAtPosition ( fileName , position ) ;
3637 } else {
3738 // If TS could answer the query, then return that result. Otherwise, return from Angular LS.
@@ -42,7 +43,7 @@ export function create(info: ts.server.PluginCreateInfo): NgLanguageService {
4243
4344 function getTypeDefinitionAtPosition (
4445 fileName : string , position : number ) : readonly ts . DefinitionInfo [ ] | undefined {
45- if ( angularOnly ) {
46+ if ( angularOnly || ! isTypeScriptFile ( fileName ) ) {
4647 return ngLS . getTypeDefinitionAtPosition ( fileName , position ) ;
4748 } else {
4849 // If TS could answer the query, then return that result. Otherwise, return from Angular LS.
@@ -53,7 +54,7 @@ export function create(info: ts.server.PluginCreateInfo): NgLanguageService {
5354
5455 function getDefinitionAndBoundSpan (
5556 fileName : string , position : number ) : ts . DefinitionInfoAndBoundSpan | undefined {
56- if ( angularOnly ) {
57+ if ( angularOnly || ! isTypeScriptFile ( fileName ) ) {
5758 return ngLS . getDefinitionAndBoundSpan ( fileName , position ) ;
5859 } else {
5960 // If TS could answer the query, then return that result. Otherwise, return from Angular LS.
@@ -85,7 +86,7 @@ export function create(info: ts.server.PluginCreateInfo): NgLanguageService {
8586 function getCompletionsAtPosition (
8687 fileName : string , position : number ,
8788 options : ts . GetCompletionsAtPositionOptions ) : ts . WithMetadata < ts . CompletionInfo > | undefined {
88- if ( angularOnly ) {
89+ if ( angularOnly || ! isTypeScriptFile ( fileName ) ) {
8990 return ngLS . getCompletionsAtPosition ( fileName , position , options ) ;
9091 } else {
9192 // If TS could answer the query, then return that result. Otherwise, return from Angular LS.
@@ -99,7 +100,7 @@ export function create(info: ts.server.PluginCreateInfo): NgLanguageService {
99100 formatOptions : ts . FormatCodeOptions | ts . FormatCodeSettings | undefined , source : string | undefined ,
100101 preferences : ts . UserPreferences | undefined ,
101102 data : ts . CompletionEntryData | undefined ) : ts . CompletionEntryDetails | undefined {
102- if ( angularOnly ) {
103+ if ( angularOnly || ! isTypeScriptFile ( fileName ) ) {
103104 return ngLS . getCompletionEntryDetails (
104105 fileName , position , entryName , formatOptions , preferences , data ) ;
105106 } else {
@@ -114,7 +115,7 @@ export function create(info: ts.server.PluginCreateInfo): NgLanguageService {
114115 function getCompletionEntrySymbol (
115116 fileName : string , position : number , name : string , source : string | undefined ) : ts . Symbol |
116117 undefined {
117- if ( angularOnly ) {
118+ if ( angularOnly || ! isTypeScriptFile ( fileName ) ) {
118119 return ngLS . getCompletionEntrySymbol ( fileName , position , name ) ;
119120 } else {
120121 // If TS could answer the query, then return that result. Otherwise, return from Angular LS.
@@ -137,7 +138,7 @@ export function create(info: ts.server.PluginCreateInfo): NgLanguageService {
137138 function getSignatureHelpItems (
138139 fileName : string , position : number ,
139140 options : ts . SignatureHelpItemsOptions ) : ts . SignatureHelpItems | undefined {
140- if ( angularOnly ) {
141+ if ( angularOnly || ! isTypeScriptFile ( fileName ) ) {
141142 return ngLS . getSignatureHelpItems ( fileName , position , options ) ;
142143 } else {
143144 return tsLS . getSignatureHelpItems ( fileName , position , options ) ??
@@ -146,7 +147,7 @@ export function create(info: ts.server.PluginCreateInfo): NgLanguageService {
146147 }
147148
148149 function getOutliningSpans ( fileName : string ) : ts . OutliningSpan [ ] {
149- if ( angularOnly ) {
150+ if ( angularOnly || ! isTypeScriptFile ( fileName ) ) {
150151 return ngLS . getOutliningSpans ( fileName ) ;
151152 } else {
152153 return tsLS . getOutliningSpans ( fileName ) ?? ngLS . getOutliningSpans ( fileName ) ;
@@ -178,7 +179,7 @@ export function create(info: ts.server.PluginCreateInfo): NgLanguageService {
178179 fileName : string , start : number , end : number , errorCodes : readonly number [ ] ,
179180 formatOptions : ts . FormatCodeSettings ,
180181 preferences : ts . UserPreferences ) : readonly ts . CodeFixAction [ ] {
181- if ( angularOnly ) {
182+ if ( angularOnly || ! isTypeScriptFile ( fileName ) ) {
182183 return ngLS . getCodeFixesAtPosition (
183184 fileName , start , end , errorCodes , formatOptions , preferences ) ;
184185 } else {
0 commit comments