1 // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
2 package com.intellij.psi;
4 import com.intellij.lang.jvm.JvmField;
5 import com.intellij.util.ArrayFactory;
6 import com.intellij.util.IncorrectOperationException;
7 import org.jetbrains.annotations.NotNull;
8 import org.jetbrains.annotations.Nullable;
11 * Represents a Java field or enum constant.
13 public interface PsiField extends PsiJvmMember, PsiVariable, PsiDocCommentOwner, JvmField {
15 * The empty array of PSI fields which can be reused to avoid unnecessary allocations.
17 PsiField[] EMPTY_ARRAY = new PsiField[0];
19 ArrayFactory<PsiField> ARRAY_FACTORY = count -> count == 0 ? EMPTY_ARRAY : new PsiField[count];
22 * Adds initializer to the field declaration or, if {@code initializer} parameter is null,
23 * removes the initializer from the field declaration.
25 * @param initializer the initializer to add.
26 * @throws IncorrectOperationException if the modifications fails for some reason.
29 void setInitializer(@Nullable PsiExpression initializer) throws IncorrectOperationException;
32 @NotNull PsiIdentifier getNameIdentifier();
34 /* This explicit declaration is required to force javac generate bridge method 'JvmType getType()'; without it calling
35 JvmField#getType() method on instances which weren't recompiled against the new API will cause AbstractMethodError. */