diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetDeclarationStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetDeclarationStub.java index d421106aa55..44260b40c1c 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetDeclarationStub.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetDeclarationStub.java @@ -27,7 +27,7 @@ import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; import java.util.Collections; import java.util.List; -abstract class JetDeclarationStub extends JetElementImplStub implements JetDeclaration { +abstract class JetDeclarationStub extends JetModifierListOwnerStub implements JetDeclaration { public JetDeclarationStub(@NotNull T stub, @NotNull IStubElementType nodeType) { super(stub, nodeType); } @@ -35,32 +35,4 @@ abstract class JetDeclarationStub extends JetElementImplS public JetDeclarationStub(@NotNull ASTNode node) { super(node); } - - @Override - @Nullable - public JetModifierList getModifierList() { - return getStubOrPsiChild(JetStubElementTypes.MODIFIER_LIST); - } - - @Override - public boolean hasModifier(JetModifierKeywordToken modifier) { - JetModifierList modifierList = getModifierList(); - return modifierList != null && modifierList.hasModifier(modifier); - } - - @NotNull - @Override - public List getAnnotationEntries() { - JetModifierList modifierList = getModifierList(); - if (modifierList == null) return Collections.emptyList(); - return modifierList.getAnnotationEntries(); - } - - @NotNull - @Override - public List getAnnotations() { - JetModifierList modifierList = getModifierList(); - if (modifierList == null) return Collections.emptyList(); - return modifierList.getAnnotations(); - } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetModifierListOwnerStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetModifierListOwnerStub.java new file mode 100644 index 00000000000..9dcd9f5ca5a --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetModifierListOwnerStub.java @@ -0,0 +1,66 @@ +/* + * 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; + +import com.intellij.lang.ASTNode; +import com.intellij.psi.stubs.IStubElementType; +import com.intellij.psi.stubs.StubElement; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; +import org.jetbrains.jet.lexer.JetModifierKeywordToken; + +import java.util.Collections; +import java.util.List; + +public class JetModifierListOwnerStub extends JetElementImplStub implements JetModifierListOwner { + public JetModifierListOwnerStub(ASTNode node) { + super(node); + } + + public JetModifierListOwnerStub(T stub, IStubElementType nodeType) { + super(stub, nodeType); + } + + @Override + @Nullable + public JetModifierList getModifierList() { + return getStubOrPsiChild(JetStubElementTypes.MODIFIER_LIST); + } + + @Override + public boolean hasModifier(JetModifierKeywordToken modifier) { + JetModifierList modifierList = getModifierList(); + return modifierList != null && modifierList.hasModifier(modifier); + } + + @Override + @NotNull + public List getAnnotationEntries() { + JetModifierList modifierList = getModifierList(); + if (modifierList == null) return Collections.emptyList(); + return modifierList.getAnnotationEntries(); + } + + @Override + @NotNull + public List getAnnotations() { + JetModifierList modifierList = getModifierList(); + if (modifierList == null) return Collections.emptyList(); + return modifierList.getAnnotations(); + } +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeProjection.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeProjection.java index b6371481aa5..d98c53108d5 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeProjection.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeProjection.java @@ -23,13 +23,10 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.JetNodeTypes; import org.jetbrains.jet.lang.psi.stubs.PsiJetTypeProjectionStub; import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; -import org.jetbrains.jet.lexer.JetModifierKeywordToken; import org.jetbrains.jet.lexer.JetTokens; -import java.util.Collections; -import java.util.List; +public class JetTypeProjection extends JetModifierListOwnerStub { -public class JetTypeProjection extends JetElementImplStub implements JetModifierListOwner { public JetTypeProjection(@NotNull ASTNode node) { super(node); } @@ -38,17 +35,6 @@ public class JetTypeProjection extends JetElementImplStub getAnnotationEntries() { - JetModifierList modifierList = getModifierList(); - if (modifierList == null) return Collections.emptyList(); - return modifierList.getAnnotationEntries(); - } - - @NotNull - @Override - public List getAnnotations() { - JetModifierList modifierList = getModifierList(); - if (modifierList == null) return Collections.emptyList(); - return modifierList.getAnnotations(); - } }