GithubHelp home page GithubHelp logo

lsp4jakarta's Introduction

Eclipse LSP4Jakarta - Language Server for Jakarta EE

License Build Gitter

The Eclipse LSP4Jakarta (Language Server for Jakarta EE) project provides language support capabilities for the specifications defined under the Jakarta EE umbrella. It adheres to the language server protocol.

This project contains:

component diagram

Table of Contents


Client IDEs

Eclipse LSP4Jakarta is consumed by the following client IDEs.

Submit a PR to have your tools that use Eclipse LSP4Jakarta listed.

Features

The language features currently offered by Eclipse LSP4Jakarta to Jakarta EE APIs are code snippets, diagnostics, and quick-fixes.

Code snippets help you quickly generate common blocks of code.

Eclipse LSP4Jakarta code snippet to generate a new RESTful web services GET method

Diagnostics indicate incorrect API usage and suggest associated quick-fixes to correct API usage.

Eclipse LSP4Jakarta diagnostic and quick-fix for invalid RESTful web services usage

The following is a list of Eclipse LSP4Jakarta language features offered for each Jakarta EE API. Language features will only be delivered for a given Jakarta EE API if that API is found on the project's class path. Eclipse LSP4Jakarta is currently targeting Jakarta EE 9/9.1 (jakarta.* namespace).

If you would like to see language feature assistance for a Jakarta EE API that is not yet listed here, please open an issue on the issue tracker.

Jakarta Annotations

Eclipse LSP4Jakarta provides the following Jakarta Annotations diagnostics.

Diagnostic description Severity Associated quick-fixes
The @Generated annotation must define the 'date' attribute following the ISO 8601 standard. Error N/A
The @Resource annotation must define the attribute 'type' when applied on a class. Error Add type to jakarta.annotation.Resource
The @Resource annotation must define the attribute 'name' when applied on a class. Error Add name to jakarta.annotation.Resource
A method with the @PostConstruct annotation must be void Error Change return type to void
A method with the @PreDestroy annotation must not be static. Error N/A
A method with the @PostConstruct/@PreDestroy annotation must not have any parameters. Error Remove @PostConstruct/@PreDestroy OR Remove all parameters
A method with the @PostConstruct/@PreDestroy annotation must not throw checked exceptions. Warning N/A

Jakarta Bean Validation

Eclipse LSP4Jakarta provides the following Jakarta Bean Validation snippets.

Snippet prefix Description
@Email Email address constraint, which validates a well-formed email address

Eclipse LSP4Jakarta provides the following Jakarta Bean Validation diagnostics.

Diagnostic description Severity Associated quick-fixes
Constraint annotations are not allowed on static fields or methods. Error Remove the constraint annotation OR Remove the static modifier
The @AssertTrue/@AssertFalse annotation can only be used on boolean and Boolean type fields or methods. Error Remove @AssertTrue/@AssertFalse
The @DecimalMax/@DecimalMin/@Digits annotation can only be used on: BigDecimal, BigInteger, CharSequence, byte, short, int, long (and their respective wrappers) type fields or methods. Error Remove @DecimalMax/@DecimalMin/@Digits
The @Email annotation can only be used on String and CharSequence type fields or methods. Error Remove @Email
The @Future/@FutureOrPresent/@Past/@PastOrPresent annotation can only be used on: Date, Calendar, Instant, LocalDate, LocalDateTime, LocalTime, MonthDay, OffsetDateTime, OffsetTime, Year, YearMonth, ZonedDateTime, HijrahDate, JapaneseDate, JapaneseDate, MinguoDate and ThaiBuddhistDate type fields or methods. Error Remove @Future/@FutureOrPresent/@Past/@PastOrPresent
The @Min/@Max annotation can only be used on BigDecimal, BigInteger, byte, short, int, long (and their respective wrappers) type fields or methods. Error Remove @Min/@Max
The @Negative/@NegativeOrZero/@Positive/@PositiveOrZero annotation can only be used on BigDecimal, BigInteger, byte, short, int, long, float, double (and their respective wrappers) type fields or methods. Error Remove @Negative/@NegativeOrZero/@Positive/@PositiveOrZero
The @NotBlank/@Pattern annotation can only be used on String and CharSequence type fields or methods. Error Remove @NotBlank/@Pattern

Jakarta Contexts and Dependency Injection

