Move: Report separate conflicts for each property accessor

#KT-13216 Fixed
This commit is contained in:
Alexey Sedunov
2016-08-19 18:16:27 +03:00
parent 9607fd0620
commit 6480118da6
11 changed files with 44 additions and 9 deletions
@@ -54,6 +54,7 @@ class KotlinElementDescriptionProvider : ElementDescriptionProvider {
is KtClass -> if (targetElement.isInterface()) "interface" else "class"
is KtObjectDeclaration -> "object"
is KtNamedFunction -> "function"
is KtPropertyAccessor -> (if (targetElement.isGetter) "getter" else "setter") + " for property "
is KtFunctionLiteral -> "lambda"
is KtPrimaryConstructor, is KtSecondaryConstructor -> "constructor"
is KtProperty -> if (targetElement.isLocal) "variable" else "property"
@@ -67,17 +68,21 @@ class KotlinElementDescriptionProvider : ElementDescriptionProvider {
else -> null
}
if (targetElement !is PsiNamedElement || targetElement.language != KotlinLanguage.INSTANCE) return null
val namedElement = if (targetElement is KtPropertyAccessor) {
targetElement.parent as? KtProperty
} else targetElement as? PsiNamedElement
if (namedElement == null || namedElement.language != KotlinLanguage.INSTANCE) return null
return when(location) {
is UsageViewTypeLocation -> elementKind()
is UsageViewShortNameLocation, is UsageViewLongNameLocation -> targetElement.name
is UsageViewShortNameLocation, is UsageViewLongNameLocation -> namedElement.name
is RefactoringDescriptionLocation -> {
val kind = elementKind() ?: return null
val descriptor = (targetElement as KtDeclaration).descriptor ?: return null
val descriptor = (namedElement as KtDeclaration).descriptor ?: return null
val renderFqName = location.includeParent() &&
targetElement !is KtTypeParameter &&
targetElement !is KtParameter &&
targetElement !is KtConstructor<*>
namedElement !is KtTypeParameter &&
namedElement !is KtParameter &&
namedElement !is KtConstructor<*>
val desc = when (descriptor) {
is FunctionDescriptor -> {
val baseText = REFACTORING_RENDERER.render(descriptor)
@@ -91,7 +96,7 @@ class KotlinElementDescriptionProvider : ElementDescriptionProvider {
}
is HighlightUsagesDescriptionLocation -> {
val kind = elementKind() ?: return null
val descriptor = (targetElement as KtDeclaration).descriptor ?: return null
val descriptor = (namedElement as KtDeclaration).descriptor ?: return null
"$kind ${descriptor.name.asString()}"
}
else -> null
@@ -126,7 +126,7 @@ fun VirtualFile.toPsiDirectory(project: Project): PsiDirectory? = PsiManager.get
fun PsiElement.getUsageContext(): PsiElement {
return when (this) {
is KtElement -> PsiTreeUtil.getParentOfType(this, KtNamedDeclaration::class.java, KtFile::class.java)!!
is KtElement -> PsiTreeUtil.getParentOfType(this, KtPropertyAccessor::class.java, KtNamedDeclaration::class.java, KtFile::class.java)!!
else -> ConflictsUtil.getContainer(this)
}
}