Mercurial > vim
comparison runtime/autoload/phpcomplete.vim @ 25773:11b656e74444
Update runtime files
Commit: https://github.com/vim/vim/commit/6c391a74fe90190796ca0b0c010112948a6e75d7
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Sep 9 21:55:11 2021 +0200
Update runtime files
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 09 Sep 2021 22:00:10 +0200 |
parents | 5b37a0bf7e3a |
children | d6dde6229b36 |
comparison
equal
deleted
inserted
replaced
25772:55753c17b73d | 25773:11b656e74444 |
---|---|
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 (::). |
12 " This generates E_STRICT level warning, but php calls these methods nontheless. | 12 " This generates E_STRICT level warning, but php calls these methods nonetheless. |
13 " | 13 " |
14 " let g:phpcomplete_complete_for_unknown_classes = 1/0 [default 0] | 14 " let g:phpcomplete_complete_for_unknown_classes = 1/0 [default 0] |
15 " Enables completion of variables and functions in "everything under the sun" fashion | 15 " Enables completion of variables and functions in "everything under the sun" fashion |
16 " when completing for an instance or static class context but the code can't tell the class | 16 " when completing for an instance or static class context but the code can't tell the class |
17 " or locate the file that it lives in. | 17 " or locate the file that it lives in. |
26 " | 26 " |
27 " let g:phpcomplete_min_num_of_chars_for_namespace_completion = n [default 1] | 27 " let g:phpcomplete_min_num_of_chars_for_namespace_completion = n [default 1] |
28 " This option controls the number of characters the user needs to type before | 28 " This option controls the number of characters the user needs to type before |
29 " the tags will be searched for namespaces and classes in typed out namespaces in | 29 " the tags will be searched for namespaces and classes in typed out namespaces in |
30 " "use ..." context. Setting this to 0 is not recommended because that means the code | 30 " "use ..." context. Setting this to 0 is not recommended because that means the code |
31 " have to scan every tag, and vim's taglist() function runs extremly slow with a | 31 " have to scan every tag, and vim's taglist() function runs extremely slow with a |
32 " "match everything" pattern. | 32 " "match everything" pattern. |
33 " | 33 " |
34 " let g:phpcomplete_parse_docblock_comments = 1/0 [default 0] | 34 " let g:phpcomplete_parse_docblock_comments = 1/0 [default 0] |
35 " When enabled the preview window's content will include information | 35 " When enabled the preview window's content will include information |
36 " extracted from docblock comments of the completions. | 36 " extracted from docblock comments of the completions. |
261 call add(namespaced_matches, {'word': namespace_for_class.'\'.tag.name, 'kind': tag.kind, 'menu': tag.filename, 'info': tag.filename }) | 261 call add(namespaced_matches, {'word': namespace_for_class.'\'.tag.name, 'kind': tag.kind, 'menu': tag.filename, 'info': tag.filename }) |
262 elseif (tag.kind ==? 'c' || tag.kind ==? 'i' || tag.kind ==? 't') | 262 elseif (tag.kind ==? 'c' || tag.kind ==? 'i' || tag.kind ==? 't') |
263 call add(no_namespace_matches, {'word': namespace_for_class.'\'.tag.name, 'kind': tag.kind, 'menu': tag.filename, 'info': tag.filename }) | 263 call add(no_namespace_matches, {'word': namespace_for_class.'\'.tag.name, 'kind': tag.kind, 'menu': tag.filename, 'info': tag.filename }) |
264 endif | 264 endif |
265 endfor | 265 endfor |
266 " if it seems that the tags file have namespace informations we can safely throw | 266 " if it seems that the tags file have namespace information we can safely throw |
267 " away namespaceless tag matches since we can be sure they are invalid | 267 " away namespaceless tag matches since we can be sure they are invalid |
268 if patched_ctags_detected | 268 if patched_ctags_detected |
269 no_namespace_matches = [] | 269 no_namespace_matches = [] |
270 endif | 270 endif |
271 let res += namespaced_matches + no_namespace_matches | 271 let res += namespaced_matches + no_namespace_matches |
803 if c_name != '' && c_name =~? '^'.base | 803 if c_name != '' && c_name =~? '^'.base |
804 call add(res, {'word': c_name, 'kind': kind}) | 804 call add(res, {'word': c_name, 'kind': kind}) |
805 endif | 805 endif |
806 endfor | 806 endfor |
807 | 807 |
808 " resolve the typed in part with namespaces (if theres a \ in it) | 808 " resolve the typed in part with namespaces (if there's a \ in it) |
809 let [tag_match_pattern, namespace_for_class] = phpcomplete#ExpandClassName(a:base, a:current_namespace, a:imports) | 809 let [tag_match_pattern, namespace_for_class] = phpcomplete#ExpandClassName(a:base, a:current_namespace, a:imports) |
810 | 810 |
811 let tags = [] | 811 let tags = [] |
812 if len(tag_match_pattern) >= g:phpcomplete_min_num_of_chars_for_namespace_completion | 812 if len(tag_match_pattern) >= g:phpcomplete_min_num_of_chars_for_namespace_completion |
813 let tags = phpcomplete#GetTaglist('^\c'.tag_match_pattern) | 813 let tags = phpcomplete#GetTaglist('^\c'.tag_match_pattern) |
919 | 919 |
920 return [[line_no, col_no], a:filelines[line_no][col_no]] | 920 return [[line_no, col_no], a:filelines[line_no][col_no]] |
921 endfunction " }}} | 921 endfunction " }}} |
922 | 922 |
923 function! phpcomplete#EvaluateModifiers(modifiers, required_modifiers, prohibited_modifiers) " {{{ | 923 function! phpcomplete#EvaluateModifiers(modifiers, required_modifiers, prohibited_modifiers) " {{{ |
924 " if theres no modifier, and no modifier is allowed and no modifier is required | 924 " if there's no modifier, and no modifier is allowed and no modifier is required |
925 if len(a:modifiers) == 0 && len(a:required_modifiers) == 0 | 925 if len(a:modifiers) == 0 && len(a:required_modifiers) == 0 |
926 return 1 | 926 return 1 |
927 else | 927 else |
928 " check if every requred modifier is present | 928 " check if every required modifier is present |
929 for required_modifier in a:required_modifiers | 929 for required_modifier in a:required_modifiers |
930 if index(a:modifiers, required_modifier) == -1 | 930 if index(a:modifiers, required_modifier) == -1 |
931 return 0 | 931 return 0 |
932 endif | 932 endif |
933 endfor | 933 endfor |
1251 if do_break | 1251 if do_break |
1252 break | 1252 break |
1253 endif | 1253 endif |
1254 endif | 1254 endif |
1255 | 1255 |
1256 " save the coma position for later use if theres a "naked" , possibly separating a parameter and it is not in a parented part | 1256 " save the coma position for later use if there's a "naked" , possibly separating a parameter and it is not in a parented part |
1257 if first_coma_break_pos == -1 && current_char == ',' | 1257 if first_coma_break_pos == -1 && current_char == ',' |
1258 let first_coma_break_pos = len(instruction) | 1258 let first_coma_break_pos = len(instruction) |
1259 endif | 1259 endif |
1260 endif | 1260 endif |
1261 | 1261 |
1297 " strip leading whitespace | 1297 " strip leading whitespace |
1298 let instruction = substitute(instruction, '^\s\+', '', '') | 1298 let instruction = substitute(instruction, '^\s\+', '', '') |
1299 | 1299 |
1300 " there were a "naked" coma in the instruction | 1300 " there were a "naked" coma in the instruction |
1301 if first_coma_break_pos != -1 | 1301 if first_coma_break_pos != -1 |
1302 if instruction !~? '^use' && instruction !~? '^class' " use ... statements and class delcarations should not be broken up by comas | 1302 if instruction !~? '^use' && instruction !~? '^class' " use ... statements and class declarations should not be broken up by comas |
1303 let pos = (-1 * first_coma_break_pos) + 1 | 1303 let pos = (-1 * first_coma_break_pos) + 1 |
1304 let instruction = instruction[pos :] | 1304 let instruction = instruction[pos :] |
1305 endif | 1305 endif |
1306 endif | 1306 endif |
1307 | 1307 |
1309 " what the plugin really need is a proper php tokenizer | 1309 " what the plugin really need is a proper php tokenizer |
1310 if instruction =~? '\c^\(if\|while\|foreach\|for\)\s*(' | 1310 if instruction =~? '\c^\(if\|while\|foreach\|for\)\s*(' |
1311 " clear everything up until the first ( | 1311 " clear everything up until the first ( |
1312 let instruction = substitute(instruction, '^\(if\|while\|foreach\|for\)\s*(\s*', '', '') | 1312 let instruction = substitute(instruction, '^\(if\|while\|foreach\|for\)\s*(\s*', '', '') |
1313 | 1313 |
1314 " lets iterate trough the instruction until we can find the pair for the opening ( | 1314 " lets iterate through the instruction until we can find the pair for the opening ( |
1315 let i = 0 | 1315 let i = 0 |
1316 let depth = 1 | 1316 let depth = 1 |
1317 while i < len(instruction) | 1317 while i < len(instruction) |
1318 if instruction[i] == '(' | 1318 if instruction[i] == '(' |
1319 let depth += 1 | 1319 let depth += 1 |
1417 " there's a namespace in the type, threat the type as FQCN | 1417 " there's a namespace in the type, threat the type as FQCN |
1418 if type =~ '\\' | 1418 if type =~ '\\' |
1419 let parts = split(substitute(type, '^\\', '', ''), '\') | 1419 let parts = split(substitute(type, '^\\', '', ''), '\') |
1420 let class_candidate_namespace = join(parts[0:-2], '\') | 1420 let class_candidate_namespace = join(parts[0:-2], '\') |
1421 let classname_candidate = parts[-1] | 1421 let classname_candidate = parts[-1] |
1422 " check for renamed namepsace in imports | 1422 " check for renamed namespace in imports |
1423 if has_key(classstructure.imports, class_candidate_namespace) | 1423 if has_key(classstructure.imports, class_candidate_namespace) |
1424 let class_candidate_namespace = classstructure.imports[class_candidate_namespace].name | 1424 let class_candidate_namespace = classstructure.imports[class_candidate_namespace].name |
1425 endif | 1425 endif |
1426 else | 1426 else |
1427 " no namespace in the type, threat it as a relative classname | 1427 " no namespace in the type, threat it as a relative classname |
2016 let valid = 1 | 2016 let valid = 1 |
2017 for classstructure in classcontents | 2017 for classstructure in classcontents |
2018 if getftime(classstructure.file) != classstructure.mtime | 2018 if getftime(classstructure.file) != classstructure.mtime |
2019 let valid = 0 | 2019 let valid = 0 |
2020 " we could break here, but the time required for checking probably worth | 2020 " we could break here, but the time required for checking probably worth |
2021 " the the memory we can free by checking every file in the cached hirearchy | 2021 " the the memory we can free by checking every file in the cached hierarchy |
2022 call phpcomplete#ClearCachedClassContents(classstructure.file) | 2022 call phpcomplete#ClearCachedClassContents(classstructure.file) |
2023 endif | 2023 endif |
2024 endfor | 2024 endfor |
2025 | 2025 |
2026 if valid | 2026 if valid |
2030 else | 2030 else |
2031 " clear the outdated cached value from the cache store | 2031 " clear the outdated cached value from the cache store |
2032 call remove(s:cache_classstructures, cache_key) | 2032 call remove(s:cache_classstructures, cache_key) |
2033 call phpcomplete#ClearCachedClassContents(full_file_path) | 2033 call phpcomplete#ClearCachedClassContents(full_file_path) |
2034 | 2034 |
2035 " fall trough for the read from files path | 2035 " fall through for the read from files path |
2036 endif | 2036 endif |
2037 else | 2037 else |
2038 call phpcomplete#ClearCachedClassContents(full_file_path) | 2038 call phpcomplete#ClearCachedClassContents(full_file_path) |
2039 endif | 2039 endif |
2040 | 2040 |
2139 if trait_line !~? ';' | 2139 if trait_line !~? ';' |
2140 " try to find the next line containing ';' | 2140 " try to find the next line containing ';' |
2141 let l = lnum | 2141 let l = lnum |
2142 let search_line = trait_line | 2142 let search_line = trait_line |
2143 | 2143 |
2144 " add lines from the file until theres no ';' in them | 2144 " add lines from the file until there's no ';' in them |
2145 while search_line !~? ';' && l > 0 | 2145 while search_line !~? ';' && l > 0 |
2146 " file lines are reversed so we need to go backwards | 2146 " file lines are reversed so we need to go backwards |
2147 let l += 1 | 2147 let l += 1 |
2148 call win_execute(popup_id, 'let search_line = getline('.l.')') | 2148 call win_execute(popup_id, 'let search_line = getline('.l.')') |
2149 let trait_line .= ' '.substitute(search_line, '\(^\s\+\|\s\+$\)', '', 'g') | 2149 let trait_line .= ' '.substitute(search_line, '\(^\s\+\|\s\+$\)', '', 'g') |
2571 " try to find the next line containing ';' | 2571 " try to find the next line containing ';' |
2572 let l = i | 2572 let l = i |
2573 let search_line = line | 2573 let search_line = line |
2574 let use_line = line | 2574 let use_line = line |
2575 | 2575 |
2576 " add lines from the file until theres no ';' in them | 2576 " add lines from the file until there's no ';' in them |
2577 while search_line !~? ';' && l > 0 | 2577 while search_line !~? ';' && l > 0 |
2578 " file lines are reversed so we need to go backwards | 2578 " file lines are reversed so we need to go backwards |
2579 let l -= 1 | 2579 let l -= 1 |
2580 let search_line = file_lines[l] | 2580 let search_line = file_lines[l] |
2581 let use_line .= ' '.substitute(search_line, '\(^\s\+\|\s\+$\)', '', 'g') | 2581 let use_line .= ' '.substitute(search_line, '\(^\s\+\|\s\+$\)', '', 'g') |
2603 endfor | 2603 endfor |
2604 | 2604 |
2605 " find kind flags from tags or built in methods for the objects we extracted | 2605 " find kind flags from tags or built in methods for the objects we extracted |
2606 " they can be either classes, interfaces or namespaces, no other thing is importable in php | 2606 " they can be either classes, interfaces or namespaces, no other thing is importable in php |
2607 for [key, import] in items(imports) | 2607 for [key, import] in items(imports) |
2608 " if theres a \ in the name we have it's definitely not a built in thing, look for tags | 2608 " if there's a \ in the name we have it's definitely not a built in thing, look for tags |
2609 if import.name =~ '\\' | 2609 if import.name =~ '\\' |
2610 let patched_ctags_detected = 0 | 2610 let patched_ctags_detected = 0 |
2611 let [classname, namespace_for_classes] = phpcomplete#ExpandClassName(import.name, '\', {}) | 2611 let [classname, namespace_for_classes] = phpcomplete#ExpandClassName(import.name, '\', {}) |
2612 let namespace_name_candidate = substitute(import.name, '\\', '\\\\', 'g') | 2612 let namespace_name_candidate = substitute(import.name, '\\', '\\\\', 'g') |
2613 " can be a namespace name as is, or can be a tagname at the end with a namespace | 2613 " can be a namespace name as is, or can be a tagname at the end with a namespace |
2660 let import['builtin'] = 1 | 2660 let import['builtin'] = 1 |
2661 elseif has_key(g:php_builtin_interfacenames, tolower(import.name)) | 2661 elseif has_key(g:php_builtin_interfacenames, tolower(import.name)) |
2662 let import['kind'] = 'i' | 2662 let import['kind'] = 'i' |
2663 let import['builtin'] = 1 | 2663 let import['builtin'] = 1 |
2664 else | 2664 else |
2665 " or can be a tag with exactly matchign name | 2665 " or can be a tag with exactly matching name |
2666 let tags = phpcomplete#GetTaglist('^'.import['name'].'$') | 2666 let tags = phpcomplete#GetTaglist('^'.import['name'].'$') |
2667 for tag in tags | 2667 for tag in tags |
2668 " search for the first matchin namespace, class, interface with no namespace | 2668 " search for the first matching namespace, class, interface with no namespace |
2669 if !has_key(tag, 'namespace') && (tag.kind == 'n' || tag.kind == 'c' || tag.kind == 'i' || tag.kind == 't') | 2669 if !has_key(tag, 'namespace') && (tag.kind == 'n' || tag.kind == 'c' || tag.kind == 'i' || tag.kind == 't') |
2670 call extend(import, tag) | 2670 call extend(import, tag) |
2671 let import['builtin'] = 0 | 2671 let import['builtin'] = 0 |
2672 break | 2672 break |
2673 endif | 2673 endif |
2881 let g:php_builtin_functions = {} | 2881 let g:php_builtin_functions = {} |
2882 for [ext, data] in items(php_builtin['functions']) | 2882 for [ext, data] in items(php_builtin['functions']) |
2883 call extend(g:php_builtin_functions, data) | 2883 call extend(g:php_builtin_functions, data) |
2884 endfor | 2884 endfor |
2885 | 2885 |
2886 " Built in classs | 2886 " Built in class |
2887 let g:php_builtin_classes = {} | 2887 let g:php_builtin_classes = {} |
2888 for [ext, data] in items(php_builtin['classes']) | 2888 for [ext, data] in items(php_builtin['classes']) |
2889 call extend(g:php_builtin_classes, data) | 2889 call extend(g:php_builtin_classes, data) |
2890 endfor | 2890 endfor |
2891 | 2891 |
2899 let g:php_constants = {} | 2899 let g:php_constants = {} |
2900 for [ext, data] in items(php_builtin['constants']) | 2900 for [ext, data] in items(php_builtin['constants']) |
2901 call extend(g:php_constants, data) | 2901 call extend(g:php_constants, data) |
2902 endfor | 2902 endfor |
2903 | 2903 |
2904 " When the classname not found or found but the tags dosen't contain that | 2904 " When the classname not found or found but the tags doesn't contain that |
2905 " class we will try to complate any method of any builtin class. To speed up | 2905 " class we will try to complete any method of any builtin class. To speed up |
2906 " that lookup we compile a 'ClassName::MethodName':'info' dictionary from the | 2906 " that lookup we compile a 'ClassName::MethodName':'info' dictionary from the |
2907 " builtin class informations | 2907 " builtin class information |
2908 let g:php_builtin_object_functions = {} | 2908 let g:php_builtin_object_functions = {} |
2909 | 2909 |
2910 " When completing for 'everyting imaginable' (no class context, not a | 2910 " When completing for 'everyting imaginable' (no class context, not a |
2911 " variable) we need a list of built-in classes in a format of {'classname':''} | 2911 " variable) we need a list of built-in classes in a format of {'classname':''} |
2912 " for performance reasons we precompile this too | 2912 " for performance reasons we precompile this too |