File plugin/qthelp.vim changed (mode: 100644) (index bf75a4c..2c2b71a) |
... |
... |
endfunction |
113 |
113 |
" determines if a class name, a variable name or a class member name is |
" determines if a class name, a variable name or a class member name is |
114 |
114 |
" underneath the cursor and returns appropriate taglist |
" underneath the cursor and returns appropriate taglist |
115 |
115 |
function! s:QHGetTagsListUC() |
function! s:QHGetTagsListUC() |
|
116 |
|
let b:membername = '' |
|
117 |
|
|
116 |
118 |
" wuc is for Word Underneath the Cursor |
" wuc is for Word Underneath the Cursor |
117 |
119 |
let l:wuc = expand('<cword>') |
let l:wuc = expand('<cword>') |
118 |
120 |
|
|
119 |
|
let l:lst = taglist('//apple_ref/cpp/cl//'.l:wuc.'$') |
|
120 |
|
if empty(l:lst) |
|
121 |
|
let l:lst = taglist('^'.l:wuc.'$') |
|
122 |
|
call filter(l:lst, 'v:val["filename"] =~? "[/\]'.l:wuc.'.html$"') |
|
123 |
|
endif |
|
124 |
|
|
|
125 |
|
if empty(l:lst) " if WUC is var_name |
|
126 |
|
let [l:class, b:membername] = QHGetVUCInfo() |
|
127 |
|
if empty(b:membername) |
|
128 |
|
let l:lst = taglist('//apple_ref/cpp/cl//'.l:class.'$') |
|
129 |
|
if empty(l:lst) |
|
130 |
|
let l:lst = taglist('^'.l:class.'$') |
|
131 |
|
endif |
|
132 |
|
else |
|
133 |
|
let l:lst = s:QHGetTagsListOnMember(l:class, b:membername) |
|
134 |
|
if empty(l:lst) |
|
135 |
|
let b:membername = '' |
|
136 |
|
let l:lst = taglist('//apple_ref/cpp/cl//'.l:class.'$') |
|
137 |
|
endif |
|
138 |
|
if empty(l:lst) |
|
139 |
|
let b:membername = '' |
|
140 |
|
let l:lst = taglist('^'.l:class.'$') |
|
141 |
|
endif |
|
|
121 |
|
let l:lst = s:QHTryFindClass(l:wuc) |
|
122 |
|
if empty(l:lst) " if WUC is not class name |
|
123 |
|
let [l:class, l:membername] = QHGetVUCInfo() |
|
124 |
|
if !empty(l:membername) |
|
125 |
|
let l:lst = s:QHGetTagsListOnMember(l:class, l:membername) |
|
126 |
|
endif |
|
127 |
|
if empty(l:lst) |
|
128 |
|
let l:lst = s:QHTryFindClass(l:class) |
142 |
129 |
endif |
endif |
143 |
|
else |
|
144 |
|
let b:membername = '' |
|
145 |
130 |
endif |
endif |
146 |
131 |
|
|
147 |
132 |
return l:lst |
return l:lst |
148 |
133 |
endfunction |
endfunction |
149 |
134 |
|
|
150 |
|
" b:membername should be set before calling this function because one should |
|
151 |
|
" modify it last |
|
|
135 |
|
" tries to get a list of tags for the class |
|
136 |
|
function! s:QHTryFindClass(class) |
|
137 |
|
let l:lst = taglist('//apple_ref/cpp/cl//'.a:class.'$') |
|
138 |
|
if empty(l:lst) |
|
139 |
|
let l:lst = s:QHGetTagsListOnMember(a:class, a:class) |
|
140 |
|
endif |
|
141 |
|
let b:membername = '' |
|
142 |
|
return l:lst |
|
143 |
|
endfunction |
|
144 |
|
|
|
145 |
|
" tries to get a gat for the member of the class |
|
146 |
|
" sets b:membername |
152 |
147 |
function! s:QHGetTagsListOnMember(class, member) |
function! s:QHGetTagsListOnMember(class, member) |
153 |
|
let l:lst = taglist('^'.a:member.'-typedef$') |
|
154 |
|
call filter(l:lst, 'v:val["filename"] =~? "[/\]'.a:class.'.html$"') |
|
155 |
|
if len(l:lst) != 0 |
|
|
148 |
|
let l:lst = [] |
|
149 |
|
|
|
150 |
|
if empty(l:lst) |
156 |
151 |
let b:membername = a:member.'-typedef' |
let b:membername = a:member.'-typedef' |
157 |
|
return l:lst |
|
|
152 |
|
let l:lst = s:QHGetWithoutAppleRef(b:membername, a:class) |
158 |
153 |
endif |
endif |
159 |
|
let l:lst = taglist('^'.a:member.'-enum$') |
|
160 |
|
call filter(l:lst, 'v:val["filename"] =~? "[/\]'.a:class.'.html$"') |
|
161 |
|
if len(l:lst) != 0 |
|
|
154 |
|
if empty(l:lst) |
162 |
155 |
let b:membername = a:member.'-enum' |
let b:membername = a:member.'-enum' |
163 |
|
return l:lst |
|
|
156 |
|
let l:lst = s:QHGetWithoutAppleRef(b:membername, a:class) |
|
157 |
|
endif |
|
158 |
|
|
|
159 |
|
if empty(l:lst) |
|
160 |
|
let b:membername = a:member |
164 |
161 |
endif |
endif |
165 |
162 |
|
|
166 |
163 |
if empty(l:lst) |
if empty(l:lst) |
|
... |
... |
function! s:QHGetTagsListOnMember(class, member) |
175 |
172 |
if empty(l:lst) |
if empty(l:lst) |
176 |
173 |
let l:lst = taglist('//apple_ref/cpp/tag/'.a:class.'/'.a:member.'$') |
let l:lst = taglist('//apple_ref/cpp/tag/'.a:class.'/'.a:member.'$') |
177 |
174 |
endif |
endif |
|
175 |
|
|
|
176 |
|
if empty(l:lst) |
|
177 |
|
let l:lst = s:QHGetWithoutAppleRef(a:member, a:class) |
|
178 |
|
endif |
|
179 |
|
|
178 |
180 |
if empty(l:lst) |
if empty(l:lst) |
179 |
|
let l:lst = taglist('^'.a:member.'$') |
|
180 |
|
call filter(l:lst, 'v:val["filename"] =~? "[/\]'.a:class.'\.html$"') |
|
|
181 |
|
let b:membername = '' |
181 |
182 |
endif |
endif |
|
183 |
|
|
|
184 |
|
return l:lst |
|
185 |
|
endfunction |
|
186 |
|
|
|
187 |
|
" tries to guess tag by its name and name of the class |
|
188 |
|
function! s:QHGetWithoutAppleRef(tag, class) |
|
189 |
|
let l:lst = taglist('^'.a:tag.'$') |
|
190 |
|
call filter(l:lst, 'v:val["filename"] =~? "[/\]'.a:class.'\.html$"') |
182 |
191 |
return l:lst |
return l:lst |
183 |
192 |
endfunction |
endfunction |
184 |
193 |
|
|
185 |
194 |
" analyses query for class name or class name and its member name |
" analyses query for class name or class name and its member name |
|
195 |
|
" sets b:membername |
186 |
196 |
function! s:QHGetTagsList(query) |
function! s:QHGetTagsList(query) |
187 |
197 |
call s:QHDebug('QHDBG: QHGetTagsList(query="'.a:query.'")') |
call s:QHDebug('QHDBG: QHGetTagsList(query="'.a:query.'")') |
188 |
198 |
let l:lst = [] |
let l:lst = [] |
189 |
199 |
|
|
190 |
200 |
let l:regex = '\('.s:idregex.'\)::\('.s:idregex.'\)' |
let l:regex = '\('.s:idregex.'\)::\('.s:idregex.'\)' |
191 |
|
if matchstr(a:query, l:regex) != '' |
|
|
201 |
|
if empty(matchstr(a:query, l:regex)) |
|
202 |
|
let l:lst = taglist('//apple_ref/cpp/cl//'.a:query.'$') |
|
203 |
|
let b:membername = '' |
|
204 |
|
else |
192 |
205 |
let l:class = substitute(a:query, l:regex, '\1', '') |
let l:class = substitute(a:query, l:regex, '\1', '') |
193 |
206 |
call s:QHDebug('QHDBG: QHGetTagsList, class="'.l:class.'"') |
call s:QHDebug('QHDBG: QHGetTagsList, class="'.l:class.'"') |
194 |
207 |
let l:member = substitute(a:query, l:regex, '\2', '') |
let l:member = substitute(a:query, l:regex, '\2', '') |
|
... |
... |
function! s:QHGetTagsList(query) |
203 |
216 |
\.l:class.'/'.l:member.'$') |
\.l:class.'/'.l:member.'$') |
204 |
217 |
endif |
endif |
205 |
218 |
let b:membername = l:member |
let b:membername = l:member |
206 |
|
else |
|
207 |
|
let l:lst = taglist('//apple_ref/cpp/cl//'.a:query.'$') |
|
208 |
|
let b:membername = '' |
|
209 |
219 |
endif |
endif |
210 |
220 |
|
|
211 |
221 |
return l:lst |
return l:lst |
|
... |
... |
function! s:QHOpenBrowser(file) |
217 |
227 |
return |
return |
218 |
228 |
endif |
endif |
219 |
229 |
let l:browserargs = 'file://'.fnamemodify(a:file, ':p') |
let l:browserargs = 'file://'.fnamemodify(a:file, ':p') |
220 |
|
if b:membername != '' |
|
|
230 |
|
if !empty(b:membername) |
221 |
231 |
let l:browserargs = l:browserargs.'\#'.b:membername |
let l:browserargs = l:browserargs.'\#'.b:membername |
222 |
232 |
endif |
endif |
223 |
233 |
let l:browserargs = shellescape(l:browserargs) |
let l:browserargs = shellescape(l:browserargs) |
|
... |
... |
endfunction |
235 |
245 |
" lets tell user about what we have found |
" lets tell user about what we have found |
236 |
246 |
function! s:QHInformUser(varname, class, membername) |
function! s:QHInformUser(varname, class, membername) |
237 |
247 |
let l:msg = a:class |
let l:msg = a:class |
238 |
|
if a:membername != '' |
|
|
248 |
|
if !empty(a:membername) |
239 |
249 |
let l:msg = l:msg.'::' |
let l:msg = l:msg.'::' |
240 |
250 |
endif |
endif |
241 |
|
if a:varname != '' |
|
|
251 |
|
if !empty(a:varname) |
242 |
252 |
let l:msg = a:varname.' ('.l:msg.')' |
let l:msg = a:varname.' ('.l:msg.')' |
243 |
253 |
endif |
endif |
244 |
|
if b:foundinfile != '' |
|
|
254 |
|
if !empty(b:foundinfile) |
245 |
255 |
let l:msg = l:msg.'; was found in '.b:foundinfile |
let l:msg = l:msg.'; was found in '.b:foundinfile |
246 |
256 |
\.' at line '.b:foundatline |
\.' at line '.b:foundatline |
247 |
257 |
endif |
endif |
|
... |
... |
function! QHGetVUCInfo() |
271 |
281 |
let l:wuctype = s:QHGetWUCType(wuc) |
let l:wuctype = s:QHGetWUCType(wuc) |
272 |
282 |
if l:wuctype == 0 " we're assuming that this is varname |
if l:wuctype == 0 " we're assuming that this is varname |
273 |
283 |
let l:varname = s:QHGetVarType(l:wuc) |
let l:varname = s:QHGetVarType(l:wuc) |
274 |
|
if empty(l:varname) |
|
275 |
|
return [l:wuc, ''] |
|
276 |
|
else |
|
277 |
|
return [l:varname, ''] |
|
278 |
|
endif |
|
|
284 |
|
let l:classname = empty(l:varname) ? l:wuc : l:varname |
|
285 |
|
return [l:classname, ''] |
279 |
286 |
elseif l:wuctype == 1 |
elseif l:wuctype == 1 |
280 |
287 |
return [s:QHGetNSName(l:wuc), l:wuc] |
return [s:QHGetNSName(l:wuc), l:wuc] |
281 |
288 |
elseif l:wuctype == 2 |
elseif l:wuctype == 2 |
|
... |
... |
function! s:QHGetVarType(varname) |
293 |
300 |
" firstly lets try to find declaration in current file |
" firstly lets try to find declaration in current file |
294 |
301 |
" simple case |
" simple case |
295 |
302 |
let l:type = s:QHSearchSimpleVarDef(a:varname) |
let l:type = s:QHSearchSimpleVarDef(a:varname) |
296 |
|
if l:type != '' |
|
|
303 |
|
if !empty(l:type) |
297 |
304 |
call s:QHDebug('QHDBG: Simple definition search succesed') |
call s:QHDebug('QHDBG: Simple definition search succesed') |
298 |
305 |
return l:type |
return l:type |
299 |
306 |
endif |
endif |
300 |
307 |
" more complex |
" more complex |
301 |
308 |
let l:type = s:QHSearchComplexVarDef(a:varname) |
let l:type = s:QHSearchComplexVarDef(a:varname) |
302 |
|
if l:type != '' |
|
|
309 |
|
if !empty(l:type) |
303 |
310 |
call s:QHDebug('QHDBG: Complex definition search succesed') |
call s:QHDebug('QHDBG: Complex definition search succesed') |
304 |
311 |
return l:type |
return l:type |
305 |
312 |
endif |
endif |
306 |
313 |
|
|
307 |
314 |
" try to find variable in function declaration |
" try to find variable in function declaration |
308 |
315 |
let l:type = s:QHSearchVarDefInArgs(a:varname) |
let l:type = s:QHSearchVarDefInArgs(a:varname) |
309 |
|
if l:type != '' |
|
|
316 |
|
if !empty(l:type) |
310 |
317 |
call s:QHDebug('QHDBG: Arg search succesed') |
call s:QHDebug('QHDBG: Arg search succesed') |
311 |
318 |
return l:type |
return l:type |
312 |
319 |
endif |
endif |
|
... |
... |
function! s:QHSearchComplexVarDef(varname) |
359 |
366 |
" continue the search but without search() to escape moving cursor |
" continue the search but without search() to escape moving cursor |
360 |
367 |
for l:l in range(l:lnum - 1, 1, -1) |
for l:l in range(l:lnum - 1, 1, -1) |
361 |
368 |
let l:type = matchstr(getline(l:l), l:defregex) |
let l:type = matchstr(getline(l:l), l:defregex) |
362 |
|
if l:type != '' && l:type != 'delete' |
|
|
369 |
|
if !empty(l:type) && l:type != 'delete' |
363 |
370 |
let b:foundinfile = 'this file' |
let b:foundinfile = 'this file' |
364 |
371 |
let b:foundatline = l:l |
let b:foundatline = l:l |
365 |
372 |
return l:type |
return l:type |
|
... |
... |
function! s:QHSearchVarDefInFile(varname, filename) |
390 |
397 |
let l:lnum = 0 |
let l:lnum = 0 |
391 |
398 |
for l:line in l:headerfile |
for l:line in l:headerfile |
392 |
399 |
let l:definition = matchstr(l:line, l:defregex) |
let l:definition = matchstr(l:line, l:defregex) |
393 |
|
if l:definition != '' |
|
|
400 |
|
if !empty(l:definition) |
394 |
401 |
let b:foundinfile = a:filename |
let b:foundinfile = a:filename |
395 |
402 |
let b:foundatline = l:lnum |
let b:foundatline = l:lnum |
396 |
403 |
return matchstr(l:line, s:typeregex) |
return matchstr(l:line, s:typeregex) |
397 |
404 |
endif |
endif |
398 |
|
let l:lnum = l:lnum + 1 |
|
|
405 |
|
let l:lnum += 1 |
399 |
406 |
endfor |
endfor |
400 |
407 |
return '' |
return '' |
401 |
408 |
endfunction |
endfunction |