mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-14 18:05:27 +07:00
[spellchecker] IJPL-969 Project-level dictionary file is named after a current user: issues sharing it
GitOrigin-RevId: 669815ed85c2c8d9310801c7f2305367b3496bb1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d9301b23f9
commit
7dace1831d
@@ -36,6 +36,8 @@
|
||||
|
||||
<registryKey key="spellchecker.corrections.limit" defaultValue="3" description="Spellchecker corrections limit" restartRequired="false"/>
|
||||
<registryKey key="spellchecker.inspection.enabled" defaultValue="true" description="Enable spellchecking inspection" restartRequired="false"/>
|
||||
<registryKey key="spellchecker.use.standard.project.dictionary.name" defaultValue="true" description="Enables single project dictionary file"
|
||||
restartRequired="false"/>
|
||||
|
||||
<statistics.projectUsagesCollector implementation="com.intellij.spellchecker.statistics.SpellcheckerConfigCollector"/>
|
||||
<lookup.usageDetails implementation="com.intellij.spellchecker.statistics.SpellcheckerLookupUsageDescriptor"/>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
change.to.title=Fix typo
|
||||
change.to.tooltip=Replace with ''{0}''
|
||||
rename.to=Typo: Rename to...
|
||||
rename.to=Typo: Rename to\u2026
|
||||
proofread=Proofreading
|
||||
spelling=Spelling
|
||||
spellchecking.inspection.name=Typo
|
||||
@@ -17,15 +17,15 @@ entered.word.0.is.correct.you.no.need.to.add.this.in.list=The word ''{0}'' is al
|
||||
process.code=Process code
|
||||
process.literals=Process literals
|
||||
process.comments=Process comments
|
||||
link.to.inspection.settings=Configure 'Spelling' inspection...
|
||||
link.to.inspection.settings=Configure 'Spelling' inspection\u2026
|
||||
add.dictionary.description=Custom dictionaries (plain text word lists{0}):
|
||||
custom.dictionary.title=Custom Dictionary
|
||||
add.custom.dictionaries=Add custom dictionaries
|
||||
edit.custom.dictionary=Edit custom dictionary
|
||||
add.custom.dictionaries=Add Custom Dictionaries
|
||||
edit.custom.dictionary=Edit Custom Dictionary
|
||||
dictionary.not.found.title=Dictionary Is Not Found
|
||||
dictionary.not.found=Dictionary is not found at path {0}
|
||||
dictionary.unsupported.format.title=Unsupported Format
|
||||
dictionary.unsupported.format=Dictionary file {0} has unsupported format
|
||||
dictionary.unsupported.format=Dictionary file {0} has an unsupported format
|
||||
dictionary.unsupported.language.title=Unsupported Language
|
||||
dictionary.unsupported.language=Dictionary file {0} language is not currently supported, use the Hunspell plugin instead
|
||||
remove.custom.dictionaries=Remove custom dictionaries
|
||||
|
||||
@@ -55,11 +55,14 @@ class SpellCheckerManager @Internal constructor(@Internal val project: Project,
|
||||
private var projectDictionary: ProjectDictionary? = null
|
||||
private var appDictionary: EditableDictionary? = null
|
||||
|
||||
internal val projectDictionaryPath: String by lazy {
|
||||
@get:Internal
|
||||
val projectDictionaryPath: String by lazy {
|
||||
val projectStoreDir = project.takeIf { !it.isDefault }?.stateStore?.directoryStorePath
|
||||
projectStoreDir?.toAbsolutePath()?.resolve(PROJECT_DICTIONARY_PATH)?.toString() ?: ""
|
||||
projectStoreDir?.toAbsolutePath()?.resolve(getProjectDictionaryPath())?.toString() ?: ""
|
||||
}
|
||||
internal val appDictionaryPath: String by lazy {
|
||||
|
||||
@get:Internal
|
||||
val appDictionaryPath: String by lazy {
|
||||
PathManager.getOptionsPath() + File.separator + CACHED_DICTIONARY_FILE
|
||||
}
|
||||
|
||||
@@ -96,7 +99,7 @@ class SpellCheckerManager @Internal constructor(@Internal val project: Project,
|
||||
|
||||
companion object {
|
||||
private const val MAX_METRICS = 1
|
||||
private val PROJECT_DICTIONARY_PATH = "dictionaries${File.separator}${System.getProperty("user.name").replace('.', '_')}.xml"
|
||||
|
||||
private const val CACHED_DICTIONARY_FILE = "spellchecker-dictionary.xml"
|
||||
|
||||
@JvmStatic
|
||||
@@ -209,7 +212,8 @@ class SpellCheckerManager @Internal constructor(@Internal val project: Project,
|
||||
val dictionaryState = project.service<ProjectDictionaryState>()
|
||||
dictionaryState.addProjectDictListener { restartInspections() }
|
||||
projectDictionary = dictionaryState.projectDictionary
|
||||
projectDictionary!!.setActiveName(System.getProperty("user.name"))
|
||||
projectDictionary!!.setActiveName(getProjectDictionaryName())
|
||||
|
||||
spellChecker.addModifiableDictionary(projectDictionary!!)
|
||||
}
|
||||
|
||||
@@ -459,4 +463,15 @@ private class StreamLoader(private val name: String, private val loaderClass: Cl
|
||||
}
|
||||
|
||||
override fun getName() = name
|
||||
}
|
||||
|
||||
private fun getProjectDictionaryPath(): String {
|
||||
return "dictionaries${File.separator}${getProjectDictionaryName().replace('.', '_')}.xml"
|
||||
}
|
||||
|
||||
internal fun getProjectDictionaryName(): String {
|
||||
return if (Registry.`is`("spellchecker.use.standard.project.dictionary.name"))
|
||||
ProjectDictionary.DEFAULT_CURRENT_DICT_NAME
|
||||
else
|
||||
System.getProperty("user.name")
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public final class ProjectDictionary implements EditableDictionary {
|
||||
private static final @NonNls String DEFAULT_CURRENT_USER_NAME = "default.user";
|
||||
public static final @NonNls String DEFAULT_CURRENT_DICT_NAME = "project";
|
||||
private static final String DEFAULT_PROJECT_DICTIONARY_NAME = "project";
|
||||
private String activeName;
|
||||
private Set<EditableDictionary> dictionaries;
|
||||
@@ -74,7 +74,7 @@ public final class ProjectDictionary implements EditableDictionary {
|
||||
|
||||
private @NotNull EditableDictionary ensureCurrentUserDictionary() {
|
||||
if (activeName == null) {
|
||||
activeName = DEFAULT_CURRENT_USER_NAME;
|
||||
activeName = DEFAULT_CURRENT_DICT_NAME;
|
||||
}
|
||||
EditableDictionary result = getDictionaryByName(activeName);
|
||||
if (result == null) {
|
||||
|
||||
@@ -86,8 +86,8 @@ public final class CustomDictionariesPanel extends JPanel {
|
||||
}
|
||||
if (defaultDictionaries.contains(selectedDictionary)) {
|
||||
selectedDictionary = selectedDictionary.equals(SpellCheckerBundle.message("app.dictionary"))
|
||||
? myManager.getAppDictionaryPath$intellij_spellchecker()
|
||||
: myManager.getProjectDictionaryPath$intellij_spellchecker();
|
||||
? myManager.getAppDictionaryPath()
|
||||
: myManager.getProjectDictionaryPath();
|
||||
}
|
||||
manager.openDictionaryInEditor(selectedDictionary);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user