mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 04:51:24 +07:00
[uast] Make light parameter type building lazy in K2
Computing the type can be slow, and clients might not even need to access the type. GitOrigin-RevId: 22df309ed18d77f07ae7d2dd2dcc994c79541f0b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d3bf2e0e20
commit
cf770b3acf
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.psi.impl.light;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
@@ -6,6 +6,8 @@ import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class LightParameter extends LightVariableBuilder<LightVariableBuilder<?>> implements PsiParameter {
|
||||
private final PsiElement myDeclarationScope;
|
||||
private final boolean myVarArgs;
|
||||
@@ -29,6 +31,18 @@ public class LightParameter extends LightVariableBuilder<LightVariableBuilder<?>
|
||||
myVarArgs = isVarArgs;
|
||||
}
|
||||
|
||||
public LightParameter(
|
||||
@NonNls @NotNull String name,
|
||||
@NotNull PsiElement declarationScope,
|
||||
@NotNull Supplier<? extends @NotNull PsiType> typeSupplier,
|
||||
@NotNull Language language,
|
||||
boolean isVarArgs
|
||||
) {
|
||||
super(declarationScope.getManager(), name, typeSupplier, language, new LightModifierList(declarationScope.getManager()));
|
||||
myDeclarationScope = declarationScope;
|
||||
myVarArgs = isVarArgs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull PsiElement getDeclarationScope() {
|
||||
return myDeclarationScope;
|
||||
|
||||
@@ -15,10 +15,11 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class LightVariableBuilder<T extends LightVariableBuilder<?>> extends LightElement implements PsiVariable, NavigationItem, OriginInfoAwareElement {
|
||||
private final String myName;
|
||||
private final PsiType myType;
|
||||
private final Supplier<? extends PsiType> myTypeSupplier;
|
||||
private volatile LightModifierList myModifierList;
|
||||
private volatile Icon myBaseIcon = IconManager.getInstance().getPlatformIcon(PlatformIcons.Variable);
|
||||
private String myOriginInfo;
|
||||
@@ -40,7 +41,19 @@ public class LightVariableBuilder<T extends LightVariableBuilder<?>> extends Lig
|
||||
@NotNull Language language, @NotNull LightModifierList modifierList) {
|
||||
super(manager, language);
|
||||
myName = name;
|
||||
myType = type;
|
||||
myTypeSupplier = () -> type;
|
||||
myModifierList = modifierList;
|
||||
}
|
||||
|
||||
protected LightVariableBuilder(PsiManager manager,
|
||||
@NotNull String name,
|
||||
@NotNull Supplier<? extends @NotNull PsiType> typeSupplier,
|
||||
@NotNull Language language,
|
||||
@NotNull LightModifierList modifierList
|
||||
) {
|
||||
super(manager, language);
|
||||
myName = name;
|
||||
myTypeSupplier = typeSupplier;
|
||||
myModifierList = modifierList;
|
||||
}
|
||||
|
||||
@@ -60,7 +73,7 @@ public class LightVariableBuilder<T extends LightVariableBuilder<?>> extends Lig
|
||||
|
||||
@Override
|
||||
public @NotNull PsiType getType() {
|
||||
return myType;
|
||||
return myTypeSupplier.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user