001 /*
002 * Copyright 2010-2014 JetBrains s.r.o.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 package org.jetbrains.jet.lang.psi;
018
019 import com.intellij.lang.ASTNode;
020 import com.intellij.psi.stubs.IStubElementType;
021 import com.intellij.psi.stubs.StubElement;
022 import org.jetbrains.annotations.NotNull;
023 import org.jetbrains.annotations.Nullable;
024 import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes;
025 import org.jetbrains.jet.lexer.JetModifierKeywordToken;
026
027 import java.util.Collections;
028 import java.util.List;
029
030 public class JetModifierListOwnerStub<T extends StubElement> extends JetElementImplStub<T> implements JetModifierListOwner {
031 public JetModifierListOwnerStub(ASTNode node) {
032 super(node);
033 }
034
035 public JetModifierListOwnerStub(T stub, IStubElementType nodeType) {
036 super(stub, nodeType);
037 }
038
039 @Override
040 @Nullable
041 public JetModifierList getModifierList() {
042 return getStubOrPsiChild(JetStubElementTypes.MODIFIER_LIST);
043 }
044
045 @Override
046 public boolean hasModifier(JetModifierKeywordToken modifier) {
047 JetModifierList modifierList = getModifierList();
048 return modifierList != null && modifierList.hasModifier(modifier);
049 }
050
051 @Override
052 @NotNull
053 public List<JetAnnotationEntry> getAnnotationEntries() {
054 JetModifierList modifierList = getModifierList();
055 if (modifierList == null) return Collections.emptyList();
056 return modifierList.getAnnotationEntries();
057 }
058
059 @Override
060 @NotNull
061 public List<JetAnnotation> getAnnotations() {
062 JetModifierList modifierList = getModifierList();
063 if (modifierList == null) return Collections.emptyList();
064 return modifierList.getAnnotations();
065 }
066 }