@@ -1617,7 +1617,7 @@ namespace ts.projectSystem {
1617
1617
checkProjectActualFiles ( projectService . inferredProjects [ 1 ] , [ file2 . path ] ) ;
1618
1618
} ) ;
1619
1619
1620
- it ( "loading files with correct priority" , ( ) => {
1620
+ it ( "loading files with correct priority" , ( ) => {
1621
1621
const f1 = {
1622
1622
path : "/a/main.ts" ,
1623
8000
1623
content : "let x = 1"
@@ -1642,14 +1642,14 @@ namespace ts.projectSystem {
1642
1642
} ) ;
1643
1643
projectService . openClientFile ( f1 . path ) ;
1644
1644
projectService . checkNumberOfProjects ( { configuredProjects : 1 } ) ;
1645
- checkProjectActualFiles ( projectService . configuredProjects [ 0 ] , [ f1 . path ] ) ;
1645
+ checkProjectActualFiles ( projectService . configuredProjects [ 0 ] , [ f1 . path ] ) ;
1646
1646
1647
1647
projectService . closeClientFile ( f1 . path ) ;
1648
1648
1649
1649
projectService . openClientFile ( f2 . path ) ;
1650
1650
projectService . checkNumberOfProjects ( { configuredProjects : 1 , inferredProjects : 1 } ) ;
1651
- checkProjectActualFiles ( projectService . configuredProjects [ 0 ] , [ f1 . path ] ) ;
1652
- checkProjectActualFiles ( projectService . inferredProjects [ 0 ] , [ f2 . path ] ) ;
1651
+ checkProjectActualFiles ( projectService . configuredProjects [ 0 ] , [ f1 . path ] ) ;
1652
+ checkProjectActualFiles ( projectService . inferredProjects [ 0 ] , [ f2 . path ] ) ;
1653
1653
} ) ;
1654
1654
1655
1655
it ( "tsconfig script block support" , ( ) => {
@@ -1767,7 +1767,7 @@ namespace ts.projectSystem {
1767
1767
// #3. Ensure no errors when compiler options aren't specified
1768
1768
const config3 = {
1769
1769
path : "/a/b/tsconfig.json" ,
1770
- content : JSON . stringify ( { } )
1770
+ content : JSON . stringify ( { } )
1771
1771
} ;
1772
1772
1773
1773
host = createServerHost ( [ file1 , file2 , config3 , libFile ] , { executingFilePath : combinePaths ( getDirectoryPath ( libFile . path ) , "tsc.js" ) } ) ;
@@ -3267,13 +3267,13 @@ namespace ts.projectSystem {
3267
3267
assert . equal ( ( < protocol . CompileOnSaveAffectedFileListSingleProject [ ] > response ) [ 0 ] . projectUsesOutFile , expectedUsesOutFile , "usesOutFile" ) ;
3268
3268
}
3269
3269
3270
- it ( "projectUsesOutFile should not be returned if not set" , ( ) => {
3270
+ it ( "projectUsesOutFile should not be returned if not set" , ( ) => {
3271
3271
test ( { } , /*expectedUsesOutFile*/ false ) ;
3272
3272
} ) ;
3273
- it ( "projectUsesOutFile should be true if outFile is set" , ( ) => {
3273
+ it ( "projectUsesOutFile should be true if outFile is set" , ( ) => {
3274
3274
test ( { outFile : "/a/out.js" } , /*expectedUsesOutFile*/ true ) ;
3275
3275
} ) ;
3276
- it ( "projectUsesOutFile should be true if out is set" , ( ) => {
3276
+ it ( "projectUsesOutFile should be true if out is set" , ( ) => {
3277
3277
test ( { out : "/a/out.js" } , /*expectedUsesOutFile*/ true ) ;
3278
3278
} ) ;
3279
3279
} ) ;
@@ -3311,9 +3311,7 @@ namespace ts.projectSystem {
3311
3311
assert . isDefined ( test2Entry , "should contain 'Test2'" ) ;
3312
3312
3313
3313
assert . isTrue ( test1Entry . hasAction , "should set the 'hasAction' property to true for Test1" ) ;
3314
- assert . equal ( test1Entry . sourceFileName , file2 . path , "should have the correct source file name" ) ;
3315
3314
assert . isUndefined ( test2Entry . hasAction , "should not set the 'hasAction' property for Test2" ) ;
3316
- assert . isUndefined ( test2Entry . sourceFileName , "should not set the 'sourceFileName' property for Test2" ) ;
3317
3315
} ) ;
3318
3316
} ) ;
3319
3317
@@ -3407,7 +3405,7 @@ namespace ts.projectSystem {
3407
3405
} ;
3408
3406
} ) ( ) ;
3409
3407
const host = createServerHost ( [ f1 , config ] ) ;
3410
- const session = createSession ( host , /*typingsInstaller*/ undefined , ( ) => { } , cancellationToken ) ;
3408
+ const session = createSession ( host , /*typingsInstaller*/ undefined , ( ) => { } , cancellationToken ) ;
3411
3409
{
3412
3410
session . executeCommandSeq ( < protocol . OpenRequest > {
3413
3411
command : "open" ,
@@ -3574,6 +3572,70 @@ namespace ts.projectSystem {
3574
3572
} ) ;
3575
3573
} ) ;
3576
3574
3575
+ describe ( "completion entry with code actions" , ( ) => {
3576
+ it ( "should work for symbols from non-imported modules" , ( ) => {
3577
+ const moduleFile = {
3578
+ path : "/a/b/moduleFile.ts" ,
3579
+ content : `export const guitar = 10;`
3580
+ } ;
3581
+ const file1 = {
3582
+ path : "/a/b/file2.ts" ,
3583
+ content : ``
3584
+ } ;
3585
+ const globalFile = {
3586
+ path : "/a/b/globalFile.ts" ,
3587
+ content : `interface Jazz { }`
3588
+ } ;
3589
+ const ambientModuleFile = {
3590
+ path : "/a/b/ambientModuleFile.ts" ,
3591
+ content :
3592
+ `declare module "windyAndWarm" {
3593
+ export const chetAtkins = "great";
3594
+ }`
3595
+ } ;
3596
+ const defaultModuleFile = {
3597
+ path : "/a/b/defaultModuleFile.ts" ,
3598
+ content :
3599
+ `export default function egyptianElla() { };`
3600
+ } ;
3601
+ const configFile = {
3602
+ path : "/a/b/tsconfig.json" ,
3603
+ content : "{}"
3604
+ } ;
3605
+
3606
+ const host = createServerHost ( [ moduleFile , file1 , globalFile , ambientModuleFile , defaultModuleFile , configFile ] ) ;
3607
+ const session = createSession ( host ) ;
3608
+ const projectService = session . getProjectService ( ) ;
3609
+ projectService . openClientFile ( file1 . path ) ;
3610
+
3611
+ checkEntryDetail ( "guitar" , /*hasAction*/ true , `import { guitar } from "./moduleFile";\n\n` ) ;
3612
+ checkEntryDetail ( "Jazz" , /*hasAction*/ false ) ;
3613
+ checkEntryDetail ( "chetAtkins" , /*hasAction*/ true , `import { chetAtkins } from "windyAndWarm";\n\n` ) ;
3614
+ checkEntryDetail ( "egyptianElla" , /*hasAction*/ true , `import egyptianElla from "./defaultModuleFile";\n\n` ) ;
3615
+
3616
+ function checkEntryDetail ( entryName : string , hasAction : boolean , insertString ?: string ) {
3617
+ const request = makeSessionRequest < protocol . CompletionDetailsRequestArgs > (
3618
+ CommandNames . CompletionDetails ,
3619
+ { entryNames : [ entryName ] , file : file1 . path , line : 1 , offset : 0 , projectFileName : configFile . path } ) ;
3620
+ const response = session . executeCommand ( request ) . response as protocol . CompletionEntryDetails [ ] ;
3621
+ assert . isTrue ( response . length === 1 ) ;
3622
+
3623
+ const entryDetails = response [ 0 ] ;
3624
+ if ( ! hasAction ) {
3625
+ assert . isUndefined ( entryDetails . codeActions ) ;
3626
+ }
3627
+ else {
3628
+ const action = entryDetails . codeActions [ 0 ] ;
3629
+ assert . isTrue ( action . changes [ 0 ] . fileName === file1 . path ) ;
3630
+ assert . deepEqual ( action . changes [ 0 ] , < protocol . FileCodeEdits > {
3631
+ fileName : file1 . path ,
3632
+ textChanges : [ { start : { line : 1 , offset : 1 } , end : { line : 1 , offset : 1 } , newText : insertString } ]
3633
+ } ) ;
3634
+ }
3635
+ }
3636
+ } ) ;
3637
+ } ) ;
3638
+
3577
3639
describe ( "maxNodeModuleJsDepth for inferred projects" , ( ) => {
3578
3640
it ( "should be set to 2 if the project has js root files" , ( ) => {
3579
3641
const file1 : FileOrFolder = {
0 commit comments