Function: js--pitem-type
js--pitem-type is a byte-compiled function defined in js.el.gz.
Signature
(js--pitem-type CL-X)
Documentation
Access slot "type" of js--pitem struct CL-X.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/js.el.gz
;; js--pitem is the basic building block of the lexical
;; database. When one refers to a real part of the buffer, the region
;; of text to which it refers is split into a conceptual header and
;; body. Consider the (very short) block described by a hypothetical
;; js--pitem:
;;
;; function foo(a,b,c) { return 42; }
;; ^ ^ ^
;; | | |
;; +- h-begin +- h-end +- b-end
;;
;; (Remember that these are buffer positions, and therefore point
;; between characters, not at them. An arrow drawn to a character
;; indicates the corresponding position is between that character and
;; the one immediately preceding it.)
;;
;; The header is the region of text [h-begin, h-end], and is
;; the text needed to unambiguously recognize the start of the
;; construct. If the entire header is not present, the construct is
;; not recognized at all. No other pitems may be nested inside the
;; header.
;;
;; The body is the region [h-end, b-end]. It may contain nested
;; js--pitem instances. The body of a pitem may be empty: in
;; that case, b-end is equal to header-end.
;;
;; The three points obey the following relationship:
;;
;; h-begin < h-end <= b-end
;;
;; We put a text property in the buffer on the character *before*
;; h-end, and if we see it, on the character *before* b-end.
;;
;; The text property for h-end, js--pstate, is actually a list
;; of all js--pitem instances open after the marked character.
;;
;; The text property for b-end, js--pend, is simply the
;; js--pitem that ends after the marked character. (Because
;; pitems always end when the paren-depth drops below a critical
;; value, and because we can only drop one level per character, only
;; one pitem may end at a given character.)
;;
;; In the structure below, we only store h-begin and (sometimes)
;; b-end. We can trivially and quickly find h-end by going to h-begin
;; and searching for an js--pstate text property. Since no other
;; js--pitem instances can be nested inside the header of a
;; pitem, the location after the character with this text property
;; must be h-end.
;;
;; js--pitem instances are never modified (with the exception
;; of the b-end field). Instead, modified copies are added at
;; subsequence parse points.
;; (The exception for b-end and its caveats is described below.)
;;
(cl-defstruct (js--pitem (:type list))
;; IMPORTANT: Do not alter the position of fields within the list.
;; Various bits of code depend on their positions, particularly
;; anything that manipulates the list of children.
;; List of children inside this pitem's body
(children nil :read-only t)
;; When we reach this paren depth after h-end, the pitem ends
(paren-depth nil :read-only t)
;; Symbol or class-style plist if this is a class
(type nil :read-only t)
;; See above
(h-begin nil :read-only t)
;; List of strings giving the parts of the name of this pitem (e.g.,
;; '("MyClass" "myMethod"), or t if this pitem is anonymous
(name nil :read-only t)
;; THIS FIELD IS MUTATED, and its value is shared by all copies of
;; this pitem: when we copy-and-modify pitem instances, we share
;; their tail structures, so all the copies actually have the same
;; terminating cons cell. We modify that shared cons cell directly.
;;
;; The field value is either a number (buffer location) or nil if
;; unknown.
;;
;; If the field's value is greater than `js--cache-end', the
;; value is stale and must be treated as if it were nil. Conversely,
;; if this field is nil, it is guaranteed that this pitem is open up
;; to at least `js--cache-end'. (This property is handy when
;; computing whether we're inside a given pitem.)
;;
(b-end nil))