Java: allow inlining library field from the field (IDEA-360539)

GitOrigin-RevId: 968d07c992b673ffed1a67e7963de5d2ee36584c
This commit is contained in:
Bas Leijdekkers
2024-10-11 11:16:04 +02:00
committed by intellij-monorepo-bot
parent b8c89d8e2b
commit beb35f4a2c

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2014 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-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.refactoring.inline;
import com.intellij.codeInsight.PsiEquivalenceUtil;
@@ -39,6 +25,7 @@ import com.intellij.refactoring.util.CommonRefactoringUtil;
import com.intellij.refactoring.util.InlineUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
@@ -102,8 +89,6 @@ public final class InlineConstantFieldHandler extends JavaInlineActionHandler {
}
}
if ((!(element instanceof PsiCompiledElement) || reference == null) && !CommonRefactoringUtil.checkReadOnlyStatus(project, field)) return;
MultiMap<PsiElement, String> conflicts = new MultiMap<>();
InlineUtil.checkChangedBeforeLastAccessConflicts(conflicts, initializer, field);
@@ -144,8 +129,7 @@ public final class InlineConstantFieldHandler extends JavaInlineActionHandler {
return false;
}
@Nullable
public static PsiExpression getInitializer(PsiField field) {
public static @Nullable PsiExpression getInitializer(PsiField field) {
if (field.hasInitializer()) {
PsiExpression initializer = field.getInitializer();
if (initializer instanceof PsiCompiledElement) {
@@ -185,9 +169,8 @@ public final class InlineConstantFieldHandler extends JavaInlineActionHandler {
return null;
}
@Nullable
@Override
public String getActionName(PsiElement element) {
public @NotNull String getActionName(PsiElement element) {
return JavaRefactoringBundle.message("inline.field.action.name");
}