sponsor Vim development Vim logo Vim Book Ad

JavaBrowser : Shows java file class, package in a tree as in IDEs. Java source browser.

 script karma  Rating 258/92, Downloaded by 8565    Comments, bugs, improvements  Vim wiki

created by
Pradeep Unde
 
script type
utility
 
description
This script is modelled on TagList vim script. Thanks to Yegappan Lakshmanan for taglist.vim
However, this script is SPECIFICALLY tailored for Java language. So, it shows structure of the Java file
starting with classes defined within it and NOT in a general tag structure. I found it useful and hope you all
find it useful too. It also has a nice syntax to show the class members in UML format.

The "Java Browser" plugin provides the following features:
1. Opens details of Java file types (class, package etc) in a Tree structure in a separate vim window
e.g: + package
            java.util
       + class
       +   vector
       +      field
                  ....
       +      method
                  ....
2. The tree has syntax highlighting as follows:
    A. public members in green, protected in orange, private in red
    B. static members are underlined and abstracts are shown in italics as per UML specs in addition to above highlighting.
e.g:- If you have method that public static and abstract, it will shown in green color, in italic and underlined. You can think of all possible combinations.
3. When you double click (configurable for a single click) or hit enter key in the browser window when on a member, it will take you to the definition of that member in the Java file window.
4. It can show an arrow (=>) or an icon (ONLY for signs enabled VIM) showing the current position of the cursor in the java file.
5. The browser window is updated automatically when you open any other Java file (or switch between buffers) in the Java file window. You can manually update browser window by typing 'u' in the browser window (when u change a class for example and you need that to be reflected).
6. When you put the cursor (not the mouse pointer) on a member, it shows the prototype of the member declaration in the command window (like baloon popup in IDEs!)
7. It understands the inner classes and are shown like HashMap.Iterator etc.
8. It understands the overridden methods.
9. Browser window opening can be configured for a vertically/horizontally split Vim window.
10. Groups the tags by their type and displays them in a foldable tree.
11. Automatically highlights the current tag name.
12. The browser window contents can be sorted either by name or by line number.
13. Runs in all the platforms where the exuberant ctags utility and Vim are
     supported (this includes MS-Windows and Unix based systems).

TODO:
1. To cache ctags output for a file to speed up displaying the taglist
     window.

This plugin relies on the exuberant ctags utility to generate the tag
listing. You can download the exuberant ctags utility from
http://ctags.sourceforge.net. The exuberant ctags utility must be installed
in your system to use this plugin. You should use exuberant ctags version
5.3 and above.  There is no need for you to create a tags file to use this
plugin.

This script relies on the Vim "filetype" detection mechanism to determine
the type of the current file. To turn on filetype detection use

               :filetype on

This plugin will not work in 'compatible' mode.  Make sure the 'compatible'
option is not set. This plugin will not work if you run Vim in the
restricted mode (using the -Z command-line argument). This plugin also
assumes that the system() Vim function is supported.
 
install details
1. Unzip and untar javabrowser.tgz to get javabrowser.vim and tagindicator.xpm files.
2. Copy the javabrowser.vim script to the $HOME/.vim/plugin directory. Refer to
    ':help add-plugin', ':help add-global-plugin' and ':help runtimepath' for
    more details about Vim plugins.
3. Copy tagindicator.xpm and tagindicator.bmp to $VIM/pixmaps directory. NOTE: This is optional.
4. Set the JavaBrowser_Ctags_Cmd variable to point to the exuberant ctags utility
    path.
5. Set Javabrowser_Use_Icon = 1 in your .vimrc file if you want to use icon provided with the script. Note: VIM must be compiled with "signs" option for this. If it is not, it will automatically be disabled and normal search highlight will be used to highlight the current tag. You can also use Javabrowser_Use_Text_Icon = 1 if you like => to indicate your current tag. Even for this, VIM needs to be compiled with "sign" support. You can also set JavaBrowser_Use_Highlight_Tag = 1 in your .vimrc if you want the current tag to be highlighted along with the icon (text or tagindicator.xpm). By default, it is OFF.
6. If you are running a terminal/console version of Vim and the terminal
    doesn't support changing the window width then set the JavaBrowser_Inc_Winwidth
    variable to 0.
