don't preselect better-matching deprecated classes (IDEA-124382)

This commit is contained in:
peter
2017-09-18 18:44:39 +02:00
parent 583b83e553
commit d8a63070d0
5 changed files with 46 additions and 1 deletions
@@ -0,0 +1,30 @@
/*
* Copyright 2000-2017 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.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.impl.JavaElementLookupRenderer;
/**
* @author peter
*/
public class DeprecatedSkipper extends CompletionPreselectSkipper {
@Override
public boolean skipElement(LookupElement element, CompletionLocation location) {
return JavaElementLookupRenderer.isDeprecated(element.getPsiElement());
}
}
@@ -68,7 +68,7 @@ public class JavaElementLookupRenderer implements ElementLookupRenderer {
return isDeprecated(item.getPsiElement());
}
private static boolean isDeprecated(@Nullable PsiElement element) {
public static boolean isDeprecated(@Nullable PsiElement element) {
return element instanceof PsiDocCommentOwner && ((PsiDocCommentOwner)element).isDeprecated();
}
}
@@ -0,0 +1,10 @@
class Foo {
{
XLon<caret>
}
}
@Deprecated
class XLong {}
class XLonger {}
@@ -787,4 +787,8 @@ class ContainerUtil extends ContainerUtilRt {
checkPreferredItems 0, 'text'
}
void testDoNotPreselectShorterDeprecatedClasses() {
checkPreferredItems 1, 'XLong', 'XLonger'
}
}
+1
View File
@@ -1460,6 +1460,7 @@
<statistician key="completion" implementationClass="com.intellij.codeInsight.completion.JavaCompletionStatistician"/>
<completion.skip implementation="com.intellij.codeInsight.completion.AbstractExpectedTypeSkipper" id="skipAbstract"/>
<completion.skip implementation="com.intellij.codeInsight.completion.DeprecatedSkipper" id="skipDeprecated"/>
<extendWordSelectionHandler implementation="com.intellij.codeInsight.editorActions.wordSelection.LiteralSelectioner"/>