Skip to content
Closed
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
14 changes: 9 additions & 5 deletions libs/core/src/true-affected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export const trueAffected = async ({
}

const affectedPackages = new Set<string>(changedIncludedFilesPackages);
const visitedIdentifiers = new Map<string, string[]>();
const visitedIdentifiers = new Map<string, Set<string>>();

const findReferencesLibs = (node: Node<ts.Node>) => {
const rootNode = findRootNode(node);
Expand Down Expand Up @@ -269,7 +269,6 @@ export const trueAffected = async ({
/* istanbul ignore next */
if (identifier == null) return;

const refs = identifier.findReferencesAsNodes();
const identifierName = identifier.getText();
const path = rootNode.getSourceFile().getFilePath();

Expand All @@ -278,22 +277,27 @@ export const trueAffected = async ({
);

if (identifierName && path) {
const visited = visitedIdentifiers.get(path) ?? [];
if (visited.includes(identifierName)) {
if (!visitedIdentifiers.has(path)) {
visitedIdentifiers.set(path, new Set());
}
const visited = visitedIdentifiers.get(path)!;
if (visited.has(identifierName)) {
logger.debug(
`Already visited ${chalk.bold(identifierName)} in ${chalk.bold(path)}`
);

return;
}

visitedIdentifiers.set(path, [...visited, identifierName]);
visited.add(identifierName);

logger.debug(
`Visiting ${chalk.bold(identifierName)} in ${chalk.bold(path)}`
);
}

const refs = identifier.findReferencesAsNodes();

refs.forEach((node) => {
const sourceFile = node.getSourceFile();
const pkg = getPackageNameByPath(sourceFile.getFilePath(), projects);
Expand Down