wip
This commit is contained in:
parent
51feae52b4
commit
619a5152df
|
@ -9675,7 +9675,6 @@ namespace ts {
|
||||||
return Ternary.False;
|
return Ternary.False;
|
||||||
}
|
}
|
||||||
if (sourcePropAccessibility) {
|
if (sourcePropAccessibility) {
|
||||||
//Hmm, this will have to take into account nominal equivalence?
|
|
||||||
if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) {
|
if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) {
|
||||||
return Ternary.False;
|
return Ternary.False;
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ namespace ts {
|
||||||
text = "";
|
text = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return text !== undefined ? createSourceFile(fileName, text, languageVersion, setParentNodes, /*scriptKind*/ undefined) : undefined;
|
return text !== undefined ? createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function directoryExists(directoryPath: string): boolean {
|
function directoryExists(directoryPath: string): boolean {
|
||||||
|
@ -449,7 +449,7 @@ namespace ts {
|
||||||
resolveModuleNamesWorker = (moduleNames, containingFile) => host.resolveModuleNames(moduleNames, containingFile).map(resolved => {
|
resolveModuleNamesWorker = (moduleNames, containingFile) => host.resolveModuleNames(moduleNames, containingFile).map(resolved => {
|
||||||
// An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName.
|
// An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName.
|
||||||
if (!resolved || (resolved as ResolvedModuleFull).extension !== undefined) {
|
if (!resolved || (resolved as ResolvedModuleFull).extension !== undefined) {
|
||||||
//Note: packageName may be undefined, I don't care
|
// Host may not have set packageName, but it's OK to leave it as undefined.
|
||||||
return resolved as ResolvedModuleFull;
|
return resolved as ResolvedModuleFull;
|
||||||
}
|
}
|
||||||
const withExtension = clone(resolved) as ResolvedModuleFull;
|
const withExtension = clone(resolved) as ResolvedModuleFull;
|
||||||
|
@ -1527,19 +1527,19 @@ namespace ts {
|
||||||
function findSourceFile(fileName: string, path: Path, packageName: string | undefined, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile {
|
function findSourceFile(fileName: string, path: Path, packageName: string | undefined, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile {
|
||||||
if (filesByName.contains(path)) {
|
if (filesByName.contains(path)) {
|
||||||
const file = filesByName.get(path);
|
const file = filesByName.get(path);
|
||||||
|
if (!file) return undefined;
|
||||||
|
|
||||||
//TODO: we do if (file) too much...
|
setPackageName(file, packageName);
|
||||||
if (file) setPackageName(file, packageName);
|
|
||||||
|
|
||||||
// try to check if we've already seen this file but with a different casing in path
|
// try to check if we've already seen this file but with a different casing in path
|
||||||
// NOTE: this only makes sense for case-insensitive file systems
|
// NOTE: this only makes sense for case-insensitive file systems
|
||||||
if (file && options.forceConsistentCasingInFileNames && getNormalizedAbsolutePath(file.fileName, currentDirectory) !== getNormalizedAbsolutePath(fileName, currentDirectory)) {
|
if (options.forceConsistentCasingInFileNames && getNormalizedAbsolutePath(file.fileName, currentDirectory) !== getNormalizedAbsolutePath(fileName, currentDirectory)) {
|
||||||
reportFileNamesDifferOnlyInCasingError(fileName, file.fileName, refFile, refPos, refEnd);
|
reportFileNamesDifferOnlyInCasingError(fileName, file.fileName, refFile, refPos, refEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the file was previously found via a node_modules search, but is now being processed as a root file,
|
// If the file was previously found via a node_modules search, but is now being processed as a root file,
|
||||||
// then everything it sucks in may also be marked incorrectly, and needs to be checked again.
|
// then everything it sucks in may also be marked incorrectly, and needs to be checked again.
|
||||||
if (file && sourceFilesFoundSearchingNodeModules.get(file.path) && currentNodeModulesDepth === 0) {
|
if (sourceFilesFoundSearchingNodeModules.get(file.path) && currentNodeModulesDepth === 0) {
|
||||||
sourceFilesFoundSearchingNodeModules.set(file.path, false);
|
sourceFilesFoundSearchingNodeModules.set(file.path, false);
|
||||||
if (!options.noResolve) {
|
if (!options.noResolve) {
|
||||||
processReferencedFiles(file, isDefaultLib);
|
processReferencedFiles(file, isDefaultLib);
|
||||||
|
@ -1550,7 +1550,7 @@ namespace ts {
|
||||||
processImportedModules(file);
|
processImportedModules(file);
|
||||||
}
|
}
|
||||||
// See if we need to reprocess the imports due to prior skipped imports
|
// See if we need to reprocess the imports due to prior skipped imports
|
||||||
else if (file && modulesWithElidedImports.get(file.path)) {
|
else if (modulesWithElidedImports.get(file.path)) {
|
||||||
if (currentNodeModulesDepth < maxNodeModuleJsDepth) {
|
if (currentNodeModulesDepth < maxNodeModuleJsDepth) {
|
||||||
modulesWithElidedImports.set(file.path, false);
|
modulesWithElidedImports.set(file.path, false);
|
||||||
processImportedModules(file);
|
processImportedModules(file);
|
||||||
|
@ -1572,48 +1572,51 @@ namespace ts {
|
||||||
});
|
});
|
||||||
|
|
||||||
filesByName.set(path, file);
|
filesByName.set(path, file);
|
||||||
if (file) {
|
if (!file) return undefined;
|
||||||
sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
|
|
||||||
setPackageName(file, packageName);
|
|
||||||
file.path = path;
|
|
||||||
|
|
||||||
if (host.useCaseSensitiveFileNames()) {
|
sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
|
||||||
// for case-sensitive file systems check if we've already seen some file with similar filename ignoring case
|
setPackageName(file, packageName);
|
||||||
const existingFile = filesByNameIgnoreCase.get(path);
|
file.path = path;
|
||||||
if (existingFile) {
|
|
||||||
reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
filesByNameIgnoreCase.set(path, file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib;
|
if (host.useCaseSensitiveFileNames()) {
|
||||||
|
// for case-sensitive file systems check if we've already seen some file with similar filename ignoring case
|
||||||
if (!options.noResolve) {
|
const existingFile = filesByNameIgnoreCase.get(path);
|
||||||
processReferencedFiles(file, isDefaultLib);
|
if (existingFile) {
|
||||||
processTypeReferenceDirectives(file);
|
reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd);
|
||||||
}
|
|
||||||
|
|
||||||
// always process imported modules to record module name resolutions
|
|
||||||
processImportedModules(file);
|
|
||||||
|
|
||||||
if (isDefaultLib) {
|
|
||||||
files.unshift(file);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
files.push(file);
|
filesByNameIgnoreCase.set(path, file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib;
|
||||||
|
|
||||||
|
if (!options.noResolve) {
|
||||||
|
processReferencedFiles(file, isDefaultLib);
|
||||||
|
processTypeReferenceDirectives(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
// always process imported modules to record module name resolutions
|
||||||
|
processImportedModules(file);
|
||||||
|
|
||||||
|
if (isDefaultLib) {
|
||||||
|
files.unshift(file);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
files.push(file);
|
||||||
|
}
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
//neater
|
|
||||||
function setPackageName(file: SourceFile, packageName: string | undefined) {
|
function setPackageName(file: SourceFile, packageName: string | undefined): void {
|
||||||
if (packageName === undefined) return;
|
if (packageName === undefined) {
|
||||||
if (file.packageName === undefined) {
|
return;
|
||||||
|
}
|
||||||
|
else if (file.packageName === undefined) {
|
||||||
file.packageName = packageName;
|
file.packageName = packageName;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
Debug.assert(file.packageName === packageName, "Same source file loaded from two different packages", () =>
|
Debug.assert(file.packageName === packageName, "Same source file loaded from two different packages", () =>
|
||||||
`Packages are ${file.packageName} and ${packageName}`);
|
`Packages are ${file.packageName} and ${packageName}`);
|
||||||
}
|
}
|
||||||
|
@ -1652,6 +1655,7 @@ namespace ts {
|
||||||
let saveResolution = true;
|
let saveResolution = true;
|
||||||
if (resolvedTypeReferenceDirective) {
|
if (resolvedTypeReferenceDirective) {
|
||||||
if (resolvedTypeReferenceDirective.primary) {
|
if (resolvedTypeReferenceDirective.primary) {
|
||||||
|
//pass along resolvedTypeReferenceDirective.packageName?
|
||||||
// resolved from the primary path
|
// resolved from the primary path
|
||||||
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd);
|
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2280,12 +2280,12 @@ namespace ts {
|
||||||
|
|
||||||
fileName: string;
|
fileName: string;
|
||||||
/* @internal */ path: Path;
|
/* @internal */ path: Path;
|
||||||
//This will be set if this is resolved by getting something from node_modules.
|
/** This will be set if the source file is resolved from an external library import. */
|
||||||
/* @internal */ packageName: string | undefined;
|
/* @internal */ packageName: string | undefined;
|
||||||
text: string;
|
text: string;
|
||||||
|
|
||||||
amdDependencies: AmdDependency[];
|
amdDependencies: AmdDependency[];
|
||||||
moduleName: string; //This is set by an `/// <amd-module name="foo" />` directive.
|
moduleName: string; // This is set by an `/// <amd-module name="foo" />` directive.
|
||||||
referencedFiles: FileReference[];
|
referencedFiles: FileReference[];
|
||||||
typeReferenceDirectives: FileReference[];
|
typeReferenceDirectives: FileReference[];
|
||||||
languageVariant: LanguageVariant;
|
languageVariant: LanguageVariant;
|
||||||
|
@ -3851,8 +3851,11 @@ namespace ts {
|
||||||
* This is optional for backwards-compatibility, but will be added if not provided.
|
* This is optional for backwards-compatibility, but will be added if not provided.
|
||||||
*/
|
*/
|
||||||
extension: Extension;
|
extension: Extension;
|
||||||
//Note: this is a breaking change...
|
/**
|
||||||
packageName: string | undefined;
|
* Name of the external library that the resolution came from.
|
||||||
|
* For `node_modules/@types/foo/bar.d.ts`, the packageName should be `foo/bar`.
|
||||||
|
*/
|
||||||
|
packageName?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum Extension {
|
export enum Extension {
|
||||||
|
@ -3870,6 +3873,7 @@ namespace ts {
|
||||||
failedLookupLocations: string[];
|
failedLookupLocations: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//packageName here?
|
||||||
export interface ResolvedTypeReferenceDirective {
|
export interface ResolvedTypeReferenceDirective {
|
||||||
// True if the type declaration file was found in a primary lookup location
|
// True if the type declaration file was found in a primary lookup location
|
||||||
primary: boolean;
|
primary: boolean;
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace ts {
|
||||||
assert.deepEqual(actual.failedLookupLocations, expectedFailedLookupLocations);
|
assert.deepEqual(actual.failedLookupLocations, expectedFailedLookupLocations);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createResolvedModule(resolvedFileName: string, isExternalLibraryImport = false, packageName: string | undefined = undefined): ResolvedModuleFull {
|
export function createResolvedModule(resolvedFileName: string, isExternalLibraryImport = false, packageName?: string): ResolvedModuleFull {
|
||||||
return { resolvedFileName, extension: extensionFromPath(resolvedFileName), packageName, isExternalLibraryImport };
|
return { resolvedFileName, extension: extensionFromPath(resolvedFileName), packageName, isExternalLibraryImport };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace ts {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
it("printFile", () => {
|
it("printFile", () => {
|
||||||
const printsCorrectly = makePrintsCorrectly("printsFileCorrectly");
|
const printsCorrectly = makePrintsCorrectly("printsFileCorrectly");
|
||||||
const sourceFile = createSourceFile("source.ts", `
|
const sourceFile = createSourceFile("source.ts", `
|
||||||
interface A<T> {
|
interface A<T> {
|
||||||
|
|
|
@ -482,7 +482,7 @@ namespace ts {
|
||||||
public kind: SyntaxKind.SourceFile;
|
public kind: SyntaxKind.SourceFile;
|
||||||
public _declarationBrand: any;
|
public _declarationBrand: any;
|
||||||
public fileName: string;
|
public fileName: string;
|
||||||
public packageName: string | undefined;
|
/* @internal */ public packageName: string | undefined;
|
||||||
public path: Path;
|
public path: Path;
|
||||||
public text: string;
|
public text: string;
|
||||||
public scriptSnapshot: IScriptSnapshot;
|
public scriptSnapshot: IScriptSnapshot;
|
||||||
|
@ -941,7 +941,6 @@ namespace ts {
|
||||||
sourceFile.scriptSnapshot = scriptSnapshot;
|
sourceFile.scriptSnapshot = scriptSnapshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: this is public, so packageName must go on the end and be optional
|
|
||||||
export function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean, scriptKind?: ScriptKind): SourceFile {
|
export function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean, scriptKind?: ScriptKind): SourceFile {
|
||||||
const text = scriptSnapshot.getText(0, scriptSnapshot.getLength());
|
const text = scriptSnapshot.getText(0, scriptSnapshot.getLength());
|
||||||
const sourceFile = createSourceFile(fileName, text, scriptTarget, setNodeParents, scriptKind);
|
const sourceFile = createSourceFile(fileName, text, scriptTarget, setNodeParents, scriptKind);
|
||||||
|
@ -1142,8 +1141,8 @@ namespace ts {
|
||||||
|
|
||||||
// Now create a new compiler
|
// Now create a new compiler
|
||||||
const compilerHost: CompilerHost = {
|
const compilerHost: CompilerHost = {
|
||||||
getSourceFile: getOrCreateSourceFile, //packageName
|
getSourceFile: getOrCreateSourceFile,
|
||||||
getSourceFileByPath: getOrCreateSourceFileByPath, //packageName
|
getSourceFileByPath: getOrCreateSourceFileByPath,
|
||||||
getCancellationToken: () => cancellationToken,
|
getCancellationToken: () => cancellationToken,
|
||||||
getCanonicalFileName,
|
getCanonicalFileName,
|
||||||
useCaseSensitiveFileNames: () => useCaseSensitivefileNames,
|
useCaseSensitiveFileNames: () => useCaseSensitivefileNames,
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
[0531/071111.044:ERROR:tcp_listen_socket.cc(76)] Could not bind socket to 127.0.0.1:5959
|
|
||||||
[0531/071111.044:ERROR:node_debugger.cc(87)] Cannot start debugger server
|
|
||||||
[0531/071111.491:ERROR:tcp_listen_socket.cc(76)] Could not bind socket to 127.0.0.1:5960
|
|
||||||
[0531/071111.492:ERROR:node_debugger.cc(87)] Cannot start debugger server
|
|
Loading…
Reference in a new issue