Permalink
Browse files

Resolve object attributes to standard library identifiers.

The plug-in now tries to resolve object attributes using a
progressively smaller suffix of the identifier at the cursor.
This enables resolving identifiers like "self.parser.add_option"
to their global variant, e.g. "optparse.OptionParser.add_option".
  • Loading branch information...
xolox committed May 31, 2010
1 parent dd6901c commit bf6751d5fb6a3e7f9babe114269a3de85be8d319
Showing with 14 additions and 1 deletion.
  1. +14 −1 pyref.vim
View
@@ -1,6 +1,6 @@
" Vim plug-in
" Maintainer: Peter Odding <peter@peterodding.com>
" Last Change: May 28, 2010
" Last Change: June 1, 2010
" URL: http://peterodding.com/code/vim/pyref
" License: MIT
@@ -178,6 +178,19 @@ function! s:PyRef()
return
endif
" Split the expression on all dots and search for a progressively smaller
" suffix to resolve object attributes like "self.parser.add_option" to
" global identifiers like "optparse.OptionParser.add_option". This relies
" on the uniqueness of the method names in the standard library.
let parts = split(ident, '\.')
while len(parts) > 1
call remove(parts, 0)
let pattern = join(parts, '\.') . '$'
if s:JumpToEntry(lines, pattern)
return
endif
endwhile
" As a last resort, search all of http://docs.python.org/ using Google.
call s:OpenBrowser('http://google.com/search?btnI&q=inurl:docs.python.org/+' . ident)

0 comments on commit bf6751d

Please sign in to comment.