Use NamedStub and move stubbed getName implementation to base class
This commit is contained in:
@@ -243,16 +243,6 @@ public class JetClass extends JetTypeParameterListOwnerStub<PsiJetClassStub> imp
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
PsiJetClassStub stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.getName();
|
||||
}
|
||||
|
||||
return super.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemPresentation getPresentation() {
|
||||
return ItemPresentationProviders.getItemPresentation(this);
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.jet.lang.psi;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.stubs.IStubElementType;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.stubs.NamedStub;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.jet.lexer.JetTokens;
|
||||
/**
|
||||
* @author Nikolay Krasko
|
||||
*/
|
||||
abstract class JetNamedDeclarationStub<T extends StubElement> extends JetDeclarationStub<T> implements JetNamedDeclaration {
|
||||
abstract class JetNamedDeclarationStub<T extends NamedStub> extends JetDeclarationStub<T> implements JetNamedDeclaration {
|
||||
public JetNamedDeclarationStub(@NotNull T stub, @NotNull IStubElementType nodeType) {
|
||||
super(stub, nodeType);
|
||||
}
|
||||
@@ -41,6 +41,11 @@ abstract class JetNamedDeclarationStub<T extends StubElement> extends JetDeclara
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
T stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.getName();
|
||||
}
|
||||
|
||||
PsiElement identifier = getNameIdentifier();
|
||||
if (identifier != null) {
|
||||
String text = identifier.getText();
|
||||
|
||||
@@ -179,14 +179,4 @@ public class JetNamedFunction extends JetTypeParameterListOwnerStub<PsiJetFuncti
|
||||
PsiElement parent = getParent();
|
||||
return !(parent instanceof JetFile || parent instanceof JetClassBody || parent instanceof JetNamespaceBody);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
PsiJetFunctionStub stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.getName();
|
||||
}
|
||||
|
||||
return super.getName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.jet.lang.psi.stubs;
|
||||
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.stubs.NamedStub;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -27,14 +27,13 @@ import java.util.List;
|
||||
/**
|
||||
* @author Nikolay Krasko
|
||||
*/
|
||||
public interface PsiJetClassStub extends StubElement<JetClass> {
|
||||
public interface PsiJetClassStub extends NamedStub<JetClass> {
|
||||
|
||||
|
||||
@NonNls
|
||||
@Nullable
|
||||
String getQualifiedName();
|
||||
|
||||
@Nullable
|
||||
String getName();
|
||||
|
||||
@NotNull
|
||||
List<String> getSuperNames();
|
||||
|
||||
|
||||
@@ -16,18 +16,14 @@
|
||||
|
||||
package org.jetbrains.jet.lang.psi.stubs;
|
||||
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.stubs.NamedStub;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
||||
|
||||
/**
|
||||
* @author Nikolay Krasko
|
||||
*/
|
||||
public interface PsiJetFunctionStub extends StubElement<JetNamedFunction> {
|
||||
@Nullable
|
||||
String getName();
|
||||
|
||||
public interface PsiJetFunctionStub extends NamedStub<JetNamedFunction> {
|
||||
/**
|
||||
* Is function defined in directly in package.
|
||||
* @return
|
||||
|
||||
Reference in New Issue
Block a user