@@ -76,15 +76,15 @@ Possible values are:
76
76
:package-version '(solidity . " 0.1.5" ))
77
77
78
78
(flycheck-def-option-var flycheck-solidity-solium-soliumrcfile nil solium-check
79
- " The path to use for soliumrc.json
79
+ " The path to use for soliumrc.json
80
80
81
81
The value of this variable is either a string denoting a path to the soliumrc.json
82
82
or nil, to use the current directory. When non-nil,
83
83
we pass the directory to solium via the `--config' option."
84
- :type '(choice (const :tag " No custom soliumrc" nil )
85
- (string :tag " Custom soliumrc file location" ))
86
- :safe #'stringp
87
- :package-version '(solidity-mode . " 0.1.4" ))
84
+ :type '(choice (const :tag " No custom soliumrc" nil )
85
+ (string :tag " Custom soliumrc file location" ))
86
+ :safe #'stringp
87
+ :package-version '(solidity-mode . " 0.1.4" ))
88
88
89
89
(when solidity-flycheck-solium-checker-active
90
90
; ; define solium flycheck syntax checker
@@ -126,28 +126,52 @@ we pass the directory to solium via the `--config' option."
126
126
(setq flycheck-solium-checker-executable solidity-solium-path))
127
127
(error (format " Solidity Mode Configuration error. Requested solium flycheck integration but can't find solium at: %s " solidity-solium-path)))))
128
128
129
+ (defun get-solc-version ()
130
+ " Query solc executable and return its version.
131
+
132
+ The result is returned in a list with 3 elements.MAJOR MINOR PATCH.
133
+
134
+ If the solc output can't be parsed an error is returned."
135
+ (let ((output (shell-command-to-string (format " %s --version" solidity-solc-path))))
136
+ (if (string-match " Version: \\ ([[:digit:]]+\\ )\. \\ ([[:digit:]]+\\ )\. \\ ([[:digit:]]+\\ )" output)
137
+ (list (match-string 1 output)
138
+ (match-string 2 output)
139
+ (match-string 3 output))
140
+ (error " Could not parse the output of %s --version:\n %s " solidity-solc-path output))))
141
+
142
+ (defun solc-gt-0 .6.0 ()
143
+ " Return `t` if solc >= 0.6.0 and `nil` otherwise."
144
+ (let* ((version (get-solc-version))
145
+ (major (string-to-number (nth 0 version)))
146
+ (minor (string-to-number (nth 1 version)))
147
+ (patch (string-to-number (nth 2 version))))
148
+ (if (and (>= major 0 ) (>= minor 6 )) t nil )))
149
+
129
150
(when solidity-flycheck-solc-checker-active
130
151
; ; add a solidity mode callback to set the executable of solc for flycheck
131
152
; ; define solidity's flycheck syntax checker
132
153
; ; expanded the flycheck-define-checker macro in order to eval certain args, as per advice given in gitter
133
154
; ; https://gitter.im/flycheck/flycheck?at=5a43b3a8232e79134d98872b
134
155
(flycheck-def-executable-var solidity-checker " solc" )
135
- (if (funcall flycheck-executable-find solidity-solc-path)
136
- (progn
137
- (flycheck-define-command-checker 'solidity-checker
138
- " A Solidity syntax checker using the solc compiler"
139
- :command '(" solc" source-inplace)
140
- :error-patterns '((error line-start (file-name) " :" line " :" column " :" " Error: " (message ))
141
- (error line-start " Error: " (message ))
142
- (warning line-start (file-name) " :" line " :" column " :" " Warning: " (message )))
143
- :modes 'solidity-mode
144
- :predicate #' (lambda nil (eq major-mode 'solidity-mode ))
145
- :next-checkers `((, solidity-flycheck-chaining-error-level . solium-checker))
146
- :standard-input 'nil
147
- :working-directory 'nil )
148
- (add-to-list 'flycheck-checkers 'solidity-checker )
149
- (setq flycheck-solidity-checker-executable solidity-solc-path))
150
- (error (format " Solidity Mode Configuration error. Requested solc flycheck integration but can't find solc at: %s " solidity-solc-path))))
156
+ (let* ((cmd (if (solc-gt-0.6.0) '(" solc" " --old-reporter" source-inplace) '(" solc" source-inplace))))
157
+ (if (funcall flycheck-executable-find solidity-solc-path)
158
+ (progn
159
+ (flycheck-define-command-checker 'solidity-checker
160
+ " A Solidity syntax checker using the solc compiler"
161
+ :command cmd
162
+ :error-patterns '(
163
+ (error line-start (file-name) " :" line " :" column " :" " Error: " (message ))
164
+ (error line-start (file-name) " :" line " :" column " :" " Compiler error: " (message ))
165
+ (error line-start " Error: " (message ))
166
+ (warning line-start (file-name) " :" line " :" column " :" " Warning: " (message )))
167
+ :modes 'solidity-mode
168
+ :predicate #' (lambda nil (eq major-mode 'solidity-mode ))
169
+ :next-checkers `((, solidity-flycheck-chaining-error-level . solium-checker))
170
+ :standard-input 'nil
171
+ :working-directory 'nil )
172
+ (add-to-list 'flycheck-checkers 'solidity-checker )
173
+ (setq flycheck-solidity-checker-executable solidity-solc-path))
174
+ (error (format " Solidity Mode Configuration error. Requested solc flycheck integration but can't find solc at: %s " solidity-solc-path)))))
151
175
152
176
(provide 'solidity-flycheck )
153
177
; ;; solidity-flycheck.el ends here
0 commit comments