95 Commits

Author SHA1 Message Date
Wesley Wigham
b0ea899d13
Use the full local file path as the id for a submodule (#21471)
* Use the full file path as the id for a submodule

* Informal code review feedback
2018-01-30 11:09:48 -08:00
Andy
b363f4f9cd
Log packageId in --traceResolution (#21233) 2018-01-17 11:41:23 -08:00
Andy
61fb845b87
Get packageId for relative import within a package (#21130)
* Get packageId for relative import within a package

* Code review

* Rename things and add comments

* Improve documentation

* Test for scoped packages
2018-01-17 11:14:03 -08:00
Andrew Casey
9a4fe8eb7e Rename getPackageNameFromAtTypesDirectoryWithoutPrefix to getUnmangledNameForScopedPackage 2018-01-10 15:17:27 -08:00
Andrew Casey
db09a593d3 Unmangle package names from typings during completion 2018-01-09 16:45:42 -08:00
Andy
18a7c3fb53
For import fix, prefer symlink over a real path (#20395)
* For import fix, prefer symlink over a real path

* fixes

* Use best result from all symlinks

* Make originalPath optional more

* Only include real path if a symlink isn't available
2017-12-06 11:27:38 -08:00
Andy
d05443bb1d Add quickfix and refactoring to install @types packages (#19130)
* Add quickfix and refactoring to install @types packages

* Move `validatePackageName` to `jsTyping.ts`

* Remove combinePaths overloads

* Respond to code review

* Update api baselines

* Use native PromiseConstructor

* Return false instead of undefined

* Remove getProjectRootPath

* Update api
2017-10-17 15:04:09 -07:00
Andy
2b566b9a53 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 10:20:11 -07:00
Andy
2cb0403e2d Support 'package.json' not in package root (#19133)
* Support 'package.json' not in package root

* Test "foo/@bar"

* More tests, and don't use "types" from the root package.json if not loading the root module
2017-10-16 13:02:15 -07:00
Sheetal Nandi
e30a66d22f Add utitlity for stringContains 2017-10-10 17:16:39 -07:00
Sheetal Nandi
23acff5bc8 Merge branch 'master' into watchImprovements 2017-09-25 16:18:26 -07:00
Andy
d5e7227dbb Look at correct 'package.json' location for a scoped package (#18580)
* Look at correct 'package.json' location for a scoped package

* Update baseline
2017-09-20 08:15:24 -07:00
Sheetal Nandi
fdb104b242 Merge branch 'master' into watchImprovements 2017-09-11 13:49:36 -07:00
Andy
2e02778960 When loading a module from node_modules, get packageId even in the loadModuleFromFile case (#18185)
* When loading a module from node_modules, get packageId even in the `loadModuleFromFile` case

* Support packageId for <reference types> too
2017-09-07 14:31:20 -07:00
Sheetal Nandi
54f64a1695 Resolution is valid unless it is invalidated 2017-09-05 19:22:32 -07:00
Sheetal Nandi
60e2e68dfb Merge branch 'watchImprovements' into builder 2017-08-18 13:38:24 -07:00
Andy
eef7d8bd3d Treat explicit imports from node_modules as external library imports (#16364)
* Treat explicit imports from `node_modules` as external library imports

* Update baselines
2017-08-17 13:26:38 -07:00
Andy
93abebc04a Change function name to camelCase (#17751) 2017-08-15 12:26:00 -07:00
Sheetal Nandi
d0a23bb876 Merge branch 'watchImprovements' into builder 2017-08-12 15:35:30 -07:00
Andy
f64b8ad902 Add "preserveSymlinks" option (#16661)
* Add "preserveSymlinks" option

* Respond to PR comments
2017-08-11 10:03:21 -07:00
Andy
37b20ee670 For duplicate source files of the same package, make one redirect to the other (#16274)
* For duplicate source files of the same package, make one redirect to the other

* Add reuseProgramStructure tests

* Copy `sourceFileToPackageId` and `isSourceFileTargetOfRedirect` only if we completely reuse old structure

* Use fallthrough instead of early exit from loop

* Use a set to efficiently detect duplicate package names

* Move map setting outside of createRedirectSourceFile

* Correctly handle seenPackageNames set

* sourceFileToPackageId -> sourceFileToPackageName

* Renames

* Respond to PR comments

* Fix bug where `oldSourceFile !== newSourceFile` because oldSourceFile was a redirect

* Clean up redirectInfo

* Respond to PR comments
2017-08-09 14:39:06 -07:00
Andy
382785a528 Fix logging of module resolution errors (#17144) 2017-08-08 07:54:08 -07:00
Sheetal Nandi
7474ba762c Implementation for invalidating source file containing possibly changed module resolution 2017-08-07 11:31:13 -07:00
Sheetal Nandi
273569f6fe Make the host cache store the fileName instead of undefined for the missing host files 2017-08-07 11:04:33 -07:00
Andy
124510e409 Add comment clarifying isNotNeededPackage (#17321) 2017-07-26 07:09:22 -07:00
Andy
f0bd91c314 Convert Array to ReadonlyArray/Push in commandLineParser.ts (#17323) 2017-07-21 07:16:22 -07:00
Andy
680bfbb705 Combine moduleHasNonRelativeName with isExternalModuleNameRelative (#16564) 2017-07-13 13:46:04 -07:00
Andy
e7dc2a67ca Enable "object-literal-shorthand" lint rule (#16987) 2017-07-07 07:26:58 -07:00
Andy
9013665e22 Replace FileMap with Map where there is no keyMapper (#16724)
* Replace FileMap with Map where there is no keyMapper

* Remove `toKey` and use `keyMapper` directly
2017-06-28 13:15:34 -07:00
Andy
aeb5264b74 Consistently use variable mangledScopedPackageSeparator instead of magic "__" string (#16713) 2017-06-26 11:10:57 -07:00
Andy
09321b3834 Convert Extension to a string enum (#16425) 2017-06-09 19:32:44 -07:00
Andy Hanson
3690926e62 In path mapping module resolution, try loading from path as directory even if it has an extension 2017-05-23 08:11:42 -07:00
Arthur Ozga
567b10d71c Merge pull request #15545 from aozgaa/atTypesPrefixAndImportSuffix
At types prefix and import suffix
2017-05-22 16:53:04 -07:00
Andy Hanson
7c89ff7d77 Inline resolvedModuleFromResolved 2017-05-11 13:39:37 -07:00
Andy Hanson
5c5b5e9a3b Fail on bad moduleResolution kind 2017-05-11 09:07:03 -07:00
Andy
0b0a2d070b Merge pull request #15039 from Microsoft/resolveJavaScriptModule
Refactor how we (internally) expose JS module resolution
2017-05-08 10:52:17 -07:00
Arthur Ozga
7282b9f0ce make internal 2017-05-03 14:12:24 -07:00
Arthur Ozga
5ce32ccbe3 factor out helpers + cleanup startsWith and friends 2017-05-03 13:13:28 -07:00
Arthur Ozga
cbbf6f8847 Merge branch 'master' into tripleEquals 2017-04-17 15:57:51 -07:00
Mohamed Hegazy
4e29b1883d Merge pull request #15051 from Microsoft/at_types
Support @types module resolution from scoped packages
2017-04-17 10:08:15 -07:00
Andy Hanson
c0d26e81f1 Merge branch 'master' into resolveJavaScriptModule 2017-04-14 10:15:30 -07:00
Andy Hanson
ed5eca2b7b boolean-trivia lint rule: Enforce space between comment and argument 2017-04-11 09:44:58 -07:00
Andy Hanson
e9f95e2296 Only trace if traceEnabled 2017-04-10 09:06:26 -07:00
Andy Hanson
8ec593aec2 Support @types module resolution from scoped packages 2017-04-06 08:05:30 -07:00
Andy Hanson
4a3b38b274 Refactor how we (internally) expose JS module resolution
Also, provide a useful error if resolution fails.
2017-04-05 15:33:01 -07:00
Arthur Ozga
3bdec6943e Merge branch 'master' into tripleEquals 2017-04-05 11:51:21 -07:00
Arthur Ozga
7e03429a8e enforce triple-equals 2017-04-04 15:51:13 -07:00
Andy Hanson
73cab09608 Enable jsdoc-format lint rule 2017-04-03 14:39:19 -07:00
Andy Hanson
2305c10a65 Fix lint errors 2017-03-17 13:54:18 -07:00
Andy Hanson
3bc125463b Add more missing semicolons 2017-03-03 07:00:52 -08:00