7. Restart Vim.
8. You can use the ":JavaBrowser" command to open/close the taglist window.
9. NOTE: This script has fileformat (ff) of DOS. UNIX users, please change it to unix before using it (Use set ff=unix and save it). Thanks to Deepak for pointing that out. That's what I do for any script I find in DOS fileformat!
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
javabrowser.zip 2.03 2006-09-15 6.0 Pradeep Unde Two small bug fixes
1. When UML visibility indicators are enabled, they were also included in syntax highlighting
2. Sort by order not supported. But the window showed Sort by order at top. Changed that to Sort by name
javabrowser.zip 2.02 2006-09-03 7.0 Pradeep Unde The zip file had lot of spurious files. Removed them.
javabrowser.zip 2.02 2006-09-01 7.0 Pradeep Unde 1. Added back the nice icons (tagindicator.xpm) and (tagindicator.bmp) with the script. When the zip file is unzipped in the $VIM directory (say c:\vim), it would put the images in the $VIM\pixmaps directory and the javabrowser.vim under $VIM\vimfiles\plugin directory. I like browsing the Java Tree with the image icon and I hope you would like that too.
javabrowser.vim 2.02 2006-08-31 7.0 Pradeep Unde Automatic tag highlighting supported now. Depending where the cursor is in the java file, corresponding tag is automatically hightlighed in the JavaBrowser window
javabrowser.vim 2.01 2006-08-30 7.0 Pradeep Unde Following bog fixes and one improvement
1. Fixed error showing tooltip when mouse was over "field" or "method"
2. The cache was not getting set for the tooltip correctly
3. The tooltip was staring with the <TAB> character picked up from the ctags output. It has been removed now
javabrowser.vim 2.0 2006-08-29 6.0 Pradeep Unde 1. Overhauled the code for version 7.0 and is now faster
2. Does not give errors for version 7.0 now when browsing (or opening) the class tree
3. Added caching for ctags output, so, buffer switching is very fast for previously viewed buffers
NOTE: The sort by order and tag position auto refresh in the browser tree when navigating Java file still do not work.
Hopefully will make that work pretty soon :)
I have not tested it extensively. I would really appreciate it if you let me know about the bugs.
javabrowser.vim 1.22 2006-04-15 6.0 Pradeep Unde 1. Added function JavaBrowser_Set_Syntax_Highlighting().
2. Now, the syntax highlighting for the Class tree would automatically be set
when a new window is opened or at the time of tag refersh. So, the user would
always see the syntax highlighting set for JavaBrowser syntax groups even if
the color scheme is changed in the middle of an editing session.
javabrowser.vim 1.21 2006-03-21 6.0 Pradeep Unde Added option JavaBrowser_Show_UML_Visibility. If set, which is the default, JavaBrowser uses UML visibility indicators. + => public, - => private, # => protected in addition to the syntax highlighting.
javabrowser.vim 1.20 2006-03-17 6.0 Pradeep Unde 1. Bugfix to correct the typo for balloon_eval
2. Now also checking if the version > 700 before setting the bexpr option
The script now does show an error if the verison < 7.0. However, to get the advantage of tooltip, verion >= 7.0 is needed.
javabrowser.vim 1.19 2006-03-13 6.0 Pradeep Unde Forgot to mention that the baloon_eval feature works for vim 7.0 onwards ONLY for any arbitrary tooltips. Sorry, if this caused any confusion. So, basically, to use this new feature, you need vim 7.0
javabrowser.vim 1.19 2006-03-10 6.0 Pradeep Unde Added nice tool-tip when mouse is over a function/variable name in the tag list window. Uses the ballon_eval feature for this. If this feature is not there, the tool-tip would not be shown. Shows a nice prototype for each tag in the tool-tip. An update after a loooong time.
javabrowser.tar.gz 1.18 2003-11-18 6.0 Pradeep Unde Bug fix when sorted by name. Fixed the tag position. Now it shows the arrow at correct position.
javabrowser.tar.gz 1.17 2003-09-19 6.0 Pradeep Unde 1. Optimized so that when the cursor moves within a method/function, the tag
is not rehighlighted, reducing the flicker on the screen.
2. The sorting now works properly and correct tag is highlighted after the
sorting.
3. Set JavaBrowser_Expand_Tree_At_Startup = 1 so that the tree opens
completely at :JavaBrowser command
4. Bug fix: Now escaping the SPACES in $VIM so that sign will be read properly. If your $VIM looks like C:\Program Files\Vim, it will now work. Thanks to Doug McInns for feed back.
javabrowser.tar.gz 1.16 2003-09-17 6.0 Pradeep Unde Added tagindicator.bmp for windows. Vim on Windows does not understand the xpms. Arrgghhh! So, now Windows users can also have icon to show the current tag.
javabrowser.tar.gz 1.15 2003-09-08 6.0 Pradeep Unde 1. Added various configurable ways to highlight current tag which include
A. an icon or B. an arrow(=>) with highlight of Constant and/or C. normal
search highlight
2. Added options to control all these. Added 'JavaBrowser_Use_Icon',
'JavaBrowser_Use_Text_Icon' and 'JavaBrowser_Use_Highlight_Tag'
3. All have default values
javabrowser.vim 1.14 2003-09-04 6.0 Pradeep Unde Now automatically highlights the current tag.
javabrowser.vim 1.12 2003-04-15 6.0 Pradeep Unde Small bug fix to remove unwanted echo for visibility.
javabrowser.vim 1.11 2003-04-14 6.0 Pradeep Unde 1. Now interface methods are highlighted as public, abstract. I missed  the abstract part in  the previous version.
2. The visibility modifier (public/protected/private) can now be anywhere in the method/field declaration and it will be highlighted correctly.
ip used for rating: 54.204.77.26

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo