Files
openide/java/java-tests/testData/codeInsight/highlight/remove_new/beforeCallStaticMethodInNestedClass.java
Nikita Eshkeev 41a3187b04 [java-highlight] IDEA-253796 Trying to call static method on a new-expression should offer a quickfix to remove new
When a user call a static member of a class (field or method) they might not realize that there is still the `new` keyword present in the beginning of the expression. It's might be annoying, since the user need to go back to the beginning and remove the keyword manually and then go back where they were.

This patch adds a quick-fix that removes `new` if the new expression can be treated as a valid call expression to either a method or a field of a class.

GitOrigin-RevId: eac92b3904049546d7ca3a3b93f73386a5381b2c
2021-04-01 23:46:38 +00:00

21 lines
301 B
Java

// "Remove 'new'" "true"
class A {
class Nested {
public static A factory() { return new A(); }
}
}
class B {
{
new /*
* hello
* world
*/ A.// nested
Nested./* method */
<caret>factory// parameters
/* below */
(/* parameters are empty */);
}
}