diff --git a/compiler/tests/org/jetbrains/jet/jsonUtils.kt b/compiler/tests/org/jetbrains/jet/jsonUtils.kt new file mode 100644 index 00000000000..20773019960 --- /dev/null +++ b/compiler/tests/org/jetbrains/jet/jsonUtils.kt @@ -0,0 +1,30 @@ +/* + * Copyright 2010-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet + +import com.google.gson.JsonObject + +fun JsonObject.getString(name: String): String { + val member = getNullableString(name) + if (member == null) { + throw IllegalStateException("Member with name '$name' is expected in '$this'") + } + + return member +} + +fun JsonObject.getNullableString(name: String): String? = this[name]?.getAsString() \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/plugin/refactoring/move/AbstractJetMoveTest.kt b/idea/tests/org/jetbrains/jet/plugin/refactoring/move/AbstractJetMoveTest.kt index b39a46b25a4..1868317d4a6 100644 --- a/idea/tests/org/jetbrains/jet/plugin/refactoring/move/AbstractJetMoveTest.kt +++ b/idea/tests/org/jetbrains/jet/plugin/refactoring/move/AbstractJetMoveTest.kt @@ -49,6 +49,8 @@ import com.intellij.psi.PsiFile import com.intellij.psi.PsiManager import com.intellij.refactoring.move.moveFilesOrDirectories.MoveFilesOrDirectoriesProcessor import com.intellij.refactoring.move.MoveHandler +import org.jetbrains.jet.getString +import org.jetbrains.jet.getNullableString public abstract class AbstractJetMoveTest : MultiFileTestCase() { protected fun doTest(path: String) { @@ -127,17 +129,6 @@ public abstract class AbstractJetMoveTest : MultiFileTestCase() { } } -fun JsonObject.getString(name: String): String { - val member = getNullableString(name) - if (member == null) { - throw IllegalStateException("Member with name '$name' is expected in '$this'") - } - - return member -} - -fun JsonObject.getNullableString(name: String): String? = this[name]?.getAsString() - enum class MoveAction { MOVE_MEMBERS { override fun runRefactoring(rootDir: VirtualFile, mainFile: PsiFile, elementAtCaret: PsiElement?, config: JsonObject) { diff --git a/idea/tests/org/jetbrains/jet/plugin/refactoring/rename/AbstractRenameTest.kt b/idea/tests/org/jetbrains/jet/plugin/refactoring/rename/AbstractRenameTest.kt index 6e235670f5a..e0eb6dfd7ad 100644 --- a/idea/tests/org/jetbrains/jet/plugin/refactoring/rename/AbstractRenameTest.kt +++ b/idea/tests/org/jetbrains/jet/plugin/refactoring/rename/AbstractRenameTest.kt @@ -35,7 +35,6 @@ import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.JavaPsiFacade import com.intellij.openapi.project.Project import com.intellij.openapi.module.Module -import org.jetbrains.jet.lang.resolve.name.FqName import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache import org.jetbrains.jet.lang.resolve.BindingContext import java.util.Collections @@ -45,6 +44,8 @@ import org.jetbrains.jet.lang.descriptors.ClassDescriptor import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe import org.jetbrains.jet.lang.resolve.name.isSubpackageOf +import org.jetbrains.jet.getString +import org.jetbrains.jet.getNullableString private enum class RenameType { JAVA_CLASS @@ -55,17 +56,6 @@ private enum class RenameType { KOTLIN_PACKAGE } -fun JsonObject.getString(name: String): String { - val member = getNullableString(name) - if (member == null) { - throw IllegalStateException("Member with name '$name' is expected in '$this'") - } - - return member -} - -fun JsonObject.getNullableString(name: String): String? = this[name]?.getAsString() - public abstract class AbstractRenameTest : MultiFileTestCase() { inner class TestContext( val project: Project = getProject()!!,