test utility method CodeInsightSettings.runWithTemporarySettings

GitOrigin-RevId: aed6faffba4f7647ee797a59cbf0d7c6d8bfecb8
This commit is contained in:
Alexey Kudravtsev
2025-04-23 13:48:20 +00:00
committed by intellij-monorepo-bot
parent f5f079e49a
commit d00fbe19cf
15 changed files with 120 additions and 221 deletions
@@ -106,15 +106,11 @@ public class JavaEditingTest extends AbstractBasicJavaEditingTest {
}
public void testSmartIndentOnEnterWithinNonLastStatement() {
CodeInsightSettings settings = CodeInsightSettings.getInstance();
boolean oldValue = settings.SMART_INDENT_ON_ENTER;
settings.SMART_INDENT_ON_ENTER = true;
try {
CodeInsightSettings.runWithTemporarySettings(settings -> {
settings.SMART_INDENT_ON_ENTER = true;
doTest(JavaFileType.INSTANCE, '\n');
}
finally {
settings.SMART_INDENT_ON_ENTER = oldValue;
}
return null;
});
}
public void testEmacsTabWithSelection() {
@@ -10,11 +10,10 @@ import com.intellij.openapi.ide.CopyPasteManager;
import com.intellij.psi.PsiFile;
import com.intellij.testFramework.LightProjectDescriptor;
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase;
import com.intellij.util.ThrowableRunnable;
import org.jetbrains.annotations.NotNull;
public class CopyReferenceActionTest extends LightJavaCodeInsightFixtureTestCase {
private int oldSetting;
@NotNull
@Override
protected LightProjectDescriptor getProjectDescriptor() {
@@ -27,25 +26,12 @@ public class CopyReferenceActionTest extends LightJavaCodeInsightFixtureTestCase
}
@Override
protected void setUp() throws Exception {
super.setUp();
CodeInsightSettings settings = CodeInsightSettings.getInstance();
oldSetting = settings.ADD_IMPORTS_ON_PASTE;
settings.ADD_IMPORTS_ON_PASTE = CodeInsightSettings.YES;
}
@Override
protected void tearDown() throws Exception {
try {
CodeInsightSettings settings = CodeInsightSettings.getInstance();
settings.ADD_IMPORTS_ON_PASTE = oldSetting;
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
protected void runTestRunnable(@NotNull ThrowableRunnable<Throwable> testRunnable) throws Throwable {
CodeInsightSettings.runWithTemporarySettings(settings -> {
settings.ADD_IMPORTS_ON_PASTE = CodeInsightSettings.YES;
super.runTestRunnable(testRunnable);
return null;
});
}
public void testConstructor() { doTest(); }
@@ -35,9 +35,8 @@ public class OptimizeImportsMultiFileTest extends JavaPsiTestCase {
}
public void testOptimizeImportsMustAddUnambiguousImportsIfTheCorrespondingSettingIsOn() throws Exception {
boolean importsOnTheFly = CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY;
CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = true;
try {
CodeInsightSettings.runWithTemporarySettings(settings -> {
settings.ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = true;
VirtualFile root = createTestProjectStructure(OptimizeImportsTest.BASE_PATH + "/src1", false);
PsiTestUtil.addSourceRoot(getModule(), root);
PsiDirectory directory = myPsiManager.findDirectory(root);
@@ -52,16 +51,13 @@ public class OptimizeImportsMultiFileTest extends JavaPsiTestCase {
assertTrue(text1After, text1After.contains("import java.util.ArrayList;"));
String text2After = VfsUtilCore.loadText(root.findFileByRelativePath("p/X2.java"));
assertTrue(text2After, text2After.contains("import java.util.ArrayList;"));
}
finally {
CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = importsOnTheFly;
}
return null;
});
}
public void testOptimizeImportsMustNotAddUnambiguousImportsIfTheCorrespondingSettingIsOff() throws Exception {
boolean importsOnTheFly = CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY;
CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = false;
try {
CodeInsightSettings.runWithTemporarySettings(settings -> {
settings.ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = false;
VirtualFile root = createTestProjectStructure(OptimizeImportsTest.BASE_PATH + "/src1", false);
PsiTestUtil.addSourceRoot(getModule(), root);
PsiDirectory directory = myPsiManager.findDirectory(root);
@@ -76,9 +72,7 @@ public class OptimizeImportsMultiFileTest extends JavaPsiTestCase {
assertFalse(text1After, text1After.contains("import java.util.ArrayList;"));
String text2After = VfsUtilCore.loadText(root.findFileByRelativePath("p/X2.java"));
assertFalse(text2After, text2After.contains("import java.util.ArrayList;"));
}
finally {
CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = importsOnTheFly;
}
return null;
});
}
}
@@ -349,36 +349,24 @@ public class JavaEnterActionTest extends AbstractBasicJavaEnterActionTest {
}
public void testNoCloseJavaDocComment() {
CodeInsightSettings settings = CodeInsightSettings.getInstance();
boolean old = settings.CLOSE_COMMENT_ON_ENTER;
settings.CLOSE_COMMENT_ON_ENTER = false;
try {
CodeInsightSettings.runWithTemporarySettings(settings -> {
settings.CLOSE_COMMENT_ON_ENTER = false;
doTextTest("java",
"/**<caret>",
"/**\n <caret>");
}
finally {
settings.CLOSE_COMMENT_ON_ENTER = old;
}
return null;
});
}
public void testNoSmartIndentInJavadoc() {
CodeInsightSettings settings = CodeInsightSettings.getInstance();
boolean indent = settings.SMART_INDENT_ON_ENTER;
settings.SMART_INDENT_ON_ENTER = false;
boolean stub = settings.JAVADOC_STUB_ON_ENTER;
settings.JAVADOC_STUB_ON_ENTER = false;
try {
CodeInsightSettings.runWithTemporarySettings(settings -> {
settings.SMART_INDENT_ON_ENTER = false;
settings.JAVADOC_STUB_ON_ENTER = false;
configureByFile("/codeInsight/enterAction/settings/NoJavadocStub.java");
performAction();
checkResultByFile(null, "/codeInsight/enterAction/settings/NoJavadocStub_after.java", true); // side effect...
}
finally {
settings.SMART_INDENT_ON_ENTER = indent;
settings.JAVADOC_STUB_ON_ENTER = stub;
}
return null;
});
}
public void testLineCommentAtTrailingSpaces() {
@@ -390,18 +378,13 @@ public class JavaEnterActionTest extends AbstractBasicJavaEnterActionTest {
}
public void testNoJavadocStub() {
CodeInsightSettings settings = CodeInsightSettings.getInstance();
boolean old = settings.JAVADOC_STUB_ON_ENTER;
settings.JAVADOC_STUB_ON_ENTER = false;
try {
CodeInsightSettings.runWithTemporarySettings(settings -> {
settings.JAVADOC_STUB_ON_ENTER = false;
configureByFile("/codeInsight/enterAction/settings/NoJavadocStub.java");
performAction();
checkResultByFile("/codeInsight/enterAction/settings/NoJavadocStub_after.java");
}
finally {
settings.JAVADOC_STUB_ON_ENTER = old;
}
return null;
});
}
@@ -1000,11 +1000,10 @@ public class JavaFoldingTest extends JavaFoldingTestCase {
}
public void test_imports_remain_collapsed_when_new_item_is_added_at_the_end() {
boolean oldValue = CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY;
CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = true;
DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true);// tests disable this by default
((CodeInsightTestFixtureImpl)myFixture).canChangeDocumentDuringHighlighting(true);
try {
CodeInsightSettings.runWithTemporarySettings(settings -> {
settings.ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = true;
DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true);// tests disable this by default
((CodeInsightTestFixtureImpl)myFixture).canChangeDocumentDuringHighlighting(true);
configure("""
import java.util.ArrayList;
import java.util.List;
@@ -1034,10 +1033,8 @@ public class JavaFoldingTest extends JavaFoldingTestCase {
}""");
myFixture.doHighlighting();// update folding for the new text
assertTopLevelFoldRegionsState("[FoldRegion +(7:76), placeholder='...']");
}
finally {
CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = oldValue;
}
return null;
});
}
public void testGroupedFoldingsAreNotUpdatedOnUnrelatedDocumentChange() {
@@ -171,6 +171,7 @@ c:com.intellij.codeInsight.CodeInsightSettings
- isSelectAutopopupSuggestionsByChars():Z
- loadState(org.jdom.Element):V
- noStateLoaded():V
- s:runWithTemporarySettings(com.intellij.util.ThrowableConvertor):java.lang.Object
- setBackspaceMode(com.intellij.codeInsight.editorActions.SmartBackspaceMode):V
- setCompletionCaseSensitive(I):V
- setSelectAutopopupSuggestionsByChars(Z):V
@@ -16,6 +16,7 @@ import com.intellij.openapi.util.Disposer;
import com.intellij.serialization.SerializationException;
import com.intellij.util.ArrayUtilRt;
import com.intellij.util.ReflectionUtil;
import com.intellij.util.ThrowableConvertor;
import com.intellij.util.xmlb.annotations.OptionTag;
import com.intellij.util.xmlb.annotations.Property;
import com.intellij.util.xmlb.annotations.Transient;
@@ -24,6 +25,7 @@ import org.intellij.lang.annotations.MagicConstant;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -242,4 +244,28 @@ public class CodeInsightSettings implements PersistentStateComponent<Element>, C
if (o == null || getClass() != o.getClass()) return false;
return ReflectionUtil.comparePublicNonFinalFields(this, o);
}
/**
* Run the {@code consumer} with the current {@link CodeInsightSettings} and then restore them to the state before this method call.
* Useful for running the tests with custom code insight settings, like this:
* <pre>
* runWithTemporarySettings(settings -> {
* settings.MY_SETTING_TO_TEST = newValue;
* settings.OTHER_SETTING_TO_TEST = newValue2;
* doTest();
* });
* </pre>
* This will run {@code doTest()} with some settings changed, and then restore them automatically when the test finished.
*/
@TestOnly
public static <T, E extends Throwable> T runWithTemporarySettings(@NotNull ThrowableConvertor<? super CodeInsightSettings, ? extends T, E> consumer) throws E {
CodeInsightSettings settings = getInstance();
Element temp = settings.getState();
try {
return consumer.convert(settings);
}
finally {
settings.loadState(temp);
}
}
}
@@ -51,15 +51,12 @@ public class SimpleIndentingBackspaceHandlerTest extends LightPlatformCodeInsigh
}
private void doTest(String before, String after) {
SmartBackspaceMode savedMode = CodeInsightSettings.getInstance().getBackspaceMode();
try {
CodeInsightSettings.getInstance().setBackspaceMode(SmartBackspaceMode.INDENT);
CodeInsightSettings.runWithTemporarySettings(settings -> {
settings.setBackspaceMode(SmartBackspaceMode.INDENT);
configureFromFileText(getTestName(false) + ".txt", before);
executeAction(IdeActions.ACTION_EDITOR_BACKSPACE);
checkResultByText(after);
}
finally {
CodeInsightSettings.getInstance().setBackspaceMode(savedMode);
}
return null;
});
}
}
@@ -10,12 +10,10 @@ import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.fileTypes.FileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.testFramework.fixtures.BasePlatformTestCase;
import com.intellij.util.ThrowableRunnable;
import org.jetbrains.annotations.NotNull;
public class SelectionQuotingTypedHandlerTest extends BasePlatformTestCase {
private boolean myPrevValue;
/**
* Performs an action as write action
*
@@ -27,23 +25,12 @@ public class SelectionQuotingTypedHandlerTest extends BasePlatformTestCase {
}
@Override
protected void setUp() throws Exception {
super.setUp();
myPrevValue = CodeInsightSettings.getInstance().SURROUND_SELECTION_ON_QUOTE_TYPED;
CodeInsightSettings.getInstance().SURROUND_SELECTION_ON_QUOTE_TYPED = true;
}
@Override
protected void tearDown() throws Exception {
try {
CodeInsightSettings.getInstance().SURROUND_SELECTION_ON_QUOTE_TYPED = myPrevValue;
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
protected void runTestRunnable(@NotNull ThrowableRunnable<Throwable> testRunnable) throws Throwable {
CodeInsightSettings.runWithTemporarySettings(settings -> {
settings.SURROUND_SELECTION_ON_QUOTE_TYPED = true;
super.runTestRunnable(testRunnable);
return null;
});
}
public void testWOSelection() {
@@ -64,10 +64,8 @@ public class PlainTextEditingTest extends EditingTestBase {
}
public void testCopyPasteWithoutUnnecessaryIndent() {
CodeInsightSettings settings = CodeInsightSettings.getInstance();
int oldValue = settings.REFORMAT_ON_PASTE;
settings.REFORMAT_ON_PASTE = CodeInsightSettings.INDENT_BLOCK;
try {
CodeInsightSettings.runWithTemporarySettings(settings -> {
settings.REFORMAT_ON_PASTE = CodeInsightSettings.INDENT_BLOCK;
doTest(PlainTextFileType.INSTANCE, () -> {
// Move caret to the non-zero column.
getEditor().getCaretModel().moveToOffset(3);
@@ -79,10 +77,8 @@ public class PlainTextEditingTest extends EditingTestBase {
copy();
paste();
});
}
finally {
settings.REFORMAT_ON_PASTE = oldValue;
}
return null;
});
}
public void testCamelHumpsSelectionAndDigits() {
@@ -228,15 +224,11 @@ public class PlainTextEditingTest extends EditingTestBase {
EditorEx editorEx = (EditorEx)getEditor();
editorEx.setStickySelection(true);
editorEx.getCaretModel().moveCaretRelatively(2, 0, false, false, false);
CodeInsightSettings settings = CodeInsightSettings.getInstance();
boolean oldValue = settings.SURROUND_SELECTION_ON_QUOTE_TYPED;
settings.SURROUND_SELECTION_ON_QUOTE_TYPED = true;
try {
CodeInsightSettings.runWithTemporarySettings(settings -> {
settings.SURROUND_SELECTION_ON_QUOTE_TYPED = true;
type('\'');
}
finally {
settings.SURROUND_SELECTION_ON_QUOTE_TYPED = oldValue;
}
return null;
});
checkResultByText("ab'<selection>cd</selection>'ef");
}
@@ -154,12 +154,9 @@ public class CustomFileTypeEditorTest extends BasePlatformTestCase {
}
public void testReplaceQuoteDontSurroundSelection() {
CodeInsightSettings settings = CodeInsightSettings.getInstance();
boolean oldValue = settings.SURROUND_SELECTION_ON_QUOTE_TYPED;
settings.SURROUND_SELECTION_ON_QUOTE_TYPED = false;
boolean oldValuePairQuote = settings.AUTOINSERT_PAIR_QUOTE;
settings.AUTOINSERT_PAIR_QUOTE = false;
try {
CodeInsightSettings.runWithTemporarySettings(settings -> {
settings.SURROUND_SELECTION_ON_QUOTE_TYPED = false;
settings.AUTOINSERT_PAIR_QUOTE = false;
checkTyping("a.cs", "<caret><selection>\"</selection>a\"", '\'', "'<caret>a\"");
checkTyping("a.cs", "<caret><selection>\"</selection>a'", '\'', "'<caret>a'");
checkTyping("a.cs", "\"a<caret><selection>\"</selection>", '\'', "\"a'<caret>");
@@ -169,18 +166,13 @@ public class CustomFileTypeEditorTest extends BasePlatformTestCase {
checkTyping("a.cs", "<caret><selection>'</selection>a'", '\"', "\"<caret>a'");
checkTyping("a.cs", "\"a<caret><selection>'</selection>", '\"', "\"a\"<caret>");
checkTyping("a.cs", "'a<caret><selection>'</selection>", '\"', "'a\"<caret>");
}
finally {
settings.SURROUND_SELECTION_ON_QUOTE_TYPED = oldValue;
settings.AUTOINSERT_PAIR_QUOTE = oldValuePairQuote;
}
return null;
});
}
public void testReplaceQuoteDontInsertPair() {
CodeInsightSettings settings = CodeInsightSettings.getInstance();
boolean oldValue = settings.AUTOINSERT_PAIR_QUOTE;
settings.AUTOINSERT_PAIR_QUOTE = false;
try {
CodeInsightSettings.runWithTemporarySettings(settings -> {
settings.AUTOINSERT_PAIR_QUOTE = false;
checkTyping("a.cs", "<caret><selection>\"</selection>a\"", '\'', "'<selection><caret>\"</selection>'a\"");
checkTyping("a.cs", "<caret><selection>\"</selection>a'", '\'', "'<selection><caret>\"</selection>'a'");
checkTyping("a.cs", "\"a<caret><selection>\"</selection>", '\'', "\"a'<selection><caret>\"</selection>'");
@@ -189,10 +181,8 @@ public class CustomFileTypeEditorTest extends BasePlatformTestCase {
checkTyping("a.cs", "<caret><selection>'</selection>a'", '\"', "\"<selection><caret>'</selection>\"a'");
checkTyping("a.cs", "\"a<caret><selection>'</selection>", '\"', "\"a\"<selection><caret>'</selection>\"");
checkTyping("a.cs", "'a<caret><selection>'</selection>", '\"', "'a\"<selection><caret>'</selection>\"");
}
finally {
settings.AUTOINSERT_PAIR_QUOTE = oldValue;
}
return null;
});
}
public void testReplaceQuote() {
@@ -16,27 +16,16 @@
package com.intellij.openapi.editor.actions;
import com.intellij.codeInsight.CodeInsightSettings;
import com.intellij.util.ThrowableRunnable;
import org.jetbrains.annotations.NotNull;
public class CopyActionSimpleHandlerTest extends CopyActionTest {
private int myPrevValue;
@Override
public void setUp() throws Exception {
super.setUp();
myPrevValue = CodeInsightSettings.getInstance().ADD_IMPORTS_ON_PASTE;
CodeInsightSettings.getInstance().ADD_IMPORTS_ON_PASTE = CodeInsightSettings.NO;
}
@Override
public void tearDown() throws Exception {
try {
CodeInsightSettings.getInstance().ADD_IMPORTS_ON_PASTE = myPrevValue;
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
protected void runTestRunnable(@NotNull ThrowableRunnable<Throwable> testRunnable) throws Throwable {
CodeInsightSettings.runWithTemporarySettings(settings -> {
settings.ADD_IMPORTS_ON_PASTE = CodeInsightSettings.NO;
super.runTestRunnable(testRunnable);
return null;
});
}
}
@@ -50,16 +50,10 @@ fun testCompletion(
fun testWithAutoCompleteSetting(fileText: String, doTest: () -> Unit) {
val autoComplete = ExpectedCompletionUtils.getAutocompleteSetting(fileText) ?: false
val settings = CodeInsightSettings.getInstance()
val oldValue1 = settings.AUTOCOMPLETE_ON_CODE_COMPLETION
val oldValue2 = settings.AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION
try {
CodeInsightSettings.runWithTemporarySettings<_,Error> { settings ->
settings.AUTOCOMPLETE_ON_CODE_COMPLETION = autoComplete
settings.AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION = autoComplete
doTest()
} finally {
settings.AUTOCOMPLETE_ON_CODE_COMPLETION = oldValue1
settings.AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION = oldValue2
}
}
@@ -4,30 +4,19 @@ package com.jetbrains.python;
import com.intellij.codeInsight.CodeInsightSettings;
import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.util.ThrowableRunnable;
import com.jetbrains.python.fixtures.PyTestCase;
import org.jetbrains.annotations.NotNull;
public class PyCopyPasteTest extends PyTestCase {
private boolean myOldEnabled;
@Override
public void setUp() throws Exception {
super.setUp();
myOldEnabled = CodeInsightSettings.getInstance().INDENT_TO_CARET_ON_PASTE;
CodeInsightSettings.getInstance().INDENT_TO_CARET_ON_PASTE = true;
}
@Override
public void tearDown() throws Exception {
try {
CodeInsightSettings.getInstance().INDENT_TO_CARET_ON_PASTE = myOldEnabled;
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
protected void runTestRunnable(@NotNull ThrowableRunnable<Throwable> testRunnable) throws Throwable {
CodeInsightSettings.runWithTemporarySettings(settings -> {
settings.INDENT_TO_CARET_ON_PASTE = true;
super.runTestRunnable(testRunnable);
return null;
});
}
public void testIndent1() {
@@ -23,11 +23,21 @@ import com.intellij.ide.highlighter.XmlFileType;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.formatter.xml.HtmlCodeStyleSettings;
import com.intellij.testFramework.fixtures.BasePlatformTestCase;
import com.intellij.util.ThrowableRunnable;
import org.jetbrains.annotations.NotNull;
/**
* @author Dmitry Avdeev
*/
public class XmlTypedHandlersTest extends BasePlatformTestCase {
@Override
protected void runTestRunnable(@NotNull ThrowableRunnable<Throwable> testRunnable) throws Throwable {
CodeInsightSettings.runWithTemporarySettings(settings -> {
super.runTestRunnable(testRunnable);
return null;
});
}
public void testClosingTag() {
doTest("<foo><<caret>", '/', "<foo></foo>");
}
@@ -201,77 +211,45 @@ public class XmlTypedHandlersTest extends BasePlatformTestCase {
}
public void testSelectionBraces() {
boolean surround = CodeInsightSettings.getInstance().SURROUND_SELECTION_ON_QUOTE_TYPED;
try {
CodeInsightSettings.getInstance().SURROUND_SELECTION_ON_QUOTE_TYPED = true;
doTest("<selection><div></div></selection>",
'(',
"(<div></div>)");
} finally {
CodeInsightSettings.getInstance().SURROUND_SELECTION_ON_QUOTE_TYPED = surround;
}
}
public void testSelectionBracesInner() {
boolean surround = CodeInsightSettings.getInstance().SURROUND_SELECTION_ON_QUOTE_TYPED;
try {
CodeInsightSettings.getInstance().SURROUND_SELECTION_ON_QUOTE_TYPED = true;
doTest("<div><selection><div></div></selection></div>",
'(',
"<div>(<div></div>)</div>");
} finally {
CodeInsightSettings.getInstance().SURROUND_SELECTION_ON_QUOTE_TYPED = surround;
}
}
public void testSelectionBracesStart() {
boolean surround = CodeInsightSettings.getInstance().SURROUND_SELECTION_ON_QUOTE_TYPED;
try {
CodeInsightSettings.getInstance().SURROUND_SELECTION_ON_QUOTE_TYPED = true;
doTest("<selection><div></selection></div>",
'(',
"(<div>)</div>");
} finally {
CodeInsightSettings.getInstance().SURROUND_SELECTION_ON_QUOTE_TYPED = surround;
}
}
public void testSelectionBracesEnd() {
boolean surround = CodeInsightSettings.getInstance().SURROUND_SELECTION_ON_QUOTE_TYPED;
try {
CodeInsightSettings.getInstance().SURROUND_SELECTION_ON_QUOTE_TYPED = true;
doTest("<div><selection></div></selection>",
'(',
"<div>(</div>)");
} finally {
CodeInsightSettings.getInstance().SURROUND_SELECTION_ON_QUOTE_TYPED = surround;
}
}
public void testSelectionBracesShort() {
boolean surround = CodeInsightSettings.getInstance().SURROUND_SELECTION_ON_QUOTE_TYPED;
try {
CodeInsightSettings.getInstance().SURROUND_SELECTION_ON_QUOTE_TYPED = true;
doTest("<selection><div/></selection>",
'(',
"(<div/>)");
}
finally {
CodeInsightSettings.getInstance().SURROUND_SELECTION_ON_QUOTE_TYPED = surround;
}
}
public void testSelectionBracesShortInner() {
boolean surround = CodeInsightSettings.getInstance().SURROUND_SELECTION_ON_QUOTE_TYPED;
try {
CodeInsightSettings.getInstance().SURROUND_SELECTION_ON_QUOTE_TYPED = true;
doTest("<div><selection><div/></selection></div>",
'(',
"<div>(<div/>)</div>");
}
finally {
CodeInsightSettings.getInstance().SURROUND_SELECTION_ON_QUOTE_TYPED = surround;
}
}
public void testTagClosing() {