Check that removing open brace is out-of-block change

This commit is contained in:
Nikolay Krasko
2014-10-22 17:20:39 +04:00
parent 798a6bf689
commit 1a7fd756e5
3 changed files with 22 additions and 1 deletions
@@ -0,0 +1,6 @@
// TRUE
fun test() {<caret>
}
// TYPE: \b
@@ -17,10 +17,12 @@
package org.jetbrains.jet.plugin.codeInsight;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiManager;
import com.intellij.psi.impl.PsiModificationTrackerImpl;
import org.jetbrains.jet.InTextDirectivesUtils;
import org.jetbrains.jet.plugin.JetLightCodeInsightFixtureTestCase;
import org.jetbrains.jet.plugin.PluginTestCaseBase;
@@ -53,7 +55,7 @@ public abstract class AbstractOutOfBlockModificationTest extends JetLightCodeIns
long oobBeforeType = tracker.getOutOfCodeBlockModificationCount();
long modificationCountBeforeType = tracker.getModificationCount();
myFixture.type('a');
myFixture.type(getStringToType());
PsiDocumentManager.getInstance(myFixture.getProject()).commitDocument(myFixture.getDocument(myFixture.getFile()));
long oobAfterCount = tracker.getOutOfCodeBlockModificationCount();
@@ -65,6 +67,13 @@ public abstract class AbstractOutOfBlockModificationTest extends JetLightCodeIns
expectedOutOfBlock, oobBeforeType != oobAfterCount);
}
private String getStringToType() {
String text = myFixture.getDocument(myFixture.getFile()).getText();
String typeDirectives = InTextDirectivesUtils.findStringWithPrefixes(text, "TYPE:");
return typeDirectives != null ? StringUtil.unescapeStringCharacters(typeDirectives) : "a";
}
private boolean getExpectedOutOfBlockResult() {
String text = myFixture.getDocument(myFixture.getFile()).getText();
@@ -60,6 +60,12 @@ public class OutOfBlockModificationTestGenerated extends AbstractOutOfBlockModif
doTest(fileName);
}
@TestMetadata("FunNoType_Block.kt")
public void testFunNoType_Block() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/codeInsight/outOfBlock/FunNoType_Block.kt");
doTest(fileName);
}
@TestMetadata("FunNoType_Block_Class.kt")
public void testFunNoType_Block_Class() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/codeInsight/outOfBlock/FunNoType_Block_Class.kt");