-// Copyright 2000-2017 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.
+// 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.
package com.intellij.psi;
import com.intellij.lang.jvm.JvmField;
/**
* Represents a Java field or enum constant.
*/
-public interface PsiField extends PsiMember, PsiVariable, PsiDocCommentOwner, JvmField {
+public interface PsiField extends PsiJvmMember, PsiVariable, PsiDocCommentOwner, JvmField {
/**
* The empty array of PSI fields which can be reused to avoid unnecessary allocations.
*/
--- /dev/null
+// 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.
+package com.intellij.psi;
+
+import com.intellij.lang.jvm.JvmMember;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Not all PsiMember inheritors are JvmMembers, e.g. {@link PsiClassInitializer}.
+ * This is a bridge interface between them.
+ * <p/>
+ * Known PsiMembers which are also JvmMembers:
+ * {@link PsiClass}, {@link PsiField} and {@link PsiMethod}.
+ */
+public interface PsiJvmMember extends PsiMember, JvmMember, PsiJvmModifiersOwner {
+
+ @Override
+ @Nullable
+ PsiClass getContainingClass();
+}
--- /dev/null
+// 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.
+package com.intellij.psi;
+
+import com.intellij.lang.jvm.JvmModifier;
+import com.intellij.lang.jvm.JvmModifiersOwner;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Not all PsiModifierListOwner inheritors are JvmModifiersOwners, e.g. {@link PsiLocalVariable} or {@link PsiRequiresStatement}.
+ * This is a bridge interface between them.
+ * <p>
+ * Known PsiModifierListOwners which are also JvmModifiersOwners:
+ * {@link PsiJvmMember} inheritors, {@link PsiParameter} and {@link PsiPackage}.
+ */
+public interface PsiJvmModifiersOwner extends PsiModifierListOwner, JvmModifiersOwner {
+
+ @NotNull
+ @Override
+ default PsiAnnotation[] getAnnotations() {
+ return PsiModifierListOwner.super.getAnnotations();
+ }
+
+ @Nullable
+ @Override
+ default PsiAnnotation getAnnotation(@NotNull @NonNls String fqn) {
+ return PsiModifierListOwner.super.getAnnotation(fqn);
+ }
+
+ @Override
+ default boolean hasAnnotation(@NotNull @NonNls String fqn) {
+ return PsiModifierListOwner.super.hasAnnotation(fqn);
+ }
+
+ @Override
+ default boolean hasModifier(@NotNull JvmModifier modifier) {
+ return PsiModifierListOwner.super.hasModifier(modifier);
+ }
+
+ @Nullable
+ @Override
+ default PsiElement getSourceElement() {
+ return this;
+ }
+}
-// Copyright 2000-2018 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.
+// 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.
package com.intellij.psi;
-import com.intellij.lang.jvm.JvmMember;
import org.jetbrains.annotations.Nullable;
/**
* Represents a member of a Java class (for example, a field or a method).
*/
-public interface PsiMember extends PsiModifierListOwner, NavigatablePsiElement, JvmMember {
+public interface PsiMember extends PsiModifierListOwner, NavigatablePsiElement {
/**
* The empty array of PSI members which can be reused to avoid unnecessary allocations.
*/
*
* @return the containing class.
*/
- @Override
@Nullable
PsiClass getContainingClass();
}
-// Copyright 2000-2018 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.
+// 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.
package com.intellij.psi;
import com.intellij.lang.jvm.JvmModifier;
-import com.intellij.lang.jvm.JvmModifiersOwner;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import static com.intellij.psi.PsiJvmConversionHelper.*;
+import static com.intellij.psi.PsiJvmConversionHelper.hasListModifier;
/**
* Represents a PSI element which has a list of modifiers (public/private/protected/etc.)
* and annotations.
*/
-public interface PsiModifierListOwner extends PsiElement, JvmModifiersOwner {
+public interface PsiModifierListOwner extends PsiElement {
+
/**
* Returns the list of modifiers for the element.
*
boolean hasModifierProperty(@PsiModifier.ModifierConstant @NonNls @NotNull String name);
@NotNull
- @Override
default PsiAnnotation[] getAnnotations() {
- return getListAnnotations(this);
+ return PsiJvmConversionHelper.getListAnnotations(this);
}
@Nullable
- @Override
- default PsiAnnotation getAnnotation(@NotNull @NonNls String fqn) {
- return getListAnnotation(this, fqn);
+ default PsiAnnotation getAnnotation(@NotNull String fqn) {
+ return PsiJvmConversionHelper.getListAnnotation(this, fqn);
}
- @Override
- default boolean hasAnnotation(@NotNull @NonNls String fqn) {
- return hasListAnnotation(this, fqn);
+ default boolean hasAnnotation(@NotNull String fqn) {
+ return PsiJvmConversionHelper.hasListAnnotation(this, fqn);
}
- @Override
default boolean hasModifier(@NotNull JvmModifier modifier) {
return hasListModifier(this, modifier);
}
-
- @Nullable
- @Override
- default PsiElement getSourceElement() {
- return this;
- }
}
-// Copyright 2000-2017 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.
+// 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.
package com.intellij.psi;
import com.intellij.lang.jvm.JvmPackage;
/**
* Represents a Java package.
*/
-public interface PsiPackage extends PsiCheckedRenameElement, NavigationItem, PsiModifierListOwner,
+public interface PsiPackage extends PsiCheckedRenameElement, NavigationItem, PsiJvmModifiersOwner,
PsiDirectoryContainer, PsiQualifiedNamedElement, JvmPackage {
String PACKAGE_INFO_CLASS = "package-info";
-/*
- * Copyright 2000-2017 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+// 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.
package com.intellij.psi;
import com.intellij.lang.jvm.JvmParameter;
/**
* Represents the parameter of a Java method, foreach (enhanced for) statement or catch block.
*/
-public interface PsiParameter extends PsiVariable, JvmParameter {
+public interface PsiParameter extends PsiVariable, JvmParameter, PsiJvmModifiersOwner {
/**
* The empty array of PSI parameters which can be reused to avoid unnecessary allocations.
*/
@NotNull
@Override
default PsiAnnotation[] getAnnotations() {
- return PsiVariable.super.getAnnotations();
+ return PsiJvmModifiersOwner.super.getAnnotations();
}
}
-/*
- * Copyright 2000-2017 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+// 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.
package com.intellij.psi;
import com.intellij.lang.jvm.JvmTypeParametersOwner;
*
* @author dsl
*/
-public interface PsiTypeParameterListOwner extends PsiMember, JvmTypeParametersOwner {
+public interface PsiTypeParameterListOwner extends PsiJvmMember, JvmTypeParametersOwner {
/**
* Checks if the element has any type parameters.
*