Add exported members of all project files in the global completion list (#19069)
* checker.ts: Remove null check on symbols
* tsserverProjectSystem.ts: add two tests
* client.ts, completions.ts, types.ts: Add codeActions member to CompletionEntryDetails
* protocol.ts, session.ts: Add codeActions member to CompletionEntryDetails protocol
* protocol.ts, session.ts, types.ts: add hasAction to CompletionEntry
* session.ts, services.ts, types.ts: Add formattingOptions parameter to getCompletionEntryDetails
* completions.ts: define SymbolOriginInfo type
* completions.ts, services.ts: Add allSourceFiles parameter to getCompletionsAtPosition
* completions.ts, services.ts: Plumb allSourceFiles into new function getSymbolsFromOtherSourceFileExports inside getCompletionData
* completions.ts: add symbolToOriginInfoMap parameter to getCompletionEntriesFromSymbols and to return value of getCompletionData
* utilities.ts: Add getOtherModuleSymbols, getUniqueSymbolIdAsString, getUniqueSymbolId
* completions.ts: Set CompletionEntry.hasAction when symbol is found in symbolToOriginInfoMap (meaning there's an import action)
* completions.ts: Populate list with possible exports (implement getSymbolsFromOtherSourceFileExports)
* completions.ts, services.ts: Plumb host and rulesProvider into getCompletionEntryDetails
* completions.ts: Add TODO comment
* importFixes.ts: Add types ImportDeclarationMap and ImportCodeFixContext
* Move getImportDeclarations into getCodeActionForImport, immediately after the implementation
* importFixes.ts: Move createChangeTracker into getCodeActionForImport, immediately after getImportDeclarations
* importFixes.ts: Add convertToImportCodeFixContext function and reference it from the getCodeActions lambda
* importFixes.ts: Add context: ImportCodeFixContext parameter to getCodeActionForImport, update call sites, destructure it, use compilerOptions in getModuleSpecifierForNewImport
* importFixes.ts: Remove moduleSymbol parameter from getImportDeclarations and use the ambient one
* importFixes.ts: Use cachedImportDeclarations from context in getCodeActionForImport
* importFixes.ts: Move createCodeAction out, immediately above convertToImportCodeFixContext
* Move the declaration for lastImportDeclaration out of the getCodeActions lambda into getCodeActionForImport
* importFixes.ts: Use symbolToken in getCodeActionForImport
* importFixes.ts: Remove useCaseSensitiveFileNames altogether from getCodeActions lambda
* importFixes.ts: Remove local getUniqueSymbolId function and add checker parameter to calls to it
* importFixes.ts: Move getCodeActionForImport out into an export, immediately below convertToImportCodeFixContext
* completions.ts: In getCompletionEntryDetails, if there's symbolOriginInfo, call getCodeActionForImport
* importFixes.ts: Create and use importFixContext within getCodeActions lambda
* importFixes.ts: Use local newLineCharacter instead of context.newLineCharacter in getCodeActionForImport
* importFixes.ts: Use local host instead of context.host in getCodeActionForImport
* importFixes.ts: Remove dummy getCanonicalFileName line
* Filter symbols after gathering exports instead of before
* Lint
* Test, fix bugs, refactor
* Suggestions from code review
* Update api baseline
* Fix bug if previousToken is not an Identifier
* Replace `startsWith` with `stringContainsCharactersInOrder`
2017-10-17 19:20:11 +02:00
|
|
|
/// <reference path="fourslash.ts" />
|
|
|
|
|
2018-04-02 19:21:14 +02:00
|
|
|
// @module: esnext
|
2017-11-16 20:15:14 +01:00
|
|
|
|
Add exported members of all project files in the global completion list (#19069)
* checker.ts: Remove null check on symbols
* tsserverProjectSystem.ts: add two tests
* client.ts, completions.ts, types.ts: Add codeActions member to CompletionEntryDetails
* protocol.ts, session.ts: Add codeActions member to CompletionEntryDetails protocol
* protocol.ts, session.ts, types.ts: add hasAction to CompletionEntry
* session.ts, services.ts, types.ts: Add formattingOptions parameter to getCompletionEntryDetails
* completions.ts: define SymbolOriginInfo type
* completions.ts, services.ts: Add allSourceFiles parameter to getCompletionsAtPosition
* completions.ts, services.ts: Plumb allSourceFiles into new function getSymbolsFromOtherSourceFileExports inside getCompletionData
* completions.ts: add symbolToOriginInfoMap parameter to getCompletionEntriesFromSymbols and to return value of getCompletionData
* utilities.ts: Add getOtherModuleSymbols, getUniqueSymbolIdAsString, getUniqueSymbolId
* completions.ts: Set CompletionEntry.hasAction when symbol is found in symbolToOriginInfoMap (meaning there's an import action)
* completions.ts: Populate list with possible exports (implement getSymbolsFromOtherSourceFileExports)
* completions.ts, services.ts: Plumb host and rulesProvider into getCompletionEntryDetails
* completions.ts: Add TODO comment
* importFixes.ts: Add types ImportDeclarationMap and ImportCodeFixContext
* Move getImportDeclarations into getCodeActionForImport, immediately after the implementation
* importFixes.ts: Move createChangeTracker into getCodeActionForImport, immediately after getImportDeclarations
* importFixes.ts: Add convertToImportCodeFixContext function and reference it from the getCodeActions lambda
* importFixes.ts: Add context: ImportCodeFixContext parameter to getCodeActionForImport, update call sites, destructure it, use compilerOptions in getModuleSpecifierForNewImport
* importFixes.ts: Remove moduleSymbol parameter from getImportDeclarations and use the ambient one
* importFixes.ts: Use cachedImportDeclarations from context in getCodeActionForImport
* importFixes.ts: Move createCodeAction out, immediately above convertToImportCodeFixContext
* Move the declaration for lastImportDeclaration out of the getCodeActions lambda into getCodeActionForImport
* importFixes.ts: Use symbolToken in getCodeActionForImport
* importFixes.ts: Remove useCaseSensitiveFileNames altogether from getCodeActions lambda
* importFixes.ts: Remove local getUniqueSymbolId function and add checker parameter to calls to it
* importFixes.ts: Move getCodeActionForImport out into an export, immediately below convertToImportCodeFixContext
* completions.ts: In getCompletionEntryDetails, if there's symbolOriginInfo, call getCodeActionForImport
* importFixes.ts: Create and use importFixContext within getCodeActions lambda
* importFixes.ts: Use local newLineCharacter instead of context.newLineCharacter in getCodeActionForImport
* importFixes.ts: Use local host instead of context.host in getCodeActionForImport
* importFixes.ts: Remove dummy getCanonicalFileName line
* Filter symbols after gathering exports instead of before
* Lint
* Test, fix bugs, refactor
* Suggestions from code review
* Update api baseline
* Fix bug if previousToken is not an Identifier
* Replace `startsWith` with `stringContainsCharactersInOrder`
2017-10-17 19:20:11 +02:00
|
|
|
// @Filename: /a.ts
|
|
|
|
////export default function foo() {}
|
|
|
|
|
|
|
|
// @Filename: /b.ts
|
|
|
|
////f/**/;
|
|
|
|
|
2018-10-29 18:03:25 +01:00
|
|
|
verify.completions({
|
|
|
|
marker: "",
|
2018-10-30 19:56:34 +01:00
|
|
|
includes: {
|
|
|
|
name: "foo",
|
|
|
|
source: "/a",
|
|
|
|
sourceDisplay: "./a",
|
|
|
|
text: "function foo(): void",
|
|
|
|
kind: "function",
|
|
|
|
kindModifiers: "export",
|
|
|
|
hasAction: true,
|
2019-05-16 23:46:10 +02:00
|
|
|
sortText: completion.SortText.AutoImportSuggestions
|
2018-10-30 19:56:34 +01:00
|
|
|
},
|
2018-10-29 18:03:25 +01:00
|
|
|
preferences: { includeCompletionsForModuleExports: true },
|
2017-11-14 23:26:49 +01:00
|
|
|
});
|
Add exported members of all project files in the global completion list (#19069)
* checker.ts: Remove null check on symbols
* tsserverProjectSystem.ts: add two tests
* client.ts, completions.ts, types.ts: Add codeActions member to CompletionEntryDetails
* protocol.ts, session.ts: Add codeActions member to CompletionEntryDetails protocol
* protocol.ts, session.ts, types.ts: add hasAction to CompletionEntry
* session.ts, services.ts, types.ts: Add formattingOptions parameter to getCompletionEntryDetails
* completions.ts: define SymbolOriginInfo type
* completions.ts, services.ts: Add allSourceFiles parameter to getCompletionsAtPosition
* completions.ts, services.ts: Plumb allSourceFiles into new function getSymbolsFromOtherSourceFileExports inside getCompletionData
* completions.ts: add symbolToOriginInfoMap parameter to getCompletionEntriesFromSymbols and to return value of getCompletionData
* utilities.ts: Add getOtherModuleSymbols, getUniqueSymbolIdAsString, getUniqueSymbolId
* completions.ts: Set CompletionEntry.hasAction when symbol is found in symbolToOriginInfoMap (meaning there's an import action)
* completions.ts: Populate list with possible exports (implement getSymbolsFromOtherSourceFileExports)
* completions.ts, services.ts: Plumb host and rulesProvider into getCompletionEntryDetails
* completions.ts: Add TODO comment
* importFixes.ts: Add types ImportDeclarationMap and ImportCodeFixContext
* Move getImportDeclarations into getCodeActionForImport, immediately after the implementation
* importFixes.ts: Move createChangeTracker into getCodeActionForImport, immediately after getImportDeclarations
* importFixes.ts: Add convertToImportCodeFixContext function and reference it from the getCodeActions lambda
* importFixes.ts: Add context: ImportCodeFixContext parameter to getCodeActionForImport, update call sites, destructure it, use compilerOptions in getModuleSpecifierForNewImport
* importFixes.ts: Remove moduleSymbol parameter from getImportDeclarations and use the ambient one
* importFixes.ts: Use cachedImportDeclarations from context in getCodeActionForImport
* importFixes.ts: Move createCodeAction out, immediately above convertToImportCodeFixContext
* Move the declaration for lastImportDeclaration out of the getCodeActions lambda into getCodeActionForImport
* importFixes.ts: Use symbolToken in getCodeActionForImport
* importFixes.ts: Remove useCaseSensitiveFileNames altogether from getCodeActions lambda
* importFixes.ts: Remove local getUniqueSymbolId function and add checker parameter to calls to it
* importFixes.ts: Move getCodeActionForImport out into an export, immediately below convertToImportCodeFixContext
* completions.ts: In getCompletionEntryDetails, if there's symbolOriginInfo, call getCodeActionForImport
* importFixes.ts: Create and use importFixContext within getCodeActions lambda
* importFixes.ts: Use local newLineCharacter instead of context.newLineCharacter in getCodeActionForImport
* importFixes.ts: Use local host instead of context.host in getCodeActionForImport
* importFixes.ts: Remove dummy getCanonicalFileName line
* Filter symbols after gathering exports instead of before
* Lint
* Test, fix bugs, refactor
* Suggestions from code review
* Update api baseline
* Fix bug if previousToken is not an Identifier
* Replace `startsWith` with `stringContainsCharactersInOrder`
2017-10-17 19:20:11 +02:00
|
|
|
verify.applyCodeActionFromCompletion("", {
|
|
|
|
name: "foo",
|
2017-10-26 17:22:17 +02:00
|
|
|
source: "/a",
|
2018-08-01 02:28:35 +02:00
|
|
|
description: `Import default 'foo' from module "./a"`,
|
2018-01-12 02:43:27 +01:00
|
|
|
newFileContent: `import foo from "./a";
|
|
|
|
|
Add exported members of all project files in the global completion list (#19069)
* checker.ts: Remove null check on symbols
* tsserverProjectSystem.ts: add two tests
* client.ts, completions.ts, types.ts: Add codeActions member to CompletionEntryDetails
* protocol.ts, session.ts: Add codeActions member to CompletionEntryDetails protocol
* protocol.ts, session.ts, types.ts: add hasAction to CompletionEntry
* session.ts, services.ts, types.ts: Add formattingOptions parameter to getCompletionEntryDetails
* completions.ts: define SymbolOriginInfo type
* completions.ts, services.ts: Add allSourceFiles parameter to getCompletionsAtPosition
* completions.ts, services.ts: Plumb allSourceFiles into new function getSymbolsFromOtherSourceFileExports inside getCompletionData
* completions.ts: add symbolToOriginInfoMap parameter to getCompletionEntriesFromSymbols and to return value of getCompletionData
* utilities.ts: Add getOtherModuleSymbols, getUniqueSymbolIdAsString, getUniqueSymbolId
* completions.ts: Set CompletionEntry.hasAction when symbol is found in symbolToOriginInfoMap (meaning there's an import action)
* completions.ts: Populate list with possible exports (implement getSymbolsFromOtherSourceFileExports)
* completions.ts, services.ts: Plumb host and rulesProvider into getCompletionEntryDetails
* completions.ts: Add TODO comment
* importFixes.ts: Add types ImportDeclarationMap and ImportCodeFixContext
* Move getImportDeclarations into getCodeActionForImport, immediately after the implementation
* importFixes.ts: Move createChangeTracker into getCodeActionForImport, immediately after getImportDeclarations
* importFixes.ts: Add convertToImportCodeFixContext function and reference it from the getCodeActions lambda
* importFixes.ts: Add context: ImportCodeFixContext parameter to getCodeActionForImport, update call sites, destructure it, use compilerOptions in getModuleSpecifierForNewImport
* importFixes.ts: Remove moduleSymbol parameter from getImportDeclarations and use the ambient one
* importFixes.ts: Use cachedImportDeclarations from context in getCodeActionForImport
* importFixes.ts: Move createCodeAction out, immediately above convertToImportCodeFixContext
* Move the declaration for lastImportDeclaration out of the getCodeActions lambda into getCodeActionForImport
* importFixes.ts: Use symbolToken in getCodeActionForImport
* importFixes.ts: Remove useCaseSensitiveFileNames altogether from getCodeActions lambda
* importFixes.ts: Remove local getUniqueSymbolId function and add checker parameter to calls to it
* importFixes.ts: Move getCodeActionForImport out into an export, immediately below convertToImportCodeFixContext
* completions.ts: In getCompletionEntryDetails, if there's symbolOriginInfo, call getCodeActionForImport
* importFixes.ts: Create and use importFixContext within getCodeActions lambda
* importFixes.ts: Use local newLineCharacter instead of context.newLineCharacter in getCodeActionForImport
* importFixes.ts: Use local host instead of context.host in getCodeActionForImport
* importFixes.ts: Remove dummy getCanonicalFileName line
* Filter symbols after gathering exports instead of before
* Lint
* Test, fix bugs, refactor
* Suggestions from code review
* Update api baseline
* Fix bug if previousToken is not an Identifier
* Replace `startsWith` with `stringContainsCharactersInOrder`
2017-10-17 19:20:11 +02:00
|
|
|
f;`,
|
|
|
|
});
|