mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 20:39:40 +07:00
IDEA-52806 JAVA: smarter parameter name completion for Builder-style-methods
This commit is contained in:
@@ -110,6 +110,9 @@ public class JavaMemberNameCompletionContributor extends CompletionContributor {
|
||||
if (variableKind == VariableKind.PARAMETER) {
|
||||
final PsiMethod method = PsiTreeUtil.getParentOfType(var, PsiMethod.class);
|
||||
propertyName = PropertyUtil.getPropertyName(method);
|
||||
if (method != null && method.getName().startsWith("with")) {
|
||||
propertyName = StringUtil.decapitalize(method.getName().substring(4));
|
||||
}
|
||||
}
|
||||
|
||||
final PsiType type = var.getType();
|
||||
|
||||
@@ -52,6 +52,7 @@ public class JavaCodeStyleManagerImpl extends JavaCodeStyleManager {
|
||||
@NonNls private static final String IS_PREFIX = "is";
|
||||
@NonNls private static final String FIND_PREFIX = "find";
|
||||
@NonNls private static final String CREATE_PREFIX = "create";
|
||||
@NonNls private static final String WITH_PREFIX = "with";
|
||||
@NonNls private static final String SET_PREFIX = "set";
|
||||
|
||||
private final Project myProject;
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
public class Builder {
|
||||
public Builder withSomething(String so<caret>) {}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
public class Builder {
|
||||
public Builder withSomething(String something<caret>) {}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,9 @@ public class VariablesCompletionTest extends CompletionTestCase {
|
||||
public void testUniqueNameInFor() throws Exception {
|
||||
doTest(getTestName(false) + ".java", getTestName(false) + "_after.java");
|
||||
}
|
||||
public void testWithBuilderParameter() throws Exception {
|
||||
doTest(getTestName(false) + ".java", getTestName(false) + "_after.java");
|
||||
}
|
||||
|
||||
private void doTest(String before, String after) throws Exception {
|
||||
configureByFile(FILE_PREFIX + "locals/" + before);
|
||||
|
||||
Reference in New Issue
Block a user