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