mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java, spring] Physical annotations for Java record parameters (EA-393492)
GitOrigin-RevId: 55713ebfb02085b73553a2a288a2372debd3f27e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
32d80eba88
commit
124b7603bd
+27
@@ -3,6 +3,7 @@ package com.intellij.psi.impl.light;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.ElementPresentationUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.ui.IconManager;
|
||||
import com.intellij.ui.icons.RowIcon;
|
||||
import com.intellij.util.BitUtil;
|
||||
@@ -13,6 +14,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Objects;
|
||||
|
||||
public class LightRecordCanonicalConstructor extends LightMethod implements SyntheticElement {
|
||||
public LightRecordCanonicalConstructor(@NotNull PsiMethod method,
|
||||
@@ -89,6 +91,31 @@ public class LightRecordCanonicalConstructor extends LightMethod implements Synt
|
||||
myWrapper = wrapper;
|
||||
}
|
||||
|
||||
public @Nullable PsiRecordComponent getRecordComponent() {
|
||||
PsiClass psiClass = PsiTreeUtil.getParentOfType(this, PsiClass.class);
|
||||
if (psiClass == null) return null;
|
||||
PsiRecordComponent[] recordComponents = psiClass.getRecordComponents();
|
||||
for (PsiRecordComponent recordComponent : recordComponents) {
|
||||
if (Objects.equals(recordComponent.getName(), this.getName())) {
|
||||
return recordComponent;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable PsiModifierList getModifierList() {
|
||||
PsiRecordComponent recordComponent = getRecordComponent();
|
||||
if (recordComponent == null) return super.getModifierList();
|
||||
|
||||
return new LightModifierList(getPrototype()) {
|
||||
@Override
|
||||
public PsiAnnotation @NotNull [] getAnnotations() {
|
||||
return recordComponent.getAnnotations();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement getParent() {
|
||||
return myWrapper;
|
||||
|
||||
Reference in New Issue
Block a user