mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] Property tests: check that expression passed to extract variable could be found via findExpressionInRange
GitOrigin-RevId: c0c036e21b615411335386742f76f134ef927988
This commit is contained in:
committed by
intellij-monorepo-bot
parent
577f1b722b
commit
3145faff60
+6
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.java.propertyBased;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtil;
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
import com.intellij.java.refactoring.InplaceIntroduceVariableTest;
|
||||
@@ -22,6 +23,7 @@ import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.intellij.testFramework.propertyBased.ActionOnFile;
|
||||
import com.intellij.testFramework.propertyBased.RandomActivityInterceptor;
|
||||
import com.intellij.ui.UiInterceptors;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import one.util.streamex.EntryStream;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jetCheck.Generator;
|
||||
@@ -44,6 +46,10 @@ public class IntroduceVariableActionOnFile extends ActionOnFile {
|
||||
PsiElement element = getFile().findElementAt(offset);
|
||||
if (element == null) return;
|
||||
List<PsiExpression> expressions = PsiTreeUtil.collectParents(element, PsiExpression.class, true, e -> false);
|
||||
expressions = ContainerUtil.filter(expressions, ex -> {
|
||||
TextRange exRange = ex.getTextRange();
|
||||
return CodeInsightUtil.findExpressionInRange(getFile(), exRange.getStartOffset(), exRange.getEndOffset()) == ex;
|
||||
});
|
||||
if (expressions.isEmpty()) return;
|
||||
PsiExpression expression = env.generateValue(Generator.sampledFrom(expressions), null);
|
||||
TextRange range = expression.getTextRange();
|
||||
|
||||
Reference in New Issue
Block a user