Eclipse LSP4Jakarta provides the following Jakarta Contexts and Dependency Injection diagnostics.

Diagnostic description Severity Associated quick-fixes
A bean constructor or a method annotated with @Inject cannot have parameter(s) annotated with @Disposes/@Observes/@ObservesAsync Error Remove @Inject OR Remove the '@Disposes/@Observes/@ObservesAsync' modifier from parameter 'parameter_name'
A producer method cannot have parameter(s) annotated with @Disposes/@Observes/@ObservesAsync Error Remove @Produces OR Remove the '@Disposes/@Observes/@ObservesAsync' modifier from parameter 'parameter_name'
The @Disposes annotation must not be defined on more than one parameter of a method. Error N/A
Managed bean class of generic type must have scope @Dependent Error Replace current scope with @Dependent
The @Dependent annotation must be the only scope defined by a managed bean with a non-static public field. Error Replace current scope with @Dependent
The @Inject annotation must define a managed bean constructor that takes parameters, or the managed bean must resolve to having a no-arg constructor instead. Error Insert @Inject OR Add a no-arg protected constructor to this class OR Add a no-arg public constructor to this class.
The @Produces and @Inject annotations must not be used on the same field or property. Error Remove @Produces OR @Inject
Scope type annotations must be specified by a managed bean class/producer field or method at most once. Error N/A

Jakarta Dependency Injection

Eclipse LSP4Jakarta provides the following Jakarta Dependency Injection diagnostics.

Diagnostic description Severity Associated quick-fixes
The @Inject annotation must not define a final method. Error Remove @Inject OR Remove the 'final' modifier from this field
The @Inject annotation must not define a final/abstract/static method. Error Remove @Inject OR Remove the 'final/asbtract/static' modifier from this method
The @Inject annotation must not define a generic method. Error Remove @Inject
The @Inject annotation must not define more than one constructor. Error Remove @Inject

Jakarta JSON Binding

Eclipse LSP4Jakarta provides the following Jakarta JSON Binding diagnostics.

Diagnostic description Severity Associated quick-fixes
Only one constructor or static factory method can be annotated with @JsonbCreator in a given class. Error Remove @JsonbCreator
When a class field is annotated with @JsonbTransient, this field, getter or setter must not be annotated with other JSON Binding annotations. Error Remove @JsonbTransient OR Remove @JsonbProperty/@JsonbAnnotation
When an accessor is annotated with @JsonbTransient, its field or the accessor must not be annotated with other JSON Binding annotations. Error Remove @JsonbTransient OR Remove @JsonbProperty/@JsonbAnnotation

Jakarta JSON Processing

Eclipse LSP4Jakarta provides the following Jakarta JSON Processing diagnostics.

Diagnostic description Severity Associated quick-fixes
Json.createPointer target must be a sequence of '/' prefixed tokens or an empty String Error N/A

Jakarta Persistence

Eclipse LSP4Jakarta provides the following Jakarta Persistence snippets.

Snippet prefix Description
persist_context Entity manager injection and associated persistence context
persist_context_extended Entity manager injection with extended persistence context
persist_context_extended_unsync Entity manager injection with extended, unsynchronized persistence context
persist_entity Generic persistence entity model. Only available in an empty file.

Eclipse LSP4Jakarta provides the following Jakarta Persistence diagnostics.

Diagnostic description Severity Associated quick-fixes
A class using the @Entity annotation must contain a public or protected constructor with no arguments. Error Add a no-arg protected constructor to this class OR Add a no-arg public constructor to this class
A class using the @Entity annotation must not be final. Error Remove the 'final' modifier from this class
A class using the @Entity annotation cannot contain any methods that are declared final Error Remove the 'final' modifier from this method
A class using the @Entity annotation cannot contain any persistent instance variables that are declared final Error Remove the 'final' modifier from this field
@MapKeyClass and @MapKey annotations cannot be used on the same field or property Error Remove @MapKeyClass OR Remove @MapKey
A field with multiple @MapKeyJoinColumn annotations must specify both the name and referencedColumnName attributes in the corresponding @MapKeyJoinColumn annotations. Error Add the missing attributes to the @MapKeyJoinColumn annotation

Jakarta RESTful Web Services

Eclipse LSP4Jakarta provides the following Jakarta RESTful Web Services snippets.

