/emacs.d/elpa/dumb-jump-20220524.2122/dumb-jump.el
Emacs Lisp | 1073 lines | 782 code | 204 blank | 87 comment | 20 complexity | f98fc3de8e5a8c9ad2bef2af51e61a58 MD5 | raw file
- ;;; dumb-jump.el --- Jump to definition for 50+ languages without configuration -*- lexical-binding: t; -*-
- ;; Copyright (C) 2015-2021 jack angers
- ;; Author: jack angers and contributors
- ;; Url: https://github.com/jacktasia/dumb-jump
- ;; Package-Version: 20220524.2122
- ;; Package-Commit: 1dd583011f4025b1b8c75fd785691851b6c5dfa3
- ;; Version: 0.5.4
- ;; Package-Requires: ((emacs "24.3") (s "1.11.0") (dash "2.9.0") (popup "0.5.3"))
- ;; Keywords: programming
- ;; Dumb Jump 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, or (at your option)
- ;; any later version.
- ;;
- ;; Dumb Jump 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 Dumb Jump. If not, see http://www.gnu.org/licenses.
- ;;; Commentary:
- ;; Dumb Jump is an Emacs "jump to definition" package with support for 50+ programming languages that favors
- ;; "just working" over speed or accuracy. This means minimal -- and ideally zero -- configuration with absolutely
- ;; no stored indexes (TAGS) or persistent background processes.
- ;;
- ;; Dumb Jump provides a xref-based interface for jumping to
- ;; definitions. It is based on tools such as grep, the silver searcher
- ;; (https://geoff.greer.fm/ag/), ripgrep
- ;; (https://github.com/BurntSushi/ripgrep) or git-grep
- ;; (https://git-scm.com/docs/git-grep).
- ;;
- ;; To enable Dumb Jump, add the following to your initialisation file:
- ;;
- ;; (add-hook 'xref-backend-functions #'dumb-jump-xref-activate)
- ;;
- ;; Now pressing M-. on an identifier should open a buffer at the place
- ;; where it is defined, or a list of candidates if uncertain. This
- ;; list can be navigated using M-g M-n (next-error) and M-g M-p
- ;; (previous-error).
- ;;; Code:
- (unless (require 'xref nil :noerror)
- (require 'etags))
- (require 's)
- (require 'dash)
- (require 'popup)
- (require 'cl-generic nil :noerror)
- (require 'cl-lib)
- (defgroup dumb-jump nil
- "Easily jump to project function and variable definitions"
- :group 'tools
- :group 'convenience)
- ;;;###autoload
- (defvar dumb-jump-mode-map
- (let ((map (make-sparse-keymap)))
- (define-key map (kbd "C-M-g") 'dumb-jump-go)
- (define-key map (kbd "C-M-p") 'dumb-jump-back)
- (define-key map (kbd "C-M-q") 'dumb-jump-quick-look)
- map))
- (defcustom dumb-jump-window
- 'current
- "Which window to use when jumping. Valid options are 'current (default) or 'other."
- :group 'dumb-jump
- :type '(choice (const :tag "Current window" current)
- (const :tag "Other window" other)))
- (defcustom dumb-jump-use-visible-window
- t
- "When true will jump in a visible window if that window already has the file open."
- :group 'dumb-jump
- :type 'boolean)
- (defcustom dumb-jump-selector
- 'popup
- "Which selector to use when there is multiple choices. `ivy` and `helm' are also supported."
- :group 'dumb-jump
- :type '(choice (const :tag "Popup" popup)
- (const :tag "Helm" helm)
- (const :tag "Ivy" ivy)
- (const :tag "Completing Read" completing-read)))
- (defcustom dumb-jump-ivy-jump-to-selected-function
- #'dumb-jump-ivy-jump-to-selected
- "Prompts user for a choice using ivy then dumb-jump to that choice."
- :group 'dumb-jump
- :type 'function)
- (defcustom dumb-jump-prefer-searcher
- nil
- "The preferred searcher to use 'ag, 'rg, 'git-grep, 'gnu-grep,or 'grep.
- If nil then the most optimal searcher will be chosen at runtime."
- :group 'dumb-jump
- :type '(choice (const :tag "Best Available" nil)
- (const :tag "ag" ag)
- (const :tag "rg" rg)
- (const :tag "grep" gnu-grep)
- (const :tag "git grep" git-grep)
- (const :tag "git grep + ag" git-grep-plus-ag)))
- (defcustom dumb-jump-force-searcher
- nil
- "Forcibly use searcher: 'ag, 'rg, 'git-grep, 'gnu-grep, or 'grep.
- Set to nil to not force anything and use `dumb-jump-prefer-searcher'
- or most optimal searcher."
- :group 'dumb-jump
- :type '(choice (const :tag "Best Available" nil)
- (const :tag "ag" ag)
- (const :tag "rg" rg)
- (const :tag "grep" gnu-grep)
- (const :tag "git grep" git-grep)
- (const :tag "git grep + ag" git-grep-plus-ag)))
- (defcustom dumb-jump-grep-prefix
- "LANG=C"
- "Prefix to grep command. Seemingly makes it faster for pure text."
- :group 'dumb-jump
- :type 'string)
- (defcustom dumb-jump-grep-cmd
- "grep"
- "The path to grep. By default assumes it is in path."
- :group 'dumb-jump
- :type 'string)
- (defcustom dumb-jump-ag-cmd
- "ag"
- "The the path to the silver searcher. By default assumes it is in path. If not found fallbacks to grep."
- :group 'dumb-jump
- :type 'string)
- (defcustom dumb-jump-rg-cmd
- "rg"
- "The the path to ripgrep. By default assumes it is in path. If not found fallbacks to grep."
- :group 'dumb-jump
- :type 'string)
- (defcustom dumb-jump-git-grep-cmd
- "git grep"
- "The the path to git grep. By default assumes it is in path. If not found fallbacks to grep."
- :group 'dumb-jump
- :type 'string)
- (defcustom dumb-jump-ag-word-boundary
- "(?![a-zA-Z0-9\\?\\*-])"
- "`\\b` thinks `-` is a word boundary. When this matters use `\\j` instead and ag will use this value."
- :group 'dumb-jump
- :type 'string)
- (defcustom dumb-jump-rg-word-boundary
- "($|[^a-zA-Z0-9\\?\\*-])"
- "`\\b` thinks `-` is a word boundary. When this matters use `\\j` instead and rg will use this value."
- :group 'dumb-jump
- :type 'string)
- (defcustom dumb-jump-git-grep-word-boundary
- "($|[^a-zA-Z0-9\\?\\*-])"
- "`\\b` thinks `-` is a word boundary. When this matters use `\\j` instead and git grep will use this value."
- :group 'dumb-jump
- :type 'string)
- (defcustom dumb-jump-grep-word-boundary
- "($|[^a-zA-Z0-9\\?\\*-])"
- "`\\b` thinks `-` is a word boundary. When this matters use `\\j` instead and grep will use this value."
- :group 'dumb-jump
- :type 'string)
- (defcustom dumb-jump-fallback-regex
- "\\bJJJ\\j"
- "When dumb-jump-fallback-search is t use this regex. Defaults to boundary search of symbol under point."
- :group 'dumb-jump
- :type 'string)
- (defcustom dumb-jump-fallback-search
- t
- "If nothing is found with normal search fallback to searching the fallback regex."
- :group 'dumb-jump
- :type 'boolean)
- (defcustom dumb-jump-force-grep
- nil
- "When t will use grep even if ag is available."
- :group 'dumb-jump
- :type 'boolean)
- (defcustom dumb-jump-zgrep-cmd
- "zgrep"
- "The path to grep to use for gzipped files. By default assumes it is in path."
- :group 'dumb-jump
- :type 'string)
- (defcustom dumb-jump-grep-args "-REn"
- "Grep command args [R]ecursive, [E]xtended regexes, and show line [n]umbers."
- :group 'dumb-jump
- :type 'string)
- (defcustom dumb-jump-gnu-grep-args "-rEn"
- "Grep command args [r]ecursive and [E]xtended regexes, and show line [n]umbers."
- :group 'dumb-jump
- :type 'string)
- (defcustom dumb-jump-max-find-time
- 2
- "Number of seconds a grep/find command can take before being warned to use ag and config."
- :group 'dumb-jump
- :type 'integer)
- (defcustom dumb-jump-functions-only
- nil
- "Should we only jump to functions?"
- :group 'dumb-jump
- :type 'boolean)
- (defcustom dumb-jump-quiet
- nil
- "If non-nil Dumb Jump will not log anything to *Messages*."
- :group 'dumb-jump
- :type 'boolean)
- (defcustom dumb-jump-ignore-context
- nil
- "If non-nil Dumb Jump will ignore the context of point when jumping."
- :group 'dumb-jump
- :type 'boolean)
- (defcustom dumb-jump-git-grep-search-untracked
- t
- "If non-nil Dumb Jump will also search untracked files when using searcher git-grep."
- :group 'dumb-jump
- :type 'boolean)
- (defcustom dumb-jump-git-grep-search-args
- ""
- "Appends the passed arguments to the git-grep search function. Default: \"\""
- :group 'dumb-jump
- :type 'string)
- (defcustom dumb-jump-ag-search-args
- ""
- "Appends the passed arguments to the ag search function. Default: \"\""
- :group 'dumb-jump
- :type 'string)
- (defcustom dumb-jump-rg-search-args
- "--pcre2"
- "Appends the passed arguments to the rg search function. Default: \"--pcre2\""
- :group 'dumb-jump
- :type 'string)
- (defcustom dumb-jump-find-rules
- '((:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "elisp"
- :regex "\\\((defun|cl-defun)\\s+JJJ\\j"
- ;; \\j usage see `dumb-jump-ag-word-boundary`
- :tests ("(defun test (blah)" "(defun test\n" "(cl-defun test (blah)" "(cl-defun test\n")
- :not ("(defun test-asdf (blah)" "(defun test-blah\n" "(cl-defun test-asdf (blah)"
- "(cl-defun test-blah\n" "(defun tester (blah)" "(defun test? (blah)" "(defun test- (blah)"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "elisp"
- :regex "\\\(defvar\\b\\s*JJJ\\j"
- :tests ("(defvar test " "(defvar test\n")
- :not ("(defvar tester" "(defvar test?" "(defvar test-"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "elisp"
- :regex "\\\(defcustom\\b\\s*JJJ\\j"
- :tests ("(defcustom test " "(defcustom test\n")
- :not ("(defcustom tester" "(defcustom test?" "(defcustom test-"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "elisp"
- :regex "\\\(setq\\b\\s*JJJ\\j" :tests ("(setq test 123)")
- :not ("setq test-blah 123)" "(setq tester" "(setq test?" "(setq test-"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "elisp"
- :regex "\\\(JJJ\\s+" :tests ("(let ((test 123)))") :not ("(let ((test-2 123)))"))
- ;; variable in method signature
- (:type "variable" :supports ("ag" "rg" "git-grep") :language "elisp"
- :regex "\\((defun|cl-defun)\\s*.+\\\(?\\s*JJJ\\j\\s*\\\)?"
- :tests ("(defun blah (test)" "(defun blah (test blah)" "(defun (blah test)")
- :not ("(defun blah (test-1)" "(defun blah (test-2 blah)" "(defun (blah test-3)"))
- ;; common lisp
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "commonlisp"
- :regex "\\\(defun\\s+JJJ\\j"
- ;; \\j usage see `dumb-jump-ag-word-boundary`
- :tests ("(defun test (blah)" "(defun test\n")
- :not ("(defun test-asdf (blah)" "(defun test-blah\n"
- "(defun tester (blah)" "(defun test? (blah)" "(defun test- (blah)"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "commonlisp"
- :regex "\\\(defparameter\\b\\s*JJJ\\j"
- :tests ("(defparameter test " "(defparameter test\n")
- :not ("(defparameter tester" "(defparameter test?" "(defparameter test-"))
- ;; racket
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "racket"
- :regex "\\\(define\\s+\\(\\s*JJJ\\j"
- :tests ("(define (test blah)" "(define (test\n")
- :not ("(define test blah" "(define (test-asdf blah)" "(define test (lambda (blah"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "racket"
- :regex "\\\(define\\s+JJJ\\s*\\\(\\s*lambda"
- :tests ("(define test (lambda (blah" "(define test (lambda\n")
- :not ("(define test blah" "(define test-asdf (lambda (blah)" "(define (test)" "(define (test blah) (lambda (foo"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "racket"
- :regex "\\\(let\\s+JJJ\\s*(\\\(|\\\[)*"
- :tests ("(let test ((blah foo) (bar bas))" "(let test\n" "(let test [(foo")
- :not ("(let ((test blah"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "racket"
- :regex "\\\(define\\s+JJJ\\j"
- :tests ("(define test " "(define test\n")
- :not ("(define (test"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "racket"
- :regex "(\\\(|\\\[)\\s*JJJ\\s+"
- :tests ("(let ((test 'foo" "(let [(test 'foo" "(let [(test 'foo" "(let [[test 'foo" "(let ((blah 'foo) (test 'bar)")
- :not ("{test foo"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "racket"
- :regex "\\\(lambda\\s+\\\(?[^\(\)]*\\s*JJJ\\j\\s*\\\)?"
- :tests ("(lambda (test)" "(lambda (foo test)" "(lambda test (foo)")
- :not ("(lambda () test"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "racket"
- :regex "\\\(define\\s+\\\([^\(\)]+\\s*JJJ\\j\\s*\\\)?"
- :tests ("(define (foo test)" "(define (foo test bar)")
- :not ("(define foo test" "(define (test foo" "(define (test)"))
- (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "racket"
- :regex "\\(struct\\s+JJJ\\j"
- :tests ("(struct test (a b)"))
- ;; scheme
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "scheme"
- :regex "\\\(define\\s+\\(\\s*JJJ\\j"
- :tests ("(define (test blah)" "(define (test\n")
- :not ("(define test blah" "(define (test-asdf blah)" "(define test (lambda (blah"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "scheme"
- :regex "\\\(define\\s+JJJ\\s*\\\(\\s*lambda"
- :tests ("(define test (lambda (blah" "(define test (lambda\n")
- :not ("(define test blah" "(define test-asdf (lambda (blah)" "(define (test)" "(define (test blah) (lambda (foo"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "scheme"
- :regex "\\\(let\\s+JJJ\\s*(\\\(|\\\[)*"
- :tests ("(let test ((blah foo) (bar bas))" "(let test\n" "(let test [(foo")
- :not ("(let ((test blah"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "scheme"
- :regex "\\\(define\\s+JJJ\\j"
- :tests ("(define test " "(define test\n")
- :not ("(define (test"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "scheme"
- :regex "(\\\(|\\\[)\\s*JJJ\\s+"
- :tests ("(let ((test 'foo" "(let [(test 'foo" "(let [(test 'foo" "(let [[test 'foo" "(let ((blah 'foo) (test 'bar)")
- :not ("{test foo"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "scheme"
- :regex "\\\(lambda\\s+\\\(?[^\(\)]*\\s*JJJ\\j\\s*\\\)?"
- :tests ("(lambda (test)" "(lambda (foo test)" "(lambda test (foo)")
- :not ("(lambda () test"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "scheme"
- :regex "\\\(define\\s+\\\([^\(\)]+\\s*JJJ\\j\\s*\\\)?"
- :tests ("(define (foo test)" "(define (foo test bar)")
- :not ("(define foo test" "(define (test foo" "(define (test)"))
- ;; c++
- (:type "function" :supports ("ag" "rg" "git-grep") :language "c++"
- :regex "\\bJJJ(\\s|\\))*\\((\\w|[,&*.<>:]|\\s)*(\\))\\s*(const|->|\\{|$)|typedef\\s+(\\w|[(*]|\\s)+JJJ(\\)|\\s)*\\("
- :tests ("int test(){" "my_struct (*test)(int a, int b){" "auto MyClass::test ( Builder::Builder& reference, ) -> decltype( builder.func() ) {" "int test( int *random_argument) const {" "test::test() {" "typedef int (*test)(int);")
- :not ("return test();)" "int test(a, b);" "if( test() ) {" "else test();"))
- ;; (:type "variable" :supports ("grep") :language "c++"
- ;; :regex "(\\b\\w+|[,>])([*&]|\\s)+JJJ\\s*(\\[([0-9]|\\s)*\\])*\\s*([=,){;]|:\\s*[0-9])|#define\\s+JJJ\\b"
- ;; :tests ("int test=2;" "char *test;" "int x = 1, test = 2" "int test[20];" "#define test" "unsigned int test:2;"))
- (:type "variable" :supports ("ag" "rg") :language "c++"
- :regex "\\b(?!(class\\b|struct\\b|return\\b|else\\b|delete\\b))(\\w+|[,>])([*&]|\\s)+JJJ\\s*(\\[(\\d|\\s)*\\])*\\s*([=,(){;]|:\\s*\\d)|#define\\s+JJJ\\b"
- :tests ("int test=2;" "char *test;" "int x = 1, test = 2" "int test[20];" "#define test" "typedef int test;" "unsigned int test:2")
- :not ("return test;" "#define NOT test" "else test=2;"))
- (:type "type" :supports ("ag" "rg" "git-grep") :language "c++"
- :regex "\\b(class|struct|enum|union)\\b\\s*JJJ\\b\\s*(final\\s*)?(:((\\s*\\w+\\s*::)*\\s*\\w*\\s*<?(\\s*\\w+\\s*::)*\\w+>?\\s*,*)+)?((\\{|$))|}\\s*JJJ\\b\\s*;"
- :tests ("typedef struct test {" "enum test {" "} test;" "union test {" "class test final: public Parent1, private Parent2{" "class test : public std::vector<int> {")
- :not("union test var;" "struct test function() {"))
- ;; clojure
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "clojure"
- :regex "\\(def\\s+JJJ\\j"
- :tests ("(def test (foo)"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "clojure"
- :regex "\\(defn-?\\s+JJJ\\j"
- :tests ("(defn test [foo]" "(defn- test [foo]")
- :not ("(defn test? [foo]" "(defn- test? [foo]"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "clojure"
- :regex "\\(defmacro\\s+JJJ\\j"
- :tests ("(defmacro test [foo]"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "clojure"
- :regex "\\(deftask\\s+JJJ\\j"
- :tests ("(deftask test [foo]"))
- (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "clojure"
- :regex "\\(deftype\\s+JJJ\\j"
- :tests ("(deftype test [foo]"))
- (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "clojure"
- :regex "\\(defmulti\\s+JJJ\\j"
- :tests ("(defmulti test fn"))
- (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "clojure"
- :regex "\\(defmethod\\s+JJJ\\j"
- :tests ("(defmethod test type"))
- (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "clojure"
- :regex "\\(definterface\\s+JJJ\\j"
- :tests ("(definterface test (foo)"))
- (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "clojure"
- :regex "\\(defprotocol\\s+JJJ\\j"
- :tests ("(defprotocol test (foo)"))
- (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "clojure"
- :regex "\\(defrecord\\s+JJJ\\j"
- :tests ("(defrecord test [foo]"))
- ;; coffeescript
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "coffeescript"
- :regex "^\\s*JJJ\\s*[=:].*[-=]>"
- :tests ("test = () =>" "test= =>" "test = ->" "test=()->"
- "test : () =>" "test: =>" "test : ->" "test:()->")
- :not ("# test = =>" "test = 1"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "coffeescript"
- :regex "^\\s*JJJ\\s*[:=][^:=-][^>]+$"
- :tests ("test = $" "test : [" "test = {" "test = a")
- :not ("test::a" "test: =>" "test == 1" "# test = 1"))
- (:type "class" :supports ("ag" "grep" "rg" "git-grep") :language "coffeescript"
- :regex "^\\s*\\bclass\\s+JJJ"
- :tests ("class test" "class test extends")
- :not ("# class"))
- ;; obj-c
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "objc"
- :regex "\\\)\\s*JJJ(:|\\b|\\s)"
- :tests ("- (void)test" "- (void)test:(UIAlertView *)alertView")
- :not ("- (void)testnot" "- (void)testnot:(UIAlertView *)alertView"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "objc"
- :regex "\\b\\*?JJJ\\s*=[^=\\n]+"
- :tests ("NSString *test = @\"asdf\"")
- :not ("NSString *testnot = @\"asdf\"" "NSString *nottest = @\"asdf\""))
- (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "objc"
- :regex "(@interface|@protocol|@implementation)\\b\\s*JJJ\\b\\s*"
- :tests ("@interface test: UIWindow")
- :not ("@interface testnon: UIWindow"))
- (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "objc"
- :regex "typedef\\b\\s+(NS_OPTIONS|NS_ENUM)\\b\\([^,]+?,\\s*JJJ\\b\\s*"
- :tests ("typedef NS_ENUM(NSUInteger, test)")
- :not ("typedef NS_ENUMD(NSUInteger, test)"))
- ;; swift
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "swift"
- :regex "(let|var)\\s*JJJ\\s*(=|:)[^=:\\n]+"
- :tests ("let test = 1234" "var test = 1234" "private lazy var test: UITapGestureRecognizer")
- :not ("if test == 1234:"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "swift"
- :regex "func\\s+JJJ\\b\\s*(<[^>]*>)?\\s*\\("
- :tests ("func test(asdf)" "func test()" "func test<Value: Protocol>()")
- :not ("func testnot(asdf)" "func testnot()"))
- (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "swift"
- :regex "(class|struct|protocol|enum)\\s+JJJ\\b\\s*?"
- :tests ("struct test" "struct test: Codable" "struct test<Value: Codable>"
- "class test:" "class test: UIWindow" "class test<Value: Codable>")
- :not ("class testnot:" "class testnot(object):" "struct testnot(object)"))
- (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "swift"
- :regex "(typealias)\\s+JJJ\\b\\s*?="
- :tests ("typealias test =")
- :not ("typealias testnot"))
- ;; c#
- (:type "function" :supports ("ag" "rg") :language "csharp"
- :regex "^\\s*(?:[\\w\\[\\]]+\\s+){1,3}JJJ\\s*\\\("
- :tests ("int test()" "int test(param)" "static int test()" "static int test(param)"
- "public static MyType test()" "private virtual SomeType test(param)" "static int test()")
- :not ("test()" "testnot()" "blah = new test()"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "csharp"
- :regex "\\s*\\bJJJ\\s*=[^=\\n)]+" :tests ("int test = 1234") :not ("if test == 1234:" "int nottest = 44"))
- (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "csharp"
- :regex "(class|interface)\\s*JJJ\\b"
- :tests ("class test:" "public class test : IReadableChannel, I")
- :not ("class testnot:" "public class testnot : IReadableChannel, I"))
- ;; java (literally the same regexes as c#, but different tests)
- (:type "function" :supports ("ag" "rg") :language "java"
- :regex "^\\s*(?:[\\w\\[\\]]+\\s+){1,3}JJJ\\s*\\\("
- :tests ("int test()" "int test(param)" "static int test()" "static int test(param)"
- "public static MyType test()" "private virtual SomeType test(param)" "static int test()"
- "private foo[] test()")
- :not ("test()" "testnot()" "blah = new test()" "foo bar = test()"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "java"
- :regex "\\s*\\bJJJ\\s*=[^=\\n)]+" :tests ("int test = 1234") :not ("if test == 1234:" "int nottest = 44"))
- (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "java"
- :regex "(class|interface)\\s*JJJ\\b"
- :tests ("class test:" "public class test implements Something")
- :not ("class testnot:" "public class testnot implements Something"))
- ;; vala (again just like c#, exactly the same..)
- (:type "function" :supports ("ag" "rg") :language "vala"
- :regex "^\\s*(?:[\\w\\[\\]]+\\s+){1,3}JJJ\\s*\\\("
- :tests ("int test()" "int test(param)" "static int test()" "static int test(param)"
- "public static MyType test()" "private virtual SomeType test(param)" "static int test()")
- :not ("test()" "testnot()" "blah = new test()"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "vala"
- :regex "\\s*\\bJJJ\\s*=[^=\\n)]+" :tests ("int test = 1234") :not ("if test == 1234:" "int nottest = 44"))
- (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "vala"
- :regex "(class|interface)\\s*JJJ\\b"
- :tests ("class test:" "public class test : IReadableChannel, I")
- :not ("class testnot:" "public class testnot : IReadableChannel, I"))
- ;; coq
- (:type "function" :supports ("ag" "rg" "git-grep") :language "coq"
- :regex "\\s*Variable\\s+JJJ\\b"
- :tests ("Variable test")
- :not ("Variable testx"))
- (:type "function" :supports ("ag" "rg" "git-grep") :language "coq"
- :regex "\\s*Inductive\\s+JJJ\\b"
- :tests ("Inductive test")
- :not ("Inductive testx"))
- (:type "function" :supports ("ag" "rg" "git-grep") :language "coq"
- :regex "\\s*Lemma\\s+JJJ\\b"
- :tests ("Lemma test")
- :not ("Lemma testx"))
- (:type "function" :supports ("ag" "rg" "git-grep") :language "coq"
- :regex "\\s*Definition\\s+JJJ\\b"
- :tests ("Definition test")
- :not ("Definition testx"))
- (:type "function" :supports ("ag" "rg" "git-grep") :language "coq"
- :regex "\\s*Hypothesis\\s+JJJ\\b"
- :tests ("Hypothesis test")
- :not ("Hypothesis testx"))
- (:type "function" :supports ("ag" "rg" "git-grep") :language "coq"
- :regex "\\s*Theorm\\s+JJJ\\b"
- :tests ("Theorm test")
- :not ("Theorm testx"))
- (:type "function" :supports ("ag" "rg" "git-grep") :language "coq"
- :regex "\\s*Fixpoint\\s+JJJ\\b"
- :tests ("Fixpoint test")
- :not ("Fixpoint testx"))
- (:type "function" :supports ("ag" "rg" "git-grep") :language "coq"
- :regex "\\s*Module\\s+JJJ\\b"
- :tests ("Module test")
- :not ("Module testx"))
- (:type "function" :supports ("ag" "rg" "git-grep") :language "coq"
- :regex "\\s*CoInductive\\s+JJJ\\b"
- :tests ("CoInductive test")
- :not ("CoInductive testx"))
- ;; python
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "python"
- :regex "\\s*\\bJJJ\\s*=[^=\\n]+"
- :tests ("test = 1234")
- :not ("if test == 1234:" "_test = 1234"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "python"
- :regex "def\\s*JJJ\\b\\s*\\\("
- :tests ("\tdef test(asdf)" "def test()")
- :not ("\tdef testnot(asdf)" "def testnot()"))
- (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "python"
- :regex "class\\s*JJJ\\b\\s*\\\(?"
- :tests ("class test(object):" "class test:")
- :not ("class testnot:" "class testnot(object):"))
- ;; matlab
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "matlab"
- :regex "^\\s*\\bJJJ\\s*=[^=\\n]+"
- :tests ("test = 1234")
- :not ("for test = 1:2:" "_test = 1234"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "matlab"
- :regex "^\\s*function\\s*[^=]+\\s*=\\s*JJJ\\b"
- :tests ("\tfunction y = test(asdf)" "function x = test()" "function [x, losses] = test(A, y, lambda, method, qtile)")
- :not ("\tfunction testnot(asdf)" "function testnot()"))
- (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "matlab"
- :regex "^\\s*classdef\\s*JJJ\\b\\s*"
- :tests ("classdef test")
- :not ("classdef testnot"))
- ;; nim
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "nim"
- :regex "(const|let|var)\\s*JJJ\\*?\\s*(=|:)[^=:\\n]+"
- :tests ("let test = 1234" "var test = 1234" "var test: Stat" "const test = 1234" "const test* = 1234")
- :not ("if test == 1234:"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "nim"
- :regex "(proc|func|macro|template)\\s*`?JJJ`?\\b\\*?\\s*\\\("
- :tests ("\tproc test(asdf)" "proc test()" "func test()" "macro test()" "template test()" "proc test*()")
- :not ("\tproc testnot(asdf)" "proc testnot()"))
- (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "nim"
- :regex "type\\s*JJJ\\b\\*?\\s*(\\{[^}]+\\})?\\s*=\\s*\\w+"
- :tests ("type test = object" "type test {.pure.} = enum" "type test* = ref object")
- :not ("type testnot = object"))
- ;; nix
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "nix"
- :regex "\\b\\s*JJJ\\s*=[^=;]+"
- :tests ("test = 1234;" "test = 123;" "test=123")
- :not ("testNot = 1234;" "Nottest = 1234;" "AtestNot = 1234;"))
- ;; ruby
- (:type "variable" :supports ("ag" "rg" "git-grep") :language "ruby"
- :regex "^\\s*((\\w+[.])*\\w+,\\s*)*JJJ(,\\s*(\\w+[.])*\\w+)*\\s*=([^=>~]|$)"
- :tests ("test = 1234" "self.foo, test, bar = args")
- :not ("if test == 1234" "foo_test = 1234"))
- (:type "function" :supports ("ag" "rg" "git-grep") :language "ruby"
- :regex "(^|[^\\w.])((private|public|protected)\\s+)?def\\s+(\\w+(::|[.]))*JJJ($|[^\\w|:])"
- :tests ("def test(foo)" "def test()" "def test foo" "def test; end"
- "def self.test()" "def MODULE::test()" "private def test")
- :not ("def test_foo"))
- (:type "function" :supports ("ag" "rg" "git-grep") :language "ruby"
- :regex "(^|\\W)define(_singleton|_instance)?_method(\\s|[(])\\s*:JJJ($|[^\\w|:])"
- :tests ("define_method(:test, &body)"
- "mod.define_instance_method(:test) { body }"))
- (:type "type" :supports ("ag" "rg" "git-grep") :language "ruby"
- :regex "(^|[^\\w.])class\\s+(\\w*::)*JJJ($|[^\\w|:])"
- :tests ("class test" "class Foo::test"))
- (:type "type" :supports ("ag" "rg" "git-grep") :language "ruby"
- :regex "(^|[^\\w.])module\\s+(\\w*::)*JJJ($|[^\\w|:])"
- :tests ("module test" "module Foo::test"))
- (:type "function" :supports ("ag" "rg" "git-grep") :language "ruby"
- :regex "(^|\\W)alias(_method)?\\W+JJJ(\\W|$)"
- :tests ("alias test some_method"
- "alias_method :test, :some_method"
- "alias_method 'test' 'some_method'"
- "some_class.send(:alias_method, :test, :some_method)")
- :not ("alias some_method test"
- "alias_method :some_method, :test"
- "alias test_foo test"))
- ;; Groovy
- (:type "variable" :supports ("ag" "rg" "git-grep") :language "groovy"
- :regex "^\\s*((\\w+[.])*\\w+,\\s*)*JJJ(,\\s*(\\w+[.])*\\w+)*\\s*=([^=>~]|$)"
- :tests ("test = 1234" "self.foo, test, bar = args")
- :not ("if test == 1234" "foo_test = 1234"))
- (:type "function" :supports ("ag" "rg" "git-grep") :language "groovy"
- :regex "(^|[^\\w.])((private|public)\\s+)?def\\s+(\\w+(::|[.]))*JJJ($|[^\\w|:])"
- :tests ("def test(foo)" "def test()" "def test foo" "def test; end"
- "def self.test()" "def MODULE::test()" "private def test")
- :not ("def test_foo"))
- (:type "type" :supports ("ag" "rg" "git-grep") :language "groovy"
- :regex "(^|[^\\w.])class\\s+(\\w*::)*JJJ($|[^\\w|:])"
- :tests ("class test" "class Foo::test"))
- ;; crystal
- (:type "variable" :supports ("ag" "rg" "git-grep") :language "crystal"
- :regex "^\\s*((\\w+[.])*\\w+,\\s*)*JJJ(,\\s*(\\w+[.])*\\w+)*\\s*=([^=>~]|$)"
- :tests ("test = 1234" "self.foo, test, bar = args")
- :not ("if test == 1234" "foo_test = 1234"))
- (:type "function" :supports ("ag" "rg" "git-grep") :language "crystal"
- :regex "(^|[^\\w.])((private|public|protected)\\s+)?def\\s+(\\w+(::|[.]))*JJJ($|[^\\w|:])"
- :tests ("def test(foo)" "def test()" "def test foo" "def test; end"
- "def self.test()" "def MODULE::test()" "private def test")
- :not ("def test_foo"))
- (:type "type" :supports ("ag" "rg" "git-grep") :language "crystal"
- :regex "(^|[^\\w.])class\\s+(\\w*::)*JJJ($|[^\\w|:])"
- :tests ("class test" "class Foo::test"))
- (:type "type" :supports ("ag" "rg" "git-grep") :language "crystal"
- :regex "(^|[^\\w.])module\\s+(\\w*::)*JJJ($|[^\\w|:])"
- :tests ("module test" "module Foo::test"))
- (:type "type" :supports ("ag" "rg" "git-grep") :language "crystal"
- :regex "(^|[^\\w.])struct\\s+(\\w*::)*JJJ($|[^\\w|:])"
- :tests ("struct test" "struct Foo::test"))
- (:type "type" :supports ("ag" "rg" "git-grep") :language "crystal"
- :regex "(^|[^\\w.])alias\\s+(\\w*::)*JJJ($|[^\\w|:])"
- :tests ("alias test" "alias Foo::test"))
- ;; scad
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "scad"
- :regex "\\s*\\bJJJ\\s*=[^=\\n]+" :tests ("test = 1234") :not ("if test == 1234 {"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "scad"
- :regex "function\\s*JJJ\\s*\\\("
- :tests ("function test()" "function test ()"))
- (:type "module" :supports ("ag" "grep" "rg" "git-grep") :language "scad"
- :regex "module\\s*JJJ\\s*\\\("
- :tests ("module test()" "module test ()"))
- ;; scala
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "scala"
- :regex "\\bval\\s*JJJ\\s*=[^=\\n]+" :tests ("val test = 1234") :not ("case test => 1234"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "scala"
- :regex "\\bvar\\s*JJJ\\s*=[^=\\n]+" :tests ("var test = 1234") :not ("case test => 1234"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "scala"
- :regex "\\btype\\s*JJJ\\s*=[^=\\n]+" :tests ("type test = 1234") :not ("case test => 1234"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "scala"
- :regex "\\bdef\\s*JJJ\\s*\\\("
- :tests ("def test(asdf)" "def test()"))
- (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "scala"
- :regex "class\\s*JJJ\\s*\\\(?"
- :tests ("class test(object)"))
- (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "scala"
- :regex "trait\\s*JJJ\\s*\\\(?"
- :tests ("trait test(object)"))
- (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "scala"
- :regex "object\\s*JJJ\\s*\\\(?"
- :tests ("object test(object)"))
- ;; solidity
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "solidity"
- :regex "function\\s*JJJ\\s*\\\("
- :tests ("function test() internal" "function test (uint x, address y)" "function test() external"))
- (:type "modifier" :supports ("ag" "grep" "rg" "git-grep") :language "solidity"
- :regex "modifier\\s*JJJ\\s*\\\("
- :tests ("modifier test()" "modifier test ()"))
- (:type "event" :supports ("ag" "grep" "rg" "git-grep") :language "solidity"
- :regex "event\\s*JJJ\\s*\\\("
- :tests ("event test();" "event test (uint indexed x)" "event test(uint x, address y)"))
- (:type "error" :supports ("ag" "grep" "rg" "git-grep") :language "solidity"
- :regex "error\\s*JJJ\\s*\\\("
- :tests ("error test();" "error test (uint x)" "error test(uint x, address y)"))
- ;; R
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "r"
- :regex "\\bJJJ\\s*=[^=><]" :tests ("test = 1234") :not ("if (test == 1234)"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "r"
- :regex "\\bJJJ\\s*<-\\s*function\\b"
- :tests ("test <- function" "test <- function(")
- :not ("test <- functionX"))
- ;; perl
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "perl"
- :regex "sub\\s*JJJ\\s*(\\{|\\()"
- :tests ("sub test{" "sub test {" "sub test(" "sub test ("))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "perl"
- :regex "JJJ\\s*=\\s*"
- :tests ("$test = 1234"))
- ;; Tcl
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "tcl"
- :regex "proc\\s+JJJ\\s*\\{"
- :tests ("proc test{" "proc test {"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "tcl"
- :regex "set\\s+JJJ"
- :tests ("set test 1234"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "tcl"
- :regex "(variable|global)\\s+JJJ"
- :tests ("variable test" "global test"))
- ;; shell
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "shell"
- :regex "function\\s*JJJ\\s*"
- :tests ("function test{" "function test {" "function test () {")
- :not ("function nottest {"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "shell"
- :regex "JJJ\\\(\\\)\\s*\\{"
- :tests ("test() {")
- :not ("testx() {"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "shell"
- :regex "\\bJJJ\\s*=\\s*"
- :tests ("test = 1234") :not ("blahtest = 1234"))
- ;; php
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "php"
- :regex "function\\s*JJJ\\s*\\\("
- :tests ("function test()" "function test ()"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "php"
- :regex "\\*\\s@method\\s+[^ \t]+\\s+JJJ\\("
- :tests ("/** @method string|false test($a)" " * @method bool test()"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "php"
- :regex "(\\s|->|\\$|::)JJJ\\s*=\\s*"
- :tests ("$test = 1234" "$foo->test = 1234"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "php"
- :regex "\\*\\s@property(-read|-write)?\\s+([^ \t]+\\s+)&?\\$JJJ(\\s+|$)"
- :tests ("/** @property string $test" "/** @property string $test description for $test property" " * @property-read bool|bool $test" " * @property-write \\ArrayObject<string,resource[]> $test"))
- (:type "trait" :supports ("ag" "grep" "rg" "git-grep") :language "php"
- :regex "trait\\s*JJJ\\s*\\\{"
- :tests ("trait test{" "trait test {"))
- (:type "interface" :supports ("ag" "grep" "rg" "git-grep") :language "php"
- :regex "interface\\s*JJJ\\s*\\\{"
- :tests ("interface test{" "interface test {"))
- (:type "class" :supports ("ag" "grep" "rg" "git-grep") :language "php"
- :regex "class\\s*JJJ\\s*(extends|implements|\\\{)"
- :tests ("class test{" "class test {" "class test extends foo" "class test implements foo"))
- ;; dart
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "dart"
- :regex "\\bJJJ\\s*\\([^()]*\\)\\s*[{]"
- :tests ("test(foo) {" "test (foo){" "test(foo){"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "dart"
- :regex "class\\s*JJJ\\s*[\\\(\\\{]"
- :tests ("class test(object) {" "class test{"))
- ;; faust
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "faust"
- :regex "\\bJJJ\(\\\(.+\\\)\)*\\s*="
- :tests ("test = osc + 0.5;" "test(freq) = osc(freq) + 0.5;"))
- ;; fennel
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "fennel"
- :regex "\\((local|var)\\s+JJJ\\j"
- :tests ("(local test (foo)"
- "(var test (foo)"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "fennel"
- :regex "\\(fn\\s+JJJ\\j"
- :tests ("(fn test [foo]")
- :not ("(fn test? [foo]"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "fennel"
- :regex "\\(macro\\s+JJJ\\j"
- :tests ("(macro test [foo]"))
- ;; fortran
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "fortran"
- :regex "\\s*\\bJJJ\\s*=[^=\\n]+"
- :tests ("test = 1234")
- :not ("if (test == 1234)"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "fortran"
- :regex "\\b(function|subroutine|FUNCTION|SUBROUTINE)\\s+JJJ\\b\\s*\\\("
- :tests ("function test (foo)" "integer function test(foo)"
- "subroutine test (foo, bar)" "FUNCTION test (foo)"
- "INTEGER FUNCTION test(foo)" "SUBROUTINE test (foo, bar)")
- :not ("end function test" "end subroutine test" "END FUNCTION test"
- "END SUBROUTINE test"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "fortran"
- :regex "^\\s*(interface|INTERFACE)\\s+JJJ\\b"
- :tests ("interface test" "INTERFACE test")
- :not ("interface test2" "end interface test" "INTERFACE test2"
- "END INTERFACE test"))
- (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "fortran"
- :regex "^\\s*(module|MODULE)\\s+JJJ\\s*"
- :tests ("module test" "MODULE test")
- :not ("end module test" "END MODULE test"))
- ;; go
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "go"
- :regex "\\s*\\bJJJ\\s*=[^=\\n]+" :tests ("test = 1234") :not ("if test == 1234 {"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "go"
- :regex "\\s*\\bJJJ\\s*:=\\s*" :tests ("test := 1234"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "go"
- :regex "func\\s+\\\([^\\\)]*\\\)\\s+JJJ\\s*\\\("
- :tests ("func (s *blah) test(filename string) string {"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "go"
- :regex "func\\s+JJJ\\s*\\\("
- :tests ("func test(url string) (string, error)"))
- (:type "type" :supports ("ag" "grep" "rg" "git-grep") :language "go"
- :regex "type\\s+JJJ\\s+struct\\s+\\\{"
- :tests ("type test struct {"))
- ;; javascript extended
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "javascript"
- :regex "(service|factory)\\\(['\"]JJJ['\"]" :tags ("angular")
- :tests ("module.factory('test', [\"$rootScope\", function($rootScope) {"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "javascript"
- :regex "\\bJJJ\\s*[=:]\\s*\\\([^\\\)]*\\\)\\s+=>" :tags ("es6")
- :tests ("const test = (foo) => " "test: (foo) => {" " test: (foo) => {"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "javascript"
- :regex "\\bJJJ\\s*\\([^()]*\\)\\s*[{]" :tags ("es6")
- :tests ("test(foo) {" "test (foo){" "test(foo){")
- :not ("test = blah.then(function(){"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "javascript" :tags ("es6")
- :regex "class\\s*JJJ\\s*[\\\(\\\{]"
- :tests ("class test(object) {" "class test{"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "javascript" :tags ("es6")
- :regex "class\\s*JJJ\\s+extends"
- :tests ("class test extends Component{"))
- ;; javascript
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "javascript"
- :regex "\\s*\\bJJJ\\s*=[^=\\n]+" :tests ("test = 1234" "const test = props =>") :not ("if (test === 1234)"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "javascript"
- :regex "\\bfunction\\b[^\\(]*\\\(\\s*[^\\)]*\\bJJJ\\b\\s*,?\\s*\\\)?"
- :tests ("function (test)" "function (test, blah)" "function somefunc(test, blah) {" "function(blah, test)")
- :not ("function (testLen)" "function (test1, blah)" "function somefunc(testFirst, blah) {" "function(blah, testLast)"
- "function (Lentest)" "function (blahtest, blah)" "function somefunc(Firsttest, blah) {" "function(blah, Lasttest)"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "javascript"
- :regex "function\\s*JJJ\\s*\\\("
- :tests ("function test()" "function test ()"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "javascript"
- :regex "\\bJJJ\\s*:\\s*function\\s*\\\("
- :tests ("test: function()"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "javascript"
- :regex "\\bJJJ\\s*=\\s*function\\s*\\\("
- :tests ("test = function()"))
- ;; hcl terraform
- (:type "block" :supports ("ag" "grep" "rg" "git-grep") :language "hcl"
- :regex "(variable|output|module)\\s*\"JJJ\"\\s*\\\{"
- :tests ("variable \"test\" {"
- "output \"test\" {"
- "module \"test\" {"))
- (:type "block" :supports ("ag" "grep" "rg" "git-grep") :language "hcl"
- :regex "(data|resource)\\s*\"\\w+\"\\s*\"JJJ\"\\s*\\\{"
- :tests ("data \"openstack_images_image_v2\" \"test\" {"
- "resource \"google_compute_instance\" \"test\" {"))
- ;; typescript
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "typescript"
- :regex "(service|factory)\\\(['\"]JJJ['\"]" :tags ("angular")
- :tests ("module.factory('test', [\"$rootScope\", function($rootScope) {"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "typescript"
- :regex "\\bJJJ\\s*[=:]\\s*\\\([^\\\)]*\\\)\\s+=>"
- :tests ("const test = (foo) => " "test: (foo) => {" " test: (foo) => {"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "typescript"
- :regex "\\bJJJ\\s*\\([^()]*\\)\\s*[{]"
- :tests ("test(foo) {" "test (foo){" "test(foo){")
- :not ("test = blah.then(function(){"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "typescript"
- :regex "class\\s*JJJ\\s*[\\\(\\\{]"
- :tests ("class test{"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "typescript"
- :regex "class\\s*JJJ\\s+extends"
- :tests ("class test extends Component{"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "typescript"
- :regex "function\\s*JJJ\\s*\\\("
- :tests ("function test()" "function test ()"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "typescript"
- :regex "\\bJJJ\\s*:\\s*function\\s*\\\("
- :tests ("test: function()"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "typescript"
- :regex "\\bJJJ\\s*=\\s*function\\s*\\\("
- :tests ("test = function()"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "typescript"
- :regex "\\s*\\bJJJ\\s*=[^=\\n]+" :tests ("test = 1234" "const test = props =>") :not ("if (test === 1234)"))
- (:type "variable" :supports ("ag" "grep" "rg" "git-grep") :language "typescript"
- :regex "\\bfunction\\b[^\\(]*\\\(\\s*[^\\)]*\\bJJJ\\b\\s*,?\\s*\\\)?"
- :tests ("function (test)" "function (test, blah)" "function somefunc(test, blah) {" "function(blah, test)")
- :not ("function (testLen)" "function (test1, blah)" "function somefunc(testFirst, blah) {" "function(blah, testLast)"
- "function (Lentest)" "function (blahtest, blah)" "function somefunc(Firsttest, blah) {" "function(blah, Lasttest)"))
- ;; julia
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "julia"
- :regex "(@noinline|@inline)?\\s*function\\s*JJJ(\\{[^\\}]*\\})?\\("
- :tests ("function test()" "@inline function test()"
- "function test{T}(h)"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "julia"
- :regex "(@noinline|@inline)?JJJ(\\{[^\\}]*\\})?\\([^\\)]*\\)\s*="
- :tests ("test(a)=1" "test(a,b)=1*8"
- "@noinline test()=1" "test{T}(x)=x"))
- (:type "function" :supports ("ag" "grep" "rg" "git-grep") :language "julia"
- :regex "macro\\s*JJJ\\("
- :tests ("macro test(a)=1" " macro test(a,b)=1*8"))
- (:type "variable" :supports ("ag" "rg") :language "julia"
- :regex "const\\s+JJJ\\b"
- :tests ("const test = "))
- (:type "type" :supports ("ag" "rg") :language "julia"
- :regex "(mutable)?\\s*struct\\s*JJJ"
- :tests ("struct test"))
- (:type "type" :supports ("ag" "rg") :language "julia"
- :regex "(type|immutable|abstract)\\s*JJJ"
- :tests ("type test" "immutable test" "abstract test <:Testable" ))
- ;; haskell
- (:type "module" :supports ("ag") :language "haskell"
- :regex "^module\\s+JJJ\\s+"
- :tests ("module Test (exportA, exportB) where"))
- ; TODO Doesn't support any '=' in arguments. E.g. 'foo A{a = b,..} = bar'.
- (:type "top level function" :supports ("ag") :language "haskell"
- :regex "^\\bJJJ(?!(\\s+::))\\s+((.|\\s)*?)=\\s+"
- :tests ("test n = n * 2"
- "test X{..} (Y a b c) \n bcd \n =\n x * y"
- "test ab cd e@Datatype {..} (Another thing, inTheRow) = \n undefined"
- "test = runRealBasedMode @ext @ctx identity identity"
- "test unwrap wrap nr@Naoeu {..} (Action action, specSpecs) = \n undefined")
- :not ("nottest n = n * 2"
- "let testnot x y = x * y" "test $ y z" "let test a o = mda"
- "test :: Sometype -> AnotherType aoeu kek = undefined"))
- (:type "type-like" :supports ("ag") :language "haskell"
- :regex "^\\s*((data(\\s+family)?)|(newtype)|(type(\\s+family)?))\\s+JJJ\\s+"
- :tests ("newtype Test a = Something { b :: Kek }"
- "data Test a b = Somecase a | Otherca