fix timestamp compiler

pull/5370/head
filip mertens 1 year ago
parent f735ecd8b7
commit fb649391e2
  1. 7
      apps/remix-ide/src/app/plugins/parser/services/code-parser-compiler.ts
  2. 5
      apps/remix-ide/src/app/plugins/parser/services/code-parser-gas-service.ts
  3. 27
      libs/remix-solidity/src/compiler/compiler.ts
  4. 2
      libs/remix-solidity/src/compiler/types.ts
  5. 16
      libs/remix-ui/editor/src/lib/providers/quickfixes.ts

@ -99,11 +99,11 @@ export default class CodeParserCompiler {
await this.clearDecorators(result.getSourceCode().sources) await this.clearDecorators(result.getSourceCode().sources)
} }
if (!data.sources) return if (!data.sources) return
if (data.sources && Object.keys(data.sources).length === 0) return if (data.sources && Object.keys(data.sources).length === 0) return
this.plugin.compilerAbstract = new CompilerAbstract('soljson', data, source, input) this.plugin.compilerAbstract = new CompilerAbstract('soljson', data, source, input)
this.errorState = false this.errorState = false
this.plugin.nodeIndex = { this.plugin.nodeIndex = {
declarations: {}, declarations: {},
flatReferences: {}, flatReferences: {},
@ -113,7 +113,10 @@ export default class CodeParserCompiler {
this.plugin._buildIndex(data, source) this.plugin._buildIndex(data, source)
// cast from the remix-plugin interface to the solidity one. Should be fixed when remix-plugin move to the remix-project repository // cast from the remix-plugin interface to the solidity one. Should be fixed when remix-plugin move to the remix-project repository
this.plugin.nodeIndex.nodesPerFile[this.plugin.currentFile] = this.plugin._extractFileNodes(this.plugin.currentFile, this.plugin.compilerAbstract as unknown as lastCompilationResult) const extractedFiledNodes = this.plugin._extractFileNodes(this.plugin.currentFile, this.plugin.compilerAbstract as unknown as lastCompilationResult)
if(extractedFiledNodes) {
this.plugin.nodeIndex.nodesPerFile[this.plugin.currentFile] = extractedFiledNodes
}
await this.plugin.gasService.showGasEstimates() await this.plugin.gasService.showGasEstimates()
this.plugin.emit('astFinished') this.plugin.emit('astFinished')
} }

@ -42,7 +42,10 @@ export default class CodeParserGasService {
} }
this.plugin.currentFile = await this.plugin.call('fileManager', 'file') this.plugin.currentFile = await this.plugin.call('fileManager', 'file')
// cast from the remix-plugin interface to the solidity one. Should be fixed when remix-plugin move to the remix-project repository // cast from the remix-plugin interface to the solidity one. Should be fixed when remix-plugin move to the remix-project repository
this.plugin.nodeIndex.nodesPerFile[this.plugin.currentFile] = await this.plugin._extractFileNodes(this.plugin.currentFile, this.plugin.compilerAbstract as unknown as lastCompilationResult) const extractedFiledNodes = await this.plugin._extractFileNodes(this.plugin.currentFile, this.plugin.compilerAbstract as unknown as lastCompilationResult)
if(extractedFiledNodes) {
this.plugin.nodeIndex.nodesPerFile[this.plugin.currentFile] = extractedFiledNodes
}
const gasEstimates = await this.getGasEstimates(this.plugin.currentFile) const gasEstimates = await this.getGasEstimates(this.plugin.currentFile)

