From 105949de53dded71d81915c3e274d9b1ccc6962e Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Wed, 7 Aug 2013 21:27:48 +0400 Subject: [PATCH] Refactor: fix stubs and psi having redundant constructor parameters --- .../org/jetbrains/jet/lang/psi/JetClassBody.java | 6 +++--- .../org/jetbrains/jet/lang/psi/JetParameter.java | 6 +++--- .../jetbrains/jet/lang/psi/JetParameterList.java | 5 ++--- .../org/jetbrains/jet/lang/psi/JetProperty.java | 6 +++--- .../jetbrains/jet/lang/psi/JetTypeParameter.java | 6 +++--- .../jet/lang/psi/JetTypeParameterList.java | 5 ++--- .../stubs/elements/JetAnnotationElementType.java | 7 ++++--- .../stubs/elements/JetClassBodyElementType.java | 6 +++--- .../stubs/elements/JetFunctionElementType.java | 4 ++-- .../psi/stubs/elements/JetObjectElementType.java | 5 +---- .../stubs/elements/JetParameterElementType.java | 6 +++--- .../elements/JetParameterListElementType.java | 6 +++--- .../stubs/elements/JetPropertyElementType.java | 6 +++--- .../elements/JetTypeParameterElementType.java | 6 +++--- .../JetTypeParameterListElementType.java | 8 ++++---- .../psi/stubs/impl/PsiJetAnnotationStubImpl.java | 10 +++++----- .../psi/stubs/impl/PsiJetClassBodyStubImpl.java | 6 +++--- .../psi/stubs/impl/PsiJetFunctionStubImpl.java | 14 +++++++------- .../psi/stubs/impl/PsiJetObjectStubImpl.java | 16 +++++++--------- .../stubs/impl/PsiJetParameterListStubImpl.java | 6 +++--- .../psi/stubs/impl/PsiJetParameterStubImpl.java | 10 +++++----- .../psi/stubs/impl/PsiJetPropertyStubImpl.java | 14 ++++++++------ .../impl/PsiJetTypeParameterListStubImpl.java | 7 +++---- .../stubs/impl/PsiJetTypeParameterStubImpl.java | 16 +++++++++------- 24 files changed, 92 insertions(+), 95 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetClassBody.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetClassBody.java index 8070a7ac62f..70c287f8330 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetClassBody.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetClassBody.java @@ -18,7 +18,6 @@ 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.tree.TokenSet; import com.intellij.psi.util.PsiTreeUtil; @@ -26,6 +25,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.JetNodeTypes; import org.jetbrains.jet.lang.psi.stubs.PsiJetClassBodyStub; +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; import org.jetbrains.jet.lexer.JetTokens; import java.util.List; @@ -35,8 +35,8 @@ public class JetClassBody extends JetElementImplStub implem super(node); } - public JetClassBody(@NotNull PsiJetClassBodyStub stub, @NotNull IStubElementType nodeType) { - super(stub, nodeType); + public JetClassBody(@NotNull PsiJetClassBodyStub stub) { + super(stub, JetStubElementTypes.CLASS_BODY); } @Override diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetParameter.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetParameter.java index 19bcc07bbdc..6ea0b7bd84c 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetParameter.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetParameter.java @@ -19,12 +19,12 @@ package org.jetbrains.jet.lang.psi; import com.intellij.lang.ASTNode; import com.intellij.navigation.ItemPresentation; import com.intellij.navigation.ItemPresentationProviders; -import com.intellij.psi.stubs.IStubElementType; import com.intellij.util.ArrayFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.JetNodeTypes; import org.jetbrains.jet.lang.psi.stubs.PsiJetParameterStub; +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; import org.jetbrains.jet.lexer.JetTokens; public class JetParameter extends JetNamedDeclarationStub { @@ -41,8 +41,8 @@ public class JetParameter extends JetNamedDeclarationStub { super(node); } - public JetParameter(@NotNull PsiJetParameterStub stub, @NotNull IStubElementType nodeType) { - super(stub, nodeType); + public JetParameter(@NotNull PsiJetParameterStub stub) { + super(stub, JetStubElementTypes.VALUE_PARAMETER); } @Override diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetParameterList.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetParameterList.java index 774f1586c32..b7ae2299a74 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetParameterList.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetParameterList.java @@ -17,7 +17,6 @@ package org.jetbrains.jet.lang.psi; import com.intellij.lang.ASTNode; -import com.intellij.psi.stubs.IStubElementType; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.psi.stubs.PsiJetParameterListStub; import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; @@ -30,8 +29,8 @@ public class JetParameterList extends JetElementImplStub superNames = PsiUtilPackage.getSuperNames(psi); return new PsiJetObjectStubImpl( - JetStubElementTypes.OBJECT_DECLARATION, parentStub, name, fqName, @@ -107,9 +106,7 @@ public class JetObjectElementType extends JetStubElementType"); - return new PsiJetPropertyStubImpl(JetStubElementTypes.PROPERTY, parentStub, + return new PsiJetPropertyStubImpl(parentStub, psi.getName(), psi.isVar(), psi.isTopLevel(), psi.getFqName(), typeRef != null ? typeRef.getText() : null, expression != null ? expression.getText() : null); @@ -103,7 +103,7 @@ public class JetPropertyElementType extends JetStubElementType implements PsiJetAnnotationStub { private final StringRef shortName; - public PsiJetAnnotationStubImpl(StubElement parent, IStubElementType elementType, @NotNull String shortName) { - this(parent, elementType, StringRef.fromString(shortName)); + public PsiJetAnnotationStubImpl(StubElement parent, @NotNull String shortName) { + this(parent, StringRef.fromString(shortName)); } - public PsiJetAnnotationStubImpl(StubElement parent, IStubElementType elementType, StringRef shortName) { - super(parent, elementType); + public PsiJetAnnotationStubImpl(StubElement parent, StringRef shortName) { + super(parent, JetStubElementTypes.ANNOTATION_ENTRY); this.shortName = shortName; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetClassBodyStubImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetClassBodyStubImpl.java index 2ba662c7b1c..76523756c83 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetClassBodyStubImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetClassBodyStubImpl.java @@ -16,14 +16,14 @@ package org.jetbrains.jet.lang.psi.stubs.impl; -import com.intellij.psi.stubs.IStubElementType; import com.intellij.psi.stubs.StubBase; import com.intellij.psi.stubs.StubElement; import org.jetbrains.jet.lang.psi.JetClassBody; import org.jetbrains.jet.lang.psi.stubs.PsiJetClassBodyStub; +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; public class PsiJetClassBodyStubImpl extends StubBase implements PsiJetClassBodyStub { - public PsiJetClassBodyStubImpl(StubElement parent, IStubElementType elementType) { - super(parent, elementType); + public PsiJetClassBodyStubImpl(StubElement parent) { + super(parent, JetStubElementTypes.CLASS_BODY); } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetFunctionStubImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetFunctionStubImpl.java index d1ad6de4aa0..bb56e5be6ad 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetFunctionStubImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetFunctionStubImpl.java @@ -16,7 +16,6 @@ package org.jetbrains.jet.lang.psi.stubs.impl; -import com.intellij.psi.stubs.IStubElementType; import com.intellij.psi.stubs.StubBase; import com.intellij.psi.stubs.StubElement; import com.intellij.util.ArrayUtil; @@ -25,6 +24,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.psi.JetNamedFunction; import org.jetbrains.jet.lang.psi.stubs.PsiJetFunctionStub; +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; import org.jetbrains.jet.lang.resolve.name.FqName; public class PsiJetFunctionStubImpl extends StubBase implements PsiJetFunctionStub { @@ -35,23 +35,23 @@ public class PsiJetFunctionStubImpl extends StubBase implement private final FqName fqName; public PsiJetFunctionStubImpl( - @NotNull IStubElementType elementType, @NotNull StubElement parent, @Nullable String name, boolean isTopLevel, @Nullable FqName fqName, - boolean isExtension) { - this(elementType, parent, StringRef.fromString(name), isTopLevel, fqName, isExtension); + boolean isExtension + ) { + this(parent, StringRef.fromString(name), isTopLevel, fqName, isExtension); } public PsiJetFunctionStubImpl( - @NotNull IStubElementType elementType, @NotNull StubElement parent, @Nullable StringRef nameRef, boolean isTopLevel, @Nullable FqName fqName, - boolean isExtension) { - super(parent, elementType); + boolean isExtension + ) { + super(parent, JetStubElementTypes.FUNCTION); if (isTopLevel && fqName == null) { throw new IllegalArgumentException("fqName shouldn't be null for top level functions"); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetObjectStubImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetObjectStubImpl.java index 4ba978cb6c3..867fd1eea3d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetObjectStubImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetObjectStubImpl.java @@ -17,7 +17,6 @@ package org.jetbrains.jet.lang.psi.stubs.impl; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.psi.stubs.IStubElementType; import com.intellij.psi.stubs.StubBase; import com.intellij.psi.stubs.StubElement; import com.intellij.util.ArrayUtil; @@ -26,6 +25,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.psi.JetObjectDeclaration; import org.jetbrains.jet.lang.psi.stubs.PsiJetObjectStub; +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; import org.jetbrains.jet.lang.resolve.name.FqName; import java.util.ArrayList; @@ -40,8 +40,7 @@ public class PsiJetObjectStubImpl extends StubBase impleme private final boolean isLocal; public PsiJetObjectStubImpl( - @NotNull IStubElementType elementType, - StubElement parent, + @NotNull StubElement parent, @Nullable String name, @Nullable FqName fqName, @NotNull List superNames, @@ -49,20 +48,19 @@ public class PsiJetObjectStubImpl extends StubBase impleme boolean isClassObject, boolean isLocal ) { - this(elementType, parent, StringRef.fromString(name), fqName, Utils.instance$.wrapStrings(superNames), isTopLevel, isClassObject, isLocal); + this(parent, StringRef.fromString(name), fqName, Utils.instance$.wrapStrings(superNames), isTopLevel, isClassObject, isLocal); } public PsiJetObjectStubImpl( - @NotNull IStubElementType elementType, - StubElement parent, + @NotNull StubElement parent, @Nullable StringRef name, @Nullable FqName fqName, @NotNull StringRef[] superNames, boolean isTopLevel, boolean isClassObject, - boolean isLocal) { - super(parent, elementType); - + boolean isLocal + ) { + super(parent, JetStubElementTypes.OBJECT_DECLARATION); this.name = name; this.fqName = fqName; this.superNames = superNames; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetParameterListStubImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetParameterListStubImpl.java index 80939085176..5fcd1c8defa 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetParameterListStubImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetParameterListStubImpl.java @@ -16,15 +16,15 @@ package org.jetbrains.jet.lang.psi.stubs.impl; -import com.intellij.psi.stubs.IStubElementType; import com.intellij.psi.stubs.StubBase; import com.intellij.psi.stubs.StubElement; import org.jetbrains.jet.lang.psi.JetParameterList; import org.jetbrains.jet.lang.psi.stubs.PsiJetParameterListStub; +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; public class PsiJetParameterListStubImpl extends StubBase implements PsiJetParameterListStub { - public PsiJetParameterListStubImpl(IStubElementType elementType, StubElement parent) { - super(parent, elementType); + public PsiJetParameterListStubImpl(StubElement parent) { + super(parent, JetStubElementTypes.VALUE_PARAMETER_LIST); } @Override diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetParameterStubImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetParameterStubImpl.java index 3b838a9a8b1..9d51ffba357 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetParameterStubImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetParameterStubImpl.java @@ -16,13 +16,13 @@ package org.jetbrains.jet.lang.psi.stubs.impl; -import com.intellij.psi.stubs.IStubElementType; import com.intellij.psi.stubs.StubBase; import com.intellij.psi.stubs.StubElement; import com.intellij.util.io.StringRef; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.psi.JetParameter; import org.jetbrains.jet.lang.psi.stubs.PsiJetParameterStub; +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; import org.jetbrains.jet.lang.resolve.name.FqName; public class PsiJetParameterStubImpl extends StubBase implements PsiJetParameterStub { @@ -34,13 +34,13 @@ public class PsiJetParameterStubImpl extends StubBase implements P private final FqName fqName; public PsiJetParameterStubImpl( - IStubElementType elementType, StubElement parent, + StubElement parent, FqName fqName, StringRef name, boolean isMutable, boolean isVarArg, StringRef typeText, StringRef defaultValueText ) { - super(parent, elementType); + super(parent, JetStubElementTypes.VALUE_PARAMETER); this.name = name; this.isMutable = isMutable; this.isVarArg = isVarArg; @@ -50,14 +50,14 @@ public class PsiJetParameterStubImpl extends StubBase implements P } public PsiJetParameterStubImpl( - IStubElementType elementType, StubElement parent, + StubElement parent, FqName fqName, String name, boolean isMutable, boolean isVarArg, String typeText, String defaultValueText ) { - this(elementType, parent, fqName, StringRef.fromString(name), isMutable, isVarArg, + this(parent, fqName, StringRef.fromString(name), isMutable, isVarArg, StringRef.fromString(typeText), StringRef.fromString(defaultValueText)); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetPropertyStubImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetPropertyStubImpl.java index 373d450eb37..1fe6fb4f4ae 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetPropertyStubImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetPropertyStubImpl.java @@ -16,13 +16,13 @@ package org.jetbrains.jet.lang.psi.stubs.impl; -import com.intellij.psi.stubs.IStubElementType; import com.intellij.psi.stubs.StubBase; import com.intellij.psi.stubs.StubElement; import com.intellij.util.io.StringRef; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.psi.JetProperty; import org.jetbrains.jet.lang.psi.stubs.PsiJetPropertyStub; +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; import org.jetbrains.jet.lang.resolve.name.FqName; public class PsiJetPropertyStubImpl extends StubBase implements PsiJetPropertyStub { @@ -33,9 +33,11 @@ public class PsiJetPropertyStubImpl extends StubBase implements Psi private final StringRef typeText; private final StringRef inferenceBodyText; - public PsiJetPropertyStubImpl(IStubElementType elementType, StubElement parent, StringRef name, - boolean isVar, boolean isTopLevel, @Nullable FqName fqName, StringRef typeText, StringRef inferenceBodyText) { - super(parent, elementType); + public PsiJetPropertyStubImpl( + StubElement parent, StringRef name, + boolean isVar, boolean isTopLevel, @Nullable FqName fqName, StringRef typeText, StringRef inferenceBodyText + ) { + super(parent, JetStubElementTypes.PROPERTY); if (isTopLevel && fqName == null) { throw new IllegalArgumentException("fqName shouldn't be null for top level properties"); @@ -49,11 +51,11 @@ public class PsiJetPropertyStubImpl extends StubBase implements Psi this.inferenceBodyText = inferenceBodyText; } - public PsiJetPropertyStubImpl(IStubElementType elementType, StubElement parent, String name, + public PsiJetPropertyStubImpl(StubElement parent, String name, boolean isVar, boolean isTopLevel, @Nullable FqName topFQName, String typeText, String inferenceBodyText ) { - this(elementType, parent, StringRef.fromString(name), + this(parent, StringRef.fromString(name), isVar, isTopLevel, topFQName, StringRef.fromString(typeText), StringRef.fromString(inferenceBodyText)); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetTypeParameterListStubImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetTypeParameterListStubImpl.java index 147e5b9c107..e87c15c9c4a 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetTypeParameterListStubImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetTypeParameterListStubImpl.java @@ -16,16 +16,15 @@ package org.jetbrains.jet.lang.psi.stubs.impl; -import com.intellij.psi.stubs.IStubElementType; import com.intellij.psi.stubs.StubBase; import com.intellij.psi.stubs.StubElement; -import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.psi.JetTypeParameterList; import org.jetbrains.jet.lang.psi.stubs.PsiJetTypeParameterListStub; +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; public class PsiJetTypeParameterListStubImpl extends StubBase implements PsiJetTypeParameterListStub { - public PsiJetTypeParameterListStubImpl(@NotNull IStubElementType elementType, StubElement parent) { - super(parent, elementType); + public PsiJetTypeParameterListStubImpl(StubElement parent) { + super(parent, JetStubElementTypes.TYPE_PARAMETER_LIST); } @Override diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetTypeParameterStubImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetTypeParameterStubImpl.java index d0beee0d463..f83e583158a 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetTypeParameterStubImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/impl/PsiJetTypeParameterStubImpl.java @@ -22,7 +22,7 @@ import com.intellij.util.io.StringRef; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.psi.JetTypeParameter; import org.jetbrains.jet.lang.psi.stubs.PsiJetTypeParameterStub; -import org.jetbrains.jet.lang.psi.stubs.elements.JetTypeParameterElementType; +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; import org.jetbrains.jet.lang.resolve.name.FqName; public class PsiJetTypeParameterStubImpl extends StubBase implements PsiJetTypeParameterStub { @@ -31,9 +31,10 @@ public class PsiJetTypeParameterStubImpl extends StubBase impl private final boolean isInVariance; private final boolean isOutVariance; - public PsiJetTypeParameterStubImpl(JetTypeParameterElementType type, StubElement parent, - StringRef name, StringRef extendBoundTypeText, boolean isInVariance, boolean isOutVariance) { - super(parent, type); + public PsiJetTypeParameterStubImpl( + StubElement parent, StringRef name, StringRef extendBoundTypeText, boolean isInVariance, boolean isOutVariance + ) { + super(parent, JetStubElementTypes.TYPE_PARAMETER); this.name = name; this.extendBoundTypeText = extendBoundTypeText; @@ -41,9 +42,10 @@ public class PsiJetTypeParameterStubImpl extends StubBase impl this.isOutVariance = isOutVariance; } - public PsiJetTypeParameterStubImpl(JetTypeParameterElementType type, StubElement parent, - String name, String extendBoundTypeText, boolean isInVariance, boolean isOutVariance) { - this(type, parent, StringRef.fromString(name), StringRef.fromString(extendBoundTypeText), isInVariance, isOutVariance); + public PsiJetTypeParameterStubImpl( + StubElement parent, String name, String extendBoundTypeText, boolean isInVariance, boolean isOutVariance + ) { + this(parent, StringRef.fromString(name), StringRef.fromString(extendBoundTypeText), isInVariance, isOutVariance); } @Override