8000 feat(typescript-estree): add debug logs for useProgramFromProjectService by JoshuaKGoldberg · Pull Request #8426 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

feat(typescript-estree): add debug logs for useProgramFromProjectService #8426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
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
18 changes: 18 additions & 0 deletions packages/typescript-estree/src/useProgramFromProjectService.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import debug from 'debug';
import { minimatch } from 'minimatch';

import { createProjectProgram } from './create-program/createProjectProgram';
Expand All @@ -9,12 +10,17 @@ import {
} from './create-program/shared';
import type { MutableParseSettings } from './parseSettings';

const log = debug(
'typescript-eslint:typescript-estree:useProgramFromProjectService',
);

export function useProgramFromProjectService(
{ allowDefaultProjectForFiles, service }: ProjectServiceSettings,
parseSettings: Readonly<MutableParseSettings>,
hasFullTypeInformation: boolean,
): ASTAndDefiniteProgram | undefined {
const filePath = getCanonicalFileName(parseSettings.filePath);
log('Opening project service file for: %s', filePath);

const opened = service.openClientFile(
ensureAbsolutePath(filePath, service.host.getCurrentDirectory()),
Expand All @@ -23,7 +29,14 @@ export function useProgramFromProjectService(
parseSettings.tsconfigRootDir,
);

log('Opened project service file: %o', opened);

if (hasFullTypeInformation) {
log(
'Project service type information enabled; checking for file path match on: %o',
allowDefaultProjectForFiles,
);

if (opened.configFileName) {
if (filePathMatchedBy(filePath, allowDefaultProjectForFiles)) {
throw new Error(
Expand All @@ -37,16 +50,21 @@ export function useProgramFromProjectService(
}
}

log('Retrieving script info and then program for: %s', filePath);

const scriptInfo = service.getScriptInfo(filePath);
const program = service
.getDefaultProjectForFile(scriptInfo!.fileName, true)!
.getLanguageService(/*ensureSynchronized*/ true)
.getProgram();

if (!program) {
log('Could not find project service program for: %s', filePath);
return undefined;
}

log('Found project service program for: %s', filePath);

return createProjectProgram(parseSettings, [program]);
}

Expand Down
0