bunch files update after master switched to 191
This commit is contained in:
-74
@@ -1,74 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.refactoring.rename
|
|
||||||
|
|
||||||
import com.intellij.openapi.fileTypes.FileTypeManager
|
|
||||||
import com.intellij.openapi.module.ModuleUtilCore
|
|
||||||
import com.intellij.psi.JavaPsiFacade
|
|
||||||
import com.intellij.psi.PsiReference
|
|
||||||
import com.intellij.psi.PsiElement
|
|
||||||
import com.intellij.psi.search.GlobalSearchScope
|
|
||||||
import com.intellij.psi.search.SearchScope
|
|
||||||
import com.intellij.refactoring.rename.RenamePsiFileProcessor
|
|
||||||
import org.jetbrains.kotlin.asJava.classes.KtLightClass
|
|
||||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
|
|
||||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
|
||||||
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
|
||||||
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
|
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
|
||||||
import org.jetbrains.kotlin.idea.statistics.FUSEventGroups
|
|
||||||
import org.jetbrains.kotlin.idea.statistics.KotlinFUSLogger
|
|
||||||
|
|
||||||
class RenameKotlinFileProcessor : RenamePsiFileProcessor() {
|
|
||||||
class FileRenamingPsiClassWrapper(
|
|
||||||
private val psiClass: KtLightClass,
|
|
||||||
private val file: KtFile
|
|
||||||
) : KtLightClass by psiClass {
|
|
||||||
override fun isValid() = file.isValid
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun canProcessElement(element: PsiElement) =
|
|
||||||
element is KtFile && ProjectRootsUtil.isInProjectSource(element, includeScriptsOutsideSourceRoots = true)
|
|
||||||
|
|
||||||
override fun prepareRenaming(element: PsiElement?,
|
|
||||||
newName: String,
|
|
||||||
allRenames: MutableMap<PsiElement, String>,
|
|
||||||
scope: SearchScope) {
|
|
||||||
val jetFile = element as? KtFile ?: return
|
|
||||||
if (FileTypeManager.getInstance().getFileTypeByFileName(newName) != KotlinFileType.INSTANCE) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val module = ModuleUtilCore.findModuleForPsiElement(element) ?: return
|
|
||||||
|
|
||||||
val fileInfo = JvmFileClassUtil.getFileClassInfoNoResolve(jetFile)
|
|
||||||
if (!fileInfo.withJvmName) {
|
|
||||||
val facadeFqName = fileInfo.facadeClassFqName
|
|
||||||
val project = jetFile.project
|
|
||||||
val facadeClass = JavaPsiFacade.getInstance(project)
|
|
||||||
.findClass(facadeFqName.asString(), GlobalSearchScope.moduleScope(module)) as? KtLightClass
|
|
||||||
if (facadeClass != null) {
|
|
||||||
allRenames[FileRenamingPsiClassWrapper(facadeClass, jetFile)] = PackagePartClassUtils.getFilePartShortName(newName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
override fun findReferences(element: PsiElement): MutableCollection<PsiReference> {
|
|
||||||
return super.findReferences(element).also {
|
|
||||||
KotlinFUSLogger.log(FUSEventGroups.Refactoring, this::class.java.name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.idea.statistics
|
|
||||||
|
|
||||||
open class KotlinFUSLogger {
|
|
||||||
companion object {
|
|
||||||
fun log(group: FUSEventGroups, event: String) {
|
|
||||||
// Not whitelisted for 182
|
|
||||||
}
|
|
||||||
|
|
||||||
fun log(group: FUSEventGroups, event: String, eventData: Map<String, String>) {
|
|
||||||
// Not whitelisted for 182
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.idea.statistics
|
||||||
|
|
||||||
|
open class KotlinFUSLogger {
|
||||||
|
companion object {
|
||||||
|
fun log(group: FUSEventGroups, event: String) {
|
||||||
|
// Not whitelisted for AS
|
||||||
|
}
|
||||||
|
|
||||||
|
fun log(group: FUSEventGroups, event: String, eventData: Map<String, String>) {
|
||||||
|
// Not whitelisted for AS
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.idea.statistics
|
||||||
|
|
||||||
|
open class KotlinFUSLogger {
|
||||||
|
companion object {
|
||||||
|
fun log(group: FUSEventGroups, event: String) {
|
||||||
|
// Not whitelisted for AS
|
||||||
|
}
|
||||||
|
|
||||||
|
fun log(group: FUSEventGroups, event: String, eventData: Map<String, String>) {
|
||||||
|
// Not whitelisted for AS
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.idea.statistics
|
||||||
|
|
||||||
|
open class KotlinFUSLogger {
|
||||||
|
companion object {
|
||||||
|
fun log(group: FUSEventGroups, event: String) {
|
||||||
|
// Not whitelisted for AS
|
||||||
|
}
|
||||||
|
|
||||||
|
fun log(group: FUSEventGroups, event: String, eventData: Map<String, String>) {
|
||||||
|
// Not whitelisted for AS
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user