annotate runtime/autoload/ccomplete.vim @ 20525:42e5347ff9b6

Added tag v8.2.0816 for changeset bed30e6b5a095706cba0ca717d52588156c2b391
author Bram Moolenaar <Bram@vim.org>
date Sun, 24 May 2020 17:30:04 +0200
parents 1908e92b02fd
children e7c125224b1a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents:
diff changeset
1 " Vim completion script
52e76e2b5b65 updated for version 7.0140
vimboss
parents:
diff changeset
2 " Language: C
52e76e2b5b65 updated for version 7.0140
vimboss
parents:
diff changeset
3 " Maintainer: Bram Moolenaar <Bram@vim.org>
19968
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14668
diff changeset
4 " Last Change: 2020 Apr 08
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents:
diff changeset
5
3237
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2152
diff changeset
6 let s:cpo_save = &cpo
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2152
diff changeset
7 set cpo&vim
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
8
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
9 " This function is used for the 'omnifunc' option.
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents:
diff changeset
10 function! ccomplete#Complete(findstart, base)
52e76e2b5b65 updated for version 7.0140
vimboss
parents:
diff changeset
11 if a:findstart
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
12 " Locate the start of the item, including ".", "->" and "[...]".
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents:
diff changeset
13 let line = getline('.')
52e76e2b5b65 updated for version 7.0140
vimboss
parents:
diff changeset
14 let start = col('.') - 1
548
f43150a669dc updated for version 7.0155
vimboss
parents: 523
diff changeset
15 let lastword = -1
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents:
diff changeset
16 while start > 0
548
f43150a669dc updated for version 7.0155
vimboss
parents: 523
diff changeset
17 if line[start - 1] =~ '\w'
f43150a669dc updated for version 7.0155
vimboss
parents: 523
diff changeset
18 let start -= 1
f43150a669dc updated for version 7.0155
vimboss
parents: 523
diff changeset
19 elseif line[start - 1] =~ '\.'
f43150a669dc updated for version 7.0155
vimboss
parents: 523
diff changeset
20 if lastword == -1
f43150a669dc updated for version 7.0155
vimboss
parents: 523
diff changeset
21 let lastword = start
f43150a669dc updated for version 7.0155
vimboss
parents: 523
diff changeset
22 endif
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents:
diff changeset
23 let start -= 1
52e76e2b5b65 updated for version 7.0140
vimboss
parents:
diff changeset
24 elseif start > 1 && line[start - 2] == '-' && line[start - 1] == '>'
548
f43150a669dc updated for version 7.0155
vimboss
parents: 523
diff changeset
25 if lastword == -1
f43150a669dc updated for version 7.0155
vimboss
parents: 523
diff changeset
26 let lastword = start
f43150a669dc updated for version 7.0155
vimboss
parents: 523
diff changeset
27 endif
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents:
diff changeset
28 let start -= 2
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
29 elseif line[start - 1] == ']'
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
30 " Skip over [...].
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
31 let n = 0
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
32 let start -= 1
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
33 while start > 0
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
34 let start -= 1
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
35 if line[start] == '['
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
36 if n == 0
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
37 break
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
38 endif
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
39 let n -= 1
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
40 elseif line[start] == ']' " nested []
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
41 let n += 1
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
42 endif
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
43 endwhile
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents:
diff changeset
44 else
52e76e2b5b65 updated for version 7.0140
vimboss
parents:
diff changeset
45 break
52e76e2b5b65 updated for version 7.0140
vimboss
parents:
diff changeset
46 endif
52e76e2b5b65 updated for version 7.0140
vimboss
parents:
diff changeset
47 endwhile
548
f43150a669dc updated for version 7.0155
vimboss
parents: 523
diff changeset
48
f43150a669dc updated for version 7.0155
vimboss
parents: 523
diff changeset
49 " Return the column of the last word, which is going to be changed.
f43150a669dc updated for version 7.0155
vimboss
parents: 523
diff changeset
50 " Remember the text that comes before it in s:prepended.
f43150a669dc updated for version 7.0155
vimboss
parents: 523
diff changeset
51 if lastword == -1
f43150a669dc updated for version 7.0155
vimboss
parents: 523
diff changeset
52 let s:prepended = ''
f43150a669dc updated for version 7.0155
vimboss
parents: 523
diff changeset
53 return start
f43150a669dc updated for version 7.0155
vimboss
parents: 523
diff changeset
54 endif
f43150a669dc updated for version 7.0155
vimboss
parents: 523
diff changeset
55 let s:prepended = strpart(line, start, lastword - start)
f43150a669dc updated for version 7.0155
vimboss
parents: 523
diff changeset
56 return lastword
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents:
diff changeset
57 endif
52e76e2b5b65 updated for version 7.0140
vimboss
parents:
diff changeset
58
511
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
59 " Return list of matches.
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
60
548
f43150a669dc updated for version 7.0155
vimboss
parents: 523
diff changeset
61 let base = s:prepended . a:base
f43150a669dc updated for version 7.0155
vimboss
parents: 523
diff changeset
62
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
63 " Don't do anything for an empty base, would result in all the tags in the
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
64 " tags file.
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
65 if base == ''
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
66 return []
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
67 endif
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
68
720
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
69 " init cache for vimgrep to empty
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
70 let s:grepCache = {}
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
71
511
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
72 " Split item in words, keep empty word after "." or "->".
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
73 " "aa" -> ['aa'], "aa." -> ['aa', ''], "aa.bb" -> ['aa', 'bb'], etc.
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
74 " We can't use split, because we need to skip nested [...].
14668
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
75 " "aa[...]" -> ['aa', '[...]'], "aa.bb[...]" -> ['aa', 'bb', '[...]'], etc.
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
76 let items = []
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
77 let s = 0
14668
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
78 let arrays = 0
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
79 while 1
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
80 let e = match(base, '\.\|->\|\[', s)
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
81 if e < 0
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
82 if s == 0 || base[s - 1] != ']'
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
83 call add(items, strpart(base, s))
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
84 endif
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
85 break
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
86 endif
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
87 if s == 0 || base[s - 1] != ']'
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
88 call add(items, strpart(base, s, e - s))
548
f43150a669dc updated for version 7.0155
vimboss
parents: 523
diff changeset
89 endif
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
90 if base[e] == '.'
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
91 let s = e + 1 " skip over '.'
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
92 elseif base[e] == '-'
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
93 let s = e + 2 " skip over '->'
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
94 else
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
95 " Skip over [...].
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
96 let n = 0
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
97 let s = e
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
98 let e += 1
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
99 while e < len(base)
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
100 if base[e] == ']'
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
101 if n == 0
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
102 break
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
103 endif
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
104 let n -= 1
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
105 elseif base[e] == '[' " nested [...]
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
106 let n += 1
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
107 endif
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
108 let e += 1
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
109 endwhile
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
110 let e += 1
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
111 call add(items, strpart(base, s, e - s))
14668
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
112 let arrays += 1
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
113 let s = e
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
114 endif
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
115 endwhile
505
7e6d264ec0a2 updated for version 7.0141
vimboss
parents: 502
diff changeset
116
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
117 " Find the variable items[0].
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
118 " 1. in current function (like with "gd")
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
119 " 2. in tags file(s) (like with ":tag")
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
120 " 3. in current file (like with "gD")
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
121 let res = []
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
122 if searchdecl(items[0], 0, 1) == 0
505
7e6d264ec0a2 updated for version 7.0141
vimboss
parents: 502
diff changeset
123 " Found, now figure out the type.
7e6d264ec0a2 updated for version 7.0141
vimboss
parents: 502
diff changeset
124 " TODO: join previous line if it makes sense
7e6d264ec0a2 updated for version 7.0141
vimboss
parents: 502
diff changeset
125 let line = getline('.')
7e6d264ec0a2 updated for version 7.0141
vimboss
parents: 502
diff changeset
126 let col = col('.')
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 876
diff changeset
127 if stridx(strpart(line, 0, col), ';') != -1
18ee39301b82 updated for version 7.2a
vimboss
parents: 876
diff changeset
128 " Handle multiple declarations on the same line.
18ee39301b82 updated for version 7.2a
vimboss
parents: 876
diff changeset
129 let col2 = col - 1
18ee39301b82 updated for version 7.2a
vimboss
parents: 876
diff changeset
130 while line[col2] != ';'
18ee39301b82 updated for version 7.2a
vimboss
parents: 876
diff changeset
131 let col2 -= 1
18ee39301b82 updated for version 7.2a
vimboss
parents: 876
diff changeset
132 endwhile
18ee39301b82 updated for version 7.2a
vimboss
parents: 876
diff changeset
133 let line = strpart(line, col2 + 1)
18ee39301b82 updated for version 7.2a
vimboss
parents: 876
diff changeset
134 let col -= col2
18ee39301b82 updated for version 7.2a
vimboss
parents: 876
diff changeset
135 endif
18ee39301b82 updated for version 7.2a
vimboss
parents: 876
diff changeset
136 if stridx(strpart(line, 0, col), ',') != -1
18ee39301b82 updated for version 7.2a
vimboss
parents: 876
diff changeset
137 " Handle multiple declarations on the same line in a function
18ee39301b82 updated for version 7.2a
vimboss
parents: 876
diff changeset
138 " declaration.
18ee39301b82 updated for version 7.2a
vimboss
parents: 876
diff changeset
139 let col2 = col - 1
18ee39301b82 updated for version 7.2a
vimboss
parents: 876
diff changeset
140 while line[col2] != ','
18ee39301b82 updated for version 7.2a
vimboss
parents: 876
diff changeset
141 let col2 -= 1
18ee39301b82 updated for version 7.2a
vimboss
parents: 876
diff changeset
142 endwhile
18ee39301b82 updated for version 7.2a
vimboss
parents: 876
diff changeset
143 if strpart(line, col2 + 1, col - col2 - 1) =~ ' *[^ ][^ ]* *[^ ]'
18ee39301b82 updated for version 7.2a
vimboss
parents: 876
diff changeset
144 let line = strpart(line, col2 + 1)
18ee39301b82 updated for version 7.2a
vimboss
parents: 876
diff changeset
145 let col -= col2
18ee39301b82 updated for version 7.2a
vimboss
parents: 876
diff changeset
146 endif
18ee39301b82 updated for version 7.2a
vimboss
parents: 876
diff changeset
147 endif
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
148 if len(items) == 1
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
149 " Completing one word and it's a local variable: May add '[', '.' or
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
150 " '->'.
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
151 let match = items[0]
734
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
152 let kind = 'v'
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
153 if match(line, '\<' . match . '\s*\[') > 0
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
154 let match .= '['
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
155 else
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
156 let res = s:Nextitem(strpart(line, 0, col), [''], 0, 1)
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
157 if len(res) > 0
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
158 " There are members, thus add "." or "->".
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
159 if match(line, '\*[ \t(]*' . match . '\>') > 0
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
160 let match .= '->'
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
161 else
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
162 let match .= '.'
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
163 endif
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
164 endif
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
165 endif
734
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
166 let res = [{'match': match, 'tagline' : '', 'kind' : kind, 'info' : line}]
14668
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
167 elseif len(items) == arrays + 1
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
168 " Completing one word and it's a local array variable: build tagline
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
169 " from declaration line
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
170 let match = items[0]
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
171 let kind = 'v'
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
172 let tagline = "\t/^" . line . '$/'
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
173 let res = [{'match': match, 'tagline' : tagline, 'kind' : kind, 'info' : line}]
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
174 else
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
175 " Completing "var.", "var.something", etc.
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1624
diff changeset
176 let res = s:Nextitem(strpart(line, 0, col), items[1:], 0, 1)
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
177 endif
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
178 endif
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
179
14668
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
180 if len(items) == 1 || len(items) == arrays + 1
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
181 " Only one part, no "." or "->": complete from tags file.
14668
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
182 if len(items) == 1
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
183 let tags = taglist('^' . base)
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
184 else
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
185 let tags = taglist('^' . items[0] . '$')
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
186 endif
734
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
187
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
188 " Remove members, these can't appear without something in front.
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
189 call filter(tags, 'has_key(v:val, "kind") ? v:val["kind"] != "m" : 1')
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
190
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
191 " Remove static matches in other files.
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
192 call filter(tags, '!has_key(v:val, "static") || !v:val["static"] || bufnr("%") == bufnr(v:val["filename"])')
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
193
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
194 call extend(res, map(tags, 's:Tag2item(v:val)'))
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
195 endif
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
196
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
197 if len(res) == 0
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
198 " Find the variable in the tags file(s)
511
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
199 let diclist = taglist('^' . items[0] . '$')
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
200
734
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
201 " Remove members, these can't appear without something in front.
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
202 call filter(diclist, 'has_key(v:val, "kind") ? v:val["kind"] != "m" : 1')
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
203
511
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
204 let res = []
505
7e6d264ec0a2 updated for version 7.0141
vimboss
parents: 502
diff changeset
205 for i in range(len(diclist))
800
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
206 " New ctags has the "typeref" field. Patched version has "typename".
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
207 if has_key(diclist[i], 'typename')
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
208 call extend(res, s:StructMembers(diclist[i]['typename'], items[1:], 1))
800
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
209 elseif has_key(diclist[i], 'typeref')
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
210 call extend(res, s:StructMembers(diclist[i]['typeref'], items[1:], 1))
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
211 endif
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
212
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
213 " For a variable use the command, which must be a search pattern that
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
214 " shows the declaration of the variable.
505
7e6d264ec0a2 updated for version 7.0141
vimboss
parents: 502
diff changeset
215 if diclist[i]['kind'] == 'v'
7e6d264ec0a2 updated for version 7.0141
vimboss
parents: 502
diff changeset
216 let line = diclist[i]['cmd']
7e6d264ec0a2 updated for version 7.0141
vimboss
parents: 502
diff changeset
217 if line[0] == '/' && line[1] == '^'
610
cd3689efd90a updated for version 7.0173
vimboss
parents: 548
diff changeset
218 let col = match(line, '\<' . items[0] . '\>')
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
219 call extend(res, s:Nextitem(strpart(line, 2, col - 2), items[1:], 0, 1))
505
7e6d264ec0a2 updated for version 7.0141
vimboss
parents: 502
diff changeset
220 endif
7e6d264ec0a2 updated for version 7.0141
vimboss
parents: 502
diff changeset
221 endif
7e6d264ec0a2 updated for version 7.0141
vimboss
parents: 502
diff changeset
222 endfor
7e6d264ec0a2 updated for version 7.0141
vimboss
parents: 502
diff changeset
223 endif
7e6d264ec0a2 updated for version 7.0141
vimboss
parents: 502
diff changeset
224
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
225 if len(res) == 0 && searchdecl(items[0], 1) == 0
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
226 " Found, now figure out the type.
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
227 " TODO: join previous line if it makes sense
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
228 let line = getline('.')
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
229 let col = col('.')
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
230 let res = s:Nextitem(strpart(line, 0, col), items[1:], 0, 1)
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
231 endif
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
232
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
233 " If the last item(s) are [...] they need to be added to the matches.
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
234 let last = len(items) - 1
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
235 let brackets = ''
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
236 while last >= 0
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
237 if items[last][0] != '['
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
238 break
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
239 endif
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
240 let brackets = items[last] . brackets
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
241 let last -= 1
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
242 endwhile
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
243
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
244 return map(res, 's:Tagline2item(v:val, brackets)')
511
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
245 endfunc
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
246
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
247 function! s:GetAddition(line, match, memarg, bracket)
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
248 " Guess if the item is an array.
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
249 if a:bracket && match(a:line, a:match . '\s*\[') > 0
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
250 return '['
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
251 endif
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
252
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
253 " Check if the item has members.
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
254 if len(s:SearchMembers(a:memarg, [''], 0)) > 0
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
255 " If there is a '*' before the name use "->".
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
256 if match(a:line, '\*[ \t(]*' . a:match . '\>') > 0
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
257 return '->'
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
258 else
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
259 return '.'
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
260 endif
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
261 endif
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
262 return ''
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
263 endfunction
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
264
648
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
265 " Turn the tag info "val" into an item for completion.
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
266 " "val" is is an item in the list returned by taglist().
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
267 " If it is a variable we may add "." or "->". Don't do it for other types,
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
268 " such as a typedef, by not including the info that s:GetAddition() uses.
648
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
269 function! s:Tag2item(val)
734
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
270 let res = {'match': a:val['name']}
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
271
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
272 let res['extra'] = s:Tagcmd2extra(a:val['cmd'], a:val['name'], a:val['filename'])
666
0137e7c3d31b updated for version 7.0196
vimboss
parents: 659
diff changeset
273
800
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
274 let s = s:Dict2info(a:val)
734
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
275 if s != ''
800
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
276 let res['info'] = s
734
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
277 endif
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
278
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
279 let res['tagline'] = ''
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
280 if has_key(a:val, "kind")
734
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
281 let kind = a:val['kind']
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
282 let res['kind'] = kind
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
283 if kind == 'v'
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
284 let res['tagline'] = "\t" . a:val['cmd']
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
285 let res['dict'] = a:val
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
286 elseif kind == 'f'
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
287 let res['match'] = a:val['name'] . '('
648
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
288 endif
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
289 endif
734
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
290
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
291 return res
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
292 endfunction
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
293
800
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
294 " Use all the items in dictionary for the "info" entry.
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
295 function! s:Dict2info(dict)
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
296 let info = ''
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
297 for k in sort(keys(a:dict))
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
298 let info .= k . repeat(' ', 10 - len(k))
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
299 if k == 'cmd'
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
300 let info .= substitute(matchstr(a:dict['cmd'], '/^\s*\zs.*\ze$/'), '\\\(.\)', '\1', 'g')
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
301 else
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
302 let info .= a:dict[k]
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
303 endif
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
304 let info .= "\n"
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
305 endfor
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
306 return info
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
307 endfunc
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
308
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
309 " Parse a tag line and return a dictionary with items like taglist()
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
310 function! s:ParseTagline(line)
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
311 let l = split(a:line, "\t")
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
312 let d = {}
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
313 if len(l) >= 3
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
314 let d['name'] = l[0]
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
315 let d['filename'] = l[1]
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
316 let d['cmd'] = l[2]
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
317 let n = 2
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
318 if l[2] =~ '^/'
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
319 " Find end of cmd, it may contain Tabs.
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
320 while n < len(l) && l[n] !~ '/;"$'
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
321 let n += 1
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
322 let d['cmd'] .= " " . l[n]
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
323 endwhile
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
324 endif
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
325 for i in range(n + 1, len(l) - 1)
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
326 if l[i] == 'file:'
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
327 let d['static'] = 1
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
328 elseif l[i] !~ ':'
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
329 let d['kind'] = l[i]
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
330 else
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
331 let d[matchstr(l[i], '[^:]*')] = matchstr(l[i], ':\zs.*')
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
332 endif
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
333 endfor
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
334 endif
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
335
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
336 return d
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
337 endfunction
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
338
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
339 " Turn a match item "val" into an item for completion.
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
340 " "val['match']" is the matching item.
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
341 " "val['tagline']" is the tagline in which the last part was found.
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
342 function! s:Tagline2item(val, brackets)
666
0137e7c3d31b updated for version 7.0196
vimboss
parents: 659
diff changeset
343 let line = a:val['tagline']
734
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
344 let add = s:GetAddition(line, a:val['match'], [a:val], a:brackets == '')
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
345 let res = {'word': a:val['match'] . a:brackets . add }
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
346
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
347 if has_key(a:val, 'info')
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
348 " Use info from Tag2item().
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
349 let res['info'] = a:val['info']
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
350 else
800
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
351 " Parse the tag line and add each part to the "info" entry.
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
352 let s = s:Dict2info(s:ParseTagline(line))
734
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
353 if s != ''
800
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
354 let res['info'] = s
734
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
355 endif
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
356 endif
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
357
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
358 if has_key(a:val, 'kind')
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
359 let res['kind'] = a:val['kind']
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
360 elseif add == '('
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
361 let res['kind'] = 'f'
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
362 else
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
363 let s = matchstr(line, '\t\(kind:\)\=\zs\S\ze\(\t\|$\)')
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
364 if s != ''
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
365 let res['kind'] = s
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
366 endif
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
367 endif
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
368
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 654
diff changeset
369 if has_key(a:val, 'extra')
734
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
370 let res['menu'] = a:val['extra']
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
371 return res
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 654
diff changeset
372 endif
666
0137e7c3d31b updated for version 7.0196
vimboss
parents: 659
diff changeset
373
0137e7c3d31b updated for version 7.0196
vimboss
parents: 659
diff changeset
374 " Isolate the command after the tag and filename.
0137e7c3d31b updated for version 7.0196
vimboss
parents: 659
diff changeset
375 let s = matchstr(line, '[^\t]*\t[^\t]*\t\zs\(/^.*$/\|[^\t]*\)\ze\(;"\t\|\t\|$\)')
0137e7c3d31b updated for version 7.0196
vimboss
parents: 659
diff changeset
376 if s != ''
734
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
377 let res['menu'] = s:Tagcmd2extra(s, a:val['match'], matchstr(line, '[^\t]*\t\zs[^\t]*\ze\t'))
666
0137e7c3d31b updated for version 7.0196
vimboss
parents: 659
diff changeset
378 endif
734
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
379 return res
648
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
380 endfunction
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
381
666
0137e7c3d31b updated for version 7.0196
vimboss
parents: 659
diff changeset
382 " Turn a command from a tag line to something that is useful in the menu
0137e7c3d31b updated for version 7.0196
vimboss
parents: 659
diff changeset
383 function! s:Tagcmd2extra(cmd, name, fname)
0137e7c3d31b updated for version 7.0196
vimboss
parents: 659
diff changeset
384 if a:cmd =~ '^/^'
0137e7c3d31b updated for version 7.0196
vimboss
parents: 659
diff changeset
385 " The command is a search command, useful to see what it is.
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
386 let x = matchstr(a:cmd, '^/^\s*\zs.*\ze$/')
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
387 let x = substitute(x, '\<' . a:name . '\>', '@@', '')
666
0137e7c3d31b updated for version 7.0196
vimboss
parents: 659
diff changeset
388 let x = substitute(x, '\\\(.\)', '\1', 'g')
0137e7c3d31b updated for version 7.0196
vimboss
parents: 659
diff changeset
389 let x = x . ' - ' . a:fname
0137e7c3d31b updated for version 7.0196
vimboss
parents: 659
diff changeset
390 elseif a:cmd =~ '^\d*$'
0137e7c3d31b updated for version 7.0196
vimboss
parents: 659
diff changeset
391 " The command is a line number, the file name is more useful.
0137e7c3d31b updated for version 7.0196
vimboss
parents: 659
diff changeset
392 let x = a:fname . ' - ' . a:cmd
0137e7c3d31b updated for version 7.0196
vimboss
parents: 659
diff changeset
393 else
0137e7c3d31b updated for version 7.0196
vimboss
parents: 659
diff changeset
394 " Not recognized, use command and file name.
0137e7c3d31b updated for version 7.0196
vimboss
parents: 659
diff changeset
395 let x = a:cmd . ' - ' . a:fname
0137e7c3d31b updated for version 7.0196
vimboss
parents: 659
diff changeset
396 endif
0137e7c3d31b updated for version 7.0196
vimboss
parents: 659
diff changeset
397 return x
0137e7c3d31b updated for version 7.0196
vimboss
parents: 659
diff changeset
398 endfunction
648
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
399
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
400 " Find composing type in "lead" and match items[0] with it.
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
401 " Repeat this recursively for items[1], if it's there.
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
402 " When resolving typedefs "depth" is used to avoid infinite recursion.
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
403 " Return the list of matches.
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
404 function! s:Nextitem(lead, items, depth, all)
511
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
405
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
406 " Use the text up to the variable name and split it in tokens.
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
407 let tokens = split(a:lead, '\s\+\|\<')
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
408
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
409 " Try to recognize the type of the variable. This is rough guessing...
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
410 let res = []
511
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
411 for tidx in range(len(tokens))
505
7e6d264ec0a2 updated for version 7.0141
vimboss
parents: 502
diff changeset
412
720
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
413 " Skip tokens starting with a non-ID character.
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
414 if tokens[tidx] !~ '^\h'
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
415 continue
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
416 endif
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
417
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
418 " Recognize "struct foobar" and "union foobar".
860
2fe516aa3710 updated for version 7.0g02
vimboss
parents: 800
diff changeset
419 " Also do "class foobar" when it's C++ after all (doesn't work very well
2fe516aa3710 updated for version 7.0g02
vimboss
parents: 800
diff changeset
420 " though).
2fe516aa3710 updated for version 7.0g02
vimboss
parents: 800
diff changeset
421 if (tokens[tidx] == 'struct' || tokens[tidx] == 'union' || tokens[tidx] == 'class') && tidx + 1 < len(tokens)
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
422 let res = s:StructMembers(tokens[tidx] . ':' . tokens[tidx + 1], a:items, a:all)
511
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
423 break
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
424 endif
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
425
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
426 " TODO: add more reserved words
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
427 if index(['int', 'short', 'char', 'float', 'double', 'static', 'unsigned', 'extern'], tokens[tidx]) >= 0
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
428 continue
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
429 endif
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
430
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
431 " Use the tags file to find out if this is a typedef.
511
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
432 let diclist = taglist('^' . tokens[tidx] . '$')
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
433 for tagidx in range(len(diclist))
734
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
434 let item = diclist[tagidx]
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
435
800
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
436 " New ctags has the "typeref" field. Patched version has "typename".
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
437 if has_key(item, 'typeref')
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
438 call extend(res, s:StructMembers(item['typeref'], a:items, a:all))
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
439 continue
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
440 endif
734
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
441 if has_key(item, 'typename')
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
442 call extend(res, s:StructMembers(item['typename'], a:items, a:all))
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
443 continue
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
444 endif
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
445
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
446 " Only handle typedefs here.
734
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
447 if item['kind'] != 't'
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
448 continue
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
449 endif
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
450
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
451 " Skip matches local to another file.
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
452 if has_key(item, 'static') && item['static'] && bufnr('%') != bufnr(item['filename'])
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
453 continue
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
454 endif
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
455
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
456 " For old ctags we recognize "typedef struct aaa" and
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
457 " "typedef union bbb" in the tags file command.
734
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
458 let cmd = item['cmd']
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
459 let ei = matchend(cmd, 'typedef\s\+')
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
460 if ei > 1
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
461 let cmdtokens = split(strpart(cmd, ei), '\s\+\|\<')
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
462 if len(cmdtokens) > 1
860
2fe516aa3710 updated for version 7.0g02
vimboss
parents: 800
diff changeset
463 if cmdtokens[0] == 'struct' || cmdtokens[0] == 'union' || cmdtokens[0] == 'class'
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
464 let name = ''
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
465 " Use the first identifier after the "struct" or "union"
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
466 for ti in range(len(cmdtokens) - 1)
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
467 if cmdtokens[ti] =~ '^\w'
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
468 let name = cmdtokens[ti]
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
469 break
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
470 endif
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
471 endfor
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
472 if name != ''
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
473 call extend(res, s:StructMembers(cmdtokens[0] . ':' . name, a:items, a:all))
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
474 endif
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
475 elseif a:depth < 10
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
476 " Could be "typedef other_T some_T".
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
477 call extend(res, s:Nextitem(cmdtokens[0], a:items, a:depth + 1, a:all))
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
478 endif
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
479 endif
511
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
480 endif
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
481 endfor
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
482 if len(res) > 0
505
7e6d264ec0a2 updated for version 7.0141
vimboss
parents: 502
diff changeset
483 break
7e6d264ec0a2 updated for version 7.0141
vimboss
parents: 502
diff changeset
484 endif
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
485 endfor
511
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
486
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
487 return res
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
488 endfunction
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
489
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
490
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
491 " Search for members of structure "typename" in tags files.
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
492 " Return a list with resulting matches.
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
493 " Each match is a dictionary with "match" and "tagline" entries.
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
494 " When "all" is non-zero find all, otherwise just return 1 if there is any
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
495 " member.
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
496 function! s:StructMembers(typename, items, all)
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
497 " Todo: What about local structures?
876
1d0ef79659af updated for version 7.0-002
vimboss
parents: 860
diff changeset
498 let fnames = join(map(tagfiles(), 'escape(v:val, " \\#%")'))
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
499 if fnames == ''
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
500 return []
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
501 endif
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
502
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
503 let typename = a:typename
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
504 let qflist = []
720
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
505 let cached = 0
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
506 if a:all == 0
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
507 let n = '1' " stop at first found match
720
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
508 if has_key(s:grepCache, a:typename)
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
509 let qflist = s:grepCache[a:typename]
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
510 let cached = 1
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
511 endif
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
512 else
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
513 let n = ''
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
514 endif
720
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
515 if !cached
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
516 while 1
3682
11d40fc82f11 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
517 exe 'silent! keepj noautocmd ' . n . 'vimgrep /\t' . typename . '\(\t\|$\)/j ' . fnames
720
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
518
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
519 let qflist = getqflist()
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
520 if len(qflist) > 0 || match(typename, "::") < 0
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
521 break
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
522 endif
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
523 " No match for "struct:context::name", remove "context::" and try again.
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
524 let typename = substitute(typename, ':[^:]*::', ':', '')
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
525 endwhile
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
526
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
527 if a:all == 0
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
528 " Store the result to be able to use it again later.
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
529 let s:grepCache[a:typename] = qflist
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
530 endif
720
e180933b876a updated for version 7.0219
vimboss
parents: 716
diff changeset
531 endif
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
532
14668
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
533 " Skip over [...] items
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
534 let idx = 0
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
535 while 1
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
536 if idx >= len(a:items)
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
537 let target = '' " No further items, matching all members
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
538 break
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
539 endif
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
540 if a:items[idx][0] != '['
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
541 let target = a:items[idx]
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
542 break
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
543 endif
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
544 let idx += 1
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
545 endwhile
734
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
546 " Put matching members in matches[].
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
547 let matches = []
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
548 for l in qflist
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
549 let memb = matchstr(l['text'], '[^\t]*')
14668
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
550 if memb =~ '^' . target
734
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
551 " Skip matches local to another file.
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
552 if match(l['text'], "\tfile:") < 0 || bufnr('%') == bufnr(matchstr(l['text'], '\t\zs[^\t]*'))
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
553 let item = {'match': memb, 'tagline': l['text']}
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
554
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
555 " Add the kind of item.
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
556 let s = matchstr(l['text'], '\t\(kind:\)\=\zs\S\ze\(\t\|$\)')
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
557 if s != ''
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
558 let item['kind'] = s
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
559 if s == 'f'
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
560 let item['match'] = memb . '('
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
561 endif
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
562 endif
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
563
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
564 call add(matches, item)
5220ea46cb9a updated for version 7.0221
vimboss
parents: 720
diff changeset
565 endif
516
b7abd41f91da updated for version 7.0144
vimboss
parents: 511
diff changeset
566 endif
511
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
567 endfor
505
7e6d264ec0a2 updated for version 7.0141
vimboss
parents: 502
diff changeset
568
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
569 if len(matches) > 0
14668
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
570 " Skip over next [...] items
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3682
diff changeset
571 let idx += 1
654
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
572 while 1
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
573 if idx >= len(a:items)
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
574 return matches " No further items, return the result.
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
575 endif
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
576 if a:items[idx][0] != '['
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
577 break
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
578 endif
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
579 let idx += 1
441f938ea9e9 updated for version 7.0192
vimboss
parents: 651
diff changeset
580 endwhile
505
7e6d264ec0a2 updated for version 7.0141
vimboss
parents: 502
diff changeset
581
511
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
582 " More items following. For each of the possible members find the
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
583 " matching following members.
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
584 return s:SearchMembers(matches, a:items[idx :], a:all)
511
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
585 endif
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
586
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
587 " Failed to find anything.
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
588 return []
32cf0d2e14b4 updated for version 7.0143
vimboss
parents: 505
diff changeset
589 endfunction
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
590
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
591 " For matching members, find matches for following items.
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
592 " When "all" is non-zero find all, otherwise just return 1 if there is any
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
593 " member.
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
594 function! s:SearchMembers(matches, items, all)
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
595 let res = []
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
596 for i in range(len(a:matches))
648
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
597 let typename = ''
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
598 if has_key(a:matches[i], 'dict')
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
599 if has_key(a:matches[i].dict, 'typename')
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
600 let typename = a:matches[i].dict['typename']
800
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
601 elseif has_key(a:matches[i].dict, 'typeref')
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
602 let typename = a:matches[i].dict['typeref']
648
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
603 endif
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
604 let line = "\t" . a:matches[i].dict['cmd']
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
605 else
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
606 let line = a:matches[i]['tagline']
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
607 let e = matchend(line, '\ttypename:')
800
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
608 if e < 0
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
609 let e = matchend(line, '\ttyperef:')
d8f905020502 updated for version 7.0b
vimboss
parents: 787
diff changeset
610 endif
648
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
611 if e > 0
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
612 " Use typename field
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
613 let typename = matchstr(line, '[^\t]*', e)
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
614 endif
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
615 endif
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
616
648
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
617 if typename != ''
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
618 call extend(res, s:StructMembers(typename, a:items, a:all))
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
619 else
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
620 " Use the search command (the declaration itself).
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
621 let s = match(line, '\t\zs/^')
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
622 if s > 0
648
9032e4668296 updated for version 7.0189
vimboss
parents: 610
diff changeset
623 let e = match(line, '\<' . a:matches[i]['match'] . '\>', s)
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
624 if e > 0
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
625 call extend(res, s:Nextitem(strpart(line, s, e - s), a:items, 0, a:all))
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
626 endif
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
627 endif
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
628 endif
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
629 if a:all == 0 && len(res) > 0
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
630 break
8ae24f338cab updated for version 7.0217
vimboss
parents: 666
diff changeset
631 endif
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
632 endfor
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
633 return res
a7ae7e043e43 updated for version 7.0146
vimboss
parents: 520
diff changeset
634 endfunc
3237
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2152
diff changeset
635
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2152
diff changeset
636 let &cpo = s:cpo_save
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2152
diff changeset
637 unlet s:cpo_save
19968
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14668
diff changeset
638
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14668
diff changeset
639 " vim: noet sw=2 sts=2