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.
16 package com
.intellij
.psi
.impl
.source
;
18 import com
.intellij
.lang
.ASTNode
;
19 import com
.intellij
.openapi
.diagnostic
.Logger
;
20 import com
.intellij
.psi
.JavaElementVisitor
;
21 import com
.intellij
.psi
.PsiElementVisitor
;
22 import com
.intellij
.psi
.PsiParameter
;
23 import com
.intellij
.psi
.PsiParameterList
;
24 import com
.intellij
.psi
.impl
.PsiImplUtil
;
25 import com
.intellij
.psi
.impl
.java
.stubs
.JavaStubElementTypes
;
26 import com
.intellij
.psi
.impl
.java
.stubs
.PsiParameterListStub
;
27 import com
.intellij
.psi
.impl
.source
.tree
.CompositeElement
;
28 import org
.jetbrains
.annotations
.NonNls
;
29 import org
.jetbrains
.annotations
.NotNull
;
31 public class PsiParameterListImpl
extends JavaStubPsiElement
<PsiParameterListStub
> implements PsiParameterList
{
32 private static final Logger LOG
= Logger
.getInstance("#com.intellij.psi.impl.source.PsiParameterListImpl");
34 public PsiParameterListImpl(final PsiParameterListStub stub
) {
35 super(stub
, JavaStubElementTypes
.PARAMETER_LIST
);
38 public PsiParameterListImpl(final ASTNode node
) {
43 public PsiParameter
[] getParameters() {
44 return getStubOrPsiChildren(JavaStubElementTypes
.PARAMETER
, PsiParameter
.ARRAY_FACTORY
);
47 public int getParameterIndex(PsiParameter parameter
) {
48 LOG
.assertTrue(parameter
.getParent() == this);
49 return PsiImplUtil
.getParameterIndex(parameter
, this);
53 public CompositeElement
getNode() {
54 return (CompositeElement
)super.getNode();
57 public int getParametersCount() {
58 final PsiParameterListStub stub
= getStub();
60 return stub
.getChildrenStubs().size();
63 return getNode().countChildren(Constants
.PARAMETER_BIT_SET
);
66 public void accept(@NotNull PsiElementVisitor visitor
){
67 if (visitor
instanceof JavaElementVisitor
) {
68 ((JavaElementVisitor
)visitor
).visitParameterList(this);
71 visitor
.visitElement(this);
76 public String
toString(){
77 return "PsiParameterList:" + getText();