Compare commits

...

43 Commits

Author SHA1 Message Date
Mikhail Glukhikh
ede11fbdd0 Fix compilation in 161 branch (KtLightClassForLocalDeclaration) 2017-03-16 13:38:10 +03:00
Mikhail Glukhikh
823a371fa9 Fix compilation (AbstractAndroidFoldingTest) 2017-03-16 13:29:29 +03:00
Mikhail Glukhikh
ec68471f82 Revert startInWriteAction in quick-fix for EqualsOrHashCodeInspection (no such thing in 161) 2017-03-16 13:29:22 +03:00
mglukhikh
9f5e6f5f9c Quick doc provider test fix (2016.1 platform specific) 2017-03-16 13:29:16 +03:00
mglukhikh
6b9c4c1526 Debugger test fix (161 branch specific) 2017-03-16 13:29:09 +03:00
Mikhail Glukhikh
198fa9733a Revert commit d13c342 to fix KotlinConsoleKeeper in 161 / AS22 2017-03-16 13:29:03 +03:00
Mikhail Glukhikh
34de3283f7 Fix 161 branch IDE tests by removing "compatible build" 2017-03-16 13:28:56 +03:00
mglukhikh
28a2abea4e Fix compilation (KotlinLineMarkerProvider) 2017-03-16 13:28:50 +03:00
mglukhikh
61cb263af6 Fix compilation (KotlinSuspendCallLineMarkerProvider) 2017-03-16 13:28:43 +03:00
Ilya Chernikov
745665dfe7 Fix compilation 2017-03-16 13:28:37 +03:00
Yan Zhulanow
119f81cda3 Revert "Rename: Fix exceptions on moving file with facade class to another package"
This reverts commit f8513abfa1.

(cherry picked from commit e53914d)
2017-03-16 13:28:30 +03:00
Ilya Chernikov
622e8ceb8f Fix test code after KotlinTestUtils api changes 2017-03-16 13:28:23 +03:00
Ilya Chernikov
b862999394 Fix missing api problem by copying functions from newer IOUtil 2017-03-16 13:28:17 +03:00
Dmitry Jemerov
df76ad533e revert Snappy version 2017-03-16 13:28:10 +03:00
Dmitry Jemerov
97fd653235 Revert: Get rid of deprecated (as of IDEA 2016.2) method calls 2017-03-16 13:28:04 +03:00
Dmitry Jemerov
4a32239a88 Fix compilation of AS 2.2 linters against IJ 2016.1 2017-03-16 13:27:58 +03:00
Dmitry Jemerov
b7c35d4545 fix compilation under 161 2017-03-16 13:27:51 +03:00
Dmitry Jemerov
e24a20360a delete postfix template test from 161 branch 2017-03-16 13:27:44 +03:00
Dmitry Jemerov
8291f07464 compilation fix 2017-03-16 13:27:38 +03:00
Dmitry Jemerov
6bee3f8aff set plugins compatible build to a version which is compatible with the Kotlin plugin 2017-03-16 13:27:31 +03:00
Dmitry Jemerov
127e2cba50 Revert: Problem: fix thread leaking check fail on teamcity for ultimate rename tests 2017-03-16 13:27:25 +03:00
Dmitry Jemerov
e6130042a7 fix compilation against 161 (KotlinSteppingCommandProvider) 2017-03-16 13:27:18 +03:00
Dmitry Jemerov
bd49deef41 Revert "Add TransactionGuard application service to KotlinCoreEnvironment"
This reverts commit 3e0b79e40a.
2017-03-16 13:27:11 +03:00
Dmitry Jemerov
581ae0fd86 Revert "Push Down: Support moving members from Java to Kotlin class"
This reverts commit f9e877ce96.
2017-03-16 13:27:05 +03:00
Dmitry Jemerov
2bb965607c until build for 2016.1 version of the plugin 2017-03-16 13:26:58 +03:00
Dmitry Jemerov
a23fe719c8 do not register Kotlin postfix template provider 2017-03-16 13:26:51 +03:00
Dmitry Jemerov
6b74b8cf0b Revert: Fix goto implementation tests - deffered task should be executed 2017-03-16 13:26:45 +03:00
Dmitry Jemerov
a3fd53b843 Revert: Fix goto implementation tests - deffered task should be executed 2017-03-16 13:26:39 +03:00
Dmitry Jemerov
e1afe868e8 Revert: Test only: method signature changed 2017-03-16 13:26:32 +03:00
Dmitry Jemerov
97bb1a92e3 Revert: Problem: workaround thread leaking problem 2017-03-16 13:26:25 +03:00
Dmitry Jemerov
12d7461cdd Revert: Register TypeAnnotationModifier EP in environment for web demo converter 2017-03-16 13:26:19 +03:00
Dmitry Jemerov
233cbf1069 Revert: Tests only: codeCleanup() method signature was changed 2017-03-16 13:26:12 +03:00
Dmitry Jemerov
5988728417 Revert: Tests only: Constructor for XWatchesViewImpl was changed 2017-03-16 13:26:06 +03:00
Dmitry Jemerov
89c2b98629 Revert: Tests only: add new method in MockPsiManager.java 2017-03-16 13:25:59 +03:00
Dmitry Jemerov
d0dff3638c Revert: Tests only: reparseRange parameters changed 2017-03-16 13:25:52 +03:00
Dmitry Jemerov
cb3804c7e4 Revert: Tests only: implement new method 2017-03-16 13:25:46 +03:00
Dmitry Jemerov
97187fa5d2 Revert: Register TypeAnnotationModifier as extension point 2017-03-16 13:25:39 +03:00
Dmitry Jemerov
b336ad43c5 Revert: More write action requirement remove 2017-03-16 13:25:32 +03:00
Dmitry Jemerov
8c75426545 Revert: API Change: Implement new method isSuppressAll() 2017-03-16 13:25:26 +03:00
Dmitry Jemerov
06dbc029d8 Revert startInWriteAction() methods 2017-03-16 13:25:19 +03:00
Dmitry Jemerov
cf9369264e Revert: registerUnresolvedError is in base class in idea from br146 2017-03-16 13:25:13 +03:00
Dmitry Jemerov
7def1618a8 Revert: Patch ThreadTracker during Kotlin plugin init 2017-03-16 13:25:05 +03:00
Dmitry Jemerov
c0d6987a3a revert IDEA version to 2016.1.2 2017-03-16 13:24:59 +03:00
128 changed files with 744 additions and 1156 deletions

View File

@@ -29,8 +29,6 @@ import com.intellij.lang.java.JavaParserDefinition
import com.intellij.mock.MockApplication
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.TransactionGuard
import com.intellij.openapi.application.TransactionGuardImpl
import com.intellij.openapi.components.ServiceManager
import com.intellij.openapi.extensions.Extensions
import com.intellij.openapi.extensions.ExtensionsArea
@@ -47,7 +45,6 @@ import com.intellij.openapi.vfs.impl.ZipHandler
import com.intellij.psi.FileContextProvider
import com.intellij.psi.PsiElementFinder
import com.intellij.psi.augment.PsiAugmentProvider
import com.intellij.psi.augment.TypeAnnotationModifier
import com.intellij.psi.compiled.ClassFileDecompilers
import com.intellij.psi.impl.JavaClassSupersImpl
import com.intellij.psi.impl.PsiElementFinderImpl
@@ -348,7 +345,7 @@ class KotlinCoreEnvironment private constructor(
@JvmStatic
private fun setCompatibleBuild() {
System.getProperties().setProperty("idea.plugins.compatible.build", "162.9999")
//System.getProperties().setProperty("idea.plugins.compatible.build", "161.9999")
}
@TestOnly
@@ -414,8 +411,6 @@ class KotlinCoreEnvironment private constructor(
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), ContainerProvider.EP_NAME, ContainerProvider::class.java)
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), ClsCustomNavigationPolicy.EP_NAME, ClsCustomNavigationPolicy::class.java)
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), ClassFileDecompilers.EP_NAME, ClassFileDecompilers.Decompiler::class.java)
//
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), TypeAnnotationModifier.EP_NAME, TypeAnnotationModifier::class.java)
}
private fun registerApplicationExtensionPointsAndExtensionsFrom(configuration: CompilerConfiguration, configFilePath: String) {
@@ -449,7 +444,6 @@ class KotlinCoreEnvironment private constructor(
registerParserDefinition(KotlinParserDefinition())
application.registerService(KotlinBinaryClassCache::class.java, KotlinBinaryClassCache())
application.registerService(JavaClassSupers::class.java, JavaClassSupersImpl::class.java)
application.registerService(TransactionGuard::class.java, TransactionGuardImpl::class.java)
}
}

