[java] library source compatibility check restricted to Java; no notification for matched files

This commit is contained in:
Roman Shevchenko
2016-01-07 17:35:59 +01:00
parent 1b89ea0cf8
commit 4049b71f17
2 changed files with 7 additions and 9 deletions
@@ -51,14 +51,13 @@ class LibrarySourceNotificationProvider(private val project: Project, notificati
override fun createNotificationPanel(file: VirtualFile, fileEditor: FileEditor): EditorNotificationPanel? {
if (file.fileType is LanguageFileType && ProjectRootManager.getInstance(project).fileIndex.isInLibrarySource(file)) {
val psiFile = PsiManager.getInstance(project).findFile(file)
if (psiFile is PsiClassOwner) {
val classes = psiFile.classes
if (classes.isNotEmpty()) {
val mismatch = classes.any { differs(it) }
val panel = ColoredNotificationPanel(if (mismatch) LightColors.RED else null)
panel.setText(ProjectBundle.message(if (mismatch) "library.source.mismatch" else "library.source.file"))
if (psiFile is PsiJavaFile) {
val offender = psiFile.classes.find { differs(it) }
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 = classes[0].originalElement.containingFile?.virtualFile
val classFile = offender.originalElement.containingFile?.virtualFile
if (classFile != null) {
OpenFileDescriptor(project, classFile, -1).navigate(true)
}
@@ -138,8 +138,7 @@ library.choose.one.to.attach=<html><body>Multiple libraries contain the file.<br
project.sdk.not.defined=Project SDK is not defined
project.sdk.setup=Setup SDK
library.source.file=Library source file
library.source.mismatch=Library source does not match the bytecode
library.source.mismatch=Library source does not match the bytecode for class {0}
library.source.open.class=Open .class file
module.module.language.level=&Language level: