annotate lisp/cedet/semantic/wisent/javascript.el @ 105804:91f3ea36baf8

Suppress harmless warnings about setting up semantic-imenu (not part of Emacs) variables.
author Glenn Morris <rgm@gnu.org>
date Sat, 31 Oct 2009 02:03:19 +0000
parents 7f4c7f5c0eba
children 83dde921cc1b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104478
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1 ;;; semantic/wisent/javascript.el --- javascript parser support
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
105291
46dfe0d3bb5c Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 104506
diff changeset
3 ;; Copyright (C) 2005, 2009 Free Software Foundation, Inc.
104478
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
4
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5 ;; Author: Eric Ludlam <zappo@gnu.org>
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
6 ;; Keywords: syntax
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12 ;; the Free Software Foundation, either version 3 of the License, or
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
13 ;; (at your option) any later version.
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
14
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18 ;; GNU General Public License for more details.
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23 ;;; Commentary:
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 ;;
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25 ;; Parser support for javascript language.
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28 ;;; Code:
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29 (require 'semantic/java)
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 (require 'semantic/wisent)
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 (require 'semantic/wisent/js-wy)
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33 (defun wisent-javascript-jv-expand-tag (tag)
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 "Expand TAG into a list of equivalent tags, or nil.
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35 Expand multiple variable declarations in the same statement, that is
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36 tags of class `variable' whose name is equal to a list of elements of
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37 the form (NAME VALUE START . END). NAME is a variable name. VALUE is
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38 an initializer START and END are the bounds in the declaration, related
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39 to this variable NAME."
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40 (let (elts elt value clone start end xpand)
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 (when (and (eq 'variable (semantic-tag-class tag))
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
42 (consp (setq elts (semantic-tag-name tag))))
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 ;; There are multiple names in the same variable declaration.
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 (while elts
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45 ;; For each name element, clone the initial tag and give it
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
46 ;; the name of the element.
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 (setq elt (car elts)
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48 elts (cdr elts)
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 clone (semantic-tag-clone tag (car elt))
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 value (car (cdr elt))
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51 start (if elts (caddr elt) (semantic-tag-start tag))
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 end (if xpand (cdddr elt) (semantic-tag-end tag))
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53 xpand (cons clone xpand))
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54 ;; Set the definition of the cloned tag
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 (semantic-tag-put-attribute clone :default-value value)
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 ;; Set the bounds of the cloned tag with those of the name
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57 ;; element.
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 (semantic-tag-set-bounds clone start end))
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59 xpand)))
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 ;;; Override Methods
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62 ;;
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 ;; These methods override aspects of how semantic-tools can access
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 ;; the tags created by the javascript parser.
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65 ;; Local context
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66 (define-mode-overload-implementation semantic-get-local-variables
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 javascript-mode ()
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68 "Get local values from a specific context.
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69 This function overrides `get-local-variables'."
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 ;; Does javascript have identifiable local variables?
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 nil)
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74 ;;; Setup Function
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 ;;
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76 ;; This sets up the javascript parser
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77
105804
91f3ea36baf8 Suppress harmless warnings about setting up semantic-imenu (not part
Glenn Morris <rgm@gnu.org>
parents: 105377
diff changeset
78 ;; In semantic-imenu.el, not part of Emacs.
91f3ea36baf8 Suppress harmless warnings about setting up semantic-imenu (not part
Glenn Morris <rgm@gnu.org>
parents: 105377
diff changeset
79 (defvar semantic-imenu-summary-function)
91f3ea36baf8 Suppress harmless warnings about setting up semantic-imenu (not part
Glenn Morris <rgm@gnu.org>
parents: 105377
diff changeset
80
104478
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 ;;;###autoload
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82 (defun wisent-javascript-setup-parser ()
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83 "Setup buffer for parse."
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84 (wisent-javascript-jv-wy--install-parser)
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 (setq
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
86 ;; Lexical Analysis
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 semantic-lex-analyzer 'javascript-lexer-jv
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88 semantic-lex-number-expression semantic-java-number-regexp
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
89 ;; semantic-lex-depth nil ;; Full lexical analysis
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 ;; Parsing
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91 semantic-tag-expand-function 'wisent-javascript-jv-expand-tag
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 ;; Environment
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 semantic-imenu-summary-function 'semantic-format-tag-name
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 imenu-create-index-function 'semantic-create-imenu-index
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95 semantic-command-separation-character ";"
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96 ))
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98 (provide 'semantic/wisent/javascript-jv)
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 ;; Local variables:
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 ;; generated-autoload-file: "../loaddefs.el"
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 ;; generated-autoload-feature: semantic/loaddefs
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 ;; generated-autoload-load-name: "semantic/wisent/javascript"
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104 ;; End:
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
105
105377
7f4c7f5c0eba Add arch tagline
Miles Bader <miles@gnu.org>
parents: 105291
diff changeset
106 ;; arch-tag: 15416a3a-84ca-4b3b-a13c-e7a1891ec3ea
104478
8b129ef893a2 lisp/cedet/semantic/wisent/comp.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107 ;;; semantic/wisent/javascript-jv.el ends here