annotate runtime/autoload/ccomplete.vim @ 29161:198a44d40394 v8.2.5100

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