Snippet prefix Description
rest_class Resource class with GET resource method. Only available in an empty file.
rest_get GET resource method
rest_post POST resource method
rest_put PUT resource method
rest_delete DELETE resource method
rest_head HEAD resource method

Eclipse LSP4Jakarta provides the following Jakarta RESTful Web Services diagnostics.

Diagnostic description Severity Associated quick-fixes
Resource methods cannot have more than one entity parameter. Error Remove all entity parameters except 'entity_param_name'
Provider/Root resource classes are instantiated by the JAX-RS runtime and MUST have a public constructor. Error Make constructor public OR Add a no-arg public constructor to this class
Only public methods can be exposed as resource methods. Error Make method public
This constructor is unused, as root resource classes will only use the constructor with the most parameters. Warning N/A
Multiple constructors have the same number of parameters, it might be ambiguous which constructor is used. Warning N/A

Jakarta Servlet

Eclipse LSP4Jakarta provides the following Jakarta Servlet snippets. All these snippets are only available in an empty file.

Snippet prefix Description
servlet_generic Generic protocol independent servlet
servlet_doget HTTPServlet with GET request
servlet_dopost HTTPServlet with POST request
servlet_webfilter Servlet WebFilter

Eclipse LSP4Jakarta provides the following Jakarta Servlet diagnostics.

Diagnostic description Severity Associated quick-fixes
Annotated classes with @WebServlet must extend the HttpServlet class. Error Let 'class_name' extend 'HttpServlet'
The @WebServlet annotation must define the attribute 'urlPatterns' or 'value'. Error Add the 'value' attribute to @WebServlet OR Add the 'urlPatterns' attribute to @WebServlet

Jakarta Transactions

Eclipse LSP4Jakarta provides the following Jakarta Transactions snippets.

Snippet prefix Description
tx_user_inject Initializes a UserTransaction object via injection
tx_user_jndi Initializes a UserTransaction object via JNDI lookup
@Transactional Transactional annotation with rollbackOn and dontRollbackOn

Jakarta WebSocket

Eclipse LSP4Jakarta provides the following Jakarta WebSocket diagnostics.

Diagnostic description Severity Associated quick-fixes
Parameters of type String, any Java primitive type, or boxed version thereof must be annotated with @PathParams. Error Insert @PathParam
Classes annotated with @ServerEndpoint or @ClientEndpoint must have only one @OnMessage annotated method for each of the native WebSocket message formats: text, binary and pong. Error N/A
Invalid parameter type. When using @OnOpen, parameter must be of type: jakarta.websocket.EndpointConfig, jakarta.websocket.Session, annotated with @PathParams and of type String or any Java primitive type or boxed version thereof. Error N/A
Invalid parameter type. When using @OnClose, parameter must be of type: jakarta.websocket.CloseReason, jakarta.websocket.Session, annotated with @PathParams and of type String or any Java primitive type or boxed version thereof. Error N/A
Server endpoint paths must not use the same variable more than once in a path. Error N/A
Server endpoint paths must be a URI-template (level-1) or a partial URI. Error N/A
Server endpoint paths must start with a leading '/'. Error N/A
Server endpoint paths must not contain the sequences '/../', '/./' or '//'. Error N/A

Contributing

See the DEVELOPING and CONTRIBUTING documents for more details.

License

Eclipse Public License - v 2.0 See LICENSE file.

Feedback

Please report bugs, issues and feature requests by creating a GitHub issue.

lsp4jakarta's People

Contributors

aditrada avatar ajm01 avatar ananya2801 avatar ankushsharma2698 avatar aparnamichael avatar bensonnw avatar berasogut avatar dalidia avatar evie-lau avatar giancarlopernudisegura avatar hanidamlaj avatar himanshuc71 avatar jnnnx7 avatar kathrynkodama avatar kidovin01 avatar lamminade avatar mattbsox avatar mezarin avatar mshah0722 avatar pengyuxiong avatar priyyanshi avatar rezaakv avatar scottkurz avatar shaunak avatar tiganov avatar turkeylurkey avatar vaisakhkannan avatar yeekangc avatar yijiajing avatar zijianp001 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lsp4jakarta's Issues

Jakarta Servlet GenericServlet and HttpServlet snippets

Add the following Jakarta Servlet snippets for Java files:

  • extending GenericServlet
  • extending HttpServlet

The snippet should provide the corresponding imports and methods that are used in best practice.

