Skip to content
This repository has been archived by the owner on Jun 15, 2024. It is now read-only.

Commit

Permalink
refactor(core): use system in the format diagnostics host
Browse files Browse the repository at this point in the history
  • Loading branch information
jordimarimon committed Mar 11, 2024
1 parent c4e48ca commit 7c66aed
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
10 changes: 4 additions & 6 deletions packages/core/src/analyser-diagnostic.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ts from 'typescript';
import type { AnalyserSystem } from './system/analyser-system.js';


/**
Expand All @@ -25,14 +26,11 @@ export class AnalyserDiagnostic {

private readonly _formatDiagnosticHost: ts.FormatDiagnosticsHost;

private readonly _cwd: string;

constructor(cwd: string) {
this._cwd = cwd;
constructor(system: AnalyserSystem) {
this._formatDiagnosticHost = {
getCanonicalFileName: (name: string) => name,
getCurrentDirectory: () => this._cwd,
getNewLine: () => '\n',
getCurrentDirectory: () => system.getCurrentDirectory(),
getNewLine: () => system.newLine,
};
}

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class Project {
this._program = program;
this._commandLine = commandLine;
this._options = options;
this._diagnostics = new AnalyserDiagnostic(system.getCurrentDirectory());
this._diagnostics = new AnalyserDiagnostic(system);
this._packageJson = this._getPackageJSON();
this._context = new ProjectContext(
system,
Expand Down Expand Up @@ -191,7 +191,7 @@ export class Project {
* @returns True if the source file has been already analysed, false otherwise
*/
has(filePath: string): boolean {
const normalizedPath = this._context.getSystem().normalizePath(filePath);
const normalizedPath = this._system.normalizePath(filePath);
return this._modules.some(m => m.getSourcePath() === normalizedPath);
}

Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/system/analyser-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ export interface AnalyserSystem extends ts.System {
getAbsolutePath(path: string): string;

/**
* Returns the real location of the path.
*
* This is handy when resolving symlinks.
* Returns the real location of the path (resolves symlinks).
*/
realpath(path: string): string;

Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/utils/member.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { isThirdParty } from './import.js';
import ts from 'typescript';


// TODO(Jordi M.): Create method that abstracts the call to "ts.canHaveModifier"
// as this method only exists in TS >= 4.8

export function getVisibilityModifier(member: ts.ClassElement): ModifierType {
const modifierFlags = ts.getCombinedModifierFlags(member);

Expand Down
3 changes: 1 addition & 2 deletions tailwind.config.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
'./docs/**/*.{njk,md,html}',
'./scripts/docs/generate-api-reference.js',
'./docs/**/*.{njk,md,html}'
],

theme: {
Expand Down

0 comments on commit 7c66aed

Please sign in to comment.