From 7c0d8675b512d1e589c55ef02abb10b45d8df4de Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Tue, 23 Apr 2013 18:16:10 +1200 Subject: [PATCH] Make createKinddict() an instance method --- autoload/tagbar.vim | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index f422eef..00b77d9 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -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