https://jakarta.ee/specifications/servlet/5.0/apidocs/jakarta/servlet/GenericServlet.html
https://jakarta.ee/specifications/servlet/5.0/apidocs/jakarta/servlet/http/HttpServlet.html

See https://eclipse-ee4j.github.io/jakartaee-tutorial/servlets001.html#BNAFE and https://github.com/eclipse-ee4j/jakartaee-tutorial-examples/tree/master/web/servlet for examples.

*note the tutorial is referring to Jakarta EE 8, with Jakarta EE 9 the package names will change to jakarta... which is why they are slightly different in the apidocs.

POC: Use Eclipse JDT to calculate a diagnostic

Proof of Concept:
Connect a sample diagnostic to Eclipse JDT, ie. have a diagnostic appear on a specific annotation/class/method etc.

Note: All code accessing Eclipse JDT should be in a separate package within the Eclipse Client.

Resources:
Eclipse JDT Tutorials
JDTUtils - we don't need to have this complicated logic at this point, just use this class for reference.

quick fix(s) for general servlet

add quick fixes for existing diagnostics inside servlet

  • quick fix(s) for implementing each of the interfaces (Done)
  • quick fix for correcting the annotations
  • quick fix for implementing Filter (Done)

Support for Jakarta WebProfile priority specifications

https://jakarta.ee/specifications/webprofile/9/

Jakarta Servlet 5.0

  • @WebListener diagnostic #6 and quick fix
  • @WebServlet diagnostic #7 and quick fix
  • @WebServlet and @WebFilter URL diagnostics #8 and quick fix
  • @WebFilter diagnostic #13 and quick fix
  • GenericServlet and HttpServlet snippets #9
  • Filter snippet #12

Jakarta Persistence 3.0

  • Generic Entity Model (No relationships with other entities)[MVC] snippets #35
  • @PersistenceContext snippets #36
  • @Entity diagnostics #48
  • MapKey diagnostics #49
    • quick fix for MapKey annotation #75
    • quick fix for MapKeyColumn annotation #76

Jakarta Bean Validation 3.0

  • Constraint diagnostics #53 and quick fix #113
  • Constraints on static fields diagnostic #55 and quick fix #114
  • Constraint @Size and @NotEmpty diagnostics #63
    • quick fix
  • Constraints on static methods diagnostic #55 and quick fix #114
  • @Email snippet #52

Jakarta JSON Binding 2.0

Jakarta RESTful Web Services 3.0

  • diagnostic for non-public Jax-rs resource methods #78
  • Jax-rs resource snippets #77
  • diagnostic for root resource class constructors #116
  • diagnostic for resource method entity parameters #117
  • diagnostic for root resource class with multiple public constructors #118, #119
  • diagnostic for provider class constructors #124

Jakarta Contexts and Dependency Injection 3.0

  • non-static public field and incorrect scope diagnostic #81
  • @Produces and @Inject diagnostic #102
  • scope diagnostic #103
  • initializer method with incorrect annotations #104
  • producer method with incorrect parameter annotations #105
  • @Disposes diagnostic #106
  • managed bean diagnostic #108
  • outstanding quick-fixes #134

Jakarta Annotations 2.0

Jakarta Dependency Injection 2.0

Jakarta Managed Beans 2.0

Jakarta WebSocket 2.0

Jakarta Transactions

Diagnostic for non-public JAX-RS resource methods.

From the spec:

"Only public methods may be exposed as resource methods. An implementation SHOULD warn users if a non-public method carries a method designator or @Path annotation."

Display a warning on any non-public resource methods that only public methods can be used.

solution of "Bundle can't be resolved" on eclipse

Some bundles may not get resolved for eclipse after initialization.

In my case "org.apache.commons.lang3" is not added.

The solution is:

  • go to the preferences on eclipse and search for "target platform"
  • select the "running platform" and then click edit on the right
  • choose add in the pop up window to add locations
  • at last, choose software website option and use the website url to Download plug-ins.

The website link for "org.apache.commons.lang3" is "http://download.eclipse.org/tools/orbit/downloads/drops/R20150519210750/repository/"

Jakarta Persistence MapKey diagnostics

