Mercurial > emacs
annotate lisp/cedet/semantic/edit.el @ 109461:d898f8a84d48
Enhance `c-file-style' in file/directory local variables.
cc-mode.el (c-count-cfss): New function.
(c-before-hack-hook): Call `c-set-style' differently according to whether
c-file-style was set in file or directory local variables.
author | Alan Mackenzie <acm@muc.de> |
---|---|
date | Sun, 18 Jul 2010 20:28:00 +0000 |
parents | 5df8e547a422 |
children | 376148b31b5e |
rev | line source |
---|---|
104442
b22b44e953cb
cedet/semantic/chart.el: Don't require semantic/find.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1 ;;; semantic/edit.el --- Edit Management for Semantic |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2 |
105340 | 3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, |
106815 | 4 ;; 2008, 2009, 2010 Free Software Foundation, Inc. |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
5 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
6 ;; Author: Eric M. Ludlam <zappo@gnu.org> |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
7 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
8 ;; This file is part of GNU Emacs. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
9 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
11 ;; it under the terms of the GNU General Public License as published by |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
12 ;; the Free Software Foundation, either version 3 of the License, or |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
13 ;; (at your option) any later version. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
14 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
15 ;; GNU Emacs is distributed in the hope that it will be useful, |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
18 ;; GNU General Public License for more details. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
19 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
20 ;; You should have received a copy of the GNU General Public License |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
22 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
23 ;;; Commentary: |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
24 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
25 ;; In Semantic 1.x, changes were handled in a simplistic manner, where |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
26 ;; tags that changed were reparsed one at a time. Any other form of |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
27 ;; edit were managed through a full reparse. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
28 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
29 ;; This code attempts to minimize the number of times a full reparse |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
30 ;; needs to occur. While overlays and tags will continue to be |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
31 ;; recycled in the simple case, new cases where tags are inserted |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
32 ;; or old tags removed from the original list are handled. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
33 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
34 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
35 ;;; NOTES FOR IMPROVEMENT |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
36 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
37 ;; Work done by the incremental parser could be improved by the |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
38 ;; following: |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
39 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
40 ;; 1. Tags created could have as a property an overlay marking a region |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
41 ;; of themselves that can be edited w/out affecting the definition of |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
42 ;; that tag. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
43 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
44 ;; 2. Tags w/ positioned children could have a property of an |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
45 ;; overlay marking the region in themselves that contain the |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
46 ;; children. This could be used to better improve splicing near |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
47 ;; the beginning and end of the child lists. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
48 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
49 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
50 ;;; BUGS IN INCREMENTAL PARSER |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
51 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
52 ;; 1. Changes in the whitespace between tags could extend a |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
53 ;; following tag. These will be marked as merely unmatched |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
54 ;; syntax instead. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
55 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
56 ;; 2. Incremental parsing while a new function is being typed in |
105340 | 57 ;; sometimes gets a chance only when lists are incomplete, |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
58 ;; preventing correct context identification. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
59 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
60 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
61 (require 'semantic) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
62 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
63 ;;; Code: |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
64 (defvar semantic-after-partial-cache-change-hook nil |
104513
a6a812dd2d88
* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
104472
diff
changeset
|
65 "Normal hook run after the buffer cache has been updated. |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
66 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
67 This hook will run when the cache has been partially reparsed. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
68 Partial reparses are incurred when a user edits a buffer, and only the |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
69 modified sections are rescanned. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
70 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
71 Hook functions must take one argument, which is the list of tags |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
72 updated in the current buffer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
73 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
74 For language specific hooks, make sure you define this as a local hook.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
75 |
104519
934691bc93ed
* cedet/semantic/idle.el (semantic-idle-scheduler-work-timer):
Chong Yidong <cyd@stupidchicken.com>
parents:
104517
diff
changeset
|
76 (defvar semantic-change-hooks |
934691bc93ed
* cedet/semantic/idle.el (semantic-idle-scheduler-work-timer):
Chong Yidong <cyd@stupidchicken.com>
parents:
104517
diff
changeset
|
77 '(semantic-edits-change-function-handle-changes) |
104513
a6a812dd2d88
* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
104472
diff
changeset
|
78 "Abnormal hook run when semantic detects a change in a buffer. |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
79 Each hook function must take three arguments, identical to the |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
80 common hook `after-change-functions'.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
81 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
82 (defvar semantic-reparse-needed-change-hook nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
83 "Hooks run when a user edit is detected as needing a reparse. |
106840
5df8e547a422
Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
84 For language specific hooks, make sure you define this as a local hook. |
5df8e547a422
Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
85 Not used yet; part of the next generation reparse mechanism.") |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
86 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
87 (defvar semantic-no-reparse-needed-change-hook nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
88 "Hooks run when a user edit is detected as not needing a reparse. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
89 If the hook returns non-nil, then declare that a reparse is needed. |
106840
5df8e547a422
Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
90 For language specific hooks, make sure you define this as a local hook. |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
91 Not used yet; part of the next generation reparse mechanism.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
92 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
93 (defvar semantic-edits-new-change-hooks nil |
104513
a6a812dd2d88
* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
104472
diff
changeset
|
94 "Abnormal hook run when a new change is found. |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
95 Functions must take one argument representing an overlay on that change.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
96 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
97 (defvar semantic-edits-delete-change-hooks nil |
104513
a6a812dd2d88
* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
104472
diff
changeset
|
98 "Abnormal hook run before a change overlay is deleted. |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
99 Deleted changes occur when multiple changes are merged. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
100 Functions must take one argument representing an overlay being deleted.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
101 |
104513
a6a812dd2d88
* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
104472
diff
changeset
|
102 (defvar semantic-edits-move-change-hook nil |
a6a812dd2d88
* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
104472
diff
changeset
|
103 "Abnormal hook run after a change overlay is moved. |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
104 Changes move when a new change overlaps an old change. The old change |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
105 will be moved. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
106 Functions must take one argument representing an overlay being moved.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
107 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
108 (defvar semantic-edits-reparse-change-hooks nil |
104513
a6a812dd2d88
* cedet/semantic/lex.el (semantic-lex-reset-hooks): Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents:
104472
diff
changeset
|
109 "Abnormal hook run after a change results in a reparse. |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
110 Functions are called before the overlay is deleted, and after the |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
111 incremental reparse.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
112 |
104517
beb4db733a34
* cedet/semantic/edit.el
Chong Yidong <cyd@stupidchicken.com>
parents:
104513
diff
changeset
|
113 (defvar semantic-edits-incremental-reparse-failed-hook nil |
beb4db733a34
* cedet/semantic/edit.el
Chong Yidong <cyd@stupidchicken.com>
parents:
104513
diff
changeset
|
114 "Hook run after the incremental parser fails. |
105340 | 115 When this happens, the buffer is marked as needing a full reparse.") |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
116 |
104517
beb4db733a34
* cedet/semantic/edit.el
Chong Yidong <cyd@stupidchicken.com>
parents:
104513
diff
changeset
|
117 (semantic-varalias-obsolete 'semantic-edits-incremental-reparse-failed-hooks |
105760
d0906291f75b
* cedet/semantic/fw.el (semantic-alias-obsolete)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105377
diff
changeset
|
118 'semantic-edits-incremental-reparse-failed-hook "23.2") |
104517
beb4db733a34
* cedet/semantic/edit.el
Chong Yidong <cyd@stupidchicken.com>
parents:
104513
diff
changeset
|
119 |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
120 (defcustom semantic-edits-verbose-flag nil |
105340 | 121 "Non-nil means the incremental parser is verbose. |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
122 If nil, errors are still displayed, but informative messages are not." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
123 :group 'semantic |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
124 :type 'boolean) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
125 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
126 ;;; Change State management |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
127 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
128 ;; Manage a series of overlays that define changes recently |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
129 ;; made to the current buffer. |
104472
552b3b560245
lisp/cedet/semantic/edit.el (semantic-change-function): Autoload.
Chong Yidong <cyd@stupidchicken.com>
parents:
104450
diff
changeset
|
130 ;;;###autoload |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
131 (defun semantic-change-function (start end length) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
132 "Provide a mechanism for semantic tag management. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
133 Argument START, END, and LENGTH specify the bounds of the change." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
134 (setq semantic-unmatched-syntax-cache-check t) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
135 (let ((inhibit-point-motion-hooks t) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
136 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
137 (run-hook-with-args 'semantic-change-hooks start end length) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
138 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
139 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
140 (defun semantic-changes-in-region (start end &optional buffer) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
141 "Find change overlays which exist in whole or in part between START and END. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
142 Optional argument BUFFER is the buffer to search for changes in." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
143 (save-excursion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
144 (if buffer (set-buffer buffer)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
145 (let ((ol (semantic-overlays-in (max start (point-min)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
146 (min end (point-max)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
147 (ret nil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
148 (while ol |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
149 (when (semantic-overlay-get (car ol) 'semantic-change) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
150 (setq ret (cons (car ol) ret))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
151 (setq ol (cdr ol))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
152 (sort ret #'(lambda (a b) (< (semantic-overlay-start a) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
153 (semantic-overlay-start b))))))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
154 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
155 (defun semantic-edits-change-function-handle-changes (start end length) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
156 "Run whenever a buffer controlled by `semantic-mode' change. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
157 Tracks when and how the buffer is re-parsed. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
158 Argument START, END, and LENGTH specify the bounds of the change." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
159 ;; We move start/end by one so that we can merge changes that occur |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
160 ;; just before, or just after. This lets simple typing capture everything |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
161 ;; into one overlay. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
162 (let ((changes-in-change (semantic-changes-in-region (1- start) (1+ end))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
163 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
164 (semantic-parse-tree-set-needs-update) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
165 (if (not changes-in-change) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
166 (let ((o (semantic-make-overlay start end))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
167 (semantic-overlay-put o 'semantic-change t) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
168 ;; Run the hooks safely. When hooks blow it, our dirty |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
169 ;; function will be removed from the list of active change |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
170 ;; functions. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
171 (condition-case nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
172 (run-hook-with-args 'semantic-edits-new-change-hooks o) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
173 (error nil))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
174 (let ((tmp changes-in-change)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
175 ;; Find greatest bounds of all changes |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
176 (while tmp |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
177 (when (< (semantic-overlay-start (car tmp)) start) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
178 (setq start (semantic-overlay-start (car tmp)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
179 (when (> (semantic-overlay-end (car tmp)) end) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
180 (setq end (semantic-overlay-end (car tmp)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
181 (setq tmp (cdr tmp))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
182 ;; Move the first found overlay, recycling that overlay. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
183 (semantic-overlay-move (car changes-in-change) start end) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
184 (condition-case nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
185 (run-hook-with-args 'semantic-edits-move-change-hooks |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
186 (car changes-in-change)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
187 (error nil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
188 (setq changes-in-change (cdr changes-in-change)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
189 ;; Delete other changes. They are now all bound here. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
190 (while changes-in-change |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
191 (condition-case nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
192 (run-hook-with-args 'semantic-edits-delete-change-hooks |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
193 (car changes-in-change)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
194 (error nil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
195 (semantic-overlay-delete (car changes-in-change)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
196 (setq changes-in-change (cdr changes-in-change)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
197 ))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
198 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
199 (defsubst semantic-edits-flush-change (change) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
200 "Flush the CHANGE overlay." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
201 (condition-case nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
202 (run-hook-with-args 'semantic-edits-delete-change-hooks |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
203 change) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
204 (error nil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
205 (semantic-overlay-delete change)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
206 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
207 (defun semantic-edits-flush-changes () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
208 "Flush the changes in the current buffer." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
209 (let ((changes (semantic-changes-in-region (point-min) (point-max)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
210 (while changes |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
211 (semantic-edits-flush-change (car changes)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
212 (setq changes (cdr changes)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
213 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
214 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
215 (defun semantic-edits-change-in-one-tag-p (change hits) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
216 "Return non-nil of the overlay CHANGE exists solely in one leaf tag. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
217 HITS is the list of tags that CHANGE is in. It can have more than |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
218 one tag in it if the leaf tag is within a parent tag." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
219 (and (< (semantic-tag-start (car hits)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
220 (semantic-overlay-start change)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
221 (> (semantic-tag-end (car hits)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
222 (semantic-overlay-end change)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
223 ;; Recurse on the rest. If this change is inside all |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
224 ;; of these tags, then they are all leaves or parents |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
225 ;; of the smallest tag. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
226 (or (not (cdr hits)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
227 (semantic-edits-change-in-one-tag-p change (cdr hits)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
228 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
229 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
230 ;;; Change/Tag Query functions |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
231 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
232 ;; A change (region of space) can effect tags in different ways. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
233 ;; These functions perform queries on a buffer to determine different |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
234 ;; ways that a change effects a buffer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
235 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
236 ;; NOTE: After debugging these, replace below to no longer look |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
237 ;; at point and mark (via comments I assume.) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
238 (defsubst semantic-edits-os (change) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
239 "For testing: Start of CHANGE, or smaller of (point) and (mark)." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
240 (if change (semantic-overlay-start change) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
241 (if (< (point) (mark)) (point) (mark)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
242 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
243 (defsubst semantic-edits-oe (change) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
244 "For testing: End of CHANGE, or larger of (point) and (mark)." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
245 (if change (semantic-overlay-end change) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
246 (if (> (point) (mark)) (point) (mark)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
247 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
248 (defun semantic-edits-change-leaf-tag (change) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
249 "A leaf tag which completely encompasses CHANGE. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
250 If change overlaps a tag, but is not encompassed in it, return nil. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
251 Use `semantic-edits-change-overlap-leaf-tag'. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
252 If CHANGE is completely encompassed in a tag, but overlaps sub-tags, |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
253 return nil." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
254 (let* ((start (semantic-edits-os change)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
255 (end (semantic-edits-oe change)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
256 (tags (nreverse |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
257 (semantic-find-tag-by-overlay-in-region |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
258 start end)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
259 ;; A leaf is always first in this list |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
260 (if (and tags |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
261 (<= (semantic-tag-start (car tags)) start) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
262 (> (semantic-tag-end (car tags)) end)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
263 ;; Ok, we have a match. If this tag has children, |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
264 ;; we have to do more tests. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
265 (let ((chil (semantic-tag-components (car tags)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
266 (if (not chil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
267 ;; Simple leaf. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
268 (car tags) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
269 ;; For this type, we say that we encompass it if the |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
270 ;; change occurs outside the range of the children. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
271 (if (or (not (semantic-tag-with-position-p (car chil))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
272 (> start (semantic-tag-end (nth (1- (length chil)) chil))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
273 (< end (semantic-tag-start (car chil)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
274 ;; We have modifications to the definition of this parent |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
275 ;; so we have to reparse the whole thing. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
276 (car tags) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
277 ;; We actually modified an area between some children. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
278 ;; This means we should return nil, as that case is |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
279 ;; calculated by someone else. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
280 nil))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
281 nil))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
282 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
283 (defun semantic-edits-change-between-tags (change) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
284 "Return a cache list of tags surrounding CHANGE. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
285 The returned list is the CONS cell in the master list pointing to |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
286 a tag just before CHANGE. The CDR will have the tag just after CHANGE. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
287 CHANGE cannot encompass or overlap a leaf tag. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
288 If CHANGE is fully encompassed in a tag that has children, and |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
289 this change occurs between those children, this returns non-nil. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
290 See `semantic-edits-change-leaf-tag' for details on parents." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
291 (let* ((start (semantic-edits-os change)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
292 (end (semantic-edits-oe change)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
293 (tags (nreverse |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
294 (semantic-find-tag-by-overlay-in-region |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
295 start end))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
296 (list-to-search nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
297 (found nil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
298 (if (not tags) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
299 (setq list-to-search semantic--buffer-cache) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
300 ;; A leaf is always first in this list |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
301 (if (and (< (semantic-tag-start (car tags)) start) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
302 (> (semantic-tag-end (car tags)) end)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
303 ;; We are completely encompassed in a tag. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
304 (if (setq list-to-search |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
305 (semantic-tag-components (car tags))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
306 ;; Ok, we are completely encompassed within the first tag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
307 ;; entry, AND that tag has children. This means that change |
106840
5df8e547a422
Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
308 ;; occurred outside of all children, but inside some tag |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
309 ;; with children. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
310 (if (or (not (semantic-tag-with-position-p (car list-to-search))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
311 (> start (semantic-tag-end |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
312 (nth (1- (length list-to-search)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
313 list-to-search))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
314 (< end (semantic-tag-start (car list-to-search)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
315 ;; We have modifications to the definition of this parent |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
316 ;; and not between it's children. Clear the search list. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
317 (setq list-to-search nil))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
318 ;; Search list is nil. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
319 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
320 ;; If we have a search list, lets go. Otherwise nothing. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
321 (while (and list-to-search (not found)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
322 (if (cdr list-to-search) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
323 ;; We end when the start of the CDR is after the end of our |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
324 ;; asked change. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
325 (if (< (semantic-tag-start (cadr list-to-search)) end) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
326 (setq list-to-search (cdr list-to-search)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
327 (setq found t)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
328 (setq list-to-search nil))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
329 ;; Return it. If it is nil, there is a logic bug, and we need |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
330 ;; to avoid this bit of logic anyway. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
331 list-to-search |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
332 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
333 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
334 (defun semantic-edits-change-over-tags (change) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
335 "Return a cache list of tags surrounding a CHANGE encompassing tags. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
336 CHANGE must not only include all overlapped tags (excepting possible |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
337 parent tags) in their entirety. In this case, the change may be deleting |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
338 or moving whole tags. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
339 The return value is a vector. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
340 Cell 0 is a list of all tags completely encompassed in change. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
341 Cell 1 is the cons cell into a master parser cache starting with |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
342 the cell which occurs BEFORE the first position of CHANGE. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
343 Cell 2 is the parent of cell 1, or nil for the buffer cache. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
344 This function returns nil if any tag covered by change is not |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
345 completely encompassed. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
346 See `semantic-edits-change-leaf-tag' for details on parents." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
347 (let* ((start (semantic-edits-os change)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
348 (end (semantic-edits-oe change)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
349 (tags (nreverse |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
350 (semantic-find-tag-by-overlay-in-region |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
351 start end))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
352 (parent nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
353 (overlapped-tags nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
354 inner-start inner-end |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
355 (list-to-search nil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
356 ;; By the time this is already called, we know that it is |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
357 ;; not a leaf change, nor a between tag change. That leaves |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
358 ;; an overlap, and this condition. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
359 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
360 ;; A leaf is always first in this list. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
361 ;; Is the leaf encompassed in this change? |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
362 (if (and tags |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
363 (>= (semantic-tag-start (car tags)) start) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
364 (<= (semantic-tag-end (car tags)) end)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
365 (progn |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
366 ;; We encompass one whole change. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
367 (setq overlapped-tags (list (car tags)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
368 inner-start (semantic-tag-start (car tags)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
369 inner-end (semantic-tag-end (car tags)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
370 tags (cdr tags)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
371 ;; Keep looping while tags are inside the change. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
372 (while (and tags |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
373 (>= (semantic-tag-start (car tags)) start) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
374 (<= (semantic-tag-end (car tags)) end)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
375 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
376 ;; Check if this new all-encompassing tag is a parent |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
377 ;; of that which went before. Only check end because |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
378 ;; we know that start is less than inner-start since |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
379 ;; tags was sorted on that. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
380 (if (> (semantic-tag-end (car tags)) inner-end) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
381 ;; This is a parent. Drop the children found |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
382 ;; so far. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
383 (setq overlapped-tags (list (car tags)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
384 inner-start (semantic-tag-start (car tags)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
385 inner-end (semantic-tag-end (car tags)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
386 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
387 ;; It is not a parent encompassing tag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
388 (setq overlapped-tags (cons (car tags) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
389 overlapped-tags) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
390 inner-start (semantic-tag-start (car tags)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
391 (setq tags (cdr tags))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
392 (if (not tags) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
393 ;; There are no tags left, and all tags originally |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
394 ;; found are encompassed by the change. Setup our list |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
395 ;; from the cache |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
396 (setq list-to-search semantic--buffer-cache);; We have a tag ouside the list. Check for |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
397 ;; We know we have a parent because it would |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
398 ;; completely cover the change. A tag can only |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
399 ;; do that if it is a parent after we get here. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
400 (when (and tags |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
401 (< (semantic-tag-start (car tags)) start) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
402 (> (semantic-tag-end (car tags)) end)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
403 ;; We have a parent. Stuff in the search list. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
404 (setq parent (car tags) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
405 list-to-search (semantic-tag-components parent)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
406 ;; If the first of TAGS is a parent (see above) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
407 ;; then clear out the list. All other tags in |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
408 ;; here must therefore be parents of the car. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
409 (setq tags nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
410 ;; One last check, If start is before the first |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
411 ;; tag or after the last, we may have overlap into |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
412 ;; the characters that make up the definition of |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
413 ;; the tag we are parsing. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
414 (when (or (semantic-tag-with-position-p (car list-to-search)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
415 (< start (semantic-tag-start |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
416 (car list-to-search))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
417 (> end (semantic-tag-end |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
418 (nth (1- (length list-to-search)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
419 list-to-search)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
420 ;; We have a problem |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
421 (setq list-to-search nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
422 parent nil)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
423 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
424 (when list-to-search |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
425 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
426 ;; Ok, return the vector only if all TAGS are |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
427 ;; confirmed as the lineage of `overlapped-tags' |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
428 ;; which must have a value by now. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
429 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
430 ;; Loop over the search list to find the preceeding CDR. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
431 ;; Fortunatly, (car overlapped-tags) happens to be |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
432 ;; the first tag positionally. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
433 (let ((tokstart (semantic-tag-start (car overlapped-tags)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
434 (while (and list-to-search |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
435 ;; Assume always (car (cdr list-to-search)). |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
436 ;; A thrown error will be captured nicely, but |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
437 ;; that case shouldn't happen. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
438 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
439 ;; We end when the start of the CDR is after the |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
440 ;; end of our asked change. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
441 (cdr list-to-search) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
442 (< (semantic-tag-start (car (cdr list-to-search))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
443 tokstart) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
444 (setq list-to-search (cdr list-to-search))))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
445 ;; Create the return vector |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
446 (vector overlapped-tags |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
447 list-to-search |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
448 parent) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
449 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
450 nil))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
451 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
452 ;;; Default Incremental Parser |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
453 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
454 ;; Logic about how to group changes for effective reparsing and splicing. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
455 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
456 (defun semantic-parse-changes-failed (&rest args) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
457 "Signal that Semantic failed to parse changes. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
458 That is, display a message by passing all ARGS to `format', then throw |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
459 a 'semantic-parse-changes-failed exception with value t." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
460 (when semantic-edits-verbose-flag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
461 (message "Semantic parse changes failed: %S" |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
462 (apply 'format args))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
463 (throw 'semantic-parse-changes-failed t)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
464 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
465 (defsubst semantic-edits-incremental-fail () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
466 "When the incremental parser fails, we mark that we need a full reparse." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
467 ;;(debug) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
468 (semantic-parse-tree-set-needs-rebuild) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
469 (when semantic-edits-verbose-flag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
470 (message "Force full reparse (%s)" |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
471 (buffer-name (current-buffer)))) |
104517
beb4db733a34
* cedet/semantic/edit.el
Chong Yidong <cyd@stupidchicken.com>
parents:
104513
diff
changeset
|
472 (run-hooks 'semantic-edits-incremental-reparse-failed-hook)) |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
473 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
474 (defun semantic-edits-incremental-parser () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
475 "Incrementally reparse the current buffer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
476 Incremental parser allows semantic to only reparse those sections of |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
477 the buffer that have changed. This function depends on |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
478 `semantic-edits-change-function-handle-changes' setting up change |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
479 overlays in the current buffer. Those overlays are analyzed against |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
480 the semantic cache to see what needs to be changed." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
481 (let ((changed-tags |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
482 ;; Don't use `semantic-safe' here to explicitly catch errors |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
483 ;; and reset the parse tree. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
484 (catch 'semantic-parse-changes-failed |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
485 (if debug-on-error |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
486 (semantic-edits-incremental-parser-1) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
487 (condition-case err |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
488 (semantic-edits-incremental-parser-1) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
489 (error |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
490 (message "incremental parser error: %S" |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
491 (error-message-string err)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
492 t)))))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
493 (when (eq changed-tags t) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
494 ;; Force a full reparse. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
495 (semantic-edits-incremental-fail) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
496 (setq changed-tags nil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
497 changed-tags)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
498 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
499 (defmacro semantic-edits-assert-valid-region () |
105340 | 500 "Assert that parse-start and parse-end are sorted correctly." |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
501 ;;; (if (> parse-start parse-end) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
502 ;;; (error "Bug is %s !> %d! Buff min/max = [ %d %d ]" |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
503 ;;; parse-start parse-end |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
504 ;;; (point-min) (point-max))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
505 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
506 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
507 (defun semantic-edits-incremental-parser-1 () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
508 "Incrementally reparse the current buffer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
509 Return the list of tags that changed. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
510 If the incremental parse fails, throw a 'semantic-parse-changes-failed |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
511 exception with value t, that can be caught to schedule a full reparse. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
512 This function is for internal use by `semantic-edits-incremental-parser'." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
513 (let* ((changed-tags nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
514 (debug-on-quit t) ; try to find this annoying bug! |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
515 (changes (semantic-changes-in-region |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
516 (point-min) (point-max))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
517 (tags nil) ;tags found at changes |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
518 (newf-tags nil) ;newfound tags in change |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
519 (parse-start nil) ;location to start parsing |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
520 (parse-end nil) ;location to end parsing |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
521 (parent-tag nil) ;parent of the cache list. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
522 (cache-list nil) ;list of children within which |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
523 ;we incrementally reparse. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
524 (reparse-symbol nil) ;The ruled we start at for reparse. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
525 (change-group nil) ;changes grouped in this reparse |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
526 (last-cond nil) ;track the last case used. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
527 ;query this when debugging to find |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
528 ;source of bugs. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
529 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
530 (or changes |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
531 ;; If we were called, and there are no changes, then we |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
532 ;; don't know what to do. Force a full reparse. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
533 (semantic-parse-changes-failed "Don't know what to do")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
534 ;; Else, we have some changes. Loop over them attempting to |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
535 ;; patch things up. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
536 (while changes |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
537 ;; Calculate the reparse boundary. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
538 ;; We want to take some set of changes, and group them |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
539 ;; together into a small change group. One change forces |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
540 ;; a reparse of a larger region (the size of some set of |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
541 ;; tags it encompases.) It may contain several tags. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
542 ;; That region may have other changes in it (several small |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
543 ;; changes in one function, for example.) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
544 ;; Optimize for the simple cases here, but try to handle |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
545 ;; complex ones too. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
546 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
547 (while (and changes ; we still have changes |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
548 (or (not parse-start) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
549 ;; Below, if the change we are looking at |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
550 ;; is not the first change for this |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
551 ;; iteration, and it starts before the end |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
552 ;; of current parse region, then it is |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
553 ;; encompased within the bounds of tags |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
554 ;; modified by the previous iteration's |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
555 ;; change. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
556 (< (semantic-overlay-start (car changes)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
557 parse-end))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
558 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
559 ;; REMOVE LATER |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
560 (if (eq (car changes) (car change-group)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
561 (semantic-parse-changes-failed |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
562 "Possible infinite loop detected")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
563 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
564 ;; Store this change in this change group. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
565 (setq change-group (cons (car changes) change-group)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
566 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
567 (cond |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
568 ;; Is this is a new parse group? |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
569 ((not parse-start) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
570 (setq last-cond "new group") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
571 (let (tmp) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
572 (cond |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
573 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
574 ;;;; Are we encompassed all in one tag? |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
575 ((setq tmp (semantic-edits-change-leaf-tag (car changes))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
576 (setq last-cond "Encompassed in tag") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
577 (setq tags (list tmp) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
578 parse-start (semantic-tag-start tmp) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
579 parse-end (semantic-tag-end tmp) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
580 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
581 (semantic-edits-assert-valid-region)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
582 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
583 ;;;; Did the change occur between some tags? |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
584 ((setq cache-list (semantic-edits-change-between-tags |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
585 (car changes))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
586 (setq last-cond "Between and not overlapping tags") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
587 ;; The CAR of cache-list is the tag just before |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
588 ;; our change, but wasn't modified. Hmmm. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
589 ;; Bound our reparse between these two tags |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
590 (setq tags nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
591 parent-tag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
592 (car (semantic-find-tag-by-overlay |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
593 parse-start))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
594 (cond |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
595 ;; A change at the beginning of the buffer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
596 ;; Feb 06 - |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
597 ;; IDed when the first cache-list tag is after |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
598 ;; our change, meaning there is nothing before |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
599 ;; the chnge. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
600 ((> (semantic-tag-start (car cache-list)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
601 (semantic-overlay-end (car changes))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
602 (setq last-cond "Beginning of buffer") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
603 (setq parse-start |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
604 ;; Don't worry about parents since |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
605 ;; there there would be an exact |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
606 ;; match in the tag list otherwise |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
607 ;; and the routine would fail. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
608 (point-min) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
609 parse-end |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
610 (semantic-tag-start (car cache-list))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
611 (semantic-edits-assert-valid-region) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
612 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
613 ;; A change stuck on the first surrounding tag. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
614 ((= (semantic-tag-end (car cache-list)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
615 (semantic-overlay-start (car changes))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
616 (setq last-cond "Beginning of Tag") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
617 ;; Reparse that first tag. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
618 (setq parse-start |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
619 (semantic-tag-start (car cache-list)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
620 parse-end |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
621 (semantic-overlay-end (car changes)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
622 tags |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
623 (list (car cache-list))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
624 (semantic-edits-assert-valid-region) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
625 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
626 ;; A change at the end of the buffer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
627 ((not (car (cdr cache-list))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
628 (setq last-cond "End of buffer") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
629 (setq parse-start (semantic-tag-end |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
630 (car cache-list)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
631 parse-end (point-max)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
632 (semantic-edits-assert-valid-region) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
633 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
634 (t |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
635 (setq last-cond "Default") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
636 (setq parse-start |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
637 (semantic-tag-end (car cache-list)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
638 parse-end |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
639 (semantic-tag-start (car (cdr cache-list))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
640 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
641 (semantic-edits-assert-valid-region)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
642 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
643 ;;;; Did the change completely overlap some number of tags? |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
644 ((setq tmp (semantic-edits-change-over-tags |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
645 (car changes))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
646 (setq last-cond "Overlap multiple tags") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
647 ;; Extract the information |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
648 (setq tags (aref tmp 0) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
649 cache-list (aref tmp 1) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
650 parent-tag (aref tmp 2)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
651 ;; We can calculate parse begin/end by checking |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
652 ;; out what is in TAGS. The one near start is |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
653 ;; always first. Make sure the reprase includes |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
654 ;; the `whitespace' around the snarfed tags. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
655 ;; Since cache-list is positioned properly, use it |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
656 ;; to find that boundary. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
657 (if (eq (car tags) (car cache-list)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
658 ;; Beginning of the buffer! |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
659 (let ((end-marker (nth (length tags) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
660 cache-list))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
661 (setq parse-start (point-min)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
662 (if end-marker |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
663 (setq parse-end |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
664 (semantic-tag-start end-marker)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
665 (setq parse-end (semantic-overlay-end |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
666 (car changes)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
667 (semantic-edits-assert-valid-region) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
668 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
669 ;; Middle of the buffer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
670 (setq parse-start |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
671 (semantic-tag-end (car cache-list))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
672 ;; For the end, we need to scoot down some |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
673 ;; number of tags. We 1+ the length of tags |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
674 ;; because we want to skip the first tag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
675 ;; (remove 1-) then want the tag after the end |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
676 ;; of the list (1+) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
677 (let ((end-marker (nth (1+ (length tags)) cache-list))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
678 (if end-marker |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
679 (setq parse-end (semantic-tag-start end-marker)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
680 ;; No marker. It is the last tag in our |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
681 ;; list of tags. Only possible if END |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
682 ;; already matches the end of that tag. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
683 (setq parse-end |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
684 (semantic-overlay-end (car changes))))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
685 (semantic-edits-assert-valid-region) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
686 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
687 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
688 ;;;; Unhandled case. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
689 ;; Throw error, and force full reparse. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
690 ((semantic-parse-changes-failed "Unhandled change group"))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
691 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
692 ;; Is this change inside the previous parse group? |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
693 ;; We already checked start. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
694 ((< (semantic-overlay-end (car changes)) parse-end) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
695 (setq last-cond "in bounds") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
696 nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
697 ;; This change extends the current parse group. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
698 ;; Find any new tags, and see how to append them. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
699 ((semantic-parse-changes-failed |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
700 (setq last-cond "overlap boundary") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
701 "Unhandled secondary change overlapping boundary")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
702 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
703 ;; Prepare for the next iteration. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
704 (setq changes (cdr changes))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
705 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
706 ;; By the time we get here, all TAGS are children of |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
707 ;; some parent. They should all have the same start symbol |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
708 ;; since that is how the multi-tag parser works. Grab |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
709 ;; the reparse symbol from the first of the returned tags. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
710 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
711 ;; Feb '06 - If repase-symbol is nil, then they are top level |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
712 ;; tags. (I'm guessing.) Is this right? |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
713 (setq reparse-symbol |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
714 (semantic--tag-get-property (car (or tags cache-list)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
715 'reparse-symbol)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
716 ;; Find a parent if not provided. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
717 (and (not parent-tag) tags |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
718 (setq parent-tag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
719 (semantic-find-tag-parent-by-overlay |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
720 (car tags)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
721 ;; We can do the same trick for our parent and resulting |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
722 ;; cache list. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
723 (unless cache-list |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
724 (if parent-tag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
725 (setq cache-list |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
726 ;; We need to get all children in case we happen |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
727 ;; to have a mix of positioned and non-positioned |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
728 ;; children. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
729 (semantic-tag-components parent-tag)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
730 ;; Else, all the tags since there is no parent. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
731 ;; It sucks to have to use the full buffer cache in |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
732 ;; this case because it can be big. Failure to provide |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
733 ;; however results in a crash. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
734 (setq cache-list semantic--buffer-cache) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
735 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
736 ;; Use the boundary to calculate the new tags found. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
737 (setq newf-tags (semantic-parse-region |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
738 parse-start parse-end reparse-symbol)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
739 ;; Make sure all these tags are given overlays. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
740 ;; They have already been cooked by the parser and just |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
741 ;; need the overlays. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
742 (let ((tmp newf-tags)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
743 (while tmp |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
744 (semantic--tag-link-to-buffer (car tmp)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
745 (setq tmp (cdr tmp)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
746 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
747 ;; See how this change lays out. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
748 (cond |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
749 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
750 ;;;; Whitespace change |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
751 ((and (not tags) (not newf-tags)) |
106840
5df8e547a422
Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
752 ;; A change that occurred outside of any existing tags |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
753 ;; and there are no new tags to replace it. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
754 (when semantic-edits-verbose-flag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
755 (message "White space changes")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
756 nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
757 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
758 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
759 ;;;; New tags in old whitespace area. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
760 ((and (not tags) newf-tags) |
106840
5df8e547a422
Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
761 ;; A change occurred outside existing tags which added |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
762 ;; a new tag. We need to splice these tags back |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
763 ;; into the cache at the right place. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
764 (semantic-edits-splice-insert newf-tags parent-tag cache-list) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
765 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
766 (setq changed-tags |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
767 (append newf-tags changed-tags)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
768 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
769 (when semantic-edits-verbose-flag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
770 (message "Inserted tags: (%s)" |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
771 (semantic-format-tag-name (car newf-tags)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
772 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
773 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
774 ;;;; Old tags removed |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
775 ((and tags (not newf-tags)) |
106840
5df8e547a422
Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
776 ;; A change occurred where pre-existing tags were |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
777 ;; deleted! Remove the tag from the cache. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
778 (semantic-edits-splice-remove tags parent-tag cache-list) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
779 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
780 (setq changed-tags |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
781 (append tags changed-tags)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
782 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
783 (when semantic-edits-verbose-flag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
784 (message "Deleted tags: (%s)" |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
785 (semantic-format-tag-name (car tags)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
786 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
787 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
788 ;;;; One tag was updated. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
789 ((and (= (length tags) 1) (= (length newf-tags) 1)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
790 ;; One old tag was modified, and it is replaced by |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
791 ;; One newfound tag. Splice the new tag into the |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
792 ;; position of the old tag. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
793 ;; Do the splice. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
794 (semantic-edits-splice-replace (car tags) (car newf-tags)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
795 ;; Add this tag to our list of changed toksns |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
796 (setq changed-tags (cons (car tags) changed-tags)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
797 ;; Debug |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
798 (when semantic-edits-verbose-flag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
799 (message "Update Tag Table: %s" |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
800 (semantic-format-tag-name (car tags) nil t))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
801 ;; Flush change regardless of above if statement. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
802 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
803 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
804 ;;;; Some unhandled case. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
805 ((semantic-parse-changes-failed "Don't know what to do"))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
806 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
807 ;; We got this far, and we didn't flag a full reparse. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
808 ;; Clear out this change group. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
809 (while change-group |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
810 (semantic-edits-flush-change (car change-group)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
811 (setq change-group (cdr change-group))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
812 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
813 ;; Don't increment change here because an earlier loop |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
814 ;; created change-groups. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
815 (setq parse-start nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
816 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
817 ;; Mark that we are done with this glop |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
818 (semantic-parse-tree-set-up-to-date) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
819 ;; Return the list of tags that changed. The caller will |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
820 ;; use this information to call hooks which can fix themselves. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
821 changed-tags)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
822 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
823 ;; Make it the default changes parser |
104450
08a15f853c45
lisp/cedet/semantic/edit.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104444
diff
changeset
|
824 ;;;###autoload |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
825 (defalias 'semantic-parse-changes-default |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
826 'semantic-edits-incremental-parser) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
827 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
828 ;;; Cache Splicing |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
829 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
830 ;; The incremental parser depends on the ability to parse up sections |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
831 ;; of the file, and splice the results back into the cache. There are |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
832 ;; three types of splices. A REPLACE, an ADD, and a REMOVE. REPLACE |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
833 ;; is one of the simpler cases, as the starting cons cell representing |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
834 ;; the old tag can be used to auto-splice in. ADD and REMOVE |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
835 ;; require scanning the cache to find the correct location so that the |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
836 ;; list can be fiddled. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
837 (defun semantic-edits-splice-remove (oldtags parent cachelist) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
838 "Remove OLDTAGS from PARENT's CACHELIST. |
105340 | 839 OLDTAGS are tags in the current buffer, preferably linked |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
840 together also in CACHELIST. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
841 PARENT is the parent tag containing OLDTAGS. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
842 CACHELIST should be the children from PARENT, but may be |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
843 pre-positioned to a convenient location." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
844 (let* ((first (car oldtags)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
845 (last (nth (1- (length oldtags)) oldtags)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
846 (chil (if parent |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
847 (semantic-tag-components parent) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
848 semantic--buffer-cache)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
849 (cachestart cachelist) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
850 (cacheend nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
851 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
852 ;; First in child list? |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
853 (if (eq first (car chil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
854 ;; First tags in the cache are being deleted. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
855 (progn |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
856 (when semantic-edits-verbose-flag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
857 (message "To Remove First Tag: (%s)" |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
858 (semantic-format-tag-name first))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
859 ;; Find the last tag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
860 (setq cacheend chil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
861 (while (and cacheend (not (eq last (car cacheend)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
862 (setq cacheend (cdr cacheend))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
863 ;; The splicable part is after cacheend.. so move cacheend |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
864 ;; one more tag. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
865 (setq cacheend (cdr cacheend)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
866 ;; Splice the found end tag into the cons cell |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
867 ;; owned by the current top child. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
868 (setcar chil (car cacheend)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
869 (setcdr chil (cdr cacheend)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
870 (when (not cacheend) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
871 ;; No cacheend.. then the whole system is empty. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
872 ;; The best way to deal with that is to do a full |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
873 ;; reparse |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
874 (semantic-parse-changes-failed "Splice-remove failed. Empty buffer?") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
875 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
876 (message "To Remove Middle Tag: (%s)" |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
877 (semantic-format-tag-name first))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
878 ;; Find in the cache the preceeding tag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
879 (while (and cachestart (not (eq first (car (cdr cachestart))))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
880 (setq cachestart (cdr cachestart))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
881 ;; Find the last tag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
882 (setq cacheend cachestart) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
883 (while (and cacheend (not (eq last (car cacheend)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
884 (setq cacheend (cdr cacheend))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
885 ;; Splice the end position into the start position. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
886 ;; If there is no start, then this whole section is probably |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
887 ;; gone. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
888 (if cachestart |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
889 (setcdr cachestart (cdr cacheend)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
890 (semantic-parse-changes-failed "Splice-remove failed.")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
891 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
892 ;; Remove old overlays of these deleted tags |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
893 (while oldtags |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
894 (semantic--tag-unlink-from-buffer (car oldtags)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
895 (setq oldtags (cdr oldtags))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
896 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
897 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
898 (defun semantic-edits-splice-insert (newtags parent cachelist) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
899 "Insert NEWTAGS into PARENT using CACHELIST. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
900 PARENT could be nil, in which case CACHLIST is the buffer cache |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
901 which must be updated. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
902 CACHELIST must be searched to find where NEWTAGS are to be inserted. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
903 The positions of NEWTAGS must be synchronized with those in |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
904 CACHELIST for this to work. Some routines pre-position CACHLIST at a |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
905 convenient location, so use that." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
906 (let* ((start (semantic-tag-start (car newtags))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
907 (newtagendcell (nthcdr (1- (length newtags)) newtags)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
908 (end (semantic-tag-end (car newtagendcell))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
909 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
910 (if (> (semantic-tag-start (car cachelist)) start) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
911 ;; We are at the beginning. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
912 (let* ((pc (if parent |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
913 (semantic-tag-components parent) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
914 semantic--buffer-cache)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
915 (nc (cons (car pc) (cdr pc))) ; new cons cell. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
916 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
917 ;; Splice the new cache cons cell onto the end of our list. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
918 (setcdr newtagendcell nc) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
919 ;; Set our list into parent. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
920 (setcar pc (car newtags)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
921 (setcdr pc (cdr newtags))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
922 ;; We are at the end, or in the middle. Find our match first. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
923 (while (and (cdr cachelist) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
924 (> end (semantic-tag-start (car (cdr cachelist))))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
925 (setq cachelist (cdr cachelist))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
926 ;; Now splice into the list! |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
927 (setcdr newtagendcell (cdr cachelist)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
928 (setcdr cachelist newtags)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
929 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
930 (defun semantic-edits-splice-replace (oldtag newtag) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
931 "Replace OLDTAG with NEWTAG in the current cache. |
105340 | 932 Do this by recycling OLDTAG's first CONS cell. This effectively |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
933 causes the new tag to completely replace the old one. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
934 Make sure that all information in the overlay is transferred. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
935 It is presumed that OLDTAG and NEWTAG are both cooked. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
936 When this routine returns, OLDTAG is raw, and the data will be |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
937 lost if not transferred into NEWTAG." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
938 (let* ((oo (semantic-tag-overlay oldtag)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
939 (o (semantic-tag-overlay newtag)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
940 (oo-props (semantic-overlay-properties oo))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
941 (while oo-props |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
942 (semantic-overlay-put o (car oo-props) (car (cdr oo-props))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
943 (setq oo-props (cdr (cdr oo-props))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
944 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
945 ;; Free the old overlay(s) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
946 (semantic--tag-unlink-from-buffer oldtag) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
947 ;; Recover properties |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
948 (semantic--tag-copy-properties oldtag newtag) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
949 ;; Splice into the main list. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
950 (setcdr oldtag (cdr newtag)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
951 (setcar oldtag (car newtag)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
952 ;; This important bit is because the CONS cell representing |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
953 ;; OLDTAG is now pointing to NEWTAG, but the NEWTAG |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
954 ;; cell is about to be abandoned. Here we update our overlay |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
955 ;; to point at the updated state of the world. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
956 (semantic-overlay-put o 'semantic oldtag) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
957 )) |
104519
934691bc93ed
* cedet/semantic/idle.el (semantic-idle-scheduler-work-timer):
Chong Yidong <cyd@stupidchicken.com>
parents:
104517
diff
changeset
|
958 |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
959 (add-hook 'semantic-before-toplevel-cache-flush-hook |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
960 #'semantic-edits-flush-changes) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
961 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
962 (provide 'semantic/edit) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
963 |
104450
08a15f853c45
lisp/cedet/semantic/edit.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104444
diff
changeset
|
964 ;; Local variables: |
08a15f853c45
lisp/cedet/semantic/edit.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104444
diff
changeset
|
965 ;; generated-autoload-file: "loaddefs.el" |
08a15f853c45
lisp/cedet/semantic/edit.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104444
diff
changeset
|
966 ;; generated-autoload-load-name: "semantic/edit" |
08a15f853c45
lisp/cedet/semantic/edit.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104444
diff
changeset
|
967 ;; End: |
08a15f853c45
lisp/cedet/semantic/edit.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104444
diff
changeset
|
968 |
105377 | 969 ;; arch-tag: 91c7fbf0-a418-4220-a90a-b58c74b450e3 |
104442
b22b44e953cb
cedet/semantic/chart.el: Don't require semantic/find.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
970 ;;; semantic/edit.el ends here |