diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml
index b7a15dbb985..850c2d10964 100644
--- a/idea/src/META-INF/plugin.xml
+++ b/idea/src/META-INF/plugin.xml
@@ -58,17 +58,6 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/ShowExpressionTypeAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/ShowExpressionTypeAction.kt
deleted file mode 100644
index d4acb343243..00000000000
--- a/idea/src/org/jetbrains/kotlin/idea/actions/ShowExpressionTypeAction.kt
+++ /dev/null
@@ -1,98 +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.actions
-
-import com.intellij.codeInsight.CodeInsightUtilCore
-import com.intellij.codeInsight.hint.HintManager
-import com.intellij.openapi.actionSystem.ActionManager
-import com.intellij.openapi.actionSystem.AnAction
-import com.intellij.openapi.actionSystem.AnActionEvent
-import com.intellij.openapi.actionSystem.CommonDataKeys
-import com.intellij.openapi.editor.Editor
-import com.intellij.psi.PsiFile
-import org.jetbrains.kotlin.descriptors.CallableDescriptor
-import org.jetbrains.kotlin.idea.KotlinLanguage
-import org.jetbrains.kotlin.idea.caches.resolve.analyze
-import org.jetbrains.kotlin.psi.KtCallableDeclaration
-import org.jetbrains.kotlin.psi.KtExpression
-import org.jetbrains.kotlin.psi.KtFile
-import org.jetbrains.kotlin.psi.psiUtil.endOffset
-import org.jetbrains.kotlin.psi.psiUtil.parents
-import org.jetbrains.kotlin.psi.psiUtil.startOffset
-import org.jetbrains.kotlin.renderer.DescriptorRenderer
-import org.jetbrains.kotlin.resolve.BindingContext
-import org.jetbrains.kotlin.resolve.calls.callUtil.getType
-import org.jetbrains.kotlin.types.KotlinType
-
-@Deprecated("Remove once we no longer support IDEA 14.1") class ShowExpressionTypeAction : AnAction() {
- override fun actionPerformed(e: AnActionEvent) {
- val editor = e.getData(CommonDataKeys.EDITOR) ?: return
- val psiFile = e.getData(CommonDataKeys.PSI_FILE) as? KtFile ?: return
-
- val type = if (editor.selectionModel.hasSelection()) {
- val startOffset = editor.selectionModel.selectionStart
- val endOffset = editor.selectionModel.selectionEnd
- val expression = CodeInsightUtilCore.findElementInRange(psiFile, startOffset, endOffset, KtExpression::class.java, KotlinLanguage.INSTANCE) ?: return
- typeByExpression(expression)
- }
- else {
- val offset = editor.caretModel.offset
- val token = psiFile.findElementAt(offset) ?: return
- val pair = token.parents
- .filterIsInstance()
- .map { it to typeByExpression(it) }
- .firstOrNull { it.second != null } ?: return
- val (expression, type) = pair
- editor.selectionModel.setSelection(expression.startOffset, expression.endOffset)
- type
- }
-
- if (type != null) {
- HintManager.getInstance().showInformationHint(editor, renderTypeHint(type))
- }
- }
-
-
- override fun update(e: AnActionEvent) {
- // hide the action in IDEA 15 where a standard platform action is available
- if (ActionManager.getInstance().getAction("ExpressionTypeInfo") != null) {
- e.presentation.isVisible = false
- return
- }
-
- val editor = e.getData(CommonDataKeys.EDITOR)
- val psiFile = e.getData(CommonDataKeys.PSI_FILE)
- e.presentation.isEnabled = editor != null && psiFile is KtFile
- }
-
- companion object {
- fun renderTypeHint(type: KotlinType) = "" + DescriptorRenderer.HTML.renderType(type) + ""
-
- fun typeByExpression(expression: KtExpression): KotlinType? {
- val bindingContext = expression.analyze()
-
- if (expression is KtCallableDeclaration) {
- val descriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, expression] as? CallableDescriptor
- if (descriptor != null) {
- return descriptor.returnType
- }
- }
-
- return expression.getType(bindingContext)
- }
- }
-}
diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt
index 0e71147af43..19ac19c991b 100644
--- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt
@@ -18,11 +18,17 @@ package org.jetbrains.kotlin.idea.codeInsight
import com.intellij.lang.ExpressionTypeProvider
import com.intellij.psi.PsiElement
-import org.jetbrains.kotlin.idea.actions.ShowExpressionTypeAction
+import org.jetbrains.kotlin.descriptors.CallableDescriptor
+import org.jetbrains.kotlin.idea.caches.resolve.analyze
+import org.jetbrains.kotlin.psi.KtCallableDeclaration
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtFunction
import org.jetbrains.kotlin.psi.KtStatementExpression
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
+import org.jetbrains.kotlin.renderer.DescriptorRenderer
+import org.jetbrains.kotlin.resolve.BindingContext
+import org.jetbrains.kotlin.resolve.calls.callUtil.getType
+import org.jetbrains.kotlin.types.KotlinType
class KotlinExpressionTypeProvider : ExpressionTypeProvider() {
override fun getExpressionsAt(elementAt: PsiElement): List =
@@ -33,9 +39,27 @@ class KotlinExpressionTypeProvider : ExpressionTypeProvider() {
}
override fun getInformationHint(element: KtExpression): String {
- val type = ShowExpressionTypeAction.typeByExpression(element) ?: return "Type is unknown"
- return ShowExpressionTypeAction.renderTypeHint(type)
+ val type = typeByExpression(element) ?: return "Type is unknown"
+ return renderTypeHint(type)
}
override fun getErrorHint(): String = "No expression found"
+
+ companion object {
+ fun renderTypeHint(type: KotlinType) = "" + DescriptorRenderer.HTML.renderType(type) + ""
+
+ fun typeByExpression(expression: KtExpression): KotlinType? {
+ val bindingContext = expression.analyze()
+
+ if (expression is KtCallableDeclaration) {
+ val descriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, expression] as? CallableDescriptor
+ if (descriptor != null) {
+ return descriptor.returnType
+ }
+ }
+
+ return expression.getType(bindingContext)
+ }
+ }
}
+