Move Java-specific part of SurroundWithTest to java-tests module

GitOrigin-RevId: fd78bb663c7e48c87f1dae25b6a04571aa62cf50
This commit is contained in:
Dmitry Jemerov
2022-05-02 16:17:23 +00:00
committed by intellij-monorepo-bot
parent 8461ecdd09
commit 9c8e2379be
7 changed files with 137 additions and 0 deletions
@@ -0,0 +1,6 @@
class Plin {
public static void write(int startBitInUnit, int bitSize) {
<selection>startBitInUnit + bitSize > 0</selection>
}
}
@@ -0,0 +1,9 @@
class Plin {
public static void write(int startBitInUnit, int bitSize) {
if (startBitInUnit + bitSize > 0) {
<caret>
} else {
}
}
}
@@ -0,0 +1,31 @@
class External {
private int member;
External() {
member = 0;
}
void testMethod(int param1, int param2) {
int local1 = 0;
int local2 = 123;
int local3 = local1;
{
int innerLocal1 = 0;
int innerLocal2 = 7;
int innerLocal3 = 0;
int innerLocal4 = 7;
String incorrect;
<selection><caret>int insideRunnable1 = param1 + ((++innerLocal2) << param2);
param2 = local1 * insideRunnable1;
local3 = param2;
int insideRunnable2 = local2;
innerLocal1--;
--innerLocal3;
innerLocal4++;
incorrect = "misplaced initialization";</selection>
local2 = local3;
}
}
}
@@ -0,0 +1,35 @@
class External {
private int member;
External() {
member = 0;
}
void testMethod(final int param1, int param2) {
final int local1 = 0;
int local2 = 123;
int local3 = local1;
{
int innerLocal1 = 0;
int innerLocal2 = 7;
int innerLocal3 = 0;
int innerLocal4 = 7;
String incorrect;
<caret>Runnable runnable = new Runnable() {
public void run() {
int insideRunnable1 = param1 + ((++innerLocal2) << param2);
param2 = local1 * insideRunnable1;
local3 = param2;
int insideRunnable2 = local2;
innerLocal1--;
--innerLocal3;
innerLocal4++;
incorrect = "misplaced initialization";
}
};
local2 = local3;
}
}
}
@@ -0,0 +1,5 @@
class A{
void foo(){
<selection> f();
</selection> }
}
@@ -0,0 +1,9 @@
class A{
void foo(){
try {
f();
} catch (Exception e) {
<selection>throw new RuntimeException(e);</selection>
}
}
}
@@ -0,0 +1,42 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInsight;
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.generation.surroundWith.JavaWithIfElseExpressionSurrounder;
import com.intellij.codeInsight.generation.surroundWith.JavaWithRunnableSurrounder;
import com.intellij.codeInsight.generation.surroundWith.JavaWithTryCatchSurrounder;
import com.intellij.codeInsight.generation.surroundWith.SurroundWithHandler;
import com.intellij.lang.surroundWith.Surrounder;
import com.intellij.testFramework.LightJavaCodeInsightTestCase;
import org.jetbrains.annotations.NotNull;
public class JavaSurroundWithTest extends LightJavaCodeInsightTestCase {
@Override
protected @NotNull String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
}
public void testTryCatch1() {
doTest(new JavaWithTryCatchSurrounder());
}
public void testRunnable() {
doTest(new JavaWithRunnableSurrounder());
}
public void testBlockedByPSI() {
doTest(new JavaWithIfElseExpressionSurrounder());
}
private void doTest(Surrounder handler) {
String baseName = getBaseName();
configureByFile(baseName + "." + "java");
SurroundWithHandler.invoke(getProject(), getEditor(), getFile(), handler);
checkResultByFile(baseName + "_after." + "java");
}
private String getBaseName() {
return "/codeInsight/surroundWith/" + getTestName(false);
}
}