Permalink
Browse files

also return private/protected methods in file and in extended classes

  • Loading branch information...
1 parent c1d4388 commit 3dabb94e5955bbf80bee1e5ea937ff91b2d546e6 @folke folke committed Nov 20, 2011
Showing with 5 additions and 4 deletions.
  1. +5 −4 ftplugin/phpcomplete.vim
View
9 ftplugin/phpcomplete.vim
@@ -164,14 +164,15 @@ function! phpcomplete#CompletePHP(findstart, base)
let classcontent = ''
let classcontent .= "\n".phpcomplete#GetClassContents(classfile, classname)
let sccontent = split(classcontent, "\n")
+ let classAccess = expand('%:p') == fnamemodify(classlocation, ':p') ? '\\(public\\|private\\|protected\\)' : 'public'
" limit based on context to static or normal public methods
if scontext =~ '::'
let functions = filter(deepcopy(sccontent),
- \ 'v:val =~ "^\\s*\\(\\(public\\s\\+static\\|static\\)\\s\\+\\)*function"')
+ \ 'v:val =~ "^\\s*\\(\\(' . classAccess . '\\s\\+static\\|static\\)\\s\\+\\)*function"')
elseif scontext =~ '->$'
let functions = filter(deepcopy(sccontent),
- \ 'v:val =~ "^\\s*\\(public\\s\\+\\)*function"')
+ \ 'v:val =~ "^\\s*\\(' . classAccess . '\\s\\+\\)*function"')
endif
let jfuncs = join(functions, ' ')
@@ -189,7 +190,7 @@ function! phpcomplete#CompletePHP(findstart, base)
" Variables declared with var or with public keyword are
" public
let variables = filter(deepcopy(sccontent),
- \ 'v:val =~ "^\\s*\\(public\\|var\\)\\s\\+\\$"')
+ \ 'v:val =~ "^\\s*\\(' . classAccess . '\\|var\\)\\s\\+\\$"')
let jvars = join(variables, ' ')
let svars = split(jvars, '\$')
let c_variables = {}
@@ -692,7 +693,7 @@ function! phpcomplete#GetClassLocation(classname) " {{{
while i < line('.')
let line = getline(line('.')-i)
if line =~ '^\s*class ' . a:classname . '\(\s\+\|$\)'
- return expand('%')
+ return expand('%:p')
else
let i += 1
continue

0 comments on commit 3dabb94

Please sign in to comment.