Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: Build & Release Rider Plugin

on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: write

jobs:
build:
runs-on: ubuntu-latest
name: Build Plugin (PR / Main)

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Cache Gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Build plugin
run: ./gradlew buildPlugin

- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: plugin-build
path: build/distributions/*.zip

release:
needs: build
runs-on: ubuntu-latest
name: Release on Main
if: github.event_name == 'push' && github.ref == 'refs/heads/main'

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Determine new version and changelog
id: changelog
uses: release-please/action@v4
with:
release-type: simple
package-name: rider-plugin
changelog-types: |
[
{"type":"feat","section":"✨ Features","hidden":false},
{"type":"fix","section":"🐛 Fixes","hidden":false},
{"type":"chore","section":"🧹 Chores","hidden":false},
{"type":"docs","section":"📚 Docs","hidden":false}
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Stop if no new release
if: ${{ steps.changelog.outputs.release_created != 'true' }}
run: echo "No new version to release."

- name: Update gradle.properties version
if: ${{ steps.changelog.outputs.release_created == 'true' }}
run: |
TAG_NAME="${{ steps.changelog.outputs.tag_name }}"
VERSION="${TAG_NAME#v}"
sed -i.bak "s/^version=.*/version=${VERSION}/" gradle.properties
echo "✅ Updated gradle.properties to version ${VERSION}"

- name: Update plugin.xml version
if: ${{ steps.changelog.outputs.release_created == 'true' }}
run: |
TAG_NAME="${{ steps.changelog.outputs.tag_name }}"
VERSION="${TAG_NAME#v}"
XML_FILE="src/rider/main/resources/META-INF/plugin.xml"
echo "🧩 Updating ${XML_FILE} to version ${VERSION}"

awk -v ver="$VERSION" '
/<!--/ { in_comment=1 }
/-->/ { in_comment=0 }
!in_comment {
gsub(/<version>[^<]+<\/version>/, "<version>" ver "</version>")
}
{ print }
' "$XML_FILE" > "$XML_FILE.tmp" && mv "$XML_FILE.tmp" "$XML_FILE"

grep "<version>" "$XML_FILE" || echo "(none found)"

- name: Build plugin
if: ${{ steps.changelog.outputs.release_created == 'true' }}
run: ./gradlew buildPlugin

- name: Commit updated version and changelog
if: ${{ steps.changelog.outputs.release_created == 'true' }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add gradle.properties CHANGELOG.md src/rider/main/resources/META-INF/plugin.xml
git commit -m "chore(release): update version to ${{ steps.changelog.outputs.tag_name }}"
git push

- name: Create GitHub Release
if: ${{ steps.changelog.outputs.release_created == 'true' }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.changelog.outputs.tag_name }}
name: Release ${{ steps.changelog.outputs.tag_name }}
body: ${{ steps.changelog.outputs.release_notes }}
files: build/distributions/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
DotnetPluginId=ReSharperPlugin.SerializeReferenceDropdownIntegration
DotnetSolution=ReSharperPlugin.SerializeReferenceDropdownIntegration.sln
RiderPluginId=com.jetbrains.rider.plugins.serializereferencedropdownintegration
PluginVersion=1.1.1
PluginVersion=1.1.2

BuildConfiguration=Debug

Expand Down
5 changes: 5 additions & 0 deletions src/dotnet/Plugin.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@
<!-- TODO - icon, url something else....-->
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JetBrains.ReSharper.SDK" Version="$(SdkVersion)" />
<PackageReference Include="JetBrains.Rider.SDK" Version="$(SdkVersion)" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.Linq;
using JetBrains.ReSharper.Daemon.CodeInsights;
using JetBrains.ReSharper.Feature.Services.Daemon;
using JetBrains.ReSharper.Psi.CSharp.Tree;
using JetBrains.ReSharper.Psi.Tree;
using JetBrains.ReSharper.Psi.Util;
using ReSharperPlugin.SerializeReferenceDropdownIntegration.Unity.SRD;

namespace ReSharperPlugin.SerializeReferenceDropdownIntegration.ClassUsage;

