123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- (require 'semantic/db)
- (require 'semantic/db-find)
- (eval-when-compile
-
- (require 'eieio)
- (require 'eieio-opt))
- (defvar semanticdb-javascript-tags
- '(("eval" function
- (:arguments
- (("x" variable nil nil nil)))
- nil nil)
- ("parseInt" function
- (:arguments
- (("string" variable nil nil nil)
- ("radix" variable nil nil nil)))
- nil nil)
- ("parseFloat" function
- (:arguments
- (("string" variable nil nil nil)))
- nil nil)
- ("isNaN" function
- (:arguments
- (("number" variable nil nil nil)))
- nil nil)
- ("isFinite" function
- (:arguments
- (("number" variable nil nil nil)))
- nil nil)
- ("decodeURI" function
- (:arguments
- (("encodedURI" variable nil nil nil)))
- nil nil)
- ("decodeURIComponent" function
- (:arguments
- (("encodedURIComponent" variable nil nil nil)))
- nil nil)
- ("encodeURI" function
- (:arguments
- (("uri" variable nil nil nil)))
- nil nil)
- ("encodeURIComponent" function
- (:arguments
- (("uriComponent" variable nil nil nil)))
- nil nil))
- "Hard-coded list of javascript tags for semanticdb.
- See bottom of this file for instructions on managing this list.")
- (defclass semanticdb-table-javascript (semanticdb-search-results-table)
- ((major-mode :initform javascript-mode)
- )
- "A table for returning search results from javascript.")
- (defclass semanticdb-project-database-javascript
- (semanticdb-project-database
- eieio-singleton
- )
- ((new-table-class :initform semanticdb-table-javascript
- :type class
- :documentation
- "New tables created for this database are of this class.")
- )
- "Database representing javascript.")
- (defvar-mode-local javascript-mode semanticdb-project-system-databases
- (list
- (semanticdb-project-database-javascript "Javascript"))
- "Search javascript for symbols.")
- (defvar-mode-local javascript-mode semanticdb-find-default-throttle
- '(project omniscience)
- "Search project files, then search this omniscience database.
- It is not necessary to do system or recursive searching because of
- the omniscience database.")
- (defmethod semanticdb-get-database-tables ((obj semanticdb-project-database-javascript))
- "For a javascript database, there are no explicit tables.
- Create one of our special tables that can act as an intermediary."
-
-
-
-
-
- (when (not (slot-boundp obj 'tables))
- (let ((newtable (semanticdb-table-javascript "tmp")))
- (oset obj tables (list newtable))
- (oset newtable parent-db obj)
- (oset newtable tags nil)
- ))
- (call-next-method)
- )
- (defmethod semanticdb-file-table ((obj semanticdb-project-database-javascript) filename)
- "From OBJ, return FILENAME's associated table object."
-
- (car (semanticdb-get-database-tables obj))
- )
- (defmethod semanticdb-get-tags ((table semanticdb-table-javascript ))
- "Return the list of tags belonging to TABLE."
-
-
-
- semanticdb-javascript-tags)
- (defmethod semanticdb-equivalent-mode ((table semanticdb-table-javascript) &optional buffer)
- "Return non-nil if TABLE's mode is equivalent to BUFFER.
- Equivalent modes are specified by the `semantic-equivalent-major-modes'
- local variable."
- (with-current-buffer buffer
- (eq (or mode-local-active-mode major-mode) 'javascript-mode)))
- (define-mode-local-override semanticdb-find-translate-path javascript-mode
- (path brutish)
- "Return a list of semanticdb tables associated with PATH.
- If brutish, do the default action.
- If not brutish, do the default action, and append the system
- database (if available.)"
- (let ((default
-
-
-
- (let ((semanticdb-search-system-databases nil)
- )
- (semanticdb-find-translate-path-default path brutish))))
-
-
- (if (or brutish (not semanticdb-search-system-databases))
- default
- (let ((tables (apply #'append
- (mapcar
- (lambda (db) (semanticdb-get-database-tables db))
- semanticdb-project-system-databases))))
- (append default tables)))))
- (defun semanticdb-javascript-regexp-search (regexp)
- "Search for REGEXP in our fixed list of javascript tags."
- (let* ((tags semanticdb-javascript-tags)
- (result nil))
- (while tags
- (if (string-match regexp (caar tags))
- (setq result (cons (car tags) result)))
- (setq tags (cdr tags)))
- result))
- (defmethod semanticdb-find-tags-by-name-method
- ((table semanticdb-table-javascript) name &optional tags)
- "Find all tags named NAME in TABLE.
- Return a list of tags."
- (if tags
-
- (call-next-method)
- (assoc-string name semanticdb-javascript-tags)
- ))
- (defmethod semanticdb-find-tags-by-name-regexp-method
- ((table semanticdb-table-javascript) regex &optional tags)
- "Find all tags with name matching REGEX in TABLE.
- Optional argument TAGS is a list of tags to search.
- Return a list of tags."
- (if tags (call-next-method)
-
- (semanticdb-javascript-regexp-search regex)
- ))
- (defmethod semanticdb-find-tags-for-completion-method
- ((table semanticdb-table-javascript) prefix &optional tags)
- "In TABLE, find all occurrences of tags matching PREFIX.
- Optional argument TAGS is a list of tags to search.
- Returns a table of all matching tags."
- (if tags (call-next-method)
-
- (semanticdb-javascript-regexp-search (concat "^" prefix ".*"))
- ))
- (defmethod semanticdb-find-tags-by-class-method
- ((table semanticdb-table-javascript) class &optional tags)
- "In TABLE, find all occurrences of tags of CLASS.
- Optional argument TAGS is a list of tags to search.
- Returns a table of all matching tags."
- (if tags (call-next-method)
-
-
-
-
-
-
-
- nil))
- (defmethod semanticdb-deep-find-tags-by-name-method
- ((table semanticdb-table-javascript) name &optional tags)
- "Find all tags name NAME in TABLE.
- Optional argument TAGS is a list of tags to search.
- Like `semanticdb-find-tags-by-name-method' for javascript."
- (semanticdb-find-tags-by-name-method table name tags))
- (defmethod semanticdb-deep-find-tags-by-name-regexp-method
- ((table semanticdb-table-javascript) regex &optional tags)
- "Find all tags with name matching REGEX in TABLE.
- Optional argument TAGS is a list of tags to search.
- Like `semanticdb-find-tags-by-name-method' for javascript."
- (semanticdb-find-tags-by-name-regexp-method table regex tags))
- (defmethod semanticdb-deep-find-tags-for-completion-method
- ((table semanticdb-table-javascript) prefix &optional tags)
- "In TABLE, find all occurrences of tags matching PREFIX.
- Optional argument TAGS is a list of tags to search.
- Like `semanticdb-find-tags-for-completion-method' for javascript."
- (semanticdb-find-tags-for-completion-method table prefix tags))
- (defmethod semanticdb-find-tags-external-children-of-type-method
- ((table semanticdb-table-javascript) type &optional tags)
- "Find all nonterminals which are child elements of TYPE.
- Optional argument TAGS is a list of tags to search.
- Return a list of tags."
- (if tags (call-next-method)
-
-
-
-
-
-
-
- ))
- (defun semanticdb-javascript-strip-tags (tags)
- "Strip TAGS from overlays and reparse symbols."
- (cond ((and (consp tags) (eq 'reparse-symbol (car tags)))
- nil)
- ((overlayp tags) nil)
- ((atom tags) tags)
- (t (cons (semanticdb-javascript-strip-tags
- (car tags)) (semanticdb-javascript-strip-tags
- (cdr tags))))))
- (provide 'semantic/db-javascript)
|