Extract JetModifierListOwnerStub, make JetTypeProjection extend JetModifierListOwnerStub
This commit is contained in:
@@ -27,7 +27,7 @@ import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
abstract class JetDeclarationStub<T extends StubElement> extends JetElementImplStub<T> implements JetDeclaration {
|
||||
abstract class JetDeclarationStub<T extends StubElement> extends JetModifierListOwnerStub<T> implements JetDeclaration {
|
||||
public JetDeclarationStub(@NotNull T stub, @NotNull IStubElementType nodeType) {
|
||||
super(stub, nodeType);
|
||||
}
|
||||
@@ -35,32 +35,4 @@ abstract class JetDeclarationStub<T extends StubElement> 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<JetAnnotationEntry> getAnnotationEntries() {
|
||||
JetModifierList modifierList = getModifierList();
|
||||
if (modifierList == null) return Collections.emptyList();
|
||||
return modifierList.getAnnotationEntries();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<JetAnnotation> getAnnotations() {
|
||||
JetModifierList modifierList = getModifierList();
|
||||
if (modifierList == null) return Collections.emptyList();
|
||||
return modifierList.getAnnotations();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<T extends StubElement> extends JetElementImplStub<T> 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<JetAnnotationEntry> getAnnotationEntries() {
|
||||
JetModifierList modifierList = getModifierList();
|
||||
if (modifierList == null) return Collections.emptyList();
|
||||
return modifierList.getAnnotationEntries();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<JetAnnotation> getAnnotations() {
|
||||
JetModifierList modifierList = getModifierList();
|
||||
if (modifierList == null) return Collections.emptyList();
|
||||
return modifierList.getAnnotations();
|
||||
}
|
||||
}
|
||||
@@ -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<PsiJetTypeProjectionStub> {
|
||||
|
||||
public class JetTypeProjection extends JetElementImplStub<PsiJetTypeProjectionStub> implements JetModifierListOwner {
|
||||
public JetTypeProjection(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
@@ -38,17 +35,6 @@ public class JetTypeProjection extends JetElementImplStub<PsiJetTypeProjectionSt
|
||||
super(stub, JetStubElementTypes.TYPE_PROJECTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetModifierList getModifierList() {
|
||||
return (JetModifierList) findChildByType(JetNodeTypes.MODIFIER_LIST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasModifier(JetModifierKeywordToken modifier) {
|
||||
JetModifierList modifierList = getModifierList();
|
||||
return modifierList != null && modifierList.hasModifier(modifier);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetProjectionKind getProjectionKind() {
|
||||
ASTNode projectionNode = getProjectionNode();
|
||||
@@ -91,20 +77,4 @@ public class JetTypeProjection extends JetElementImplStub<PsiJetTypeProjectionSt
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<JetAnnotationEntry> getAnnotationEntries() {
|
||||
JetModifierList modifierList = getModifierList();
|
||||
if (modifierList == null) return Collections.emptyList();
|
||||
return modifierList.getAnnotationEntries();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<JetAnnotation> getAnnotations() {
|
||||
JetModifierList modifierList = getModifierList();
|
||||
if (modifierList == null) return Collections.emptyList();
|
||||
return modifierList.getAnnotations();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user