mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-186546 Copyright plugin can't read copyright profile created in IDEA 2017.3
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o.
|
||||
// Use of this source code is governed by the Apache 2.0 license that can be
|
||||
// found in the LICENSE file.
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.copyright
|
||||
|
||||
import com.intellij.configurationStore.*
|
||||
@@ -83,6 +81,10 @@ class CopyrightManager @JvmOverloads constructor(private val project: Project, s
|
||||
}
|
||||
|
||||
override fun isSchemeFile(name: CharSequence) = !StringUtil.equals(name, "profiles_settings.xml")
|
||||
|
||||
override fun getSchemeKey(attributeProvider: Function<String, String?>, fileNameWithoutExtension: String): String? {
|
||||
return super.getSchemeKey(attributeProvider, fileNameWithoutExtension) ?: fileNameWithoutExtension
|
||||
}
|
||||
}, schemeNameToFileName = OLD_NAME_CONVERTER, streamProvider = schemeManagerIprProvider)
|
||||
|
||||
init {
|
||||
@@ -258,6 +260,9 @@ private class CopyrightLazySchemeWrapper(name: String,
|
||||
}
|
||||
|
||||
element.deserializeInto(scheme)
|
||||
// use effective name instead of probably missed from the serialized
|
||||
// https://youtrack.jetbrains.com/v2/issue/IDEA-186546
|
||||
scheme.profileName = name
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
val allowReplaceKeyword = scheme.allowReplaceKeyword
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.maddyhome.idea.copyright
|
||||
|
||||
import com.intellij.configurationStore.SerializableScheme
|
||||
@@ -22,6 +20,7 @@ val DEFAULT_COPYRIGHT_NOTICE: String = EntityUtil.encode(
|
||||
class CopyrightProfile @JvmOverloads constructor(profileName: String? = null) : ExternalizableScheme, BaseState(), SerializableScheme {
|
||||
// ugly name to preserve compatibility
|
||||
// must be not private because otherwise binding is not created for private accessor
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
@get:OptionTag("myName")
|
||||
var profileName by string()
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.copyright
|
||||
|
||||
import com.intellij.configurationStore.SchemeManagerFactoryBase
|
||||
import com.intellij.testFramework.ProjectRule
|
||||
import com.intellij.testFramework.assertions.Assertions.assertThat
|
||||
import com.intellij.testFramework.assertions.Assertions.catchThrowable
|
||||
import com.intellij.testFramework.rules.InMemoryFsRule
|
||||
import com.intellij.util.io.write
|
||||
import com.maddyhome.idea.copyright.CopyrightProfile
|
||||
@@ -34,7 +33,7 @@ internal class CopyrightManagerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun serializeEmpy() {
|
||||
fun serializeEmpty() {
|
||||
val scheme = CopyrightProfile()
|
||||
assertThat(scheme.writeScheme()).isEqualTo("""<copyright />""")
|
||||
}
|
||||
@@ -66,20 +65,21 @@ internal class CopyrightManagerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun empty() {
|
||||
val schemeFile = fsRule.fs.getPath("copyright/openapi.xml")
|
||||
fun `use file name if scheme name missed`() {
|
||||
val schemeFile = fsRule.fs.getPath("copyright/FooBar.xml")
|
||||
val schemeData = """
|
||||
<component name="CopyrightManager">
|
||||
<copyright />
|
||||
<copyright>
|
||||
<option name="notice" value="Copyright (C) &#36;{today.year} - present by FooBar Inc. and the FooBar group of companies Please see distribution for license." />
|
||||
</copyright>
|
||||
</component>""".trimIndent()
|
||||
schemeFile.write(schemeData)
|
||||
val schemeManagerFactory = SchemeManagerFactoryBase.TestSchemeManagerFactory(fsRule.fs.getPath(""))
|
||||
val profileManager = CopyrightManager(projectRule.project, schemeManagerFactory,
|
||||
isSupportIprProjects = false /* otherwise scheme will be not loaded from our memory fs */)
|
||||
val catchThrowable = catchThrowable { profileManager.loadSchemes() }
|
||||
assertThat(catchThrowable)
|
||||
.isInstanceOf(AssertionError::class.java)
|
||||
.hasMessageStartingWith("Cannot read scheme openapi.xml")
|
||||
.hasCauseExactlyInstanceOf(RuntimeException::class.java)
|
||||
profileManager.loadSchemes()
|
||||
val copyrights = profileManager.getCopyrights()
|
||||
assertThat(copyrights).hasSize(1)
|
||||
assertThat(copyrights.first().name).isEqualTo("FooBar")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user