Install dart-mode && dart-server

This commit is contained in:
Marcus Kammer 2020-04-14 10:57:40 +02:00
parent c37364d527
commit 561efc9e03
18 changed files with 14888 additions and 1 deletions

View file

@ -69,7 +69,7 @@
'(package-enable-at-startup t)
'(package-selected-packages
(quote
(projectile python-django ivy elpy olivetti ace-window graphviz-dot-mode dot-mode plantuml-mode elisp-format elisp-lint flymake-racket google-translate org-pomodoro elm-mode dashboard pickle poet-theme flymake-eslint json-mode darkroom dockerfile-mode ein spacemacs-theme flucui-themes leuven-theme htmlize scss-mode berrys-theme web-mode python-docstring sphinx-doc sphinx-frontend sphinx-mode ox-nikola racket-mode slime gherkin-mode powershell typescript-mode ob-http ob-ipython ob-restclient nord-theme restclient request restclient-test yaml-mode magit)))
(dart-mode dart-server projectile python-django ivy elpy olivetti ace-window graphviz-dot-mode dot-mode plantuml-mode elisp-format elisp-lint flymake-racket google-translate org-pomodoro elm-mode dashboard pickle poet-theme flymake-eslint json-mode darkroom dockerfile-mode ein spacemacs-theme flucui-themes leuven-theme htmlize scss-mode berrys-theme web-mode python-docstring sphinx-doc sphinx-frontend sphinx-mode ox-nikola racket-mode slime gherkin-mode powershell typescript-mode ob-http ob-ipython ob-restclient nord-theme restclient request restclient-test yaml-mode magit)))
'(python-shell-interpreter "python3")
'(register-preview-delay 2)
'(register-separator 43)

View file

