Comparing version 0.6.0-next.14 to 0.6.0-next.15
@@ -231,7 +231,25 @@ import * as ts from 'typescript'; | ||
} | ||
export interface Reporter { | ||
reportProgress(scannedFiles: number): void; | ||
export interface Logger { | ||
reportProgress(fileName: string): void; | ||
reportStatus(projectName: string, numberOfSymbols: number, numberOfDocuments: number, time: number | undefined): void; | ||
reportInternalSymbol(symbol: ts.Symbol, symbolId: SymbolId, location: ts.Node | undefined): void; | ||
beginProject(projectName: string): void; | ||
startEndProject(projectName: string): void; | ||
doneEndProject(projectName: string): void; | ||
beginDataManager(): void; | ||
startEndDataManager(): void; | ||
doneEndDataManager(): void; | ||
} | ||
export declare class NullLogger implements Logger { | ||
constructor(); | ||
reportProgress(_fileName: string): void; | ||
reportStatus(_projectName: string, _numberOfSymbols: number, _numberOfDocuments: number, _time: number | undefined): void; | ||
reportInternalSymbol(_symbol: ts.Symbol, _symbolId: string, _location: ts.Node): void; | ||
beginProject(_name: string): void; | ||
startEndProject(_name: string): void; | ||
doneEndProject(_name: string): void; | ||
beginDataManager(): void; | ||
startEndDataManager(): void; | ||
doneEndDataManager(): void; | ||
} | ||
export interface Options { | ||
@@ -244,3 +262,3 @@ workspaceRoot: string; | ||
dataMode: DataMode; | ||
reporter: Reporter; | ||
logger: Logger; | ||
} | ||
@@ -259,3 +277,3 @@ declare enum ParseMode { | ||
private readonly projectData; | ||
private readonly reporter; | ||
private readonly logger; | ||
private documentStats; | ||
@@ -265,3 +283,3 @@ private readonly documentDataItems; | ||
private readonly managedSymbolDataItems; | ||
constructor(id: ProjectId, context: ProjectDataManagerContext, project: Project, reporter: Reporter); | ||
constructor(id: ProjectId, context: ProjectDataManagerContext, project: Project, logger: Logger); | ||
abstract getParseMode(): ParseMode; | ||
@@ -307,2 +325,3 @@ manageSymbolData(symbolData: SymbolData): void; | ||
constructor(context: TSProjectContext, languageService: ts.LanguageService, importMonikers: ImportMonikers, exportMonikers: ExportMonikers | undefined, references: ProjectInfo[], options: Options, symbolDataContext: SymbolDataContext); | ||
get name(): string; | ||
protected get vertex(): VertexBuilder; | ||
@@ -351,3 +370,3 @@ protected get edge(): EdgeBuilder; | ||
private readonly context; | ||
private readonly reporter; | ||
private readonly logger; | ||
private readonly dataMode; | ||
@@ -368,3 +387,3 @@ private readonly workspacePDM; | ||
readonly edge: EdgeBuilder; | ||
constructor(context: EmitterContext, workspaceRoot: string, reporter: Reporter, dataMode: DataMode); | ||
constructor(context: EmitterContext, workspaceRoot: string, logger: Logger, dataMode: DataMode); | ||
emit(element: Vertex | Edge): void; | ||
@@ -371,0 +390,0 @@ begin(): void; |
@@ -121,4 +121,5 @@ "use strict"; | ||
} | ||
class StreamReporter { | ||
class StreamLogger extends lsif_1.NullLogger { | ||
constructor(stream) { | ||
super(); | ||
this.stream = stream; | ||
@@ -131,4 +132,4 @@ this.reported = new Set(); | ||
} | ||
reportProgress(scannedFiles) { | ||
this.stream.write('.'.repeat(scannedFiles)); | ||
reportProgress(_fileName) { | ||
this.stream.write('.'); | ||
} | ||
@@ -180,4 +181,5 @@ reportStatus(projectName, numberOfSymbols, numberOfDocuments, time) { | ||
} | ||
class NullReporter { | ||
class InternalNullLogger extends lsif_1.NullLogger { | ||
constructor() { | ||
super(); | ||
} | ||
@@ -188,10 +190,4 @@ begin() { | ||
} | ||
reportProgress(_scannedFiles) { | ||
} | ||
reportStatus(_projectName, _numberOfSymbols, _numberOfDocuments, _time) { | ||
} | ||
reportInternalSymbol(_symbol, _symbolId, _location) { | ||
} | ||
} | ||
class FileReporter extends StreamReporter { | ||
class FileReporter extends StreamLogger { | ||
constructor(file, reportProgressOnStdout) { | ||
@@ -203,2 +199,44 @@ const stream = fs.createWriteStream(file, { encoding: 'utf8' }); | ||
} | ||
reportProgress(fileName) { | ||
if (this.reportProgressOnStdout) { | ||
process.stdout.write('.'); | ||
} | ||
this.writeTime(); | ||
this.fileStream.write(`Indexing file: ${fileName}${os.EOL}`); | ||
} | ||
beginProject(name) { | ||
this.writeTime(); | ||
this.fileStream.write(`Begin project ${name}${os.EOL}`); | ||
} | ||
startEndProject(name) { | ||
this.writeTime(); | ||
this.fileStream.write(`Start ending project ${name}${os.EOL}`); | ||
} | ||
reportStatus(projectName, numberOfSymbols, numberOfDocuments, time) { | ||
this.writeTime(); | ||
this.fileStream.write(`Processed ${numberOfSymbols} symbols in ${numberOfDocuments} files for project ${projectName}`); | ||
if (time !== undefined) { | ||
this.fileStream.write(` in ${time}ms.`); | ||
} | ||
else { | ||
this.fileStream.write('.'); | ||
} | ||
this.fileStream.write(os.EOL); | ||
} | ||
doneEndProject(name) { | ||
this.writeTime(); | ||
this.fileStream.write(`Done ending project ${name}${os.EOL}${os.EOL}`); | ||
} | ||
beginDataManager() { | ||
this.writeTime(); | ||
this.fileStream.write(`Begin global data manager${os.EOL}`); | ||
} | ||
startEndDataManager() { | ||
this.writeTime(); | ||
this.fileStream.write(`Start ending global data manager${os.EOL}`); | ||
} | ||
doneEndDataManager() { | ||
this.writeTime(); | ||
this.fileStream.write(`Done ending global data manager${os.EOL}`); | ||
} | ||
end() { | ||
@@ -210,7 +248,9 @@ this.fileStream.close(); | ||
} | ||
reportProgress(scannedFiles) { | ||
if (this.reportProgressOnStdout) { | ||
process.stdout.write('.'.repeat(scannedFiles)); | ||
} | ||
writeTime() { | ||
const date = new Date(); | ||
this.fileStream.write(`[${date.getFullYear()}-${this.pad(date.getMonth(), 2)}-${this.pad(date.getDay(), 2)} ${this.pad(date.getHours(), 2)}:${this.pad(date.getMinutes(), 2)}:${this.pad(date.getSeconds(), 2)}:${this.pad(date.getMilliseconds(), 3)}] `); | ||
} | ||
pad(value, digits) { | ||
return ('00' + value).slice(-1 * digits); | ||
} | ||
} | ||
@@ -388,3 +428,3 @@ function processProject(pclOrOptions, emitter, typingsInstaller, dataManager, importMonikers, exportMonikers, options) { | ||
stdout: options.stdout, | ||
reporter: options.reporter, | ||
logger: options.reporter, | ||
dataMode: options.dataMode, | ||
@@ -553,6 +593,6 @@ }; | ||
if (options.stdout) { | ||
reporter = new NullReporter(); | ||
reporter = new InternalNullLogger(); | ||
} | ||
else { | ||
reporter = new StreamReporter(process.stdout); | ||
reporter = new StreamLogger(process.stdout); | ||
} | ||
@@ -565,3 +605,3 @@ } | ||
else { | ||
reporter = new StreamReporter(process.stdout); | ||
reporter = new StreamLogger(process.stdout); | ||
} | ||
@@ -573,3 +613,3 @@ } | ||
else { | ||
reporter = new NullReporter(); | ||
reporter = new InternalNullLogger(); | ||
} | ||
@@ -576,0 +616,0 @@ reporter.begin(); |
{ | ||
"name": "lsif-tsc", | ||
"description": "Tool to create an LSIF dump for TypeScript projects.", | ||
"version": "0.6.0-next.14", | ||
"version": "0.6.0-next.15", | ||
"author": "Microsoft Corporation", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
633649
7308