Add the following diagnostics related to MapKey:

  1. Add a diagnostic to validate that the @MapKeyClass and @MapKey annotations are not used on the same field or property.
    https://jakarta.ee/specifications/persistence/3.0/jakarta-persistence-spec-3.0.html#mapkey-annotation

  2. Add a diagnostic to validate that if more than one @MapKeyJoinColumn annotation is applied to a field or property, both the name and the referencedColumnName elements must be specified in each such@MapKeyJoinColumn annotation.
    https://jakarta.ee/specifications/persistence/3.0/jakarta-persistence-spec-3.0.html#a15450

Jakarta Servlet @WebServlet and @WebFilter URL diagnostics

Add a diagnostic to verify that the servlet annotated with @WebServlet must specify at least one URL pattern.

https://jakarta.ee/specifications/servlet/5.0/apidocs/jakarta/servlet/annotation/WebServlet.html

See https://eclipse-ee4j.github.io/jakartaee-tutorial/servlets004.html
*note the tutorial is referring to Jakarta EE 8, with Jakarta EE 9 the package names will change to jakarta... which is why they are slightly different in the apidocs.

Add quick-fix for Jakarta Persistence MapKeyJoinColumn diagnostic

If more than one @MapKeyJoinColumn annotation is applied to a field or property, both the name and the referencedColumnName elements must be specified in each such @MapKeyJoinColumn annotation.
https://github.com/eclipse/lsp4jakarta/blob/master/jakarta-eclipse/src/org/jakarta/jdt/persistence/PersistenceMapKeyDiagnosticsCollector.java#L124-L153

Add quick-fix(s) to this diagnostic to add the missing elements to the existing annotations.
See this quick-fix implementation here for modifying an annotation: https://github.com/eclipse/lsp4jakarta/pull/73/files

Jakarta Persistence Snippet - Annotation snippets for the many types of Column Relationships

There are Several different types of relationships columns in different tables can have. This is represented through annotations in Jakarta Persistence. These annotations also have several optional parameters that yield different behaviour
I will provide and example of a single instance using the @OneToOne annotation.

@OneToOne() // Basic Usage
@OneToOne(optional=false) // A non-null relationship must always exist
@OneToOne(cascade=REMOVE) // cascades the remove option to the target
... etc.

There are several other parameters that can be placed to provide snippets,
this is a relatively small amount of code so I am not sure if it is the most viable.
But it can be made viable with associated comments in the snippet to provide the user context into what the snippet does.

CDI managed bean with non-public static field and incorrect scope diagnostic

https://jakarta.ee/specifications/cdi/2.0/cdi-spec-2.0.html#managed_beans
According to the CDI specification: If a managed bean has a non-static public field, it must have scope @Dependent. If a managed bean with a non-static public field declares any scope other than @Dependent, the container automatically detects the problem and treats it as a definition error.

Deliver a diagnostic warning if the class is annotated with @ApplicationScoped (jakarta.enterprise.context.ApplicationScoped), @ConversationScoped, @RequestScoped or @SessionScoped and contains a non-static public field. The diagnostic should be delivered on the non-static public field.

The following quick-fixes should be available:

  • make the field static
  • change the scope of the class to @Dependent

See javadocs here: https://jakarta.ee/specifications/cdi/2.0/apidocs/

Jakarta Servlet Filter snippet

Add a snippet to Java files for implementing the Filter interface.

https://jakarta.ee/specifications/servlet/5.0/apidocs/jakarta/servlet/Filter.html

See:
https://eclipse-ee4j.github.io/jakartaee-tutorial/servlets006.html
https://github.com/eclipse-ee4j/jakartaee-tutorial-examples/blob/9814044413785e7b3428fd0f0259a3f7c778ef69/web/servlet/mood/src/main/java/jakarta/tutorial/mood/TimeOfDayFilter.java

*note the tutorial is referring to Jakarta EE 8, with Jakarta EE 9 the package names will change to jakarta... which is why they are slightly different in the apidocs.

Implement dynamic templating in completionSnippets

Certain key variables should resolve automatically in snippets.
Example:

${package_name}

Should resolve automatically based on the context to

package com.example.system;

I just did some testing, and the proposed method doesnt actually work in eclipse rn. I tried messing around with templates in eclipse and that does fill in snippets with variables as we want but for whatever reason that is not extending to our current completion framework. So for now I would say we should keep snippets like this. In order to accomodate the change in this request I think i would have to restructure completionProposalComputer a bit and I am not sure about what is needed for that yet

Jakarta Servlet @WebFilter diagnostic

Classes annotated with @WebFilter must implement the Filter interface.

