[ui] adds "show diff" action for mismatched sources (IDEA-151265)

This commit is contained in:
Roman Shevchenko
2016-02-24 11:45:11 +01:00
parent 6cd47a13a2
commit 09948a625f
2 changed files with 17 additions and 6 deletions
@@ -16,6 +16,9 @@
package com.intellij.codeInsight.daemon.impl
import com.intellij.ProjectTopics
import com.intellij.diff.DiffContentFactory
import com.intellij.diff.DiffManager
import com.intellij.diff.requests.SimpleDiffRequest
import com.intellij.openapi.fileEditor.FileEditor
import com.intellij.openapi.fileEditor.OpenFileDescriptor
import com.intellij.openapi.fileTypes.LanguageFileType
@@ -56,12 +59,19 @@ class LibrarySourceNotificationProvider(private val project: Project, notificati
if (offender != null) {
val panel = ColoredNotificationPanel(LightColors.RED)
panel.setText(ProjectBundle.message("library.source.mismatch", offender.name))
panel.createActionLabel(ProjectBundle.message("library.source.open.class"), {
val classFile = offender.originalElement.containingFile?.virtualFile
if (classFile != null) {
OpenFileDescriptor(project, classFile, -1).navigate(true)
}
})
val clsFile = offender.originalElement.containingFile?.virtualFile
if (clsFile != null) {
panel.createActionLabel(ProjectBundle.message("library.source.open.class"), {
OpenFileDescriptor(project, clsFile, -1).navigate(true)
})
panel.createActionLabel(ProjectBundle.message("library.source.show.diff"), {
val cf = DiffContentFactory.getInstance()
val request = SimpleDiffRequest(null, cf.create(project, clsFile), cf.create(project, file), clsFile.path, file.path)
DiffManager.getInstance().showDiff(project, request)
})
}
return panel
}
}
@@ -141,6 +141,7 @@ project.sdk.setup=Setup SDK
library.source.mismatch=Library source does not match the bytecode for class {0}
library.source.open.class=Open .class file
library.source.show.diff=Show diff
module.module.language.level=&Language level:
module.circular.dependency.warning.short=There is circular dependency between {0}