IDEA-91842 Type parameters are shown for field but not for method

This commit is contained in:
peter
2012-09-24 10:54:28 +04:00
parent a51936baa6
commit f0b351d75a
4 changed files with 26 additions and 5 deletions

View File

@@ -64,7 +64,7 @@ public class VariableLookupItem extends LookupItem<PsiVariable> implements Typed
public void renderElement(LookupElementPresentation presentation) {
super.renderElement(presentation);
if (myHelper != null) {
myHelper.renderElement(presentation, getAttribute(FORCE_QUALIFY) != null ? Boolean.TRUE : null, PsiSubstitutor.EMPTY);
myHelper.renderElement(presentation, getAttribute(FORCE_QUALIFY) != null ? Boolean.TRUE : null, getSubstitutor());
}
}

View File

@@ -19,6 +19,7 @@ import com.intellij.codeInsight.completion.JavaCompletionUtil;
import com.intellij.codeInsight.lookup.DefaultLookupItemRenderer;
import com.intellij.codeInsight.lookup.LookupElementPresentation;
import com.intellij.codeInsight.lookup.LookupItem;
import com.intellij.codeInsight.lookup.VariableLookupItem;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.impl.beanProperties.BeanPropertyElement;
@@ -90,7 +91,11 @@ public class JavaElementLookupRenderer implements ElementLookupRenderer {
if (element.isValid()) {
if (element instanceof PsiVariable){
PsiVariable variable = (PsiVariable)element;
text = variable.getType().getPresentableText();
PsiType type = variable.getType();
if (item instanceof VariableLookupItem) {
type = ((VariableLookupItem)item).getSubstitutor().substitute(type);
}
text = type.getPresentableText();
}
else if (element instanceof PsiExpression){
PsiExpression expression = (PsiExpression)element;

View File

@@ -0,0 +1,10 @@
class Ref<T> {
T target;
}
class TestPoint2D {
void (Ref<String> r) {
r.<caret>
}
}

View File

@@ -97,9 +97,15 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
}
private LookupElementPresentation renderElement(LookupElement element) {
def presentation = new LookupElementPresentation()
element.renderElement(presentation)
return presentation
return LookupElementPresentation.renderElement(element)
}
public void testFieldItemPresentationGenerics() {
configure()
LookupElementPresentation presentation = renderElement(myItems[0])
assert "target" == presentation.itemText
assert !presentation.tailText
assert "String" == presentation.typeText
}
public void testMethodItemPresentationGenerics() {