Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbols view should nest elements by their surrounding scope #1431

Open
odrotbohm opened this issue Dec 6, 2024 · 9 comments
Open

Symbols view should nest elements by their surrounding scope #1431

odrotbohm opened this issue Dec 6, 2024 · 9 comments
Assignees
Labels
for: eclipse something that is specific for Eclipse for: vscode something that is specific for VSCode theme: spring index & symbols theme: structural view type: enhancement

Comments

@odrotbohm
Copy link
Member

For a Spring MVC controller class like this:

@Controller
class MyController {

  @GetMapping("/path")
  void foo(@RequestParam String bar) {

  }
}

the Spring Symbols view creates multiple top-level entries:

It would be nice if the elements were nested inside each other. The parameter annotation as a nested node underneath the method, that in turn underneath the bean etc. Otherwise (and currently) you might end up with a gazillion of @RequestParam list entries that – without that contextual information – are not really helpful on their own.

@martinlippert martinlippert added theme: spring index & symbols for: eclipse something that is specific for Eclipse for: vscode something that is specific for VSCode and removed status: waiting-for-triage labels Dec 6, 2024
@martinlippert martinlippert added this to the Backlog milestone Dec 6, 2024
@martinlippert martinlippert self-assigned this Dec 6, 2024
martinlippert added a commit that referenced this issue Jan 15, 2025
…ndex child nodes

some additional groundwork for nested structure inside of spring index, in support of GH-1425, GH-1431, GH-1424
@martinlippert
Copy link
Member

There is bit of groundwork necessary to fully materialize this on the UI side, but the groundwork is already underway. I hope for the hierarchical view of symbols to appear in the outline view of VSCode as the first step (probably for the 4.29.0 release), then the work continues for the remaining UI work for 4.30.0 or 4.31.0 - just as a quick update.

@martinlippert
Copy link
Member

@odrotbohm How should the hierarchical structure look like for something like this?

@Configuration
class MyConfig {

  @Bean
  @ConditionalOnClass("some.ClassA")
  public MyBean myBean(@Qualifier("qualifier1") DataSource datasource) {
    ...
  }

}

It seems to me like:

  • myConfig (the bean for the configuration class)
    • myBean (the bean created via the @Bean method)
      • @Qualifier (as a child of the myBean node of the tree?

Where should the @ConditionalOnClass appear in the tree? Not at all? As a child of myBean as well?

What do you think?

martinlippert added a commit that referenced this issue Feb 26, 2025
… AbstractSymbolProvider

GH-1431: changed indexing of components to index embedded components like bean methods, request mappings, etc.

GH-1431: added new tests for index structure
Signed-off-by: Martin Lippert <[email protected]>
@martinlippert
Copy link
Member

@odrotbohm There is a (very specific) way to play around with early steps here.

  • you need to use VSCode with the Java and Spring Boot Tools extension installed
  • you need to switch the Spring Boot Tools extension to the "pre-release" version (there is a button for that in the extension page in VSCode)
  • you need to set a specific preference via: Settings -> Extensions -> Spring Boot Tools -> Language Server -> Spring-boot-LS-Java-Vmware, and add -DoutlineSymbolsFromIndex=true

Then, you can restart VSCode and import your project. The new hierarchical structure will then show up for one file only in the outline section under the Spring Boot Tools node of the tree. This works for single files only at the moment, but it should give you a good idea about how the hierarchical structural view will look like for a single file.

You could imagine that the separate structural view would then show the project perspective, but below the project nodes for each file (the tree structure that you see in the outline view).

This is very early days and it needs a lot of polishing and improvements on various levels. But feel free to give it a try and report back what you stumble upon, what should be incorporated into the structure, what is missing, how to display it differently, etc. At the moment the exact label for each node is more or less what we also create for the workspace symbols, but I assume that those structural view nodes should get their own, slightly different label over time.

@martinlippert
Copy link
Member

One more thing: There is a setting for directing the log output of the language server to a log file. Would be great to set that, just in case something goes wrong. The log output might help in that case.

@odrotbohm
Copy link
Member Author

The new hierarchical structure will then show up for one file only in the outline section under the Spring Boot Tools node of the tree.

Can you elaborate where I would find this? What does "the tree" refer to here? In the Spring Boot Dashboard view I only see the sections "Apps", "Beans", and "Endpoint Mappings".

@odrotbohm
Copy link
Member Author

Never mind. Found it.

@odrotbohm
Copy link
Member Author

This looks nice already. A few things that caught my eye:

  • Spring Data repositories could list the query methods in a nested way?
  • Not all Spring components cause a Spring Boot Tools node to appear in the outline (for example, PaymentServiceImpl in Restbucks does not)
  • The hover text of a bean node ends with "(interface)" even if the bean node is a class (for example PaymentController in Restbucks)

@martinlippert
Copy link
Member

  • Spring Data repositories could list the query methods in a nested way?

How do you identify a query method and distinguish such a method from another, non-query method? Can you point me to the code in Spring Data that identifies query methods? That way, I could mimic that logic inside the tools.

  • Not all Spring components cause a Spring Boot Tools node to appear in the outline (for example, PaymentServiceImpl in Restbucks does not)

Will take a look.

  • The hover text of a bean node ends with "(interface)" even if the bean node is a class (for example PaymentController in Restbucks)

Will look into this as well.

Thanks a lot for the early feedback, very much appreciated. Feel free to add more thoughts here anytime.

@martinlippert
Copy link
Member

  • Not all Spring components cause a Spring Boot Tools node to appear in the outline (for example, PaymentServiceImpl in Restbucks does not)

PaymentServiceImpl is annotated with a Service annotation from JMolecules, not Spring. This is at least the reason why the tooling doesn't recognize it as a bean. How does it turn into a bean? Feels like I need to treat since as a regular @Component annotated class, but how can the tooling decide this?

  • The hover text of a bean node ends with "(interface)" even if the bean node is a class (for example PaymentController in Restbucks)

This comes from the SymbolKind constant that we use here, so VSCode adds the symbol kind to the hover automatically (no way to prevent that), so we need to be more precise about which SymbolKind we choose for each individual symbol or index element.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: eclipse something that is specific for Eclipse for: vscode something that is specific for VSCode theme: spring index & symbols theme: structural view type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants