Mercurial > vim
comparison runtime/autoload/phpcomplete.vim @ 6956:ad7ee058c03b
Correct optwin script, update PHP complete.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 22 Jul 2015 22:22:59 +0200 |
parents | 2def7b25de60 |
children | 8a1481e59d64 |
comparison
equal
deleted
inserted
replaced
6955:4d8542ea435e | 6956:ad7ee058c03b |
---|---|
1 " Vim completion script | 1 " Vim completion script |
2 " Language: PHP | 2 " Language: PHP |
3 " Maintainer: Dávid Szabó ( complex857 AT gmail DOT com ) | 3 " Maintainer: Dávid Szabó ( complex857 AT gmail DOT com ) |
4 " Previous Maintainer: Mikolaj Machowski ( mikmach AT wp DOT pl ) | 4 " Previous Maintainer: Mikolaj Machowski ( mikmach AT wp DOT pl ) |
5 " URL: https://github.com/shawncplus/phpcomplete.vim | 5 " URL: https://github.com/shawncplus/phpcomplete.vim |
6 " Last Change: 2015 Jul 03 | 6 " Last Change: 2015 Jul 13 |
7 " | 7 " |
8 " OPTIONS: | 8 " OPTIONS: |
9 " | 9 " |
10 " let g:phpcomplete_relax_static_constraint = 1/0 [default 0] | 10 " let g:phpcomplete_relax_static_constraint = 1/0 [default 0] |
11 " Enables completion for non-static methods when completing for static context (::). | 11 " Enables completion for non-static methods when completing for static context (::). |
316 for i in int_values | 316 for i in int_values |
317 let f_name = matchstr(i, | 317 let f_name = matchstr(i, |
318 \ '^&\?\zs[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*\ze') | 318 \ '^&\?\zs[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*\ze') |
319 if f_name =~? '^'.substitute(a:base, '\\', '\\\\', 'g') | 319 if f_name =~? '^'.substitute(a:base, '\\', '\\\\', 'g') |
320 let f_args = matchstr(i, | 320 let f_args = matchstr(i, |
321 \ '^&\?[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*\s*(\zs.\{-}\ze)\_s*\({\|$\)') | 321 \ '^&\?[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*\s*(\zs.\{-}\ze)\_s*\(;\|{\|$\)') |
322 let int_functions[f_name.'('] = f_args.')' | 322 let int_functions[f_name.'('] = f_args.')' |
323 endif | 323 endif |
324 endfor | 324 endfor |
325 | 325 |
326 " Internal solution for finding constants in current file | 326 " Internal solution for finding constants in current file |
644 let int_functions = {} | 644 let int_functions = {} |
645 for i in int_values | 645 for i in int_values |
646 let f_name = matchstr(i, | 646 let f_name = matchstr(i, |
647 \ '^&\?\zs[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*\ze') | 647 \ '^&\?\zs[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*\ze') |
648 let f_args = matchstr(i, | 648 let f_args = matchstr(i, |
649 \ '^&\?[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*\s*(\zs.\{-}\ze)\_s*\({\|$\)') | 649 \ '^&\?[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*\s*(\zs.\{-}\ze)\_s*\(;\|{\|$\)') |
650 | 650 |
651 let int_functions[f_name.'('] = f_args.')' | 651 let int_functions[f_name.'('] = f_args.')' |
652 endfor | 652 endfor |
653 | 653 |
654 " collect external functions from tags | 654 " collect external functions from tags |
979 let c_doc = {} | 979 let c_doc = {} |
980 for i in functions | 980 for i in functions |
981 let f_name = matchstr(i, | 981 let f_name = matchstr(i, |
982 \ 'function\s*&\?\zs[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*\ze') | 982 \ 'function\s*&\?\zs[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*\ze') |
983 let f_args = matchstr(i, | 983 let f_args = matchstr(i, |
984 \ 'function\s*&\?[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*\s*(\zs.\{-}\ze)\_s*\({\|\_$\)') | 984 \ 'function\s*&\?[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*\s*(\zs.\{-}\ze)\_s*\(;\|{\|\_$\)') |
985 if f_name != '' && stridx(f_name, '__') != 0 | 985 if f_name != '' && stridx(f_name, '__') != 0 |
986 let c_functions[f_name.'('] = f_args | 986 let c_functions[f_name.'('] = f_args |
987 if g:phpcomplete_parse_docblock_comments | 987 if g:phpcomplete_parse_docblock_comments |
988 let c_doc[f_name.'('] = phpcomplete#GetDocBlock(a:sccontent, 'function\s*&\?\<'.f_name.'\>') | 988 let c_doc[f_name.'('] = phpcomplete#GetDocBlock(a:sccontent, 'function\s*&\?\<'.f_name.'\>') |
989 endif | 989 endif |
1377 let classcontents = phpcomplete#GetCachedClassContents(classlocation, classname_candidate) | 1377 let classcontents = phpcomplete#GetCachedClassContents(classlocation, classname_candidate) |
1378 | 1378 |
1379 " Get Structured information of all classes and subclasses including namespace and includes | 1379 " Get Structured information of all classes and subclasses including namespace and includes |
1380 " try to find the method's return type in docblock comment | 1380 " try to find the method's return type in docblock comment |
1381 for classstructure in classcontents | 1381 for classstructure in classcontents |
1382 let doclock_target_pattern = 'function\s\+&\?'.method.'\|\(public\|private\|protected\|var\).\+\$'.method | 1382 let docblock_target_pattern = 'function\s\+&\?'.method.'\|\(public\|private\|protected\|var\).\+\$'.method |
1383 let doc_str = phpcomplete#GetDocBlock(split(classstructure.content, '\n'), doclock_target_pattern) | 1383 let doc_str = phpcomplete#GetDocBlock(split(classstructure.content, '\n'), docblock_target_pattern) |
1384 if doc_str != '' | 1384 if doc_str != '' |
1385 break | 1385 break |
1386 endif | 1386 endif |
1387 endfor | 1387 endfor |
1388 if doc_str != '' | 1388 if doc_str != '' |
1699 if line =~# '^\s*'.object.'\s*=&\?\s\+\(clone\)\?\s*'.variable_name_pattern | 1699 if line =~# '^\s*'.object.'\s*=&\?\s\+\(clone\)\?\s*'.variable_name_pattern |
1700 | 1700 |
1701 " try to find the next non-comment or string ";" char | 1701 " try to find the next non-comment or string ";" char |
1702 let start_col = match(line, '^\s*'.object.'\C\s*=\zs&\?\s\+\(clone\)\?\s*'.variable_name_pattern) | 1702 let start_col = match(line, '^\s*'.object.'\C\s*=\zs&\?\s\+\(clone\)\?\s*'.variable_name_pattern) |
1703 let filelines = reverse(copy(lines)) | 1703 let filelines = reverse(copy(lines)) |
1704 let [pos, char] = s:getNextCharWithPos(filelines, [a:start_line - i - 1, start_col]) | 1704 let [pos, char] = s:getNextCharWithPos(filelines, [len(filelines) - i, start_col]) |
1705 let chars_read = 1 | 1705 let chars_read = 1 |
1706 let last_pos = pos | 1706 let last_pos = pos |
1707 " function_boundary == 0 if we are not in a function | |
1708 let real_lines_offset = len(function_boundary) == 1 ? 1 : function_boundary[0][0] | |
1707 " read while end of the file | 1709 " read while end of the file |
1708 while char != 'EOF' && chars_read < 1000 | 1710 while char != 'EOF' && chars_read < 1000 |
1709 let last_pos = pos | 1711 let last_pos = pos |
1710 let [pos, char] = s:getNextCharWithPos(filelines, pos) | 1712 let [pos, char] = s:getNextCharWithPos(filelines, pos) |
1711 let chars_read += 1 | 1713 let chars_read += 1 |
1712 " we got a candidate | 1714 " we got a candidate |
1713 if char == ';' | 1715 if char == ';' |
1714 let synIDName = synIDattr(synID(pos[0] + 1, pos[1] + 1, 0), 'name') | 1716 " pos values is relative to the function's lines, |
1717 " line 0 need to be offsetted with the line number | |
1718 " where te function was started to get the line number | |
1719 " in real buffer terms | |
1720 let synIDName = synIDattr(synID(real_lines_offset + pos[0], pos[1] + 1, 0), 'name') | |
1715 " it's not a comment or string, end search | 1721 " it's not a comment or string, end search |
1716 if synIDName !~? 'comment\|string' | 1722 if synIDName !~? 'comment\|string' |
1717 break | 1723 break |
1718 endif | 1724 endif |
1719 endif | 1725 endif |
1720 endwhile | 1726 endwhile |
1721 | 1727 |
1722 let prev_context = phpcomplete#GetCurrentInstruction(last_pos[0] + 1, last_pos[1], b:phpbegin) | 1728 let prev_context = phpcomplete#GetCurrentInstruction(real_lines_offset + last_pos[0], last_pos[1], b:phpbegin) |
1723 if prev_context == '' | 1729 if prev_context == '' |
1724 " cannot get previous context give up | 1730 " cannot get previous context give up |
1725 return | 1731 return |
1726 endif | 1732 endif |
1727 let prev_class = phpcomplete#GetClassName(a:start_line - i, prev_context, a:current_namespace, a:imports) | 1733 let prev_class = phpcomplete#GetClassName(a:start_line - i, prev_context, a:current_namespace, a:imports) |
1737 break | 1743 break |
1738 endif | 1744 endif |
1739 | 1745 |
1740 " assignment for the variable in question with a function on the right hand side | 1746 " assignment for the variable in question with a function on the right hand side |
1741 if line =~# '^\s*'.object.'\s*=&\?\s*'.function_invocation_pattern | 1747 if line =~# '^\s*'.object.'\s*=&\?\s*'.function_invocation_pattern |
1742 | |
1743 " try to find the next non-comment or string ";" char | 1748 " try to find the next non-comment or string ";" char |
1744 let start_col = match(line, '\C^\s*'.object.'\s*=\zs&\?\s*'.function_invocation_pattern) | 1749 let start_col = match(line, '\C^\s*'.object.'\s*=\zs&\?\s*'.function_invocation_pattern) |
1745 let filelines = reverse(lines) | 1750 let filelines = reverse(copy(lines)) |
1746 let [pos, char] = s:getNextCharWithPos(filelines, [a:start_line - i - 1, start_col]) | 1751 let [pos, char] = s:getNextCharWithPos(filelines, [len(filelines) - i, start_col]) |
1747 let chars_read = 1 | 1752 let chars_read = 1 |
1748 let last_pos = pos | 1753 let last_pos = pos |
1754 " function_boundary == 0 if we are not in a function | |
1755 let real_lines_offset = len(function_boundary) == 1 ? 1 : function_boundary[0][0] | |
1749 " read while end of the file | 1756 " read while end of the file |
1750 while char != 'EOF' && chars_read < 1000 | 1757 while char != 'EOF' && chars_read < 1000 |
1751 let last_pos = pos | 1758 let last_pos = pos |
1752 let [pos, char] = s:getNextCharWithPos(filelines, pos) | 1759 let [pos, char] = s:getNextCharWithPos(filelines, pos) |
1753 let chars_read += 1 | 1760 let chars_read += 1 |
1754 " we got a candidate | 1761 " we got a candidate |
1755 if char == ';' | 1762 if char == ';' |
1756 let synIDName = synIDattr(synID(pos[0] + 1, pos[1] + 1, 0), 'name') | 1763 " pos values is relative to the function's lines, |
1764 " line 0 need to be offsetted with the line number | |
1765 " where te function was started to get the line number | |
1766 " in real buffer terms | |
1767 let synIDName = synIDattr(synID(real_lines_offset + pos[0], pos[1] + 1, 0), 'name') | |
1757 " it's not a comment or string, end search | 1768 " it's not a comment or string, end search |
1758 if synIDName !~? 'comment\|string' | 1769 if synIDName !~? 'comment\|string' |
1759 break | 1770 break |
1760 endif | 1771 endif |
1761 endif | 1772 endif |
1762 endwhile | 1773 endwhile |
1763 | 1774 |
1764 let prev_context = phpcomplete#GetCurrentInstruction(last_pos[0] + 1, last_pos[1], b:phpbegin) | 1775 let prev_context = phpcomplete#GetCurrentInstruction(real_lines_offset + last_pos[0], last_pos[1], b:phpbegin) |
1765 if prev_context == '' | 1776 if prev_context == '' |
1766 " cannot get previous context give up | 1777 " cannot get previous context give up |
1767 return | 1778 return |
1768 endif | 1779 endif |
1769 | 1780 |
1860 " }}} | 1871 " }}} |
1861 | 1872 |
1862 function! phpcomplete#GetClassLocation(classname, namespace) " {{{ | 1873 function! phpcomplete#GetClassLocation(classname, namespace) " {{{ |
1863 " Check classname may be name of built in object | 1874 " Check classname may be name of built in object |
1864 if has_key(g:php_builtin_classes, tolower(a:classname)) && (a:namespace == '' || a:namespace == '\') | 1875 if has_key(g:php_builtin_classes, tolower(a:classname)) && (a:namespace == '' || a:namespace == '\') |
1876 return 'VIMPHP_BUILTINOBJECT' | |
1877 endif | |
1878 if has_key(g:php_builtin_interfaces, tolower(a:classname)) && (a:namespace == '' || a:namespace == '\') | |
1865 return 'VIMPHP_BUILTINOBJECT' | 1879 return 'VIMPHP_BUILTINOBJECT' |
1866 endif | 1880 endif |
1867 | 1881 |
1868 if a:namespace == '' || a:namespace == '\' | 1882 if a:namespace == '' || a:namespace == '\' |
1869 let search_namespace = '\' | 1883 let search_namespace = '\' |
2046 let endline = line('.') | 2060 let endline = line('.') |
2047 | 2061 |
2048 let content = join(getline(cfline, endline), "\n") | 2062 let content = join(getline(cfline, endline), "\n") |
2049 " Catch extends | 2063 " Catch extends |
2050 if content =~? 'extends' | 2064 if content =~? 'extends' |
2051 let extends_class = matchstr(content, 'class\_s\+'.a:class_name.'\_s\+extends\_s\+\zs'.class_name_pattern.'\ze') | 2065 let extends_string = matchstr(content, '\(class\|interface\)\_s\+'.a:class_name.'\_.\+extends\_s\+\zs\('.class_name_pattern.'\(,\|\_s\)*\)\+\ze\(extends\|{\)') |
2066 let extended_classes = map(split(extends_string, '\(,\|\_s\)\+'), 'substitute(v:val, "\\_s\\+", "", "g")') | |
2052 else | 2067 else |
2053 let extends_class = '' | 2068 let extended_classes = '' |
2069 endif | |
2070 | |
2071 " Catch implements | |
2072 if content =~? 'implements' | |
2073 let implements_string = matchstr(content, 'class\_s\+'.a:class_name.'\_.\+implements\_s\+\zs\('.class_name_pattern.'\(,\|\_s\)*\)\+\ze') | |
2074 let implemented_interfaces = map(split(implements_string, '\(,\|\_s\)\+'), 'substitute(v:val, "\\_s\\+", "", "g")') | |
2075 else | |
2076 let implemented_interfaces = [] | |
2054 endif | 2077 endif |
2055 call searchpair('{', '', '}', 'W') | 2078 call searchpair('{', '', '}', 'W') |
2056 let class_closing_bracket_line = line('.') | 2079 let class_closing_bracket_line = line('.') |
2057 let classcontent = join(getline(cfline, class_closing_bracket_line), "\n") | 2080 let classcontent = join(getline(cfline, class_closing_bracket_line), "\n") |
2058 | 2081 |
2106 \ 'file': full_file_path, | 2129 \ 'file': full_file_path, |
2107 \ 'mtime': getftime(full_file_path), | 2130 \ 'mtime': getftime(full_file_path), |
2108 \ }) | 2131 \ }) |
2109 | 2132 |
2110 let all_extends = used_traits | 2133 let all_extends = used_traits |
2111 if extends_class != '' | 2134 if len(extended_classes) > 0 |
2112 call add(all_extends, extends_class) | 2135 call extend(all_extends, extended_classes) |
2136 endif | |
2137 if len(implemented_interfaces) > 0 | |
2138 call extend(all_extends, implemented_interfaces) | |
2113 endif | 2139 endif |
2114 if len(all_extends) > 0 | 2140 if len(all_extends) > 0 |
2115 for class in all_extends | 2141 for class in all_extends |
2116 let [class, namespace] = phpcomplete#ExpandClassName(class, current_namespace, imports) | 2142 let [class, namespace] = phpcomplete#ExpandClassName(class, current_namespace, imports) |
2117 if namespace == '' | 2143 if namespace == '' |
2118 let namespace = '\' | 2144 let namespace = '\' |
2119 endif | 2145 endif |
2120 let classlocation = phpcomplete#GetClassLocation(class, namespace) | 2146 let classlocation = phpcomplete#GetClassLocation(class, namespace) |
2121 if classlocation == "VIMPHP_BUILTINOBJECT" | 2147 if classlocation == "VIMPHP_BUILTINOBJECT" |
2122 let result += [phpcomplete#GenerateBuiltinClassStub(g:php_builtin_classes[tolower(class)])] | 2148 if has_key(g:php_builtin_classes, tolower(class)) |
2149 let result += [phpcomplete#GenerateBuiltinClassStub('class', g:php_builtin_classes[tolower(class)])] | |
2150 endif | |
2151 if has_key(g:php_builtin_interfaces, tolower(class)) | |
2152 let result += [phpcomplete#GenerateBuiltinClassStub('interface', g:php_builtin_interfaces[tolower(class)])] | |
2153 endif | |
2123 elseif classlocation != '' && filereadable(classlocation) | 2154 elseif classlocation != '' && filereadable(classlocation) |
2124 let full_file_path = fnamemodify(classlocation, ':p') | 2155 let full_file_path = fnamemodify(classlocation, ':p') |
2125 let result += phpcomplete#GetClassContentsStructure(full_file_path, readfile(full_file_path), class) | 2156 let result += phpcomplete#GetClassContentsStructure(full_file_path, readfile(full_file_path), class) |
2126 elseif tolower(current_namespace) == tolower(namespace) && match(join(a:file_lines, "\n"), '\c\(class\|interface\|trait\)\_s\+'.class.'\(\>\|$\)') != -1 | 2157 elseif tolower(current_namespace) == tolower(namespace) && match(join(a:file_lines, "\n"), '\c\(class\|interface\|trait\)\_s\+'.class.'\(\>\|$\)') != -1 |
2127 " try to find the declaration in the same file. | 2158 " try to find the declaration in the same file. |
2142 endfor | 2173 endfor |
2143 return join(result, "\n") | 2174 return join(result, "\n") |
2144 endfunction | 2175 endfunction |
2145 " }}} | 2176 " }}} |
2146 | 2177 |
2147 function! phpcomplete#GenerateBuiltinClassStub(class_info) " {{{ | 2178 function! phpcomplete#GenerateBuiltinClassStub(type, class_info) " {{{ |
2148 let re = 'class '.a:class_info['name']." {" | 2179 let re = a:type.' '.a:class_info['name']." {" |
2149 for [name, initializer] in items(a:class_info.constants) | 2180 if has_key(a:class_info, 'constants') |
2150 let re .= "\n\tconst ".name." = ".initializer.";" | 2181 for [name, initializer] in items(a:class_info.constants) |
2151 endfor | 2182 let re .= "\n\tconst ".name." = ".initializer.";" |
2152 for [name, info] in items(a:class_info.properties) | 2183 endfor |
2153 let re .= "\n\t// @var $".name." ".info.type | 2184 endif |
2154 let re .= "\n\tpublic $".name.";" | 2185 if has_key(a:class_info, 'properties') |
2155 endfor | 2186 for [name, info] in items(a:class_info.properties) |
2156 for [name, info] in items(a:class_info.static_properties) | 2187 let re .= "\n\t// @var $".name." ".info.type |
2157 let re .= "\n\t// @var ".name." ".info.type | 2188 let re .= "\n\tpublic $".name.";" |
2158 let re .= "\n\tpublic static ".name." = ".info.initializer.";" | 2189 endfor |
2159 endfor | 2190 endif |
2160 for [name, info] in items(a:class_info.methods) | 2191 if has_key(a:class_info, 'static_properties') |
2161 if name =~ '^__' | 2192 for [name, info] in items(a:class_info.static_properties) |
2162 continue | 2193 let re .= "\n\t// @var ".name." ".info.type |
2163 endif | 2194 let re .= "\n\tpublic static ".name." = ".info.initializer.";" |
2164 let re .= "\n\t/**" | 2195 endfor |
2165 let re .= "\n\t * ".name | 2196 endif |
2166 let re .= "\n\t *" | 2197 if has_key(a:class_info, 'methods') |
2167 let re .= "\n\t * @return ".info.return_type | 2198 for [name, info] in items(a:class_info.methods) |
2168 let re .= "\n\t */" | 2199 if name =~ '^__' |
2169 let re .= "\n\tpublic function ".name."(".info.signature."){" | 2200 continue |
2170 let re .= "\n\t}" | 2201 endif |
2171 endfor | 2202 let re .= "\n\t/**" |
2172 for [name, info] in items(a:class_info.static_methods) | 2203 let re .= "\n\t * ".name |
2173 let re .= "\n\t/**" | 2204 let re .= "\n\t *" |
2174 let re .= "\n\t * ".name | 2205 let re .= "\n\t * @return ".info.return_type |
2175 let re .= "\n\t *" | 2206 let re .= "\n\t */" |
2176 let re .= "\n\t * @return ".info.return_type | 2207 let re .= "\n\tpublic function ".name."(".info.signature."){" |
2177 let re .= "\n\t */" | 2208 let re .= "\n\t}" |
2178 let re .= "\n\tpublic static function ".name."(".info.signature."){" | 2209 endfor |
2179 let re .= "\n\t}" | 2210 endif |
2180 endfor | 2211 if has_key(a:class_info, 'static_methods') |
2212 for [name, info] in items(a:class_info.static_methods) | |
2213 let re .= "\n\t/**" | |
2214 let re .= "\n\t * ".name | |
2215 let re .= "\n\t *" | |
2216 let re .= "\n\t * @return ".info.return_type | |
2217 let re .= "\n\t */" | |
2218 let re .= "\n\tpublic static function ".name."(".info.signature."){" | |
2219 let re .= "\n\t}" | |
2220 endfor | |
2221 endif | |
2181 let re .= "\n}" | 2222 let re .= "\n}" |
2182 | 2223 |
2183 return { 'class': a:class_info['name'], | 2224 return { a:type : a:class_info['name'], |
2184 \ 'content': re, | 2225 \ 'content': re, |
2185 \ 'namespace': '', | 2226 \ 'namespace': '', |
2186 \ 'imports': {}, | 2227 \ 'imports': {}, |
2187 \ 'file': 'VIMPHP_BUILTINOBJECT', | 2228 \ 'file': 'VIMPHP_BUILTINOBJECT', |
2188 \ 'mtime': 0, | 2229 \ 'mtime': 0, |
2202 if line =~? a:search | 2243 if line =~? a:search |
2203 let l = i - 1 | 2244 let l = i - 1 |
2204 " start backward serch for the comment block | 2245 " start backward serch for the comment block |
2205 while l != 0 | 2246 while l != 0 |
2206 let line = a:sccontent[l] | 2247 let line = a:sccontent[l] |
2207 " if comment end found save line position and end search | 2248 " if it's a one line docblock like comment and we can just return it right away |
2208 if line =~? '^\s*\*/' | 2249 if line =~? '^\s*\/\*\*.\+\*\/\s*$' |
2250 return substitute(line, '\v^\s*(\/\*\*\s*)|(\s*\*\/)\s*$', '', 'g') | |
2251 "... or if comment end found save line position and end search | |
2252 elseif line =~? '^\s*\*/' | |
2209 let comment_end = l | 2253 let comment_end = l |
2210 break | 2254 break |
2211 " ... or the line doesn't blank (only whitespace or nothing) end search | 2255 " ... or the line doesn't blank (only whitespace or nothing) end search |
2212 elseif line !~? '^\s*$' | 2256 elseif line !~? '^\s*$' |
2213 break | 2257 break |
2225 let comment_start = l | 2269 let comment_start = l |
2226 break | 2270 break |
2227 endif | 2271 endif |
2228 let l -= 1 | 2272 let l -= 1 |
2229 endwhile | 2273 endwhile |
2274 | |
2230 " no docblock comment start found | 2275 " no docblock comment start found |
2231 if comment_start == -1 | 2276 if comment_start == -1 |
2232 return '' | 2277 return '' |
2233 end | 2278 end |
2234 | 2279 |
2386 let block_start_pos = searchpos('\c\(class\|trait\|function\|interface\)\s\+\_.\{-}\zs{', 'Web') | 2431 let block_start_pos = searchpos('\c\(class\|trait\|function\|interface\)\s\+\_.\{-}\zs{', 'Web') |
2387 if block_start_pos == [0, 0] | 2432 if block_start_pos == [0, 0] |
2388 break | 2433 break |
2389 endif | 2434 endif |
2390 let block_end_pos = searchpairpos('{', '', '}\|\%$', 'W', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"') | 2435 let block_end_pos = searchpairpos('{', '', '}\|\%$', 'W', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"') |
2391 silent! exec block_start_pos[0].','.block_end_pos[0].'d' | 2436 |
2437 if block_end_pos != [0, 0] | |
2438 " end of the block found, just delete it | |
2439 silent! exec block_start_pos[0].','.block_end_pos[0].'d _' | |
2440 else | |
2441 " block pair not found, use block start as beginning and the end | |
2442 " of the buffer instead | |
2443 silent! exec block_start_pos[0].',$d _' | |
2444 endif | |
2392 endwhile | 2445 endwhile |
2393 normal! G | 2446 normal! G |
2394 | 2447 |
2395 " grab the remains | 2448 " grab the remains |
2396 let file_lines = reverse(getline(1, line('.') - 1)) | 2449 let file_lines = reverse(getline(1, line('.') - 1)) |