2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 package com
.intellij
.psi
.impl
.source
.tree
.java
;
22 import com
.intellij
.psi
.PsiAnnotation
;
23 import com
.intellij
.psi
.PsiManager
;
24 import com
.intellij
.psi
.PsiModifierList
;
25 import com
.intellij
.psi
.impl
.light
.LightModifierList
;
26 import org
.jetbrains
.annotations
.NotNull
;
28 import java
.util
.ArrayList
;
29 import java
.util
.Arrays
;
30 import java
.util
.List
;
32 public class PsiCompositeModifierList
extends LightModifierList
{
33 private final List
<PsiModifierList
> mySublists
;
35 public PsiCompositeModifierList(final PsiManager manager
, List
<PsiModifierList
> sublists
) {
37 mySublists
= sublists
;
41 public PsiAnnotation
[] getAnnotations() {
42 List
<PsiAnnotation
> annotations
= new ArrayList
<PsiAnnotation
>();
43 for (PsiModifierList list
: mySublists
) {
44 annotations
.addAll(Arrays
.asList(list
.getAnnotations()));
46 return annotations
.toArray(new PsiAnnotation
[annotations
.size()]);
49 public PsiAnnotation
findAnnotation(@NotNull final String qualifiedName
) {
50 for (PsiModifierList sublist
: mySublists
) {
51 final PsiAnnotation annotation
= sublist
.findAnnotation(qualifiedName
);
52 if (annotation
!= null) return annotation
;
58 public boolean hasModifierProperty(@NotNull final String name
) {
59 for (PsiModifierList sublist
: mySublists
) {
60 if (sublist
.hasModifierProperty(name
)) return true;
65 public boolean hasExplicitModifier(@NotNull final String name
) {
66 for (PsiModifierList sublist
: mySublists
) {
67 if (sublist
.hasExplicitModifier(name
)) return true;