mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't autopopup with word suggestions in groovy/java literals
This commit is contained in:
@@ -717,4 +717,11 @@ class Foo {
|
||||
|
||||
}
|
||||
|
||||
public void testNoWordCompletionAutoPopup() {
|
||||
myFixture.configureByText "a.java", 'class Bar { void foo() { "f<caret>" }}'
|
||||
type 'o'
|
||||
assert !lookup
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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 com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.lang.LanguageParserDefinitions;
|
||||
import com.intellij.lang.ParserDefinition;
|
||||
import com.intellij.patterns.ElementPattern;
|
||||
import com.intellij.patterns.PlatformPatterns;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.util.ThreeState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class SkipAutopopupInStrings extends CompletionConfidence {
|
||||
@NotNull
|
||||
@Override
|
||||
public ThreeState shouldFocusLookup(@NotNull CompletionParameters parameters) {
|
||||
return ThreeState.UNSURE;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ThreeState shouldSkipAutopopup(@Nullable PsiElement contextElement, @NotNull PsiFile psiFile, int offset) {
|
||||
if (contextElement != null) {
|
||||
ParserDefinition definition = LanguageParserDefinitions.INSTANCE.forLanguage(PsiUtilBase.getLanguageAtOffset(psiFile, offset));
|
||||
if (definition != null) {
|
||||
ElementPattern<PsiElement> pattern = PlatformPatterns.psiElement().withElementType(definition.getStringLiteralElements());
|
||||
if (pattern.accepts(contextElement) || pattern.accepts(contextElement.getParent())) {
|
||||
return ThreeState.YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ThreeState.UNSURE;
|
||||
}
|
||||
}
|
||||
-8
@@ -16,8 +16,6 @@
|
||||
|
||||
package com.intellij.psi.impl.source.resolve.reference.impl.providers;
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionProcess;
|
||||
import com.intellij.codeInsight.completion.CompletionService;
|
||||
import com.intellij.codeInsight.daemon.EmptyResolveMessageProvider;
|
||||
import com.intellij.codeInsight.daemon.QuickFixProvider;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
@@ -238,12 +236,6 @@ public class FileReference implements FileReferenceOwner, PsiPolyVariantReferenc
|
||||
|
||||
@NotNull
|
||||
public Object[] getVariants() {
|
||||
final CompletionProcess process = CompletionService.getCompletionService().getCurrentCompletion();
|
||||
if (process != null && process.isAutopopupCompletion() && isSoft()) {
|
||||
return ArrayUtil.EMPTY_OBJECT_ARRAY;
|
||||
}
|
||||
|
||||
|
||||
final String s = getText();
|
||||
if (s != null && s.equals("/")) {
|
||||
return ArrayUtil.EMPTY_OBJECT_ARRAY;
|
||||
|
||||
+9
@@ -14,10 +14,13 @@ package org.jetbrains.plugins.groovy.lang.completion;
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionConfidence;
|
||||
import com.intellij.codeInsight.completion.CompletionParameters;
|
||||
import com.intellij.codeInsight.completion.SkipAutopopupInStrings;
|
||||
import com.intellij.patterns.PsiJavaPatterns;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.ThreeState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.gpp.GppTypeConverter;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
@@ -61,4 +64,10 @@ public class GroovyCompletionConfidence extends CompletionConfidence {
|
||||
}
|
||||
return ThreeState.UNSURE;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ThreeState shouldSkipAutopopup(@Nullable PsiElement contextElement, @NotNull PsiFile psiFile, int offset) {
|
||||
return new SkipAutopopupInStrings().shouldSkipAutopopup(contextElement, psiFile, offset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,4 +95,10 @@ class GroovyAutoPopupTest extends CompletionAutoPopupTestCase {
|
||||
assert myFixture.lookupElementStrings == [ArrayIndexOutOfBoundsException.simpleName]
|
||||
}
|
||||
|
||||
public void testNoWordCompletionAutoPopup() {
|
||||
myFixture.configureByText "a.groovy", 'def foo = "f<caret>"'
|
||||
type 'o'
|
||||
assert !lookup
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-5
@@ -182,11 +182,6 @@ public abstract class PropertyReferenceBase implements PsiPolyVariantReference,
|
||||
|
||||
@NotNull
|
||||
public Object[] getVariants() {
|
||||
final CompletionProcess process = CompletionService.getCompletionService().getCurrentCompletion();
|
||||
if (process != null && process.isAutopopupCompletion() && isSoft()) {
|
||||
return ArrayUtil.EMPTY_OBJECT_ARRAY;
|
||||
}
|
||||
|
||||
final Set<Object> variants = new THashSet<Object>(new TObjectHashingStrategy<Object>() {
|
||||
public int computeHashCode(final Object object) {
|
||||
if (object instanceof Property) {
|
||||
|
||||
@@ -240,6 +240,7 @@
|
||||
<completion.confidence language="JAVA" implementationClass="com.intellij.codeInsight.completion.FocusInJavadoc" id="javadoc" order="before javaComments"/>
|
||||
<completion.confidence language="JAVA" implementationClass="com.intellij.codeInsight.completion.UnfocusedComments" id="javaComments"/>
|
||||
<completion.confidence language="JAVA" implementationClass="com.intellij.codeInsight.completion.AlwaysFocusLookup" id="javaTrue" order="last"/>
|
||||
<completion.confidence language="JAVA" implementationClass="com.intellij.codeInsight.completion.SkipAutopopupInStrings" id="javaSkipAutopopupInStrings"/>
|
||||
|
||||
<completion.contributor language="any" implementationClass="com.intellij.codeInsight.completion.BasicToClassNameDelegator" id="basic2ClassName"
|
||||
order="first, before javaMemberName, after xml"/>
|
||||
|
||||
Reference in New Issue
Block a user