@@ -21,8 +21,8 @@ function! cppmode#gen_fun#copy_function() |
21 | 21 | echo s:fun_template_declaration |
22 | 22 | echo s:fun_declaration |
23 | 23 |
|
24 | | - let row_num = <sid>get_row_num_of_class_name() |
25 | | - let s:class_name = <sid>get_class_name_of_fun(row_num) |
| 24 | + let row_num = <sid>get_class_name_row_num() |
| 25 | + let s:class_name = <sid>get_class_name(row_num) |
26 | 26 | let s:class_template_declaration = <sid>get_class_template_declaration(row_num) |
27 | 27 | endfunction |
28 | 28 |
|
@@ -50,7 +50,7 @@ function! s:get_fun_template_declaration() |
50 | 50 | endfunction |
51 | 51 |
|
52 | 52 | " 获得类名所在行号 |
53 | | -function! s:get_row_num_of_class_name() |
| 53 | +function! s:get_class_name_row_num() |
54 | 54 | let current_num = cppmode#util#get_current_row_num() |
55 | 55 |
|
56 | 56 | while current_num >= 1 |
@@ -65,7 +65,7 @@ function! s:get_row_num_of_class_name() |
65 | 65 | endfunction |
66 | 66 |
|
67 | 67 | " 获得函数所在类名 |
68 | | -function! s:get_class_name_of_fun(row_num) |
| 68 | +function! s:get_class_name(row_num) |
69 | 69 | let text = cppmode#util#get_row_text(a:row_num) |
70 | 70 | return <sid>parse_class_name(text) |
71 | 71 | endfunction |
@@ -124,11 +124,8 @@ endfunction |
124 | 124 |
|
125 | 125 | " 获得一般类成员函数 |
126 | 126 | function! s:get_normal_fun(fun) |
127 | | - let pos = cppmode#util#find(a:fun, "(") |
128 | | - let temp = cppmode#util#substr(a:fun, 0, pos) |
129 | | - let fun_pos = cppmode#util#find_r(temp, " ") |
130 | | - |
131 | | - return cppmode#util#substr(a:fun, 0, fun_pos) . " " . s:class_name . "::" . cppmode#util#substr(a:fun, fun_pos + 1, len(a:fun)) |
| 127 | + let ret = matchlist(a:fun, '\s*\(\w\+\s\+\)\(\w\+(.*)\)') |
| 128 | + return ret[1] . s:class_name . "::" . ret[2] |
132 | 129 | endfunction |
133 | 130 |
|
134 | 131 | " 注释函数默认参数值 |
@@ -164,8 +161,8 @@ endfunction |
164 | 161 |
|
165 | 162 | " 获得类类型 |
166 | 163 | function! s:get_class_template_type() |
167 | | - let key_words = ["template", "typename", "class"] |
168 | | - return cppmode#util#erase_char(cppmode#util#erase_string_list(s:class_template_declaration, key_words), " ") |
| 164 | + let type = matchlist(s:class_template_declaration, '\s*template\s*<\s*\w\+\s*\(\w\+\)\s*>')[1] |
| 165 | + return "<" . type . ">" |
169 | 166 | endfunction |
170 | 167 |
|
171 | 168 | " 增加函数体 |
|