From 2a9c1249573d5575a2d2010763ab986adf28f866 Mon Sep 17 00:00:00 2001 From: Evgeny Gerashchenko Date: Tue, 6 Mar 2012 23:28:07 +0400 Subject: [PATCH] Added implementation of ClsCustomNavigationPolicy for Kotlin libraries. --- idea/src/META-INF/plugin.xml | 1 + .../jet/plugin/JetClsNavigationPolicy.java | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 idea/src/org/jetbrains/jet/plugin/JetClsNavigationPolicy.java diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index a7a0110cd57..f209bfe7684 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -154,6 +154,7 @@ + diff --git a/idea/src/org/jetbrains/jet/plugin/JetClsNavigationPolicy.java b/idea/src/org/jetbrains/jet/plugin/JetClsNavigationPolicy.java new file mode 100644 index 00000000000..4499dce73cf --- /dev/null +++ b/idea/src/org/jetbrains/jet/plugin/JetClsNavigationPolicy.java @@ -0,0 +1,48 @@ +/* + * Copyright 2000-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.psi.PsiElement; +import com.intellij.psi.impl.compiled.*; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.psi.JetDeclaration; + +/** + * @author Evgeny Gerashchenko + * @since 3/2/12 + */ +public class JetClsNavigationPolicy implements ClsCustomNavigationPolicy { + @Override + public PsiElement getNavigationElement(@NotNull ClsClassImpl clsClass) { + return getJetDeclarationByClsElement(clsClass); + } + + @Override + public PsiElement getNavigationElement(@NotNull ClsMethodImpl clsMethod) { + return getJetDeclarationByClsElement(clsMethod); + } + + @Override + public PsiElement getNavigationElement(@NotNull ClsFieldImpl clsField) { + return getJetDeclarationByClsElement(clsField); + } + + private static JetDeclaration getJetDeclarationByClsElement(ClsElementImpl clsElement) { + JetDecompiledData decompiledData = JetDecompiledData.getDecompiledData((ClsFileImpl) clsElement.getContainingFile()); + return decompiledData.getJetDeclarationByClsElement(clsElement); + } +}