https://jakarta.ee/specifications/servlet/5.0/apidocs/jakarta/servlet/annotation/WebFilter.html
https://jakarta.ee/specifications/servlet/5.0/apidocs/jakarta/servlet/Filter.html

See:
https://eclipse-ee4j.github.io/jakartaee-tutorial/servlets006.html
*note the tutorial is referring to Jakarta EE 8, with Jakarta EE 9 the package names will change to jakarta... which is why they are slightly different in the apidocs.

Quick fix does not show up on diagnostic hover

Quick fixes show up on hover when you first launch an Eclipse application:
image

Once a change is made, the quick fix no longer appears on the hover of the diagnostic:
image

The quickfix is still accessible by clicking the warning on the left side bar, through the problems view, or right-clicking on the diagnostic and selecting "Quickfix"
image

Add quick-fix for Jakarta Persistence MapKey diagnostic

The @MapKeyClass and @MapKey annotations cannot be used on the same field or property. See the corresponding diagnostic here: https://github.com/eclipse/lsp4jakarta/blob/master/jakarta-eclipse/src/org/jakarta/jdt/persistence/PersistenceMapKeyDiagnosticsCollector.java#L75-L109

Add two quick-fixes for this diagnostic:

  1. Remove the @MapKeyClass annotation
  2. Remove the @MapKey annotation

This will involve creating a new Proposal class called "DeleteAnnotationProposal" modelled after ModifyAnnotationProposal.
See an example quick-fix here: https://github.com/eclipse/lsp4jakarta/pull/73/files

POC: Set up framework for completions

Jakarta Servlet HttpServletRequest snippets

Add the following Jakarta Servlet snippets for Java files:

  • implementing the ServletRequest interface (if necessary and used commonly in practice)
  • extending the HttpServletRequest class

https://jakarta.ee/specifications/servlet/5.0/apidocs/jakarta/servlet/ServletRequest.html
https://jakarta.ee/specifications/servlet/5.0/apidocs/jakarta/servlet/http/HttpServletRequest.html

See https://eclipse-ee4j.github.io/jakartaee-tutorial/servlets005.html
*note the tutorial is referring to Jakarta EE 8, with Jakarta EE 9 the package names will change to jakarta... which is why they are slightly different in the apidocs.

Cannot satisfy dependency error on mvn install

Getting an error on my machine when running mvn clean install in the jakarta-eclipse folder,

`[DEBUG] Resolving target definition content...
[DEBUG] No solution found because the problem is unsatisfiable.: [Unable to satisfy dependency from com.google.guava 27.1.0.v20190517-1946 to osgi.ee; (&(osgi.ee=JavaSE)(version=1.7)).; Unable to satisfy dependency from com.ibm.icu 64.2.0.v20190507-1337 to osgi.ee; (&(osgi.ee=JavaSE)(version=1.7)).;

...

[ERROR] Cannot resolve target definition:
[ERROR] Software being installed: org.eclipse.buildship.feature.group 3.1.4.v20200326-1743
[ERROR] Missing requirement: com.google.guava 27.1.0.v20190517-1946 requires 'osgi.ee; (&(osgi.ee=JavaSE)(version=1.7))' but it could not be found
[ERROR] Cannot satisfy dependency: org.eclipse.buildship.core 3.1.4.v20200326-1743 depends on: osgi.bundle; com.google.guava [27.0.0,28.0.0)
[ERROR] Cannot satisfy dependency: org.eclipse.buildship.feature.group 3.1.4.v20200326-1743 depends on: org.eclipse.equinox.p2.iu; org.eclipse.buildship.core [3.1.4.v20200326-1743,3.1.4.v20200326-1743]
[ERROR]
[ERROR] Failed to resolve target definition /Users/ldawson/.m2/repository/org/eclipse/jdt/ls/org.eclipse.jdt.ls.tp/0.57.0.20200619102332/org.eclipse.jdt.ls.tp-0.57.0.20200619102332.target: See log for details -> [Help 1]
org.apache.maven.MavenExecutionException: Failed to resolve target definition /Users/ldawson/.m2/repository/org/eclipse/jdt/ls/org.eclipse.jdt.ls.tp/0.57.0.20200619102332/org.eclipse.jdt.ls.tp-0.57.0.20200619102332.target`

Eclipse:

Eclipse IDE for Java Developers (includes Incubating components)
Version: 2020-12 (4.18.0)
Build id: 20201210-1552

