mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
show location package in chained call items (IDEA-58766)
This commit is contained in:
@@ -19,11 +19,13 @@ import com.intellij.codeInsight.lookup.*;
|
||||
import com.intellij.featureStatistics.FeatureUsageTracker;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.util.ClassConditionKey;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -65,11 +67,16 @@ public class JavaChainLookupElement extends LookupElementDecorator<LookupElement
|
||||
}
|
||||
|
||||
private String maybeAddParentheses(String s) {
|
||||
return getQualifierObject() instanceof PsiMethod ? s + "()" : s;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Object getQualifierObject() {
|
||||
Object qObject = myQualifier.getObject();
|
||||
if (qObject instanceof ResolveResult) {
|
||||
qObject = ((ResolveResult)qObject).getElement();
|
||||
}
|
||||
return qObject instanceof PsiMethod ? s + "()" : s;
|
||||
return qObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,6 +87,10 @@ public class JavaChainLookupElement extends LookupElementDecorator<LookupElement
|
||||
String name = maybeAddParentheses(qualifierPresentation.getItemText());
|
||||
final String qualifierText = myQualifier.as(CastingLookupElementDecorator.CLASS_CONDITION_KEY) != null ? "(" + name + ")" : name;
|
||||
presentation.setItemText(qualifierText + "." + presentation.getItemText());
|
||||
|
||||
if (getQualifierObject() instanceof PsiClass) {
|
||||
presentation.setTailText(StringUtil.notNullize(presentation.getTailText()) + qualifierPresentation.getTailText());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -167,4 +167,10 @@ public class LookupElementPresentation {
|
||||
public void setTypeGrayed(boolean typeGrayed) {
|
||||
myTypeGrayed = typeGrayed;
|
||||
}
|
||||
|
||||
public static LookupElementPresentation renderElement(LookupElement element) {
|
||||
LookupElementPresentation presentation = new LookupElementPresentation();
|
||||
element.renderElement(presentation);
|
||||
return presentation;
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -1114,6 +1114,12 @@ public class KeyVO {
|
||||
myFixture.configureByText 'a.groovy', 'Util.<caret>'
|
||||
myFixture.completeBasic()
|
||||
assert myFixture.lookupElementStrings[0..1] == ['Util.bar', 'Util.foo']
|
||||
|
||||
def presentation = LookupElementPresentation.renderElement(myFixture.lookupElements[0])
|
||||
assert 'Util.bar' == presentation.itemText
|
||||
assert '() (bar)' == presentation.tailText
|
||||
assert !presentation.tailGrayed
|
||||
|
||||
myFixture.type 'f\n'
|
||||
myFixture.checkResult '''import foo.Util
|
||||
|
||||
|
||||
Reference in New Issue
Block a user