From ea37c88661f675d571747043691b7a9f342e0008 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Mon, 5 Sep 2022 15:29:03 +0200 Subject: [PATCH 1/6] fix calls --- .../src/app/plugins/parser/code-parser.tsx | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/apps/remix-ide/src/app/plugins/parser/code-parser.tsx b/apps/remix-ide/src/app/plugins/parser/code-parser.tsx index c9caf3b70c..42d7c866bf 100644 --- a/apps/remix-ide/src/app/plugins/parser/code-parser.tsx +++ b/apps/remix-ide/src/app/plugins/parser/code-parser.tsx @@ -87,6 +87,18 @@ export class CodeParser extends Plugin { } } + async handleChangeEvents() { + const completionSettings = await this.call('config', 'getAppParameter', 'auto-completion') + if (completionSettings) { + await this.antlrService.getCurrentFileAST() + } + const showGasSettings = await this.call('config', 'getAppParameter', 'show-gas') + const showErrorSettings = await this.call('config', 'getAppParameter', 'display-errors') + if(showGasSettings || showErrorSettings) { + await this.compilerService.compile() + } + } + async onActivation() { this.gasService = new CodeParserGasService(this) @@ -102,8 +114,7 @@ export class CodeParser extends Plugin { this.on('editor', 'didChangeFile', async (file) => { await this.call('editor', 'discardLineTexts') - await this.antlrService.getCurrentFileAST() - await this.compilerService.compile() + await this.handleChangeEvents() }) this.on('filePanel', 'setWorkspace', async () => { @@ -113,8 +124,7 @@ export class CodeParser extends Plugin { this.on('fileManager', 'currentFileChanged', async () => { await this.call('editor', 'discardLineTexts') - await this.antlrService.getCurrentFileAST() - await this.compilerService.compile() + await this.handleChangeEvents() }) this.on('solidity', 'loadingCompiler', async (url) => { @@ -188,10 +198,10 @@ export class CodeParser extends Plugin { const index = {} const contractName: string = contractNode.name const callback = (node) => { - if(inScope && node.scope !== contractNode.id + if (inScope && node.scope !== contractNode.id && !(node.nodeType === 'EnumDefinition' || node.nodeType === 'EventDefinition' || node.nodeType === 'ModifierDefinition')) return - if(inScope) node.isClassNode = true; + if (inScope) node.isClassNode = true; node.gasEstimate = this._getContractGasEstimate(node, contractName, fileName, compilatioResult) node.functionName = node.name + this._getInputParams(node) node.contractName = contractName @@ -227,11 +237,11 @@ export class CodeParser extends Plugin { if ((node.scope && node.scope === baseContract.id) || node.nodeType === 'EnumDefinition' || node.nodeType === 'EventDefinition' - ) { + ) { baseNodesWithBaseContractScope[node.id] = node } - if(node.members){ - for(const member of node.members){ + if (node.members) { + for (const member of node.members) { member.contractName = (baseContract as any).name member.contractId = (baseContract as any).id member.isBaseNode = true; @@ -249,7 +259,7 @@ export class CodeParser extends Plugin { if (node.nodeType === 'ImportDirective') { const imported = await this.resolveImports(node, {}) - + for (const importedNode of (Object.values(imported) as any)) { if (importedNode.nodes) for (const subNode of importedNode.nodes) { From 33b425323ba3a6022bf85f98ae517455b244134e Mon Sep 17 00:00:00 2001 From: filip mertens Date: Mon, 5 Sep 2022 15:31:08 +0200 Subject: [PATCH 2/6] disable by default --- libs/remix-ui/settings/src/lib/remix-ui-settings.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx index 0a24d3b038..55f25bb3d8 100644 --- a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx +++ b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx @@ -148,7 +148,7 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => { const isEditorWrapChecked = props.config.get('settings/text-wrap') || false const isPersonalChecked = props.config.get('settings/personal-mode') || false const isMatomoChecked = props.config.get('settings/matomo-analytics') || false - const isAutoCompleteChecked = props.config.get('settings/auto-completion') === null ? true:props.config.get('settings/auto-completion') + const isAutoCompleteChecked = props.config.get('settings/auto-completion') === null ? false:props.config.get('settings/auto-completion') const isShowGasInEditorChecked = props.config.get('settings/show-gas') === null ? true:props.config.get('settings/show-gas') const displayErrorsChecked = props.config.get('settings/display-errors') === null ? true:props.config.get('settings/display-errors') return ( From d5ec61a9bf9c1d01c3ccda1a5254768ec8517487 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Mon, 5 Sep 2022 15:40:10 +0200 Subject: [PATCH 3/6] turn off by default --- libs/remix-ui/settings/src/lib/remix-ui-settings.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx index 55f25bb3d8..4b5da79895 100644 --- a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx +++ b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx @@ -41,13 +41,13 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => { if (javascriptVM === null || javascriptVM === undefined) ethereumVM(props.config, true, dispatch) const useAutoComplete = props.config.get('settings/auto-completion') - if (useAutoComplete === null || useAutoComplete === undefined) useAutoCompletion(props.config, true, dispatch) + if (useAutoComplete === null || useAutoComplete === undefined) useAutoCompletion(props.config, false, dispatch) const displayErrors = props.config.get('settings/display-errors') - if (displayErrors === null || displayErrors === undefined) useDisplayErrors(props.config, true, dispatch) + if (displayErrors === null || displayErrors === undefined) useDisplayErrors(props.config, false, dispatch) const useShowGas = props.config.get('settings/show-gas') - if (useShowGas === null || useShowGas === undefined) useShowGasInEditor(props.config, true, dispatch) + if (useShowGas === null || useShowGas === undefined) useShowGasInEditor(props.config, false, dispatch) } useEffect(() => initValue(), [resetState, props.config]) useEffect(() => initValue(), []) @@ -148,7 +148,8 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => { const isEditorWrapChecked = props.config.get('settings/text-wrap') || false const isPersonalChecked = props.config.get('settings/personal-mode') || false const isMatomoChecked = props.config.get('settings/matomo-analytics') || false - const isAutoCompleteChecked = props.config.get('settings/auto-completion') === null ? false:props.config.get('settings/auto-completion') + + const isAutoCompleteChecked = props.config.get('settings/auto-completion') || false const isShowGasInEditorChecked = props.config.get('settings/show-gas') === null ? true:props.config.get('settings/show-gas') const displayErrorsChecked = props.config.get('settings/display-errors') === null ? true:props.config.get('settings/display-errors') return ( From 60b3c9e3bf85c55e5649f5b0956a47012d935ef5 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Mon, 5 Sep 2022 15:41:17 +0200 Subject: [PATCH 4/6] turn off by default --- libs/remix-ui/settings/src/lib/remix-ui-settings.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx index 4b5da79895..e8a15d3a78 100644 --- a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx +++ b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx @@ -150,8 +150,8 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => { const isMatomoChecked = props.config.get('settings/matomo-analytics') || false const isAutoCompleteChecked = props.config.get('settings/auto-completion') || false - const isShowGasInEditorChecked = props.config.get('settings/show-gas') === null ? true:props.config.get('settings/show-gas') - const displayErrorsChecked = props.config.get('settings/display-errors') === null ? true:props.config.get('settings/display-errors') + const isShowGasInEditorChecked = props.config.get('settings/show-gas') || false + const displayErrorsChecked = props.config.get('settings/display-errors') || false return (
From 1aa4216db6ab821b9401c65e1c3aa7ae9459e7d2 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Mon, 5 Sep 2022 16:15:02 +0200 Subject: [PATCH 5/6] e2e --- apps/remix-ide-e2e/src/tests/editorAutoComplete.test.ts | 9 +++++++++ apps/remix-ide-e2e/src/tests/editorHoverContext.test.ts | 8 ++++++++ apps/remix-ide-e2e/src/tests/editorReferences.test.ts | 7 +++++++ apps/remix-ide-e2e/src/tests/editor_error_marker.test.ts | 7 +++++++ apps/remix-ide-e2e/src/tests/editor_line_text.test.ts | 7 +++++++ libs/remix-ui/settings/src/lib/remix-ui-settings.tsx | 6 +++--- 6 files changed, 41 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/editorAutoComplete.test.ts b/apps/remix-ide-e2e/src/tests/editorAutoComplete.test.ts index d30c942b59..171ad97b6a 100644 --- a/apps/remix-ide-e2e/src/tests/editorAutoComplete.test.ts +++ b/apps/remix-ide-e2e/src/tests/editorAutoComplete.test.ts @@ -12,6 +12,15 @@ module.exports = { before: function (browser: NightwatchBrowser, done: VoidFunction) { init(browser, done, 'http://127.0.0.1:8080', false) }, + + 'Should enable settings': function (browser: NightwatchBrowser) { + browser + .clickLaunchIcon('settings') + .click('[data-id="settingsAutoCompleteLabel"]') + .click('[data-id="settingsShowGasLabel"]') + .click('[data-id="displayErrorsLabel"]') + }, + 'Should add test and base files #group1': function (browser: NightwatchBrowser) { browser.addFile(examples.testContract.name, examples.testContract) .addFile(examples.baseContract.name, examples.baseContract) diff --git a/apps/remix-ide-e2e/src/tests/editorHoverContext.test.ts b/apps/remix-ide-e2e/src/tests/editorHoverContext.test.ts index db86224b11..f9f5eef0c4 100644 --- a/apps/remix-ide-e2e/src/tests/editorHoverContext.test.ts +++ b/apps/remix-ide-e2e/src/tests/editorHoverContext.test.ts @@ -18,6 +18,14 @@ module.exports = { init(browser, done, 'http://127.0.0.1:8080', false) }, + 'Should enable settings': function (browser: NightwatchBrowser) { + browser + .clickLaunchIcon('settings') + .click('[data-id="settingsAutoCompleteLabel"]') + .click('[data-id="settingsShowGasLabel"]') + .click('[data-id="displayErrorsLabel"]') + }, + 'Should load the test file': function (browser: NightwatchBrowser) { browser.openFile('contracts') .openFile('contracts/3_Ballot.sol') diff --git a/apps/remix-ide-e2e/src/tests/editorReferences.test.ts b/apps/remix-ide-e2e/src/tests/editorReferences.test.ts index 86856a9822..f63837233e 100644 --- a/apps/remix-ide-e2e/src/tests/editorReferences.test.ts +++ b/apps/remix-ide-e2e/src/tests/editorReferences.test.ts @@ -20,6 +20,13 @@ module.exports = { init(browser, done, 'http://127.0.0.1:8080', false) }, + 'Should enable settings': function (browser: NightwatchBrowser) { + browser + .clickLaunchIcon('settings') + .click('[data-id="settingsAutoCompleteLabel"]') + .click('[data-id="settingsShowGasLabel"]') + .click('[data-id="displayErrorsLabel"]') + }, 'Should load the test file': function (browser: NightwatchBrowser) { browser.openFile('contracts') .openFile('contracts/3_Ballot.sol') diff --git a/apps/remix-ide-e2e/src/tests/editor_error_marker.test.ts b/apps/remix-ide-e2e/src/tests/editor_error_marker.test.ts index 8d8cba54e0..daa5456982 100644 --- a/apps/remix-ide-e2e/src/tests/editor_error_marker.test.ts +++ b/apps/remix-ide-e2e/src/tests/editor_error_marker.test.ts @@ -8,6 +8,13 @@ module.exports = { before: function (browser: NightwatchBrowser, done: VoidFunction) { init(browser, done, 'http://127.0.0.1:8080', true) }, + 'Should enable settings': function (browser: NightwatchBrowser) { + browser + .clickLaunchIcon('settings') + .click('[data-id="settingsAutoCompleteLabel"]') + .click('[data-id="settingsShowGasLabel"]') + .click('[data-id="displayErrorsLabel"]') + }, 'Should add error marker': function (browser: NightwatchBrowser) { browser .openFile('contracts') diff --git a/apps/remix-ide-e2e/src/tests/editor_line_text.test.ts b/apps/remix-ide-e2e/src/tests/editor_line_text.test.ts index afff1c8f28..24eb0540e1 100644 --- a/apps/remix-ide-e2e/src/tests/editor_line_text.test.ts +++ b/apps/remix-ide-e2e/src/tests/editor_line_text.test.ts @@ -8,6 +8,13 @@ module.exports = { before: function (browser: NightwatchBrowser, done: VoidFunction) { init(browser, done, 'http://127.0.0.1:8080', true) }, + 'Should enable settings': function (browser: NightwatchBrowser) { + browser + .clickLaunchIcon('settings') + .click('[data-id="settingsAutoCompleteLabel"]') + .click('[data-id="settingsShowGasLabel"]') + .click('[data-id="displayErrorsLabel"]') + }, 'Should add line texts': function (browser: NightwatchBrowser) { browser .openFile('contracts') diff --git a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx index e8a15d3a78..b31313726d 100644 --- a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx +++ b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx @@ -189,19 +189,19 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
-
-
-
From 9ee695a410a96afd202e50e4518b942376be9eac Mon Sep 17 00:00:00 2001 From: filip mertens Date: Mon, 5 Sep 2022 16:22:56 +0200 Subject: [PATCH 6/6] fix setting --- apps/remix-ide/src/app/plugins/parser/code-parser.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app/plugins/parser/code-parser.tsx b/apps/remix-ide/src/app/plugins/parser/code-parser.tsx index 42d7c866bf..b763f81a3c 100644 --- a/apps/remix-ide/src/app/plugins/parser/code-parser.tsx +++ b/apps/remix-ide/src/app/plugins/parser/code-parser.tsx @@ -94,7 +94,7 @@ export class CodeParser extends Plugin { } const showGasSettings = await this.call('config', 'getAppParameter', 'show-gas') const showErrorSettings = await this.call('config', 'getAppParameter', 'display-errors') - if(showGasSettings || showErrorSettings) { + if(showGasSettings || showErrorSettings || completionSettings) { await this.compilerService.compile() } }