-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1443 from JetBrains/refactor/css-optional
Make CSS an optional dependency
- Loading branch information
Showing
10 changed files
with
136 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
rider/src/main/kotlin/com/jetbrains/rider/plugins/unity/ui/UssDisabledEditorNotification.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.jetbrains.rider.plugins.unity.ui | ||
|
||
import com.intellij.ide.plugins.PluginManager | ||
import com.intellij.ide.plugins.PluginManagerMain | ||
import com.intellij.ide.util.PropertiesComponent | ||
import com.intellij.openapi.fileEditor.FileEditor | ||
import com.intellij.openapi.fileTypes.FileTypeRegistry | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.util.Key | ||
import com.intellij.openapi.vfs.VirtualFile | ||
import com.intellij.ui.EditorNotificationPanel | ||
import com.intellij.ui.EditorNotifications | ||
import com.jetbrains.rider.isUnityProject | ||
import com.jetbrains.rider.plugins.unity.ideaInterop.fileTypes.uss.UssFileType | ||
import com.jetbrains.rider.plugins.unity.util.isUssFile | ||
|
||
class UssDisabledEditorNotification: EditorNotifications.Provider<EditorNotificationPanel>() { | ||
|
||
companion object { | ||
private val KEY = Key.create<EditorNotificationPanel>("unity.uss.css.plugin.disabled.notification.panel") | ||
private const val DO_NOT_SHOW_AGAIN_KEY = "unity.uss.css.plugin.disabled.do.not.show" | ||
private const val CSS_PLUGIN_ID = "com.intellij.css" | ||
} | ||
|
||
override fun getKey(): Key<EditorNotificationPanel> = KEY | ||
|
||
override fun createNotificationPanel(file: VirtualFile, fileEditor: FileEditor, project: Project): EditorNotificationPanel? { | ||
if (project.isUnityProject() && isUssFile(file) && PluginManager.isDisabled(CSS_PLUGIN_ID)) { | ||
if (PropertiesComponent.getInstance(project).getBoolean(DO_NOT_SHOW_AGAIN_KEY, false)) { | ||
return null | ||
} | ||
|
||
val panel = EditorNotificationPanel() | ||
panel.text("USS support requires the CSS plugin to be enabled") | ||
panel.createActionLabel("Enable CSS plugin") { | ||
// TODO: Maybe in 2020.1 we can do this dynamically without restart? | ||
// That would require enabling the CSS plugin dynamically, and then enabling our PluginCssPart.xml part | ||
// dynamically, too | ||
PluginManager.enablePlugin(CSS_PLUGIN_ID) | ||
PluginManagerMain.notifyPluginsUpdated(project) | ||
EditorNotifications.getInstance(project).updateAllNotifications() | ||
} | ||
panel.createActionLabel("Don't show again") { | ||
// Project level - do not show again for this project | ||
PropertiesComponent.getInstance(project).setValue(DO_NOT_SHOW_AGAIN_KEY, true) | ||
EditorNotifications.getInstance(project).updateAllNotifications() | ||
} | ||
return panel | ||
} | ||
|
||
return null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<idea-plugin> | ||
<!-- USS depends on CSS, but make it an optional dependency, so we don't disable all of Unity support if someone | ||
decides to disable CSS. We'll prompt to enable CSS if they open a *.uss file --> | ||
<extensions defaultExtensionNs="com.intellij"> | ||
<!-- USS support --> | ||
<lang.parserDefinition language="USS" implementationClass="com.jetbrains.rider.plugins.unity.ideaInterop.fileTypes.uss.UssFileParserDefinition"/> | ||
<lang.syntaxHighlighter language="USS" implementationClass="com.jetbrains.rider.plugins.unity.ideaInterop.fileTypes.uss.UssSyntaxHighlighter" /> | ||
<breadcrumbsInfoProvider implementation="com.jetbrains.rider.plugins.unity.ideaInterop.fileTypes.uss.UssFileBreadcrumbsProvider" /> | ||
<css.elementDescriptorProvider implementation="com.jetbrains.rider.plugins.unity.ideaInterop.fileTypes.uss.codeInsight.css.UssCssElementDescriptorProvider" order="first" /> | ||
<css.cssInspectionFilter language="USS" implementationClass="com.jetbrains.rider.plugins.unity.ideaInterop.fileTypes.uss.codeInsight.css.inspections.UssCssInspectionFilter"/> | ||
<css.cssIntentionFilter language="USS" implementationClass="com.jetbrains.rider.plugins.unity.ideaInterop.fileTypes.uss.codeInsight.css.inspections.UssCssIntentionFilter"/> | ||
<!-- Override the CSS documentation for USS files --> | ||
<lang.documentationProvider language="CSS" implementationClass="com.jetbrains.rider.plugins.unity.ideaInterop.fileTypes.uss.UssDocumentationProvider" order="first"/> | ||
|
||
<applicationService serviceImplementation="com.jetbrains.rider.plugins.unity.ideaInterop.fileTypes.uss.codeInsight.css.UssCssElementDescriptorFactory" /> | ||
</extensions> | ||
</idea-plugin> |
Oops, something went wrong.