Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d0282b7
Add test to verify when source changes
sheetalkamat Jun 13, 2019
0adab89
Use source files instead of .d.ts files from project references
sheetalkamat Jun 21, 2019
c97be16
Log the config of the project
sheetalkamat Jun 21, 2019
746b01e
Check only for .d.ts files
sheetalkamat Jun 21, 2019
ecf8751
Check for language serivice enabled when including source files
sheetalkamat Jun 21, 2019
1810288
Fix tests
sheetalkamat Jun 21, 2019
f472868
Watch generated file if it doesnt exist when trying to translate it t…
sheetalkamat Jun 25, 2019
012ecda
Add sourceOf project reference redirect to filesByName list for redir…
sheetalkamat Jun 26, 2019
2f30add
More tests
sheetalkamat Jun 26, 2019
da9260c
Create original project when location is in source of project referen…
sheetalkamat Jun 26, 2019
75bd3cd
Fix more tests
sheetalkamat Jun 27, 2019
96a8c86
Merge branch 'master' into referencesPrototypeSourceFile
sheetalkamat Jun 28, 2019
f72af3b
Verify the scenarios when d.ts directory of dependency doesnt exist
sheetalkamat Jun 28, 2019
4d13f53
Merge branch 'master' into referencesPrototypeSourceFile
sheetalkamat Jul 1, 2019
f9e4b91
Fix incorrectly exported type
sheetalkamat Jul 1, 2019
f7ea0ba
Refactoring
sheetalkamat Jul 1, 2019
b5737fc
Refactor tests so its easy to edit and reason about them
sheetalkamat Jul 2, 2019
15b68a9
Skip typechecking of source of project reference redirect
sheetalkamat Jul 1, 2019
9be475b
Refactoring
sheetalkamat Jul 3, 2019
b1fa2eb
Errors using DiagnosticsSync commands
sheetalkamat Jul 5, 2019
824c22c
Source of project reference behave as if those files cannot be emitted.
sheetalkamat Jul 8, 2019
b631850
Add option disableSourceOfProjectReferenceRedirect to disable using s…
sheetalkamat Jul 10, 2019
103fe5f
Merge branch 'master' into referencesPrototypeSourceFile
sheetalkamat Jul 11, 2019
666c4be
Merge branch 'master' into referencesPrototypeSourceFile
sheetalkamat Jul 25, 2019
4c4ddf8
Merge branch 'master' into referencesPrototypeSourceFile
sheetalkamat Aug 21, 2019
c6e502b
Verify config file errors
sheetalkamat Aug 22, 2019
076dde4
Test with --out as well
sheetalkamat Aug 22, 2019
a469fd8
Should not report that files are not part of config for files that ar…
sheetalkamat Aug 22, 2019
6e09169
Merge branch 'master' into referencesPrototypeSourceFile
sheetalkamat Aug 22, 2019
54d9ce9
Merge branch 'master' into referencesPrototypeSourceFile
sheetalkamat Sep 5, 2019
b26ca16
Merge branch 'master' into referencesPrototypeSourceFile
sheetalkamat Sep 11, 2019
432da93
Add doc comments for fileExists and directoryExists implementation
sheetalkamat Sep 23, 2019
fd3ba67
Reword the option description per feedback
sheetalkamat Sep 24, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Create original project when location is in source of project referen…
…ce redirect
  • Loading branch information
sheetalkamat committed Jun 27, 2019
commit da9260c01305bc4f91193f787c868f0def6c0f48
2 changes: 1 addition & 1 deletion src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ namespace ts {
let projectReferenceRedirects: Map<ResolvedProjectReference | false> | undefined;
let mapFromFileToProjectReferenceRedirects: Map<Path> | undefined;
let mapFromToProjectReferenceRedirectSource: Map<SourceOfProjectReferenceRedirect> | undefined;
const useSourceOfReference = host.useSourceInsteadOfReferenceRedirect && host.useSourceInsteadOfReferenceRedirect();
const useSourceOfReference = useSourceInsteadOfReferenceRedirect(host);

const shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
const structuralIsReused = tryReuseStructureFromOldProgram();
Expand Down
4 changes: 4 additions & 0 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4614,6 +4614,10 @@ namespace ts {
return false;
}
}

export function useSourceInsteadOfReferenceRedirect(host: { useSourceInsteadOfReferenceRedirect?(): boolean; }) {
return host.useSourceInsteadOfReferenceRedirect && host.useSourceInsteadOfReferenceRedirect();
}
}

