mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-26 19:06:24 +07:00
Creating indent by CodeStyleManager.adjustLineIndent when surrounding with try-finally (IDEA-128859)
This commit is contained in:
+5
@@ -0,0 +1,5 @@
|
||||
class Test {
|
||||
void test() {
|
||||
<selection> int a = 2;</selection>
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Test {
|
||||
void test() {
|
||||
try {
|
||||
int a = 2;
|
||||
} finally {
|
||||
<caret>
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
@@ -17,6 +17,7 @@ package com.intellij.codeInsight.generation.surroundWith;
|
||||
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
import com.intellij.ide.highlighter.JavaFileType;
|
||||
import com.intellij.lang.LanguageSurrounders;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.lang.surroundWith.SurroundDescriptor;
|
||||
@@ -24,6 +25,7 @@ import com.intellij.lang.surroundWith.Surrounder;
|
||||
import com.intellij.openapi.editor.SelectionModel;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -156,6 +158,18 @@ public class JavaSurroundWithTest extends LightCodeInsightTestCase {
|
||||
doTest(getTestName(false), new JavaWithIfElseExpressionSurrounder());
|
||||
}
|
||||
|
||||
public void testSurroundWithTryFinallyUsingIndents() {
|
||||
CommonCodeStyleSettings.IndentOptions indentOptions = getCurrentCodeStyleSettings().getIndentOptions(JavaFileType.INSTANCE);
|
||||
boolean oldUseTabs = indentOptions.USE_TAB_CHARACTER;
|
||||
try {
|
||||
indentOptions.USE_TAB_CHARACTER = true;
|
||||
doTest(getTestName(false), new JavaWithTryFinallySurrounder());
|
||||
}
|
||||
finally {
|
||||
indentOptions.USE_TAB_CHARACTER = oldUseTabs;
|
||||
}
|
||||
}
|
||||
|
||||
private void doTest(@NotNull String fileName, final Surrounder surrounder) {
|
||||
configureByFile(BASE_PATH + fileName + ".java");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user