mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't preselect better-matching deprecated classes (IDEA-124382)
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class Foo {
|
||||
{
|
||||
XLon<caret>
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
class XLong {}
|
||||
|
||||
class XLonger {}
|
||||
+4
@@ -787,4 +787,8 @@ class ContainerUtil extends ContainerUtilRt {
|
||||
checkPreferredItems 0, 'text'
|
||||
}
|
||||
|
||||
void testDoNotPreselectShorterDeprecatedClasses() {
|
||||
checkPreferredItems 1, 'XLong', 'XLonger'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
Reference in New Issue
Block a user