@ -49,6 +49,7 @@ export class Compiler {
if (success && this.state.compilationStartTime) { if (success && this.state.compilationStartTime) {
this.event.trigger('compilationDuration', [(new Date().getTime()) - this.state.compilationStartTime]) this.event.trigger('compilationDuration', [(new Date().getTime()) - this.state.compilationStartTime])
} }
console.log('compilationStartTime to null', this.state.compilationStartTime, data)
this.state.compilationStartTime = null this.state.compilationStartTime = null
}) })
@ -81,12 +82,16 @@ export class Compiler {
* @param missingInputs missing import file path list * @param missingInputs missing import file path list
*/ */
internalCompile(files: Source, missingInputs?: string[]): void { internalCompile(files: Source, missingInputs?: string[], timeStamp?: number): void {
if(timeStamp != this.state.compilationStartTime && this.state.compilerRetriggerMode == CompilerRetriggerMode.retrigger ) {
console.log('aborting compilation', timeStamp, this.state.compilationStartTime)
return
}
this.gatherImports(files, missingInputs, (error, input) => { this.gatherImports(files, missingInputs, (error, input) => {
if (error) { if (error) {
this.state.lastCompilationResult = null this.state.lastCompilationResult = null
this.event.trigger('compilationFinished', [false, { error: { formattedMessage: error, severity: 'error' } }, files, input, this.state.currentVersion]) this.event.trigger('compilationFinished', [false, { error: { formattedMessage: error, severity: 'error' } }, files, input, this.state.currentVersion])
} else if (this.state.compileJSON && input) { this.state.compileJSON(input) } } else if (this.state.compileJSON && input) { this.state.compileJSON(input, timeStamp) }
}) })
} }
@ -99,8 +104,9 @@ export class Compiler {
compile(files: Source, target: string): void { compile(files: Source, target: string): void {
this.state.target = target this.state.target = target
this.state.compilationStartTime = new Date().getTime() this.state.compilationStartTime = new Date().getTime()
console.log('compiling ' + target + '...', files, this.state.compilationStartTime)
this.event.trigger('compilationStarted', []) this.event.trigger('compilationStarted', [])
this.internalCompile(files) this.internalCompile(files, null, this.state.compilationStartTime)
} }
/** /**
@ -157,7 +163,7 @@ export class Compiler {
* @param source Source * @param source Source
*/ */
onCompilationFinished(data: CompilationResult, missingInputs?: string[], source?: SourceWithTarget, input?: string, version?: string): void { onCompilationFinished(data: CompilationResult, missingInputs?: string[], source?: SourceWithTarget, input?: string, version?: string, timeStamp?: number): void {
let noFatalErrors = true // ie warnings are ok let noFatalErrors = true // ie warnings are ok
const checkIfFatalError = (error: CompilationError) => { const checkIfFatalError = (error: CompilationError) => {
@ -173,7 +179,7 @@ export class Compiler {
this.event.trigger('compilationFinished', [false, data, source, input, version]) this.event.trigger('compilationFinished', [false, data, source, input, version])
} else if (missingInputs !== undefined && missingInputs.length > 0 && source && source.sources) { } else if (missingInputs !== undefined && missingInputs.length > 0 && source && source.sources) {
// try compiling again with the new set of inputs // try compiling again with the new set of inputs
this.internalCompile(source.sources, missingInputs) this.internalCompile(source.sources, missingInputs, timeStamp)
} else { } else {
data = this.updateInterface(data) data = this.updateInterface(data)
if (source) { if (source) {
@ -183,6 +189,7 @@ export class Compiler {
source: source source: source
} }
} }
console.log('compilationFinished ', timeStamp, this.state.compilationStartTime)
this.event.trigger('compilationFinished', [true, data, source, input, version]) this.event.trigger('compilationFinished', [true, data, source, input, version])
} }
} }
@ -291,7 +298,9 @@ export class Compiler {
this.state.worker.addEventListener('message', (msg: Record<'data', MessageFromWorker>) => { this.state.worker.addEventListener('message', (msg: Record<'data', MessageFromWorker>) => {
const data: MessageFromWorker = msg.data const data: MessageFromWorker = msg.data
console.log('incoming message', data.timestamp, data)
if (this.state.compilerRetriggerMode == CompilerRetriggerMode.retrigger && data.timestamp !== this.state.compilationStartTime) { if (this.state.compilerRetriggerMode == CompilerRetriggerMode.retrigger && data.timestamp !== this.state.compilationStartTime) {
console.log('dropping message', data.timestamp, this.state.compilationStartTime)
return return
} }
switch (data.cmd) { switch (data.cmd) {
@ -312,7 +321,7 @@ export class Compiler {
sources = jobs[data.job].sources sources = jobs[data.job].sources
delete jobs[data.job] delete jobs[data.job]
} }
this.onCompilationFinished(result, data.missingInputs, sources, data.input, this.state.currentVersion) this.onCompilationFinished(result, data.missingInputs, sources, data.input, this.state.currentVersion, data.timestamp)
} }
break break
} }
@ -325,7 +334,7 @@ export class Compiler {
this.onCompilationFinished({ error: { formattedMessage } }) this.onCompilationFinished({ error: { formattedMessage } })
}) })
this.state.compileJSON = (source: SourceWithTarget) => { this.state.compileJSON = (source: SourceWithTarget, timeStamp: number) => {
if (source && source.sources) { if (source && source.sources) {
const { optimize, runs, evmVersion, language, useFileConfiguration, configFileContent } = this.state const { optimize, runs, evmVersion, language, useFileConfiguration, configFileContent } = this.state
jobs.push({ sources: source }) jobs.push({ sources: source })
@ -342,12 +351,12 @@ export class Compiler {
return return
} }
console.log('posting message with timestamp ', this.state.compilationStartTime, source)
this.state.worker.postMessage({ this.state.worker.postMessage({
cmd: 'compile', cmd: 'compile',
job: jobs.length - 1, job: jobs.length - 1,
input: input, input: input,
timestamp: this.state.compilationStartTime timestamp: timeStamp
}) })
} }
} }

@ -160,7 +160,7 @@ export enum CompilerRetriggerMode {
} }
export interface CompilerState { export interface CompilerState {
compileJSON: ((input: SourceWithTarget) => void) | null, compileJSON: ((input: SourceWithTarget, timeStamp?: number) => void) | null,
worker: any, worker: any,
currentVersion: string| null| undefined, currentVersion: string| null| undefined,
compilerLicense: string| null compilerLicense: string| null

@ -170,5 +170,21 @@ export default {
title: "Add 'calldata' to param", title: "Add 'calldata' to param",
message: ' calldata ' message: ' calldata '
} }
],
'SyntaxError: No visibility specified. Did you intend to add "external': [
{
id: 12,
title: "Add visibility 'external'",
message: 'external ',
nodeType: 'FunctionDefinition'
}
],
'DeclarationError: Receive ether function must be payable, but is "nonpayable".': [
{
id: 13,
title: "Make function 'payable'",
message: 'payable ',
nodeType: 'FunctionDefinition'
}
] ]
} }
Loading…
Cancel
Save