//TODO Move from problemAnalyzer to something else where usages works normally
[ElementProblemAnalyzer(typeof(IClassDeclaration))]
public class ClassUsageAnalyzer : ElementProblemAnalyzer<IClassDeclaration>
{
private readonly ClassUsageInsightsProvider codeInsightsProvider;
private readonly UnitySrdDatabaseLoader unitySrdDatabaseLoader;
private readonly UnityProjectDetector unityProjectDetector;

public static readonly Dictionary<string, string> shortTypeToFullType = new();

public ClassUsageAnalyzer(ClassUsageInsightsProvider codeInsightsProvider,
UnitySrdDatabaseLoader unitySrdDatabaseLoader, UnityProjectDetector unityProjectDetector)
{
this.codeInsightsProvider = codeInsightsProvider;
this.unitySrdDatabaseLoader = unitySrdDatabaseLoader;
this.unityProjectDetector = unityProjectDetector;
}

protected override void Run(IClassDeclaration element, ElementProblemAnalyzerData data,
IHighlightingConsumer consumer)
{
try
{
if (unityProjectDetector.IsUnityProject() == false)
{
return;
}

unitySrdDatabaseLoader.RefreshDatabase();
if (unitySrdDatabaseLoader.IsAvailableDatabase == false)
{
return;
}

var nonReferenceType = element.IsStatic || element.IsAbstract;
if (nonReferenceType)
{
return;
}

var superClassNames = element.DeclaredElement.GetAllSuperClasses().Select(t => t.GetClrName());
var inheritedFromUnityObject = superClassNames.Any(t => t.FullName == "UnityEngine.Object");
if (inheritedFromUnityObject)
{
return;
}

var clrName = element.DeclaredElement.GetClrName();
var name = clrName.FullName;
var asmName = element.GetPsiModule().ContainingProjectModule.Name;
var type = TypeExtensions.MakeType(name, asmName);
unitySrdDatabaseLoader.TypesCount.TryGetValue(type, out var usageCount);
shortTypeToFullType[clrName.ShortName] = type;

//TODO Need check usages with MovedFrom attribute
var tooltip = $"SerializeReferenceDropdown: '{clrName.ShortName}' {usageCount} - usages in project";
consumer.AddHighlighting(
new CodeInsightsHighlighting(
element.GetNameDocumentRange(),
displayText: $"SRD: {usageCount} usages",
tooltipText: tooltip,
moreText: String.Empty,
codeInsightsProvider,
element.DeclaredElement, null));
}
catch (Exception e)
{
Log.DevError(e.ToString());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,33 @@
using JetBrains.ProjectModel;
using JetBrains.ReSharper.Daemon.CodeInsights;
using JetBrains.Rider.Model;
using ReSharperPlugin.SerializeReferenceDropdownIntegration.ToUnity;

namespace ReSharperPlugin.SerializeReferenceDropdownIntegration;
namespace ReSharperPlugin.SerializeReferenceDropdownIntegration.ClassUsage;

[SolutionComponent(Instantiation.ContainerAsyncPrimaryThread)]
[SolutionComponent(Instantiation.DemandAnyThreadSafe)]
public class ClassUsageInsightsProvider : ICodeInsightsProvider
{
private readonly ToUnitySrdPipe toUnitySrdPipe;
private readonly ToUnityWindowFocusSwitch toUnityWindowFocusSwitch;

public ClassUsageInsightsProvider(ToUnitySrdPipe toUnitySrdPipe,
ToUnityWindowFocusSwitch toUnityWindowFocusSwitch)
{
this.toUnitySrdPipe = toUnitySrdPipe;
this.toUnityWindowFocusSwitch = toUnityWindowFocusSwitch;
}

public bool IsAvailableIn(ISolution solution)
{
return true;
}

public void OnClick(CodeInsightHighlightInfo highlightInfo, ISolution solution,CodeInsightsClickInfo clickInfo)
public void OnClick(CodeInsightHighlightInfo highlightInfo, ISolution solution, CodeInsightsClickInfo clickInfo)
{
var typeName = GetFullTypeName(highlightInfo);
UnityBridge.OpenUnitySearchToolWindowWithType(typeName);
WindowFocusSwitch.SwitchToUnityApplication();
toUnitySrdPipe.OpenUnitySearchToolWindowWithType(typeName);
toUnityWindowFocusSwitch.SwitchToUnityApplication();
}

private string GetFullTypeName(CodeInsightHighlightInfo highlightInfo)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using System.Diagnostics;
using JetBrains.Util;

namespace ReSharperPlugin.SerializeReferenceDropdownIntegration;

Expand All @@ -8,12 +8,12 @@ public class Log
[Conditional("DEVLOG")]
public static void DevInfo(string data)
{
MessageBox.ShowInfo(data, "SRD DEV");
Console.WriteLine($"SRD DEV: {data}");
}

[Conditional("DEVLOG")]
public static void DevError(string data)
{
MessageBox.ShowInfo(data, "SRD DEV");
Console.WriteLine($"SRD DEV ERROR: {data}");
}
}
Loading