Convert to Kotlin: AbstractSmartSelectionTest

This commit is contained in:
Alexey Sedunov
2016-08-31 15:01:36 +03:00
parent 1ab40f6d88
commit b0a1eca1ce
@@ -14,39 +14,23 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.kotlin.idea; package org.jetbrains.kotlin.idea
import com.intellij.openapi.util.text.StringUtil; import com.intellij.testFramework.LightCodeInsightTestCase
import com.intellij.testFramework.LightCodeInsightTestCase; import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils
import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.idea.refactoring.getExpressionShortText
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils; import org.jetbrains.kotlin.idea.refactoring.getSmartSelectSuggestions
import org.jetbrains.kotlin.idea.refactoring.ElementSelectionUtilsKt; import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtElement; import org.jetbrains.kotlin.test.KotlinTestUtils
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import java.util.ArrayList; abstract class AbstractSmartSelectionTest : LightCodeInsightTestCase() {
import java.util.List; fun doTestSmartSelection(path: String) {
configureByFile(path)
public abstract class AbstractSmartSelectionTest extends LightCodeInsightTestCase { val expectedResultText = KotlinTestUtils.getLastCommentInFile(getFile() as KtFile)
val elements = getSmartSelectSuggestions(getFile(), getEditor().caretModel.offset, CodeInsightUtils.ElementKind.EXPRESSION)
public void doTestSmartSelection(@NotNull String path) throws Exception { assertEquals(expectedResultText, elements.joinToString(separator = "\n", transform = ::getExpressionShortText))
configureByFile(path);
String expectedResultText = KotlinTestUtils.getLastCommentInFile((KtFile) getFile());
List<KtElement> elements = ElementSelectionUtilsKt.getSmartSelectSuggestions(
getFile(), getEditor().getCaretModel().getOffset(), CodeInsightUtils.ElementKind.EXPRESSION);
List<String> textualExpressions = new ArrayList<String>();
for (KtElement element : elements) {
textualExpressions.add(ElementSelectionUtilsKt.getExpressionShortText(element));
}
assertEquals(expectedResultText, StringUtil.join(textualExpressions, "\n"));
} }
@NotNull override fun getTestDataPath() = ""
@Override
protected String getTestDataPath() {
return "";
}
} }