001    /*
002     * Copyright 2010-2013 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.asJava.light;
018    
019    import com.intellij.lang.Language;
020    import com.intellij.psi.*;
021    import org.jetbrains.annotations.NotNull;
022    
023    // Based on com.intellij.psi.impl.light.LightParameter
024    public class LightParameter extends LightVariableBuilder<LightVariableBuilder> implements PsiParameter {
025        public static final LightParameter[] EMPTY_ARRAY = new LightParameter[0];
026    
027        private final String myName;
028        private final PsiElement myDeclarationScope;
029        private final boolean myVarArgs;
030    
031        public LightParameter(@NotNull String name, @NotNull PsiType type, PsiElement declarationScope, Language language) {
032            this(name, type, declarationScope, language, type instanceof PsiEllipsisType);
033        }
034    
035        public LightParameter(@NotNull String name, @NotNull PsiType type, PsiElement declarationScope, Language language, boolean isVarArgs) {
036            super(declarationScope.getManager(), name, type, language);
037            myName = name;
038            myDeclarationScope = declarationScope;
039            myVarArgs = isVarArgs;
040        }
041    
042        @NotNull
043        @Override
044        public PsiElement getDeclarationScope() {
045            return myDeclarationScope;
046        }
047    
048        @Override
049        public void accept(@NotNull PsiElementVisitor visitor) {
050            if (visitor instanceof JavaElementVisitor) {
051                ((JavaElementVisitor)visitor).visitParameter(this);
052            }
053        }
054    
055        public String toString() {
056            return "Light Parameter";
057        }
058    
059        @Override
060        public boolean isVarArgs() {
061            return myVarArgs;
062        }
063    
064        @Override
065        @NotNull
066        public String getName() {
067            return myName;
068        }
069    }