Rework go to symbol/class and getNavigationElement() for kotlin declarations

Based on work by geevee
This commit is contained in:
Pavel V. Talanov
2014-12-02 18:54:46 +03:00
parent 5676b0bf7c
commit 33fc241158
12 changed files with 89 additions and 46 deletions
@@ -17,6 +17,7 @@
package org.jetbrains.jet.lang.psi;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.stubs.IStubElementType;
import com.intellij.psi.stubs.StubElement;
@@ -50,4 +51,17 @@ abstract class JetDeclarationStub<T extends StubElement> extends JetModifierList
}
return super.getParent();
}
@NotNull
@Override
public PsiElement getNavigationElement() {
KotlinDeclarationNavigationPolicy navigationPolicy = ServiceManager.getService(KotlinDeclarationNavigationPolicy.class);
if (navigationPolicy != null) {
JetElement navigationElement = navigationPolicy.getNavigationElement(this);
if (navigationElement != null) {
return navigationElement;
}
}
return this;
}
}
@@ -0,0 +1,21 @@
/*
* Copyright 2010-2014 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.lang.psi
public trait KotlinDeclarationNavigationPolicy {
public fun getNavigationElement(declaration: JetDeclaration): JetElement?
}