mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-07 13:39:36 +07:00
IDEA-227674: fix JavaColorProvider for scala
do not rely on exact number of parents, use `findContaining` instead GitOrigin-RevId: 5b4590789c77b2c52c9135fbe64e7990d00c1e95
This commit is contained in:
committed by
intellij-monorepo-bot
parent
844bf6657b
commit
0858d89e31
@@ -38,13 +38,14 @@ public class JavaColorProvider implements ElementColorProvider {
|
||||
if (element instanceof PsiWhiteSpace) return null;
|
||||
if (!myUastMetaLanguage.matchesLanguage(element.getLanguage())) return null;
|
||||
PsiElement parent = element.getParent();
|
||||
Color color = getJavaColorFromExpression(parent);
|
||||
UCallExpression newExpression = UastUtils.findContaining(parent, UCallExpression.class);
|
||||
Color color = getJavaColorFromExpression(parent, newExpression);
|
||||
if (color == null) {
|
||||
parent = parent == null ? null : parent.getParent();
|
||||
color = getJavaColorFromExpression(parent);
|
||||
}
|
||||
UCallExpression newExpression = UastContextKt.toUElement(parent, UCallExpression.class);
|
||||
if (newExpression != null) {
|
||||
|
||||
if (newExpression != null && color != null) {
|
||||
UReferenceExpression uRef = newExpression.getClassReference();
|
||||
String resolvedName = uRef == null ? null : uRef.getResolvedName();
|
||||
if (resolvedName != null && element.textMatches(resolvedName)) {
|
||||
@@ -73,7 +74,12 @@ public class JavaColorProvider implements ElementColorProvider {
|
||||
|
||||
@Nullable
|
||||
public static Color getJavaColorFromExpression(@Nullable PsiElement element) {
|
||||
UCallExpression newExpression = UastContextKt.toUElement(element, UCallExpression.class);
|
||||
UCallExpression newExpression = UastUtils.findContaining(element, UCallExpression.class);
|
||||
return getJavaColorFromExpression(element, newExpression);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Color getJavaColorFromExpression(@Nullable PsiElement element, @Nullable UCallExpression newExpression) {
|
||||
if (newExpression != null && newExpression.getKind() == UastCallKind.CONSTRUCTOR_CALL &&
|
||||
isColorType(newExpression.getReturnType())) {
|
||||
return getColor(newExpression.getValueArguments());
|
||||
|
||||
Reference in New Issue
Block a user