2 * Copyright 2000-2017 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;
18 import com.intellij.lang.jvm.JvmParameter;
19 import com.intellij.util.ArrayFactory;
20 import org.jetbrains.annotations.NotNull;
21 import org.jetbrains.annotations.Nullable;
24 * Represents the parameter of a Java method, foreach (enhanced for) statement or catch block.
26 public interface PsiParameter extends PsiVariable, JvmParameter {
28 * The empty array of PSI parameters which can be reused to avoid unnecessary allocations.
30 PsiParameter[] EMPTY_ARRAY = new PsiParameter[0];
32 ArrayFactory<PsiParameter> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new PsiParameter[count];
35 * Returns the element (method, lambda expression, foreach statement or catch block) in which the
36 * parameter is declared.
38 * @return the declaration scope for the parameter.
41 PsiElement getDeclarationScope();
44 * Checks if the parameter accepts a variable number of arguments.
46 * @return true if the parameter is a vararg, false otherwise
55 PsiTypeElement getTypeElement();
57 /* This explicit declaration is required to force javac generate bridge method 'JvmType getType()'; without it calling
58 JvmParameter#getType() method on instances which weren't recompiled against the new API will cause AbstractMethodError. */
63 // binary compatibility
66 default PsiAnnotation[] getAnnotations() {
67 return PsiVariable.super.getAnnotations();