intelli-pattern
what do you think about the following feature proposal, I think it could be possible and would be useful:
->
I want to be able to define a pattern (similar or equal to a struct search pattern) like this:
$returnType$ get_$fieldName$()
{
return ($returnType$) properties[PROPERTY_$fieldName$].getValue();
}
and then define a requirement/constraint that both occurences of fieldName have to be equal.
Then I would like this to work like an inspection, that means the editor will highlight erronous places,
where the method is defined get_myFieldA but the implementation uses PROPERTY_myFieldB
AND by alt-Enter I'm asked if I want to make the method name into myFieldB so that both match,
or the use the PROPERTY_myFieldA instead.
In other words, a way to really easy and quickly formalize a coding pattern/convention into a specification
that enables IDEA to assist in conveniently enforcing it.
It would be nice if we could also enforce that a setter for same field does also exist...
Maybe already possible, if so, please let me know how - thanks!
----
Another idea: if you could provide some convenient way to access IDEAs parsed source code and manipulate it.
That means that I could just write a few lines of java code like this: (I write pseudo code to speed me up)
StructSearch ss = StructSearch.getInstance();
List allClasses = ss.getAllClasses();
for (allClasses)
{
List allMethods = oneClass.getAllMethods();
for (allMethods)
{
String name=oneMethod.getName();
if (name.startsWith("get_"))
{
String fieldName=name.substring(4); //or 5? ;-)
List allStatementsOfThisMethod = oneMethod.getAllStatements();
//and so on, you get the idea
//just a java code access to the struct search/replace that is easily accessible,
//that means I don't have to write a plugin for it
//at some point here: -> modify the sourceCode
}
}
}
M.
Please sign in to leave a comment.