Move claritas invocation to separate function, clean versions in Claritas.

This commit is contained in:
Daniel Scalzi committed 2020-07-16 20:26:22 -04:00
1 parent ea23912a85
commit 0ac31e5eb7
2 files changed
+32 -27

No files matched your search

Binary file not shown.
+32 -27
View File
@@ -126,6 +126,36 @@ export abstract class ModuleStructure extends BaseModelStructure<Module> {
} }
protected async invokeClaritas(moduleCandidates: ModuleCandidate[]): Promise<void> {
if(this.getClaritasType() != null) {
const claritasExecutor = new ClaritasWrapper()
let claritasCandidates = moduleCandidates
const exceptionCandidates: [ModuleCandidate, ClaritasException][] = []
for(const exception of this.getClaritasExceptions()) {
const exceptionCandidate = moduleCandidates.find((value) => value.file.toLowerCase().indexOf(exception.exceptionName) > -1)
if(exceptionCandidate != null) {
exceptionCandidates.push([exceptionCandidate, exception])
claritasCandidates = claritasCandidates.filter((value) => value.file.toLowerCase().indexOf(exception.exceptionName) === -1)
}
}
this.claritasResult = await claritasExecutor.execute(
this.getClaritasType()!,
this.minecraftVersion,
claritasCandidates.map(entry => entry.filePath)
)
if(this.claritasResult == null) {
this.logger.error('Failed to process Claritas result!')
} else {
for(const [candidate, exception] of exceptionCandidates) {
this.claritasResult[candidate.filePath] = exception.proxyMetadata
}
}
}
}
protected async _doModuleRetrieval(moduleCandidates: ModuleCandidate[], options?: { protected async _doModuleRetrieval(moduleCandidates: ModuleCandidate[], options?: {
preProcess?: (candidate: ModuleCandidate) => void preProcess?: (candidate: ModuleCandidate) => void
postProcess?: (module: Module) => void postProcess?: (module: Module) => void
@@ -135,33 +165,8 @@ export abstract class ModuleStructure extends BaseModelStructure<Module> {
if(moduleCandidates.length > 0) { if(moduleCandidates.length > 0) {
// Invoke Claritas // Invoke Claritas and attach result to class.
if(this.getClaritasType() != null) { await this.invokeClaritas(moduleCandidates)
const claritasExecutor = new ClaritasWrapper()
let claritasCandidates = moduleCandidates
const exceptionCandidates: [ModuleCandidate, ClaritasException][] = []
for(const exception of this.getClaritasExceptions()) {
const exceptionCandidate = moduleCandidates.find((value) => value.file.toLowerCase().indexOf(exception.exceptionName) > -1)
if(exceptionCandidate != null) {
exceptionCandidates.push([exceptionCandidate, exception])
claritasCandidates = claritasCandidates.filter((value) => value.file.toLowerCase().indexOf(exception.exceptionName) === -1)
}
}
this.claritasResult = await claritasExecutor.execute(
this.getClaritasType()!,
this.minecraftVersion,
claritasCandidates.map(entry => entry.filePath)
)
if(this.claritasResult == null) {
this.logger.error('Failed to process Claritas result!')
} else {
for(const [candidate, exception] of exceptionCandidates) {
this.claritasResult[candidate.filePath] = exception.proxyMetadata
}
}
}
// Process Modules // Process Modules
for(const candidate of moduleCandidates) { for(const candidate of moduleCandidates) {