Skip to content

Commit

Permalink
Address feedback. Minor cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Sep 22, 2022
1 parent 9913815 commit 3d35a2c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions packages/labs/analyzer/src/lib/analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ export class Analyzer implements AnalyzerInterface {
}
}

/**
* Extracts a `ts.ParsedCommandLine` (essentially, the key bits of a
* `tsconfig.json`) from the analyzer's `ts.Program`.
*
* The `ts.getOutputFileNames()` function must be passed a
* `ts.ParsedCommandLine`; since not all usages of the analyzer create the
* program directly from a tsconfig (plugins get passed the program only),
* this allows backing the `ParsedCommandLine` out of an existing program.
*/
export const getCommandLineFromProgram = (analyzer: Analyzer) => {
const compilerOptions = analyzer.program.getCompilerOptions();
const commandLine = ts.parseJsonConfigFileContent(
Expand Down
2 changes: 1 addition & 1 deletion packages/labs/analyzer/src/lib/references.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import ts from 'typescript';
import path from 'path';
import {DiagnosticsError} from './errors.js';
import {AnalyzerInterface, Reference} from './model.js';
import {getModule} from './javascript/modules.js';
Expand Down Expand Up @@ -45,6 +44,7 @@ export function getReferenceForSymbol(
location: ts.Node,
analyzer: AnalyzerInterface
): Reference {
const {path} = analyzer;
const {name} = symbol;
// TODO(kschaaf): Do we need to check other declarations? The assumption is
// that even with multiple declarations (e.g. because of class interface +
Expand Down

0 comments on commit 3d35a2c

Please sign in to comment.