| 1 | *vim-java-search* |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | Java Search |
|---|
| 5 | *********** |
|---|
| 6 | |
|---|
| 7 | *:JavaSearch* |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | Pattern Search |
|---|
| 11 | ============== |
|---|
| 12 | |
|---|
| 13 | Pattern searching provides a means to widen a search beyond a single |
|---|
| 14 | element. A pattern search can be executed using the command |
|---|
| 15 | |
|---|
| 16 | :JavaSearch -p <pattern> [-t <type> -x <context> -s <scope> -i] |
|---|
| 17 | |
|---|
| 18 | All of the results will be placed into the current window's location |
|---|
| 19 | list (:help location-list) so that you can easily navigate the |
|---|
| 20 | results. |
|---|
| 21 | |
|---|
| 22 | Vim command completion is supported through out the command with the |
|---|
| 23 | excption of the pattern to search for. |
|---|
| 24 | |
|---|
| 25 | > |
|---|
| 26 | |
|---|
| 27 | :JavaSearch <Tab> |
|---|
| 28 | :JavaSearch -p MyClass* <Tab> |
|---|
| 29 | :JavaSearch -p MyClass* -t <Tab> |
|---|
| 30 | :JavaSearch -p MyClass* -t all <Tab> |
|---|
| 31 | :JavaSearch -p MyClass* -t all -x <Tab> |
|---|
| 32 | :JavaSearch -p MyClass* -t all -x declarations |
|---|
| 33 | |
|---|
| 34 | < |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | - -p <pattern>: The pattern to search for. |
|---|
| 38 | |
|---|
| 39 | Ex. |
|---|
| 40 | |
|---|
| 41 | > |
|---|
| 42 | MyClass* |
|---|
| 43 | MyClass.someMethod* |
|---|
| 44 | |
|---|
| 45 | < |
|---|
| 46 | |
|---|
| 47 | - -t <type> (Default: type): The type of element to search for where |
|---|
| 48 | possible types include |
|---|
| 49 | |
|---|
| 50 | - annotation |
|---|
| 51 | |
|---|
| 52 | - class |
|---|
| 53 | |
|---|
| 54 | - classOrEnum |
|---|
| 55 | |
|---|
| 56 | - classOrInterface |
|---|
| 57 | |
|---|
| 58 | - constructor |
|---|
| 59 | |
|---|
| 60 | - enum |
|---|
| 61 | |
|---|
| 62 | - field |
|---|
| 63 | |
|---|
| 64 | - interface |
|---|
| 65 | |
|---|
| 66 | - method |
|---|
| 67 | |
|---|
| 68 | - package |
|---|
| 69 | |
|---|
| 70 | - type |
|---|
| 71 | |
|---|
| 72 | - -x <context> (Default: declarations): The context to search under |
|---|
| 73 | where possible context values include |
|---|
| 74 | |
|---|
| 75 | - all - All occurances. |
|---|
| 76 | |
|---|
| 77 | - declarations - Declarations matching the pattern or element. |
|---|
| 78 | |
|---|
| 79 | - implementors - Implementors of the pattern or element. |
|---|
| 80 | |
|---|
| 81 | - references - References of the pattern or element. |
|---|
| 82 | |
|---|
| 83 | - -s <scope> (Default: all): The scope of the search where possible |
|---|
| 84 | context values include |
|---|
| 85 | |
|---|
| 86 | - all - Search the whole workspace. |
|---|
| 87 | |
|---|
| 88 | - project - Search the current project, dependent projects, and |
|---|
| 89 | libraries. |
|---|
| 90 | |
|---|
| 91 | - type - Search only in the current type (source file). |
|---|
| 92 | |
|---|
| 93 | - -i: Ignore case when searching. |
|---|
| 94 | |
|---|
| 95 | Eclim also provides a shortcut when issuing a pattern search for a |
|---|
| 96 | type. You may simply invoke :JavaSearch supplying only the pattern. |
|---|
| 97 | |
|---|
| 98 | > |
|---|
| 99 | |
|---|
| 100 | :JavaSearch SomeType |
|---|
| 101 | |
|---|
| 102 | < |
|---|
| 103 | |
|---|
| 104 | |
|---|
| 105 | To shorten things even more, there is support for camel case searching |
|---|
| 106 | as well. |
|---|
| 107 | |
|---|
| 108 | > |
|---|
| 109 | |
|---|
| 110 | :JavaSearch NPE |
|---|
| 111 | |
|---|
| 112 | < |
|---|
| 113 | |
|---|
| 114 | |
|---|
| 115 | However, please note that camel case searching does not permit wild |
|---|
| 116 | card characters ('*', '?'). |
|---|
| 117 | |
|---|
| 118 | |
|---|
| 119 | Element Search |
|---|
| 120 | ============== |
|---|
| 121 | |
|---|
| 122 | Element searching allows you to place the cursor over just about any |
|---|
| 123 | element in a source file (method call, class name, field) and perform |
|---|
| 124 | a search for that element. Performing an element search is the same |
|---|
| 125 | as performing a pattern search with the exception that you do not |
|---|
| 126 | specify the -p option since the element under the cursor will be |
|---|
| 127 | searched for instead. |
|---|
| 128 | |
|---|
| 129 | If only one result is found and that result is in the current source |
|---|
| 130 | file, the cursor will be moved to the element found. |
|---|
| 131 | |
|---|
| 132 | *:JavaSearchContext* |
|---|
| 133 | |
|---|
| 134 | As a convenience eclim also provides the command :JavaSearchContext. |
|---|
| 135 | This command accepts no arguments and will perform the appropriate |
|---|
| 136 | search depending on the context of the element. |
|---|
| 137 | |
|---|
| 138 | - If the cursor is on a class or interface declaration, the command |
|---|
| 139 | will search for all classes / interfaces that implement / extend the |
|---|
| 140 | element. |
|---|
| 141 | |
|---|
| 142 | - If the cursor is on a method or field declaration, the command will |
|---|
| 143 | search for all references to the element. |
|---|
| 144 | |
|---|
| 145 | - Otherwise, it will search for the declaration of the element. |
|---|
| 146 | |
|---|
| 147 | |
|---|
| 148 | Alternate Searching |
|---|
| 149 | =================== |
|---|
| 150 | |
|---|
| 151 | For those occasions that you find yourself browsing a third party |
|---|
| 152 | source distribution that you want to be able to search without going |
|---|
| 153 | through the steps of setting up a project, eclim provides an alternate |
|---|
| 154 | searching mechanism. To utilize the alternate searching requires no |
|---|
| 155 | change in behavior or commands, but to achieve the best results, you |
|---|
| 156 | should know how it works. |
|---|
| 157 | |
|---|
| 158 | The first thing worth noting is that the alternate search is currently |
|---|
| 159 | a bit limited. It only supports searches involving types (classes, |
|---|
| 160 | interfaces, annotations, and enums). It doesn't currently have any |
|---|
| 161 | support for methods or fields. |
|---|
| 162 | |
|---|
| 163 | Secondly, it can only search for and locate types within the current |
|---|
| 164 | source tree. Searching across the jdk source or other third party |
|---|
| 165 | source files without setting up an Eclipse or similar classpath, is |
|---|
| 166 | difficult at worst, and slow at best. |
|---|
| 167 | |
|---|
| 168 | With that said, I've found that when I'm walking through a third party |
|---|
| 169 | source tree, my main focus is on finding referenced classes / |
|---|
| 170 | interfaces quickly and easily, and the eclim alternate searching does |
|---|
| 171 | just that. |
|---|
| 172 | |
|---|
| 173 | Invoking the search is the same as the standard search mechanism. You |
|---|
| 174 | simply use the same :JavaSearch command as you normally would. The |
|---|
| 175 | only difference is that the alternate search doesn't support the -t |
|---|
| 176 | option and will notify you of such if supplied. |
|---|
| 177 | |
|---|
| 178 | When invoked, the alternate search will perform the following: |
|---|
| 179 | |
|---|
| 180 | - It will grab the full path of the current source file, strip off the |
|---|
| 181 | package and search from the resulting directory. |
|---|
| 182 | |
|---|
| 183 | Ex. When editing a file |
|---|
| 184 | /usr/local/java/foo/src/org/foo/bar/Baz.java, the alternate search |
|---|
| 185 | will first search the directory /usr/local/java/foo/src. |
|---|
| 186 | |
|---|
| 187 | - If no files are found in that directory, then it will proceed to |
|---|
| 188 | search Vim's 'path' option (:h 'path' for more info on this option). |
|---|
| 189 | |
|---|
| 190 | As an example, I have my 'path' set to '/usr/local/java/java-src' |
|---|
| 191 | and in that directory is where I store all my third party source |
|---|
| 192 | distributions (hibernate, spring, axis, etc.). |
|---|
| 193 | |
|---|
| 194 | - Once one or more files are found, the search will stop if the |
|---|
| 195 | requested search was for declarations. For all searches, eclim will |
|---|
| 196 | first try to find the declarations and if the user requested a |
|---|
| 197 | search for implementors, references, or all, then the eclim will |
|---|
| 198 | proceed to the next step. |
|---|
| 199 | |
|---|
| 200 | - For non-declaration searches, if multiple declaring source files are |
|---|
| 201 | found, eclim will prompt you to narrow the results down to the type |
|---|
| 202 | you would like results for. |
|---|
| 203 | |
|---|
| 204 | - Once eclim has narrowed the search down to the specific type to |
|---|
| 205 | proceed with, it will then attempt to narrow the search down to a |
|---|
| 206 | specific source distribution directory. To do this it locates the |
|---|
| 207 | relevant entry from the 'path' option, tacks on one more level of |
|---|
| 208 | the path from the resulting file, and commences its search from |
|---|
| 209 | there. |
|---|
| 210 | |
|---|
| 211 | Ex. When searching for all implementors of MyType, if eclim finds a |
|---|
| 212 | file /usr/local/java/java-src/myproject/core/src/org/my/MyType.java |
|---|
| 213 | and a 'path' entry of /usr/local/java/java-src exists, then eclim |
|---|
| 214 | will deduce that that search must continue in the directory |
|---|
| 215 | /usr/local/java/java-src/myproject. |
|---|
| 216 | |
|---|
| 217 | This may seem a bit complicated for a simple search, but in practice |
|---|
| 218 | it's actually quite simple, and as usual, I'm open to any and all |
|---|
| 219 | comments and suggestions. |
|---|
| 220 | |
|---|
| 221 | Note: Alternate searching is bound to the performance of the file system |
|---|
| 222 | and as such, the response time on Windows can be significantly |
|---|
| 223 | slower than Linux. This is most noticable when searching for |
|---|
| 224 | 'implementors', 'references', and 'all'. The number of and depth of |
|---|
| 225 | the directories in your Vim 'path' option may also impact |
|---|
| 226 | performance. |
|---|
| 227 | |
|---|
| 228 | |
|---|
| 229 | Configuration |
|---|
| 230 | ============= |
|---|
| 231 | |
|---|
| 232 | Vim Variables |
|---|
| 233 | |
|---|
| 234 | *g:EclimJavaSearchSingleResult* |
|---|
| 235 | |
|---|
| 236 | - g:EclimJavaSearchSingleResult - Determines what action to take when |
|---|
| 237 | a only a single result is found. |
|---|
| 238 | |
|---|
| 239 | Possible values include: |
|---|
| 240 | |
|---|
| 241 | - 'split' - open the result in a new window via "split". |
|---|
| 242 | |
|---|
| 243 | - 'edit' - open the result in the current window. |
|---|
| 244 | |
|---|
| 245 | - 'tabnew' - open the result in a new tab. |
|---|
| 246 | |
|---|
| 247 | - 'lopen' - open the location list to display the result. |
|---|
| 248 | |
|---|
| 249 | *g:EclimJavaSearchMapping* |
|---|
| 250 | |
|---|
| 251 | - g:EclimJavaSearchMapping - When set to 1, <enter> will be mapped to |
|---|
| 252 | the java search functionality for the various java related xml files |
|---|
| 253 | (spring, hibernate, web.xml, and struts-config.xml). By default |
|---|
| 254 | this is enabled. |
|---|
| 255 | |
|---|
| 256 | vim:ft=eclimhelp |
|---|