Reformat: idea.highlighter package
This commit is contained in:
@@ -103,8 +103,7 @@ var <PACKAGE_PROPERTY><MUTABLE_VARIABLE>globalCounter</MUTABLE_VARIABLE></PACKAG
|
|||||||
if (Modifier.isStatic(field.modifiers)) {
|
if (Modifier.isStatic(field.modifiers)) {
|
||||||
try {
|
try {
|
||||||
map.put(field.name, field.get(null) as TextAttributesKey)
|
map.put(field.name, field.get(null) as TextAttributesKey)
|
||||||
}
|
} catch (e: IllegalAccessException) {
|
||||||
catch (e: IllegalAccessException) {
|
|
||||||
assert(false)
|
assert(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +118,8 @@ var <PACKAGE_PROPERTY><MUTABLE_VARIABLE>globalCounter</MUTABLE_VARIABLE></PACKAG
|
|||||||
override fun getAttributeDescriptors(): Array<AttributesDescriptor> {
|
override fun getAttributeDescriptors(): Array<AttributesDescriptor> {
|
||||||
infix fun String.to(key: TextAttributesKey) = AttributesDescriptor(this, key)
|
infix fun String.to(key: TextAttributesKey) = AttributesDescriptor(this, key)
|
||||||
|
|
||||||
return arrayOf(OptionsBundle.message("options.java.attribute.descriptor.keyword") to KotlinHighlightingColors.KEYWORD,
|
return arrayOf(
|
||||||
|
OptionsBundle.message("options.java.attribute.descriptor.keyword") to KotlinHighlightingColors.KEYWORD,
|
||||||
KotlinBundle.message("options.kotlin.attribute.descriptor.builtin.annotation") to KotlinHighlightingColors.BUILTIN_ANNOTATION,
|
KotlinBundle.message("options.kotlin.attribute.descriptor.builtin.annotation") to KotlinHighlightingColors.BUILTIN_ANNOTATION,
|
||||||
OptionsBundle.message("options.java.attribute.descriptor.number") to KotlinHighlightingColors.NUMBER,
|
OptionsBundle.message("options.java.attribute.descriptor.number") to KotlinHighlightingColors.NUMBER,
|
||||||
OptionsBundle.message("options.java.attribute.descriptor.string") to KotlinHighlightingColors.STRING,
|
OptionsBundle.message("options.java.attribute.descriptor.string") to KotlinHighlightingColors.STRING,
|
||||||
@@ -176,7 +176,8 @@ var <PACKAGE_PROPERTY><MUTABLE_VARIABLE>globalCounter</MUTABLE_VARIABLE></PACKAG
|
|||||||
KotlinBundle.message("options.kotlin.attribute.descriptor.smart.constant") to KotlinHighlightingColors.SMART_CONSTANT,
|
KotlinBundle.message("options.kotlin.attribute.descriptor.smart.constant") to KotlinHighlightingColors.SMART_CONSTANT,
|
||||||
KotlinBundle.message("options.kotlin.attribute.descriptor.smart.cast.receiver") to KotlinHighlightingColors.SMART_CAST_RECEIVER,
|
KotlinBundle.message("options.kotlin.attribute.descriptor.smart.cast.receiver") to KotlinHighlightingColors.SMART_CAST_RECEIVER,
|
||||||
KotlinBundle.message("options.kotlin.attribute.descriptor.label") to KotlinHighlightingColors.LABEL,
|
KotlinBundle.message("options.kotlin.attribute.descriptor.label") to KotlinHighlightingColors.LABEL,
|
||||||
"Named argument" to KotlinHighlightingColors.NAMED_ARGUMENT) +
|
"Named argument" to KotlinHighlightingColors.NAMED_ARGUMENT
|
||||||
|
) +
|
||||||
DslHighlighterExtension.descriptionsToStyles.map { (description, key) -> description to key }.toTypedArray()
|
DslHighlighterExtension.descriptionsToStyles.map { (description, key) -> description to key }.toTypedArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -50,7 +50,8 @@ class KotlinHighlightExitPointsHandlerFactory : HighlightUsagesHandlerFactoryBas
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MyHandler(editor: Editor, file: PsiFile, val target: KtExpression) : HighlightUsagesHandlerBase<PsiElement>(editor, file) {
|
private class MyHandler(editor: Editor, file: PsiFile, val target: KtExpression) :
|
||||||
|
HighlightUsagesHandlerBase<PsiElement>(editor, file) {
|
||||||
override fun getTargets() = listOf(target)
|
override fun getTargets() = listOf(target)
|
||||||
|
|
||||||
override fun selectTargets(targets: MutableList<PsiElement>, selectionConsumer: Consumer<MutableList<PsiElement>>) {
|
override fun selectTargets(targets: MutableList<PsiElement>, selectionConsumer: Consumer<MutableList<PsiElement>>) {
|
||||||
|
|||||||
+10
-6
@@ -62,7 +62,12 @@ class KotlinRecursiveCallLineMarkerProvider : LineMarkerProvider {
|
|||||||
private fun getEnclosingFunction(element: KtElement, stopOnNonInlinedLambdas: Boolean): KtNamedFunction? {
|
private fun getEnclosingFunction(element: KtElement, stopOnNonInlinedLambdas: Boolean): KtNamedFunction? {
|
||||||
for (parent in element.parents) {
|
for (parent in element.parents) {
|
||||||
when (parent) {
|
when (parent) {
|
||||||
is KtFunctionLiteral -> if (stopOnNonInlinedLambdas && !InlineUtil.isInlinedArgument(parent, parent.analyze(), false)) return null
|
is KtFunctionLiteral -> if (stopOnNonInlinedLambdas && !InlineUtil.isInlinedArgument(
|
||||||
|
parent,
|
||||||
|
parent.analyze(),
|
||||||
|
false
|
||||||
|
)
|
||||||
|
) return null
|
||||||
is KtNamedFunction -> {
|
is KtNamedFunction -> {
|
||||||
when (parent.parent) {
|
when (parent.parent) {
|
||||||
is KtBlockExpression, is KtClassBody, is KtFile, is KtScript -> return parent
|
is KtBlockExpression, is KtClassBody, is KtFile, is KtScript -> return parent
|
||||||
@@ -84,7 +89,8 @@ class KotlinRecursiveCallLineMarkerProvider : LineMarkerProvider {
|
|||||||
|
|
||||||
val enclosingFunctionName = enclosingFunction.name
|
val enclosingFunctionName = enclosingFunction.name
|
||||||
if (enclosingFunctionName != OperatorNameConventions.INVOKE.asString()
|
if (enclosingFunctionName != OperatorNameConventions.INVOKE.asString()
|
||||||
&& enclosingFunctionName != resolveName.asString()) return false
|
&& enclosingFunctionName != resolveName.asString()
|
||||||
|
) return false
|
||||||
|
|
||||||
// Check that there were no not-inlined lambdas on the way to enclosing function
|
// Check that there were no not-inlined lambdas on the way to enclosing function
|
||||||
if (enclosingFunction != getEnclosingFunction(element, true)) return false
|
if (enclosingFunction != getEnclosingFunction(element, true)) return false
|
||||||
@@ -113,8 +119,7 @@ class KotlinRecursiveCallLineMarkerProvider : LineMarkerProvider {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RecursiveMethodCallMarkerInfo(callElement: PsiElement)
|
private class RecursiveMethodCallMarkerInfo(callElement: PsiElement) : LineMarkerInfo<PsiElement>(
|
||||||
: LineMarkerInfo<PsiElement>(
|
|
||||||
callElement,
|
callElement,
|
||||||
callElement.textRange,
|
callElement.textRange,
|
||||||
AllIcons.Gutter.RecursiveMethod,
|
AllIcons.Gutter.RecursiveMethod,
|
||||||
@@ -163,8 +168,7 @@ private fun getCallNameFromPsi(element: KtElement): Name? {
|
|||||||
OperatorConventions.getNameForOperationSymbol(node)
|
OperatorConventions.getNameForOperationSymbol(node)
|
||||||
|
|
||||||
conventionName ?: Name.identifier(element.getText())
|
conventionName ?: Name.identifier(element.getText())
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Name.identifier(element.getText())
|
Name.identifier(element.getText())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-6
@@ -62,7 +62,12 @@ class KotlinRecursiveCallLineMarkerProvider : LineMarkerProvider {
|
|||||||
private fun getEnclosingFunction(element: KtElement, stopOnNonInlinedLambdas: Boolean): KtNamedFunction? {
|
private fun getEnclosingFunction(element: KtElement, stopOnNonInlinedLambdas: Boolean): KtNamedFunction? {
|
||||||
for (parent in element.parents) {
|
for (parent in element.parents) {
|
||||||
when (parent) {
|
when (parent) {
|
||||||
is KtFunctionLiteral -> if (stopOnNonInlinedLambdas && !InlineUtil.isInlinedArgument(parent, parent.analyze(), false)) return null
|
is KtFunctionLiteral -> if (stopOnNonInlinedLambdas && !InlineUtil.isInlinedArgument(
|
||||||
|
parent,
|
||||||
|
parent.analyze(),
|
||||||
|
false
|
||||||
|
)
|
||||||
|
) return null
|
||||||
is KtNamedFunction -> {
|
is KtNamedFunction -> {
|
||||||
when (parent.parent) {
|
when (parent.parent) {
|
||||||
is KtBlockExpression, is KtClassBody, is KtFile, is KtScript -> return parent
|
is KtBlockExpression, is KtClassBody, is KtFile, is KtScript -> return parent
|
||||||
@@ -84,7 +89,8 @@ class KotlinRecursiveCallLineMarkerProvider : LineMarkerProvider {
|
|||||||
|
|
||||||
val enclosingFunctionName = enclosingFunction.name
|
val enclosingFunctionName = enclosingFunction.name
|
||||||
if (enclosingFunctionName != OperatorNameConventions.INVOKE.asString()
|
if (enclosingFunctionName != OperatorNameConventions.INVOKE.asString()
|
||||||
&& enclosingFunctionName != resolveName.asString()) return false
|
&& enclosingFunctionName != resolveName.asString()
|
||||||
|
) return false
|
||||||
|
|
||||||
// Check that there were no not-inlined lambdas on the way to enclosing function
|
// Check that there were no not-inlined lambdas on the way to enclosing function
|
||||||
if (enclosingFunction != getEnclosingFunction(element, true)) return false
|
if (enclosingFunction != getEnclosingFunction(element, true)) return false
|
||||||
@@ -113,8 +119,7 @@ class KotlinRecursiveCallLineMarkerProvider : LineMarkerProvider {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RecursiveMethodCallMarkerInfo(callElement: KtElement)
|
private class RecursiveMethodCallMarkerInfo(callElement: KtElement) : LineMarkerInfo<KtElement>(
|
||||||
: LineMarkerInfo<KtElement>(
|
|
||||||
callElement,
|
callElement,
|
||||||
callElement.textRange,
|
callElement.textRange,
|
||||||
AllIcons.Gutter.RecursiveMethod,
|
AllIcons.Gutter.RecursiveMethod,
|
||||||
@@ -154,8 +159,7 @@ private fun getCallNameFromPsi(element: KtElement): Name? {
|
|||||||
OperatorConventions.getNameForOperationSymbol(node)
|
OperatorConventions.getNameForOperationSymbol(node)
|
||||||
|
|
||||||
conventionName ?: Name.identifier(element.getText())
|
conventionName ?: Name.identifier(element.getText())
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Name.identifier(element.getText())
|
Name.identifier(element.getText())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.psi.*
|
|||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext.*
|
import org.jetbrains.kotlin.resolve.BindingContext.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||||
import org.jetbrains.kotlin.resolve.calls.checkers.isBuiltInCoroutineContext
|
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||||
|
|
||||||
|
|||||||
@@ -51,8 +51,10 @@ class PlatformExpectedAnnotator : Annotator {
|
|||||||
|
|
||||||
val trace = BindingTraceContext()
|
val trace = BindingTraceContext()
|
||||||
for (module in implementingModules) {
|
for (module in implementingModules) {
|
||||||
ExpectedActualDeclarationChecker.checkExpectedDeclarationHasActual(declaration, descriptor, trace, module,
|
ExpectedActualDeclarationChecker.checkExpectedDeclarationHasActual(
|
||||||
ExpectActualTracker.DoNothing)
|
declaration, descriptor, trace, module,
|
||||||
|
ExpectActualTracker.DoNothing
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val suppressionCache = KotlinCacheService.getInstance(declaration.project).getSuppressionCache()
|
val suppressionCache = KotlinCacheService.getInstance(declaration.project).getSuppressionCache()
|
||||||
|
|||||||
@@ -51,9 +51,11 @@ fun navigateToPlatformActual(e: MouseEvent?, declaration: KtDeclaration?) {
|
|||||||
val renderer = object : DefaultPsiElementCellRenderer() {
|
val renderer = object : DefaultPsiElementCellRenderer() {
|
||||||
override fun getContainerText(element: PsiElement?, name: String?) = ""
|
override fun getContainerText(element: PsiElement?, name: String?) = ""
|
||||||
}
|
}
|
||||||
PsiElementListNavigator.openTargets(e,
|
PsiElementListNavigator.openTargets(
|
||||||
|
e,
|
||||||
actualDeclarations.toTypedArray(),
|
actualDeclarations.toTypedArray(),
|
||||||
"Choose actual for ${declaration.name}",
|
"Choose actual for ${declaration.name}",
|
||||||
"Actuals for ${declaration.name}",
|
"Actuals for ${declaration.name}",
|
||||||
renderer)
|
renderer
|
||||||
|
)
|
||||||
}
|
}
|
||||||
@@ -21,10 +21,14 @@ import com.intellij.psi.CommonClassNames
|
|||||||
import com.intellij.psi.PsiClass
|
import com.intellij.psi.PsiClass
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import com.intellij.psi.PsiMethod
|
import com.intellij.psi.PsiMethod
|
||||||
import org.jetbrains.kotlin.asJava.*
|
import org.jetbrains.kotlin.asJava.LightClassUtil
|
||||||
|
import org.jetbrains.kotlin.asJava.toLightClass
|
||||||
import org.jetbrains.kotlin.idea.caches.lightClasses.KtFakeLightClass
|
import org.jetbrains.kotlin.idea.caches.lightClasses.KtFakeLightClass
|
||||||
import org.jetbrains.kotlin.idea.caches.lightClasses.KtFakeLightMethod
|
import org.jetbrains.kotlin.idea.caches.lightClasses.KtFakeLightMethod
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.KtClass
|
||||||
|
import org.jetbrains.kotlin.psi.KtFunction
|
||||||
|
import org.jetbrains.kotlin.psi.KtNamedFunction
|
||||||
|
import org.jetbrains.kotlin.psi.KtSecondaryConstructor
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
fun collectContainingClasses(methods: Collection<PsiMethod>): Set<PsiClass> {
|
fun collectContainingClasses(methods: Collection<PsiMethod>): Set<PsiClass> {
|
||||||
|
|||||||
+20
-11
@@ -57,7 +57,8 @@ class KotlinLineMarkerProvider : LineMarkerProvider {
|
|||||||
if (element.canHaveSeparator()) {
|
if (element.canHaveSeparator()) {
|
||||||
val prevSibling = element.getPrevSiblingIgnoringWhitespaceAndComments()
|
val prevSibling = element.getPrevSiblingIgnoringWhitespaceAndComments()
|
||||||
if (prevSibling.canHaveSeparator() &&
|
if (prevSibling.canHaveSeparator() &&
|
||||||
(element.wantsSeparator() || prevSibling?.wantsSeparator() == true)) {
|
(element.wantsSeparator() || prevSibling?.wantsSeparator() == true)
|
||||||
|
) {
|
||||||
return createLineSeparatorByElement(element)
|
return createLineSeparatorByElement(element)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,8 +123,7 @@ class KotlinLineMarkerProvider : LineMarkerProvider {
|
|||||||
|
|
||||||
if (element.isExpectDeclaration()) {
|
if (element.isExpectDeclaration()) {
|
||||||
collectActualMarkers(element, result)
|
collectActualMarkers(element, result)
|
||||||
}
|
} else if (element.isEffectivelyActual()) {
|
||||||
else if (element.isEffectivelyActual()) {
|
|
||||||
collectExpectedMarkers(element, result)
|
collectExpectedMarkers(element, result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,7 @@ interface TestableLineMarkerNavigator {
|
|||||||
fun getTargetsPopupDescriptor(element: PsiElement?): NavigationPopupDescriptor?
|
fun getTargetsPopupDescriptor(element: PsiElement?): NavigationPopupDescriptor?
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SubclassRenderer: PsiClassOrFunctionalExpressionListCellRenderer() {
|
private class SubclassRenderer : PsiClassOrFunctionalExpressionListCellRenderer() {
|
||||||
override fun getComparingObject(element: NavigatablePsiElement?): Comparable<Nothing> {
|
override fun getComparingObject(element: NavigatablePsiElement?): Comparable<Nothing> {
|
||||||
val baseText = super.getComparingObject(element)
|
val baseText = super.getComparingObject(element)
|
||||||
val moduleName = element?.module?.name ?: return baseText
|
val moduleName = element?.module?.name ?: return baseText
|
||||||
@@ -233,7 +233,10 @@ private val EXPECTED_DECLARATION = MarkerType(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun isImplementsAndNotOverrides(descriptor: CallableMemberDescriptor, overriddenMembers: Collection<CallableMemberDescriptor>): Boolean {
|
private fun isImplementsAndNotOverrides(
|
||||||
|
descriptor: CallableMemberDescriptor,
|
||||||
|
overriddenMembers: Collection<CallableMemberDescriptor>
|
||||||
|
): Boolean {
|
||||||
return descriptor.modality != Modality.ABSTRACT && overriddenMembers.all { it.modality == Modality.ABSTRACT }
|
return descriptor.modality != Modality.ABSTRACT && overriddenMembers.all { it.modality == Modality.ABSTRACT }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,8 +300,10 @@ private fun collectInheritedClassMarker(element: KtClass, result: MutableCollect
|
|||||||
result.add(lineMarkerInfo)
|
result.add(lineMarkerInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun collectOverriddenPropertyAccessors(properties: Collection<KtNamedDeclaration>,
|
private fun collectOverriddenPropertyAccessors(
|
||||||
result: MutableCollection<LineMarkerInfo<*>>) {
|
properties: Collection<KtNamedDeclaration>,
|
||||||
|
result: MutableCollection<LineMarkerInfo<*>>
|
||||||
|
) {
|
||||||
val mappingToJava = HashMap<PsiElement, KtNamedDeclaration>()
|
val mappingToJava = HashMap<PsiElement, KtNamedDeclaration>()
|
||||||
for (property in properties) {
|
for (property in properties) {
|
||||||
if (property.isOverridable()) {
|
if (property.isOverridable()) {
|
||||||
@@ -340,8 +345,10 @@ private val KtNamedDeclaration.expectOrActualAnchor
|
|||||||
}
|
}
|
||||||
?: this
|
?: this
|
||||||
|
|
||||||
private fun collectActualMarkers(declaration: KtNamedDeclaration,
|
private fun collectActualMarkers(
|
||||||
result: MutableCollection<LineMarkerInfo<*>>) {
|
declaration: KtNamedDeclaration,
|
||||||
|
result: MutableCollection<LineMarkerInfo<*>>
|
||||||
|
) {
|
||||||
|
|
||||||
val descriptor = declaration.toDescriptor() as? MemberDescriptor ?: return
|
val descriptor = declaration.toDescriptor() as? MemberDescriptor ?: return
|
||||||
val commonModuleDescriptor = declaration.containingKtFile.findModuleDescriptor()
|
val commonModuleDescriptor = declaration.containingKtFile.findModuleDescriptor()
|
||||||
@@ -367,8 +374,10 @@ private fun collectActualMarkers(declaration: KtNamedDeclaration,
|
|||||||
result.add(lineMarkerInfo)
|
result.add(lineMarkerInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun collectExpectedMarkers(declaration: KtNamedDeclaration,
|
private fun collectExpectedMarkers(
|
||||||
result: MutableCollection<LineMarkerInfo<*>>) {
|
declaration: KtNamedDeclaration,
|
||||||
|
result: MutableCollection<LineMarkerInfo<*>>
|
||||||
|
) {
|
||||||
|
|
||||||
val descriptor = declaration.toDescriptor() as? MemberDescriptor ?: return
|
val descriptor = declaration.toDescriptor() as? MemberDescriptor ?: return
|
||||||
val platformModuleDescriptor = declaration.containingKtFile.findModuleDescriptor()
|
val platformModuleDescriptor = declaration.containingKtFile.findModuleDescriptor()
|
||||||
|
|||||||
+19
-10
@@ -56,7 +56,8 @@ class KotlinLineMarkerProvider : LineMarkerProvider {
|
|||||||
if (element.canHaveSeparator()) {
|
if (element.canHaveSeparator()) {
|
||||||
val prevSibling = element.getPrevSiblingIgnoringWhitespaceAndComments()
|
val prevSibling = element.getPrevSiblingIgnoringWhitespaceAndComments()
|
||||||
if (prevSibling.canHaveSeparator() &&
|
if (prevSibling.canHaveSeparator() &&
|
||||||
(element.wantsSeparator() || prevSibling?.wantsSeparator() == true)) {
|
(element.wantsSeparator() || prevSibling?.wantsSeparator() == true)
|
||||||
|
) {
|
||||||
return createLineSeparatorByElement(element)
|
return createLineSeparatorByElement(element)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,8 +122,7 @@ class KotlinLineMarkerProvider : LineMarkerProvider {
|
|||||||
|
|
||||||
if (element.isExpectDeclaration()) {
|
if (element.isExpectDeclaration()) {
|
||||||
collectActualMarkers(element, result)
|
collectActualMarkers(element, result)
|
||||||
}
|
} else if (element.isEffectivelyActual()) {
|
||||||
else if (element.isEffectivelyActual()) {
|
|
||||||
collectExpectedMarkers(element, result)
|
collectExpectedMarkers(element, result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,7 +224,10 @@ private val EXPECTED_DECLARATION = MarkerType(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun isImplementsAndNotOverrides(descriptor: CallableMemberDescriptor, overriddenMembers: Collection<CallableMemberDescriptor>): Boolean {
|
private fun isImplementsAndNotOverrides(
|
||||||
|
descriptor: CallableMemberDescriptor,
|
||||||
|
overriddenMembers: Collection<CallableMemberDescriptor>
|
||||||
|
): Boolean {
|
||||||
return descriptor.modality != Modality.ABSTRACT && overriddenMembers.all { it.modality == Modality.ABSTRACT }
|
return descriptor.modality != Modality.ABSTRACT && overriddenMembers.all { it.modality == Modality.ABSTRACT }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,8 +291,10 @@ private fun collectInheritedClassMarker(element: KtClass, result: MutableCollect
|
|||||||
result.add(lineMarkerInfo)
|
result.add(lineMarkerInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun collectOverriddenPropertyAccessors(properties: Collection<KtNamedDeclaration>,
|
private fun collectOverriddenPropertyAccessors(
|
||||||
result: MutableCollection<LineMarkerInfo<*>>) {
|
properties: Collection<KtNamedDeclaration>,
|
||||||
|
result: MutableCollection<LineMarkerInfo<*>>
|
||||||
|
) {
|
||||||
val mappingToJava = HashMap<PsiElement, KtNamedDeclaration>()
|
val mappingToJava = HashMap<PsiElement, KtNamedDeclaration>()
|
||||||
for (property in properties) {
|
for (property in properties) {
|
||||||
if (property.isOverridable()) {
|
if (property.isOverridable()) {
|
||||||
@@ -331,8 +336,10 @@ private val KtNamedDeclaration.expectOrActualAnchor
|
|||||||
}
|
}
|
||||||
?: this
|
?: this
|
||||||
|
|
||||||
private fun collectActualMarkers(declaration: KtNamedDeclaration,
|
private fun collectActualMarkers(
|
||||||
result: MutableCollection<LineMarkerInfo<*>>) {
|
declaration: KtNamedDeclaration,
|
||||||
|
result: MutableCollection<LineMarkerInfo<*>>
|
||||||
|
) {
|
||||||
|
|
||||||
val descriptor = declaration.toDescriptor() as? MemberDescriptor ?: return
|
val descriptor = declaration.toDescriptor() as? MemberDescriptor ?: return
|
||||||
val commonModuleDescriptor = declaration.containingKtFile.findModuleDescriptor()
|
val commonModuleDescriptor = declaration.containingKtFile.findModuleDescriptor()
|
||||||
@@ -358,8 +365,10 @@ private fun collectActualMarkers(declaration: KtNamedDeclaration,
|
|||||||
result.add(lineMarkerInfo)
|
result.add(lineMarkerInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun collectExpectedMarkers(declaration: KtNamedDeclaration,
|
private fun collectExpectedMarkers(
|
||||||
result: MutableCollection<LineMarkerInfo<*>>) {
|
declaration: KtNamedDeclaration,
|
||||||
|
result: MutableCollection<LineMarkerInfo<*>>
|
||||||
|
) {
|
||||||
|
|
||||||
val descriptor = declaration.toDescriptor() as? MemberDescriptor ?: return
|
val descriptor = declaration.toDescriptor() as? MemberDescriptor ?: return
|
||||||
val platformModuleDescriptor = declaration.containingKtFile.findModuleDescriptor()
|
val platformModuleDescriptor = declaration.containingKtFile.findModuleDescriptor()
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import com.intellij.psi.PsiMethod
|
|||||||
import com.intellij.psi.PsiModifier
|
import com.intellij.psi.PsiModifier
|
||||||
import com.intellij.psi.search.PsiElementProcessor
|
import com.intellij.psi.search.PsiElementProcessor
|
||||||
import com.intellij.psi.search.PsiElementProcessorAdapter
|
import com.intellij.psi.search.PsiElementProcessorAdapter
|
||||||
import com.intellij.psi.search.searches.OverridingMethodsSearch
|
|
||||||
import com.intellij.util.CommonProcessors
|
import com.intellij.util.CommonProcessors
|
||||||
import gnu.trove.THashSet
|
import gnu.trove.THashSet
|
||||||
import org.jetbrains.kotlin.asJava.elements.KtLightMethod
|
import org.jetbrains.kotlin.asJava.elements.KtLightMethod
|
||||||
@@ -91,7 +90,8 @@ fun buildNavigateToOverriddenMethodPopup(e: MouseEvent?, element: PsiElement?):
|
|||||||
val method = getPsiMethod(element) ?: return null
|
val method = getPsiMethod(element) ?: return null
|
||||||
|
|
||||||
if (DumbService.isDumb(method.project)) {
|
if (DumbService.isDumb(method.project)) {
|
||||||
DumbService.getInstance(method.project)?.showDumbModeNotification("Navigation to overriding classes is not possible during index update")
|
DumbService.getInstance(method.project)
|
||||||
|
?.showDumbModeNotification("Navigation to overriding classes is not possible during index update")
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +104,9 @@ fun buildNavigateToOverriddenMethodPopup(e: MouseEvent?, element: PsiElement?):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Searching for overriding declarations", true, method.project, e?.component as JComponent?)) {
|
"Searching for overriding declarations", true, method.project, e?.component as JComponent?
|
||||||
|
)
|
||||||
|
) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,16 +117,19 @@ fun buildNavigateToOverriddenMethodPopup(e: MouseEvent?, element: PsiElement?):
|
|||||||
overridingJavaMethods = overridingJavaMethods.sortedWith(renderer.comparator)
|
overridingJavaMethods = overridingJavaMethods.sortedWith(renderer.comparator)
|
||||||
|
|
||||||
val methodsUpdater = OverridingMethodsUpdater(method, renderer)
|
val methodsUpdater = OverridingMethodsUpdater(method, renderer)
|
||||||
return NavigationPopupDescriptor(overridingJavaMethods,
|
return NavigationPopupDescriptor(
|
||||||
|
overridingJavaMethods,
|
||||||
methodsUpdater.getCaption(overridingJavaMethods.size),
|
methodsUpdater.getCaption(overridingJavaMethods.size),
|
||||||
"Overriding declarations of " + method.name,
|
"Overriding declarations of " + method.name,
|
||||||
renderer,
|
renderer,
|
||||||
methodsUpdater)
|
methodsUpdater
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private class OverridingMethodsUpdater(
|
private class OverridingMethodsUpdater(
|
||||||
private val myMethod: PsiMethod,
|
private val myMethod: PsiMethod,
|
||||||
private val myRenderer: PsiElementListCellRenderer<out PsiElement>) :
|
private val myRenderer: PsiElementListCellRenderer<out PsiElement>
|
||||||
|
) :
|
||||||
ListBackgroundUpdaterTask(myMethod.project, "Searching for overriding methods") {
|
ListBackgroundUpdaterTask(myMethod.project, "Searching for overriding methods") {
|
||||||
override fun getCaption(size: Int): String {
|
override fun getCaption(size: Int): String {
|
||||||
return if (myMethod.hasModifierProperty(PsiModifier.ABSTRACT))
|
return if (myMethod.hasModifierProperty(PsiModifier.ABSTRACT))
|
||||||
|
|||||||
@@ -29,11 +29,9 @@ import com.intellij.psi.PsiMethod
|
|||||||
import com.intellij.psi.search.GlobalSearchScope
|
import com.intellij.psi.search.GlobalSearchScope
|
||||||
import com.intellij.psi.search.PsiElementProcessor
|
import com.intellij.psi.search.PsiElementProcessor
|
||||||
import com.intellij.psi.search.PsiElementProcessorAdapter
|
import com.intellij.psi.search.PsiElementProcessorAdapter
|
||||||
import com.intellij.psi.search.searches.OverridingMethodsSearch
|
|
||||||
import com.intellij.util.AdapterProcessor
|
import com.intellij.util.AdapterProcessor
|
||||||
import com.intellij.util.CommonProcessors
|
import com.intellij.util.CommonProcessors
|
||||||
import com.intellij.util.Function
|
import com.intellij.util.Function
|
||||||
import org.jetbrains.kotlin.asJava.getAccessorLightMethods
|
|
||||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||||
import org.jetbrains.kotlin.idea.search.declarationsSearch.forEachOverridingMethod
|
import org.jetbrains.kotlin.idea.search.declarationsSearch.forEachOverridingMethod
|
||||||
import org.jetbrains.kotlin.idea.search.declarationsSearch.toPossiblyFakeLightMethods
|
import org.jetbrains.kotlin.idea.search.declarationsSearch.toPossiblyFakeLightMethods
|
||||||
@@ -92,7 +90,8 @@ fun buildNavigateToPropertyOverriddenDeclarationsPopup(e: MouseEvent?, element:
|
|||||||
KotlinDefinitionsSearcher.processPropertyImplementationsMethods(
|
KotlinDefinitionsSearcher.processPropertyImplementationsMethods(
|
||||||
psiPropertyMethods,
|
psiPropertyMethods,
|
||||||
GlobalSearchScope.allScope(project),
|
GlobalSearchScope.allScope(project),
|
||||||
elementProcessor)
|
elementProcessor
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(
|
if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(
|
||||||
@@ -100,7 +99,9 @@ fun buildNavigateToPropertyOverriddenDeclarationsPopup(e: MouseEvent?, element:
|
|||||||
MarkerType.SEARCHING_FOR_OVERRIDING_METHODS,
|
MarkerType.SEARCHING_FOR_OVERRIDING_METHODS,
|
||||||
/* can be canceled */ true,
|
/* can be canceled */ true,
|
||||||
project,
|
project,
|
||||||
e?.component as JComponent?)) {
|
e?.component as JComponent?
|
||||||
|
)
|
||||||
|
) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,9 +110,11 @@ fun buildNavigateToPropertyOverriddenDeclarationsPopup(e: MouseEvent?, element:
|
|||||||
.sortedWith(renderer.comparator)
|
.sortedWith(renderer.comparator)
|
||||||
.filterIsInstance<NavigatablePsiElement>()
|
.filterIsInstance<NavigatablePsiElement>()
|
||||||
|
|
||||||
return NavigationPopupDescriptor(navigatingOverrides,
|
return NavigationPopupDescriptor(
|
||||||
|
navigatingOverrides,
|
||||||
KotlinBundle.message("navigation.title.overriding.property", propertyOrParameter.name),
|
KotlinBundle.message("navigation.title.overriding.property", propertyOrParameter.name),
|
||||||
KotlinBundle.message("navigation.findUsages.title.overriding.property", propertyOrParameter.name), renderer)
|
KotlinBundle.message("navigation.findUsages.title.overriding.property", propertyOrParameter.name), renderer
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import org.jetbrains.kotlin.renderer.RenderingFormat
|
|||||||
import java.awt.event.MouseEvent
|
import java.awt.event.MouseEvent
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
object SuperDeclarationMarkerTooltip: Function<PsiElement, String> {
|
object SuperDeclarationMarkerTooltip : Function<PsiElement, String> {
|
||||||
override fun `fun`(element: PsiElement): String? {
|
override fun `fun`(element: PsiElement): String? {
|
||||||
val ktDeclaration = element.getParentOfType<KtDeclaration>(false) ?: return null
|
val ktDeclaration = element.getParentOfType<KtDeclaration>(false) ?: return null
|
||||||
val (elementDescriptor, overriddenDescriptors) = resolveDeclarationWithParents(ktDeclaration!!)
|
val (elementDescriptor, overriddenDescriptors) = resolveDeclarationWithParents(ktDeclaration!!)
|
||||||
@@ -83,16 +83,19 @@ class SuperDeclarationMarkerNavigationHandler : GutterIconNavigationHandler<PsiE
|
|||||||
}
|
}
|
||||||
|
|
||||||
val elementName = elementDescriptor!!.name
|
val elementName = elementDescriptor!!.name
|
||||||
return NavigationPopupDescriptor(superDeclarations,
|
return NavigationPopupDescriptor(
|
||||||
|
superDeclarations,
|
||||||
KotlinBundle.message("navigation.title.super.declaration", elementName),
|
KotlinBundle.message("navigation.title.super.declaration", elementName),
|
||||||
KotlinBundle.message("navigation.findUsages.title.super.declaration", elementName),
|
KotlinBundle.message("navigation.findUsages.title.super.declaration", elementName),
|
||||||
KtFunctionPsiElementCellRenderer())
|
KtFunctionPsiElementCellRenderer()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class ResolveWithParentsResult(
|
data class ResolveWithParentsResult(
|
||||||
val descriptor: CallableMemberDescriptor?,
|
val descriptor: CallableMemberDescriptor?,
|
||||||
val overriddenDescriptors: Collection<CallableMemberDescriptor>)
|
val overriddenDescriptors: Collection<CallableMemberDescriptor>
|
||||||
|
)
|
||||||
|
|
||||||
fun resolveDeclarationWithParents(element: KtDeclaration): ResolveWithParentsResult {
|
fun resolveDeclarationWithParents(element: KtDeclaration): ResolveWithParentsResult {
|
||||||
val descriptor = if (element is KtParameter)
|
val descriptor = if (element is KtParameter)
|
||||||
|
|||||||
Reference in New Issue
Block a user