Presentation: Support constructors in JetFunctionPresenter
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
package org.jetbrains.kotlin.psi;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.navigation.ItemPresentationProviders;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.stubs.IStubElementType;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
@@ -171,6 +173,11 @@ public abstract class JetConstructor<T extends JetConstructor<T>> extends JetDec
|
||||
throw new IncorrectOperationException("setName to constructor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemPresentation getPresentation() {
|
||||
return ItemPresentationProviders.getItemPresentation(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiElement getConstructorKeyword() {
|
||||
return findChildByType(JetTokens.CONSTRUCTOR_KEYWORD);
|
||||
|
||||
@@ -393,7 +393,7 @@
|
||||
implementationClass="org.jetbrains.kotlin.idea.ktSignature.KotlinSignatureInJavaMarkerProvider"/>
|
||||
<iconProvider implementation="org.jetbrains.kotlin.idea.JetIconProvider"/>
|
||||
<itemPresentationProvider implementationClass="org.jetbrains.kotlin.idea.presentation.JetFunctionPresenter"
|
||||
forClass="org.jetbrains.kotlin.psi.JetNamedFunction"/>
|
||||
forClass="org.jetbrains.kotlin.psi.JetFunction"/>
|
||||
<itemPresentationProvider implementationClass="org.jetbrains.kotlin.idea.presentation.JetClassPresenter"
|
||||
forClass="org.jetbrains.kotlin.psi.JetClass"/>
|
||||
<itemPresentationProvider implementationClass="org.jetbrains.kotlin.idea.presentation.JetObjectPresenter"
|
||||
|
||||
@@ -23,15 +23,15 @@ import com.intellij.navigation.ItemPresentationProvider;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.psi.JetNamedFunction;
|
||||
import org.jetbrains.kotlin.psi.JetParameter;
|
||||
import org.jetbrains.kotlin.psi.JetTypeReference;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class JetFunctionPresenter implements ItemPresentationProvider<JetNamedFunction> {
|
||||
public class JetFunctionPresenter implements ItemPresentationProvider<JetFunction> {
|
||||
@Override
|
||||
public ItemPresentation getPresentation(@NotNull final JetNamedFunction function) {
|
||||
public ItemPresentation getPresentation(@NotNull final JetFunction function) {
|
||||
if (function instanceof JetFunctionLiteral) return null;
|
||||
|
||||
return new JetDefaultNamedDeclarationPresentation(function) {
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
@@ -60,6 +60,11 @@ public class JetFunctionPresenter implements ItemPresentationProvider<JetNamedFu
|
||||
|
||||
@Override
|
||||
public String getLocationString() {
|
||||
if (function instanceof JetConstructor) {
|
||||
FqName name = ((JetConstructor) function).getClassOrObject().getFqName();
|
||||
return name != null ? String.format("(in %s)", name) : "";
|
||||
}
|
||||
|
||||
FqName name = function.getFqName();
|
||||
if (name != null) {
|
||||
JetTypeReference receiverTypeRef = function.getReceiverTypeReference();
|
||||
|
||||
Reference in New Issue
Block a user