mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
unify finishing lookup behavior for templates & completion (IDEA-195114)
This commit is contained in:
+23
@@ -2,6 +2,7 @@
|
||||
package com.intellij.java.codeInsight.template
|
||||
|
||||
import com.intellij.JavaTestUtil
|
||||
import com.intellij.codeInsight.CodeInsightSettings
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.EmptyExpression
|
||||
import com.intellij.codeInsight.lookup.Lookup
|
||||
import com.intellij.codeInsight.template.Template
|
||||
@@ -482,6 +483,28 @@ java.util.List<? extends Integer> list;
|
||||
|
||||
}
|
||||
}}'''
|
||||
}
|
||||
|
||||
void "test overtyping suggestion with a quote"() {
|
||||
CodeInsightSettings.instance.SELECT_AUTOPOPUP_SUGGESTIONS_BY_CHARS = true
|
||||
|
||||
myFixture.configureByText 'a.java', '''
|
||||
class A {
|
||||
{
|
||||
String s;
|
||||
<caret>s.toString();
|
||||
}
|
||||
}'''
|
||||
myFixture.doHighlighting()
|
||||
myFixture.launchAction(myFixture.findSingleIntention('Initialize variable'))
|
||||
myFixture.type('"')
|
||||
myFixture.checkResult '''
|
||||
class A {
|
||||
{
|
||||
String s = "";
|
||||
s.toString();
|
||||
}
|
||||
}'''
|
||||
assert !myFixture.lookup
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -19,12 +19,10 @@ package com.intellij.codeInsight.completion;
|
||||
import com.intellij.codeInsight.lookup.CharFilter;
|
||||
import com.intellij.codeInsight.lookup.Lookup;
|
||||
|
||||
public class CompletionCharFilter extends CharFilter {
|
||||
public class DefaultCharFilter extends CharFilter {
|
||||
|
||||
@Override
|
||||
public Result acceptChar(char c, final int prefixLength, final Lookup lookup) {
|
||||
if (!lookup.isCompletion()) return null;
|
||||
|
||||
if (Character.isJavaIdentifierPart(c)) return Result.ADD_TO_PREFIX;
|
||||
switch(c){
|
||||
case '.':
|
||||
@@ -46,8 +46,6 @@ import com.intellij.psi.util.PsiUtilBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class LookupTypedHandler extends TypedActionHandlerBase {
|
||||
|
||||
public LookupTypedHandler(@Nullable TypedActionHandler originalHandler) {
|
||||
@@ -182,9 +180,7 @@ public class LookupTypedHandler extends TypedActionHandlerBase {
|
||||
if (filtersDecision != null) {
|
||||
return filtersDecision;
|
||||
}
|
||||
throw new AssertionError("Typed char not handler by char filter: c=" + charTyped +
|
||||
"; prefix=" + lookup.getCurrentItem() +
|
||||
"; filters=" + Arrays.toString(getFilters()));
|
||||
return CharFilter.Result.HIDE_LOOKUP;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.refactoring;
|
||||
|
||||
import com.intellij.codeInsight.lookup.CharFilter;
|
||||
import com.intellij.codeInsight.lookup.Lookup;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class IdentifierCharFilter extends CharFilter {
|
||||
|
||||
@Override
|
||||
public Result acceptChar(char c, final int prefixLength, final Lookup lookup) {
|
||||
if (lookup.isCompletion()) return null;
|
||||
|
||||
if (Character.isJavaIdentifierPart(c)) return Result.ADD_TO_PREFIX;
|
||||
return Result.SELECT_ITEM_AND_FINISH_LOOKUP;
|
||||
}
|
||||
}
|
||||
@@ -613,8 +613,7 @@
|
||||
<console.folding implementation="com.intellij.execution.console.SubstringConsoleFolding"/>
|
||||
|
||||
<lookup.charFilter implementation="com.intellij.codeInsight.template.impl.LiveTemplateCharFilter" order="first" id="liveTemplate"/>
|
||||
<lookup.charFilter implementation="com.intellij.codeInsight.completion.CompletionCharFilter" order="last" id="completion"/>
|
||||
<lookup.charFilter implementation="com.intellij.refactoring.IdentifierCharFilter" id="identifier" order="last"/>
|
||||
<lookup.charFilter implementation="com.intellij.codeInsight.completion.DefaultCharFilter" order="last" id="default"/>
|
||||
<lookup.charFilter implementation="com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceCharFilter" id="fileRef"
|
||||
order="before completion"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user