@ -0,0 +1,34 @@
;;; dart-mode-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
(add-to-list 'load-path (directory-file-name
(or (file-name-directory #$) (car load-path))))
;;;### (autoloads nil "dart-mode" "dart-mode.el" (0 0 0 0))
;;; Generated autoloads from dart-mode.el
(add-to-list 'auto-mode-alist '("\\.dart\\'" . dart-mode))
(autoload 'dart-mode "dart-mode" "\
Major mode for editing Dart files.
The hook `dart-mode-hook' is run with no args at mode
initialization.
Key bindings:
\\{dart-mode-map}
\(fn)" t nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "dart-mode" '("dart-")))
;;;***
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; dart-mode-autoloads.el ends here

View file

@ -0,0 +1,2 @@
;;; -*- no-byte-compile: t -*-
(define-package "dart-mode" "20190827.2102" "Major mode for editing Dart files" '((emacs "24.3")) :commit "04fcd649f19d49390079fbf2920a10bf37f6a634" :keywords '("languages") :authors '(("Brady Trainor" . "mail@bradyt.net")) :maintainer '("Brady Trainor" . "mail@bradyt.net") :url "https://github.com/bradyt/dart-mode")

View file

@ -0,0 +1,625 @@
;;; dart-mode.el --- Major mode for editing Dart files -*- lexical-binding: t; -*-
;; Author: Brady Trainor <mail@bradyt.net>
;; URL: https://github.com/bradyt/dart-mode
;; Package-Version: 20190827.2102
;; Version: 1.0.4
;; Package-Requires: ((emacs "24.3"))
;; Keywords: languages
;;; Commentary:
;; Major mode for editing Dart files.
;; Provides basic syntax highlighting and indentation.
;;; Code:
;;; Configuration
(defvar dart-mode-map (make-sparse-keymap)
"Keymap used in dart-mode buffers.")
(define-key dart-mode-map (kbd "<backtab>") 'dart-dedent-simple)
(define-key dart-mode-map (kbd "C-c C-i") 'indent-according-to-mode)
;;; Indentation
(defcustom dart-indent-trigger-commands
'(indent-for-tab-command yas-expand yas/expand dart-dedent-simple)
"Commands that might trigger a `dart-indent-line' call."
:type '(repeat symbol)
:group 'dart)
(defun dart-indent-line-function ()
"`indent-line-function' for Dart mode.
When the variable `last-command' is equal to one of the symbols
inside `dart-indent-trigger-commands' it cycles possible
indentation levels from right to left."
(if (and (memq this-command dart-indent-trigger-commands)
(eq last-command this-command))
(dart-indent-simple)
(dart-indent-line-relative)))
(defun dart-indent-simple (&optional backwards)
(interactive)
(save-excursion
(indent-line-to
(max 0 (indent-next-tab-stop (current-indentation) backwards))))
(when (< (current-column) (current-indentation))
(back-to-indentation)))
(defun dart-dedent-simple ()
(interactive)
(dart-indent-simple 'backwards))
(defun dart-depth-of-line ()
(save-excursion
(back-to-indentation)
(let ((depth (car (syntax-ppss))))
(when (and (char-after)
(= (char-syntax (char-after)) ?\)))
(while (and (char-after)
(/= (char-syntax (char-after)) ?\()
(/= (char-after) ?\C-j))
(when (= (char-syntax (char-after)) ?\))
(setq depth (1- depth)))
(forward-char)))
depth)))
(defun dart-indent-line-relative ()
(let ((curr-depth (dart-depth-of-line))
prev-line
prev-depth
prev-indent)
(save-excursion
(beginning-of-line)
(catch 'done
(while t
(when (= (point) 1)
(throw 'done t))
(forward-line -1)
(unless (looking-at (rx (and bol (zero-or-more space) eol)))
(setq prev-line t)
(setq prev-indent (current-indentation))
(setq prev-depth (dart-depth-of-line))
(throw 'done t)))))
(save-excursion
(if prev-line
(indent-line-to (max 0 (+ prev-indent
(* (- curr-depth prev-depth)
tab-width))))
(indent-line-to 0)))
(when (< (current-column) (current-indentation))
(back-to-indentation))))
;;; Fontification
(defvar dart--file-directives
'("as" "deferred" "export" "hide" "import" "library" "of" "part"
"show"))
(defvar dart--builtins
;; ECMA 408; Section: Identifier Reference
;; "Built-in identifiers"
'("abstract" "as" "covariant" "deferred" "dynamic" "export"
"external" "factory" "Function" "get" "implements" "import"
"interface" "library" "mixin" "operator" "part" "set" "static"
"typedef"))
(defvar dart--keywords
;; ECMA 408; Section: Reserved Words
'("assert" "break" "case" "catch" "class" "const" "continue"
"default" "do" "else" "enum" "extends" "final" "finally" "for"
"if" "in" "is" "new" "rethrow" "return" "super" "switch" "this"
"throw" "try" "var" "while" "with"))
(defvar dart--types '("bool" "double" "int" "num" "void"))
(defvar dart--constants '("false" "null" "true"))
(defvar dart--async-keywords-re (rx word-start
(or "async" "await" "sync" "yield")
word-end
(zero-or-one ?*)))
(defvar dart--number-re (rx symbol-start
(zero-or-one ?-)
(group (or (and (one-or-more digit)
(zero-or-one
(and ?. (one-or-more digit))))
(and ?. (one-or-more digit)))
(zero-or-one (and (or ?e ?E)
(zero-or-one (or ?+ ?-))
(one-or-more digit))))))
(defvar dart--hex-number-re (rx symbol-start
(zero-or-one ?-)
(group (or "0x" "0X")
(one-or-more (any (?a . ?f)
(?A . ?F)
digit)))))
(defvar dart--operator-declaration-re (rx "operator"
(one-or-more space)
(group
(one-or-more (not (any ?\())))))
(eval-and-compile (defun dart--identifier (&optional case)
`(and (or word-start symbol-start)
(zero-or-more (any ?$ ?_))
,(if case
case
'alpha)
(zero-or-more (or ?$ ?_ alnum)))))
(defvar dart--metadata-re (rx ?@ (eval (dart--identifier))))
(defvar dart--types-re (rx (eval (dart--identifier 'upper))))
(defvar dart--constants-re (rx (and word-start
upper
(>= 2 (or upper ?_))
word-end)))
(defun dart--string-interpolation-id-func (limit)
"Font-lock matcher for string interpolation identifiers.
These have the form $variableName.
Can fontify entire match with group 0, or using group 1 for sigil,
group 2 for variableName."
(catch 'result
(let (data end syntax)
(while (re-search-forward (rx (group ?$)
(group (zero-or-more ?_)
lower
(zero-or-more (or ?_ alnum))))
limit t)
(setq data (match-data))
(setq end (match-end 2))
(setq syntax (syntax-ppss))
;; Check that we are in a string and not in a raw string
(when (and (nth 3 syntax)
(or (= (nth 8 syntax) 1)
(not (eq (char-before (nth 8 syntax)) ?r))))
(set-match-data data)
(goto-char end)
(throw 'result t))
(when end
(goto-char end)))
(throw 'result nil))))
(defun dart--string-interpolation-exp-func (limit)
"Font-lock matcher for string interpolation expressions.
These have the form ${expression}.
Can fontify entire match with group 0, or using group 1 for sigil,
groups 2 and 4 for curly brackets, and 3 for contents."
(catch 'result
(let (sigil beg open close end depth)
;; Loop and put point after ${
(while (and (search-forward "${" limit t)
;; Check that we are in a string and not in a raw string
(save-excursion
(and (nth 3 (syntax-ppss))
(not (eq (char-before (nth 8 (syntax-ppss))) ?r)))))
;; "a string with ${someInterpolation + aValue} inside of it."
;; ^^^ ^^
;; ||| ||
;; sigil -+|+- open close -++- end
;; +- beg
(setq open (point))
(setq beg (- open 1))
(setq sigil (- open 2))
(setq depth 1)
;; Move forward until limit, while depth is positive and we
;; are inside string.
(while (and (> depth 0)
(< (point) limit)
(nth 3 (syntax-ppss)))
(setq depth (+ depth (pcase (char-after)
(?\{ 1)
(?\} -1)
(_ 0))))
(forward-char))
(setq end (point))
;; If depth is zero, we have found a closing } within string
;; and before limit. Set `match-data', `point', and return `t'.
(when (= depth 0)
(setq close (1- end))
(set-match-data (list sigil end
sigil beg
beg open
open close
close end))
(goto-char end)
(throw 'result t))
;; If the candidate did not meet criteria, put point at end
;; and search again.
(goto-char end))
;; When there are no more candidate "${", return nil.
(throw 'result nil))))
(defun dart--function-declaration-func (limit)
"Font-lock matcher function for function declarations.
Matches function declarations before LIMIT that look like,
\"lowercaseIdentifier([...]) [[a]sync[*], {, =>]\"
For example, \"main\" in \"void main() async\" would be matched."
(catch 'result
(let (beg end)
(while (re-search-forward
(rx (group (eval (dart--identifier 'lower))) ?\() limit t)
(setq beg (match-beginning 1))
(setq end (match-end 1))
(condition-case nil
(progn
(up-list)
(when (looking-at (rx (one-or-more space)
(or "async" "async*" "sync*" "{" "=>")))
(set-match-data (list beg end))
(goto-char end)
(throw 'result t)))
(scan-error nil))
(goto-char end))
(throw 'result nil))))
(defun dart--abstract-method-func (limit)
"Font-lock matcher function for abstract methods.
Matches function declarations before LIMIT that look like,
\" [^ ][^=]* lowercaseIdentifier([...]);\"
For example, \"compareTo\" in \" int compareTo(num other);\" would be
matched."
(catch 'result
(let (beg end)
(while (re-search-forward
(rx (and (not (any ?\.)) (group (eval (dart--identifier 'lower)))) ?\() limit t)
(setq beg (match-beginning 1))
(setq end (match-end 1))
(condition-case nil
(progn
(up-list)
(when (and (< (point) (point-max))
(= (char-after (point)) ?\;))
(goto-char beg)
(back-to-indentation)
(when (and (= (current-column) 2)
(not (looking-at "return"))
(string-match-p
" " (buffer-substring-no-properties
(point) beg))
(not (string-match-p
"=" (buffer-substring-no-properties
(point) beg))))
(goto-char end)
(set-match-data (list beg end))
(throw 'result t))))
(scan-error nil))
(goto-char end)))
(throw 'result nil)))
(defun dart--declared-identifier-func (limit)
"Font-lock matcher function for declared identifiers.
Matches declared identifiers before LIMIT that look like,
\"finalConstVarOrType lowercaseIdentifier\"
For example, \"height\" in \"const int height\" would be matched."
(catch 'result
(let (beg end)
(while (re-search-forward
(rx
(and (group (or (or "const" "final"
"bool" "double" "dynamic" "int" "num" "void"
"var"
"get" "set")
(eval (dart--identifier 'upper)))
(zero-or-more ?>))
(one-or-more (or space ?\C-j))
(group (eval (dart--identifier 'lower)))
(not (any ?\( alnum ?$ ?_))))
limit t)
(setq beg (match-beginning 2))
(setq end (match-end 2))
;; Check for false positives
(when (not (member (match-string 2)
'("bool" "double" "dynamic" "int" "num" "void"
"var"
"get" "set")))
(goto-char end)
(unless (nth 3 (syntax-ppss))
(set-match-data (list beg end))
(throw 'result t)))
(goto-char (match-end 1)))
(throw 'result nil))))
(defun dart--in-parenthesized-expression-or-formal-parameter-list-p ()
"Returns `t' if `point' is in parentheses, otherwise `nil'.
In particular, parenthesized expressions or formal parameter lists."
(save-excursion
(catch 'result
;; Attempt to jump out of parentheses.
(condition-case nil
(backward-up-list)
(scan-error (throw 'result nil)))
;; If we've only jumped out of optional or named section of
;; formal parameters, try to jump again.
(when (member (char-after (point)) '(?\[ ?\{))
(condition-case nil
(backward-up-list)
(scan-error (throw 'result nil))))
(throw 'result (= (char-after (point)) ?\()))))
(defun dart--declared-identifier-anchor-func (limit)
"Font-lock matcher for declared identifier.
Uses `dart--declared-identifier-func' to find candidates before
LIMIT, and checks that they are not in parentheses.
This matcher is an anchor to match multiple identifiers in a
single variable declaration. From ECMA-408,
variableDeclaration:
declaredIdentifier (', ' identifier)*
;
After this function sets anchor, font-lock will use the function
`dart--declared-identifier-next-func' to find subsequent
identifiers."
(catch 'result
(let (data)
(while (dart--declared-identifier-func limit)
(setq data (match-data))
(unless (dart--in-parenthesized-expression-or-formal-parameter-list-p)
(set-match-data data)
(goto-char (match-end 0))
(throw 'result t))
(goto-char (match-end 0)))
(throw 'result nil))))
(defun dart--declared-identifier-next-func (limit)
"Font-lock matcher for subsequent identifiers.
For use after `dart--declared-identifier-anchor-func' sets
anchor, this function will look for subsequent identifers to
fontify as declared variables. From ECMA-408,
variableDeclaration:
declaredIdentifier (', ' identifier)*
;"
(catch 'result
(let ((depth (car (syntax-ppss))))
(while t
(cond
;; If point is followed by semi-colon, we are done.
((or (> (point) limit)
(= (char-after (point)) ?\;)
(< (car (syntax-ppss)) depth))
(throw 'result nil))
;; If point is followed by comma, and we are still at same
;; depth, then attempt to match another identifier, otherwise
;; return nil.
((and (= (char-after (point)) ?\x2c) ; ?,
(= (car (syntax-ppss)) depth))
(if (looking-at (rx ?\x2c
(one-or-more space)
(group (eval (dart--identifier 'lower)))))
(progn (set-match-data (list (match-beginning 1)
(match-end 1)))
(goto-char (match-end 0))
(throw 'result t))
(throw 'result nil)))
;; Otherwise, if we are still before `point-max' (shouldn't
;; this be `limit'? May be a bad attempt to deal with
;; multiline searches. Should research how this is done with
;; font-lock.), move forward.
((< (point) (point-max))
(forward-char))
;; Otherwise, return nil.
(t (throw 'result nil)))))))
(defun dart--anonymous-function-matcher (limit)
"Font-lock matcher for start of anonymous functions.
Looks for opening parenthesis, tries to jump to opening
parenthesis, ensure it is not preceded by for, while, etc. Then
tries to jump to closing parenthesis and check if followed by \"
{\" or \" =>\".
Used with `dart--untyped-parameter-anchored-matcher' to fontify
untyped parameters. For example, in
(untypedParameter) => untypedParameter.length"
(catch 'result
(let (beg end)
(while (search-forward "(" limit t)
(setq beg (match-beginning 0))
(setq end (match-end 0))
(unless (looking-back (rx (or (and (or "do" "for" "if" "switch" "while")
space)
"super")
?\()
(point-at-bol))
(condition-case nil
(up-list)
(scan-error (throw 'result nil)))
(when (looking-at (rx space (or ?\{ "=>")))
(set-match-data (list beg end))
(goto-char end)
(throw 'result t))
(goto-char end)))
(throw 'result nil))))
(defun dart--untyped-parameter-anchored-matcher (limit)
"Font-lock anchored-matcher for untyped parameters.
Searches forward for for lowercase idenitifer and ensures depth
is still same.
Used with `dart--anonymous-function-matcher' to fontify
untyped parameters. For example, in
(untypedParameter) => untypedParameter.length"
(let (beg end)
(catch 'result
(if (equal (char-after) ?\))
(throw 'result nil))
(let ((depth (car (syntax-ppss))))
(while (re-search-forward
(rx (and (group (or (one-or-more (char ?_))
(eval (dart--identifier 'lower))))
(or ?, ?\)))))
(setq beg (match-beginning 1))
(setq end (match-end 1))
(goto-char end)
(if (or (> (point) limit)
(< (car (syntax-ppss)) depth))
(throw 'result nil)
(set-match-data (list beg end))
(throw 'result t))))
(throw 'result nil))))
(defun dart--get-point-at-end-of-list ()
(let (pt)
(save-excursion
(up-list)
(setq pt (point)))
pt))
(defvar dart-font-lock-defaults
'((dart-font-lock-keywords-1 dart-font-lock-keywords-1
dart-font-lock-keywords-2
dart-font-lock-keywords-3)))
(defvar dart-font-lock-keywords-1
`((,(regexp-opt dart--file-directives 'words) . font-lock-builtin-face)
(dart--function-declaration-func . font-lock-function-name-face)
(,dart--operator-declaration-re . (1 font-lock-function-name-face))
(dart--abstract-method-func . font-lock-function-name-face)))
(defvar dart-font-lock-keywords-2
`(,dart--async-keywords-re
,(regexp-opt dart--keywords 'words)
(,(regexp-opt dart--builtins 'words) . font-lock-builtin-face)
(,(regexp-opt dart--constants 'words) . font-lock-constant-face)
(,dart--hex-number-re . (1 font-lock-constant-face))
(,dart--number-re . (1 font-lock-constant-face))
(,dart--metadata-re . font-lock-constant-face)
(,dart--constants-re . font-lock-constant-face)
(,(regexp-opt dart--types 'words) . font-lock-type-face)
(,dart--types-re . font-lock-type-face)
(dart--function-declaration-func . font-lock-function-name-face)
(,dart--operator-declaration-re . (1 font-lock-function-name-face))
(dart--abstract-method-func . font-lock-function-name-face)))
(defvar dart-font-lock-keywords-3
(append
dart-font-lock-keywords-2
`((dart--declared-identifier-func . font-lock-variable-name-face)
(dart--declared-identifier-anchor-func
. (dart--declared-identifier-next-func
nil
nil
(0 font-lock-variable-name-face)))
(dart--anonymous-function-matcher
. (dart--untyped-parameter-anchored-matcher
(dart--get-point-at-end-of-list)
nil
(0 font-lock-variable-name-face)))
(dart--string-interpolation-id-func (0 font-lock-variable-name-face t))
(dart--string-interpolation-exp-func (0 font-lock-variable-name-face t)))))
(defun dart-syntax-propertize-function (beg end)
"Sets syntax-table text properties for raw and/or multiline strings.
We use fences uniformly for consistency.
In raw strings, we modify backslash characters to have punctuation
syntax rather than escape syntax.
String interpolation is not handled correctly yet, but the fixes to
quote characters in multiline strings, and escape characters in raw
strings, ensures that code outside of strings is not highlighted as
strings."
(goto-char beg)
;; We rely on syntax-propertize-extend-region-functions that `beg`
;; will be at beginning of line, but we ensure here that we are not
;; in a string
(while (nth 3 (syntax-ppss))
(goto-char (nth 8 (syntax-ppss)))
(beginning-of-line))
;; Search for string opening
(while (re-search-forward (rx (group (optional ?r))
(group (or (repeat 3 ?\")
(repeat 3 ?\')
?\"
?\')))
end t)
(let ((bos (match-beginning 2))
(rawp (equal (match-string-no-properties 1) "r"))
(string-delimiter (match-string-no-properties 2)))
;; Set string fence syntax at beginning of string
(put-text-property bos (1+ bos) 'syntax-table (string-to-syntax "|") nil)
;; Look for the end of string delimiter, depending on rawp and
;; string-delimiter
;; Unless rawp, ensure an even number of backslashes
(when (or (looking-at (concat (unless rawp (rx (zero-or-more ?\\ ?\\)))
string-delimiter))
(re-search-forward (concat (unless rawp (rx (not (any ?\\)) (zero-or-more ?\\ ?\\)))
string-delimiter)
end t))
(let ((eos (match-end 0)))
;; Set end of string fence delimiter
(put-text-property (1- eos) eos 'syntax-table (string-to-syntax "|") nil)
;; For all strings, remove fence property between fences
;; For raw strings, set all backslashes to punctuation syntax
(dolist (pt (number-sequence (1+ bos) (- eos 2)))
(when (equal (get-text-property pt 'syntax-table) (string-to-syntax "|"))
(remove-text-properties pt (1+ pt) 'syntax-table))
(when (and rawp (equal (char-after pt) ?\\))
(put-text-property pt (1+ pt) 'syntax-table (string-to-syntax ".") nil)))
(goto-char eos))))))
;;; Initialization
;;;###autoload (add-to-list 'auto-mode-alist '("\\.dart\\'" . dart-mode))
;;;###autoload
(define-derived-mode dart-mode prog-mode "Dart"
"Major mode for editing Dart files.
The hook `dart-mode-hook' is run with no args at mode
initialization.
Key bindings:
\\{dart-mode-map}"
(modify-syntax-entry ?/ "_ 124b")
(modify-syntax-entry ?* ". 23")
(modify-syntax-entry ?\n "> b")
(modify-syntax-entry ?\' "\"")
(modify-syntax-entry ?\> ".")
(modify-syntax-entry ?\< ".")
(setq-local electric-indent-chars '(?\n ?\) ?\] ?\}))
(setq-local comment-start "//")
(setq-local comment-end "")
(setq fill-column 80)
(setq font-lock-defaults dart-font-lock-defaults)
(setq-local indent-line-function 'dart-indent-line-function)
(setq indent-tabs-mode nil)
(setq tab-width 2)
(setq-local syntax-propertize-function 'dart-syntax-propertize-function))
(provide 'dart-mode)
;;; dart-mode.el ends here

Binary file not shown.

View file

@ -0,0 +1,3 @@
Major mode for editing Dart files.
Provides basic syntax highlighting and indentation.

View file

@ -0,0 +1,31 @@
;;; dart-server-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
(add-to-list 'load-path (directory-file-name
(or (file-name-directory #$) (car load-path))))
;;;### (autoloads nil "dart-server" "dart-server.el" (0 0 0 0))
;;; Generated autoloads from dart-server.el
(autoload 'dart-server "dart-server" "\
Toggle Dart-Server mode on or off.
With a prefix argument ARG, enable Dart-Server mode if ARG is
positive, and disable it otherwise. If called from Lisp, enable
the mode if ARG is omitted or nil, and toggle it if ARG is `toggle'.
\\{dart-server-map}
\(fn &optional ARG)" t nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "dart-server" '("dart-server-")))
;;;***
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; dart-server-autoloads.el ends here

View file

@ -0,0 +1,2 @@
;;; -*- no-byte-compile: t -*-
(define-package "dart-server" "20190817.1254" "Minor mode for editing Dart files" '((emacs "24.5") (cl-lib "0.5") (dash "2.10.0") (flycheck "0.23") (s "1.10")) :commit "aba838e8ee2f30309f366e8a91c17616549003ce" :keywords '("languages") :authors '(("Natalie Weizenbaum") ("Brady Trainor" . "mail@bradyt.com")) :maintainer '("Brady Trainor" . "mail@bradyt.com") :url "https://github.com/bradyt/dart-server")

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -0,0 +1,4 @@
Minor mode for editing Dart files.
Provides dart server features, such as formatting, analysis,
flycheck, etc.

View file

@ -0,0 +1,273 @@
;;; flycheck-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
(add-to-list 'load-path (directory-file-name
(or (file-name-directory #$) (car load-path))))
;;;### (autoloads nil "flycheck" "flycheck.el" (0 0 0 0))
;;; Generated autoloads from flycheck.el
(autoload 'flycheck-manual "flycheck" "\
Open the Flycheck manual.
\(fn)" t nil)
(autoload 'flycheck-mode "flycheck" "\
Minor mode for on-the-fly syntax checking.
When called interactively, toggle `flycheck-mode'. With prefix
ARG, enable `flycheck-mode' if ARG is positive, otherwise disable
it.
When called from Lisp, enable `flycheck-mode' if ARG is omitted,
nil or positive. If ARG is `toggle', toggle `flycheck-mode'.
Otherwise behave as if called interactively.
In `flycheck-mode' the buffer is automatically syntax-checked
using the first suitable syntax checker from `flycheck-checkers'.
Use `flycheck-select-checker' to select a checker for the current
buffer manually.
\\{flycheck-mode-map}
\(fn &optional ARG)" t nil)
(defvar global-flycheck-mode nil "\
Non-nil if Global Flycheck mode is enabled.
See the `global-flycheck-mode' command
for a description of this minor mode.
Setting this variable directly does not take effect;
either customize it (see the info node `Easy Customization')
or call the function `global-flycheck-mode'.")
(custom-autoload 'global-flycheck-mode "flycheck" nil)
(autoload 'global-flycheck-mode "flycheck" "\
Toggle Flycheck mode in all buffers.
With prefix ARG, enable Global Flycheck mode if ARG is positive;
otherwise, disable it. If called from Lisp, enable the mode if
ARG is omitted or nil.
Flycheck mode is enabled in all buffers where
`flycheck-mode-on-safe' would do it.
See `flycheck-mode' for more information on Flycheck mode.
\(fn &optional ARG)" t nil)
(autoload 'flycheck-define-error-level "flycheck" "\
Define a new error LEVEL with PROPERTIES.
The following PROPERTIES constitute an error level:
`:severity SEVERITY'
A number denoting the severity of this level. The higher
the number, the more severe is this level compared to other
levels. Defaults to 0.
The severity is used by `flycheck-error-level-<' to
determine the ordering of errors according to their levels.
`:compilation-level LEVEL'
A number indicating the broad class of messages that errors
at this level belong to: one of 0 (info), 1 (warning), or
2 or nil (error). Defaults to nil.
This is used by `flycheck-checker-pattern-to-error-regexp'
to map error levels into `compilation-mode''s hierarchy and
to get proper highlighting of errors in `compilation-mode'.
`:overlay-category CATEGORY'
A symbol denoting the overlay category to use for error
highlight overlays for this level. See Info
node `(elisp)Overlay Properties' for more information about
overlay categories.
A category for an error level overlay should at least define
the `face' property, for error highlighting. Another useful
property for error level categories is `priority', to
influence the stacking of multiple error level overlays.
`:fringe-bitmap BITMAP'
A fringe bitmap symbol denoting the bitmap to use for fringe
indicators for this level. See Info node `(elisp)Fringe
Bitmaps' for more information about fringe bitmaps,
including a list of built-in fringe bitmaps.
`:fringe-face FACE'
A face symbol denoting the face to use for fringe indicators
for this level.
`:error-list-face FACE'
A face symbol denoting the face to use for messages of this
level in the error list. See `flycheck-list-errors'.
\(fn LEVEL &rest PROPERTIES)" nil nil)
(function-put 'flycheck-define-error-level 'lisp-indent-function '1)
(autoload 'flycheck-define-command-checker "flycheck" "\
Define SYMBOL as syntax checker to run a command.
Define SYMBOL as generic syntax checker via
`flycheck-define-generic-checker', which uses an external command
to check the buffer. SYMBOL and DOCSTRING are the same as for
`flycheck-define-generic-checker'.
In addition to the properties understood by
`flycheck-define-generic-checker', the following PROPERTIES
constitute a command syntax checker. Unless otherwise noted, all
properties are mandatory. Note that the default `:error-filter'
of command checkers is `flycheck-sanitize-errors'.
`:command COMMAND'
The command to run for syntax checking.
COMMAND is a list of the form `(EXECUTABLE [ARG ...])'.
EXECUTABLE is a string with the executable of this syntax
checker. It can be overridden with the variable
`flycheck-SYMBOL-executable'. Note that this variable is
NOT implicitly defined by this function. Use
`flycheck-def-executable-var' to define this variable.
Each ARG is an argument to the executable, either as string,
or as special symbol or form for
`flycheck-substitute-argument', which see.
`:error-patterns PATTERNS'
A list of patterns to parse the output of the `:command'.
Each ITEM in PATTERNS is a list `(LEVEL SEXP ...)', where
LEVEL is a Flycheck error level (see
`flycheck-define-error-level'), followed by one or more RX
`SEXP's which parse an error of that level and extract line,
column, file name and the message.
See `rx' for general information about RX, and
`flycheck-rx-to-string' for some special RX forms provided
by Flycheck.
All patterns are applied in the order of declaration to the
whole output of the syntax checker. Output already matched
by a pattern will not be matched by subsequent patterns. In
other words, the first pattern wins.
This property is optional. If omitted, however, an
`:error-parser' is mandatory.
`:error-parser FUNCTION'
A function to parse errors with.
The function shall accept three arguments OUTPUT CHECKER
BUFFER. OUTPUT is the syntax checker output as string,
CHECKER the syntax checker that was used, and BUFFER a
buffer object representing the checked buffer. The function
must return a list of `flycheck-error' objects parsed from
OUTPUT.
This property is optional. If omitted, it defaults to
`flycheck-parse-with-patterns'. In this case,
`:error-patterns' is mandatory.
`:standard-input t'
Whether to send the buffer contents on standard input.
If this property is given and has a non-nil value, send the
contents of the buffer on standard input.
Defaults to nil.
Note that you may not give `:start', `:interrupt', and
`:print-doc' for a command checker. You can give a custom
`:verify' function, though, whose results will be appended to the
default `:verify' function of command checkers.
\(fn SYMBOL DOCSTRING &rest PROPERTIES)" nil nil)
(function-put 'flycheck-define-command-checker 'lisp-indent-function '1)
(function-put 'flycheck-define-command-checker 'doc-string-elt '2)
(autoload 'flycheck-def-config-file-var "flycheck" "\
Define SYMBOL as config file variable for CHECKER, with default FILE-NAME.
SYMBOL is declared as customizable variable using `defcustom', to
provide configuration files for the given syntax CHECKER.
CUSTOM-ARGS are forwarded to `defcustom'.
FILE-NAME is the initial value of the new variable. If omitted,
the default value is nil. It can be either a string or a list of
strings.
Use this together with the `config-file' form in the `:command'
argument to `flycheck-define-checker'.
\(fn SYMBOL CHECKER &optional FILE-NAME &rest CUSTOM-ARGS)" nil t)
(function-put 'flycheck-def-config-file-var 'lisp-indent-function '3)
(autoload 'flycheck-def-option-var "flycheck" "\
Define SYMBOL as option variable with INIT-VALUE for CHECKER.
SYMBOL is declared as customizable variable using `defcustom', to
provide an option for the given syntax CHECKERS (a checker or a
list of checkers). INIT-VALUE is the initial value of the
variable, and DOCSTRING is its docstring. CUSTOM-ARGS are
forwarded to `defcustom'.
Use this together with the `option', `option-list' and
`option-flag' forms in the `:command' argument to
`flycheck-define-checker'.
\(fn SYMBOL INIT-VALUE CHECKERS DOCSTRING &rest CUSTOM-ARGS)" nil t)
(function-put 'flycheck-def-option-var 'lisp-indent-function '3)
(function-put 'flycheck-def-option-var 'doc-string-elt '4)
(autoload 'flycheck-define-checker "flycheck" "\
Define SYMBOL as command syntax checker with DOCSTRING and PROPERTIES.
Like `flycheck-define-command-checker', but PROPERTIES must not
be quoted. Also, implicitly define the executable variable for
SYMBOL with `flycheck-def-executable-var'.
\(fn SYMBOL DOCSTRING &rest PROPERTIES)" nil t)
(function-put 'flycheck-define-checker 'lisp-indent-function '1)
(function-put 'flycheck-define-checker 'doc-string-elt '2)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "flycheck" '("flycheck-" "list-flycheck-errors" "help-flycheck-checker-d")))
;;;***
;;;### (autoloads nil "flycheck-buttercup" "flycheck-buttercup.el"
;;;;;; (0 0 0 0))
;;; Generated autoloads from flycheck-buttercup.el
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "flycheck-buttercup" '("flycheck-buttercup-format-error-list")))
;;;***
;;;### (autoloads nil "flycheck-ert" "flycheck-ert.el" (0 0 0 0))
;;; Generated autoloads from flycheck-ert.el
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "flycheck-ert" '("flycheck-er")))
;;;***
;;;### (autoloads nil nil ("flycheck-pkg.el") (0 0 0 0))
;;;***
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; flycheck-autoloads.el ends here

View file

@ -0,0 +1,157 @@
;;; flycheck-buttercup.el --- Flycheck: Extensions to Buttercup -*- lexical-binding: t; -*-
;; Copyright (C) 2017 Flycheck contributors
;; Copyright (C) 2016 Sebastian Wiesner and Flycheck contributors
;; Author: Sebastian Wiesner <swiesner@lunaryorn.com>
;; Maintainer: Clément Pit-Claudel <clement.pitclaudel@live.com>
;; fmdkdd <fmdkdd@gmail.com>
;; Keywords: lisp, tools
;; This file is not part of GNU Emacs.
;; 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
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Extensions to Buttercup to write BDD tests for Flycheck.
;;
;; Buttercup is a BDD testing framework for Emacs, see URL
;; `https://github.com/jorgenschaefer/emacs-buttercup/'. Flycheck uses
;; Buttercup extensively for new tests.
;;
;; This library provides extensions to Buttercup to write Specs for Flycheck.
;;
;; * Custom matchers
;;
;; (expect 'foo :to-be-local) - Is `foo' a local variable in the current buffer?
;;; Code:
(require 'buttercup)
(require 'flycheck)
(require 'seq)
;;; Buttercup helpers
(defun flycheck-buttercup-format-error-list (errors)
"Format ERRORS into a human-readable string."
(mapconcat (lambda (e) (flycheck-error-format e 'with-file-name))
errors "\n"))
;;; Data matchers
(buttercup-define-matcher :to-be-empty-string (s)
(let ((s (funcall s)))
(if (equal s "")
(cons t (format "Expected %S not be an empty string" s))
(cons nil (format "Expected %S to be an empty string" s)))))
(buttercup-define-matcher :to-match-with-group (re s index match)
(let* ((re (funcall re))
(s (funcall s))
(index (funcall index))
(match (funcall match))
(matches? (string-match re s))
(result (and matches? (match-string index s))))
(if (and matches? (equal result match))
(cons t (format "Expected %S not to match %S with %S in group %s"
re s match index))
(cons nil (format "Expected %S to match %S with %S in group %s, %s"
re s match index
(if matches?
(format "but got %S" result)
"but did not match"))))))
;;; Emacs feature matchers
(buttercup-define-matcher :to-be-live (buffer)
(let ((buffer (get-buffer (funcall buffer))))
(if (buffer-live-p buffer)
(cons t (format "Expected %S not to be a live buffer, but it is"
buffer))
(cons nil (format "Expected %S to be a live buffer, but it is not"
buffer)))))
(buttercup-define-matcher :to-be-visible (buffer)
(let ((buffer (get-buffer (funcall buffer))))
(cond
((and buffer (get-buffer-window buffer))
(cons t (format "Expected %S not to be a visible buffer, but it is"
buffer)))
((not (bufferp buffer))
(cons nil
(format "Expected %S to be a visible buffer, but it is not a buffer"
buffer)))
(t (cons
nil
(format "Expected %S to be a visible buffer, but it is not visible"
buffer))))))
(buttercup-define-matcher :to-be-local (symbol)
(let ((symbol (funcall symbol)))
(if (local-variable-p symbol)
(cons t (format "Expected %S not to be a local variable, but it is"
symbol))
(cons nil (format "Expected %S to be a local variable, but it is not"
symbol)))))
(buttercup-define-matcher :to-contain-match (buffer re)
(let ((buffer (funcall buffer))
(re (funcall re)))
(if (not (get-buffer buffer))
(cons nil (format "Expected %S to contain a match of %s, \
but is not a buffer" buffer re))
(with-current-buffer buffer
(save-excursion
(goto-char (point-min))
(if (re-search-forward re nil 'noerror)
(cons t (format "Expected %S to contain a match \
for %s, but it did not" buffer re))
(cons nil (format "Expected %S not to contain a match for \
%s but it did not." buffer re))))))))
;;; Flycheck matchers
(buttercup-define-matcher :to-be-equal-flycheck-errors (a b)
(let* ((a (funcall a))
(b (funcall b))
(a-formatted (flycheck-buttercup-format-error-list a))
(b-formatted (flycheck-buttercup-format-error-list b)))
(if (equal a b)
(cons t (format "Expected
%s
not to be equal to
%s" a-formatted b-formatted))
(cons nil (format "Expected
%s
to be equal to
%s" a-formatted b-formatted)))))
(provide 'flycheck-buttercup)
;; Disable byte compilation for this library, to prevent package.el choking on a
;; missing `buttercup' library. See
;; https://github.com/flycheck/flycheck/issues/860
;; Local Variables:
;; no-byte-compile: t
;; End:
;;; flycheck-buttercup.el ends here

View file

@ -0,0 +1,495 @@
;;; flycheck-ert.el --- Flycheck: ERT extensions -*- lexical-binding: t; -*-
;; Copyright (C) 2017-2018 Flycheck contributors
;; Copyright (C) 2013-2016 Sebastian Wiesner and Flycheck contributors
;; Author: Sebastian Wiesner <swiesner@lunaryorn.com>
;; Maintainer: Clément Pit-Claudel <clement.pitclaudel@live.com>
;; fmdkdd <fmdkdd@gmail.com>
;; URL: https://github.com/flycheck/flycheck
;; This file is not part of GNU Emacs.
;; 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
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Unit testing library for Flycheck, the modern on-the-fly syntax checking
;; extension for GNU Emacs.
;; Provide various utility functions and unit test helpers to test Flycheck and
;; Flycheck extensions.
;;; Code:
(require 'flycheck)
(require 'ert)
(require 'macroexp) ; For macro utilities
;;; Compatibility
(eval-and-compile
;; Provide `ert-skip' and friends for Emacs 24.3
(defconst flycheck-ert-ert-can-skip (fboundp 'ert-skip)
"Whether ERT supports test skipping.")
(unless (fboundp 'define-error)
;; from Emacs `subr.el'
(defun define-error (name message &optional parent)
"Define NAME as a new error signal.
MESSAGE is a string that will be output to the echo area if such an error
is signaled without being caught by a `condition-case'.
PARENT is either a signal or a list of signals from which it inherits.
Defaults to `error'."
(unless parent (setq parent 'error))
(let ((conditions
(if (consp parent)
(apply #'append
(mapcar
(lambda (parent)
(cons parent
(or (get parent 'error-conditions)
(error "Unknown signal `%s'" parent))))
parent))
(cons parent (get parent 'error-conditions)))))
(put name 'error-conditions
(delete-dups (copy-sequence (cons name conditions))))
(when message (put name 'error-message message)))))
(unless flycheck-ert-ert-can-skip
;; Fake skipping
(define-error 'flycheck-ert-skipped "Test skipped")
(defun ert-skip (data)
(signal 'flycheck-ert-skipped data))
(defmacro skip-unless (form)
`(unless (ignore-errors ,form)
(signal 'flycheck-ert-skipped ',form)))
(defun ert-test-skipped-p (result)
(and (ert-test-failed-p result)
(eq (car (ert-test-failed-condition result))
'flycheck-ert-skipped)))))
;;; Internal variables
(defvar flycheck-ert--resource-directory nil
"The directory to get resources from in this test suite.")
;;; Resource management macros
(defmacro flycheck-ert-with-temp-buffer (&rest body)
"Eval BODY within a temporary buffer.
Like `with-temp-buffer', but resets the modification state of the
temporary buffer to make sure that it is properly killed even if
it has a backing file and is modified."
(declare (indent 0) (debug t))
`(with-temp-buffer
(unwind-protect
,(macroexp-progn body)
;; Reset modification state of the buffer, and unlink it from its backing
;; file, if any, because Emacs refuses to kill modified buffers with
;; backing files, even if they are temporary.
(set-buffer-modified-p nil)
(set-visited-file-name nil 'no-query))))
(defmacro flycheck-ert-with-file-buffer (file-name &rest body)
"Create a buffer from FILE-NAME and eval BODY.
BODY is evaluated with `current-buffer' being a buffer with the
contents FILE-NAME."
(declare (indent 1) (debug t))
`(let ((file-name ,file-name))
(unless (file-exists-p file-name)
(error "%s does not exist" file-name))
(flycheck-ert-with-temp-buffer
(insert-file-contents file-name 'visit)
(set-visited-file-name file-name 'no-query)
(cd (file-name-directory file-name))
;; Mark the buffer as not modified, because we just loaded the file up to
;; now.
(set-buffer-modified-p nil)
,@body)))
(defmacro flycheck-ert-with-help-buffer (&rest body)
"Execute BODY and kill the help buffer afterwards.
Use this macro to test functions that create a Help buffer."
(declare (indent 0))
`(unwind-protect
,(macroexp-progn body)
(when (buffer-live-p (get-buffer (help-buffer)))
(kill-buffer (help-buffer)))))
(defmacro flycheck-ert-with-global-mode (&rest body)
"Execute BODY with Global Flycheck Mode enabled.
After BODY, restore the old state of Global Flycheck Mode."
(declare (indent 0))
`(let ((old-state global-flycheck-mode))
(unwind-protect
(progn
(global-flycheck-mode 1)
,@body)
(global-flycheck-mode (if old-state 1 -1)))))
(defmacro flycheck-ert-with-env (env &rest body)
"Add ENV to `process-environment' in BODY.
Execute BODY with a `process-environment' which contains all
variables from ENV added.
ENV is an alist, where each cons cell `(VAR . VALUE)' is a
environment variable VAR to be added to `process-environment'
with VALUE."
(declare (indent 1))
`(let ((process-environment (copy-sequence process-environment)))
(pcase-dolist (`(,var . ,value) ,env)
(setenv var value))
,@body))
;;; Test resources
(defun flycheck-ert-resource-filename (resource-file)
"Determine the absolute file name of a RESOURCE-FILE.
Relative file names are expanded against
`flycheck-ert--resource-directory'."
(expand-file-name resource-file flycheck-ert--resource-directory))
(defmacro flycheck-ert-with-resource-buffer (resource-file &rest body)
"Create a temp buffer from a RESOURCE-FILE and execute BODY.
The absolute file name of RESOURCE-FILE is determined with
`flycheck-ert-resource-filename'."
(declare (indent 1))
`(flycheck-ert-with-file-buffer
(flycheck-ert-resource-filename ,resource-file)
,@body))
;;; Test suite initialization
(defun flycheck-ert-initialize (resource-dir)
"Initialize a test suite with RESOURCE-DIR.
RESOURCE-DIR is the directory, `flycheck-ert-resource-filename'
should use to lookup resource files."
(when flycheck-ert--resource-directory
(error "Test suite already initialized"))
(let ((tests (ert-select-tests t t)))
;; Select all tests
(unless tests
(error "No tests defined. \
Call `flycheck-ert-initialize' after defining all tests!"))
(setq flycheck-ert--resource-directory resource-dir)
;; Emacs 24.3 don't support skipped tests, so we add poor man's test
;; skipping: We mark skipped tests as expected failures by adjusting the
;; expected result of all test cases. Not particularly pretty, but works :)
(unless flycheck-ert-ert-can-skip
(dolist (test tests)
(let ((result (ert-test-expected-result-type test)))
(setf (ert-test-expected-result-type test)
`(or ,result (satisfies ert-test-skipped-p))))))))
;;; Test case definitions
(defmacro flycheck-ert-def-checker-test (checker language name
&rest keys-and-body)
"Define a test case for a syntax CHECKER for LANGUAGE.
CHECKER is a symbol or a list of symbols denoting syntax checkers
being tested by the test. The test case is skipped, if any of
these checkers cannot be used. LANGUAGE is a symbol or a list of
symbols denoting the programming languages supported by the
syntax checkers. This is currently only used for tagging the
test appropriately.
NAME is a symbol denoting the local name of the test. The test
itself is ultimately named
`flycheck-define-checker/CHECKER/NAME'. If CHECKER is a list,
the first checker in the list is used for naming the test.
Optionally, the keyword arguments `:tags' and `:expected-result'
may be given. They have the same meaning as in `ert-deftest.',
and are added to the tags and result expectations set up by this
macro.
The remaining forms KEYS-AND-BODY denote the body of the test
case, including assertions and setup code."
(declare (indent 3))
(unless checker
(error "No syntax checkers specified"))
(unless language
(error "No languages specified"))
(let* ((checkers (if (symbolp checker) (list checker) checker))
(checker (car checkers))
(languages (if (symbolp language) (list language) language))
(language-tags (mapcar (lambda (l) (intern (format "language-%s" l)))
languages))
(checker-tags (mapcar (lambda (c) (intern (format "checker-%s" c)))
checkers))
(local-name (or name 'default))
(full-name (intern (format "flycheck-define-checker/%s/%s"
checker local-name)))
(keys-and-body (ert--parse-keys-and-body keys-and-body))
(body (cadr keys-and-body))
(keys (car keys-and-body))
(default-tags '(syntax-checker external-tool)))
`(ert-deftest ,full-name ()
:expected-result ,(or (plist-get keys :expected-result) :passed)
:tags (append ',(append default-tags language-tags checker-tags)
,(plist-get keys :tags))
,@(mapcar (lambda (c)
`(skip-unless
;; Ignore non-command checkers
(or (not (flycheck-checker-get ',c 'command))
(executable-find (flycheck-checker-executable ',c)))))
checkers)
,@body)))
;;; Test case results
(defun flycheck-ert-syntax-check-timed-out-p (result)
"Whether RESULT denotes a timed-out test.
RESULT is an ERT test result object."
(and (ert-test-failed-p result)
(eq (car (ert-test-failed-condition result))
'flycheck-ert-syntax-check-timed-out)))
;;; Syntax checking in tests
(defvar-local flycheck-ert-syntax-checker-finished nil
"Non-nil if the current checker has finished.")
(add-hook 'flycheck-after-syntax-check-hook
(lambda () (setq flycheck-ert-syntax-checker-finished t)))
(defconst flycheck-ert-checker-wait-time 10
"Time to wait until a checker is finished in seconds.
After this time has elapsed, the checker is considered to have
failed, and the test aborted with failure.")
(define-error 'flycheck-ert-syntax-check-timed-out "Syntax check timed out.")
(defun flycheck-ert-wait-for-syntax-checker ()
"Wait until the syntax check in the current buffer is finished."
(let ((starttime (float-time)))
(while (and (not flycheck-ert-syntax-checker-finished)
(< (- (float-time) starttime) flycheck-ert-checker-wait-time))
(accept-process-output nil 0.02))
(unless (< (- (float-time) starttime) flycheck-ert-checker-wait-time)
(flycheck-stop)
(signal 'flycheck-ert-syntax-check-timed-out nil)))
(setq flycheck-ert-syntax-checker-finished nil))
(defun flycheck-ert-buffer-sync ()
"Like `flycheck-buffer', but synchronously."
(setq flycheck-ert-syntax-checker-finished nil)
(should (not (flycheck-running-p)))
(flycheck-mode) ;; This will only start a deferred check,
(should (flycheck-get-checker-for-buffer))
(flycheck-buffer) ;; …so we need an explicit manual check
;; After starting the check, the checker should either be running now, or
;; already be finished (if it was fast).
(should (or flycheck-current-syntax-check
flycheck-ert-syntax-checker-finished))
;; Also there should be no deferred check pending anymore
(should-not (flycheck-deferred-check-p))
(flycheck-ert-wait-for-syntax-checker))
(defun flycheck-ert-ensure-clear ()
"Clear the current buffer.
Raise an assertion error if the buffer is not clear afterwards."
(flycheck-clear)
(should (not flycheck-current-errors))
(should (not (-any? (lambda (ov) (overlay-get ov 'flycheck-overlay))
(overlays-in (point-min) (point-max))))))
;;; Test assertions
(defun flycheck-error-without-group (err)
"Return a copy ERR with the `group' property set to nil."
(let ((copy (copy-flycheck-error err)))
(setf (flycheck-error-group copy) nil)
copy))
(defun flycheck-ert-should-overlay (error)
"Test that ERROR has a proper overlay in the current buffer.
ERROR is a Flycheck error object."
(let* ((overlay (-first (lambda (ov)
(equal (flycheck-error-without-group
(overlay-get ov 'flycheck-error))
(flycheck-error-without-group error)))
(flycheck-overlays-in 0 (+ 1 (buffer-size)))))
(region
;; Overlays of errors from other files are on the first line
(if (flycheck-relevant-error-other-file-p error)
(cons (point-min)
(save-excursion (goto-char (point-min)) (point-at-eol)))
(flycheck-error-region-for-mode error 'symbols)))
(level (flycheck-error-level error))
(category (flycheck-error-level-overlay-category level))
(face (get category 'face))
(fringe-bitmap (flycheck-error-level-fringe-bitmap level))
(fringe-face (flycheck-error-level-fringe-face level))
(fringe-icon (list 'left-fringe fringe-bitmap fringe-face)))
(should overlay)
(should (overlay-get overlay 'flycheck-overlay))
(should (= (overlay-start overlay) (car region)))
(should (= (overlay-end overlay) (cdr region)))
(should (eq (overlay-get overlay 'face) face))
(should (equal (get-char-property 0 'display
(overlay-get overlay 'before-string))
fringe-icon))
(should (eq (overlay-get overlay 'category) category))
(should (equal (flycheck-error-without-group (overlay-get overlay
'flycheck-error))
(flycheck-error-without-group error)))))
(defun flycheck-ert-should-errors (&rest errors)
"Test that the current buffers has ERRORS.
ERRORS is a list of errors expected to be present in the current
buffer. Each error is given as a list of arguments to
`flycheck-error-new-at'.
If ERRORS are omitted, test that there are no errors at all in
the current buffer.
With ERRORS, test that each error in ERRORS is present in the
current buffer, and that the number of errors in the current
buffer is equal to the number of given ERRORS. In other words,
check that the buffer has all ERRORS, and no other errors."
(let ((expected (mapcar (apply-partially #'apply #'flycheck-error-new-at)
errors)))
(should (equal (mapcar #'flycheck-error-without-group expected)
(mapcar #'flycheck-error-without-group
flycheck-current-errors)))
;; Check that related errors are the same
(cl-mapcar (lambda (err1 err2)
(should (equal (mapcar #'flycheck-error-without-group
(flycheck-related-errors err1 expected))
(mapcar #'flycheck-error-without-group
(flycheck-related-errors err2)))))
expected flycheck-current-errors)
(mapc #'flycheck-ert-should-overlay expected))
(should (= (length errors)
(length (flycheck-overlays-in (point-min) (point-max))))))
(define-error 'flycheck-ert-suspicious-checker "Suspicious state from checker")
(defun flycheck-ert-should-syntax-check-in-buffer (&rest errors)
"Test a syntax check in BUFFER, expecting ERRORS.
This is like `flycheck-ert-should-syntax-check', but with a
buffer in the right mode instead of a file."
;; Load safe file-local variables because some tests depend on them
(let ((enable-local-variables :safe)
;; Disable all hooks at this place, to prevent 3rd party packages
;; from interfering
(hack-local-variables-hook))
(hack-local-variables))
;; Configure config file locating for unit tests
(let ((process-hook-called 0)
(suspicious nil))
(add-hook 'flycheck-process-error-functions
(lambda (_err)
(setq process-hook-called (1+ process-hook-called))
nil)
nil :local)
(add-hook 'flycheck-status-changed-functions
(lambda (status)
(when (eq status 'suspicious)
(setq suspicious t)))
nil :local)
(flycheck-ert-buffer-sync)
(when suspicious
(signal 'flycheck-ert-suspicious-checker nil))
(apply #'flycheck-ert-should-errors errors)
(should (= process-hook-called (length errors))))
(flycheck-ert-ensure-clear))
(defun flycheck-ert-should-syntax-check (resource-file modes &rest errors)
"Test a syntax check in RESOURCE-FILE with MODES.
RESOURCE-FILE is the file to check. MODES is a single major mode
symbol or a list thereof, specifying the major modes to syntax
check with. If more than one major mode is specified, the test
is run for each mode separately, so if you give three major
modes, the entire test will run three times. ERRORS is the list
of expected errors, as in `flycheck-ert-should-errors'. If
omitted, the syntax check must not emit any errors. The errors
are cleared after each test.
The syntax checker is selected via standard syntax checker
selection. To test a specific checker, you need to set
`flycheck-checker' or `flycheck-disabled-checkers' accordingly
before using this predicate, depending on whether you want to use
manual or automatic checker selection.
During the syntax check, configuration files of syntax checkers
are also searched in the `config-files' sub-directory of the
resource directory."
(when (symbolp modes)
(setq modes (list modes)))
(dolist (mode modes)
(unless (fboundp mode)
(ert-skip (format "%S missing" mode)))
(flycheck-ert-with-resource-buffer resource-file
(funcall mode)
(apply #'flycheck-ert-should-syntax-check-in-buffer errors))))
(defun flycheck-ert-at-nth-error (n)
"Determine whether point is at the N'th Flycheck error.
Return non-nil if the point is at the N'th Flycheck error in the
current buffer. Otherwise return nil."
(let* ((error (nth (1- n) flycheck-current-errors))
(mode flycheck-highlighting-mode)
(region (flycheck-error-region-for-mode error mode)))
(and (member error (flycheck-overlay-errors-at (point)))
(= (point) (car region)))))
(defun flycheck-ert-explain--at-nth-error (n)
"Explain a failed at-nth-error predicate at N."
(let ((errors (flycheck-overlay-errors-at (point))))
(if (null errors)
(format "Expected to be at error %s, but no error at point %s"
n (point))
(let ((pos (cl-position (car errors) flycheck-current-errors)))
(format "Expected to be at error %s, but point %s is at error %s"
n (point) (1+ pos))))))
(put 'flycheck-ert-at-nth-error 'ert-explainer
'flycheck-ert-explain--at-nth-error)
(provide 'flycheck-ert)
;;; flycheck-ert.el ends here

Binary file not shown.

View file

@ -0,0 +1,16 @@
(define-package "flycheck" "20200405.2310" "On-the-fly syntax checking"
'((dash "2.12.1")
(pkg-info "0.4")
(let-alist "1.0.4")
(seq "1.11")
(emacs "24.3"))
:keywords
'("convenience" "languages" "tools")
:authors
'(("Sebastian Wiesner" . "swiesner@lunaryorn.com"))
:maintainer
'("Clément Pit-Claudel" . "clement.pitclaudel@live.com")
:url "http://www.flycheck.org")
;; Local Variables:
;; no-byte-compile: t
;; End:

File diff suppressed because it is too large Load diff

Binary file not shown.