mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
a test for IDEA-116706 Unselect word at caret doesn't work reversing through lambdarized anonymous class
This commit is contained in:
@@ -19,6 +19,7 @@ package com.intellij.codeInsight.folding;
|
||||
import com.intellij.codeInsight.folding.impl.CodeFoldingManagerImpl
|
||||
import com.intellij.codeInsight.folding.impl.JavaCodeFoldingSettingsImpl
|
||||
import com.intellij.find.FindManager
|
||||
import com.intellij.openapi.actionSystem.IdeActions
|
||||
import com.intellij.openapi.application.ex.PathManagerEx
|
||||
import com.intellij.openapi.editor.FoldRegion
|
||||
import com.intellij.openapi.editor.ex.FoldingModelEx
|
||||
@@ -35,10 +36,10 @@ import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
* @since 1/17/11 1:00 PM
|
||||
*/
|
||||
public class JavaFoldingTest extends LightCodeInsightFixtureTestCase {
|
||||
|
||||
|
||||
def JavaCodeFoldingSettingsImpl myFoldingSettings
|
||||
def JavaCodeFoldingSettingsImpl myFoldingStateToRestore
|
||||
|
||||
|
||||
@Override
|
||||
public void setUp() {
|
||||
super.setUp()
|
||||
@@ -65,7 +66,7 @@ import java.util.Map;
|
||||
|
||||
class Foo { List a; Map b; }
|
||||
"""
|
||||
|
||||
|
||||
assert myFixture.editor.foldingModel.getCollapsedRegionAtOffset(10)
|
||||
|
||||
myFixture.type 'import '
|
||||
@@ -118,25 +119,25 @@ class Test {
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
configure text
|
||||
def foldingModel = myFixture.editor.foldingModel as FoldingModelImpl
|
||||
def closureStartFold = foldingModel.getCollapsedRegionAtOffset(text.indexOf("Runnable"))
|
||||
assertNotNull closureStartFold
|
||||
assertFalse closureStartFold.expanded
|
||||
|
||||
|
||||
assertNotNull closureStartFold.group
|
||||
def closureFolds = foldingModel.getGroupedRegions(closureStartFold.group)
|
||||
assertNotNull closureFolds
|
||||
assertEquals(2, closureFolds.size())
|
||||
|
||||
|
||||
def closureEndFold = closureFolds.get(1)
|
||||
assertFalse closureEndFold.expanded
|
||||
|
||||
|
||||
myFixture.editor.caretModel.moveToOffset(closureEndFold.startOffset + 1)
|
||||
assertTrue closureStartFold.expanded
|
||||
assertTrue closureEndFold.expanded
|
||||
|
||||
|
||||
changeFoldRegions { closureStartFold.expanded = false }
|
||||
assertTrue closureStartFold.expanded
|
||||
assertTrue closureEndFold.expanded
|
||||
@@ -172,7 +173,7 @@ class Test {
|
||||
assertNotNull closureFolds
|
||||
assertEquals(2, closureFolds.size())
|
||||
}
|
||||
|
||||
|
||||
public void "test builder style setter"() {
|
||||
myFoldingSettings.COLLAPSE_ACCESSORS = true
|
||||
def text = """\
|
||||
@@ -379,22 +380,22 @@ class Test {
|
||||
FindManager.getInstance(project).findNextUsageInEditor(TextEditorProvider.getInstance().getTextEditor(myFixture.editor))
|
||||
assertEquals('test1', myFixture.editor.selectionModel.selectedText)
|
||||
}
|
||||
|
||||
|
||||
public void testCustomFolding() {
|
||||
myFixture.testFolding("$PathManagerEx.testDataPath/codeInsight/folding/${getTestName(false)}.java");
|
||||
}
|
||||
|
||||
|
||||
public void "test move methods"() {
|
||||
def initialText = '''\
|
||||
class Test {
|
||||
void test1() {
|
||||
}
|
||||
|
||||
|
||||
void test2() {
|
||||
}
|
||||
}
|
||||
'''
|
||||
|
||||
|
||||
Closure<FoldRegion> fold = { String methodName ->
|
||||
def text = myFixture.editor.document.text
|
||||
def nameIndex = text.indexOf(methodName)
|
||||
@@ -444,7 +445,7 @@ class Test {
|
||||
assertEquals(2, folds[0].startOffset)
|
||||
assertEquals(6, folds[0].endOffset)
|
||||
}
|
||||
|
||||
|
||||
private def configure(String text) {
|
||||
myFixture.configureByText("a.java", text)
|
||||
CodeFoldingManagerImpl.getInstance(getProject()).buildInitialFoldings(myFixture.editor);
|
||||
@@ -458,21 +459,21 @@ class Test {
|
||||
int field;
|
||||
int field2;
|
||||
int field3;
|
||||
|
||||
|
||||
int getField()
|
||||
{
|
||||
return field;
|
||||
}
|
||||
|
||||
|
||||
void setField(int f) {
|
||||
field = f;
|
||||
}
|
||||
|
||||
|
||||
void setField2(int f){field2=f;} // normal method folding here
|
||||
|
||||
// normal method folding here
|
||||
void setField3(int f){
|
||||
|
||||
|
||||
field2=f;
|
||||
}
|
||||
|
||||
@@ -480,10 +481,10 @@ class Test {
|
||||
PsiClass fooClass = JavaPsiFacade.getInstance(project).findClass('Foo', GlobalSearchScope.allScope(project))
|
||||
def regions = myFixture.editor.foldingModel.allFoldRegions.sort { it.startOffset }
|
||||
assert regions.size() == 6
|
||||
|
||||
|
||||
checkAccessorFolding(regions[0], regions[1], fooClass.methods[0])
|
||||
checkAccessorFolding(regions[2], regions[3], fooClass.methods[1])
|
||||
|
||||
|
||||
assert regions[4].placeholderText == '{...}'
|
||||
assert regions[5].placeholderText == '{...}'
|
||||
}
|
||||
@@ -504,7 +505,7 @@ class Test {
|
||||
int someMethod() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}"""
|
||||
PsiClass fooClass = JavaPsiFacade.getInstance(project).findClass('Foo', GlobalSearchScope.allScope(project))
|
||||
def regions = myFixture.editor.foldingModel.allFoldRegions.sort { it.startOffset }
|
||||
@@ -516,7 +517,7 @@ class Test {
|
||||
configure """class Foo {
|
||||
int someVeryVeryLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongVariable;
|
||||
|
||||
// don't create folding that would exceed the right margin
|
||||
// don't create folding that would exceed the right margin
|
||||
int getSomeVeryVeryLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongVariable() {
|
||||
return someVeryVeryLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongVariable;
|
||||
}
|
||||
@@ -529,4 +530,18 @@ class Test {
|
||||
private def changeFoldRegions(Closure op) {
|
||||
myFixture.editor.foldingModel.runBatchFoldingOperationDoNotCollapseCaret(op)
|
||||
}
|
||||
|
||||
public void "test unselect word should go inside folding group"() {
|
||||
configure """class Foo {
|
||||
int field;
|
||||
|
||||
<selection>int getField() {
|
||||
<caret>return field;
|
||||
}</selection>
|
||||
|
||||
}"""
|
||||
assertSize 2, myFixture.editor.foldingModel.allFoldRegions
|
||||
myFixture.performEditorAction(IdeActions.ACTION_EDITOR_UNSELECT_WORD_AT_CARET)
|
||||
assert 'return field;' == myFixture.editor.selectionModel.selectedText
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user