Add Focus Mode support to kotlin language
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 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.core
|
||||||
|
|
||||||
|
import com.intellij.codeInsight.daemon.impl.focusMode.FocusModeProvider
|
||||||
|
import com.intellij.openapi.util.Segment
|
||||||
|
import com.intellij.psi.PsiAnonymousClass
|
||||||
|
import com.intellij.psi.PsiFile
|
||||||
|
import com.intellij.psi.SyntaxTraverser
|
||||||
|
import org.jetbrains.kotlin.psi.*
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.containingClass
|
||||||
|
|
||||||
|
class KotlinFocusModeProvider : FocusModeProvider {
|
||||||
|
override fun calcFocusZones(file: PsiFile): MutableList<out Segment> =
|
||||||
|
SyntaxTraverser.psiTraverser(file)
|
||||||
|
.postOrderDfsTraversal()
|
||||||
|
.filter {
|
||||||
|
it is KtClassOrObject || it is KtFunction || it is KtClassInitializer
|
||||||
|
}
|
||||||
|
.filter {
|
||||||
|
val p = it.parent
|
||||||
|
p is KtFile || p is KtClassBody
|
||||||
|
}
|
||||||
|
.map {
|
||||||
|
it.textRange
|
||||||
|
}.toMutableList()
|
||||||
|
}
|
||||||
@@ -853,6 +853,8 @@
|
|||||||
|
|
||||||
<usageToPsiElementProvider implementation="org.jetbrains.kotlin.idea.codeInsight.KotlinUsageToPsiElementProvider"/>
|
<usageToPsiElementProvider implementation="org.jetbrains.kotlin.idea.codeInsight.KotlinUsageToPsiElementProvider"/>
|
||||||
|
|
||||||
|
<focusModeProvider language="kotlin" implementationClass="org.jetbrains.kotlin.idea.core.KotlinFocusModeProvider" />
|
||||||
|
|
||||||
<facetType implementation="org.jetbrains.kotlin.idea.facet.KotlinFacetTypeImpl"/>
|
<facetType implementation="org.jetbrains.kotlin.idea.facet.KotlinFacetTypeImpl"/>
|
||||||
|
|
||||||
<lang.sliceProvider language="kotlin" implementationClass="org.jetbrains.kotlin.idea.slicer.KotlinSliceProvider"/>
|
<lang.sliceProvider language="kotlin" implementationClass="org.jetbrains.kotlin.idea.slicer.KotlinSliceProvider"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user