View File

@@ -61,7 +61,7 @@ open class KtLightClassForLocalDeclaration(
if (createWrapper) {
return object : LightMethod(myManager, method, containingClass!!, KotlinLanguage.INSTANCE) {
override fun getParent(): PsiElement {
return getContainingClass()
return getContainingClass()!!
}
override fun getName(): String {

View File

@@ -23,7 +23,6 @@ import com.intellij.psi.PsiElementVisitor
import com.intellij.psi.impl.compiled.ClsFileImpl
import com.intellij.psi.stubs.PsiClassHolderFileStub
import org.jetbrains.kotlin.asJava.classes.KtLightClass
import org.jetbrains.kotlin.asJava.classes.KtLightClassForFacade
import org.jetbrains.kotlin.asJava.classes.KtLightClassForSourceDeclaration
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.KtFile
@@ -70,13 +69,4 @@ open class FakeFileForLightClass(
}
override fun isEquivalentTo(another: PsiElement?) = this == another
override fun setPackageName(packageName: String) {
if (lightClass() is KtLightClassForFacade) {
ktFile.packageDirective?.fqName = FqName(packageName)
}
else {
super.setPackageName(packageName)
}
}
}

View File

@@ -332,8 +332,7 @@ public abstract class KtParsingTestCase extends KtPlatformLiteFixture {
public static void ensureCorrectReparse(@NotNull PsiFile file) {
String psiToStringDefault = DebugUtil.psiToString(file, false, false);
String fileText = file.getText();
DiffLog diffLog = (new BlockSupportImpl(file.getProject())).reparseRange(
file, file.getNode(), TextRange.allOf(fileText), fileText, new EmptyProgressIndicator(), fileText);
DiffLog diffLog = (new BlockSupportImpl(file.getProject())).reparseRange(file, TextRange.allOf(fileText), fileText, new EmptyProgressIndicator(), fileText);
diffLog.performActualPsiChange(file);
TestCase.assertEquals(psiToStringDefault, DebugUtil.psiToString(file, false, false));

View File

@@ -139,11 +139,6 @@ public class MockPsiDocumentManager extends PsiDocumentManager {
throw new UnsupportedOperationException();
}
@Override
public void performLaterWhenAllCommitted(@NotNull Runnable runnable) {
throw new UnsupportedOperationException();
}
@Override
public void reparseFiles(@NotNull Collection<VirtualFile> files, boolean includeOpenFiles) {
throw new UnsupportedOperationException();

View File

@@ -21,7 +21,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileFilter;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiManagerEx;
import com.intellij.psi.impl.PsiModificationTrackerImpl;
@@ -139,9 +138,6 @@ public class MockPsiManager extends PsiManagerEx {
return false;
}
@Override
public void setAssertOnFileLoadingFilter(@NotNull VirtualFileFilter filter, @NotNull Disposable parentDisposable) {}
@Override
public boolean isAssertOnFileLoading(@NotNull VirtualFile file) {
return false;

View File

@@ -869,10 +869,8 @@ fun main(args: Array<String>) {
model("refactoring/pullUp/j2k", extension = "java", singleClass = true, testClassName = "J2K", testMethod = "doJavaTest")
}
testClass<AbstractPushDownTest> {
model("refactoring/pushDown/k2k", extension = "kt", singleClass = true, testClassName = "K2K", testMethod = "doKotlinTest")
model("refactoring/pushDown/k2j", extension = "kt", singleClass = true, testClassName = "K2J", testMethod = "doKotlinTest")
model("refactoring/pushDown/j2k", extension = "java", singleClass = true, testClassName = "J2K", testMethod = "doJavaTest")
testClass<AbstractPushDownTest>() {
model("refactoring/pushDown", extension = "kt", singleClass = true)
}
testClass<AbstractSelectExpressionForDebuggerTest> {

View File

@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.idea.vfilefinder
import com.intellij.util.indexing.*
import com.intellij.util.io.DataExternalizer
import com.intellij.util.io.DataInputOutputUtil
import com.intellij.util.io.IOUtil
import com.intellij.util.io.KeyDescriptor
import org.jetbrains.kotlin.load.kotlin.ModuleMapping
@@ -25,6 +26,24 @@ import org.jetbrains.kotlin.load.kotlin.PackageParts
import org.jetbrains.kotlin.serialization.deserialization.DeserializationConfiguration
import java.io.DataInput
import java.io.DataOutput
import java.io.IOException
import java.util.*
private fun writeStringList(out: DataOutput, list: Collection<String>) {
DataInputOutputUtil.writeINT(out, list.size)
for (s in list) {
IOUtil.writeUTF(out, s)
}
}
private fun readStringList(`in`: DataInput): List<String> {
val size = DataInputOutputUtil.readINT(`in`)
val strings = ArrayList<String>(size)
for (i in 0..size - 1) {
strings.add(IOUtil.readUTF(`in`))
}
return strings
}
object KotlinModuleMappingIndex : FileBasedIndexExtension<String, PackageParts>() {
@@ -43,19 +62,19 @@ object KotlinModuleMappingIndex : FileBasedIndexExtension<String, PackageParts>(
private val VALUE_EXTERNALIZER = object : DataExternalizer<PackageParts> {
override fun read(input: DataInput): PackageParts? =
PackageParts(IOUtil.readUTF(input)).apply {
val shortPartNames = IOUtil.readStringList(input)
val shortFacadeNames = IOUtil.readStringList(input)
val shortPartNames = readStringList(input)
val shortFacadeNames = readStringList(input)
for ((partName, facadeName) in shortPartNames zip shortFacadeNames) {
addPart(partName, if (facadeName.isNotEmpty()) facadeName else null)
}
IOUtil.readStringList(input).forEach(this::addMetadataPart)
readStringList(input).forEach(this::addMetadataPart)
}
override fun save(out: DataOutput, value: PackageParts) {
IOUtil.writeUTF(out, value.packageFqName)
IOUtil.writeStringList(out, value.parts)
IOUtil.writeStringList(out, value.parts.map { value.getMultifileFacadeName(it).orEmpty() })
IOUtil.writeStringList(out, value.metadataParts)
writeStringList(out, value.parts)
writeStringList(out, value.parts.map { value.getMultifileFacadeName(it).orEmpty() })
writeStringList(out, value.metadataParts)
}
}

View File

@@ -75,8 +75,6 @@ class IllegalIdentifierInspection : AbstractKotlinInspection() {
override fun getName() = "Rename"
override fun getFamilyName() = name
override fun startInWriteAction(): Boolean = false
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
val element = descriptor.psiElement ?: return
val file = element.containingFile ?: return

View File

@@ -72,7 +72,7 @@ public abstract class KotlinAndroidTestCaseBase extends UsefulTestCase {
@Override
protected void tearDown() throws Exception {
TestUtilsKt.doKotlinTearDown(getProject(), new RunnableWithException() {
TestUtilsKt.unInvalidateBuiltinsAndStdLib(getProject(), new RunnableWithException() {
@Override
public void run() throws Exception {
KotlinAndroidTestCaseBase.super.tearDown();

View File

@@ -25,7 +25,7 @@ abstract class AbstractAndroidResourceFoldingTest : KotlinAndroidTestCase() {
fun doTest(path: String) {
myFixture.copyFileToProject("values.xml", "res/values/values.xml")
myFixture.copyFileToProject("R.java", "gen/com/myapp/R.java")
myFixture.testFoldingWithCollapseStatus(path, "${myFixture.tempDirPath}/src/main.kt")
myFixture.testFoldingWithCollapseStatus("${myFixture.tempDirPath}/src/main.kt")
}
override fun createManifest() {

View File

@@ -68,7 +68,7 @@ public class KotlinConfidenceTest extends LightCompletionTestCase {
@Override
protected void tearDown() throws Exception {
TestUtilsKt.doKotlinTearDown(getProject(), new RunnableWithException() {
TestUtilsKt.unInvalidateBuiltinsAndStdLib(getProject(), new RunnableWithException() {
@Override
public void run() throws Exception {
KotlinConfidenceTest.super.tearDown();

View File

@@ -57,10 +57,11 @@ class KotlinConsoleKeeper(val project: Project) {
private fun createCommandLine(module: Module): GeneralCommandLine? {
val javaParameters = createJavaParametersWithSdk(module)
val sdk = javaParameters.jdk ?: return null
val sdkType = sdk.sdkType
val exePath = (sdkType as JavaSdkType).getVMExecutablePath(sdk)
javaParameters.mainClass = "dummy"
val commandLine = javaParameters.toCommandLine()
val commandLine = JdkUtil.setupJVMCommandLine(exePath, javaParameters, true)
val paramList = commandLine.parametersList
paramList.clearAll()

View File

@@ -72,7 +72,7 @@ abstract class KotlinLightCodeInsightFixtureTestCase : KotlinLightCodeInsightFix
KotlinInternalMode.enabled = kotlinInternalModeOriginalValue
VfsRootAccess.disallowRootAccess(KotlinTestUtils.getHomeDirectory())
doKotlinTearDown(project) {
unInvalidateBuiltinsAndStdLib(project) {
super.tearDown()
}

View File

@@ -40,7 +40,7 @@ abstract class KotlinLightPlatformCodeInsightFixtureTestCase: LightPlatformCodeI
KotlinInternalMode.enabled = kotlinInternalModeOriginalValue
VfsRootAccess.disallowRootAccess(KotlinTestUtils.getHomeDirectory())
doKotlinTearDown(project) {
unInvalidateBuiltinsAndStdLib(project) {
super.tearDown()
}
}

View File

@@ -16,7 +16,6 @@
package org.jetbrains.kotlin.idea.test
import com.intellij.concurrency.IdeaForkJoinWorkerThreadFactory
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.editor.Document
import com.intellij.openapi.module.Module
@@ -30,7 +29,6 @@ import com.intellij.psi.impl.PsiManagerEx
import com.intellij.psi.impl.file.impl.FileManagerImpl
import com.intellij.psi.impl.source.PsiFileImpl
import com.intellij.testFramework.LightPlatformTestCase
import com.intellij.testFramework.ThreadTracker
import com.intellij.util.Consumer
import org.jetbrains.kotlin.diagnostics.Severity
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
@@ -40,10 +38,7 @@ import org.jetbrains.kotlin.idea.decompiler.KotlinDecompiledFileViewProvider
import org.jetbrains.kotlin.idea.decompiler.KtDecompiledFile
import org.jetbrains.kotlin.idea.util.application.runWriteAction
import org.jetbrains.kotlin.psi.KtFile
import java.lang.IllegalArgumentException
import java.util.*
import java.util.concurrent.ForkJoinPool
import java.util.concurrent.atomic.AtomicBoolean
enum class ModuleKind {
KOTLIN_JVM_WITH_STDLIB_SOURCES,
@@ -52,16 +47,18 @@ enum class ModuleKind {
fun Module.configureAs(descriptor: KotlinLightProjectDescriptor) {
val module = this
updateModel(module, Consumer<ModifiableRootModel> { model ->
if (descriptor.sdk != null) {
model.sdk = descriptor.sdk
}
val entries = model.contentEntries
if (entries.isEmpty()) {
descriptor.configureModule(module, model)
}
else {
descriptor.configureModule(module, model, entries[0])
updateModel(module, object : Consumer<ModifiableRootModel> {
override fun consume(model: ModifiableRootModel) {
if (descriptor.sdk != null) {
model.sdk = descriptor.sdk
}
val entries = model.contentEntries
if (entries.isEmpty()) {
descriptor.configureModule(module, model)
}
else {
descriptor.configureModule(module, model, entries[0])
}
}
})
}
@@ -79,27 +76,17 @@ fun Module.configureAs(kind: ModuleKind) {
}
fun KtFile.dumpTextWithErrors(): String {
val diagnostics = analyzeFullyAndGetResult().bindingContext.diagnostics
val errors = diagnostics.filter { it.severity == Severity.ERROR }
val diagnostics = analyzeFullyAndGetResult().bindingContext.getDiagnostics()
val errors = diagnostics.filter { it.getSeverity() == Severity.ERROR }
if (errors.isEmpty()) return text
val header = errors.map { "// ERROR: " + DefaultErrorMessages.render(it).replace('\n', ' ') }.joinToString("\n", postfix = "\n")
return header + text
}
fun closeAndDeleteProject(): Unit =
ApplicationManager.getApplication().runWriteAction { LightPlatformTestCase.closeAndDeleteProject() }
ApplicationManager.getApplication().runWriteAction() { LightPlatformTestCase.closeAndDeleteProject() }
fun doKotlinTearDown(project: Project, runnable: RunnableWithException) {
doKotlinTearDown(project) { runnable.run() }
}
fun doKotlinTearDown(project: Project, runnable: () -> Unit) {
unInvalidateBuiltinsAndStdLib(project) {
runnable()
}
}
fun unInvalidateBuiltinsAndStdLib(project: Project, runnable: () -> Unit) {
fun unInvalidateBuiltinsAndStdLib(project: Project, runnable: RunnableWithException) {
val stdLibViewProviders = HashSet<KotlinDecompiledFileViewProvider>()
val vFileToViewProviderMap = ((PsiManager.getInstance(project) as PsiManagerEx).fileManager as FileManagerImpl).vFileToViewProviderMap
for ((file, viewProvider) in vFileToViewProviderMap) {
@@ -108,7 +95,7 @@ fun unInvalidateBuiltinsAndStdLib(project: Project, runnable: () -> Unit) {
}
}
runnable()
runnable.run()
// Base tearDown() invalidates builtins and std-lib files. Restore them with brute force.
fun unInvalidateFile(file: PsiFileImpl) {
@@ -119,19 +106,23 @@ fun unInvalidateBuiltinsAndStdLib(project: Project, runnable: () -> Unit) {
stdLibViewProviders.forEach {
it.allFiles.forEach { unInvalidateFile(it as KtDecompiledFile) }
vFileToViewProviderMap[it.virtualFile] = it
vFileToViewProviderMap.set(it.virtualFile, it)
}
}
private val VirtualFile.isStdLibFile: Boolean get() = presentableUrl.contains("kotlin-runtime.jar")
fun unInvalidateBuiltinsAndStdLib(project: Project, runnable: () -> Unit) {
unInvalidateBuiltinsAndStdLib(project, RunnableWithException { runnable() })
}
fun invalidateLibraryCache(project: Project) {
LibraryModificationTracker.getInstance(project).incModificationCount()
}
fun Document.extractMarkerOffset(project: Project, caretMarker: String = "<caret>"): Int {
val offset = runWriteAction {
val text = StringBuilder(text)
val text = StringBuilder(getText())
val offset = text.indexOf(caretMarker)
if (offset >= 0) {
@@ -146,4 +137,4 @@ fun Document.extractMarkerOffset(project: Project, caretMarker: String = "<caret
PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(this)
return offset
}
}

View File

@@ -6,7 +6,7 @@
<version>@snapshot@</version>
<vendor url="http://www.jetbrains.com">JetBrains s.r.o.</vendor>
<idea-version since-build="145.257" until-build="172.*"/>
<idea-version since-build="145.257" until-build="162.0"/>
<depends>com.intellij.modules.java</depends>
@@ -409,10 +409,6 @@
<codeInsight.gotoSuper language="kotlin" implementationClass="org.jetbrains.kotlin.idea.codeInsight.GotoSuperActionHandler"/>
<codeInsight.template.postfixTemplateProvider language="kotlin"
implementationClass="org.jetbrains.kotlin.idea.codeInsight.postfix.KtPostfixTemplateProvider"/>
<typeDeclarationProvider implementation="org.jetbrains.kotlin.idea.codeInsight.KotlinTypeDeclarationProvider"/>
<completion.contributor language="kotlin"
@@ -734,10 +730,6 @@
language="kotlin"
implementationClass="org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinClassMembersRefactoringSupport"/>
<refactoring.pushDown
language="kotlin"
implementationClass="org.jetbrains.kotlin.idea.refactoring.pushDown.JavaToKotlinPushDownDelegate"/>
<problemFileHighlightFilter implementation="org.jetbrains.kotlin.idea.projectView.KotlinProblemFileHighlightFilter"/>
<codeInsight.typeInfo language="kotlin" implementationClass="org.jetbrains.kotlin.idea.codeInsight.KotlinExpressionTypeProvider"/>

View File

@@ -54,10 +54,6 @@ public class PluginStartupComponent implements ApplicationComponent {
public void initComponent() {
registerPathVariable();
if (ApplicationManager.getApplication().isUnitTestMode()) {
ThreadTrackerPatcherForTeamCityTesting.INSTANCE.patchThreadTracker();
}
JarUserDataManager.INSTANCE.register(KotlinJavaScriptLibraryDetectionUtil.HasKotlinJSMetadataInJar.INSTANCE);
DebuggerFiltersUtilKt.addKotlinStdlibDebugFilterIfNeeded();

View File

@@ -1,77 +0,0 @@
/*
* Copyright 2010-2016 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.concurrency.IdeaForkJoinWorkerThreadFactory
import com.intellij.testFramework.ThreadTracker
import java.lang.reflect.Modifier
import java.util.concurrent.ForkJoinPool
import java.util.concurrent.atomic.AtomicBoolean
/*
Workaround for ThreadTracker.checkLeak() failures on TeamCity.
Currently TeamCity runs tests in classloader without boot.jar where IdeaForkJoinWorkerThreadFactory is defined. That
makes ForkJoinPool.commonPool() silently ignores java.util.concurrent.ForkJoinPool.common.threadFactory
(because of java.lang.ClassNotFoundException) option during factory initialization.
Standard names for ForkJoinPool threads doesn't pass ThreadTracker.checkLeak() check and that ruins tests constantly.
As it's allowed to reorder tests on TeamCity and any test can be first at some point, this patch should be applied at
some common place.
*/
object ThreadTrackerPatcherForTeamCityTesting {
private val patched = AtomicBoolean(false)
fun patchThreadTracker() {
if (patched.get()) return
patched.compareAndSet(false, true)
IdeaForkJoinWorkerThreadFactory.setupForkJoinCommonPool()
// Check setup was successful and patching isn't needed
val commonPoolFactoryName = ForkJoinPool.commonPool().factory::class.java.name
if (commonPoolFactoryName == IdeaForkJoinWorkerThreadFactory::class.java.name) {
return
}
try {
val wellKnownOffendersField = try {
ThreadTracker::class.java.getDeclaredField("wellKnownOffenders")
}
catch (communityPropertyNotFoundEx: NoSuchFieldException) {
ThreadTracker::class.java.declaredFields.single {
Modifier.isStatic(it.modifiers) && MutableSet::class.java.isAssignableFrom(it.type)
}
}
wellKnownOffendersField.isAccessible = true
@Suppress("UNCHECKED_CAST")
val wellKnownOffenders = wellKnownOffendersField.get(null) as MutableSet<String>
wellKnownOffenders.add("ForkJoinPool.commonPool-worker-")
println("Patching ThreadTracker was successful")
}
catch (e: NoSuchFieldException) {
println("Patching ThreadTracker failed: " + e)
}
catch (e: IllegalAccessException) {
println("Patching ThreadTracker failed: " + e)
}
}
}

View File

@@ -77,7 +77,7 @@ class KotlinClassWithDelegatedPropertyRenderer(val rendererSettings: NodeRendere
listener: DescriptorLabelListener): String? {
val toStringRenderer = rendererSettings.toStringRenderer
if (toStringRenderer.isEnabled && DebuggerManagerEx.getInstanceEx(evaluationContext.project).context.isEvaluationPossible) {
if (toStringRenderer.isApplicable(descriptor.type)) {
if (toStringRenderer.isApplicable(descriptor.value?.type())) {
return toStringRenderer.calcLabel(descriptor, evaluationContext, listener)
}
}

View File

@@ -127,7 +127,7 @@ class KotlinStepActionFactory(private val debuggerProcess: DebugProcessImpl) {
if (stepThread == null) {
// TODO: Intellij code doesn't bother to check thread for null, so probably it's not-null actually
debuggerProcess.createStepOverCommand(suspendContext, true).contextAction(suspendContext)
debuggerProcess.createStepOverCommand(suspendContext, true).contextAction()
return
}

View File

@@ -269,17 +269,17 @@ sealed class Action(val position: XSourcePositionImpl? = null,
val stepOverInlineData: StepOverFilterData? = null) {
class STEP_OVER : Action() {
override fun apply(debugProcess: DebugProcessImpl, suspendContext: SuspendContextImpl, ignoreBreakpoints: Boolean) =
debugProcess.createStepOverCommand(suspendContext, ignoreBreakpoints).contextAction(suspendContext)
debugProcess.createStepOverCommand(suspendContext, ignoreBreakpoints).contextAction()
}
class STEP_OUT : Action() {
override fun apply(debugProcess: DebugProcessImpl, suspendContext: SuspendContextImpl, ignoreBreakpoints: Boolean) =
debugProcess.createStepOutCommand(suspendContext).contextAction(suspendContext)
debugProcess.createStepOutCommand(suspendContext).contextAction()
}
class RUN_TO_CURSOR(position: XSourcePositionImpl) : Action(position) {
override fun apply(debugProcess: DebugProcessImpl, suspendContext: SuspendContextImpl, ignoreBreakpoints: Boolean) {
return runReadAction {
debugProcess.createRunToCursorCommand(suspendContext, position!!, ignoreBreakpoints)
}.contextAction(suspendContext)
}.contextAction()
}
}
class STEP_OVER_INLINED(stepOverInlineData: StepOverFilterData) : Action(stepOverInlineData = stepOverInlineData) {

View File

@@ -121,6 +121,12 @@ class KotlinSmartEnterHandler: SmartEnterProcessorWithFixers() {
}
}
fun registerUnresolvedError(offset: Int) {
if (myFirstErrorOffset > offset) {
myFirstErrorOffset = offset
}
}
private fun PsiElement.isKotlinStatement() = when {
parent is KtBlockExpression && node?.elementType !in BRACES -> true
parent?.node?.elementType in BRANCH_CONTAINERS && this !is KtBlockExpression -> true

View File

@@ -38,7 +38,7 @@ class KotlinSuspendCallLineMarkerProvider : LineMarkerProvider {
callElement,
callElement.textRange,
KotlinIcons.SUSPEND_CALL,
Pass.UPDATE_OVERRIDDEN_MARKERS,
Pass.UPDATE_OVERRIDEN_MARKERS,
{ "Suspend function call" },
null,
GutterIconRenderer.Alignment.RIGHT

View File

@@ -171,7 +171,7 @@ private fun collectSuperDeclarationMarkers(declaration: KtDeclaration, result: M
declaration,
anchor.textRange,
if (implements) IMPLEMENTING_MARK else OVERRIDING_MARK,
Pass.UPDATE_OVERRIDDEN_MARKERS,
Pass.UPDATE_OVERRIDEN_MARKERS,
SuperDeclarationMarkerTooltip,
SuperDeclarationMarkerNavigationHandler(),
GutterIconRenderer.Alignment.RIGHT
@@ -194,7 +194,7 @@ private fun collectInheritedClassMarker(element: KtClass, result: MutableCollect
anchor,
anchor.textRange,
if (isTrait) IMPLEMENTED_MARK else OVERRIDDEN_MARK,
Pass.UPDATE_OVERRIDDEN_MARKERS,
Pass.UPDATE_OVERRIDEN_MARKERS,
SUBCLASSED_CLASS.tooltip,
SUBCLASSED_CLASS.navigationHandler,
GutterIconRenderer.Alignment.RIGHT
@@ -225,7 +225,7 @@ private fun collectOverriddenPropertyAccessors(properties: Collection<KtNamedDec
anchor,
anchor.textRange,
if (isImplemented(property)) IMPLEMENTED_MARK else OVERRIDDEN_MARK,
Pass.UPDATE_OVERRIDDEN_MARKERS,
Pass.UPDATE_OVERRIDEN_MARKERS,
OVERRIDDEN_PROPERTY.tooltip,
OVERRIDDEN_PROPERTY.navigationHandler,
GutterIconRenderer.Alignment.RIGHT
@@ -247,7 +247,7 @@ private fun collectImplementationMarkers(declaration: KtNamedDeclaration,
anchor,
anchor.textRange,
KotlinIcons.FROM_HEADER,
Pass.UPDATE_OVERRIDDEN_MARKERS,
Pass.UPDATE_OVERRIDEN_MARKERS,
PLATFORM_IMPLEMENTATION.tooltip,
PLATFORM_IMPLEMENTATION.navigationHandler,
GutterIconRenderer.Alignment.RIGHT
@@ -268,7 +268,7 @@ private fun collectHeaderMarkers(declaration: KtNamedDeclaration,
anchor,
anchor.textRange,
KotlinIcons.FROM_IMPL,
Pass.UPDATE_OVERRIDDEN_MARKERS,
Pass.UPDATE_OVERRIDEN_MARKERS,
HEADER_DECLARATION.tooltip,
HEADER_DECLARATION.navigationHandler,
GutterIconRenderer.Alignment.RIGHT
@@ -305,7 +305,7 @@ private fun collectOverriddenFunctions(functions: Collection<KtNamedFunction>, r
anchor,
anchor.textRange,
if (isImplemented(function)) IMPLEMENTED_MARK else OVERRIDDEN_MARK,
Pass.UPDATE_OVERRIDDEN_MARKERS, OVERRIDDEN_FUNCTION.tooltip,
Pass.UPDATE_OVERRIDEN_MARKERS, OVERRIDDEN_FUNCTION.tooltip,
OVERRIDDEN_FUNCTION.navigationHandler,
GutterIconRenderer.Alignment.RIGHT
))

View File

@@ -61,8 +61,6 @@ sealed class GenerateEqualsOrHashCodeFix : LocalQuickFix {
override fun getFamilyName() = name
override fun startInWriteAction() = false
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
if (!FileModificationService.getInstance().preparePsiElementForWrite(descriptor.psiElement)) return
KotlinGenerateEqualsAndHashcodeAction().doInvoke(project, null, descriptor.psiElement.parent as KtClass)

View File

@@ -125,7 +125,5 @@ class UnusedReceiverParameterInspection : AbstractKotlinInspection() {
}
override fun getFamilyName(): String = name
override fun startInWriteAction() = false
}
}

View File

@@ -379,8 +379,6 @@ class SafeDeleteFix(declaration: KtDeclaration) : LocalQuickFix {
override fun getFamilyName() = "Safe delete"
override fun startInWriteAction(): Boolean = false
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
val declaration = descriptor.psiElement.getStrictParentOfType<KtDeclaration>() ?: return
if (!FileModificationService.getInstance().prepareFileForWrite(declaration.containingFile)) return

View File

@@ -30,7 +30,6 @@ import com.intellij.refactoring.move.MoveCallback
import com.intellij.refactoring.move.MoveHandlerDelegate
import com.intellij.refactoring.move.moveClassesOrPackages.MoveClassesOrPackagesImpl
import com.intellij.refactoring.util.CommonRefactoringUtil
import org.jetbrains.kotlin.asJava.unwrapped
import org.jetbrains.kotlin.idea.core.getPackage
import org.jetbrains.kotlin.idea.refactoring.canRefactor
import org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.ui.KotlinSelectNestedClassRefactoringDialog
@@ -169,7 +168,7 @@ class MoveKotlinDeclarationsHandler : MoveHandlerDelegate() {
override fun tryToMove(
element: PsiElement, project: Project, dataContext: DataContext?, reference: PsiReference?, editor: Editor?
): Boolean {
val elementsToMove = element.unwrapped?.let { arrayOf(it) } ?: PsiElement.EMPTY_ARRAY
val elementsToMove = arrayOf(element)
val targetContainer = dataContext?.let { dataContext -> LangDataKeys.TARGET_PSI_ELEMENT.getData(dataContext) }
return canMove(elementsToMove, targetContainer, true) && doMoveWithCheck(project, elementsToMove, targetContainer, null, editor)
}

View File

@@ -16,14 +16,10 @@
package org.jetbrains.kotlin.idea.refactoring.move.moveFilesOrDirectories
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.actionSystem.LangDataKeys
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import com.intellij.psi.*
import com.intellij.refactoring.move.MoveCallback
import com.intellij.refactoring.move.moveFilesOrDirectories.MoveFilesOrDirectoriesHandler
import org.jetbrains.kotlin.asJava.classes.KtLightClassForFacade
import org.jetbrains.kotlin.idea.refactoring.move.*
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtFile
@@ -58,13 +54,4 @@ class KotlinMoveFilesOrDirectoriesHandler : MoveFilesOrDirectoriesHandler() {
callback?.refactoringCompleted()
}
}
override fun tryToMove(element: PsiElement, project: Project, dataContext: DataContext?, reference: PsiReference?, editor: Editor?): Boolean {
if (element is KtLightClassForFacade) {
doMove(project, element.files.toTypedArray(), dataContext?.getData(LangDataKeys.TARGET_PSI_ELEMENT), null)
return true
}
return super.tryToMove(element, project, dataContext, reference, editor)
}
}

View File

@@ -1,116 +0,0 @@
/*
* Copyright 2010-2016 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.refactoring.pushDown
import com.intellij.psi.*
import com.intellij.refactoring.memberPushDown.JavaPushDownDelegate
import com.intellij.refactoring.memberPushDown.NewSubClassData
import com.intellij.refactoring.memberPushDown.PushDownData
import com.intellij.refactoring.util.RefactoringUtil
import com.intellij.refactoring.util.classMembers.MemberInfo
import com.intellij.util.containers.MultiMap
import org.jetbrains.kotlin.asJava.unwrapped
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.getJavaClassDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.getJavaMemberDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
import org.jetbrains.kotlin.idea.core.getOrCreateCompanionObject
import org.jetbrains.kotlin.idea.refactoring.isInterfaceClass
import org.jetbrains.kotlin.idea.refactoring.j2k
import org.jetbrains.kotlin.idea.refactoring.j2kText
import org.jetbrains.kotlin.idea.refactoring.pullUp.addMemberToTarget
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.KtCallableDeclaration
import org.jetbrains.kotlin.psi.KtClass
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtPsiFactory
import org.jetbrains.kotlin.types.TypeSubstitutor
import org.jetbrains.kotlin.types.substitutions.getTypeSubstitutor
class JavaToKotlinPushDownDelegate : JavaPushDownDelegate() {
override fun checkTargetClassConflicts(
targetClass: PsiElement?,
pushDownData: PushDownData<MemberInfo, PsiMember>,
conflicts: MultiMap<PsiElement, String>,
subClassData: NewSubClassData?
) {
super.checkTargetClassConflicts(targetClass, pushDownData, conflicts, subClassData)
val ktClass = targetClass?.unwrapped as? KtClassOrObject ?: return
val targetClassDescriptor = ktClass.resolveToDescriptor() as ClassDescriptor
for (memberInfo in pushDownData.membersToMove) {
val member = memberInfo.member ?: continue
checkExternalUsages(conflicts, member, targetClassDescriptor, ktClass.getResolutionFacade())
}
}
override fun pushDownToClass(targetClass: PsiElement, pushDownData: PushDownData<MemberInfo, PsiMember>) {
val superClass = pushDownData.sourceClass as? PsiClass ?: return
val subClass = targetClass.unwrapped as? KtClassOrObject ?: return
val resolutionFacade = subClass.getResolutionFacade()
val superClassDescriptor = superClass.getJavaClassDescriptor(resolutionFacade) ?: return
val subClassDescriptor = subClass.resolveToDescriptor() as ClassDescriptor
val substitutor = getTypeSubstitutor(superClassDescriptor.defaultType, subClassDescriptor.defaultType) ?: TypeSubstitutor.EMPTY
val psiFactory = KtPsiFactory(subClass)
var hasAbstractMembers = false
members@ for (memberInfo in pushDownData.membersToMove) {
val member = memberInfo.member
val memberDescriptor = member.getJavaMemberDescriptor(resolutionFacade) ?: continue
when (member) {
is PsiMethod, is PsiField -> {
val ktMember = member.j2k() as? KtCallableDeclaration ?: continue@members
ktMember.removeModifier(KtTokens.DEFAULT_VISIBILITY_KEYWORD)
val isStatic = member.hasModifierProperty(PsiModifier.STATIC)
val targetMemberClass = if (isStatic && subClass is KtClass) subClass.getOrCreateCompanionObject() else subClass
val targetMemberClassDescriptor = resolutionFacade.resolveToDescriptor(targetMemberClass) as ClassDescriptor
if (member.hasModifierProperty(PsiModifier.ABSTRACT)) {
hasAbstractMembers = true
}
moveCallableMemberToClass(
ktMember,
memberDescriptor as CallableMemberDescriptor,
targetMemberClass,
targetMemberClassDescriptor,
substitutor,
memberInfo.isToAbstract
).apply {
if (subClass.isInterfaceClass()) {
removeModifier(KtTokens.ABSTRACT_KEYWORD)
}
}
}
is PsiClass -> {
if (memberInfo.overrides != null) {
val typeText = RefactoringUtil.findReferenceToClass(superClass.implementsList, member)?.j2kText() ?: continue@members
subClass.addSuperTypeListEntry(psiFactory.createSuperTypeEntry(typeText))
}
else {
val ktClass = member.j2k() as? KtClassOrObject ?: continue@members
addMemberToTarget(ktClass, subClass)
}
}
}
}
if (hasAbstractMembers && !subClass.isInterfaceClass()) {
subClass.addModifier(KtTokens.ABSTRACT_KEYWORD)
}
}
}

View File

@@ -29,24 +29,28 @@ import com.intellij.usageView.UsageViewDescriptor
import org.jetbrains.kotlin.asJava.unwrapped
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.idea.caches.resolve.getJavaClassDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.codeInsight.shorten.addToShorteningWaitSet
import org.jetbrains.kotlin.idea.runSynchronouslyWithProgress
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberInfo
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KtPsiClassWrapper
import org.jetbrains.kotlin.idea.refactoring.pullUp.*
import org.jetbrains.kotlin.idea.runSynchronouslyWithProgress
import org.jetbrains.kotlin.idea.search.declarationsSearch.HierarchySearchRequest
import org.jetbrains.kotlin.idea.search.declarationsSearch.searchInheritors
import org.jetbrains.kotlin.idea.util.application.runReadAction
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.source.getPsi
import org.jetbrains.kotlin.types.TypeSubstitutor
import org.jetbrains.kotlin.types.substitutions.getTypeSubstitutor
import org.jetbrains.kotlin.util.findCallableMemberBySignature
import org.jetbrains.kotlin.utils.keysToMap
import java.util.*
import java.util.ArrayList
class KotlinPushDownContext(
val sourceClass: KtClass,
@@ -137,14 +141,31 @@ class KotlinPushDownProcessor(
is KtProperty, is KtNamedFunction -> {
memberDescriptor as CallableMemberDescriptor
moveCallableMemberToClass(
member as KtCallableDeclaration,
memberDescriptor,
targetClass,
targetClassDescriptor,
substitutor,
memberInfo.isToAbstract
)
val targetMemberDescriptor = memberDescriptor.substitute(substitutor)?.let {
targetClassDescriptor.findCallableMemberBySignature(it as CallableMemberDescriptor)
}
val targetMember = targetMemberDescriptor?.source?.getPsi() as? KtCallableDeclaration
targetMember?.apply {
if (memberDescriptor.modality != Modality.ABSTRACT && memberInfo.isToAbstract) {
addModifier(KtTokens.OVERRIDE_KEYWORD)
}
else if (memberDescriptor.overriddenDescriptors.isEmpty()) {
removeModifier(KtTokens.OVERRIDE_KEYWORD)
}
else {
addModifier(KtTokens.OVERRIDE_KEYWORD)
}
} ?: addMemberToTarget(member, targetClass).apply {
if (this@KotlinPushDownProcessor.context.sourceClassDescriptor.kind == ClassKind.INTERFACE) {
if (targetClassDescriptor.kind != ClassKind.INTERFACE && memberDescriptor.modality == Modality.ABSTRACT) {
addModifier(KtTokens.ABSTRACT_KEYWORD)
}
}
if (memberDescriptor.modality != Modality.ABSTRACT && memberInfo.isToAbstract) {
KtTokens.VISIBILITY_MODIFIERS.types.forEach { removeModifier(it as KtModifierKeywordToken) }
addModifier(KtTokens.OVERRIDE_KEYWORD)
}
}
}
is KtClassOrObject, is KtPsiClassWrapper -> {

View File

@@ -28,7 +28,6 @@ import org.jetbrains.kotlin.idea.refactoring.memberInfo.KtPsiClassWrapper
import org.jetbrains.kotlin.idea.refactoring.pullUp.renderForConflicts
import org.jetbrains.kotlin.idea.references.KtReference
import org.jetbrains.kotlin.idea.references.mainReference
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForReceiver
@@ -98,7 +97,7 @@ private fun checkConflicts(
for (member in membersToPush) {
checkMemberClashing(conflicts, context, member, membersToKeepAbstract, substitutor, targetClass, targetClassDescriptor)
checkSuperCalls(conflicts, context, member, membersToPush)
checkExternalUsages(conflicts, member, targetClassDescriptor, context.resolutionFacade)
checkExternalUsages(conflicts, context, member, targetClassDescriptor)
checkVisibility(conflicts, context, member, targetClassDescriptor)
}
}
@@ -170,15 +169,15 @@ private fun checkSuperCalls(
)
}
internal fun checkExternalUsages(
private fun checkExternalUsages(
conflicts: MultiMap<PsiElement, String>,
member: PsiElement,
targetClassDescriptor: ClassDescriptor,
resolutionFacade: ResolutionFacade
context: KotlinPushDownContext,
member: KtNamedDeclaration,
targetClassDescriptor: ClassDescriptor
): Unit {
for (ref in ReferencesSearch.search(member, member.resolveScope, false)) {
val calleeExpr = ref.element as? KtSimpleNameExpression ?: continue
val resolvedCall = calleeExpr.getResolvedCall(resolutionFacade.analyze(calleeExpr)) ?: continue
val resolvedCall = calleeExpr.getResolvedCall(context.resolutionFacade.analyze(calleeExpr)) ?: continue
val callElement = resolvedCall.call.callElement
val dispatchReceiver = resolvedCall.dispatchReceiver
if (dispatchReceiver == null || dispatchReceiver is Qualifier) continue

View File

@@ -1,66 +0,0 @@
/*
* Copyright 2010-2016 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.refactoring.pushDown
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.idea.refactoring.pullUp.addMemberToTarget
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.KtCallableDeclaration
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.resolve.source.getPsi
import org.jetbrains.kotlin.types.TypeSubstitutor
import org.jetbrains.kotlin.util.findCallableMemberBySignature
internal fun moveCallableMemberToClass(
member: KtCallableDeclaration,
memberDescriptor: CallableMemberDescriptor,
targetClass: KtClassOrObject,
targetClassDescriptor: ClassDescriptor,
substitutor: TypeSubstitutor,
makeAbstract: Boolean
): KtCallableDeclaration {
val targetMemberDescriptor = memberDescriptor.substitute(substitutor)?.let {
targetClassDescriptor.findCallableMemberBySignature(it as CallableMemberDescriptor)
}
val targetMember = targetMemberDescriptor?.source?.getPsi() as? KtCallableDeclaration
return targetMember?.apply {
if (memberDescriptor.modality != Modality.ABSTRACT && makeAbstract) {
addModifier(KtTokens.OVERRIDE_KEYWORD)
}
else if (memberDescriptor.overriddenDescriptors.isEmpty()) {
removeModifier(KtTokens.OVERRIDE_KEYWORD)
}
else {
addModifier(KtTokens.OVERRIDE_KEYWORD)
}
} ?: addMemberToTarget(member, targetClass).apply {
val sourceClassDescriptor = memberDescriptor.containingDeclaration as? ClassDescriptor
if (sourceClassDescriptor?.kind == ClassKind.INTERFACE) {
if (targetClassDescriptor.kind != ClassKind.INTERFACE && memberDescriptor.modality == Modality.ABSTRACT) {
addModifier(KtTokens.ABSTRACT_KEYWORD)
}
}
if (memberDescriptor.modality != Modality.ABSTRACT && makeAbstract) {
KtTokens.VISIBILITY_MODIFIERS.types.forEach { removeModifier(it as KtModifierKeywordToken) }
addModifier(KtTokens.OVERRIDE_KEYWORD)
}
} as KtCallableDeclaration
}

View File

@@ -42,6 +42,7 @@ Compile bytecode for args.size
field = propEx: int = {java.lang.IllegalStateException@uniqueID}java.lang.IllegalStateException (sp = delegatedPropertyInClass.kt, 14)
field = detailMessage: java.lang.String = null (sp = Throwable.!EXT!)
field = cause: java.lang.Throwable = {java.lang.IllegalStateException@uniqueID}java.lang.IllegalStateException (sp = Throwable.!EXT!)
- args.size = ...
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
Process finished with exit code 0

View File

@@ -31,6 +31,7 @@ Compile bytecode for args.size
field = prop$delegate: delegatedPropertyInClassWithToString.MyDelegate = {delegatedPropertyInClassWithToString.MyDelegate@uniqueID} (sp = delegatedPropertyInClassWithToString.kt, 12)
- Class has no fields
field = prop: int = 1 (sp = delegatedPropertyInClassWithToString.kt, 12)
- args.size = ...
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
Process finished with exit code 0

View File

@@ -30,6 +30,7 @@ Compile bytecode for args.size
local = a: delegatedPropertyInClassWoRenderer.A = {delegatedPropertyInClassWoRenderer.A@uniqueID} (sp = delegatedPropertyInClassWoRenderer.kt, 7)
field = prop: int = {delegatedPropertyInClassWoRenderer.MyDelegate@uniqueID} (sp = delegatedPropertyInClassWoRenderer.kt, 13)
- Class has no fields
- args.size = ...
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
Process finished with exit code 0

View File

@@ -30,6 +30,7 @@ Compile bytecode for a2.prop
local = a3: evBreakpointOnPropertyDeclaration.A = {evBreakpointOnPropertyDeclaration.A@uniqueID} (sp = evBreakpointOnPropertyDeclaration.kt, 10)
field = prop: int = 1 (sp = evBreakpointOnPropertyDeclaration.kt, 4)
local = p1: int = 1 (sp = evBreakpointOnPropertyDeclaration.kt, 12)
- a2.prop = ...
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
Process finished with exit code 0

View File

@@ -20,6 +20,7 @@ Compile bytecode for a.prop
local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = evDuplicateItems.kt, 7)
local = a: evDuplicateItems.A = {evDuplicateItems.A@uniqueID} (sp = evDuplicateItems.kt, 8)
field = prop: int = 1 (sp = evDuplicateItems.kt, 4)
- a.prop = ...
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
Process finished with exit code 0

View File

@@ -18,6 +18,7 @@ Compile bytecode for a
frame = foo:5, A {evFunctionDeclaration}
this = this = {evFunctionDeclaration.A@uniqueID}
field = a: int = 1 (sp = evFunctionDeclaration.kt, 3)
- a = ...
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
Process finished with exit code 0

View File

@@ -34,6 +34,7 @@ Compile bytecode for a2.prop
local = a3: evLineRange.A = {evLineRange.A@uniqueID} (sp = evLineRange.kt, 10)
field = prop: int = 1 (sp = evLineRange.kt, 4)
local = i1: int = 1 (sp = evLineRange.kt, 13)
- a2.prop = ...
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
Process finished with exit code 0

View File

@@ -22,6 +22,7 @@ Compile bytecode for a.prop
local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = evProperty.kt, 7)
local = a: evProperty.A = {evProperty.A@uniqueID} (sp = evProperty.kt, 8)
field = prop: int = 1 (sp = evProperty.kt, 4)
- a.prop = ...
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
Process finished with exit code 0

View File

@@ -24,6 +24,7 @@ Compile bytecode for prop
frame = test:8, A {evPropertyRefExpr}
this = this = {evPropertyRefExpr.A@uniqueID}
field = prop: int = 1 (sp = evPropertyRefExpr.kt, 4)
- prop = ...
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
Process finished with exit code 0

View File

@@ -35,6 +35,7 @@ Compile bytecode for a1.prop
field = prop: int = 1 (sp = evSkipAnonymousObject.kt, 4)
local = a2: evSkipAnonymousObject.A = {evSkipAnonymousObject.A@uniqueID} (sp = evSkipAnonymousObject.kt, 9)
field = prop: int = 1 (sp = evSkipAnonymousObject.kt, 4)
- a1.prop = ...
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
Process finished with exit code 0

View File

@@ -30,6 +30,7 @@ Compile bytecode for a1.prop
field = prop: int = 1 (sp = evSkipLambda.kt, 4)
local = a2: evSkipLambda.A = {evSkipLambda.A@uniqueID} (sp = evSkipLambda.kt, 9)
field = prop: int = 1 (sp = evSkipLambda.kt, 4)
- a1.prop = ...
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
Process finished with exit code 0

View File

@@ -31,6 +31,7 @@ Compile bytecode for a1.prop
field = prop: int = 1 (sp = evSkipLocalClass.kt, 4)
local = a2: evSkipLocalClass.A = {evSkipLocalClass.A@uniqueID} (sp = evSkipLocalClass.kt, 9)
field = prop: int = 1 (sp = evSkipLocalClass.kt, 4)
- a1.prop = ...
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
Process finished with exit code 0

View File

@@ -20,6 +20,7 @@ Compile bytecode for args.size
local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = toStringRenderer.kt, 3)
local = a: toStringRenderer.A = {toStringRenderer.A@uniqueID}myA (sp = toStringRenderer.kt, 4)
- Class has no fields
- args.size = ...
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
Process finished with exit code 0

View File

@@ -62,6 +62,7 @@ Compile bytecode for arrayOfA
local = q: java.lang.String = (sp = underscoreNames.kt, 16)
field = value: char[] = {char[0]@uniqueID} (sp = String.!EXT!)
field = hash: int = 0 (sp = String.!EXT!)
- arrayOfA = ...
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
Process finished with exit code 0

View File

@@ -7,4 +7,4 @@ class KotlinPackageClassUsedFromJava {
}
//INFO: <html><head> <style type="text/css"> #error { background-color: #eeeeee; margin-bottom: 10px; } p { margin: 5px 0; } </style></head><body><small><b>testing</b></small><PRE>public final class <b>testing.KotlinPackageClassUsedFromJava_DataKt</b>
//INFO: extends <a href="psi_element://java.lang.Object"><code>Object</code></a></PRE></body></html>
//INFO: extends <a href="psi_element://java.lang.Object"><code>java.lang.Object</code></a></PRE></body></html>

View File

@@ -1 +0,0 @@
class K : A()

View File

@@ -1,28 +0,0 @@
abstract class K : A() {
// INFO: {"checked": "true"}
var x = 2 * 3
// INFO: {"checked": "true"}
internal inner class X
// INFO: {"checked": "true"}
internal class Y
// INFO: {"checked": "true"}
fun foo(n: Int): Boolean {
return n > 0
}
// INFO: {"checked": "true"}
internal abstract fun bar(s: String): Int
companion object {
// INFO: {"checked": "true"}
var X = "1" + "2"
// INFO: {"checked": "true"}
fun foo2(n: Int): String {
return "_" + n + "_"
}
}
}

View File

@@ -1,29 +0,0 @@
abstract class <caret>A {
// INFO: {"checked": "true"}
int x = 2 * 3;
// INFO: {"checked": "true"}
static String X = "1" + "2";
// INFO: {"checked": "true"}
boolean foo(int n) {
return n > 0;
}
// INFO: {"checked": "true"}
static String foo2(int n) {
return "_" + n + "_";
}
// INFO: {"checked": "true"}
abstract int bar(String s);
// INFO: {"checked": "true"}
class X {
}
// INFO: {"checked": "true"}
static class Y {
}
}

View File

@@ -1,3 +0,0 @@
abstract class A {
}

View File

@@ -1 +0,0 @@
class K : A()

View File

@@ -1,28 +0,0 @@
abstract class K : A() {
// INFO: {"checked": "true"}
var x = 2 * 3
// INFO: {"checked": "true"}
internal inner class X
// INFO: {"checked": "true"}
internal class Y
// INFO: {"checked": "true", "toAbstract": "true"}
override fun foo(n: Int): Boolean {
return n > 0
}
// INFO: {"checked": "true"}
internal abstract fun bar(s: String): Int
companion object {
// INFO: {"checked": "true"}
var X = "1" + "2"
// INFO: {"checked": "true"}
fun foo2(n: Int): String {
return "_" + n + "_"
}
}
}

View File

@@ -1,29 +0,0 @@
abstract class <caret>A {
// INFO: {"checked": "true"}
int x = 2 * 3;
// INFO: {"checked": "true"}
static String X = "1" + "2";
// INFO: {"checked": "true", "toAbstract": "true"}
boolean foo(int n) {
return n > 0;
}
// INFO: {"checked": "true"}
static String foo2(int n) {
return "_" + n + "_";
}
// INFO: {"checked": "true"}
abstract int bar(String s);
// INFO: {"checked": "true"}
class X {
}
// INFO: {"checked": "true"}
static class Y {
}
}

View File

@@ -1,6 +0,0 @@
abstract class A {
// INFO: {"checked": "true", "toAbstract": "true"}
abstract boolean foo(int n);
}

View File

@@ -1,10 +0,0 @@
class K : A()
fun test(a: A) {
val t1 = a.x
a.x = t1 + 1
val t2 = A.X
a.foo(1)
A.foo2(2)
A.Y()
}

View File

@@ -1,29 +0,0 @@
abstract class <caret>A {
// INFO: {"checked": "true"}
int x = 2 * 3;
// INFO: {"checked": "true"}
static String X = "1" + "2";
// INFO: {"checked": "true"}
boolean foo(int n) {
return n > 0;
}
// INFO: {"checked": "true"}
static String foo2(int n) {
return "_" + n + "_";
}
// INFO: {"checked": "true"}
abstract int bar(String s);
// INFO: {"checked": "true"}
class X {
}
// INFO: {"checked": "true"}
static class Y {
}
}

View File

@@ -1,3 +0,0 @@
Pushed member won't be available in 'foo(1)'
Pushed member won't be available in 'x'
Pushed member won't be available in 'x'

View File

@@ -1,3 +0,0 @@
class K : I
interface IK: I

View File

@@ -1,25 +0,0 @@
abstract class K : I {
// INFO: {"checked": "true"}
class X
// INFO: {"checked": "true"}
abstract fun bar(s: String): Int
companion object {
// INFO: {"checked": "true"}
val x = 2 * 3
}
}
interface IK: I {
// INFO: {"checked": "true"}
class X
// INFO: {"checked": "true"}
fun bar(s: String): Int
companion object {
// INFO: {"checked": "true"}
val x = 2 * 3
}
}

View File

@@ -1,12 +0,0 @@
interface <caret>I {
// INFO: {"checked": "true"}
int x = 2 * 3;
// INFO: {"checked": "true"}
int bar(String s);
// INFO: {"checked": "true"}
class X {
}
}

View File

@@ -1,3 +0,0 @@
interface I {
}

Some files were not shown because too many files have changed in this diff Show More