Skip to content

Commit

Permalink
#138 Switch to modern Rider plugin architecture (from components to s…
Browse files Browse the repository at this point in the history
…ervice) to avoid exception on plugin start-up.
  • Loading branch information
ihnat-esr committed Sep 20, 2020
1 parent afeb699 commit 18a5eb2
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 110 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changelog

## 1.4.3
- Support for 2020.x version
- Open end `until` version
## 1.4.4
- Switch to up-to-date Rider plugin architecture
- Fix bug, related to plugin start-up initialization
20 changes: 13 additions & 7 deletions Extension/Xamarin.Forms.HotReload.Extension.Rider/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@ buildscript {
}

dependencies {
classpath("com.jetbrains.rd:rd-gen:0.193.119")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.31")
classpath("com.jetbrains.rd:rd-gen:0.201.40")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72")
classpath("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.72")
}
}

plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.3.41'
id 'org.jetbrains.kotlin.jvm' version '1.3.72'
id 'org.jetbrains.intellij' version '0.4.21'
}

ext {
repoRoot = projectDir
pluginVersion = '1.4.3'
pluginVersion = '1.4.4'
// https://www.jetbrains.com/intellij-repository/snapshots - link to repo of RD snapshots
ProductVersion = "${productVersion}-SNAPSHOT"
isWindows = Os.isFamily(Os.FAMILY_WINDOWS)
Expand All @@ -31,13 +32,14 @@ ext {
}

repositories {
maven { url 'https://jetbrains.com/intellij-repository/snapshots' }
maven { url 'https://cache-redirector.jetbrains.com/intellij-repository/snapshots' }
maven { url 'https://cache-redirector.jetbrains.com/maven-central' }
flatDir { dirs rdLibDirectory.absolutePath }
}

wrapper {
gradleVersion = '4.9'
gradleVersion = '5.3'
distributionType = Wrapper.DistributionType.ALL
distributionUrl = "https://cache-redirector.jetbrains.com/services.gradle.org/distributions/gradle-${gradleVersion}-all.zip"
}
Expand Down Expand Up @@ -86,7 +88,7 @@ def riderSdkPackageVersion = {

task compileDotNet {
def riderSdkVersionPropsPath = new File(dotNetDir, "SdkVersion.props")
def version = "2019.3.0-*"
def version = "2020.1.0-*"

// ToDo: Better to use in future def version = riderSdkPackageVersion()
riderSdkVersionPropsPath.text = ''
Expand All @@ -100,7 +102,11 @@ task compileDotNet {
exec {
boolean isUnix = Os.isFamily(Os.FAMILY_UNIX)
if (isUnix) {
environment "FrameworkPathOverride", "/usr/lib/mono/4.5"
if (Os.isFamily(Os.FAMILY_MAC)) {
environment "FrameworkPathOverride", "/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5"
} else {
environment "FrameworkPathOverride", "/usr/lib/mono/4.5"
}
}

executable "dotnet"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Properties for the build. Override on the command line with -Pprop=value
# E.g. -PBuildConfiguration=Release
# Note that these values are strings!
productVersion=2020.1
productVersion=2020.2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Wed Jun 12 19:43:55 MSK 2019
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<SdkVersion>2019.3.0-*</SdkVersion>
<SdkVersion>2020.1.0-*</SdkVersion>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import com.jetbrains.rider.projectView.solution
import hotreload.extension.rider.icons.HotReloadIcons
import javax.swing.Icon

class RunPluginAction(icon: Icon) : AnAction("Enable HotReload", "", icon) {
class RunPluginAction(icon: Icon) : AnAction("Enable HotReload", null, icon) {

constructor(): this(HotReloadIcons.IconOff)

override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ShowNotificationComponent(project: Project) : LifetimedProjectComponent(pr
}
}

private fun showNotification(messageInfo: MessageInfo){
private fun showNotification(messageInfo: MessageInfo) {
val yamlNotification = Notification(notificationGroupId.displayId, messageInfo.title, messageInfo.message, NotificationType.INFORMATION)
Notifications.Bus.notify(yamlNotification, project)
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package hotreload.extension.rider.services

import com.intellij.ide.actions.SaveAllAction
import com.intellij.ide.actions.SaveDocumentAction
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.actionSystem.ex.AnActionListener
import com.intellij.openapi.project.Project
import com.jetbrains.rd.util.reactive.hasTrueValue
import com.jetbrains.rider.model.SavedDocument
import com.jetbrains.rider.model.hotReloadPluginModel
import com.jetbrains.rider.projectView.solution
import com.jetbrains.rider.util.idea.PsiFile

class SaveDocumentListener(val project: Project) : AnActionListener {

override fun afterActionPerformed(action: AnAction, dataContext: DataContext, event: AnActionEvent) {
super.afterActionPerformed(action, dataContext, event)

if (action is SaveDocumentAction || action is SaveAllAction) {
val psiFile = event.dataContext.PsiFile ?: return
val filePath = psiFile.containingFile.viewProvider.virtualFile.canonicalPath
val content = psiFile.containingFile.textToCharArray()

val document = SavedDocument(filePath.toString(), content)
val model = project.solution.hotReloadPluginModel
if (model.isEnabled.hasTrueValue) {
model.reload.fire(document)
}
}
}
}

Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
<idea-plugin>
<id>hotreloadplugin-rider</id>
<name>Hot Reload</name>
<version>_PLACEHOLDER_</version>
<vendor url="https://github.com/AndreiMisiukevich/HotReload">Ignat Bavtovich</vendor>
<depends>com.intellij.modules.rider</depends>
<id>hotreloadplugin-rider</id>
<name>Hot Reload</name>
<version>_PLACEHOLDER_</version>
<vendor url="https://github.com/AndreiMisiukevich/HotReload">Ignat Bavtovich</vendor>
<depends>com.intellij.modules.rider</depends>

<description>
Plugin helps to integrate Xamarin HotReload project with Rider and easily apply new changes in your code without
any configuration
</description>
<description>
Plugin helps to integrate Xamarin HotReload project with Rider and easily apply new changes in your code without
any configuration
</description>

<application-components>
<component>
<implementation-class>hotreload.extension.rider.component.StartUpProjectComponent</implementation-class>
</component>
</application-components>
<project-components>
<component>
<implementation-class>hotreload.extension.rider.component.SaveDocumentListener</implementation-class>
</component>
<component>
<implementation-class>hotreload.extension.rider.component.ShowNotificationComponent</implementation-class>
</component>
</project-components>
<actions>
<action class="hotreload.extension.rider.action.RunPluginAction" icon="/logo/hotReloadOff.png">
<add-to-group group-id="NavBarToolBar" anchor="last"/>
</action>
</actions>
<projectListeners>
<listener class="hotreload.extension.rider.services.SaveDocumentListener"
topic="com.intellij.openapi.actionSystem.ex.AnActionListener" />
</projectListeners>
</idea-plugin>

0 comments on commit 18a5eb2

Please sign in to comment.