Inspections plus Structural Search/Replace - Great plugin idea, but is it possible?

While playing with structural search and replace I had a very nice idea:
What if a user can define a new inspection herself by creating a structural search and replace and saving it with an inspection name and description?
Inspection is triggered by search result and automatically offers quick fix, i.e. replace expression.

There could be a bunch of default inspections defined this way, e.g. to replace deprecated JDK code with new construct.
The same way I could define inspections to align code to my own company's standard, e.g. "direct construction of JButton" with quick fix "use com.foo.SwingFactory.createButton()" instead (just a contrived example).

Would this be feasible with the current opan api?

4 comments
Comment actions Permalink

Stephen Kelvin wrote:

>What if a user can define a new inspection herself by creating a structural search and replace and saving it with an inspection name and description?

>

I've been dreaming of such a feature, when hardcoding camouflage plugin
visitors for each pattern that I want to "camouflage", but I have some
doubts regarding performance: when you modify one char in one line, of a
2000-line class, is the whole class re-inspected?
Optimization would require the "searcher" to know the scope of each
inspection: line, block, statement, method, class..


Alain

0
Comment actions Permalink

I posted such a suggestion a while ago and Dave said it wouldn't be very
useful because most useful inspections need some logic, which the SS does
not provide.

While playing with structural search and replace I had a very nice
idea:

What if a user can define a new inspection herself by creating a
structural search and replace and saving it with an inspection name
and description?

Inspection is triggered by search result and automatically offers
quick fix, i.e. replace expression.

There could be a bunch of default inspections defined this way, e.g.
to replace deprecated JDK code with new construct.

The same way I could define inspections to align code to my own
company's standard, e.g. "direct construction of JButton" with quick
fix "use com.foo.SwingFactory.createButton()" instead (just a
contrived example).

Would this be feasible with the current opan api?




0
Comment actions Permalink

Keith Lea wrote:

... said it wouldn't be very useful because most useful inspections
need some logic, which the SS does not provide.




- Through the openAPI, the logic would be provided by the plugin.

- In plain IDEA, we could use some "standard" actions like

- "add a bookmark, or TODO"
- "fold the matching code"
- "highlight the matching code"
- "highlight the block of lines around the matching code"
- "place a marker in the gutter"
- comment the matching code
- delete the matching code

, or even some active actions, like
- "$varName$ = $varName$.toUppercase()"

, or even some refactoring
- "move the method to .."


A basic use case:
- grayout the entire line when the lines ends with/contains "//timer"
-

etc..

0
Comment actions Permalink

Is there any plugin like this now? It would be great to have one :D

1

Please sign in to leave a comment.