Merge commit 'origin/master'

This commit is contained in:
Maxim.Mossienko
2011-03-30 18:34:26 +04:00
3 changed files with 71 additions and 14 deletions
@@ -16,6 +16,8 @@
package com.intellij.ide.navigationToolbar;
import com.intellij.ProjectTopics;
import com.intellij.ide.actions.CopyAction;
import com.intellij.ide.actions.CutAction;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ex.AnActionListener;
import com.intellij.openapi.project.Project;
@@ -238,15 +240,21 @@ public class NavBarListener extends WolfTheProblemSolver.ProblemListener
}
@Override
public void afterActionPerformed(AnAction action, DataContext dataContext, AnActionEvent event) {
if (!(action instanceof PopupAction)) {
if (myPanel.isInFloatingMode()) {
myPanel.hideHint();
} else {
myPanel.cancelPopup();
}
if (shouldSkipAction(action)) return;
if (myPanel.isInFloatingMode()) {
myPanel.hideHint();
} else {
myPanel.cancelPopup();
}
}
private static boolean shouldSkipAction(AnAction action) {
return action instanceof PopupAction
|| action instanceof CopyAction
|| action instanceof CutAction;
}
//---- Ignored
@Override
public void beforeActionPerformed(AnAction action, DataContext dataContext, AnActionEvent event) {}
@@ -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)
}
}