mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-66978 (Intuitive code completion when calling constructors with named parameters)
This commit is contained in:
+12
-8
@@ -88,10 +88,14 @@ class MapArgumentCompletionProvider extends CompletionProvider<CompletionParamet
|
||||
)
|
||||
));
|
||||
|
||||
contributor.extend(CompletionType.BASIC, inArgumentListOfCall, instance);
|
||||
ElementPattern<PsiElement> inLabel = psiElement(GroovyTokenTypes.mIDENT).withParent(psiElement(GrArgumentLabel.class).withParent(
|
||||
GroovyPatterns.methodNamedParameter(null)));
|
||||
|
||||
contributor.extend(CompletionType.BASIC, psiElement(GroovyTokenTypes.mIDENT).withParent(psiElement(GrArgumentLabel.class).withParent(
|
||||
GroovyPatterns.methodNamedParameter(null))), instance);
|
||||
contributor.extend(CompletionType.BASIC, inArgumentListOfCall, instance);
|
||||
contributor.extend(CompletionType.BASIC, inLabel, instance);
|
||||
|
||||
contributor.extend(CompletionType.SMART, inArgumentListOfCall, instance);
|
||||
contributor.extend(CompletionType.SMART, inLabel, instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -188,11 +192,11 @@ class MapArgumentCompletionProvider extends CompletionProvider<CompletionParamet
|
||||
}
|
||||
|
||||
for (String name : writableProperties.keySet()) {
|
||||
if (usedNames.contains(name)) continue;
|
||||
usedNames.add(name);
|
||||
final LookupElementBuilder builder =
|
||||
LookupElementBuilder.create(writableProperties.get(name), name).setIcon(GroovyIcons.PROPERTY)
|
||||
.setInsertHandler(NamedArgumentInsertHandler.INSTANCE);
|
||||
if ("metaClass".equals(name) || !usedNames.add(name)) continue;
|
||||
|
||||
final LookupElementBuilder builder = LookupElementBuilder.create(writableProperties.get(name), name)
|
||||
.setIcon(GroovyIcons.PROPERTY)
|
||||
.setInsertHandler(NamedArgumentInsertHandler.INSTANCE);
|
||||
result.addElement(builder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.lang
|
||||
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
import com.intellij.codeInsight.completion.CompletionType
|
||||
|
||||
/**
|
||||
* @author Sergey Evdokimov
|
||||
*/
|
||||
class GroovyMapAttributeTest extends LightCodeInsightFixtureTestCase {
|
||||
|
||||
public void testSmartCompletionCompletion() {
|
||||
def file = myFixture.addFileToProject("a.groovy", """
|
||||
class Aaa {
|
||||
String sss1
|
||||
String sss2
|
||||
|
||||
|
||||
static {
|
||||
new Aaa(<caret>)
|
||||
}
|
||||
}
|
||||
""")
|
||||
myFixture.configureFromExistingVirtualFile file.virtualFile
|
||||
|
||||
def res = myFixture.complete(CompletionType.SMART)
|
||||
assertNotNull(res)
|
||||
assertSize(2, res)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user