Merge branch 'master' of https://github.com/ethereum/remix-project into desktopmerge

desktopmerge
filip mertens 1 year ago
commit e89f5bb2d9
  1. 28
      apps/remix-ide/src/app.js
  2. 1
      apps/remix-ide/src/app/components/preload.tsx
  3. 51
      apps/remix-ide/src/app/plugins/parser/services/code-parser-antlr-service.ts
  4. 10
      libs/remix-ui/workspace/src/lib/reducers/workspace.ts

@ -23,20 +23,20 @@ import {WalkthroughService} from './walkthroughService'
import {OffsetToLineColumnConverter, CompilerMetadata, CompilerArtefacts, FetchAndCompile, CompilerImports, GistHandler} from '@remix-project/core-plugin' import {OffsetToLineColumnConverter, CompilerMetadata, CompilerArtefacts, FetchAndCompile, CompilerImports, GistHandler} from '@remix-project/core-plugin'
import Registry from './app/state/registry' import Registry from './app/state/registry'
import { ConfigPlugin } from './app/plugins/config' import {ConfigPlugin} from './app/plugins/config'
import { StoragePlugin } from './app/plugins/storage' import {StoragePlugin} from './app/plugins/storage'
import { Layout } from './app/panels/layout' import {Layout} from './app/panels/layout'
import { NotificationPlugin } from './app/plugins/notification' import {NotificationPlugin} from './app/plugins/notification'
import { Blockchain } from './blockchain/blockchain' import {Blockchain} from './blockchain/blockchain'
import { MergeVMProvider, LondonVMProvider, BerlinVMProvider, ShanghaiVMProvider } from './app/providers/vm-provider' import {MergeVMProvider, LondonVMProvider, BerlinVMProvider, ShanghaiVMProvider} from './app/providers/vm-provider'
import { MainnetForkVMProvider } from './app/providers/mainnet-vm-fork-provider' import {MainnetForkVMProvider} from './app/providers/mainnet-vm-fork-provider'
import { SepoliaForkVMProvider } from './app/providers/sepolia-vm-fork-provider' import {SepoliaForkVMProvider} from './app/providers/sepolia-vm-fork-provider'
import { GoerliForkVMProvider } from './app/providers/goerli-vm-fork-provider' import {GoerliForkVMProvider} from './app/providers/goerli-vm-fork-provider'
import { CustomForkVMProvider } from './app/providers/custom-vm-fork-provider' import {CustomForkVMProvider} from './app/providers/custom-vm-fork-provider'
import { HardhatProvider } from './app/providers/hardhat-provider' import {HardhatProvider} from './app/providers/hardhat-provider'
import { GanacheProvider } from './app/providers/ganache-provider' import {GanacheProvider} from './app/providers/ganache-provider'
import { FoundryProvider } from './app/providers/foundry-provider' import {FoundryProvider} from './app/providers/foundry-provider'
import { ExternalHttpProvider } from './app/providers/external-http-provider' import {ExternalHttpProvider} from './app/providers/external-http-provider'
import {InjectedProviderDefault} from './app/providers/injected-provider-default' import {InjectedProviderDefault} from './app/providers/injected-provider-default'
import {InjectedProviderTrustWallet} from './app/providers/injected-provider-trustwallet' import {InjectedProviderTrustWallet} from './app/providers/injected-provider-trustwallet'
import {Injected0ptimismProvider} from './app/providers/injected-optimism-provider' import {Injected0ptimismProvider} from './app/providers/injected-optimism-provider'