namespace ts {
Expand Down
7 changes: 5 additions & 2 deletions src/server/editorServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2570,7 +2570,9 @@ namespace ts.server {

/*@internal*/
getOriginalLocationEnsuringConfiguredProject(project: Project, location: DocumentPosition): DocumentPosition | undefined {
const originalLocation = project.getSourceMapper().tryGetSourcePosition(location);
const originalLocation = useSourceInsteadOfReferenceRedirect(project) && project.getResolvedProjectReferenceToRedirect(location.fileName) ?
location :
project.getSourceMapper().tryGetSourcePosition(location);
if (!originalLocation) return undefined;

const { fileName } = originalLocation;
Expand All @@ -2581,7 +2583,8 @@ namespace ts.server {
if (!configFileName) return undefined;

const configuredProject = this.findConfiguredProjectByProjectName(configFileName) ||
this.createAndLoadConfiguredProject(configFileName, `Creating project for original file: ${originalFileInfo.fileName} for location: ${location.fileName}`);
this.createAndLoadConfiguredProject(configFileName, `Creating project for original file: ${originalFileInfo.fileName}${location !== originalLocation ? " for location " + location.fileName : ""}`);
if (configuredProject === project) return originalLocation;
updateProjectIfDirty(configuredProject);
// Keep this configured project as referenced from project
addOriginalConfiguredProject(configuredProject);
Expand Down
18 changes: 15 additions & 3 deletions src/server/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ namespace ts.server {
/*@internal*/
originalConfiguredProjects: Map<true> | undefined;

/*@internal*/
useSourceInsteadOfReferenceRedirect?: () => boolean;

/*@internal*/
getResolvedProjectReferenceToRedirect(_fileName: string): ResolvedProjectReference | undefined {
return undefined;
}

private readonly cancellationToken: ThrottledCancellationToken;

public isNonTsProject() {
Expand Down Expand Up @@ -1526,9 +1534,7 @@ namespace ts.server {
}

/* @internal */
useSourceInsteadOfReferenceRedirect() {
return !!this.languageServiceEnabled;
}
useSourceInsteadOfReferenceRedirect = () => !!this.languageServiceEnabled;

fileExists(file: string): boolean {
// Project references go to source file instead of .d.ts file
Expand Down Expand Up @@ -1590,6 +1596,12 @@ namespace ts.server {
return program && program.forEachResolvedProjectReference(cb);
}

/*@internal*/
getResolvedProjectReferenceToRedirect(fileName: string): ResolvedProjectReference | undefined {
const program = this.getCurrentProgram();
return program && program.getResolvedProjectReferenceToRedirect(fileName);
}

/*@internal*/
enablePluginsWithOptions(options: CompilerOptions, pluginConfigOverrides: Map<any> | undefined) {
const host = this.projectService.host;
Expand Down
6 changes: 4 additions & 2 deletions src/server/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,9 @@ namespace ts.server {

function getDefinitionInProject(definition: DocumentPosition | undefined, definingProject: Project, project: Project): DocumentPosition | undefined {
if (!definition || project.containsFile(toNormalizedPath(definition.fileName))) return definition;
const mappedDefinition = definingProject.getLanguageService().getSourceMapper().tryGetGeneratedPosition(definition);
const mappedDefinition = useSourceInsteadOfReferenceRedirect(definingProject) && definingProject.getResolvedProjectReferenceToRedirect(definition.fileName) ?
definition :
definingProject.getLanguageService().getSourceMapper().tryGetGeneratedPosition(definition);
return mappedDefinition && project.containsFile(toNormalizedPath(mappedDefinition.fileName)) ? mappedDefinition : undefined;
}

Expand Down Expand Up @@ -472,7 +474,7 @@ namespace ts.server {
for (const symlinkedProject of symlinkedProjects) addToTodo({ project: symlinkedProject, location: originalLocation as TLocation }, toDo!, seenProjects);
});
}
return originalLocation;
return originalLocation === location ? undefined : originalLocation;
});
return toDo;
}
Expand Down
7 changes: 4 additions & 3 deletions src/services/sourcemaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ namespace ts {

const program = host.getProgram()!;
// If this is source file of project reference source (instead of redirect) there is no generated position
if (host.useSourceInsteadOfReferenceRedirect &&
host.useSourceInsteadOfReferenceRedirect() &&
program.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) return undefined;
if (useSourceInsteadOfReferenceRedirect(host) &&
program.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) {
return undefined;
}

const options = program.getCompilerOptions();
const outPath = options.outFile || options.out;
Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/unittests/tsserver/events/projectLoading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ namespace ts.projectSystem {
checkNumberOfProjects(service, { configuredProjects: 2 });
const project = service.configuredProjects.get(configA.path)!;
assert.isDefined(project);
verifyEvent(project, `Creating project for original file: ${aTs.path} for location: ${aDTs.path}`);
verifyEvent(project, `Creating project for original file: ${aTs.path}`);
});

describe("with external projects and config files ", () => {
Expand Down