Make createKinddict() an instance method

This commit is contained in:
Jan Larres 2013-04-23 18:16:10 +12:00
parent acca348959
commit 7c0d8675b5

View File

@ -797,8 +797,8 @@ function! s:InitTypes() abort
call s:LoadUserTypeDefs()
for type in values(s:known_types)
call s:CreateTypeKinddict(type)
for typeinfo in values(s:known_types)
call typeinfo.createKinddict()
endfor
let s:type_init_done = 1
@ -871,18 +871,6 @@ function! s:TransformUserTypeDef(def) abort
return newdef
endfunction
" s:CreateTypeKinddict() {{{2
" TODO: make instance method
function! s:CreateTypeKinddict(type) abort
" Create a dictionary of the kind order for fast access in sorting
" functions
let i = 0
for kind in a:type.kinds
let a:type.kinddict[kind.short] = i
let i += 1
endfor
endfunction
" s:RestoreSession() {{{2
" Properly restore Tagbar after a session got loaded
function! s:RestoreSession() abort
@ -1504,6 +1492,16 @@ function! s:TypeInfo.getKind(kind) abort dict
return self.kinds[idx]
endfunction
" s:TypeInfo.createKinddict() {{{3
" Create a dictionary of the kind order for fast access in sorting functions
function! s:TypeInfo.createKinddict() abort dict
let i = 0
for kind in self.kinds
let self.kinddict[kind.short] = i
let i += 1
endfor
endfunction
" File info {{{2
let s:FileInfo = {}
@ -1917,7 +1915,7 @@ function! s:ProcessFile(fname, ftype) abort
if exists('b:tagbar_type')
let typeinfo = extend(copy(typeinfo),
\ s:TransformUserTypeDef(b:tagbar_type))
call s:CreateTypeKinddict(typeinfo)
call typeinfo.createKinddict()
endif
let fileinfo = s:FileInfo.New(a:fname, a:ftype, typeinfo)
endif