001 /*
002 * Copyright 2010-2016 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.kotlin.load.java.structure.impl;
018
019 import com.intellij.psi.PsiAnnotationOwner;
020 import com.intellij.psi.PsiParameter;
021 import com.intellij.psi.impl.compiled.ClsParameterImpl;
022 import org.jetbrains.annotations.NotNull;
023 import org.jetbrains.annotations.Nullable;
024 import org.jetbrains.kotlin.descriptors.Visibilities;
025 import org.jetbrains.kotlin.descriptors.Visibility;
026 import org.jetbrains.kotlin.load.java.structure.JavaAnnotation;
027 import org.jetbrains.kotlin.load.java.structure.JavaType;
028 import org.jetbrains.kotlin.load.java.structure.JavaValueParameter;
029 import org.jetbrains.kotlin.name.FqName;
030 import org.jetbrains.kotlin.name.Name;
031
032 import java.util.Collection;
033
034 public class JavaValueParameterImpl extends JavaElementImpl<PsiParameter>
035 implements JavaValueParameter, JavaAnnotationOwnerImpl, JavaModifierListOwnerImpl {
036 public JavaValueParameterImpl(@NotNull PsiParameter psiParameter) {
037 super(psiParameter);
038 }
039
040 @Nullable
041 @Override
042 public PsiAnnotationOwner getAnnotationOwnerPsi() {
043 return getPsi().getModifierList();
044 }
045
046 @Override
047 public boolean isAbstract() {
048 return false;
049 }
050
051 @Override
052 public boolean isStatic() {
053 return false;
054 }
055
056 @Override
057 public boolean isFinal() {
058 return false;
059 }
060
061 @NotNull
062 @Override
063 public Visibility getVisibility() {
064 return Visibilities.LOCAL;
065 }
066
067 @NotNull
068 @Override
069 public Collection<JavaAnnotation> getAnnotations() {
070 return JavaElementUtil.getAnnotations(this);
071 }
072
073 @Nullable
074 @Override
075 public JavaAnnotation findAnnotation(@NotNull FqName fqName) {
076 return JavaElementUtil.findAnnotation(this, fqName);
077 }
078
079 @Override
080 public boolean isDeprecatedInJavaDoc() {
081 return false;
082 }
083
084 @Override
085 @Nullable
086 public Name getName() {
087 PsiParameter psi = getPsi();
088 if (psi instanceof ClsParameterImpl && ((ClsParameterImpl) psi).isAutoGeneratedName()) {
089 return null;
090 }
091
092 String name = psi.getName();
093 return name == null ? null : Name.identifier(name);
094 }
095
096 @Override
097 @NotNull
098 public JavaType getType() {
099 return JavaTypeImpl.create(getPsi().getType());
100 }
101
102 @Override
103 public boolean isVararg() {
104 return getPsi().isVarArgs();
105 }
106 }