1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 06:30:03 +08:00
SpaceVim/bundle/vim-javacomplete2/doc/javacomplete.txt
2022-11-02 01:41:33 +08:00

821 lines
27 KiB
Plaintext
Vendored

*javacomplete.txt* Updated version of the original javacomplete plugin
artur shaik *javacomplete*
==============================================================================
CONTENTS *javacomplete-contents*
1. Overview..........................................|javacomplete-overview|
1. Download......................................|javacomplete-download|
2. Features......................................|javacomplete-features|
3. Install........................................|javacomplete-install|
4. Requirements..............................|javacomplete-requirements|
2. Usage................................................|javacomplete-usage|
1. Class creation................................|javacomplete-classnew|
2. Commands......................................|javacomplete-commands|
3. Input contexts................................|javacomplete-contexts|
4. Kind letter.................................|javacomplete-kindletter|
5. Options.........................................|javacomplete-config|
3. FAQ....................................................|javacomplete-faq|
4. History............................................|javacomplete-history|
5. Todo..................................................|javacomplete-todo|
6. Thanks..............................................|javacomplete-thanks|
==============================================================================
OVERVIEW *javacomplete-overview*
This is javacomplete, an omni-completion script of JAVA language for vim 7 and
above. It includes javacomplete.vim, java_parser.vim, javavi library,
javaparser library and javacomplete.txt.
==============================================================================
DOWNLOAD *javacomplete-download*
You can download the lastest version from this url:
https://github.com/artur-shaik/vim-javacomplete2
==============================================================================
FEATURES *javacomplete-features*
1. List members of a class, including (static) fields, (static) methods and
ctors;
2. List classes or subpackages of a package;
3. Provide parameters information of a method, list all overload methods;
4. Complete an incomplete word;
5. Provide a complete JAVA parser written in Vim script language;
6. Use the JVM to obtain most information;
7. Use the embedded parser to obtain the class information from source
files;
8. JSP is supported, Builtin objects such as request, session can be
recognized;
9. The classes and jar files in the WEB-INF will be appended automatically
to the classpath;
10. Server side java reflection class loader and parsing library;
11. Search class files automatically;
12. Complete class name;
13. Add import statement for a given class name;
14. Complete methods declaration after '@Override';
15. Support for maven, gradle and Eclipse's '.classpath';
16. Cross-session cache;
17. Auto insert methods that need to be implemented;
18. `toString`, `equals`, `hashCode`, Accessors generation.
==============================================================================
INSTALL *javacomplete-install*
1. This assumes you are using `Vundle`.
Adapt for your plugin manager of choice. Put this into your `.vimrc`.
>
" Java completion plugin.
Plugin 'artur-shaik/vim-javacomplete2'
<
2. Set 'omnifunc' option. e.g.
>
autocmd Filetype java setlocal omnifunc=javacomplete#Complete
<
3. Map keys you prefer:
For smart (trying to guess import option) insert class import with <F4>:
>
nmap <F4> <Plug>(JavaComplete-Imports-AddSmart)
imap <F4> <Plug>(JavaComplete-Imports-AddSmart)
<
For usual (will ask for import option) insert class import with <F5>:
>
nmap <F5> <Plug>(JavaComplete-Imports-Add)
imap <F5> <Plug>(JavaComplete-Imports-Add)
<
For add all missing imports with <F6>:
>
nmap <F6> <Plug>(JavaComplete-Imports-AddMissing)
imap <F6> <Plug>(JavaComplete-Imports-AddMissing)
<
For remove all missing imports with <F7>:
>
nmap <F7> <Plug>(JavaComplete-Imports-RemoveUnused)
imap <F7> <Plug>(JavaComplete-Imports-RemoveUnused)
<
For sorting all imports with <F8>:
>
nmap <F8> <Plug>(JavaComplete-Imports-SortImports)
imap <F8> <Plug>(JavaComplete-Imports-SortImports)
<
Default mappings:
>
nmap <leader>jI <Plug>(JavaComplete-Imports-AddMissing)
nmap <leader>jR <Plug>(JavaComplete-Imports-RemoveUnused)
nmap <leader>ji <Plug>(JavaComplete-Imports-AddSmart)
nmap <leader>jii <Plug>(JavaComplete-Imports-Add)
nmap <Leader>jis <Plug>(JavaComplete-Imports-SortImports)
imap <C-j>I <Plug>(JavaComplete-Imports-AddMissing)
imap <C-j>R <Plug>(JavaComplete-Imports-RemoveUnused)
imap <C-j>i <Plug>(JavaComplete-Imports-AddSmart)
imap <C-j>ii <Plug>(JavaComplete-Imports-Add)
nmap <leader>jM <Plug>(JavaComplete-Generate-AbstractMethods)
imap <C-j>jM <Plug>(JavaComplete-Generate-AbstractMethods)
nmap <leader>jA <Plug>(JavaComplete-Generate-Accessors)
nmap <leader>js <Plug>(JavaComplete-Generate-AccessorSetter)
nmap <leader>jg <Plug>(JavaComplete-Generate-AccessorGetter)
nmap <leader>ja <Plug>(JavaComplete-Generate-AccessorSetterGetter)
nmap <leader>jts <Plug>(JavaComplete-Generate-ToString)
nmap <leader>jeq <Plug>(JavaComplete-Generate-EqualsAndHashCode)
nmap <leader>jc <Plug>(JavaComplete-Generate-Constructor)
nmap <leader>jcc <Plug>(JavaComplete-Generate-DefaultConstructor)
imap <C-j>s <Plug>(JavaComplete-Generate-AccessorSetter)
imap <C-j>g <Plug>(JavaComplete-Generate-AccessorGetter)
imap <C-j>a <Plug>(JavaComplete-Generate-AccessorSetterGetter)
vmap <leader>js <Plug>(JavaComplete-Generate-AccessorSetter)
vmap <leader>jg <Plug>(JavaComplete-Generate-AccessorGetter)
vmap <leader>ja <Plug>(JavaComplete-Generate-AccessorSetterGetter)
<
4. Javavi library will be automatcally compiled when you
use first time. If no libs/javavi/target is generated, check that you have
the write permission and jdk installed.
==============================================================================
REQUIREMENTS *javacomplete-requirements*
1. Vim version 7.4 and above with python support;
2. JDK8.
==============================================================================
USAGE *javacomplete-usage*
You can use `vim-javacomplete2` just like other omni-completion plugin. Many
samples of input context are gived in the following section.
See |javacomplete-faq| in time if some problem occurs. When meeting other
problems not described in FAQ, you can contact with the author by the
following e-mail: ashaihullin@gmail.com
==============================================================================
CLASS CREATION *javacomplete-classnew*
Prompt scheme, for class creation:
>
template:[subdirectory]:/package.ClassName extends SuperClass implements
Interface(String str, public Integer i):contructor(*):toString(1)
<
A: (optional) template - which will be used to create class boilerplate. Some
existed templates: junit, interface, exception, servlet, etcl
B: (optional) subdirectory in which class will be put. For example: test,
androidTest;
C: class name and package. With `/` will use backsearch for parent package to
put in it. Without `/` put in relative package to current;
D: (optional) extends and implements classes will be automatically imported;
E: (optional) private str variable, and public i variable will be added to
class;
F: (optional) contructor using all fields and toString override method with
only 'str' field will be created. Also hashCode and equals can be used.
There is autocompletion in command prompt that will try to help you. Your
current opened file shouldn't have dirty changes or 'hidden' should be set.
==============================================================================
COMMANDS *javacomplete-commands*
All these commands are supported when encoding with java project.
:JCimportsAddMissing *:JCimportsAddMissing*
add all missing 'imports'
:JCimportsRemoveUnused *:JCimportsRemoveUnused*
remove all unsused 'imports'
:JCimportAdd *:JCimportAdd*
add 'import' for classname that is under cursor, or before it
:JCimportAddSmart *:JCimportAddSmart*
add 'import' for classname trying to guess variant without ask user to
choose an option (it will ask on false guessing)
:JCimportsSort *:JCimportsSort*
sort all 'imports'
:JCserverShowPort *:JCserverShowPort*
show port, through which vim plugin communicates with server;
:JCserverShowPID *:JCserverShowPID*
show server process identificator;
:JCserverStart *:JCserverStart*
start server manually;
:JCserverTerminate *:JCserverTerminate*
stop server manually;
:JCserverCompile *:JCserverCompile*
compile server manually;
:JCdebugEnableLogs *:JCdebugEnableLogs*
enable logs;
:JCdebugDisableLogs *:JCdebugDisableLogs*
disable logs;
:JCdebugGetLogContent *:JCdebugGetLogContent*
get debug logs;
:JCcacheClear *:JCcacheClear*
clear cache manually.
:JCgenerateAbstractMethods *:JCgenerateAbstractMethods*
generate methods that need to be implemented
:JCgenerateAccessors *:JCgenerateAccessors*
generate getters and setters for all fields;
:JCgenerateAccessorSetter *:JCgenerateAccessorSetter*
generate setter for field under cursor;
:JCgenerateAccessorGetter *:JCgenerateAccessorGetter*
generate getter for field under cursor;
:JCgenerateAccessorSetterGetter *:JCgenerateAccessorSetterGetter*
generate getter and setter for field under cursor;
:JCgenerateToString *:JCgenerateToString*
generate 'toString' method;
:JCgenerateEqualsAndHashCode *:JCgenerateEqualsAndHashCode*
generate 'equals' and 'hashCode' methods;
:JCgenerateConstructor *:JCgenerateConstructor*
generate constructor with chosen fields;
:JCgenerateConstructorDefault *:JCgenerateConstructorDefault*
generate default constructor;
:JCclassNew *:JCclassNew*
open prompt to enter class creation command;
:JCclassInFile *:JCclassInFile*
open prompt to choose template that will be used for creation class
boilerplate in current empty file;
==============================================================================
INPUT CONTEXTS *javacomplete-contexts*
It recognize nearly all kinds of Primary Expressions (see langspec-3.0) except
for `"Primary.new Indentifier"`. Casting conversion is also supported.
Samples of input contexts are as following: (Note that '|' indicates cursor)
(1). after '.', list members of a class or a package
>
- package.| subpackages and classes of a package
- Type.| static members of the 'Type' class and "class"
- var.| or field.| members of a variable or a field
- method().| members of result of method()
- this.| members of the current class
- ClassName.this.| members of the qualified class
- super.| members of the super class
- array.| members of an array object
- array[i].| array access, return members of the element of array
- "String".| String literal, return members of java.lang.String
- int.| or void.| primitive type or pseudo-type, return "class"
- int[].| array type, return members of a array type and "class"
- java.lang.String[].|
- new int[].| members of the new array instance
- new java.lang.String[i=1][].|
- new Type().| members of the new class instance
- Type.class.| class literal, return members of java.lang.Class
- void.class.| or int.class.|
- ((Type)var).| cast var as Type, return members of Type.
- (var.method()).| same with "var.|"
- (new Class()).| same with "new Class().|"
<
(2). after '(', list matching methods with parameters information.
>
- method(|) methods matched
- var.method(|) methods matched
- new ClassName(|) constructors matched
- this(|) constructors of current class matched
- super(|) constructors of super class matched
Any place between '(' and ')' will be supported soon.
Help information of javadoc is not supported yet.
<
(3). after an incomplete word, list all the matched beginning with it.
>
- var.ab| subset of members of var beginning with `ab`
- ab| list of all maybes
<
(4). import statement
>
- " import java.util.|"
- " import java.ut|"
- " import ja|"
- " import java.lang.Character.|" e.g. "Subset"
- " import static java.lang.Math.|" e.g. "PI, abs"
<
(5). package declaration
>
- " package com.|"
<
The above are in simple expression.
(6). after compound expression:
>
- PrimaryExpr.var.|
- PrimaryExpr.method().|
- PrimaryExpr.method(|)
- PrimaryExpr.var.ab|
e.g.
- "java.lang . System.in .|"
- "java.lang.System.getenv().|"
- "int.class.toString().|"
- "list.toArray().|"
- "new ZipFile(path).|"
- "new ZipFile(path).entries().|"
<
(7). Nested expression:
>
- "System.out.println( str.| )"
- "System.out.println(str.charAt(| )"
- "for (int i = 0; i < str.|; i++)"
- "for ( Object o : a.getCollect| )"
<
==============================================================================
KIND LETTER *javacomplete-kindletter*
A single letter indicates the kind of compeltion item. These kinds are:
>
+ ctor
v local variable or parameter
f nonstatic field
F static field
m nonstatic method
M static method
P package
C class type
I interface type
<
==============================================================================
OPTIONS *javacomplete-config*
All these options are supported when encoding with java project.
*g:JavaComplete_SourcesPath*
path of your sources. Don't try to add all sources you have, this will slow
down parsing process. Add you project sources and necessery library sources.
If you have compiled classes add them to previous config instead. By default
plugin will search `src` directory and add it automatically.
*g:JavaComplete_MavenRepositoryDisabled*
disable the maven repository.
>
let g:JavaComplete_MavenRepositoryDisabled = 1
<
by default this option is disabled (0).
*g:JavaComplete_LibsPath*
path of you jar files. This path will always appended with '~/.m2/repository'
directory. Here you can add your glassfish libs directory or your project
libs. It will be automatically appended with you jre home path
*g:JavaComplete_BaseDir*
Base cache directory of javacomplete2 (default is ~/.cache):
>
let g:JavaComplete_BaseDir = '~/.your_cache_dir'
<
*g:JavaComplete_ImportDefault*
In the import selection the default behavior is to use the first option
available:
>
let g:JavaComplete_ImportDefault = 0
<
To avoid this behavior use:
>
let g:JavaComplete_ImportDefault = -1
<
*g:JavaComplete_InsertImports*
Import selection is activated automatically when completing new class name.
This can be avoided by setting:
>
let g:JavaComplete_InsertImports = 0
<
*g:JavaComplete_GradleExecutable*
Set the path of gradle executable file. by default it is empty string.
*g:JavaComplete_ServerAutoShutdownTime*
The Java daemon should kill itself when Vim stops. Also its possible to
configure the timeout, so if there is no request during this time the daemon
will stop. To configure the timemout use the following (in seconds). By
default this option is 0.
*g:JavaComplete_ImportSortType*
Sorting can by jar archives `jarName` or by package names `packageName`. This
option is to set the imports sorting type. By default this option is
`jarName`:
>
let g:JavaComplete_ImportSortType = 'jarName'
<
*g:JavaComplete_ImportOrder*
Specifies the order of import groups, when use `packageName` sorting type, for
example:
>
let g:JavaComplete_ImportOrder = ['java.', 'javax.', 'com.', 'org.', 'net.']
<
An import group is a list of individual import statements that all start with
the same beginning of package name surrounded by blank lines above and below
the group.
*g:JavaComplete_RegularClasses*
Regular class names that will be used automatically when you insert import:
>
let g:JavaComplete_RegularClasses = ['java.lang.String', 'java.lang.Object']
<
You can populate it with your custom classes, or it will be populated
automatically when you choose any import option. List will be persisted, so it
will be used next time you run the same project.
*g:JavaComplete_AutoStartServer*
Disable automatic startup of server:
>
let g:JavaComplete_AutoStartServer = 0
<
By default this option is disabled (1).
*g:JavaComplete_UseFQN*
Use fully qualified name in description:
>
let g:JavaComplete_UseFQN = 1
<
By default this option is disabled (0).
*g:JavaComplete_EnableDefaultMappings*
Enable or disable default key mappings, by default this option is 1, and
default mappings are defined. To disable default mappings, set this option to
1.
>
let g:JavaComplete_EnableDefaultMappings = 1
<
*g:JavaComplete_PomPath*
Set pom.xml path explicitly:
>
let g:JavaComplete_PomPath = /path/to/pom.xml
<
It will be set automatically, if pom.xml is in underlying path.
*g:JavaComplete_ClosingBrace*
Close brace on method declaration completion:
>
let g:JavaComplete_ClosingBrace = 1
<
Add close brace automatically, when complete method declaration. By default
this option is enabled (1). Disable if it conflicts with another plugins.
*g:JavaComplete_JavaviLogDirectory*
Set the directory where to write server logs. By default this option is empty.
*g:JavaComplete_CustomTemplateDirectory*
Set directory that contains custom templates for class creation, for example:
>
let g:JavaComplete_CustomTemplateDirectory = '~/jc_templates'
<
By default this options is empty string.
==============================================================================
FAQ *javacomplete-faq*
4.1 Why can not complete in gradle project?
Check if 'gradle' is in your runtime path or './gradlew' (or
'.\gradlew.bat' for Windows) is in your project's directory.
4.2 I have installed gradle, but why I can not complete R.class?
In android project, many of the class contains a ton of innerclass,
javacomplete2 could works better by reflection, so you need to compile you
project, after use './gradlew build', R.java will be automatically
generated and compiled.
==============================================================================
HISTORY *javacomplete-history*
This section document the history of `vim-javacomplete2`.
v2.3.4 2015-12-14
Use maven, gradle, or Eclipse's 'classpath` file to generate classpath
Complete methods declaration on '@Override'.
v2.3.3 2015-10-08
Jsp files support, no taglibs yet.
Vimscript refactored.
Read eclipse ".classpath" file.
Option to set jvm launcher and compiler for javavi server.
Using <Plug> mappings.
Bug fixes.
v2.3.2 2015-09-18
Nested classes.
Vimscript refactored.
v2.3.1 2015-09-07
Better experience with imports.
Commands added.
v2.3 2015-07-29
Annotations completion support.
Option to swtich use of FQN in completion suggestions.
Check python support before start.
v2.2 2015-07-08
Lambda expressions parsing.
v2.1 2015-06-12
Generics completion. Bug fixes.
Added g:JavaComplete_MavenRepositoryDisable option.
v2.0 2015-05-26
Writed new library for reflection and parsing. Parsing make by
third party library. Library run in server like way.
Added class name completion and insertion of class import.
Added auto classpath searcher.
v0.77.1.2 2011-01-30
Fixed to adapt globpath() (vim < 7.2). Patched by Sam Lidder.
v0.77.1.1 2010-11-12
Fixed to ignore the 'suffixes' and 'wildignore' options which
make Reflection.class can not be found.
v0.77.1 2007-09-19
Supported showing method parameters information in any place
between parenthesises.
v0.77 2007-09-19
bug fix
Added GetCurrentFileKey() avoid empty key of s:files for current buffer.
Use a new strategy for searching inherited members.
Supported new contexts "jav|", "var|", just after an incomplete word.
Supported new context "abs(|)", a imported static method.
Improved FoundClassDeclaration()
Fixed bug calling cursor(0, 0)
Rewrote DoGetClassInfo(), GetFQN() and IsFQN()
Fixed a bug when merging superclass's members
Improved s:MergeLines() and s:ExtractCleanExpr().
Rewrote CompleteAfterDot(). Added ParseExpr(). Removed
s:GetNextSubexprType()
Supported accessible static imported members.
Supported accessible inherited members.
Used b:changedtick and getftime() to check buffer (or other file) for
changing.
Supported not-file-name toplevel or static member class in source files.
v0.76.8 2007-08-30
Created the s:TreeVisitor to search type or symbol names.
Supported local and anonymous class.
Supported appending automatically classpath under WEB-INF for jsp files.
v0.76.7 2007-08-28
Fixed case of "new java.util.zip.ZipFile().|"
Improved process of type arguments and method parameters. JAVA5+
Reorganize codes in javacomplete#Complete()
Added CONTEXT_NEED_TYPE, removed CONTEXT_INCOMPLETE_WORD
Add Context types for type declaration: CONTEXT_NEED_TYPE
v0.76.6 2007-08-23
Improved GetStatement() and related. Bug fixed.
v0.76.5 2007-08-21
Fixed bug: "foo().|", "getFoo().foo().|",
"for (Enumeration entries = ; entries.|; )".
Supported input contexts: "((Object)o).|", "((Object)o).getClass().|",
"new ZipFile(path).|", "(new String().)|".
v0.76.4 2007-08-17
Improved input contexts: "int.class.toString().|", "list.toArray().|".
Fixed recognizing "this(|)", "method1(|)"
Added the 'kind' letter to distinguish between classes and packages.
Support accessible nested classes.
Support import static members and import accessible nested classes.
Fixed a bug when Reflection.java is in the path which contains space.
Improved process of this and super in JSP.
Fixed an severe bug parsing current jsp file.
v0.76.3 2007-08-10
Add an option 'searchdecl' set by javacomplete#SetSearchdeclMethod().
Make an improvement for jsp file.
Clear cache when set options affecting classpath.
Improved DoGetPackageList() and s:GenerateImports().
Replace codes searching list of string with index().
v0.76.2 2007-08-08
Fix failing to list members of nested class.
Combine members of local packages and loadable packages.
Add quick recognition of package or import.
Add inherited fields and methods to local class.
v0.76.1 2007-08-04
Fix using a: in javacomplete#SetClassPath()
Fix a bug in javacomplete#GetClassPath()
v0.76 2007-08-04
2007-08-04
Fix a infinite loop bug in s:GetMatchedIndexEx()
Fix that array type not recognised in compound expression.
Add a option for JDK1.1. See FAQ 3.
2007-08-03
Improve for 'this' or 'super'.
Support searching toplevel class in sourcepath.
Clean
2007-08-02
Improve the process of checking a class in one of packages.
2007-08-01
Add Searchdecl() using java_parser.vim to provide quick information.
Supports input context: "StringLiteral".|, "int.|", "void.|"
2007-07-28
Automatcally compile Reflection.java and place it to $HOME.
Add option 'javacompiler', default 'javac'
Add option 'java', default 'java'
v0.75 2007-02-13
Add java_parser.vim.
Add b:sourcepath option.
Improve recognition of classes defined in current buffer or in source path.
Support generating class information from tags instead of returning list
directly.
v0.74 2007-02-03
Support jre1.2 (and above).
Support input context like "boolean.class.|"
Handle java primitive types like 'int'.
v0.73 2007-02-01
Fix bug that CLASSPATH not used when b:classpath or g:java_classpath not
set.
Fix bug that call filter() without making a copy for incomplete.
Improve recognition of declaration of this class
v0.72 2007-01-31
Handle nested expression.
v0.71 2007-01-28
Add Basic support for class in current folder.
v0.70 2007-01-27
Complete the reflection part.
v0.60 2007-01-25
Design TClassInfo, etc.
v0.50 2007-01-21
Use java and Reflection.class directly.
==============================================================================
TODO *javacomplete-todo*
Add javadoc
Cross session cache;
Most used (classes, methods, vars) at first place (smart suggestions);
FXML support;
JSP check support;
Refactoring support?;
Class creation helpers;
etc...
==============================================================================
THANKS *javacomplete-thanks*
* Cheng Fang author of original javacomplete plugin;
* Zhang Li author of vim-javacompleteex plugin;
* http://github.com/javaparser/javaparser library.
FeedBack: Any problem, bug or suggest are welcome to send to
ashaihullin@gmail.com
vim:tw=78:ts=8:ft=help:norl: