Fixed incompatibility with 192

#KT-35918 Comment
This commit is contained in:
Alexander Podkhalyuzin
2020-01-23 13:22:44 +01:00
committed by Vladimir Dolzhenko
parent 2408977a68
commit 13d8603c4b
7 changed files with 87 additions and 14 deletions
+2 -8
View File
@@ -12,14 +12,8 @@
<item index="2" class="java.lang.String" itemvalue="org.gradle.api.tasks.options.Option" />
</list>
</component>
<component name="FacetAutodetectingManager">
<autodetection-disabled>
<facet-type id="Python">
<modules>
<module name="Jet" />
</modules>
</facet-type>
</autodetection-disabled>
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="IdProvider" IDEtalkID="71A301FF1940049D6D82F12C40F1E1D5" />
<component name="JavadocGenerationManager">
@@ -11,8 +11,6 @@ import com.intellij.ide.hierarchy.call.CallHierarchyNodeDescriptor
import com.intellij.ide.hierarchy.call.CalleeMethodsTreeStructure
import com.intellij.ide.util.treeView.NodeDescriptor
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiMember
import com.intellij.psi.PsiMethod
import com.intellij.util.ArrayUtil
import org.jetbrains.kotlin.asJava.unwrapped
import org.jetbrains.kotlin.idea.caches.resolve.analyze
@@ -41,8 +39,9 @@ class KotlinCalleeTreeStructure(
override fun buildChildren(nodeDescriptor: HierarchyNodeDescriptor): Array<Any> {
if (nodeDescriptor is CallHierarchyNodeDescriptor) {
val psiMethod: PsiMember = nodeDescriptor.enclosingElement as? PsiMethod ?: return ArrayUtil.EMPTY_OBJECT_ARRAY
return CalleeMethodsTreeStructure(myProject, psiMethod, scopeType).getChildElements(nodeDescriptor)
val member /* : PsiMember in 193, : PsiMethod in 192 */ =
extractMemberFromDescriptor(nodeDescriptor) ?: return ArrayUtil.EMPTY_OBJECT_ARRAY
return CalleeMethodsTreeStructure(myProject, member, scopeType).getChildElements(nodeDescriptor)
}
val element = nodeDescriptor.psiElement as? KtElement ?: return ArrayUtil.EMPTY_OBJECT_ARRAY
@@ -0,0 +1,13 @@
/*
* Copyright 2010-2020 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.hierarchy.calls
import com.intellij.ide.hierarchy.call.CallHierarchyNodeDescriptor
import com.intellij.psi.PsiMember
fun extractMemberFromDescriptor(nodeDescriptor: CallHierarchyNodeDescriptor): PsiMember? {
return nodeDescriptor.enclosingElement
}
@@ -0,0 +1,13 @@
/*
* Copyright 2010-2020 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.hierarchy.calls
import com.intellij.ide.hierarchy.call.CallHierarchyNodeDescriptor
import com.intellij.psi.PsiMethod
fun extractMemberFromDescriptor(nodeDescriptor: CallHierarchyNodeDescriptor): PsiMethod? {
return nodeDescriptor.enclosingElement as? PsiMethod
}
@@ -65,8 +65,9 @@ class KotlinCallerTreeStructure(
callerToDescriptorMap: MutableMap<PsiElement, NodeDescriptor<*>>
): Collection<Any> {
if (nodeDescriptor is CallHierarchyNodeDescriptor) {
val psiMethod: PsiMember = nodeDescriptor.enclosingElement as? PsiMethod ?: return emptyList()
return CallerMethodsTreeStructure(myProject, psiMethod, scopeType).getChildElements(nodeDescriptor).toList()
val member /* : PsiMember in 193, : PsiMethod in 192 */ =
extractMemberFromDescriptor(nodeDescriptor) ?: return emptyList()
return CallerMethodsTreeStructure(myProject, member, scopeType).getChildElements(nodeDescriptor).toList()
}
if (element !is KtDeclaration) return emptyList()
@@ -0,0 +1,53 @@
/*
* Copyright 2010-2017 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.js
import com.intellij.openapi.module.Module
import com.intellij.openapi.roots.CompilerModuleExtension
import org.jetbrains.jps.util.JpsPathUtil
import org.jetbrains.kotlin.idea.facet.KotlinFacet
import org.jetbrains.kotlin.idea.framework.isGradleModule
import org.jetbrains.kotlin.idea.project.platform
import org.jetbrains.kotlin.platform.js.isJs
import org.jetbrains.plugins.gradle.settings.GradleSystemRunningSettings
val Module.jsTestOutputFilePath: String?
get() {
KotlinFacet.get(this)?.configuration?.settings?.testOutputPath?.let { return it }
if (!shouldUseJpsOutput) return null
val compilerExtension = CompilerModuleExtension.getInstance(this)
val outputDir = compilerExtension?.compilerOutputUrlForTests ?: return null
return JpsPathUtil.urlToPath("$outputDir/${name}_test.js")
}
val Module.jsProductionOutputFilePath: String?
get() {
KotlinFacet.get(this)?.configuration?.settings?.productionOutputPath?.let { return it }
if (!shouldUseJpsOutput) return null
val compilerExtension = CompilerModuleExtension.getInstance(this)
val outputDir = compilerExtension?.compilerOutputUrl ?: return null
return JpsPathUtil.urlToPath("$outputDir/$name.js")
}
fun Module.asJsModule(): Module? = takeIf { it.platform.isJs() }
val Module.shouldUseJpsOutput: Boolean
get() = !(isGradleModule() && GradleSystemRunningSettings.getInstance().isUseGradleAwareMake)