Skip to content
This repository has been archived by the owner on Jun 22, 2023. It is now read-only.

Is this a dead repo? #12

Closed
abannach opened this issue Aug 5, 2021 · 4 comments
Closed

Is this a dead repo? #12

abannach opened this issue Aug 5, 2021 · 4 comments

Comments

@abannach
Copy link

abannach commented Aug 5, 2021

Looks like this isn't doing anything in IntelliJ IDEA 2021.1.1 (Ultimate Edition)

@komu
Copy link
Member

komu commented Aug 5, 2021

Hi,

Yeah, I guess plugin would need to be updated to the latest version of IDEA, since there were some incompatible changes. I've been meaning to get around to it at some point, but I haven't found the time. Given IDEA's analysis of SQL and decent tests, I've noticed that even I don't really miss the plugin. 😄

But if you wish to bring the plugin up to speed with latest IDEA versions, I'll certainly merge PR's and release a new version. And I think I'll find the time to fix the plugin at some point anyway, there's just been a lot of other priorities lately.

@abannach
Copy link
Author

abannach commented Aug 6, 2021

No worries. I can't make any promises as I haven't worked with an Intellij plugin before, but if I find some free time I might poke at it. Assuming it's more infrastructure vs logic I think that would be doable.

If you don't mind me asking, how do you have your IDEA doing SQL analysis? Just in the query console or in the actual Java code? The Java code is where I'm not currently getting any syntax highlighting and would like the autocomplete ability.

@abannach abannach closed this as completed Aug 6, 2021
@komu
Copy link
Member

komu commented Aug 9, 2021

Oh, the automatic SQL analysis thing is something that I should fix in Dalesbred. It's still possible to get it working by manually configuring it, but it used to work without any extra work.

So let me digress a bit. Generally it's possible to let IDEA know that a string parameter of a method is actually some language supported by IDEA by adding org.intellij.lang.annotations.Language annotation to it. See how the regular expression is colored (and analyzed):

Screenshot 2021-08-09 at 9 10 29

At some point IDEA even realized that if an annotation is annotated with @Language, then that can be used as well. So
Dalesbred has its own SQL-annotation:

@Language("SQL")
@Retention(RetentionPolicy.CLASS)
@Target({ METHOD, FIELD, PARAMETER, LOCAL_VARIABLE })
public @interface SQL {
}

and every method taking SQL is annotated with it:

public @NotNull <T> List<T> findAll(@NotNull RowMapper<T> rowMapper, @NotNull @SQL String sql, Object... args)

Unfortunately at some point this stopped working in IDEA, so I should drop using the SQL-annotation and just use @Language("SQL") everywhere. Then the analysis should work out of the box.

But to get back to the point, you can actually get it working right now. Since not all methods in all libraries are annotated by their authors, IDEA allows users to specify that "this string parameter is actually this language". Just write a call to the method, place the cursor on the parameter and then press alt-enter to get the intention actions:

Screenshot 2021-08-09 at 9 19 00

Press enter on "Inject language or reference" and then select the correct language from the list. Afterwards IDEA remembers that the given parameter is of the selected language wherever you use it so you only need to do this once per called method. Autocomplete, refactoring, analysis etc. all work right inside the string literal, which is really nice.

Screenshot 2021-08-09 at 9 23 38

@komu
Copy link
Member

komu commented Aug 9, 2021

I just released Dalesbred 1.3.4 which fixes this. So once that is synced to Maven Central within couple of hours, you should be able to use that and not have to specify anything manually.

But of course the above tips are generally useful when dealing with your own code and other third party libraries.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants