Skip to content

Commit

Permalink
fix: multiple parses for the same project
Browse files Browse the repository at this point in the history
  • Loading branch information
harttle committed Nov 21, 2019
1 parent 617f8c4 commit 60424d1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/parsers/san-app-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const debug = debugFactory('component-parser')
export class SanAppParser {
private root: string
private id: number = 0
private cache: Map<SourceFile, SanSourceFile> = new Map()
public project: Project

constructor (project: Project) {
Expand Down Expand Up @@ -72,7 +73,16 @@ export class SanAppParser {
}

private parseSanSourceFile (sourceFile: SourceFile) {
if (!this.cache.has(sourceFile)) {
this.cache.set(sourceFile, this.doParseSanSourceFile(sourceFile))
}
console.log('cache size', this.cache.size)
return this.cache.get(sourceFile)
}

private doParseSanSourceFile (sourceFile: SourceFile) {
debug('parseSanSourceFile', sourceFile.getFilePath())
sourceFile.refreshFromFileSystemSync()
const componentClassIdentifier = getComponentClassIdentifier(sourceFile)
const sanSourceFile = SanSourceFile.createFromTSSourceFile(sourceFile, componentClassIdentifier)

Expand Down

0 comments on commit 60424d1

Please sign in to comment.