From b190993dcb8376e80fb1d9b71f3ed6170bd2a341 Mon Sep 17 00:00:00 2001 From: Alex Coventry Date: Mon, 20 Jan 2020 18:04:41 -0500 Subject: [PATCH 01/27] Make solidity-match-variable-decls regexp's unhighlited matches shy. This ensures that if the two optional matches in the regexp, `\\[ *[0-9]*\\]` or `(regexp-opt solidity-variable-modifier 'words)` have no match, the name of the variable being declared can be still be found via the absolute match index 2. Prior to this change, a simple `address foo` would match the regexp, but the expected match index for the variable, 4, would have no match, which could lead to font-lock errors in some circumstances. [Reference for shy matches]( https://www.gnu.org/software/emacs/manual/html_node/emacs/Regexp-Backslash.html#index-shy-group_002c-in-regexp-1000) --- solidity-mode.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solidity-mode.el b/solidity-mode.el index 13f62f1..58191ad 100644 --- a/solidity-mode.el +++ b/solidity-mode.el @@ -332,7 +332,7 @@ Possible values are: '(solidity-match-event-decl (1 font-lock-keyword-face) (2 font-lock-variable-name-face)) '(solidity-match-variable-decls (1 font-lock-keyword-face) - (4 font-lock-variable-name-face)) + (2 font-lock-variable-name-face)) `(,(regexp-opt solidity-constants 'words) . font-lock-constant-face)) "The font lock options for solidity.") @@ -422,7 +422,7 @@ Highlight the 1st result." Highlight the 1st result." (solidity-match-regexp (concat - " *\\(" (regexp-opt solidity-builtin-types 'words) " *\\(\\[ *[0-9]*\\]\\)* *\\) " "\\("(regexp-opt solidity-variable-modifier 'words) " \\)* *\\(" solidity-identifier-regexp "\\)") + " *\\(" (regexp-opt solidity-builtin-types 'words) " *\\(?:\\[ *[0-9]*\\]\\)* *\\) " "\\(?:"(regexp-opt solidity-variable-modifier 'words) " \\)* *\\(" solidity-identifier-regexp "\\)") limit)) ;; solidity syntax table From fbc898915eb7d264f83c152ef17c477a4844185c Mon Sep 17 00:00:00 2001 From: hrkrshnn Date: Tue, 14 Apr 2020 19:23:07 +0530 Subject: [PATCH 02/27] Added the keyword virtual --- solidity-mode.el | 1 + 1 file changed, 1 insertion(+) diff --git a/solidity-mode.el b/solidity-mode.el index 58191ad..61124a7 100644 --- a/solidity-mode.el +++ b/solidity-mode.el @@ -137,6 +137,7 @@ Possible values are: "using" "var" "view" + "virtual" "while" ) "Keywords of the solidity language.") From 022b3159832384a7dcdc2168809e698600826047 Mon Sep 17 00:00:00 2001 From: hrkrshnn Date: Sat, 18 Apr 2020 13:56:40 +0530 Subject: [PATCH 03/27] Added keywords override and abstract --- solidity-mode.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/solidity-mode.el b/solidity-mode.el index 61124a7..6030d15 100644 --- a/solidity-mode.el +++ b/solidity-mode.el @@ -88,7 +88,8 @@ Possible values are: (mapcar (lambda (x) (and (funcall condp x) x)) lst))) (defconst solidity-keywords - '("after" + '("abstract" + "after" "anonymous" "as" "assembly" @@ -120,6 +121,7 @@ Possible values are: "memory" "modifier" "new" + "override" "payable" "pragma" "private" From d8eb460f1fc22aac65ad4926811df90df37ce68a Mon Sep 17 00:00:00 2001 From: Harikrishnan Mulackal Date: Sun, 24 May 2020 21:10:28 +0530 Subject: [PATCH 04/27] Added the keyword let --- solidity-mode.el | 1 + 1 file changed, 1 insertion(+) diff --git a/solidity-mode.el b/solidity-mode.el index 6030d15..19cfe9d 100644 --- a/solidity-mode.el +++ b/solidity-mode.el @@ -247,6 +247,7 @@ Possible values are: "int248" "int256" + "let" "mapping" "real" "string" From d166a86b83907e0cfd64c191e9dfce4b44a9843e Mon Sep 17 00:00:00 2001 From: Masahiro Nakamura <13937915+tsuu32@users.noreply.github.com> Date: Fri, 29 May 2020 11:52:31 +0900 Subject: [PATCH 05/27] Set c-basic-offset to 4 --- solidity-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solidity-mode.el b/solidity-mode.el index 19cfe9d..3f27060 100644 --- a/solidity-mode.el +++ b/solidity-mode.el @@ -552,7 +552,7 @@ Cursor must be at the function's name. Does not currently work for constructors (set (make-local-variable 'comment-multi-line) t) (set (make-local-variable 'comment-line-break-function) 'c-indent-new-comment-line) - + (set (make-local-variable 'c-basic-offset) 4) (when solidity-mode-disable-c-mode-hook (set (make-local-variable 'c-mode-hook) nil)) From b4fd719715be098921b6cbfb2ff9da31f3bd0d05 Mon Sep 17 00:00:00 2001 From: Mark Hudnall Date: Sun, 3 Jan 2021 00:19:07 -0800 Subject: [PATCH 06/27] Fix solidity-flycheck for solidity >= 0.8.0 In 0.8.0, the --old-reporter flag was removed. This caused solidity-flycheck to error out. We add error patterns for the new reporter format and use the new format for solidity >= 0.6.0, when it was first introduced. Closes https://github.com/ethereum/emacs-solidity/issues/62 --- solidity-flycheck.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/solidity-flycheck.el b/solidity-flycheck.el index 270c685..47acbac 100644 --- a/solidity-flycheck.el +++ b/solidity-flycheck.el @@ -153,13 +153,18 @@ we pass the directory to solium via the `--config' option." ;; expanded the flycheck-define-checker macro in order to eval certain args, as per advice given in gitter ;; https://gitter.im/flycheck/flycheck?at=5a43b3a8232e79134d98872b (flycheck-def-executable-var solidity-checker "solc") - (let* ((cmd (if (solc-gt-0.6.0) '("solc" "--old-reporter" source-inplace) '("solc" source-inplace)))) + (let* ((cmd (if (solc-gt-0.6.0) '("solc" "--no-color" source-inplace) '("solc" source-inplace)))) (if (funcall flycheck-executable-find solidity-solc-path) (progn (flycheck-define-command-checker 'solidity-checker "A Solidity syntax checker using the solc compiler" :command cmd :error-patterns '( + ;; Solidity >= 0.6.0 error formats + (error line-start "Error: " (message) "\n" (zero-or-more whitespace) "--> " (file-name) ":" line ":" column) + (warning line-start "Warning: " (message) "\n" (zero-or-more whitespace) "--> " (file-name) ":" line ":" column) + + ;; Solidity < 0.6.0 error formats (error line-start (file-name) ":" line ":" column ":" " Error: " (message)) (error line-start (file-name) ":" line ":" column ":" " Compiler error: " (message)) (error line-start "Error: " (message)) From d14acf9eb7e34fb4d82457f33a121e52a21a6b7a Mon Sep 17 00:00:00 2001 From: Mark Hudnall Date: Mon, 11 Jan 2021 16:27:05 -0800 Subject: [PATCH 07/27] Support project root and additional allow-paths solidity-flycheck can now detect projects. Project roots: When `solidity-flycheck-use-project' is t, solidity-flycheck will detect a project and include files in the project during compilation and linting. solidity-flycheck will look for a .soliumrc.json in a parent directory. If found, this directory is considered the project root. If no .soliumrc.json is found, `project-roots' is used. When `solidity-flycheck-solium-checker-active' is t, the .soliumrc.json found in the project root will be used as the solium config, rather than a .soliumrc.json in the same directory as the file being linted. When `solidity-flycheck-solc-checker-active' is t, the project root will be passed to solc using the --allow-paths flag. This means imports to other files inside the project will lint without erorr." Additional allow-paths: The custom variable `solidity-flycheck-solc-additional-allow-paths' can be set to support additional allow-paths. This lets you import .sol files from other directories without causing linting errors. For example, say that you use Brownie (URL `https://github.com/eth-brownie/brownie'), which stores ethPM packages in \"~/.brownie/packages\". You could add \"~/.brownie/packages\" to this variable to import ethPM packages without linting errors. Subdirectories in each allow path are remapped. Note that when `solidity-flycheck-use-project' is t, the project root will be added to --allow-paths in addition to any paths defined here. --- solidity-flycheck.el | 103 ++++++++++++++++++++++++++++++++++++++++--- solidity-mode.el | 2 +- 2 files changed, 99 insertions(+), 6 deletions(-) diff --git a/solidity-flycheck.el b/solidity-flycheck.el index 47acbac..0a8670c 100644 --- a/solidity-flycheck.el +++ b/solidity-flycheck.el @@ -4,8 +4,8 @@ ;; Author: Lefteris Karapetsas ;; Keywords: languages, solidity, flycheck -;; Version: 0.1.10 -;; Package-Requires: ((flycheck "32-cvs") (solidity-mode "0.1.9")) +;; Version: 0.1.11 +;; Package-Requires: ((flycheck "32-cvs") (solidity-mode "0.1.9") (dash "2.17.0")) ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ (require 'flycheck) (require 'solidity-common) +(require 'dash) (defvar flycheck-solidity-checker-executable) (defvar flycheck-solium-checker-executable) @@ -86,6 +87,55 @@ we pass the directory to solium via the `--config' option." :safe #'stringp :package-version '(solidity-mode . "0.1.4")) +(defcustom solidity-flycheck-solc-additional-allow-paths nil + "A list of paths that should be passed to solc using the --allow-paths option. + +This lets you import .sol files from other directories without causing linting errors. +For example, say that you use Brownie (URL `https://github.com/eth-brownie/brownie'), +which stores ethPM packages in \"~/.brownie/packages\". You could add \"~/.brownie/packages\" +to this variable to import ethPM packages without linting errors. Subdirectories +in each allow path are remapped. + +Note that when `solidity-flycheck-use-project' is t, the project root will be +added to --allow-paths in addition to any paths defined here." + :group 'solidity + :type 'list + :safe #'listp + :package-version '(solidity-mode . "0.1.11")) + +(defcustom solidity-flycheck-use-project nil + "A boolean flag denoting whether solidity-flycheck should detect projects. + +When t, solidity-flycheck will detect a project and include files in the project +during compilation and linting. solidity-flycheck will look for a .soliumrc.json +in a parent directory. If found, this directory is considered the project root. If +no .soliumrc.json is found, `project-roots' is used. + +When `solidity-flycheck-solium-checker-active' is t, the .soliumrc.json found in +the project root will be used as the solium config, rather than a .soliumrc.json +in the same directory as the file being linted. + +When `solidity-flycheck-solc-checker-active' is t, the project root will be passed +to solc using the --allow-paths flag. This means imports to other files inside the +project will lint without erorr." + :group 'solidity + :type 'boolean + :safe #'booleanp + :package-version '(solidity-mode . "0.1.11")) + +(defun solidity-flycheck--find-working-directory (_checker) + "Look for a working directtory to run solium CHECKER in. + +This will be a parent directory that contains a `.soliumrc.json' file. If +no .soliumrc.json is found, `project-roots' is used." + (when (and buffer-file-name solidity-flycheck-use-project) + (when-let ((root (or + (locate-dominating-file buffer-file-name ".soliumrc.json") + (let* ((proj (project-current t)) + (roots (project-roots proj))) + (car roots))))) + (expand-file-name root)))) + (when solidity-flycheck-solium-checker-active ;; define solium flycheck syntax checker ;; expanded the flycheck-define-checker macro in order to eval certain args, as per advice given in gitter @@ -121,7 +171,7 @@ we pass the directory to solium via the `--config' option." :predicate #'(lambda nil (eq major-mode 'solidity-mode)) :next-checkers 'nil :standard-input 'nil - :working-directory 'nil) + :working-directory 'solidity-flycheck--find-working-directory) (add-to-list 'flycheck-checkers 'solium-checker) (setq flycheck-solium-checker-executable solidity-solium-path)) (error (format "Solidity Mode Configuration error. Requested solium flycheck integration but can't find solium at: %s" solidity-solium-path))))) @@ -147,13 +197,56 @@ we pass the directory to solium via the `--config' option." (patch (string-to-number (nth 2 version)))) (if (and (>= major 0) (>= minor 6)) t nil))) +(defun solidity-flycheck--solc-allow-paths () + (append + (mapcar #'expand-file-name solidity-flycheck-solc-additional-allow-paths) + '("."))) + +(defun solidity-flycheck--only-subdirectories (dir) + (-filter + (lambda (p) + (and (file-directory-p p) + (not (string-prefix-p "." (file-name-nondirectory p))))) + (directory-files dir t))) + +(defun solidity-flycheck--solc-remappings () + (let* ((allow-paths (solidity-flycheck--solc-allow-paths))) + (->> allow-paths + (mapcar + #'solidity-flycheck--only-subdirectories) + + -flatten + + (mapcar + (lambda (dir) + (let ((prefix (file-name-nondirectory dir))) + (concat prefix "=" dir))))))) + +(defun solidity-flycheck--solc-remappings-opt () + (when-let ((remappings (solidity-flycheck--solc-remappings))) + remappings)) + +(defun solidity-flycheck--solc-allow-paths-opt () + (let ((allow-paths (mapconcat 'identity (solidity-flycheck--solc-allow-paths) ","))) + (when (not (string= "" allow-paths)) + `("--allow-paths" ,allow-paths)))) + +(defun solidity-flycheck--solc-cmd () + (if (solc-gt-0.6.0) + `("solc" + "--no-color" + ,@(solidity-flycheck--solc-allow-paths-opt) + ,@(solidity-flycheck--solc-remappings-opt) + source-inplace) + '("solc" source-inplace))) + (when solidity-flycheck-solc-checker-active ;; add a solidity mode callback to set the executable of solc for flycheck ;; define solidity's flycheck syntax checker ;; expanded the flycheck-define-checker macro in order to eval certain args, as per advice given in gitter ;; https://gitter.im/flycheck/flycheck?at=5a43b3a8232e79134d98872b (flycheck-def-executable-var solidity-checker "solc") - (let* ((cmd (if (solc-gt-0.6.0) '("solc" "--no-color" source-inplace) '("solc" source-inplace)))) + (let* ((cmd (solidity-flycheck--solc-cmd))) (if (funcall flycheck-executable-find solidity-solc-path) (progn (flycheck-define-command-checker 'solidity-checker @@ -173,7 +266,7 @@ we pass the directory to solium via the `--config' option." :predicate #'(lambda nil (eq major-mode 'solidity-mode)) :next-checkers `((,solidity-flycheck-chaining-error-level . solium-checker)) :standard-input 'nil - :working-directory 'nil) + :working-directory 'solidity-flycheck--find-working-directory) (add-to-list 'flycheck-checkers 'solidity-checker) (setq flycheck-solidity-checker-executable solidity-solc-path)) (error (format "Solidity Mode Configuration error. Requested solc flycheck integration but can't find solc at: %s" solidity-solc-path))))) diff --git a/solidity-mode.el b/solidity-mode.el index 3f27060..bef8480 100644 --- a/solidity-mode.el +++ b/solidity-mode.el @@ -4,7 +4,7 @@ ;; Author: Lefteris Karapetsas ;; Keywords: languages, solidity -;; Version: 0.1.10 +;; Version: 0.1.11 ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by From 9b1b7097fb5aaecb2aeec558b7d975bb3d7b8d10 Mon Sep 17 00:00:00 2001 From: Mark Hudnall Date: Fri, 29 Jan 2021 02:25:56 -0800 Subject: [PATCH 08/27] Add some tests for remapping logic --- .gitignore | 4 +- test/solidity-flycheck-tests.el | 44 +++++++++++++++++++++ test/solidity-mode-test-setup.el | 68 ++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 test/solidity-flycheck-tests.el create mode 100644 test/solidity-mode-test-setup.el diff --git a/.gitignore b/.gitignore index a402d5a..4c8ee07 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -solidity-mode.elc \ No newline at end of file +solidity-mode.elc +test/elpa +test/straight diff --git a/test/solidity-flycheck-tests.el b/test/solidity-flycheck-tests.el new file mode 100644 index 0000000..767f052 --- /dev/null +++ b/test/solidity-flycheck-tests.el @@ -0,0 +1,44 @@ +;;; solidity-flycheck-tests.el --- Setup and execute all tests + +;;; Commentary: + +;; This package contains tests for the solidity-flycheck package. + +;;; Code: + +(require 'solidity-flycheck) + +(ert-deftest test-solidity-flycheck--solc-allow-paths () + "Test that `solidity-flycheck--solc-allow-paths' contains `solidity-flycheck-solc-additional-allow-paths'." + (let ((solidity-flycheck-solc-additional-allow-paths '("/tmp/test1" "/tmp/test2"))) + (should (equal + (solidity-flycheck--solc-allow-paths) + '("/tmp/test1" "/tmp/test2" "."))))) + +(defmacro with-temp-dirs (temp-dirs &rest body) + (let ((bindings (mapcar (lambda (d) `(,d (make-temp-file "" t))) + temp-dirs))) + `(let ,bindings + (unwind-protect + (progn + ,@body) + (progn + (dolist (d (list ,@temp-dirs)) + (delete-directory d t))))))) + +(ert-deftest test-solidity-flycheck--solc-remappings () + "Test that `solidity-flycheck--solc-remappings' creates remappings for path in `solidity-flycheck--solc-allow-paths'" + (with-temp-dirs + (test-dir-1 test-dir-2 test-dir-3) + (let* ((default-directory test-dir-1) + (solidity-flycheck-solc-additional-allow-paths (list test-dir-2 test-dir-3))) + (make-directory (concat (file-name-as-directory test-dir-2) "subdir1")) + (make-directory (concat (file-name-as-directory test-dir-3) "@subdir2")) + (should (equal + (solidity-flycheck--solc-remappings) + (list (concat "subdir1=" (concat (file-name-as-directory test-dir-2) "subdir1")) + (concat "@subdir2=" (concat (file-name-as-directory test-dir-3) "@subdir2"))))))) + ) + +(provide 'solidity-flycheck-tests) +;;; solidity-flycheck-tests.el ends here diff --git a/test/solidity-mode-test-setup.el b/test/solidity-mode-test-setup.el new file mode 100644 index 0000000..29d3edc --- /dev/null +++ b/test/solidity-mode-test-setup.el @@ -0,0 +1,68 @@ +;;; solidity-mode-test-setup.el --- Setup and execute all tests + +;;; Commentary: + +;; This package sets up a suitable enviroment for testing +;; solidity-mode, and executes the tests. +;; +;; Usage: +;; +;; emacs -q -l test/solidity-mode-test-setup.el +;; +;; Note that this package assumes that some packages are located in +;; specific locations. + +;;; Code: + +(setq user-init-file (or load-file-name (buffer-file-name))) +(setq user-emacs-directory (file-name-directory user-init-file)) + +(require 'package) +(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) +(setq package-enable-at-startup nil) +(package-initialize) +(when (not package-archive-contents) + (package-refresh-contents)) + +(defvar bootstrap-version) +(let ((bootstrap-file + (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) + (bootstrap-version 5)) + (unless (file-exists-p bootstrap-file) + (with-current-buffer + (url-retrieve-synchronously + "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" + 'silent 'inhibit-cookies) + (goto-char (point-max)) + (eval-print-last-sexp))) + (load bootstrap-file nil 'nomessage)) + +(straight-use-package 'use-package) + +(add-to-list 'load-path (expand-file-name "./")) +(add-to-list 'load-path (expand-file-name "./test")) +(package-install-file "solidity-mode.el") +(package-install-file "solidity-flycheck.el") +(global-flycheck-mode 1) + +(use-package solidity-mode + :mode ("\\.sol\\'" . solidity-mode)) + +(use-package solidity-flycheck + :defer t + :init + (setq solidity-flycheck-solium-checker-active t) + (setq solidity-flycheck-solc-checker-active t) + (setq solidity-flycheck-chaining-error-level t) + (setq solidity-flycheck-use-project t) + (setq solidity-flycheck-solc-additional-allow-paths '("~/.brownie/packages")) + (add-hook + 'solidity-mode-hook + (lambda () + (require 'solidity-flycheck)))) + +(require 'ert) + +(require 'solidity-flycheck-tests) + +(ert t) From 32b641df0d8f5e2256fd5ef693291803de0a63ab Mon Sep 17 00:00:00 2001 From: Weiwu Zhang Date: Thu, 1 Apr 2021 14:38:05 +1100 Subject: [PATCH 09/27] Update README.org added the steps needed for melpa --- README.org | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.org b/README.org index 38f4120..82e0168 100644 --- a/README.org +++ b/README.org @@ -17,6 +17,11 @@ If you don't know how to use el-get you can find more information on its [[https ** Melpa You can also obtain solidity-mode from [[http://melpa.org/#/][Melpa]] as can be seen [[http://melpa.org/#/solidity-mode][here]]. +1. Install melpa and make sure emacs is started with it. +2. Press =Alt+x= (this is in emacs notation written as =M-x= ) and then type =package-refresh-contents=. +3. Press =Alt+x= and then type =package-install=. This will prompt you for a package. +3. type =solidity-mode= and hit enter, this should install all you need. + * Configuration By default solidity-mode associates itself with any files ending in =.sol=. From b83354943626ea7c50011d5806b17be17077d1c4 Mon Sep 17 00:00:00 2001 From: Mark Hudnall Date: Mon, 1 Mar 2021 23:55:05 -0800 Subject: [PATCH 10/27] Ignore solc remappings that don't exist --- solidity-flycheck.el | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/solidity-flycheck.el b/solidity-flycheck.el index 0a8670c..4147a40 100644 --- a/solidity-flycheck.el +++ b/solidity-flycheck.el @@ -212,11 +212,9 @@ no .soliumrc.json is found, `project-roots' is used." (defun solidity-flycheck--solc-remappings () (let* ((allow-paths (solidity-flycheck--solc-allow-paths))) (->> allow-paths - (mapcar - #'solidity-flycheck--only-subdirectories) - + (remove-if-not #'file-exists-p) + (mapcar #'solidity-flycheck--only-subdirectories) -flatten - (mapcar (lambda (dir) (let ((prefix (file-name-nondirectory dir))) From 383ac144727c716c65989c079ae76127e25144c3 Mon Sep 17 00:00:00 2001 From: Juergen Hoetzel Date: Wed, 5 May 2021 17:25:35 +0200 Subject: [PATCH 11/27] Fix invalid identifier regex (overlapping range) The overlapping range [A-z] includes non-identifier characters: "[^`". --- solidity-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solidity-mode.el b/solidity-mode.el index bef8480..f0d8036 100644 --- a/solidity-mode.el +++ b/solidity-mode.el @@ -297,7 +297,7 @@ Possible values are: "Built in constructs of the solidity language.") (defvar solidity-identifier-regexp - "\\([a-zA-z0-9]\\|_\\)+") + "\\([a-zA-Z0-9]\\|_\\)+") (defvar solidity-variable-attributes "\\(&\\|*\\|~\\)" From 5f6ef3156fadae5af6f381d674d20535529a20e4 Mon Sep 17 00:00:00 2001 From: hrkrshnn Date: Sun, 20 Jun 2021 20:26:48 +0200 Subject: [PATCH 12/27] Added support for highlighting custom errors in solidity. They are almost same as events, so copied the existing code for events! --- solidity-mode.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/solidity-mode.el b/solidity-mode.el index f0d8036..0ff338c 100644 --- a/solidity-mode.el +++ b/solidity-mode.el @@ -106,6 +106,7 @@ Possible values are: "emit" "enum" "event" + "error" "external" "for" "function" @@ -335,6 +336,8 @@ Possible values are: (2 font-lock-variable-name-face)) '(solidity-match-event-decl (1 font-lock-keyword-face) (2 font-lock-variable-name-face)) + '(solidity-match-error-decl (1 font-lock-keyword-face) + (2 font-lock-variable-name-face)) '(solidity-match-variable-decls (1 font-lock-keyword-face) (2 font-lock-variable-name-face)) `(,(regexp-opt solidity-constants 'words) . font-lock-constant-face)) @@ -402,6 +405,15 @@ Highlight the 1st result." " *\\(\\\\) +\\(" solidity-identifier-regexp "\\)") limit)) +(defun solidity-match-error-decl (limit) + "Search the buffer forward until LIMIT matching error names. + +Highlight the 1st result." + (solidity-match-regexp + (concat + " *\\(\\\\) +\\(" solidity-identifier-regexp "\\)") + limit)) + (defun solidity-match-modifier-decl (limit) "Search the buffer forward until LIMIT matching function names. From 6f7bd1641e5282ec5163188d8b8c2f6dfddc2e36 Mon Sep 17 00:00:00 2001 From: hrkrshnn Date: Fri, 9 Jul 2021 14:14:29 +0200 Subject: [PATCH 13/27] Added the keyword immutable. --- solidity-mode.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/solidity-mode.el b/solidity-mode.el index 0ff338c..c0fda22 100644 --- a/solidity-mode.el +++ b/solidity-mode.el @@ -111,6 +111,7 @@ Possible values are: "for" "function" "if" + "immutable" "import" "in" "indexed" @@ -171,6 +172,7 @@ Possible values are: (defconst solidity-variable-modifier '("constant" "public" + "immutable" "indexed" "storage" "memory" From 9c77b390eab999e5e54dc5c1068f57201e6628bf Mon Sep 17 00:00:00 2001 From: hrkrshnn Date: Thu, 16 Sep 2021 13:30:59 +0200 Subject: [PATCH 14/27] Added support for highlighting user defined value types. A feature from Solidity 0.8.8. Syntax looks like: `type MyAddress is address;` --- solidity-mode.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/solidity-mode.el b/solidity-mode.el index c0fda22..8438717 100644 --- a/solidity-mode.el +++ b/solidity-mode.el @@ -340,6 +340,8 @@ Possible values are: (2 font-lock-variable-name-face)) '(solidity-match-error-decl (1 font-lock-keyword-face) (2 font-lock-variable-name-face)) + '(solidity-match-user-defined-value-type-decl (1 font-lock-keyword-face) + (2 font-lock-variable-name-face)) '(solidity-match-variable-decls (1 font-lock-keyword-face) (2 font-lock-variable-name-face)) `(,(regexp-opt solidity-constants 'words) . font-lock-constant-face)) @@ -416,6 +418,15 @@ Highlight the 1st result." " *\\(\\\\) +\\(" solidity-identifier-regexp "\\)") limit)) +(defun solidity-match-user-defined-value-type-decl (limit) + "Search the buffer forward until LIMIT matching user defined value type names. + +Highlight the 1st result." + (solidity-match-regexp + (concat + " *\\(\\\\) +\\(" solidity-identifier-regexp "\\)") + limit)) + (defun solidity-match-modifier-decl (limit) "Search the buffer forward until LIMIT matching function names. From bac439dbd2097664df45e9fac0ce57e23462c14c Mon Sep 17 00:00:00 2001 From: hrkrshnn Date: Sat, 13 Nov 2021 01:24:23 +0530 Subject: [PATCH 15/27] Added "try" and "catch" to keyword list --- solidity-mode.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/solidity-mode.el b/solidity-mode.el index 8438717..0237cc2 100644 --- a/solidity-mode.el +++ b/solidity-mode.el @@ -95,6 +95,7 @@ Possible values are: "assembly" "assert" "break" + "catch" "constant" "constructor" "continue" @@ -138,6 +139,7 @@ Possible values are: "switch" "this" "throw" + "try" "using" "var" "view" From dae5957e5028ffecb527c98a0b0c39696fa9ec1c Mon Sep 17 00:00:00 2001 From: Kevin Ji <1146876+kevinji@users.noreply.github.com> Date: Thu, 16 Dec 2021 17:03:57 -0800 Subject: [PATCH 16/27] Fix typo in LICENSE's filename --- LICENCSE => LICENSE | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename LICENCSE => LICENSE (100%) diff --git a/LICENCSE b/LICENSE similarity index 100% rename from LICENCSE rename to LICENSE From 7f239128a15b2baf47be0f8c88f1f533f3114071 Mon Sep 17 00:00:00 2001 From: Layerex Date: Sat, 27 Nov 2021 11:21:20 +0300 Subject: [PATCH 17/27] Add calldata keyword --- solidity-mode.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/solidity-mode.el b/solidity-mode.el index 0237cc2..ce1898a 100644 --- a/solidity-mode.el +++ b/solidity-mode.el @@ -95,6 +95,7 @@ Possible values are: "assembly" "assert" "break" + "calldata" "catch" "constant" "constructor" @@ -178,6 +179,7 @@ Possible values are: "indexed" "storage" "memory" + "calldata" ) "Modifiers of variables in solidity.") From f0f68b038c5edf16c85fc8ca58537e1c6479738b Mon Sep 17 00:00:00 2001 From: Ta Quang Trung Date: Thu, 6 Jan 2022 11:44:34 +0800 Subject: [PATCH 18/27] add fallback and receive keywords --- solidity-mode.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/solidity-mode.el b/solidity-mode.el index ce1898a..ea4a6ab 100644 --- a/solidity-mode.el +++ b/solidity-mode.el @@ -110,6 +110,7 @@ Possible values are: "event" "error" "external" + "fallback" "for" "function" "if" @@ -131,6 +132,7 @@ Possible values are: "private" "public" "pure" + "receive" "require" "return" "returns" From 20fb77e089e10187b37ae1a94153017b82ed2a0a Mon Sep 17 00:00:00 2001 From: Layerex Date: Mon, 21 Feb 2022 12:43:19 +0300 Subject: [PATCH 19/27] Highlight interface names --- solidity-mode.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/solidity-mode.el b/solidity-mode.el index ea4a6ab..4fc7b0e 100644 --- a/solidity-mode.el +++ b/solidity-mode.el @@ -338,6 +338,8 @@ Possible values are: (2 font-lock-variable-name-face)) '(solidity-match-contract-decl (1 font-lock-keyword-face) (2 font-lock-variable-name-face)) + '(solidity-match-interface-decl (1 font-lock-keyword-face) + (2 font-lock-variable-name-face)) '(solidity-match-modifier-decl (1 font-lock-keyword-face) (2 font-lock-variable-name-face)) '(solidity-match-struct-decl (1 font-lock-keyword-face) @@ -370,6 +372,15 @@ First match should be a keyword and second an identifier." " *\\(\\\\) +\\(" solidity-identifier-regexp "\\)") limit)) +(defun solidity-match-interface-decl (limit) + "Search the buffer forward until LIMIT matching interface declarations. + +First match should be a keyword and second an identifier." + (solidity-match-regexp + (concat + " *\\(\\\\) +\\(" solidity-identifier-regexp "\\)") + limit)) + (defun solidity-match-library-decl (limit) "Search the buffer forward until LIMIT matching library declarations. From 211dbdf0dfab1139681156e6f9621a5bbe0f74a1 Mon Sep 17 00:00:00 2001 From: Clark Henry <42017055+clarkhenry@users.noreply.github.com> Date: Sun, 10 Jul 2022 20:29:22 -0700 Subject: [PATCH 20/27] use cl-lib function --- solidity-flycheck.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solidity-flycheck.el b/solidity-flycheck.el index 4147a40..b729755 100644 --- a/solidity-flycheck.el +++ b/solidity-flycheck.el @@ -212,7 +212,7 @@ no .soliumrc.json is found, `project-roots' is used." (defun solidity-flycheck--solc-remappings () (let* ((allow-paths (solidity-flycheck--solc-allow-paths))) (->> allow-paths - (remove-if-not #'file-exists-p) + (cl-remove-if-not #'file-exists-p) (mapcar #'solidity-flycheck--only-subdirectories) -flatten (mapcar From ffbeee8dd95b45d52a3abc2ca7decfa51b64ad00 Mon Sep 17 00:00:00 2001 From: Ta Quang Trung Date: Fri, 30 Sep 2022 10:43:42 +0800 Subject: [PATCH 21/27] fix indentation for the close parenthesis of function calls --- solidity-mode.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/solidity-mode.el b/solidity-mode.el index 4fc7b0e..98c6052 100644 --- a/solidity-mode.el +++ b/solidity-mode.el @@ -596,6 +596,10 @@ Cursor must be at the function's name. Does not currently work for constructors 'c-indent-new-comment-line) (set (make-local-variable 'c-basic-offset) 4) + ;; customize indentation more specific to Solidity + (make-local-variable 'c-offsets-alist) + (add-to-list 'c-offsets-alist '(arglist-close . c-lineup-close-paren)) + (when solidity-mode-disable-c-mode-hook (set (make-local-variable 'c-mode-hook) nil)) From 6aa8b0aef128754b775a165e269879832d5a60e5 Mon Sep 17 00:00:00 2001 From: Ta Quang Trung Date: Sat, 15 Oct 2022 16:37:13 +0800 Subject: [PATCH 22/27] display fallback function in imenu outline --- solidity-mode.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/solidity-mode.el b/solidity-mode.el index 98c6052..6bf77e5 100644 --- a/solidity-mode.el +++ b/solidity-mode.el @@ -551,14 +551,16 @@ Cursor must be at the function's name. Does not currently work for constructors (let* ((spacetabs "[\t\n ]+") (optional-spacetabs "[\t\n ]*") (ident-group "\\([A-Za-z_][A-Za-z0-9_]*\\)") - (ctr-ident-group "\\(constructor\\)") + (constructor-ident-group "\\(constructor\\)") + (fallback-ident-group "\\(fallback\\)") (modifier (mapconcat 'identity '("payable" "public" "private" "external" "internal" "view" "pure") "\\|")) (modifiers (concat "\\(?:\\(?:" modifier "\\)" spacetabs "\\)*"))) `(("function", (concat "^" optional-spacetabs "function" spacetabs ident-group) 1) ("modifier", (concat "^" optional-spacetabs "modifier" spacetabs ident-group) 1) - ("constructor", (concat "^" optional-spacetabs ctr-ident-group) 1) + ("constructor", (concat "^" optional-spacetabs constructor-ident-group) 1) + ("function", (concat "^" optional-spacetabs fallback-ident-group) 1) ("contract", (concat "^" optional-spacetabs "contract" spacetabs ident-group) 1) ("library", (concat "^" optional-spacetabs "library" spacetabs ident-group) 1) ("interface", (concat "^" optional-spacetabs "interface" spacetabs ident-group) 1) From 3a40b017afd7b96f55734dc45f29d4d65bcdf518 Mon Sep 17 00:00:00 2001 From: Mark Hudnall Date: Mon, 1 Mar 2021 23:44:17 -0800 Subject: [PATCH 23/27] Simplify checkers and add solhint - Add a checker for solhint - Simplify checkers. This commit removes some of the load-time logic that determined whether to define the flycheck checkers. Flycheck has its own logic to enable or disable checkers based on the presence of the :command binary, making these checks redundant. Some of the other checks done at load time have been moved into (eval ...) forms, so that the binaries can be customized after load-time with flycheck's pre-defined vars e.g. `flycheck-solium-checker-executable'. This is useful when linting binaries are installed locally in a project. --- solidity-common.el | 6 ++ solidity-flycheck.el | 207 +++++++++++++++++++++++-------------------- 2 files changed, 116 insertions(+), 97 deletions(-) diff --git a/solidity-common.el b/solidity-common.el index 3527912..a830742 100644 --- a/solidity-common.el +++ b/solidity-common.el @@ -37,5 +37,11 @@ :type 'string :package-version '(solidity . "0.1.4")) +(defcustom solidity-solhint-path "solhint" + "Path to the solium binary." + :group 'solidity + :type 'string + :package-version '(solidity . "0.1.12")) + (provide 'solidity-common) ;;; solidity-common.el ends here diff --git a/solidity-flycheck.el b/solidity-flycheck.el index b729755..73d58a6 100644 --- a/solidity-flycheck.el +++ b/solidity-flycheck.el @@ -30,16 +30,7 @@ (require 'flycheck) (require 'solidity-common) (require 'dash) - -(defvar flycheck-solidity-checker-executable) -(defvar flycheck-solium-checker-executable) - -(defcustom solidity-flycheck-solc-checker-active nil - "A boolean flag denoting if solc flycheck checker should be active." - :group 'solidity - :type 'boolean - :safe #'booleanp - :package-version '(solidity . "0.1.5")) +(require 'project) (defcustom solidity-flycheck-chaining-error-level 'warning "The maximum error level at which chaining of checkers will happen. @@ -69,13 +60,6 @@ Possible values are: :package-version '(solidity . "0.1.5") :safe #'symbolp) -(defcustom solidity-flycheck-solium-checker-active nil - "A boolean flag denoting if solium flycheck checker should be active." - :group 'solidity - :type 'boolean - :safe #'booleanp - :package-version '(solidity . "0.1.5")) - (flycheck-def-option-var flycheck-solidity-solium-soliumrcfile nil solium-check "The path to use for soliumrc.json @@ -111,13 +95,15 @@ during compilation and linting. solidity-flycheck will look for a .soliumrc.json in a parent directory. If found, this directory is considered the project root. If no .soliumrc.json is found, `project-roots' is used. -When `solidity-flycheck-solium-checker-active' is t, the .soliumrc.json found in -the project root will be used as the solium config, rather than a .soliumrc.json -in the same directory as the file being linted. +When using solium-checker, the .soliumrc.json found in the project root will be +used as the solium config, rather than a .soliumrc.json in the same directory as +the file being linted. -When `solidity-flycheck-solc-checker-active' is t, the project root will be passed -to solc using the --allow-paths flag. This means imports to other files inside the -project will lint without erorr." +When using solhint-checker, solhint will be run at the project root. + +When using solidity-checker , the project root will be passed to solc using the +--allow-paths flag. This means imports to other files inside the project will +lint without erorr." :group 'solidity :type 'boolean :safe #'booleanp @@ -136,45 +122,52 @@ no .soliumrc.json is found, `project-roots' is used." (car roots))))) (expand-file-name root)))) -(when solidity-flycheck-solium-checker-active ;; define solium flycheck syntax checker ;; expanded the flycheck-define-checker macro in order to eval certain args, as per advice given in gitter ;; https://gitter.im/flycheck/flycheck?at=5a43b3a8232e79134d98872b ;; first try to add solium to the checker's list since if we got solc ;; it must come after it in the list due to it being chained after solc - (flycheck-def-executable-var solium-checker "solium") - (let ((solium-full-path (funcall flycheck-executable-find solidity-solium-path))) - (if solium-full-path - (let ((solium-has-reporter (string-match-p "--reporter" (shell-command-to-string (concat solium-full-path " --help"))))) - (flycheck-define-command-checker 'solium-checker - "A Solidity linter using solium" - :command `("solium" - ,(if solium-has-reporter "--reporter=gcc" "") - (option "--config=" flycheck-solidity-solium-soliumrcfile concat) - "-f" - source-inplace) - :error-patterns `((error line-start (zero-or-more not-newline) "[Fatal error]" (message)) - ,(if solium-has-reporter - '(error line-start (file-name) ":" line ":" column ": error: " (message)) - '(error line-start (zero-or-more " ") line ":" column (zero-or-more " ") "error" (message))) - ,(if solium-has-reporter - '(warning line-start (file-name) ":" line ":" column ": warning: " (message)) - '(warning line-start (zero-or-more " ") line ":" column (zero-or-more " ") "warning" (message)))) - :error-filter - ;; Add fake line numbers if they are missing in the lint output - #'(lambda (errors) - (dolist (err errors) - (unless (flycheck-error-line err) - (setf (flycheck-error-line err) 1))) - errors) - :modes 'solidity-mode - :predicate #'(lambda nil (eq major-mode 'solidity-mode)) - :next-checkers 'nil - :standard-input 'nil - :working-directory 'solidity-flycheck--find-working-directory) - (add-to-list 'flycheck-checkers 'solium-checker) - (setq flycheck-solium-checker-executable solidity-solium-path)) - (error (format "Solidity Mode Configuration error. Requested solium flycheck integration but can't find solium at: %s" solidity-solium-path))))) +(flycheck-def-executable-var solium-checker "solium") + +(defun solium-has-reporter () + (let ((solium-full-path (funcall + flycheck-executable-find + (or flycheck-solium-checker-executable solidity-solium-path)))) + (and solium-full-path + (string-match-p "--reporter" (shell-command-to-string (concat solium-full-path " --help")))))) + +(flycheck-define-command-checker 'solium-checker + "A Solidity linter using solium" + :command `(,solidity-solium-path + (eval (when (solium-has-reporter) "--reporter=gcc")) + (option "--config=" flycheck-solidity-solium-soliumrcfile concat) + "-f" + source-inplace) +:error-patterns `((error line-start (zero-or-more not-newline) "[Fatal error]" (message)) + (error line-start (zero-or-more " ") line ":" column (zero-or-more " ") "error" (message)) + (warning line-start (zero-or-more " ") line ":" column (zero-or-more " ") "warning" (message)) + ;; reporter=gcc formats + (error line-start (file-name) ":" line ":" column ": error: " (message)) + (warning line-start (file-name) ":" line ":" column ": warning: " (message))) + + :error-filter + ;; Add fake line numbers if they are missing in the lint output + #'(lambda (errors) + (dolist (err errors) + (unless (flycheck-error-line err) + (setf (flycheck-error-line err) 1))) + errors) + :modes 'solidity-mode + :predicate #'(lambda nil (eq major-mode 'solidity-mode)) + :next-checkers `((,solidity-flycheck-chaining-error-level . solhint-checker)) + :standard-input 'nil + :working-directory 'solidity-flycheck--find-working-directory) + +;; add a solidity mode callback to set the executable of solc for flycheck +;; define solidity's flycheck syntax checker +;; expanded the flycheck-define-checker macro in order to eval certain args, as per advice given in gitter +;; https://gitter.im/flycheck/flycheck?at=5a43b3a8232e79134d98872b +(flycheck-def-executable-var solidity-checker "solc") (defun get-solc-version () "Query solc executable and return its version. @@ -182,12 +175,15 @@ no .soliumrc.json is found, `project-roots' is used." The result is returned in a list with 3 elements.MAJOR MINOR PATCH. If the solc output can't be parsed an error is returned." - (let ((output (shell-command-to-string (format "%s --version" solidity-solc-path)))) + (let* ((solc-full-path (funcall + flycheck-executable-find + (or flycheck-solidity-checker-executable solidity-solc-path))) + (output (shell-command-to-string (format "%s --version" solc-full-path)))) (if (string-match "Version: \\([[:digit:]]+\\)\.\\([[:digit:]]+\\)\.\\([[:digit:]]+\\)" output) (list (match-string 1 output) (match-string 2 output) (match-string 3 output)) - (error "Could not parse the output of %s --version:\n %s" solidity-solc-path output)))) + (error "Could not parse the output of %s --version:\n %s" solc-full-path output)))) (defun solc-gt-0.6.0 () "Return `t` if solc >= 0.6.0 and `nil` otherwise." @@ -230,44 +226,61 @@ no .soliumrc.json is found, `project-roots' is used." `("--allow-paths" ,allow-paths)))) (defun solidity-flycheck--solc-cmd () - (if (solc-gt-0.6.0) - `("solc" - "--no-color" - ,@(solidity-flycheck--solc-allow-paths-opt) - ,@(solidity-flycheck--solc-remappings-opt) - source-inplace) - '("solc" source-inplace))) - -(when solidity-flycheck-solc-checker-active - ;; add a solidity mode callback to set the executable of solc for flycheck - ;; define solidity's flycheck syntax checker - ;; expanded the flycheck-define-checker macro in order to eval certain args, as per advice given in gitter - ;; https://gitter.im/flycheck/flycheck?at=5a43b3a8232e79134d98872b - (flycheck-def-executable-var solidity-checker "solc") - (let* ((cmd (solidity-flycheck--solc-cmd))) - (if (funcall flycheck-executable-find solidity-solc-path) - (progn - (flycheck-define-command-checker 'solidity-checker - "A Solidity syntax checker using the solc compiler" - :command cmd - :error-patterns '( - ;; Solidity >= 0.6.0 error formats - (error line-start "Error: " (message) "\n" (zero-or-more whitespace) "--> " (file-name) ":" line ":" column) - (warning line-start "Warning: " (message) "\n" (zero-or-more whitespace) "--> " (file-name) ":" line ":" column) - - ;; Solidity < 0.6.0 error formats - (error line-start (file-name) ":" line ":" column ":" " Error: " (message)) - (error line-start (file-name) ":" line ":" column ":" " Compiler error: " (message)) - (error line-start "Error: " (message)) - (warning line-start (file-name) ":" line ":" column ":" " Warning: " (message))) - :modes 'solidity-mode - :predicate #'(lambda nil (eq major-mode 'solidity-mode)) - :next-checkers `((,solidity-flycheck-chaining-error-level . solium-checker)) - :standard-input 'nil - :working-directory 'solidity-flycheck--find-working-directory) - (add-to-list 'flycheck-checkers 'solidity-checker) - (setq flycheck-solidity-checker-executable solidity-solc-path)) - (error (format "Solidity Mode Configuration error. Requested solc flycheck integration but can't find solc at: %s" solidity-solc-path))))) + `(,solidity-solc-path + (eval + (when (solc-gt-0.6.0) + `("--no-color" + ,@(solidity-flycheck--solc-allow-paths-opt) + ,@(solidity-flycheck--solc-remappings-opt)))) + source-inplace)) + +(flycheck-define-command-checker 'solidity-checker + "A Solidity syntax checker using the solc compiler" + :command (solidity-flycheck--solc-cmd) + :error-patterns '( + ;; Solidity >= 0.6.0 error formats + (error line-start "Error: " (message) "\n" (zero-or-more whitespace) "--> " (file-name) ":" line ":" column) + (warning line-start "Warning: " (message) "\n" (zero-or-more whitespace) "--> " (file-name) ":" line ":" column) + + ;; Solidity < 0.6.0 error formats + (error line-start (file-name) ":" line ":" column ":" " Error: " (message)) + (error line-start (file-name) ":" line ":" column ":" " Compiler error: " (message)) + (error line-start "Error: " (message)) + (warning line-start (file-name) ":" line ":" column ":" " Warning: " (message))) + :modes 'solidity-mode + :predicate #'(lambda nil (eq major-mode 'solidity-mode)) + :next-checkers + `((,solidity-flycheck-chaining-error-level . solium-checker) + (,solidity-flycheck-chaining-error-level . solhint-checker)) + :standard-input 'nil + :working-directory 'solidity-flycheck--find-working-directory) + +(flycheck-def-executable-var solhint-checker "solhint") +(flycheck-define-command-checker 'solhint-checker + "A Solidity linter using solhint" + :command `(,solidity-solhint-path "-f" "visualstudio" source-inplace) + :error-patterns `((error + line-start (file-name) "(" line "," column "):" (zero-or-more " ") + "error" (zero-or-more " ") (message)) + (warning + line-start (file-name) "(" line "," column "):" (zero-or-more " ") + "warning" (zero-or-more " ") (message))) + :error-filter + ;; Add fake line numbers if they are missing in the lint output + #'(lambda (errors) + (dolist (err errors) + (unless (flycheck-error-line err) + (setf (flycheck-error-line err) 1))) + errors) + :modes 'solidity-mode + :predicate #'(lambda nil (eq major-mode 'solidity-mode)) + :next-checkers 'nil + :standard-input 'nil + :working-directory 'solidity-flycheck--find-working-directory) + +(add-to-list 'flycheck-checkers 'solhint-checker) +(add-to-list 'flycheck-checkers 'solium-checker) +(add-to-list 'flycheck-checkers 'solidity-checker) (provide 'solidity-flycheck) ;;; solidity-flycheck.el ends here From 8cb8ac6d1311f5bc893cd72ee96e3e335ee8b2a1 Mon Sep 17 00:00:00 2001 From: Mark Hudnall Date: Tue, 18 Oct 2022 21:39:40 -0700 Subject: [PATCH 24/27] Use unix formatter The unix formatter is documented, while the visualstudio formatter is not. Prefer the unix formatter. --- solidity-flycheck.el | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/solidity-flycheck.el b/solidity-flycheck.el index 73d58a6..90f4850 100644 --- a/solidity-flycheck.el +++ b/solidity-flycheck.el @@ -258,13 +258,13 @@ no .soliumrc.json is found, `project-roots' is used." (flycheck-def-executable-var solhint-checker "solhint") (flycheck-define-command-checker 'solhint-checker "A Solidity linter using solhint" - :command `(,solidity-solhint-path "-f" "visualstudio" source-inplace) + :command `(,solidity-solhint-path "-f" "unix" source-inplace) :error-patterns `((error - line-start (file-name) "(" line "," column "):" (zero-or-more " ") - "error" (zero-or-more " ") (message)) + line-start (file-name) ":" line ":" column ":" (zero-or-more " ") + (zero-or-more " ") (message (one-or-more not-newline) "[Error/" (one-or-more not-newline) "]" )) (warning - line-start (file-name) "(" line "," column "):" (zero-or-more " ") - "warning" (zero-or-more " ") (message))) + line-start (file-name) ":" line ":" column ":" (zero-or-more " ") + (zero-or-more " ") (message (one-or-more not-newline) "[Warning/" (one-or-more not-newline) "]" ))) :error-filter ;; Add fake line numbers if they are missing in the lint output #'(lambda (errors) From 929ce58ff0d42cf1109f9fb0655c787ee58cc2da Mon Sep 17 00:00:00 2001 From: Mark Hudnall Date: Tue, 18 Oct 2022 21:41:52 -0700 Subject: [PATCH 25/27] Fix typo --- solidity-common.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solidity-common.el b/solidity-common.el index a830742..bbc3fcd 100644 --- a/solidity-common.el +++ b/solidity-common.el @@ -38,7 +38,7 @@ :package-version '(solidity . "0.1.4")) (defcustom solidity-solhint-path "solhint" - "Path to the solium binary." + "Path to the solhint binary." :group 'solidity :type 'string :package-version '(solidity . "0.1.12")) From ddb4a901c33bd29ba2eefff3b7f7461849c6e833 Mon Sep 17 00:00:00 2001 From: Ta Quang Trung Date: Thu, 17 Nov 2022 01:12:01 +0800 Subject: [PATCH 26/27] update syntax to accept the dollar sign as part of a word --- solidity-mode.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/solidity-mode.el b/solidity-mode.el index 6bf77e5..3d40ccf 100644 --- a/solidity-mode.el +++ b/solidity-mode.el @@ -474,8 +474,9 @@ Highlight the 1st result." ;; solidity syntax table (defvar solidity-mode-syntax-table (let ((st (make-syntax-table))) - ;; '_' underscore is a valid part of a word + ;; Underscore ('_') and dollar sign ('$') are valid parts of a word. (modify-syntax-entry ?_ "w" st) + (modify-syntax-entry ?$ "w" st) ;; c++ style comments in the syntax table ;; more info on the syntax flags here: ;; http://www.gnu.org/software/emacs/manual/html_node/elisp/Syntax-Flags.html From 8ba549e429e86778a0e079648f3bc3463fcb15f6 Mon Sep 17 00:00:00 2001 From: Ta Quang Trung Date: Wed, 28 Jun 2023 22:10:46 +0800 Subject: [PATCH 27/27] mark `unchecked` as keyword --- solidity-mode.el | 1 + 1 file changed, 1 insertion(+) diff --git a/solidity-mode.el b/solidity-mode.el index 3d40ccf..da83d44 100644 --- a/solidity-mode.el +++ b/solidity-mode.el @@ -143,6 +143,7 @@ Possible values are: "this" "throw" "try" + "unchecked" "using" "var" "view"