-
Notifications
You must be signed in to change notification settings - Fork 205
Navigation
Easy navigation to Spring-specific elements of your source code.
- Eclipse: Cmd-6 (symbols in workspace), Cmd-6 again (symbols in project, new in 4.1.1), Cmd-6 again (symbols in file)
- Code: Cmd-Shift-O (symbols in file), Cmd-T (symbols in workspace)
- Atom: not available yet (symbols in file show up in outline view)
Use Ctrl on windows/linux in place of Cmd key.
All Spring annotations from the source code in the workspace are in the list of symbols. They are prefixed with @
as the other Spring symbols. It is best to type a specific annotation such as @Autowired
in the search box to narrow down the list of symbols to specific type of annotation being searched for.
The annotation synbol entry in the list consits of:
- Annotation label (i.e.
@Autowired
,@Qualifier
etc.) - Path to the resource containing the annotation symbol
Clicking on the annotation entry in the list navigates to the position in the source code resource where the annotation is located
All Beans symbols are prefixed with @+
. Typing @+
is the search box lists only Bean symbols defined in the source code.
A common bean entry defined with an annotation consists of:
- Bean ID
- Annotation label including annotation "Meta Inheritance Relationship", i.e. any Controller is a Component
- Path to the resource containing the bean definition
There are bean definitions without annotations such as Spring Data Repository beans. These consist of:
- Bean ID
- Type of model objects stored by the repository and Java type of the repository
- Path to the resource containing the bean definition
Clicking on the bean entry in the list navigates to the position in the source code resource where the bean is defined.
Spring Tools 4 are able to parse Spring XML config files for bean definitions. Therefore all XML files in the workspace are scanned and analyzed for Spring bean definitions. At the moment only direct bean definitions in the style of:
<bean id="name" class="org.test.TheClassOfTheBean"/>
As a result, a bean symbol in generated and showing up in the list of symbols as: @+ 'name' TheClassOfTheBean
.
Since this is an experimental feature, you need to enable it via the preferences first, and restart the tooling afterwards in order to trigger the initial scanning of Spring XML config files.
All Request Mapping symbols are prefixed with @/
. Typing @/
in the search box lists only Request Mapping symbols.
A common Request Mapping symbol entry consists of:
- Path of the Request Mapping
- Type of the RequestMapping or content type or other auxiliary data if applicable
- Path to the resource containing the bean definition
Clicking on the Request Mapping entry in the list navigates to the position in the source code resource where the Request Mapping is defined.
-
@/
shows all defined request mappings (mapped path, request method, source location) -
@+
shows all defined beans (bean name, bean type, source location) -
@>
shows all functions (prototype implementation) (see the Spring Cloud Function project) -
@
shows all Spring annotations in the code -
//
shows all request mappings of all running Spring Boot apps and opens a browser for the selected endpoint (this only works in the global 'go to symbol' view - after pressing Cmd-6 twice)
If you are working with large workspaces and are observing large amounts of memory being used by the language server process behind the scenes, you have two new options to deal with this situation:
- if you are running on Eclipse, you can pass custom VM arguments to that process, for example to increase the max heap size of that JVM.
- using the same mechanism, you can set
-Dboot.ls.symbols.ignoreMethodBodies=true
. This reduces the amount of heap that is used by the parser while scanning the workspace for symbols quite significantly. The downside of this is that, when using this option, the language server will not look into method bodies anymore to identify Webflux route definitions.
In addition to that the new cache mechanism will also help in this situation, see the next section.
The symbol indexing infrastructure uses a cache now to store and retrieve generated symbols across language server startups. That means, as long as you don't change the projects or the files, the next time the language server starts up, all the symbols will be retrieved from a cache and no source code parsing will happen.
The cache will be invalidated (on a per-project base) automatically whenever libraries on the classpath of that project change or source files inside of the project change. This causes the symbol indexer to re-index the project (and update the cache).
The cached data is stored in the ~/.sts4/.symbolCache/
directory. You will see a bunch of JSON files appearing in that directory once the indexer stores the cache. The mechanism tries to delete outdated data from that directory automatically, but in case something goes wrong, feel free to wipe out the cache directory manually.
The cache is enabled by default. You can switch it off by passing -Dboot.ls.symbols.caching.enabled=false
to the language server.
The support for Spring XML config files now includes direct support for "go to definition" for:
- jump to bean class
- jump to bean definition (across Java source and XML files)
- jump to property definition
- Installation (latest release + snapshots)
- User Guide
- Getting Started
- Navigation
- Live Application Information
- Content Assist
- Version Validation
- Upgrade Support
- Validations and Quick Fixes
- WebFlux Support
- Boot Properties Editor
- Boot Dashboard
- Other Editors
- STS3
- Custom VM args
- FAQ
- Changelog
- Known Limitations & Issues
- Report an Issue
- Developer Manual
- Overview
- Language Server Integration into Clients
- Communication with JDT LS
- STS4 Language Server Protocol Extensions