-
Notifications
You must be signed in to change notification settings - Fork 206
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
add Spring Data JPA Content Assist to STS 4 #107
Comments
Possibly, but I am not totally sure what you are exactly referring to. So, can you give a concrete example of something that used to work and now doesn't anymore? With "concrete", I mean with some code sample and a bit of explanation exactly what you expect to work. We may consider trying to somehow 'rescue' the feature from the old code-base or re-implement it from scratch, but we need to know what you are actually talking about first. Oh, and thanks for the report, we rely on these reports to determine which parts of the old tooling people are really missing. |
I can confirm that the Spring-Data JPA Content assist is not working anymore. When editing JPA Repositories, STS is no longer providing completion for possible fields of the entity. Here is the original feature ticket for older versions which describe the functionality: https://jira.spring.io/browse/IDE-1249 |
I'm attaching screenshots of what code completion looks like in STS 3 vs STS 4 (specifically around JPA Query Methods) |
This pretty much sums up what's missing :-) |
Thanks for the reference and the screenshots. That helps to know what is being talked about here. Now, I'm pretty sure we are not going to re-implement or 'rescue' all of that as it was before because it seems much of it was specific to beans defined by XML. From the screenshots, am I correct in assuming you are really mostly interested in the content assist and validations in Java context? WE might be able to re-implement that, though I suspect it will have to be done mostly from scratch. (Not saying we won't do it, we might, but it could take some time as its not a trivial feature to re-implement). |
This is indeed a feature of the Spring Data support in STS 3.9.x that we didn't re-implement for STS4 yet. This is due to the fact that the Spring support in STS4 is a complete re-write and we focused on specific pieces first (instead of "blindly" re-implementing everything from the old tooling). So this piece didn't make it into the first version of the all-new Spring Tools 4. We should add this to the backlog in order to bring this content-assist for Spring Data repositories back - maybe in an even better shape than we had before... :-) |
Yes, we mainly work within the Java context nowadays. Can't remember when last I defined a bean via XML :-) |
I'm pretty impressed with STS 4 at the moment. Looking forward to what's in store for the future |
@ismailsalloo Anything specific you are looking for with regards to the Spring Data content-assist? Just the Spring Data query method completions? Or something else in addition to that? |
I mainly used it for query method completions. It would be cool if syntax within a @query annotation could also be validated. |
@ismailsalloo What exactly do you mean with syntax validation within a @query annotation? Can you provide a few examples? Since we try to stay away from validations to avoid annoying users with false warnings, I would like to understand this in more detail first. |
@martinlippert, I understand the annoyance behind false validations. It also gets to me at times. Basically my idea is not too much different from the query method suggestion. I was thinking of something to the effect where as you start typing your query within the @query annotation, based on your entity structure, STS provides the user with suggestions of what fields you can extract within your query as well as what fields you can use in your search criteria. In addition to that, if you have a number field within your search criteria, the method param that it maps to must be of type number. I know it's pie in the sky, but it would be super awesome to have that functionality in STS. I hope I'm making sense |
@ismailsalloo Thanks for the details, this content-assist support for the values in the annotation sounds indeed quite useful and like an awesome feature, thanks a lot for the suggestion. Will put that on the list of things to consider for future versions. |
@martinlippert thanks for taking out time to respond to my query and possibly having it included in the future :-) |
Providing content-assist support for JPA queries (thats what int the But i am also looking forward to a possible solution B-) |
I am trying to learn Spring Data so I downloaded STS to help with that effort. But as there is no content assist I am struggling a lot with learning what is capable in Spring Data. So I will have to use STS 3.9 until this is re-implemented in STS 4 unfortunately. Please prioritize this! |
@alextadams88 we already implemented a first step towards content-assist for Spring Data repository query methods in STS 4.1.0 and will continue to improve that for sure. But I would also like to recommend to you to NOT use the content-assist of the IDE as the main driver for learning Spring Data. I would strongly recommend to use the official documentation, guides, and maybe books on Spring Data to learn that. Even the content-assist implementation in STS 3.9.x covers only a fraction of the Spring Data features and doesn't really help a lot when learning Spring Data, I would say. |
Besides the missing content assist, what I mainly miss is the validation part which was in STS3: there was an error if you typing something like |
@LorenzoBettini I agree that these error or warning markers would be extremely useful, there are also somewhat hard to get right and the probability of producing wrong (and then annoying) error and warning markers is quite high. Therefore we opted out of implementing those validations in the first place. And (at the moment) they are not yet on the list of things to re-implement in Spring Tools 4. But we clearly see your vote and take that into account. Please keep the feedback coming. Did you try the first limited content-assist already? What do you miss from it the most? |
@martinlippert the limited content-assist somehow helps, but as I said I'm more concerned about the missing static validation. I don't remember the full signature convention of repository query methods, but the crucial validations I miss is mispelling a field name (are there other things that could be checked besides field names? I guess probably the types of the parameters of the method maybe?) I was wondering whether the logic used by Spring when creating the implementation of such methods at run-time could be reused to do the validation of the fly. In such a case, the validation should not produce any wrong results, right? But I have no idea on how Spring creates the implementation so what I've just said might make no sense at all ;) And in general sts 4 just rocks! :D |
@LorenzoBettini the idea about re-using the spring data implementation itself to implement the validation is a good one in general, this is the way we implemented this in STS3. The downside of this approach is that you have to ship corresponding Spring Data libraries inside of the IDE. And you would need to somehow match the versions, so that you validate the source code of your project with the right version of the Spring Data library, otherwise you can quickly run into version compatibility issues. In addition to that the library is implemented to use runtime type information, so loading classes of your project via a class loader into the JVM and then looking at |
OK, I see. Indeed, IIRC, in sts 3 that validation was performed only on file saving, not on the fly. |
@LorenzoBettini yeah, doing the validation not during the workspace build but on file changes/save events definitely saves some time, but it raises additional questions about dependent changes (like changes to the domain type that is used in the validation for checking the repository methods), so you would need to keep track of those dependencies (including super classes and maybe interfaces). The alternative would be to show those errors/warnings only when the file is open in an editor while typing and remove them once the file is not being edited anymore, but would that be what you would expect? Error shows up when the file is open and disappears when you close the editor again? |
Coming from Xtext, the first option is almost automatic ;) |
Unfortunately, that is correct, we did not improve the existing, simple content-assist for Spring Data yet. Any help with this would be much appreciated (to speed things up)... :-) |
@martinlippert how should I get started. I'd like to help with this feature. I really think it is essential. |
@shahrk Sounds great, your help on this one would be very welcome. This is the class that implements the existing, but very limited content-assist for Spring Data repositories: Here is a simple test case for that implementation: The first step to make some progress here would be to get a workspace up that contains the projects. The easiest way would be, most likely, so import all the projects in the The second step would be to get the existing test running (Run as -> JUnit Test). The unit test case uses this: as a test project to work against. This line in the test prepares the content of the editor: By adding the The infrastructure around this "asking the editor for all the completions" doesn't allow you to specify all the things yet that a completion request to the language server could contain (like a prefix, etc.), so you might want to add that to the infrastructure as you need it. If you decide to work on this, please make sure you accept the CLA upfront and then submit PRs. Also feel free to submit several small PRs instead of one big. That would make reviewing them easier. Hope that helps to get started with this! |
I have created a PR for this. I hope it is useful. |
Absolutely, this is truly awesome. I asked @BoykoAlex to review and provide feedback, so that we can get this into the next release. 😀 |
I will mark this as closed and fixed for now, due to the contribution from @danthe1st. Many thanks for that again!!! |
Further improvements to the content-assist should be captured in separate issues. |
Has Spring Data JPA Content Assist been removed from STS 4? In version 3 I was able to use content assist to show what fields were allowed to be part of the name of the method when using Query Methods. Has it been removed / not added to STS4 or is it a bug or disabled by default?
The text was updated successfully, but these errors were encountered: