Initial commit.
This commit is contained in:
73
vim/autoload/railmoon/oscan/extractor/buffers.vim
Executable file
73
vim/autoload/railmoon/oscan/extractor/buffers.vim
Executable file
@@ -0,0 +1,73 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#buffers
|
||||
" Purpose: extract buffer names to select
|
||||
|
||||
function! railmoon#oscan#extractor#buffers#create()
|
||||
let new_extractor = copy(s:tag_scan_buffers_extractor)
|
||||
let new_extractor.description = 'Select buffer to edit'
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_buffers_extractor = {}
|
||||
function! s:tag_scan_buffers_extractor.process(record)
|
||||
if &modified
|
||||
let choice = inputlist( [ "Buffer is modified.", "1. Save current and continue" , "2. Break", "3. Open in new tab" ] )
|
||||
if 1 == choice
|
||||
update
|
||||
elseif 2 == choice
|
||||
return
|
||||
elseif 3 == choice
|
||||
tab new
|
||||
else
|
||||
tab new
|
||||
endif
|
||||
endif
|
||||
|
||||
exec 'buffer '.a:record.data
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_buffers_extractor.tags_by_name(buffer_name, buffer_number)
|
||||
let tags = railmoon#oscan#extractor#util#tags_from_file_name(a:buffer_name)
|
||||
|
||||
if index(tags, string(a:buffer_number)) == -1
|
||||
call add(tags, a:buffer_number)
|
||||
endif
|
||||
|
||||
return tags
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_buffers_extractor.header_by_name(buffer_name, buffer_number)
|
||||
return [ a:buffer_name ]
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_buffers_extractor.extract()
|
||||
let result = []
|
||||
|
||||
let buffers = railmoon#oscan#extractor#util#buffer_list()
|
||||
|
||||
for buffer_info in buffers
|
||||
|
||||
let buffer_number = buffer_info[0]
|
||||
let buffer_name = buffer_info[1]
|
||||
|
||||
call add(result, railmoon#oscan#record#create( self.header_by_name(buffer_name, buffer_number),
|
||||
\ self.tags_by_name(buffer_name, buffer_number),
|
||||
\ buffer_number,
|
||||
\ buffer_number))
|
||||
|
||||
endfor
|
||||
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_buffers_extractor.colorize()
|
||||
syntax match FileName /.*\zs\/.*\ze/
|
||||
|
||||
hi link FileName Identifier
|
||||
endfunction
|
||||
|
||||
54
vim/autoload/railmoon/oscan/extractor/changes.vim
Normal file
54
vim/autoload/railmoon/oscan/extractor/changes.vim
Normal file
@@ -0,0 +1,54 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#changes
|
||||
" Purpose: extract recently changed lines to jump to
|
||||
|
||||
function! railmoon#oscan#extractor#changes#create()
|
||||
let new_extractor = copy(s:tag_scan_changes_extractor)
|
||||
let new_extractor.description = 'Select recently changed lines to jump to'
|
||||
let new_extractor.filetype = &filetype
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_changes_extractor = {}
|
||||
function! s:tag_scan_changes_extractor.process(record)
|
||||
exec a:record.data
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_changes_extractor.extract()
|
||||
let result = []
|
||||
|
||||
redir => changes_string
|
||||
silent changes
|
||||
redir END
|
||||
|
||||
let changes_list = split(changes_string, "\n")
|
||||
let pattern = '\s*\(\d\+\)\s*\(\d\+\)\s*\(\d\+\)\s*\(.*\)$'
|
||||
|
||||
call reverse(changes_list)
|
||||
for change_el in changes_list
|
||||
if change_el !~ pattern
|
||||
continue
|
||||
endif
|
||||
|
||||
let line_number = substitute(change_el, pattern, '\2', '')
|
||||
let line = substitute(change_el, pattern, '\4', '')
|
||||
|
||||
let tags = railmoon#oscan#extractor#util#tags_from_line(line)
|
||||
|
||||
let header = [ line ]
|
||||
call add(result, railmoon#oscan#record#create( header,
|
||||
\ tags,
|
||||
\ line_number,
|
||||
\ line_number))
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_changes_extractor.colorize()
|
||||
endfunction
|
||||
|
||||
137
vim/autoload/railmoon/oscan/extractor/ctags.vim
Executable file
137
vim/autoload/railmoon/oscan/extractor/ctags.vim
Executable file
@@ -0,0 +1,137 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#ctags
|
||||
" Purpose: extract ctags record from current buffer
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#create()
|
||||
let new_extractor = copy(s:tag_scan_ctags_extractor)
|
||||
|
||||
let new_extractor.file_name = expand("%:p")
|
||||
let new_extractor.buffer_number = bufnr('%')
|
||||
let new_extractor.file_extension = expand("%:e")
|
||||
let new_extractor.filetype = &filetype
|
||||
let new_extractor.description = 'Extract ctags records from "'.new_extractor.file_name.'"'
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#language_function(language, function_name,...)
|
||||
call railmoon#trace#debug( 'call language_function "'.a:function_name.'" for "'.a:language.'"' )
|
||||
try
|
||||
let result = eval('railmoon#oscan#extractor#ctags#'.a:language.'#'.a:function_name.'('.join(a:000,',').')')
|
||||
catch /.*/
|
||||
call railmoon#trace#debug( 'failed.['.v:exception.'] use cpp' )
|
||||
let result = eval('railmoon#oscan#extractor#ctags#cpp#'.a:function_name.'('.join(a:000,',').')')
|
||||
endtry
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#colorize_for_langauge(language)
|
||||
call railmoon#oscan#extractor#ctags#language_function(a:language, 'colorize')
|
||||
endfunction
|
||||
|
||||
" by language name return kinds to use while ctags build tags base
|
||||
" default language c++
|
||||
function! railmoon#oscan#extractor#ctags#kind_types_for_langauge(language)
|
||||
return railmoon#oscan#extractor#ctags#language_function(a:language, 'kinds')
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#process(tag_item)
|
||||
try
|
||||
let previous_magic = &magic
|
||||
set nomagic
|
||||
|
||||
if fnamemodify( @%, ':p' ) != fnamemodify( a:tag_item.filename, ':p' )
|
||||
exec 'silent edit '.a:tag_item.filename
|
||||
endif
|
||||
|
||||
silent 1
|
||||
exec a:tag_item.cmd
|
||||
finally
|
||||
let &magic = previous_magic
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" by language name and ctags tag return record
|
||||
" default language c++
|
||||
function! railmoon#oscan#extractor#ctags#record_for_language_tag( language, ctag_item )
|
||||
return railmoon#oscan#extractor#ctags#language_function( a:language, 'record', a:ctag_item )
|
||||
endfunction
|
||||
|
||||
" return language name by extension
|
||||
" default language c++
|
||||
function! railmoon#oscan#extractor#ctags#language_by_extension( extension )
|
||||
if index(['c', 'cpp', 'h', 'cxx', 'hxx', 'cc', 'hh', 'hpp'], a:extension) != -1
|
||||
return 'cpp'
|
||||
elseif a:extension == 'vim'
|
||||
return 'vim'
|
||||
elseif a:extension == 'pl'
|
||||
return 'perl'
|
||||
elseif a:extension == 'py'
|
||||
return 'python'
|
||||
endif
|
||||
|
||||
return 'cpp'
|
||||
endfunction
|
||||
|
||||
" return language name for current buffer
|
||||
" default language c++
|
||||
function! railmoon#oscan#extractor#ctags#language_by_current_buffer()
|
||||
let extension = fnamemodify(@%, ':e')
|
||||
let language = exists( '&filetype' ) ? &filetype : railmoon#oscan#extractor#ctags#language_by_extension(extension)
|
||||
|
||||
return language
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_ctags_extractor = {}
|
||||
function! s:tag_scan_ctags_extractor.process(record)
|
||||
call railmoon#oscan#extractor#ctags#process(a:record.data)
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_ctags_extractor.extract()
|
||||
let result = []
|
||||
|
||||
let self.language = railmoon#oscan#extractor#ctags#language_by_current_buffer()
|
||||
|
||||
" fields
|
||||
" f - file name
|
||||
" s - structures
|
||||
" i - inherits
|
||||
" k - kinds
|
||||
" K - kinds full written
|
||||
" a - access
|
||||
" l - language
|
||||
" t,m,z - unknown for me yet
|
||||
" n - line numbers
|
||||
" S - signature
|
||||
" extra
|
||||
" q - tag names include namespace
|
||||
" f - file names added
|
||||
let ctags_tags = railmoon#ctags_util#taglist_for_file(self.file_name,
|
||||
\ self.language,
|
||||
\ railmoon#oscan#extractor#ctags#kind_types_for_langauge(self.language),
|
||||
\ 'sikaS')
|
||||
|
||||
for item in ctags_tags
|
||||
let record = railmoon#oscan#extractor#ctags#record_for_language_tag(self.language, item)
|
||||
|
||||
" no need file name to show in each row ( all tags in one file )
|
||||
let record.additional_info = ''
|
||||
|
||||
call add(result, record)
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#colorize_keywords(language)
|
||||
call railmoon#oscan#extractor#ctags#colorize_for_langauge(a:language)
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_ctags_extractor.colorize()
|
||||
let &filetype = self.filetype
|
||||
call railmoon#oscan#extractor#ctags#colorize_for_langauge(self.language)
|
||||
endfunction
|
||||
153
vim/autoload/railmoon/oscan/extractor/ctags/cpp.vim
Executable file
153
vim/autoload/railmoon/oscan/extractor/ctags/cpp.vim
Executable file
@@ -0,0 +1,153 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#ctags#cpp
|
||||
" Purpose: extract ctags cpp record from buffer
|
||||
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#cpp#kinds()
|
||||
return "cdefgmnpstuvx"
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#cpp#colorize()
|
||||
syntax keyword Type variable inner field enumeration function method public private protected global
|
||||
syntax keyword Keyword constructor destructor
|
||||
syntax keyword Identifier decl def
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#cpp#record( tag_item )
|
||||
let tag_list = []
|
||||
let header = ""
|
||||
let line_number = a:tag_item.cmd
|
||||
|
||||
let kind = a:tag_item.kind
|
||||
let namespace = has_key(a:tag_item, 'namespace') ? a:tag_item.namespace : ''
|
||||
|
||||
let is_object = 0
|
||||
let object_name = ''
|
||||
|
||||
for name in ( [ has_key(a:tag_item, 'class') ? a:tag_item.class : ''
|
||||
\, has_key(a:tag_item, 'struct') ? a:tag_item.struct : ''
|
||||
\, has_key(a:tag_item, 'enum') ? a:tag_item.enum : ''
|
||||
\, has_key(a:tag_item, 'union') ? a:tag_item.union : '' ] )
|
||||
if ! empty(name)
|
||||
let object_name = name
|
||||
let is_object = 1
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
|
||||
let tagname = split(a:tag_item.name, '::')[ -1]
|
||||
|
||||
let is_constructor = 0
|
||||
let is_destructor = 0
|
||||
|
||||
if is_object
|
||||
let last_part_of_object_name = split(object_name, '::')[ -1]
|
||||
let is_constructor = tagname == last_part_of_object_name
|
||||
let is_destructor = tagname == '~'.last_part_of_object_name
|
||||
endif
|
||||
|
||||
|
||||
if kind == 'f' || kind == 'p'
|
||||
if is_object
|
||||
if is_constructor
|
||||
let header .= 'constructor '
|
||||
call add(tag_list, 'constructor')
|
||||
elseif is_destructor
|
||||
let header .= 'destructor '
|
||||
call add(tag_list, 'destructor')
|
||||
else
|
||||
let header .= 'method '
|
||||
call add(tag_list, 'method')
|
||||
endif
|
||||
else
|
||||
let header .= "function "
|
||||
call add(tag_list, "function")
|
||||
endif
|
||||
|
||||
if kind == 'p'
|
||||
let header .= 'decl. '
|
||||
call add(tag_list, "decl")
|
||||
else
|
||||
let header .= 'def. '
|
||||
call add(tag_list, "def")
|
||||
endif
|
||||
elseif kind == 'c'
|
||||
let header .= "class "
|
||||
call add(tag_list, "class")
|
||||
call add(tag_list, "object")
|
||||
elseif kind == 'u'
|
||||
let header .= "union "
|
||||
call add(tag_list, "union")
|
||||
call add(tag_list, "object")
|
||||
elseif kind == 's'
|
||||
let header .= "struct "
|
||||
call add(tag_list, "struct")
|
||||
call add(tag_list, "object")
|
||||
elseif kind == 'g'
|
||||
let header .= "enum "
|
||||
call add(tag_list, "enum")
|
||||
elseif kind == 'd'
|
||||
let header .= "#define "
|
||||
call add(tag_list, "define")
|
||||
elseif kind == 'm'
|
||||
let header .= "field "
|
||||
call add(tag_list, "field")
|
||||
elseif kind == 'n'
|
||||
let header .= "namespace "
|
||||
call add(tag_list, "namespace")
|
||||
elseif kind == 't'
|
||||
let header .= "typedef "
|
||||
call add(tag_list, "typedef")
|
||||
elseif kind == 'v'
|
||||
let header .= "global variable "
|
||||
call extend(tag_list, ["variable", "global"])
|
||||
elseif kind == 'e'
|
||||
let header .= "enumeration "
|
||||
call add(tag_list, "enumeration")
|
||||
endif
|
||||
|
||||
call add(tag_list, tagname)
|
||||
if is_object
|
||||
call extend(tag_list, split(object_name, '::'))
|
||||
endif
|
||||
|
||||
if ! empty(namespace)
|
||||
call extend(tag_list, split(namespace, '::'))
|
||||
endif
|
||||
|
||||
if is_object
|
||||
let header .= object_name.'::'
|
||||
endif
|
||||
|
||||
if ! empty(namespace)
|
||||
let header .= namespace.'::'
|
||||
endif
|
||||
|
||||
let header .= tagname
|
||||
|
||||
if kind =~ '[fp]' && has_key(a:tag_item, 'signature')
|
||||
let header .= a:tag_item.signature
|
||||
endif
|
||||
|
||||
let access = has_key(a:tag_item, 'access') ? a:tag_item.access : ''
|
||||
|
||||
if ! empty(access)
|
||||
if kind =~ '[csug]'
|
||||
call add(tag_list, 'inner')
|
||||
let header = 'inner '.header
|
||||
endif
|
||||
|
||||
let header = access.' '.header
|
||||
call add(tag_list, access)
|
||||
endif
|
||||
|
||||
let file_name = has_key(a:tag_item, 'filename') ? a:tag_item.filename : ''
|
||||
|
||||
return railmoon#oscan#record#create([header], tag_list, a:tag_item, fnamemodify(file_name, ':t'))
|
||||
endfunction
|
||||
|
||||
|
||||
|
||||
42
vim/autoload/railmoon/oscan/extractor/ctags/html.vim
Normal file
42
vim/autoload/railmoon/oscan/extractor/ctags/html.vim
Normal file
@@ -0,0 +1,42 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#ctags#py
|
||||
" Purpose: extract ctags html record from buffer
|
||||
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#html#kinds()
|
||||
return "af"
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#html#colorize()
|
||||
syntax keyword Type anchor function
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#html#record( tag_item )
|
||||
let tag_list = []
|
||||
let header = ""
|
||||
|
||||
let kind = a:tag_item.kind
|
||||
|
||||
let tagname = a:tag_item.name
|
||||
"let tagname = substitute( tagname, "'\\(.*\\)'", "\1", "g" )
|
||||
|
||||
if kind =~ 'a'
|
||||
let header .= 'anchor '
|
||||
call add(tag_list, 'anchor')
|
||||
elseif kind == 'f'
|
||||
let header .= "function "
|
||||
call add(tag_list, "function")
|
||||
endif
|
||||
|
||||
call add(tag_list, tagname)
|
||||
|
||||
let header .= tagname
|
||||
|
||||
let file_name = has_key(a:tag_item, 'filename') ? a:tag_item.filename : ''
|
||||
|
||||
return railmoon#oscan#record#create([header], tag_list, a:tag_item, fnamemodify(file_name, ':t'))
|
||||
endfunction
|
||||
|
||||
91
vim/autoload/railmoon/oscan/extractor/ctags/python.vim
Normal file
91
vim/autoload/railmoon/oscan/extractor/ctags/python.vim
Normal file
@@ -0,0 +1,91 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#ctags#py
|
||||
" Purpose: extract ctags python record from buffer
|
||||
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#python#kinds()
|
||||
return "cfm"
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#python#colorize()
|
||||
syntax keyword Type class function method inner public private
|
||||
syntax keyword Keyword constructor method
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#python#record( tag_item )
|
||||
let tag_list = []
|
||||
let header = ""
|
||||
let line_number = a:tag_item.cmd
|
||||
|
||||
let kind = a:tag_item.kind
|
||||
|
||||
let is_object = 0
|
||||
let object_name = ''
|
||||
|
||||
for name in ( [ has_key(a:tag_item, 'class') ? a:tag_item.class : '' ] )
|
||||
if ! empty(name)
|
||||
let object_name = name
|
||||
let is_object = 1
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
|
||||
let tagname = a:tag_item.name
|
||||
|
||||
let is_constructor = 0
|
||||
|
||||
if is_object
|
||||
let is_constructor = tagname == '__init__'
|
||||
endif
|
||||
|
||||
if kind == 'm'
|
||||
if is_object
|
||||
if is_constructor
|
||||
let header .= 'constructor '
|
||||
call add(tag_list, 'constructor')
|
||||
else
|
||||
let header .= 'method '
|
||||
call add(tag_list, 'method')
|
||||
endif
|
||||
endif
|
||||
elseif kind == 'c'
|
||||
let header .= "class "
|
||||
call add(tag_list, "class")
|
||||
call add(tag_list, "object")
|
||||
elseif kind == 'm'
|
||||
let header .= "function "
|
||||
call add(tag_list, "function")
|
||||
endif
|
||||
|
||||
call add(tag_list, tagname)
|
||||
if is_object
|
||||
call extend(tag_list, split(object_name, '::'))
|
||||
endif
|
||||
|
||||
if is_object
|
||||
let header .= object_name.'.'
|
||||
endif
|
||||
|
||||
let header .= tagname
|
||||
|
||||
if kind == 'c' && ! empty(object_name)
|
||||
call add(tag_list, 'inner')
|
||||
let header = 'inner '.header
|
||||
endif
|
||||
|
||||
let access = has_key(a:tag_item, 'access') ? a:tag_item.access : ''
|
||||
if ! empty(access)
|
||||
let header = access.' '.header
|
||||
call add(tag_list, access)
|
||||
endif
|
||||
|
||||
let file_name = has_key(a:tag_item, 'filename') ? a:tag_item.filename : ''
|
||||
|
||||
return railmoon#oscan#record#create([header], tag_list, a:tag_item, fnamemodify(file_name, ':t'))
|
||||
endfunction
|
||||
|
||||
|
||||
|
||||
43
vim/autoload/railmoon/oscan/extractor/ctags/vim.vim
Executable file
43
vim/autoload/railmoon/oscan/extractor/ctags/vim.vim
Executable file
@@ -0,0 +1,43 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#ctags#vim
|
||||
" Purpose: extract ctags vim record from buffer
|
||||
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#vim#kinds()
|
||||
return "afk"
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#vim#colorize()
|
||||
syntax keyword Type function variable autogroup
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#ctags#vim#record( tag_item )
|
||||
let tag_list = []
|
||||
let header = ""
|
||||
let line_number = a:tag_item
|
||||
|
||||
let kind = a:tag_item.kind
|
||||
|
||||
call add(tag_list, a:tag_item.name)
|
||||
|
||||
if kind == 'a'
|
||||
let header .= "autogroup "
|
||||
call add(tag_list, "autogroup")
|
||||
elseif kind == 'f'
|
||||
let header .= "function "
|
||||
call add(tag_list, "function")
|
||||
elseif kind == 'v'
|
||||
let header .= "variable "
|
||||
call add(tag_list, "variable")
|
||||
endif
|
||||
|
||||
let header .= a:tag_item.name
|
||||
|
||||
return railmoon#oscan#record#create( [ ' '.header ], tag_list, line_number)
|
||||
endfunction
|
||||
|
||||
|
||||
|
||||
121
vim/autoload/railmoon/oscan/extractor/definition_declaration.vim
Executable file
121
vim/autoload/railmoon/oscan/extractor/definition_declaration.vim
Executable file
@@ -0,0 +1,121 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#definition_declaration
|
||||
" Purpose: extract ctags record from buffer
|
||||
|
||||
function! railmoon#oscan#extractor#definition_declaration#create()
|
||||
let new_extractor = copy(s:tag_scan_definition_declaration_extractor)
|
||||
|
||||
let new_extractor.file_name = expand("%:p")
|
||||
let new_extractor.buffer_number = bufnr('%')
|
||||
let new_extractor.file_extension = expand("%:e")
|
||||
let new_extractor.filetype = &filetype
|
||||
let new_extractor.description = 'Go to possible definition/declaration for current function'
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
|
||||
let s:tag_scan_definition_declaration_extractor = {}
|
||||
function! s:tag_scan_definition_declaration_extractor.process(record)
|
||||
call railmoon#oscan#extractor#ctags#process(a:record.data)
|
||||
endfunction
|
||||
|
||||
function! s:get_nearest_ctags_tag()
|
||||
let filename = @%
|
||||
let linenumber = line('.')
|
||||
|
||||
let self.language = railmoon#oscan#extractor#ctags#language_by_current_buffer()
|
||||
|
||||
let ctags_tags = railmoon#ctags_util#taglist_for_file(filename, language, railmoon#oscan#extractor#ctags#kind_types_for_langauge(language), 'sikaS')
|
||||
|
||||
let i = len(ctags_tags) - 1
|
||||
while i >= 0
|
||||
let tag_item = ctags_tags[i]
|
||||
|
||||
if linenumber >= tag_item.cmd
|
||||
return tag_item
|
||||
endif
|
||||
let i -= 1
|
||||
endwhile
|
||||
|
||||
return {}
|
||||
endfunction
|
||||
|
||||
function! s:is_equal_tag_attribute(tag_left, tag_right, attribute)
|
||||
let left_has_attribute = has_key(a:tag_left, a:attribute)
|
||||
let right_has_attribute = has_key(a:tag_right, a:attribute)
|
||||
|
||||
if left_has_attribute && right_has_attribute
|
||||
return a:tag_left[a:attribute] == a:tag_right[a:attribute]
|
||||
endif
|
||||
|
||||
if ! left_has_attribute && ! right_has_attribute
|
||||
return 1
|
||||
endif
|
||||
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! s:return_definitions(ctags_tag)
|
||||
let result = []
|
||||
let similar_tags = taglist('\<'.a:ctags_tag.name.'\>')
|
||||
|
||||
for tag_item in similar_tags
|
||||
if tag_item.kind == 'p'
|
||||
continue
|
||||
endif
|
||||
|
||||
if s:is_equal_tag_attribute(a:ctags_tag, tag_item, 'class') &&
|
||||
\ s:is_equal_tag_attribute(a:ctags_tag, tag_item, 'namespace')
|
||||
|
||||
call add(result, tag_item)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:return_declarations(ctags_tag)
|
||||
let result = []
|
||||
let similar_tags = taglist('\<'.a:ctags_tag.name.'\>')
|
||||
|
||||
for tag_item in similar_tags
|
||||
if tag_item.kind != 'p'
|
||||
continue
|
||||
endif
|
||||
|
||||
if s:is_equal_tag_attribute(a:ctags_tag, tag_item, 'class') &&
|
||||
\ s:is_equal_tag_attribute(a:ctags_tag, tag_item, 'namespace')
|
||||
|
||||
call add(result, tag_item)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_definition_declaration_extractor.extract()
|
||||
let result = []
|
||||
|
||||
let extension = self.file_extension
|
||||
let language = railmoon#oscan#extractor#ctags#language_by_extension(extension)
|
||||
let self.language = language
|
||||
|
||||
let nearest_tag = s:get_nearest_ctags_tag()
|
||||
let ctags_tags = nearest_tag.kind =~ 'p' ? s:return_definitions(nearest_tag) : s:return_declarations(nearest_tag)
|
||||
|
||||
for item in ctags_tags
|
||||
let record = railmoon#oscan#extractor#ctags#record_for_language_tag(language, item)
|
||||
call add(result, record)
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_definition_declaration_extractor.colorize()
|
||||
let &filetype = self.filetype
|
||||
call railmoon#oscan#extractor#ctags#colorize_keywords(self.language)
|
||||
endfunction
|
||||
31
vim/autoload/railmoon/oscan/extractor/file.vim
Executable file
31
vim/autoload/railmoon/oscan/extractor/file.vim
Executable file
@@ -0,0 +1,31 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#file
|
||||
" Purpose: create extractor by file extension and or name
|
||||
|
||||
function! railmoon#oscan#extractor#file#create()
|
||||
let file_name = expand("%:p")
|
||||
let file_extension = expand("%:e")
|
||||
|
||||
|
||||
try
|
||||
return eval('railmoon#oscan#extractor#'.file_extension.'#'.'create()')
|
||||
catch /.*/
|
||||
endtry
|
||||
|
||||
let extractor_name = 'railmoon#oscan#extractor#ctags'
|
||||
|
||||
try
|
||||
let extractor = eval(extractor_name.'#'.'create()')
|
||||
catch /.*/
|
||||
echo 'extractor "'.extractor_name. '" not found. use ctags as default'
|
||||
echo '.'
|
||||
echo '.'
|
||||
echo '.'
|
||||
endtry
|
||||
|
||||
return railmoon#oscan#extractor#ctags#create()
|
||||
endfunction
|
||||
|
||||
86
vim/autoload/railmoon/oscan/extractor/files.vim
Normal file
86
vim/autoload/railmoon/oscan/extractor/files.vim
Normal file
@@ -0,0 +1,86 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#files
|
||||
" Purpose: extract files from current file directory to open
|
||||
|
||||
function! railmoon#oscan#extractor#files#create()
|
||||
let new_extractor = copy(s:tag_scan_files_extractor)
|
||||
|
||||
let file_name = expand("%:p")
|
||||
let new_extractor.current_file_dir = fnamemodify(file_name, ":p:h")
|
||||
|
||||
let new_extractor.description = 'Select file from "'.new_extractor.current_file_dir.'" directory to open'
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_files_extractor = {}
|
||||
function! s:tag_scan_files_extractor.process(record)
|
||||
if &modified
|
||||
let choice = inputlist( [ "Buffer is modified.", "1. Save current and continue" , "2. Break", "3. Open in new tab" ] )
|
||||
if 1 == choice
|
||||
update
|
||||
elseif 2 == choice
|
||||
return
|
||||
elseif 3 == choice
|
||||
tab new
|
||||
else
|
||||
tab new
|
||||
endif
|
||||
endif
|
||||
|
||||
let buf_number = bufnr(a:record.data)
|
||||
if -1 == buf_number
|
||||
exec 'edit '.escape(a:record.data,' ')
|
||||
else
|
||||
exec 'buffer '.buf_number
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_files_extractor.tags_by_name(buffer_name, buffer_number)
|
||||
let tags = railmoon#oscan#extractor#util#tags_from_file_name(a:buffer_name)
|
||||
|
||||
if index(tags, string(a:buffer_number)) == -1
|
||||
call add(tags, a:buffer_number)
|
||||
endif
|
||||
|
||||
return tags
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_files_extractor.header_by_name(buffer_name, buffer_number)
|
||||
return [ a:buffer_name ]
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_files_extractor.extract()
|
||||
let result = []
|
||||
|
||||
let files = split(glob( self.current_file_dir."/*" ), "\n")
|
||||
"call extend(files, split(glob( self.current_file_dir."/.*" ), "\n"))
|
||||
|
||||
for file in files
|
||||
|
||||
if ! filereadable(file)
|
||||
continue
|
||||
endif
|
||||
|
||||
let just_name = fnamemodify(file, ":t:r")
|
||||
let ext = fnamemodify(file, ":e")
|
||||
|
||||
let tags = [ just_name, ext ]
|
||||
|
||||
call add(result, railmoon#oscan#record#create( [ just_name ],
|
||||
\ tags,
|
||||
\ file,
|
||||
\ ext))
|
||||
|
||||
endfor
|
||||
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_files_extractor.colorize()
|
||||
endfunction
|
||||
|
||||
86
vim/autoload/railmoon/oscan/extractor/marks.vim
Executable file
86
vim/autoload/railmoon/oscan/extractor/marks.vim
Executable file
@@ -0,0 +1,86 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#marks
|
||||
" Purpose: extract marks to select
|
||||
|
||||
function! railmoon#oscan#extractor#marks#create()
|
||||
let new_extractor = copy(s:tag_scan_marks_extractor)
|
||||
let new_extractor.description = 'Select mark to jump'
|
||||
let new_extractor.filetype = &filetype
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_marks_extractor = {}
|
||||
function! s:tag_scan_marks_extractor.process(record)
|
||||
exec "normal \'".a:record.data
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_marks_extractor.extract()
|
||||
let result = []
|
||||
|
||||
redir => marks_string
|
||||
silent marks
|
||||
redir END
|
||||
|
||||
let marks_list = split(marks_string, "\n")
|
||||
let pattern = '\s*\(\S\+\)\s*\(\d\+\)\s*\(\d\+\)\s*\(.*\)$'
|
||||
|
||||
for mark_value in marks_list
|
||||
if mark_value !~ pattern
|
||||
continue
|
||||
endif
|
||||
|
||||
let mark_symbol = substitute(mark_value, pattern, '\1', '')
|
||||
let mark_line = substitute(mark_value, pattern, '\2', '')
|
||||
let mark_col = substitute(mark_value, pattern, '\3', '')
|
||||
let mark_file_or_line = substitute(mark_value, pattern, '\4', '')
|
||||
|
||||
let tags = []
|
||||
|
||||
let file_name = fnamemodify(mark_file_or_line, ':p')
|
||||
|
||||
let is_file = filereadable(file_name)
|
||||
|
||||
if is_file
|
||||
let header_line = '<# '.file_name.' #>'
|
||||
let tags = railmoon#oscan#extractor#util#tags_from_file_name(file_name)
|
||||
else
|
||||
let header_line = mark_file_or_line
|
||||
let tags = split(mark_file_or_line, '\W')
|
||||
call filter(tags, 'v:val != ""')
|
||||
call add(tags, 'buffer')
|
||||
endif
|
||||
|
||||
if mark_symbol =~ '[QWERTYUIOPASDFGHJKLZXCVBNM1234567890]'
|
||||
call add(tags, 'global')
|
||||
endif
|
||||
|
||||
if mark_symbol =~ '[QWERTYUIOPASDFGHJKLZXCVBNM]'
|
||||
call add(tags, 'user')
|
||||
endif
|
||||
|
||||
let header_line = printf("%5s %5s ", mark_line, mark_col).header_line
|
||||
|
||||
let header = [ header_line ]
|
||||
call add(result, railmoon#oscan#record#create( header,
|
||||
\ tags,
|
||||
\ mark_symbol,
|
||||
\ mark_symbol))
|
||||
endfor
|
||||
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_marks_extractor.colorize()
|
||||
syn match Comment /.*/ contained contains=Identifier
|
||||
syn region Identifier matchgroup=Ignore start='<#' end='#>' contained
|
||||
|
||||
syn match TODO /\|/ nextgroup=Keyword
|
||||
syn match Keyword /\d\+\s/ nextgroup=Statement contained skipwhite
|
||||
syn match Statement /\d\+/ nextgroup=Comment contained skipwhite
|
||||
endfunction
|
||||
|
||||
123
vim/autoload/railmoon/oscan/extractor/multiline_search.vim
Executable file
123
vim/autoload/railmoon/oscan/extractor/multiline_search.vim
Executable file
@@ -0,0 +1,123 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#multiline_search
|
||||
" Purpose: extract strings ( and their neighbours) with search pattern from current file
|
||||
|
||||
function! railmoon#oscan#extractor#multiline_search#create()
|
||||
let new_extractor = copy(s:tag_scan_multiline_search_extractor)
|
||||
|
||||
let new_extractor.file_name = expand("%:p")
|
||||
let new_extractor.file_extension = expand("%:e")
|
||||
let new_extractor.first_line_to_search = 1
|
||||
let new_extractor.last_line_to_search = line('$')
|
||||
let new_extractor.pattern = @/
|
||||
let new_extractor.filetype = &filetype
|
||||
let new_extractor.description = 'Mutliline search "'.new_extractor.pattern.'" in "'.new_extractor.file_name.'"'
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_multiline_search_extractor = {}
|
||||
function! s:tag_scan_multiline_search_extractor.process(record)
|
||||
exec a:record.data
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_multiline_search_extractor.tags_by_line(line_number_start, data)
|
||||
let tags = []
|
||||
|
||||
let i = 0
|
||||
for line in a:data
|
||||
call extend(tags, railmoon#oscan#extractor#util#tags_from_searched_line(a:line_number_start + i, line) )
|
||||
let i += 1
|
||||
endfor
|
||||
|
||||
return tags
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_multiline_search_extractor.extract()
|
||||
let result = []
|
||||
|
||||
let pos = getpos('.')
|
||||
|
||||
call cursor(self.first_line_to_search, 1)
|
||||
|
||||
let pattern = self.pattern
|
||||
let last_search_result = -1
|
||||
|
||||
let option = 'Wc'
|
||||
|
||||
let match_pattern_line_numbers = []
|
||||
|
||||
while 1
|
||||
let search_result = search(pattern, option, self.last_line_to_search)
|
||||
|
||||
if search_result == 0
|
||||
break
|
||||
endif
|
||||
|
||||
if search_result != last_search_result
|
||||
call add(match_pattern_line_numbers, search_result)
|
||||
endif
|
||||
|
||||
let last_search_result = search_result
|
||||
let option = 'W'
|
||||
endwhile
|
||||
|
||||
let match_cout = len(match_pattern_line_numbers)
|
||||
|
||||
if match_cout == 0
|
||||
return result
|
||||
endif
|
||||
|
||||
let min_block_size = 2
|
||||
let i = 0
|
||||
|
||||
while i < match_cout
|
||||
|
||||
let block_begin = match_pattern_line_numbers[i] - min_block_size
|
||||
let delta = 0
|
||||
if block_begin < self.first_line_to_search
|
||||
let delta = self.first_line_to_search - block_begin
|
||||
let block_begin = self.first_line_to_search
|
||||
endif
|
||||
|
||||
let block_end = match_pattern_line_numbers[i] + min_block_size + delta
|
||||
if block_end > self.last_line_to_search
|
||||
let block_end = self.last_line_to_search
|
||||
endif
|
||||
|
||||
while i < match_cout
|
||||
if match_pattern_line_numbers[i] - min_block_size > block_end
|
||||
let i -= 1
|
||||
break
|
||||
endif
|
||||
|
||||
let block_end = match_pattern_line_numbers[i] + min_block_size
|
||||
|
||||
let i += 1
|
||||
endwhile
|
||||
|
||||
let data = getline(block_begin, block_end)
|
||||
let tag_list = self.tags_by_line(block_begin, data)
|
||||
|
||||
call add(tag_list, block_begin)
|
||||
|
||||
call add(result, railmoon#oscan#record#create(data, tag_list, block_begin, block_begin))
|
||||
|
||||
let i +=1
|
||||
endwhile
|
||||
|
||||
|
||||
call setpos('.', pos)
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_multiline_search_extractor.colorize()
|
||||
let &filetype = self.filetype
|
||||
exec 'syn match Search "'.'\c'.self.pattern.'"'
|
||||
" exec 'syn match Identifier "[**].*"'
|
||||
endfunction
|
||||
|
||||
69
vim/autoload/railmoon/oscan/extractor/paste.vim
Normal file
69
vim/autoload/railmoon/oscan/extractor/paste.vim
Normal file
@@ -0,0 +1,69 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#paste
|
||||
" Purpose: extract registers texts to paste
|
||||
|
||||
function! railmoon#oscan#extractor#paste#create()
|
||||
let new_extractor = copy(s:tag_scan_paste_extractor)
|
||||
let new_extractor.description = 'Select register to paste'
|
||||
let new_extractor.filetype = &filetype
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_paste_extractor = {}
|
||||
function! s:tag_scan_paste_extractor.process(record)
|
||||
exec 'normal "'.a:record.data."p"
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_paste_extractor.extract()
|
||||
let result = []
|
||||
|
||||
redir => paste_string
|
||||
silent registers
|
||||
redir END
|
||||
|
||||
let paste_list = split(paste_string, "\n")
|
||||
let pattern = '^"\(\S\)\s\s\s\(.*\)$'
|
||||
|
||||
for line in paste_list
|
||||
if line !~ pattern
|
||||
continue
|
||||
endif
|
||||
|
||||
let register_name = substitute(line, pattern, '\1', '')
|
||||
let register_value = eval('@'.register_name)
|
||||
|
||||
let tags = railmoon#oscan#extractor#util#tags_from_line(register_value)
|
||||
|
||||
let register_value_list = split( register_value, "\n" )
|
||||
let shortened_value_list = register_value_list
|
||||
if len( register_value_list ) > 5
|
||||
let shortened_value_list = register_value_list[0:2]
|
||||
call add(shortened_value_list, "... more ...")
|
||||
call extend(shortened_value_list, register_value_list[-2:-1])
|
||||
endif
|
||||
|
||||
let additional_data = register_name
|
||||
let header = shortened_value_list
|
||||
|
||||
if empty(header)
|
||||
continue
|
||||
endif
|
||||
|
||||
call add(result, railmoon#oscan#record#create(header,
|
||||
\ tags,
|
||||
\ register_name,
|
||||
\ register_name))
|
||||
endfor
|
||||
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_paste_extractor.colorize()
|
||||
syn match Identifier /\.\.\. more \.\.\./
|
||||
endfunction
|
||||
|
||||
138
vim/autoload/railmoon/oscan/extractor/sco.vim
Executable file
138
vim/autoload/railmoon/oscan/extractor/sco.vim
Executable file
@@ -0,0 +1,138 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#sco
|
||||
" Purpose: extract sco taged headers or sco folded result
|
||||
|
||||
function! railmoon#oscan#extractor#sco#create()
|
||||
let new_extractor = copy(s:tag_scan_sco_extractor)
|
||||
|
||||
|
||||
let new_extractor.folded_result_start = searchpair('>>>', '', '<<<', 'bnW')
|
||||
let new_extractor.folded_result_end = searchpair('>>>', '', '<<<', 'nW')
|
||||
|
||||
let new_extractor.buffer_number = bufnr('%')
|
||||
|
||||
let new_extractor.is_extract_tag_headers = 0 == new_extractor.folded_result_start
|
||||
|
||||
if new_extractor.is_extract_tag_headers
|
||||
let new_extractor.description = 'SourceCodeObedience. Select header to move to'
|
||||
else
|
||||
let new_extractor.description = 'SourceCodeObedience. Select result to move to'
|
||||
endif
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_sco_extractor = {}
|
||||
function! s:tag_scan_sco_extractor.process(record)
|
||||
exec 'buffer '.self.buffer_number
|
||||
update
|
||||
e
|
||||
exec a:record.data
|
||||
|
||||
if ! self.is_extract_tag_headers
|
||||
Enter
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_sco_extractor.taged_headers_tags_by_line(line_number, line)
|
||||
return split(substitute(a:line, '^\s*tags:\(.*\)', '\1', ''), ',')
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_sco_extractor.taged_headers_header_by_line(line_number, line)
|
||||
let line_with_header = getline(a:line_number - 1)
|
||||
if line_with_header =~ '^\s*header:'
|
||||
return [ substitute(line_with_header, '^\s*header:\(.*\)', '\1', '') ]
|
||||
endif
|
||||
|
||||
return [ '[ '.substitute(a:line, '^\s*tags:\(.*\)', '\1', '').' ]' ]
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_sco_extractor.extract_taged_headers()
|
||||
let result = []
|
||||
|
||||
let pos = getpos('.')
|
||||
call cursor(1, 1)
|
||||
|
||||
let pattern = '^\s*tags:'
|
||||
|
||||
let option = 'Wc'
|
||||
|
||||
while 1
|
||||
let search_result = search(pattern, option)
|
||||
|
||||
if search_result == 0
|
||||
break
|
||||
endif
|
||||
|
||||
let line = getline(search_result)
|
||||
|
||||
let data = self.taged_headers_header_by_line(search_result, line)
|
||||
let tag_list = self.taged_headers_tags_by_line(search_result, line)
|
||||
|
||||
call add(result, railmoon#oscan#record#create(data, tag_list, search_result, search_result))
|
||||
|
||||
let option = 'W'
|
||||
endwhile
|
||||
|
||||
call setpos('.', pos)
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
let s:smart_mark_pattern_comment = '\s\+```\(.*[^>]\)>>.*$'
|
||||
let s:smart_mark_pattern_without_comment = '@\s\+\(\S\+\)\s\+\(\d*\)\s\(.*\)'
|
||||
let s:smart_mark_pattern = s:smart_mark_pattern_without_comment.s:smart_mark_pattern_comment
|
||||
|
||||
let s:sco_result_pattern = '^#\s\+\(\S\+\)\s\+\(\S\+\)\s\+\(\d\+\)\s\+\(.*\)$'
|
||||
|
||||
function! s:tag_scan_sco_extractor.extract_sco_results()
|
||||
let result = []
|
||||
|
||||
let line_number = self.folded_result_start + 1
|
||||
|
||||
while line_number < self.folded_result_end
|
||||
let line = getline(line_number)
|
||||
|
||||
if line =~ s:sco_result_pattern
|
||||
let file_name = substitute(line, s:sco_result_pattern, '\1', '')
|
||||
let function_name = substitute(line, s:sco_result_pattern, '\2', '')
|
||||
let file_line_number = substitute(line, s:sco_result_pattern, '\3', '')
|
||||
let body = substitute(line, s:sco_result_pattern, '\4', '')
|
||||
|
||||
let short_file_name = fnamemodify(file_name, ':t')
|
||||
|
||||
let tag_list = []
|
||||
call extend(tag_list, railmoon#oscan#extractor#util#tags_from_line(body))
|
||||
call add(tag_list, function_name)
|
||||
call extend(tag_list, railmoon#oscan#extractor#util#tags_from_file_name(file_name))
|
||||
|
||||
call add(result, railmoon#oscan#record#create([ body ], tag_list, line_number, short_file_name))
|
||||
endif
|
||||
|
||||
let line_number += 1
|
||||
endwhile
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_sco_extractor.extract()
|
||||
if self.is_extract_tag_headers
|
||||
return self.extract_taged_headers()
|
||||
endif
|
||||
|
||||
|
||||
return self.extract_sco_results()
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_sco_extractor.colorize()
|
||||
if self.is_extract_tag_headers
|
||||
syntax match Comment '\[.*\]' contains=Keyword
|
||||
syntax keyword Keyword tag symbol file include text grep calling contained
|
||||
else
|
||||
setf cpp
|
||||
endif
|
||||
endfunction
|
||||
|
||||
85
vim/autoload/railmoon/oscan/extractor/search.vim
Executable file
85
vim/autoload/railmoon/oscan/extractor/search.vim
Executable file
@@ -0,0 +1,85 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#search
|
||||
" Purpose: extract strings with search pattern from current file
|
||||
|
||||
function! railmoon#oscan#extractor#search#create()
|
||||
let new_extractor = copy(s:tag_scan_search_extractor)
|
||||
|
||||
let new_extractor.file_name = expand("%:p")
|
||||
let new_extractor.buffer_number = bufnr('%')
|
||||
let new_extractor.file_extension = expand("%:e")
|
||||
let new_extractor.line_number_width = len(line('$'))
|
||||
let new_extractor.first_line_to_search = 1
|
||||
let new_extractor.last_line_to_search = line('$')
|
||||
let new_extractor.pattern = @/
|
||||
let new_extractor.remove_leader_space = 1
|
||||
let new_extractor.filetype = &filetype
|
||||
let new_extractor.description = 'Search "'.new_extractor.pattern.'" in "'.new_extractor.file_name.'"'
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_search_extractor = {}
|
||||
function! s:tag_scan_search_extractor.process(record)
|
||||
exec 'buffer '.self.buffer_number
|
||||
exec a:record.data
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_search_extractor.tags_by_line(line_number, line) " line
|
||||
return railmoon#oscan#extractor#util#tags_from_searched_line(a:line_number, a:line)
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_search_extractor.header_by_line(line_number, line)
|
||||
if self.remove_leader_space
|
||||
let line = substitute(a:line, '^\s*', '', 'g')
|
||||
else
|
||||
let line = a:line
|
||||
endif
|
||||
|
||||
return [ line ]
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_search_extractor.extract()
|
||||
let result = []
|
||||
|
||||
let pos = getpos('.')
|
||||
|
||||
call cursor(self.first_line_to_search, 1)
|
||||
|
||||
let pattern = self.pattern
|
||||
let last_search_result = -1
|
||||
|
||||
let option = 'Wc'
|
||||
|
||||
while 1
|
||||
let search_result = search(pattern, option, self.last_line_to_search)
|
||||
|
||||
if search_result == 0
|
||||
break
|
||||
endif
|
||||
|
||||
if search_result != last_search_result
|
||||
let line = getline(search_result)
|
||||
|
||||
let data = self.header_by_line(search_result, line)
|
||||
let tag_list = self.tags_by_line(search_result, line)
|
||||
|
||||
call add(result, railmoon#oscan#record#create(data, tag_list, search_result, search_result))
|
||||
endif
|
||||
|
||||
let last_search_result = search_result
|
||||
let option = 'W'
|
||||
endwhile
|
||||
|
||||
call setpos('.', pos)
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_search_extractor.colorize()
|
||||
let &filetype = self.filetype
|
||||
endfunction
|
||||
|
||||
19
vim/autoload/railmoon/oscan/extractor/search_in_scope.vim
Executable file
19
vim/autoload/railmoon/oscan/extractor/search_in_scope.vim
Executable file
@@ -0,0 +1,19 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#search_in_scope
|
||||
" Purpose: extract strings that visible in current scope
|
||||
|
||||
function! railmoon#oscan#extractor#search_in_scope#create()
|
||||
let new_extractor = railmoon#oscan#extractor#search#create()
|
||||
|
||||
let new_extractor.first_line_to_search = searchpair('{', '', '}', 'bn')
|
||||
let new_extractor.last_line_to_search = searchpair('{', '', '}', 'n')
|
||||
let new_extractor.pattern = '.*'
|
||||
let new_extractor.remove_leader_space = 0
|
||||
let new_extractor.description = 'Search in current scope. '.new_extractor.first_line_to_search.':'.new_extractor.last_line_to_search
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
41
vim/autoload/railmoon/oscan/extractor/search_in_windows.vim
Executable file
41
vim/autoload/railmoon/oscan/extractor/search_in_windows.vim
Executable file
@@ -0,0 +1,41 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#search_in_windows
|
||||
" Purpose: extract strings with search pattern from all windows
|
||||
|
||||
function! railmoon#oscan#extractor#search_in_windows#create()
|
||||
let new_extractor = copy(s:tag_scan_search_in_windows_extractor)
|
||||
|
||||
let new_extractor.pattern = @/
|
||||
let new_extractor.buffer_number = bufnr('%')
|
||||
let new_extractor.filetype = &filetype
|
||||
let new_extractor.description = 'Search "'.new_extractor.pattern.'" in all opened windows'
|
||||
let new_extractor.not_implemented = 1
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_search_in_windows_extractor = {}
|
||||
function! s:tag_scan_search_in_windows_extractor.process(record)
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_search_in_windows_extractor.tags_by_line(line_number, line) " line
|
||||
"return railmoon#oscan#extractor#util#tags_from_searched_line(a:line_number, a:line)
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_search_in_windows_extractor.header_by_line(line_number, line)
|
||||
"let line = substitute(a:line, '^\s*', '', 'g')
|
||||
"return [ line ]
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_search_in_windows_extractor.search_in_buffer(tabpage_number, window_number)
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_search_in_windows_extractor.extract()
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_search_in_windows_extractor.colorize()
|
||||
endfunction
|
||||
|
||||
19
vim/autoload/railmoon/oscan/extractor/search_on_screen.vim
Executable file
19
vim/autoload/railmoon/oscan/extractor/search_on_screen.vim
Executable file
@@ -0,0 +1,19 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#search_on_screen
|
||||
" Purpose: extract strings that visible on window from current file
|
||||
|
||||
function! railmoon#oscan#extractor#search_on_screen#create()
|
||||
let new_extractor = railmoon#oscan#extractor#search#create()
|
||||
|
||||
let new_extractor.first_line_to_search = line('w0')
|
||||
let new_extractor.last_line_to_search = line('w$')
|
||||
let new_extractor.pattern = '.*'
|
||||
let new_extractor.remove_leader_space = 0
|
||||
let new_extractor.description = 'Search on current window visible range. From line '. new_extractor.first_line_to_search.' to line '.new_extractor.last_line_to_search
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
34
vim/autoload/railmoon/oscan/extractor/taglist.vim
Executable file
34
vim/autoload/railmoon/oscan/extractor/taglist.vim
Executable file
@@ -0,0 +1,34 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#ctags
|
||||
" Purpose: extract ctags record from tags
|
||||
|
||||
function! railmoon#oscan#extractor#taglist#create()
|
||||
let new_extractor = copy(s:tag_scan_taglist_extractor)
|
||||
|
||||
let new_extractor.file_name = expand("%:p")
|
||||
let new_extractor.file_extension = expand("%:e")
|
||||
let new_extractor.filetype = &filetype
|
||||
let new_extractor.description = 'Move through all tags in "set tags=..." database'
|
||||
let new_extractor.not_implemented = 1
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_taglist_extractor = {}
|
||||
function! s:tag_scan_taglist_extractor.process(record)
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:tag_scan_taglist_extractor.extract()
|
||||
let result = []
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_taglist_extractor.colorize()
|
||||
let &filetype = self.filetype
|
||||
call railmoon#oscan#extractor#ctags#colorize_keywords()
|
||||
endfunction
|
||||
|
||||
11
vim/autoload/railmoon/oscan/extractor/taglist_by_ooo.vim
Executable file
11
vim/autoload/railmoon/oscan/extractor/taglist_by_ooo.vim
Executable file
@@ -0,0 +1,11 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#taglist_by_ooo
|
||||
" Purpose: extract records by object oriented type.
|
||||
|
||||
function! railmoon#oscan#extractor#taglist_by_ooo#create()
|
||||
return railmoon#oscan#extractor#taglist_by_type#create('s')
|
||||
endfunction
|
||||
|
||||
39
vim/autoload/railmoon/oscan/extractor/taglist_by_type.vim
Executable file
39
vim/autoload/railmoon/oscan/extractor/taglist_by_type.vim
Executable file
@@ -0,0 +1,39 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#taglist_by_type
|
||||
" Purpose: extract records by type. help module for taglist_by_class , etc..
|
||||
|
||||
function! railmoon#oscan#extractor#taglist_by_type#create(type)
|
||||
let new_extractor = copy(s:tag_scan_taglist_by_type_extractor)
|
||||
|
||||
let new_extractor.file_name = expand("%:p")
|
||||
let new_extractor.file_extension = expand("%:e")
|
||||
let new_extractor.filetype = &filetype
|
||||
let new_extractor.type = a:type
|
||||
let new_extractor.description = 'Move through tags with ceratain type in "set tags=..." database "'
|
||||
let new_extractor.not_implemented = 1
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_taglist_by_type_extractor = {}
|
||||
function! s:tag_scan_taglist_by_type_extractor.process(record)
|
||||
endfunction
|
||||
|
||||
function! s:record_for_language_tag( language, ctag_item )
|
||||
return railmoon#oscan#extractor#ctags#language_function( a:language, 'record', a:ctag_item )
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_taglist_by_type_extractor.extract()
|
||||
let result = []
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_taglist_by_type_extractor.colorize()
|
||||
let &filetype = self.filetype
|
||||
call railmoon#oscan#extractor#ctags#colorize_keywords()
|
||||
endfunction
|
||||
|
||||
54
vim/autoload/railmoon/oscan/extractor/taglist_under_cursor.vim
Executable file
54
vim/autoload/railmoon/oscan/extractor/taglist_under_cursor.vim
Executable file
@@ -0,0 +1,54 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#taglist_under_cursor
|
||||
" Purpose: extract ctags records that fit word under curosr
|
||||
|
||||
function! railmoon#oscan#extractor#taglist_under_cursor#create()
|
||||
let new_extractor = copy(s:tag_scan_taglist_under_cursor_extractor)
|
||||
|
||||
let new_extractor.file_name = expand("%:p")
|
||||
let new_extractor.file_extension = expand("%:e")
|
||||
let new_extractor.filetype = &filetype
|
||||
let new_extractor.word_under_cursor = expand('<cword>')
|
||||
let new_extractor.description = 'Jump to tag "'.new_extractor.word_under_cursor.'" according to "'.&tags.'" tags dabase'
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_taglist_under_cursor_extractor = {}
|
||||
function! s:tag_scan_taglist_under_cursor_extractor.process(record)
|
||||
exec 'tag '.self.word_under_cursor
|
||||
call railmoon#oscan#extractor#ctags#process(a:record.data)
|
||||
endfunction
|
||||
|
||||
function! s:record_for_language_tag( language, ctag_item )
|
||||
return railmoon#oscan#extractor#ctags#language_function( a:language, 'record', a:ctag_item )
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_taglist_under_cursor_extractor.extract()
|
||||
if empty(self.word_under_cursor)
|
||||
return []
|
||||
endif
|
||||
|
||||
let result = []
|
||||
|
||||
let self.language = railmoon#oscan#extractor#ctags#language_by_current_buffer()
|
||||
|
||||
let ctags_tags = taglist('\<'.self.word_under_cursor.'\>')
|
||||
|
||||
for item in ctags_tags
|
||||
let record = s:record_for_language_tag(self.language, item)
|
||||
let record.data = item
|
||||
call add(result, record)
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_taglist_under_cursor_extractor.colorize()
|
||||
let &filetype = self.filetype
|
||||
call railmoon#oscan#extractor#ctags#colorize_keywords(self.language)
|
||||
endfunction
|
||||
|
||||
74
vim/autoload/railmoon/oscan/extractor/util.vim
Executable file
74
vim/autoload/railmoon/oscan/extractor/util.vim
Executable file
@@ -0,0 +1,74 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#util
|
||||
" Purpose: common extration and tag generation functions
|
||||
|
||||
function! railmoon#oscan#extractor#util#tags_from_file_name(file_name)
|
||||
let tags = []
|
||||
let name_tags = split(a:file_name, '\W')
|
||||
|
||||
for l:tag in name_tags
|
||||
if empty(l:tag)
|
||||
continue
|
||||
endif
|
||||
|
||||
if index(tags, string(l:tag)) != -1
|
||||
continue
|
||||
endif
|
||||
|
||||
call add(tags, l:tag)
|
||||
endfor
|
||||
|
||||
return tags
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#util#tags_from_line(line)
|
||||
let tags = split(a:line, '\W')
|
||||
call filter(tags, 'v:val != ""')
|
||||
|
||||
if a:line =~ '='
|
||||
call extend(tags, ['equal', '='])
|
||||
endif
|
||||
|
||||
if a:line =~ '"' || a:line =~ "'"
|
||||
call extend(tags, ['quotes', '"'])
|
||||
endif
|
||||
|
||||
if a:line =~ '\.'
|
||||
call extend(tags, ['dot', '.'])
|
||||
endif
|
||||
|
||||
if a:line =~ '[+-/\*]'
|
||||
call add(tags, 'sign')
|
||||
endif
|
||||
|
||||
if a:line =~ '&&' || a:line =~ '||' || a:line =~ '==' || a:line =~ '!=' " TODO in one expression
|
||||
call add(tags, 'logic')
|
||||
endif
|
||||
|
||||
return tags
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#util#tags_from_searched_line(line_number, line)
|
||||
let tags = railmoon#oscan#extractor#util#tags_from_line( a:line )
|
||||
call add(tags, a:line_number)
|
||||
|
||||
return tags
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#util#buffer_list()
|
||||
let result = []
|
||||
|
||||
for buffer_number in range(1, bufnr('$'))
|
||||
if !buflisted(buffer_number)
|
||||
continue
|
||||
endif
|
||||
|
||||
call add(result, [buffer_number, fnamemodify(bufname(buffer_number), ':p')] )
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
84
vim/autoload/railmoon/oscan/extractor/vims.vim
Executable file
84
vim/autoload/railmoon/oscan/extractor/vims.vim
Executable file
@@ -0,0 +1,84 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#vims
|
||||
" Purpose: extract vim servers to select
|
||||
|
||||
function! railmoon#oscan#extractor#vims#create()
|
||||
let new_extractor = copy(s:tag_scan_vim_extractor)
|
||||
let new_extractor.last_buffer_number = bufnr('$')
|
||||
let new_extractor.buffer_number_width = len(line('$'))
|
||||
let new_extractor.description = "Select buffer to edit among all opened Vims"
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
function! railmoon#oscan#extractor#vims#select_buffer(buffer_number)
|
||||
|
||||
let current_tabpage = tabpagenr()
|
||||
let current_window = winnr()
|
||||
|
||||
for tabpage_number in range(1, tabpagenr('$'))
|
||||
exec (tabpage_number) . 'tabnext'
|
||||
|
||||
for window_number in range(1, winnr('$'))
|
||||
|
||||
let buffer_number = winbufnr(window_number)
|
||||
|
||||
if buffer_number == a:buffer_number
|
||||
exec (window_number) . 'wincmd w'
|
||||
return
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
|
||||
exec (current_tabpage) . 'tabnext'
|
||||
exec (current_window) . 'wincmd w'
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_vim_extractor = {}
|
||||
function! s:tag_scan_vim_extractor.process(record)
|
||||
let server_name = a:record.data[0]
|
||||
let buffer_number = a:record.data[1]
|
||||
|
||||
call remote_foreground(server_name)
|
||||
call remote_expr(server_name, 'railmoon#oscan#extractor#vims#select_buffer('.buffer_number.')')
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_vim_extractor.extract()
|
||||
let result = []
|
||||
|
||||
let vim_servers = split(serverlist(), "\n")
|
||||
|
||||
for servername in vim_servers
|
||||
"echo servername
|
||||
"redraw
|
||||
let buffers_result = remote_expr(servername, 'railmoon#oscan#extractor#util#buffer_list()')
|
||||
let buffers_result = '['.join(split(buffers_result, "\n"), ',').']'
|
||||
|
||||
let buffers_list = eval(buffers_result)
|
||||
|
||||
for buffer_info in buffers_list
|
||||
|
||||
let tags = [ servername ]
|
||||
let buffer_number = buffer_info[0]
|
||||
let buffer_name = buffer_info[1]
|
||||
|
||||
call add(tags, fnamemodify(buffer_name, ':p:t'))
|
||||
|
||||
call add(result, railmoon#oscan#record#create( [ buffer_name ],
|
||||
\ tags,
|
||||
\ [ servername, buffer_number ],
|
||||
\ servername))
|
||||
|
||||
endfor
|
||||
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_vim_extractor.colorize()
|
||||
endfunction
|
||||
|
||||
79
vim/autoload/railmoon/oscan/extractor/windows.vim
Executable file
79
vim/autoload/railmoon/oscan/extractor/windows.vim
Executable file
@@ -0,0 +1,79 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: extractor#windows
|
||||
" Purpose: extract window names to select
|
||||
|
||||
function! railmoon#oscan#extractor#windows#create()
|
||||
let new_extractor = copy(s:tag_scan_windows_extractor)
|
||||
let new_extractor.description = 'Select window to be active'
|
||||
|
||||
return new_extractor
|
||||
endfunction
|
||||
|
||||
let s:tag_scan_windows_extractor = {}
|
||||
function! s:tag_scan_windows_extractor.process(record)
|
||||
exec a:record.data[0].'tabnext'
|
||||
exec a:record.data[1].'wincmd w'
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_windows_extractor.tags_by_name(buffer_name, buffer_number, tabpage_number, window_number)
|
||||
let tags = railmoon#oscan#extractor#util#tags_from_file_name(a:buffer_name)
|
||||
|
||||
if index(tags, string(a:buffer_number)) == -1
|
||||
call add(tags, a:buffer_number)
|
||||
endif
|
||||
|
||||
call add(tags, 'tabpage'.a:tabpage_number)
|
||||
call add(tags, 'window'.a:window_number)
|
||||
|
||||
return tags
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_windows_extractor.header_by_name(buffer_name, buffer_number)
|
||||
return [ a:buffer_name ]
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_windows_extractor.extract()
|
||||
let lazyredraw_status = &lazyredraw
|
||||
|
||||
set lazyredraw
|
||||
let result = []
|
||||
|
||||
try
|
||||
|
||||
for tabpage_number in range(1, tabpagenr('$'))
|
||||
exec (tabpage_number) . 'tabnext'
|
||||
|
||||
for window_number in range(1, winnr('$'))
|
||||
|
||||
let buffer_number = winbufnr(window_number)
|
||||
let buffer_name = bufname(buffer_number)
|
||||
exec window_number.'wincmd w'
|
||||
let line_number = line('.')
|
||||
|
||||
call add(result, railmoon#oscan#record#create( self.header_by_name(buffer_name, buffer_number),
|
||||
\ self.tags_by_name(buffer_name, buffer_number, tabpage_number, window_number),
|
||||
\ [tabpage_number, window_number],
|
||||
\ '[ '.tabpage_number.', '.window_number.' ] '.fnamemodify(buffer_name, ':p:t').' '.line_number))
|
||||
|
||||
endfor
|
||||
endfor
|
||||
|
||||
catch /.*/
|
||||
echo v:exception
|
||||
echo v:throwpoint
|
||||
|
||||
finally
|
||||
let &lazyredraw = lazyredraw_status
|
||||
return result
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! s:tag_scan_windows_extractor.colorize()
|
||||
syntax match Comment /|.\{-}|/
|
||||
syntax match Keyword /[\\/]/
|
||||
syntax match Number /[0-9]\+/
|
||||
endfunction
|
||||
|
||||
138
vim/autoload/railmoon/oscan/record.vim
Executable file
138
vim/autoload/railmoon/oscan/record.vim
Executable file
@@ -0,0 +1,138 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: record
|
||||
" Purpose: represent record in oscan
|
||||
|
||||
" -
|
||||
" [ plugin function ]
|
||||
" Name: railmoon#oscan#record#create
|
||||
" Purpose: create record
|
||||
" [ parameters ]
|
||||
" header record header -- list
|
||||
" tag_list list of tags associated with record
|
||||
" data record data ( line number, or buffer number, or whatever )
|
||||
" -
|
||||
function! railmoon#oscan#record#create( header, tag_list, data, ... )
|
||||
let new_record = copy( s:record )
|
||||
let s:record_id += 1
|
||||
|
||||
let new_record.header = a:header
|
||||
let new_record.tag_list = a:tag_list
|
||||
let new_record.data = a:data
|
||||
let new_record.id = s:record_id
|
||||
|
||||
if empty(a:000)
|
||||
let new_record.additional_info = ''
|
||||
else
|
||||
let new_record.additional_info = a:1
|
||||
endif
|
||||
|
||||
return new_record
|
||||
endfunction
|
||||
|
||||
let s:record = {}
|
||||
let s:record_id = 0
|
||||
|
||||
" -
|
||||
" [ object method ]
|
||||
" Object: record
|
||||
" Name: has_tag
|
||||
" Purpose: determine tag presence
|
||||
" [ parameters ]
|
||||
" tag tag
|
||||
" -
|
||||
function! s:record.has_tag( tag )
|
||||
if a:tag[0] == '~'
|
||||
for l:tag in self.tag_list
|
||||
if l:tag =~ '\c'.a:tag[1 : ]
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
|
||||
return 0
|
||||
endif
|
||||
|
||||
for l:tag in self.tag_list
|
||||
if l:tag ==? a:tag
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ object method ]
|
||||
" Object: record
|
||||
" Name: match_by_tags
|
||||
" Purpose: determine if record match with given tags
|
||||
" [ parameters ]
|
||||
" tags list of tags
|
||||
" -
|
||||
function! s:record.match_by_tags( tags )
|
||||
for l:tag in a:tags
|
||||
if ! self.has_tag( l:tag )
|
||||
return 0
|
||||
endif
|
||||
endfor
|
||||
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ object method ]
|
||||
" Object: record
|
||||
" Name: other_tags
|
||||
" Purpose: find tags that not in list but in that record
|
||||
" [ parameters ]
|
||||
" tags1 list of tags
|
||||
" tags2 list of tags
|
||||
" -
|
||||
function! s:record.other_tags( tags1, tags2 )
|
||||
let result = []
|
||||
|
||||
for l:tag in self.tag_list
|
||||
let string_tag = l:tag.''
|
||||
|
||||
if index(a:tags1, string_tag) == -1 &&
|
||||
\index(a:tags2, string_tag) == -1
|
||||
call add(result, string_tag)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ testing ]
|
||||
" -
|
||||
|
||||
function! s:create_test_record1()
|
||||
return railmoon#oscan#record#create( ['createTestRecord1'], [ 'edit', 'gui', 'form' ], 23 )
|
||||
endfunction
|
||||
|
||||
function! s:create_test_record2()
|
||||
return railmoon#oscan#record#create( ['createTestRecord2'], [ 'simple', 'gui' ], 26 )
|
||||
endfunction
|
||||
|
||||
let s:unit_test = railmoon#unit_test#create('oscan#record')
|
||||
|
||||
function! s:unit_test.test_record()
|
||||
call self.assert_equal(s:create_test_record1().match_by_tags(['edit']), 1)
|
||||
call self.assert_equal(s:create_test_record1().match_by_tags(['~dit']), 1)
|
||||
call self.assert_equal(s:create_test_record1().match_by_tags(['gui']), 1)
|
||||
call self.assert_equal(s:create_test_record1().match_by_tags(['form']), 1)
|
||||
call self.assert_equal(s:create_test_record1().match_by_tags(['form', 'gui']), 1)
|
||||
call self.assert_equal(s:create_test_record1().match_by_tags(['edit', 'form', 'gui']), 1)
|
||||
call self.assert_equal(! s:create_test_record1().match_by_tags(['simple', 'gui']), 1)
|
||||
call self.assert_equal(! s:create_test_record1().match_by_tags(['edit', 'fronmt', 'gui']), 1)
|
||||
call self.assert_equal(s:create_test_record1().other_tags(['edit', 'gui'], []), ['form'])
|
||||
call self.assert_equal(s:create_test_record1().other_tags(['gui'], []), ['edit', 'form'])
|
||||
call self.assert_equal(s:create_test_record1().other_tags([''], []), ['edit', 'gui', 'form'])
|
||||
call self.assert_equal(s:create_test_record1().other_tags(['edit', 'gui', 'form'], []), [])
|
||||
endfunction
|
||||
|
||||
call s:unit_test.run()
|
||||
|
||||
132
vim/autoload/railmoon/oscan/record_browser.vim
Executable file
132
vim/autoload/railmoon/oscan/record_browser.vim
Executable file
@@ -0,0 +1,132 @@
|
||||
" Author: Mykola Golubyev ( Nickolay Golubev )
|
||||
" Email: golubev.nikolay@gmail.com
|
||||
" Site: www.railmoon.com
|
||||
" Plugin: oscan
|
||||
" Module: record_browser
|
||||
" Purpose: represent record browser in oscan
|
||||
|
||||
function! railmoon#oscan#record_browser#create( record_extractor )
|
||||
let new_record_browser = copy( s:record_browser )
|
||||
|
||||
let new_record_browser.record_extractor = a:record_extractor
|
||||
let new_record_browser.all_records = new_record_browser.record_extractor.extract()
|
||||
|
||||
return new_record_browser
|
||||
endfunction
|
||||
|
||||
let s:record_browser = {}
|
||||
|
||||
function! s:record_browser.is_empty()
|
||||
return empty(self.all_records)
|
||||
endfunction
|
||||
|
||||
" by list of tags return records that match tag list
|
||||
" record1 tags = ['method', 'create', 'button']
|
||||
" record2 tags = ['function', 'create', 'widget']
|
||||
" record3 tags = ['method', 'create', 'file']
|
||||
" tag_list = ['method', 'create']
|
||||
" result = [record1, record3]
|
||||
function! s:record_browser.get_matched_records( tag_list )
|
||||
let result = []
|
||||
|
||||
for record in self.all_records
|
||||
if record.match_by_tags( a:tag_list )
|
||||
call add(result, record)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
" by list of tags return tags that can specify other records
|
||||
" example:
|
||||
" record1 tags = ['method', 'create', 'button']
|
||||
" record2 tags = ['method', 'create', 'widget']
|
||||
" record3 tags = ['method', 'create', 'file']
|
||||
" tag_list = ['method', 'create']
|
||||
" result = ['widget', 'button', 'file']
|
||||
function! s:record_browser.get_available_tags( tag_list ) " TODO useful?
|
||||
let result = []
|
||||
|
||||
for record in self.all_records
|
||||
if record.match_by_tags( a:tag_list )
|
||||
call extend(result, record.other_tags( result, a:tag_list ))
|
||||
endif
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
" by list of tags return tags that can specify other records
|
||||
" example above
|
||||
function! s:record_browser.get_available_tags_for_records( matched_records, tag_list )
|
||||
let result = []
|
||||
|
||||
for record in a:matched_records
|
||||
let other_tags = record.other_tags( result, a:tag_list )
|
||||
|
||||
for element in other_tags
|
||||
let string_tag = element.''
|
||||
if index(result, string_tag) == -1
|
||||
call add(result, string_tag)
|
||||
endif
|
||||
endfor
|
||||
|
||||
" call extend(result, record.other_tags( result, a:tag_list ))
|
||||
endfor
|
||||
|
||||
return result
|
||||
endfunction
|
||||
|
||||
" -
|
||||
" [ testing ]
|
||||
" -
|
||||
|
||||
function! s:create_test_record1()
|
||||
return railmoon#oscan#record#create( 'createTestRecord1', [ 'edit', 'gui', 'form' ], 23 )
|
||||
endfunction
|
||||
|
||||
function! s:create_test_record2()
|
||||
return railmoon#oscan#record#create( 'createTestRecord2', [ 'simple', 'gui' ], 26 )
|
||||
endfunction
|
||||
|
||||
let s:test_record_extractor = {}
|
||||
function! s:test_record_extractor.new()
|
||||
let new_test_record_extractor = copy( s:test_record_extractor )
|
||||
|
||||
let new_test_record_extractor.record1 = s:create_test_record1()
|
||||
let new_test_record_extractor.record2 = s:create_test_record2()
|
||||
|
||||
let new_test_record_extractor.records = [ new_test_record_extractor.record1, new_test_record_extractor.record2 ]
|
||||
|
||||
return new_test_record_extractor
|
||||
endfunction
|
||||
|
||||
function! s:test_record_extractor.extract()
|
||||
return self.records
|
||||
endfunction
|
||||
|
||||
let s:unit_test = railmoon#unit_test#create('oscan#record_browser')
|
||||
|
||||
function! s:unit_test.test_record_browser()
|
||||
|
||||
let record_extractor = s:test_record_extractor.new()
|
||||
let record_browser = railmoon#oscan#record_browser#create(record_extractor)
|
||||
|
||||
call self.assert_equal(len(record_browser.get_matched_records( [] )), 2)
|
||||
call self.assert_equal(len(record_browser.get_matched_records( ['simple'] )), 1)
|
||||
|
||||
|
||||
call self.assert_equal((record_browser.get_matched_records( ['simple'] ))[0].id, record_extractor.record2.id)
|
||||
call self.assert_equal((record_browser.get_matched_records( ['edit', 'form'] ))[0].id, record_extractor.record1.id)
|
||||
|
||||
let matched_records = record_browser.get_matched_records(['gui'])
|
||||
call self.assert_equal(record_browser.get_available_tags_for_records(matched_records, ['gui']), ['edit', 'form', 'simple'])
|
||||
|
||||
let matched_records = record_browser.get_matched_records(['form', 'gui'])
|
||||
call self.assert_equal(record_browser.get_available_tags_for_records(matched_records, ['form', 'gui']), ['edit'])
|
||||
|
||||
endfunction
|
||||
|
||||
call s:unit_test.run()
|
||||
|
||||
Reference in New Issue
Block a user