Java:

openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9)
Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.24.0, JRE 11 Mac OS X amd64-64-Bit Compressed References 20210120_897 (JIT enabled, AOT enabled)
OpenJ9 - 345e1b09e
OMR - 741e94ea8
JCL - 0a86953833 based on jdk-11.0.10+9)

We tried

  • updating Java version
  • deleting the .m2/repository and running mvn -U clean install
  • uninstalling & reinstalling buildship
  • adding tycho-snapshots to the jakarta-eclipse pom.xml
  • adding osgi 3.7.1 to the core pom.xml

Add quick-fix for Jakarta Persistence @Entity diagnostic

If a class is annotated with jakarta.persistence.Entity:

  1. The entity class must have a public or protected no-arg constructor (the class may have other constructors).
  2. The entity class must not be final. No methods or persistent instance variables of the entity class may be final.

Add quick-fixes to this diagnostic to:

  • add a public or no-arg constructor if none present
  • remove the final keyword from the class, methods, or persistent instances variables if present

See https://jakarta.ee/specifications/persistence/3.0/jakarta-persistence-spec-3.0.html#a18

POC: Set up framework for hover

Proof of Concept

  1. Create a sample hover object
  • create a new org.eclipse.jdt.ui.javaEditorTextHovers in the plugin.xml (see org.eclipse.jdt.ui.javaEditorTextHovers)
    ie.
<extension
         id="jakartajava-hover-provider"
         point="org.eclipse.jdt.ui.javaEditorTextHovers">
      <hover
            activate="true"
            class="org.jakarta.lsp4e.JakartaJavaHoverProvider"
            id="org.jakarta.lsp4e.hoverprovider">
      </hover>
   </extension>

Jakarata Bean Validation Snippets for built-in constraints

Make useful snippets similar to @Email snippet #52 for Bean Validation constraints. There could be snippets for: Digits, DecimalMax, DecimalMin, PastOrPresent, FutureOrPresent, Past, Future, Min, Max, NegativeOrZero, PostiveOrZero, Negative, Positive, NotBlank, Pattern, NotEmpty, and Size annotations.

Jakarta Servlet @WebListener diagnostic

Classes annotated with @WebListener must implement one of the following interfaces:

  • jakarta.servlet.ServletContextListener
  • jakarta.servlet.ServletContextAttributeListener
  • jakarta.servlet.ServletRequestListener
  • jakarta.servlet.ServletRequestAttributeListener
  • jakarta.servlet.http.HttpSessionListener
  • jakarta.servlet.http.HttpSessionAttributeListener

See https://jakarta.ee/specifications/servlet/5.0/apidocs/jakarta/servlet/annotation/WebListener.html and https://eclipse-ee4j.github.io/jakartaee-tutorial/servlets002.html
*note the tutorial is referring to Jakarta EE 8, with Jakarta EE 9 the package names will change to jakarta... which is why they are slightly different in the apidocs.

Add a diagnostic to verify the above.

Jakarta CDI Produces and Inject diagnostic

Add a diagnostic to validate that @Inject and @Produces are not used for the same field or method.

Add quick fix for @WebServlet diagnostic

