mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: show call hierarchy for default constructor when invoked on class (IDEA-110255)
GitOrigin-RevId: 59ca22d492344c921e5d32da883cb83d3c6aff8a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2b0d7caffd
commit
2df86d09f6
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.ide.hierarchy.call;
|
||||
|
||||
import com.intellij.ide.hierarchy.CallHierarchyBrowserBase;
|
||||
@@ -8,6 +8,7 @@ import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.light.LightDefaultConstructor;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -17,8 +18,12 @@ public class JavaCallHierarchyProvider implements HierarchyProvider {
|
||||
Project project = CommonDataKeys.PROJECT.getData(dataContext);
|
||||
if (project == null) return null;
|
||||
PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
|
||||
if (element instanceof PsiField || element instanceof PsiRecordComponent
|
||||
|| element instanceof PsiClass aClass && aClass.isRecord()) return element;
|
||||
if (element instanceof PsiField || element instanceof PsiRecordComponent) return element;
|
||||
else if (element instanceof PsiClass aClass) {
|
||||
if (aClass.isRecord()) return element;
|
||||
PsiMethod defaultConstructor = LightDefaultConstructor.create(aClass);
|
||||
if (defaultConstructor != null) return defaultConstructor;
|
||||
}
|
||||
return PsiTreeUtil.getParentOfType(element, PsiMethod.class, false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user