KT-1389 Ctrl-Alt-B on class declaration does not work - create a special renderer for showing JetLightClass in implementations list
#KT-1389 In Progress
This commit is contained in:
@@ -175,6 +175,7 @@
|
|||||||
<iconProvider implementation="org.jetbrains.jet.plugin.JetIconProvider"/>
|
<iconProvider implementation="org.jetbrains.jet.plugin.JetIconProvider"/>
|
||||||
<itemPresentationProvider implementationClass="org.jetbrains.jet.plugin.presentation.JetFunctionPresenter" forClass="org.jetbrains.jet.lang.psi.JetNamedFunction"/>
|
<itemPresentationProvider implementationClass="org.jetbrains.jet.plugin.presentation.JetFunctionPresenter" forClass="org.jetbrains.jet.lang.psi.JetNamedFunction"/>
|
||||||
<itemPresentationProvider implementationClass="org.jetbrains.jet.plugin.presentation.JetClassPresenter" forClass="org.jetbrains.jet.lang.psi.JetClass"/>
|
<itemPresentationProvider implementationClass="org.jetbrains.jet.plugin.presentation.JetClassPresenter" forClass="org.jetbrains.jet.lang.psi.JetClass"/>
|
||||||
|
<gotoTargetRendererProvider id="JetGotoTargetRenderProvider" implementation="org.jetbrains.jet.plugin.JetGotoTargetRenderProvider" order="first"/>
|
||||||
<elementDescriptionProvider implementation="org.jetbrains.jet.plugin.findUsages.JetElementDescriptionProvider"/>
|
<elementDescriptionProvider implementation="org.jetbrains.jet.plugin.findUsages.JetElementDescriptionProvider"/>
|
||||||
<findUsagesHandlerFactory implementation="org.jetbrains.jet.plugin.findUsages.KotlinFindUsagesHandlerFactory"/>
|
<findUsagesHandlerFactory implementation="org.jetbrains.jet.plugin.findUsages.KotlinFindUsagesHandlerFactory"/>
|
||||||
<debugger.positionManagerFactory implementation="org.jetbrains.jet.plugin.debugger.JetPositionManagerFactory"/>
|
<debugger.positionManagerFactory implementation="org.jetbrains.jet.plugin.debugger.JetPositionManagerFactory"/>
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2012 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 org.jetbrains.jet.plugin;
|
||||||
|
|
||||||
|
import com.intellij.codeInsight.navigation.GotoTargetHandler;
|
||||||
|
import com.intellij.codeInsight.navigation.GotoTargetRendererProvider;
|
||||||
|
import com.intellij.ide.util.PsiElementListCellRenderer;
|
||||||
|
import com.intellij.psi.PsiElement;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jetbrains.jet.asJava.JetLightClass;
|
||||||
|
import org.jetbrains.jet.plugin.presentation.JetLightClassListCellRenderer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Nikolay Krasko
|
||||||
|
*/
|
||||||
|
public class JetGotoTargetRenderProvider implements GotoTargetRendererProvider {
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public PsiElementListCellRenderer getRenderer(PsiElement element, GotoTargetHandler.GotoData gotoData) {
|
||||||
|
if (element instanceof JetLightClass) {
|
||||||
|
// Need to override default Java render
|
||||||
|
return new JetLightClassListCellRenderer();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,6 +26,7 @@ import com.intellij.util.PlatformIcons;
|
|||||||
import com.intellij.util.containers.ContainerUtil;
|
import com.intellij.util.containers.ContainerUtil;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jetbrains.jet.asJava.JetLightClass;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
|
|
||||||
@@ -90,6 +91,11 @@ public class JetIconProvider extends IconProvider {
|
|||||||
JetProperty property = (JetProperty)psiElement;
|
JetProperty property = (JetProperty)psiElement;
|
||||||
return property.isVar() ? JetIcons.FIELD_VAR : JetIcons.FIELD_VAL;
|
return property.isVar() ? JetIcons.FIELD_VAR : JetIcons.FIELD_VAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (psiElement instanceof JetLightClass) {
|
||||||
|
return JetIcons.CLASS;
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,10 +49,10 @@ public class JetClassPresenter implements ItemPresentationProvider<JetClass> {
|
|||||||
public String getLocationString() {
|
public String getLocationString() {
|
||||||
FqName name = JetPsiUtil.getFQName(item);
|
FqName name = JetPsiUtil.getFQName(item);
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
return name.toString();
|
return "(" + name.parent().toString() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2012 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 org.jetbrains.jet.plugin.presentation;
|
||||||
|
|
||||||
|
import com.intellij.ide.util.PsiElementListCellRenderer;
|
||||||
|
import com.intellij.psi.presentation.java.ClassPresentationUtil;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jetbrains.jet.asJava.JetLightClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Nikolay Krasko
|
||||||
|
*/
|
||||||
|
public class JetLightClassListCellRenderer extends PsiElementListCellRenderer<JetLightClass> {
|
||||||
|
@Override
|
||||||
|
public String getElementText(JetLightClass element) {
|
||||||
|
return ClassPresentationUtil.getNameForClass(element, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getContainerText(JetLightClass element, final String name) {
|
||||||
|
return getContainerTextStatic(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static String getContainerTextStatic(final JetLightClass element) {
|
||||||
|
return "(" + element.getFqName().parent() + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getIconFlags() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user