Add base test KotlinMultiFileTestCase with access root disable
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2010-2015 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.kotlin.idea
|
||||
|
||||
import com.intellij.refactoring.MultiFileTestCase
|
||||
import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess
|
||||
import org.jetbrains.kotlin.test.JetTestCaseBuilder
|
||||
|
||||
public abstract class KotlinMultiFileTestCase : MultiFileTestCase() {
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
VfsRootAccess.allowRootAccess(JetTestCaseBuilder.getHomeDirectory())
|
||||
}
|
||||
|
||||
override fun tearDown() {
|
||||
VfsRootAccess.disallowRootAccess(JetTestCaseBuilder.getHomeDirectory())
|
||||
super.tearDown()
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.refactoring.MultiFileTestCase;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.sun.jdi.Location;
|
||||
import com.sun.jdi.ReferenceType;
|
||||
@@ -40,6 +39,7 @@ import org.jetbrains.kotlin.backend.common.output.OutputFile;
|
||||
import org.jetbrains.kotlin.backend.common.output.OutputFileCollection;
|
||||
import org.jetbrains.kotlin.codegen.GenerationUtils;
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState;
|
||||
import org.jetbrains.kotlin.idea.KotlinMultiFileTestCase;
|
||||
import org.jetbrains.kotlin.idea.PluginTestCaseBase;
|
||||
import org.jetbrains.kotlin.idea.project.PluginJetFilesProvider;
|
||||
import org.jetbrains.kotlin.psi.JetFile;
|
||||
@@ -52,7 +52,7 @@ import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public abstract class AbstractJetPositionManagerTest extends MultiFileTestCase {
|
||||
public abstract class AbstractJetPositionManagerTest extends KotlinMultiFileTestCase {
|
||||
// Breakpoint is given as a line comment on a specific line, containing the regexp to match the name of the class where that line
|
||||
// can be found. This pattern matches against these line comments and saves the class name in the first group
|
||||
private static final Pattern BREAKPOINT_PATTERN = Pattern.compile("^.*//\\s*(.+)\\s*$");
|
||||
@@ -135,7 +135,7 @@ public abstract class AbstractJetPositionManagerTest extends MultiFileTestCase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
public void tearDown() {
|
||||
if (debugProcess != null) {
|
||||
debugProcess.dispose();
|
||||
}
|
||||
|
||||
@@ -55,8 +55,9 @@ import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.idea.search.allScope
|
||||
import org.jetbrains.kotlin.test.ConfigLibraryUtil
|
||||
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
||||
import org.jetbrains.kotlin.idea.KotlinMultiFileTestCase
|
||||
|
||||
public abstract class AbstractJetMoveTest : MultiFileTestCase() {
|
||||
public abstract class AbstractJetMoveTest : KotlinMultiFileTestCase() {
|
||||
protected fun doTest(path: String) {
|
||||
fun extractCaretOffset(doc: Document): Int {
|
||||
return runWriteAction {
|
||||
@@ -64,7 +65,7 @@ public abstract class AbstractJetMoveTest : MultiFileTestCase() {
|
||||
val offset = text.indexOf("<caret>")
|
||||
|
||||
if (offset >= 0) {
|
||||
text.delete(offset, offset + "<caret>".length)
|
||||
text.delete(offset, offset + "<caret>".length())
|
||||
doc.setText(text.toString())
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyzeFully
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||
import com.intellij.refactoring.BaseRefactoringProcessor.ConflictsInTestsException
|
||||
import com.intellij.refactoring.util.CommonRefactoringUtil.RefactoringErrorHintException
|
||||
import org.jetbrains.kotlin.idea.KotlinMultiFileTestCase
|
||||
|
||||
private enum class RenameType {
|
||||
JAVA_CLASS
|
||||
@@ -58,7 +59,7 @@ private enum class RenameType {
|
||||
KOTLIN_PACKAGE
|
||||
}
|
||||
|
||||
public abstract class AbstractRenameTest : MultiFileTestCase() {
|
||||
public abstract class AbstractRenameTest : KotlinMultiFileTestCase() {
|
||||
inner class TestContext(
|
||||
val project: Project = getProject()!!,
|
||||
val javaFacade: JavaPsiFacade = getJavaFacade()!!,
|
||||
@@ -168,7 +169,7 @@ public abstract class AbstractRenameTest : MultiFileTestCase() {
|
||||
val fileFqn = jetFile.getPackageFqName()
|
||||
Assert.assertTrue("File '${mainFilePath}' should have package containing ${fqn}", fileFqn.isSubpackageOf(fqn))
|
||||
|
||||
val packageSegment = jetFile.getPackageDirective()!!.getPackageNames()[fqn.pathSegments().size - 1]
|
||||
val packageSegment = jetFile.getPackageDirective()!!.getPackageNames()[fqn.pathSegments().size() - 1]
|
||||
val segmentReference = packageSegment.getReference()!!
|
||||
|
||||
val psiElement = segmentReference.resolve()!!
|
||||
|
||||
Reference in New Issue
Block a user