@ -74,6 +74,7 @@ export const Preload = () => {
testBlockStorage.current ? null : localStorageFileSystem.current testBlockStorage.current ? null : localStorageFileSystem.current
]) ])
if (fsLoaded) { if (fsLoaded) {
console.log(fsLoaded.name + ' activated')
_paq.push(['trackEvent', 'Storage', 'activate', fsLoaded.name]) _paq.push(['trackEvent', 'Storage', 'activate', fsLoaded.name])
loadAppComponent() loadAppComponent()
} else { } else {

@ -29,14 +29,14 @@ export default class CodeParserAntlrService {
parserThresholdSampleAmount = 3 parserThresholdSampleAmount = 3
cache: { cache: {
[name: string]: { [name: string]: {
text: string text: string,
ast: antlr.ParseResult | null ast: antlr.ParseResult | null,
duration?: number duration?: number,
parsingEnabled?: boolean parsingEnabled?: boolean,
blocks?: BlockDefinition[] blocks?: BlockDefinition[],
blockDurations?: number[] blockDurations?: number[]
} }
} = {} } = {};
constructor(plugin: CodeParser) { constructor(plugin: CodeParser) {
this.plugin = plugin this.plugin = plugin
this.createWorker() this.createWorker()
@ -60,15 +60,14 @@ export default class CodeParserAntlrService {
ast: ev.data.ast, ast: ev.data.ast,
duration: ev.data.duration, duration: ev.data.duration,
blocks: ev.data.blocks, blocks: ev.data.blocks,
blockDurations: self.cache[ev.data.file].blockDurations blockDurations: self.cache[ev.data.file].blockDurations? [...self.cache[ev.data.file].blockDurations.slice(-self.parserThresholdSampleAmount), ev.data.blockDuration]: [ev.data.blockDuration]
? [...self.cache[ev.data.file].blockDurations.slice(-self.parserThresholdSampleAmount), ev.data.blockDuration]
: [ev.data.blockDuration],
} }
self.setFileParsingState(ev.data.file) self.setFileParsingState(ev.data.file)
} }
break break;
} }
})
});
} }
setFileParsingState(file: string) { setFileParsingState(file: string) {
@ -105,8 +104,9 @@ export default class CodeParserAntlrService {
text, text,
timestamp: this.parserStartTime, timestamp: this.parserStartTime,
file, file,
parsingEnabled: (this.cache[file] && this.cache[file].parsingEnabled) || true, parsingEnabled: (this.cache[file] && this.cache[file].parsingEnabled) || true
}) });
} }
async parseSolidity(text: string) { async parseSolidity(text: string) {
@ -124,13 +124,13 @@ export default class CodeParserAntlrService {
try { try {
this.plugin.currentFile = await this.plugin.call('fileManager', 'file') this.plugin.currentFile = await this.plugin.call('fileManager', 'file')
if (this.plugin.currentFile && this.plugin.currentFile.endsWith('.sol')) { if (this.plugin.currentFile && this.plugin.currentFile.endsWith('.sol')) {
const fileContent = text || (await this.plugin.call('fileManager', 'readFile', this.plugin.currentFile)) const fileContent = text || await this.plugin.call('fileManager', 'readFile', this.plugin.currentFile)
if (!this.cache[this.plugin.currentFile]) { if (!this.cache[this.plugin.currentFile]) {
this.cache[this.plugin.currentFile] = { this.cache[this.plugin.currentFile] = {
text: '', text: '',
ast: null, ast: null,
parsingEnabled: true, parsingEnabled: true,
blockDurations: [], blockDurations: []
} }
} }
if (this.cache[this.plugin.currentFile] && this.cache[this.plugin.currentFile].text !== fileContent) { if (this.cache[this.plugin.currentFile] && this.cache[this.plugin.currentFile].text !== fileContent) {
@ -154,8 +154,8 @@ export default class CodeParserAntlrService {
async listAstNodes() { async listAstNodes() {
this.plugin.currentFile = await this.plugin.call('fileManager', 'file') this.plugin.currentFile = await this.plugin.call('fileManager', 'file')
if (!this.cache[this.plugin.currentFile]) return if (!this.cache[this.plugin.currentFile]) return
const nodes: AstNode[] = [] const nodes: AstNode[] = [];
;(SolidityParser as any).visit(this.cache[this.plugin.currentFile].ast, { (SolidityParser as any).visit(this.cache[this.plugin.currentFile].ast, {
StateVariableDeclaration: (node: antlr.StateVariableDeclaration) => { StateVariableDeclaration: (node: antlr.StateVariableDeclaration) => {
if (node.variables) { if (node.variables) {
for (const variable of node.variables) { for (const variable of node.variables) {
@ -195,11 +195,13 @@ export default class CodeParserAntlrService {
}, },
StructDefinition: function (node: antlr.StructDefinition) { StructDefinition: function (node: antlr.StructDefinition) {
nodes.push({ ...node, nodeType: node.type, id: null, src: null }) nodes.push({ ...node, nodeType: node.type, id: null, src: null })
}, }
}) })
return nodes return nodes
} }
/** /**
* *
* @param ast * @param ast
@ -217,13 +219,13 @@ export default class CodeParserAntlrService {
} }
} }
;(SolidityParser as any).visit(ast, { (SolidityParser as any).visit(ast, {
MemberAccess: function (node: antlr.MemberAccess) { MemberAccess: function (node: antlr.MemberAccess) {
checkLastNode(node) checkLastNode(node)
}, },
Identifier: function (node: antlr.Identifier) { Identifier: function (node: antlr.Identifier) {
checkLastNode(node) checkLastNode(node)
}, }
}) })
if (lastNode && lastNode.expression) { if (lastNode && lastNode.expression) {
return lastNode.expression return lastNode.expression
@ -241,15 +243,12 @@ export default class CodeParserAntlrService {
} }
} }
if (this.plugin.currentFile && this.plugin.currentFile.endsWith('.sol')) { if (this.plugin.currentFile && this.plugin.currentFile.endsWith('.sol')) {
const fileContent = text || (await this.plugin.call('fileManager', 'readFile', this.plugin.currentFile)) const fileContent = text || await this.plugin.call('fileManager', 'readFile', this.plugin.currentFile)
try { try {
const startTime = Date.now() const startTime = Date.now()
const blocks = (SolidityParser as any).parseBlock(fileContent, { loc: true, range: true, tolerant: true }) const blocks = (SolidityParser as any).parseBlock(fileContent, { loc: true, range: true, tolerant: true })
if (this.cache[this.plugin.currentFile] && this.cache[this.plugin.currentFile].blockDurations) { if(this.cache[this.plugin.currentFile] && this.cache[this.plugin.currentFile].blockDurations){
this.cache[this.plugin.currentFile].blockDurations = [ this.cache[this.plugin.currentFile].blockDurations = [...this.cache[this.plugin.currentFile].blockDurations.slice(-this.parserThresholdSampleAmount), Date.now() - startTime]
...this.cache[this.plugin.currentFile].blockDurations.slice(-this.parserThresholdSampleAmount),
Date.now() - startTime,
]
this.setFileParsingState(this.plugin.currentFile) this.setFileParsingState(this.plugin.currentFile)
} }
if (blocks) this.cache[this.plugin.currentFile].blocks = blocks if (blocks) this.cache[this.plugin.currentFile].blocks = blocks

@ -35,7 +35,7 @@ export interface BrowserState {
} }
fileState: fileDecoration[] fileState: fileDecoration[]
recentFolders: string[] recentFolders: string[]
}, }
localhost: { localhost: {
sharedFolder: string sharedFolder: string
files: {[x: string]: Record<string, FileType>} files: {[x: string]: Record<string, FileType>}
@ -87,8 +87,7 @@ export const browserInitialState: BrowserState = {
removedMenuItems: [], removedMenuItems: [],
error: null error: null
}, },
fileState: [], fileState: []
recentFolders: []
}, },
localhost: { localhost: {
sharedFolder: '', sharedFolder: '',
@ -851,13 +850,15 @@ export const browserReducer = (state = browserInitialState, action: Action) => {
} }
case 'SET_GIT_CONFIG': { case 'SET_GIT_CONFIG': {
const payload: { username: string, token: string, email: string } = action.payload const payload: {username: string; token: string; email: string} =
action.payload
return { return {
...state, ...state,
gitConfig: payload gitConfig: payload
} }
} }
case 'SET_ELECTRON_RECENT_FOLDERS': { case 'SET_ELECTRON_RECENT_FOLDERS': {
const payload: string[] = action.payload const payload: string[] = action.payload
return { return {
@ -869,7 +870,6 @@ export const browserReducer = (state = browserInitialState, action: Action) => {
} }
} }
default: default:
throw new Error() throw new Error()
} }

Loading…
Cancel
Save