mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
AMPER-4848 Suggest installing the Amper plugin in Amper-like projects
GitOrigin-RevId: 3481e14ea59fc316f9c0c11e9f03b57636dfd7a2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
acbbd98fb3
commit
dd68560360
+45
@@ -0,0 +1,45 @@
|
||||
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.kotlin.idea.suggestions
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.PluginSuggestion
|
||||
import com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.PluginSuggestionProvider
|
||||
import com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.buildSuggestionForFileIfNeeded
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
|
||||
private const val AMPER_PLUGIN_ID = "org.jetbrains.amper"
|
||||
private const val AMPER_PLUGIN_NAME = "Amper"
|
||||
private const val AMPER_FILE_LABEL = "Amper"
|
||||
private const val AMPER_PLUGIN_SUGGESTION_KEY = "amper.plugin.suggestion.dismissed"
|
||||
|
||||
private const val MODULE_YAML_FILE_NAME: String = "module.yaml"
|
||||
private const val MODULE_AMPER_FILE_NAME: String = "module.amper"
|
||||
private const val PROJECT_YAML_FILE_NAME: String = "project.yaml"
|
||||
private const val PROJECT_AMPER_FILE_NAME: String = "project.amper"
|
||||
private const val PLUGIN_YAML_FILE_NAME: String = "plugin.yaml"
|
||||
private const val TEMPLATE_FILE_SUFFIX = ".module-template.yaml"
|
||||
|
||||
internal class AmperPluginSuggestionProvider : PluginSuggestionProvider {
|
||||
|
||||
override fun getSuggestion(project: Project, file: VirtualFile): PluginSuggestion? {
|
||||
if (!file.isAmperFile()) return null
|
||||
|
||||
return buildSuggestionForFileIfNeeded(
|
||||
project,
|
||||
AMPER_PLUGIN_ID,
|
||||
AMPER_PLUGIN_NAME,
|
||||
AMPER_FILE_LABEL,
|
||||
AMPER_PLUGIN_SUGGESTION_KEY
|
||||
)
|
||||
}
|
||||
|
||||
private fun VirtualFile.isAmperFile(): Boolean = isAmperModuleFile() || isAmperProjectFile() || isAmperTemplateFile() || isAmperPluginFile()
|
||||
|
||||
private fun VirtualFile.isAmperModuleFile(): Boolean = name.equals(MODULE_YAML_FILE_NAME, ignoreCase = true) || name.equals(MODULE_AMPER_FILE_NAME, ignoreCase = true)
|
||||
|
||||
private fun VirtualFile.isAmperTemplateFile(): Boolean = name.endsWith(TEMPLATE_FILE_SUFFIX, ignoreCase = true)
|
||||
|
||||
private fun VirtualFile.isAmperProjectFile(): Boolean = name.equals(PROJECT_YAML_FILE_NAME, ignoreCase = true) || name.equals(PROJECT_AMPER_FILE_NAME, ignoreCase = true)
|
||||
|
||||
private fun VirtualFile.isAmperPluginFile(): Boolean = name.equals(PLUGIN_YAML_FILE_NAME, ignoreCase = true)
|
||||
}
|
||||
@@ -277,6 +277,7 @@
|
||||
order="after propertyKeys"/>
|
||||
|
||||
<pluginSuggestionProvider order="first" implementation="org.jetbrains.kotlin.idea.suggestions.JupyterNotebookSuggestionProvider"/>
|
||||
<pluginSuggestionProvider implementation="org.jetbrains.kotlin.idea.suggestions.AmperPluginSuggestionProvider"/>
|
||||
</extensions>
|
||||
|
||||
<!-- Templates -->
|
||||
|
||||
Reference in New Issue
Block a user