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

DataGrip User... Have a DB Based Linter, and to call it, output errors to Problems List... #144

Open
kirkw opened this issue Sep 14, 2022 · 2 comments

Comments

@kirkw
Copy link

kirkw commented Sep 14, 2022

Okay, thanks... This has been a great tool to get me to dig in.
I ended up downloading the intellij source so I can search/find things faster.

Anyways, this link has java code to do what I want, I figured I could convert it to groovy and use it.
But the imports mostly FAIL. Rendering the code useless...

Could I get a better understanding of why the imports below are failing?

Thanks!

PS: Even if I have to paste the results from a query, the goal is to have items with line # / Col # references/messages I can click on (like in real programming... But for my stored procedures)

https://intellij-support.jetbrains.com/hc/en-us/community/posts/206751535-How-to-use-CompileContext-addMessage-to-show-a-error-in-the-message-toolbox-


import com.intellij.compiler.CompilerMessageImpl
import com.intellij.compiler.ProblemsView
import com.intellij.compiler.impl.OneProjectItemCompileScope
import com.intellij.openapi.compiler.CompilerMessage
import com.intellij.openapi.compiler.CompilerMessageCategory

@dkandalov
Copy link
Owner

dkandalov commented Sep 19, 2022

Could I get a better understanding of why the imports below are failing?

This is because the compilation classes are part of com.intellij.java plugin and the plugin you're writing doesn't depend on it. You can add the dependency with this instruction // depends-on-plugin com.intellij.java after imports, see this example https://github.com/dkandalov/live-plugin/blob/master/plugin-examples/groovy/additional-classpath/plugin.groovy

In the past IntelliJ IDEs were less modular so compilation classes were part of the "core" (even though they were java-specific) so wouldn't need to specify dependency on any plugin to use e.g. CompilerMessageImpl class.

PS: Even if I have to paste the results from a query, the goal is to have items with line # / Col # references/messages I can click on (like in real programming... But for my stored procedures)

I don't really understand the problem you described, but in case it can be helpful I experimented with extending markdown a while ago https://gist.github.com/dkandalov/db4c400d69be423545e294654475c9aa

@kirkw
Copy link
Author

kirkw commented Sep 20, 2022

Thank you Dmitry!
Your hints have helped. By recording a few macros. I was able to get it working (80%).
I cannot YET create output to the Problems Console...

But I figured out how to parse the function/procedure name from the document.
Then create a custom query to run the LINT in the DB. (I literally jump to the end of the file,
inject the query into the code, SELECT IT, and hit Ctrl+Enter (Console.Jdbc.Execute) thanks to the Macro Trick.
Then I UNDO those items, and STRUGGLE to get the cursor back where it started, and the editor scrolled back.
So I just jumped to the top of the document after "linting".

Next I will try the // depends-on-plugin trick, to try to access those Methods...
Right now this is already a huge timesaver!

I will have to figure out how to grab the grid contents. And how to create a properly formatted Problem,
with the line #, etc. so it is hyperlinked into the code from there..

Thanks for the help!

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

No branches or pull requests

2 participants