spring-projects / sts4

The next generation of tooling for Spring Boot, including support for Cloud Foundry manifest files, Concourse CI pipeline definitions, BOSH deployment manifests, and more... - Available for Eclipse, Visual Studio Code, and Theia
https://spring.io/tools
Eclipse Public License 1.0
870 stars 203 forks source link

use DiagnosticTag.Unnecessary for validations that point out unnecessary things #1345

Open martinlippert opened 1 week ago

martinlippert commented 1 week ago

We have diagnostics in place that point out unnecessary things:

We should include the DiagnosticTag.Unnecessary in the resulting diagnostic marker. It allows the client to render the part in the editor faded out.

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#diagnosticTag

(Whether this works in Eclipse would be an additional thing to verify)

manueljordan commented 1 week ago

About

Unnecessary @PathVariable annotation when the name matches the parameter name (maybe more?)

Do you mean about:

From

@GetMapping(path={"/ciencias/{id}","/ciencias/{id}.html"})
String findOneById(Model model, @PathVariable(name="id") Integer id) {
    model.addAttribute("ciencia", cienciaService.findById(id));
    return "ciencia/findOne";
}

To

@GetMapping(path={"/ciencias/{id}","/ciencias/{id}.html"})
String findOneById(Model model, @PathVariable Integer id) {
    model.addAttribute("ciencia", cienciaService.findById(id));
    return "ciencia/findOne";
}

Therefore from @PathVariable(name="id") to @PathVariable. It thanks to:

If yes, it applies for @RequestParam too such as:

From

@GetMapping(path={"/ciencia","/ciencia.html"})
String findOneById(Model model, @RequestParam(name="id") Integer id) {
    model.addAttribute("ciencia", cienciaService.findById(id));
    return "ciencia/findOne";
}

To

@GetMapping(path={"/ciencia","/ciencia.html"})
String findOneById(Model model, @RequestParam Integer id) {
    model.addAttribute("ciencia", cienciaService.findById(id));
    return "ciencia/findOne";
}

But here is tricky because the URL is unknown until runtime