Implement the framework for quick fixes, we should offer a quick fix to extend the HttpServlet class when presenting the @WebServlet diagnostic (#7).

Quick fixes are implemented via code actions: https://microsoft.github.io/language-server-protocol/specification#textDocument_codeAction

Quick fix should say:

Let `%classname` extend `jakarta.servlet.http.HttpServlet`

See an example of a quick fix from ls4pmp here:
https://github.com/eclipse/lsp4mp/blob/master/microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/jdt/internal/health/java/ImplementHealthCheckQuickFix.java

Jakarta Servlet @WebServlet diagnostic

Add a diagnostic to verify that classes annotated with @WebServlet must extend the HttpServlet class.

https://jakarta.ee/specifications/servlet/5.0/apidocs/jakarta/servlet/annotation/WebServlet.html
https://jakarta.ee/specifications/servlet/5.0/apidocs/jakarta/servlet/http/HttpServlet.html

See https://eclipse-ee4j.github.io/jakartaee-tutorial/servlets004.html
*note the tutorial is referring to Jakarta EE 8, with Jakarta EE 9 the package names will change to jakarta... which is why they are slightly different in the apidocs.

JsonbCreator quick fix and automated tests

  • Add a quick-fix code action to remove additional @JsonbCreator annotations associated with this diagnostic: #79. See the DeleteAnnotationProposal class included in this pull request for reference: #87

  • Add automated tests for the above diagnostic and quick-fix. See JakartaServletTest for an example

Jakarta Servlet HttpServletResponse snippets

Add the following Jakarta Servlet snippets for Java files:

  • implementing the ServletResponse interface (if necessary and used commonly in practice)
  • extending the HttpServletResponse class

https://jakarta.ee/specifications/servlet/5.0/apidocs/jakarta/servlet/ServletResponse.html
https://jakarta.ee/specifications/servlet/5.0/apidocs/jakarta/servlet/http/HttpServletResponse.html

See https://eclipse-ee4j.github.io/jakartaee-tutorial/servlets005.html
*note the tutorial is referring to Jakarta EE 8, with Jakarta EE 9 the package names will change to jakarta... which is why they are slightly different in the apidocs.

Jakarta Bean Validation Size and NotEmpty annotation diagnostics

Add diagnostics for these constraints to ensure they are annotated on the supported types.

The main problem is that these annotations work on field types of Collections, Arrays and Map, which should be resolved (before using them to check against the allowed types below) and also the type could be any custom subtype of these interfaces including user made ones.

@NotEmpty: Supported types are:

  • CharSequence (length of character sequence is evaluated)
  • Collection (collection size is evaluated)
  • Map (map size is evaluated)
  • Array (array length is evaluated)

@Size: Supported types are:

  • CharSequence (length of character sequence is evaluated)
  • Collection (collection size is evaluated)
  • Map (map size is evaluated)
  • Array (array length is evaluated)

Jakarta Bean Validation Constraint diagnostics

Add diagnostics to the following constraints to ensure they are annotated on the supported types:
See the javadocs under the "jakarta.validation.constraints" package here: https://jakarta.ee/specifications/bean-validation/3.0/apidocs/

@AssertFalse and @AssertTrue: Supported types are boolean and Boolean.

@DecimalMax, @DecimalMin : Supported types are:

  • BigDecimal
  • BigInteger
  • CharSequence
  • byte, short, int, long, and their respective wrappers
  • Note that double and float are not supported due to rounding errors (some providers might provide some approximative support)

@Digits: Supported types are:

  • BigDecimal
  • BigInteger
  • CharSequence
  • byte, short, int, long, and their respective wrappers

@Email: Supported types are String and CharSequence

@Future, @FutureOrPresent, @Past, @PastOrPresent: Supported types are:

  • java.util.Date
  • java.util.Calendar
  • java.time.Instant
  • java.time.LocalDate
  • java.time.LocalDateTime
  • java.time.LocalTime
  • java.time.MonthDay
  • java.time.OffsetDateTime
  • java.time.OffsetTime
  • java.time.Year
  • java.time.YearMonth
  • java.time.ZonedDateTime
  • java.time.chrono.HijrahDate
  • java.time.chrono.JapaneseDate
  • java.time.chrono.MinguoDate
  • java.time.chrono.ThaiBuddhistDate

@Max, @Min: Supported types are:

  • BigDecimal
  • BigInteger
  • byte, short, int, long, and their respective wrappers
  • Note that double and float are not supported due to rounding errors (some providers might provide some approximative support).

@Negative, @NegativeOrZero, @Positive, @PostiveOrZero: Supported types are:

  • BigDecimal
  • BigInteger
  • byte, short, int, long, float, double and their respective wrappers

@NotBlank: String, CharSequence

@NotEmpty: Supported types are:

  • CharSequence (length of character sequence is evaluated)
  • Collection (collection size is evaluated)
  • Map (map size is evaluated)
  • Array (array length is evaluated)

@Pattern: String, CharSequence

@Size: Supported types are:

  • CharSequence (length of character sequence is evaluated)
  • Collection (collection size is evaluated)
  • Map (map size is evaluated)
  • Array (array length is evaluated)

Jakarta Bean Validation ConstraintValidator snippet

Snippet for a custom constraint validator class:

package {};

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class {} implements ConstraintValidator<A extends Annotation, Object> {

    @Override
    public boolean isValid(Object arg0, ConstraintValidatorContext constraintContext) {

    }

}

@rezaakv can you evaluate if this would be useful to developers, and if perhaps we should provide a snippet for a popular annotation type?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.