Run/Debug editor gutter drop down does not work in Kotlin files (KT-8720)
#KT-8720 Fixed
This commit is contained in:
-43
@@ -1,43 +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.configuration
|
||||
|
||||
import com.intellij.lang.annotation.AnnotationHolder
|
||||
import com.intellij.openapi.editor.markup.GutterIconRenderer
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.idea.JetIcons
|
||||
import org.jetbrains.kotlin.idea.MainFunctionDetector
|
||||
import org.jetbrains.kotlin.psi.JetNamedFunction
|
||||
import org.jetbrains.kotlin.psi.JetVisitorVoid
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import javax.swing.Icon
|
||||
|
||||
class MainFunctionGutterVisitor(val holder: AnnotationHolder, val bindingContext: BindingContext) : JetVisitorVoid() {
|
||||
override fun visitNamedFunction(function: JetNamedFunction) {
|
||||
if (MainFunctionDetector(bindingContext).isMain(function)) {
|
||||
function.nameIdentifier?.let { nameIdentifier ->
|
||||
holder.createInfoAnnotation(nameIdentifier, "Run configuration from here").gutterIconRenderer = MainGutterIconRenderer(nameIdentifier)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MainGutterIconRenderer(val nameIdentifier: PsiElement) : GutterIconRenderer() {
|
||||
override fun getIcon(): Icon = JetIcons.LAUNCH
|
||||
override fun hashCode(): Int = nameIdentifier.hashCode()
|
||||
override fun equals(other: Any?): Boolean = other is MainGutterIconRenderer && other.nameIdentifier == nameIdentifier
|
||||
}
|
||||
@@ -39,8 +39,6 @@ import org.jetbrains.kotlin.diagnostics.Severity
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
|
||||
import org.jetbrains.kotlin.idea.actions.internal.KotlinInternalMode
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeFullyAndGetResult
|
||||
import org.jetbrains.kotlin.idea.configuration.MainFunctionGutterVisitor
|
||||
import org.jetbrains.kotlin.idea.kdoc.KDocHighlightingVisitor
|
||||
import org.jetbrains.kotlin.idea.quickfix.QuickFixes
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
||||
@@ -240,9 +238,8 @@ public open class JetPsiChecker : Annotator, HighlightRangeExtension {
|
||||
PropertiesHighlightingVisitor(holder, bindingContext),
|
||||
FunctionsHighlightingVisitor(holder, bindingContext),
|
||||
VariablesHighlightingVisitor(holder, bindingContext),
|
||||
TypeKindHighlightingVisitor(holder, bindingContext),
|
||||
TypeKindHighlightingVisitor(holder, bindingContext)
|
||||
//DeprecatedAnnotationVisitor(holder, bindingContext)
|
||||
MainFunctionGutterVisitor(holder, bindingContext)
|
||||
)
|
||||
|
||||
public fun createQuickfixes(diagnostic: Diagnostic): Collection<IntentionAction> {
|
||||
|
||||
@@ -405,6 +405,7 @@
|
||||
<runConfigurationProducer implementation="org.jetbrains.kotlin.idea.run.KotlinRunConfigurationProducer"/>
|
||||
<codeInsight.lineMarkerProvider language="jet" implementationClass="org.jetbrains.kotlin.idea.highlighter.markers.KotlinLineMarkerProvider"/>
|
||||
<codeInsight.lineMarkerProvider language="jet" implementationClass="org.jetbrains.kotlin.idea.highlighter.KotlinRecursiveCallLineMarkerProvider"/>
|
||||
<codeInsight.lineMarkerProvider language="jet" implementationClass="org.jetbrains.kotlin.idea.highlighter.KotlinRunLineMarkerProvider"/>
|
||||
<iconProvider implementation="org.jetbrains.kotlin.idea.JetIconProvider"/>
|
||||
<itemPresentationProvider implementationClass="org.jetbrains.kotlin.idea.presentation.JetFunctionPresenter"
|
||||
forClass="org.jetbrains.kotlin.psi.JetFunction"/>
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.highlighter
|
||||
|
||||
import com.intellij.codeInsight.daemon.LineMarkerInfo
|
||||
import com.intellij.codeInsight.daemon.LineMarkerProvider
|
||||
import com.intellij.execution.lineMarker.RunLineMarkerInfo
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.idea.JetIcons
|
||||
import org.jetbrains.kotlin.idea.MainFunctionDetector
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
|
||||
import org.jetbrains.kotlin.psi.JetNamedFunction
|
||||
|
||||
|
||||
public class KotlinRunLineMarkerProvider : LineMarkerProvider {
|
||||
override fun getLineMarkerInfo(e: PsiElement): LineMarkerInfo<PsiElement>? {
|
||||
val function = e.parent as? JetNamedFunction
|
||||
if (function == null) return null
|
||||
|
||||
if (function.nameIdentifier != e) return null
|
||||
|
||||
val detector = MainFunctionDetector { function ->
|
||||
function.resolveToDescriptor() as FunctionDescriptor
|
||||
}
|
||||
|
||||
if (detector.isMain(function)) {
|
||||
return RunLineMarkerInfo(function, JetIcons.LAUNCH, null)
|
||||
}
|
||||
|
||||
return null
|
||||
|
||||
}
|
||||
|
||||
override fun collectSlowLineMarkers(elements: List<PsiElement>, result: MutableCollection<LineMarkerInfo<PsiElement>>) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user