diff --git a/src/XamlStyler.Extension.Rider/build.gradle.kts b/src/XamlStyler.Extension.Rider/build.gradle.kts index b2ded52e..913e7655 100644 --- a/src/XamlStyler.Extension.Rider/build.gradle.kts +++ b/src/XamlStyler.Extension.Rider/build.gradle.kts @@ -25,7 +25,9 @@ repositories { dependencies { intellijPlatform { - rider(libs.versions.rider, false) + rider(libs.versions.rider.get()) { + useInstaller = false + } jetbrainsRuntime() } } @@ -61,7 +63,7 @@ sourceSets { tasks { wrapper { - gradleVersion = "8.10" + gradleVersion = "9.4.1" distributionType = Wrapper.DistributionType.ALL distributionUrl = "https://cache-redirector.jetbrains.com/services.gradle.org/distributions/gradle-${gradleVersion}-all.zip" @@ -82,7 +84,8 @@ tasks { outputs.upToDateWhen { false } doLast { copy { - from("${buildDir}/distributions/${rootProject.name}-${version}.zip") + val buildDirPath = layout.buildDirectory.get().asFile + from("${buildDirPath}/distributions/${rootProject.name}-${version}.zip") into("${rootDir}/output") } @@ -92,10 +95,13 @@ tasks { it.groupValues[1].replace(Regex("(?s)- "), "\u2022 ").replace(Regex("`"), "").replace(Regex(","), "%2C") }.take(1).joinToString("") - exec { - executable("dotnet") - args("msbuild","/t:Pack","${DotnetSolution}","/p:Configuration=${BuildConfiguration}","/p:PackageOutputPath=${rootDir}/output","/p:PackageReleaseNotes=${changeNotes}","/p:PackageVersion=${version}") - } + providers.exec { + commandLine("dotnet", "msbuild", "/t:Pack", DotnetSolution, + "/p:Configuration=${BuildConfiguration}", + "/p:PackageOutputPath=${rootDir}/output", + "/p:PackageReleaseNotes=${changeNotes}", + "/p:PackageVersion=${version}") + }.result.get() } } diff --git a/src/XamlStyler.Extension.Rider/dotnet/Plugin.props b/src/XamlStyler.Extension.Rider/dotnet/Plugin.props index e4def17f..a3efb932 100644 --- a/src/XamlStyler.Extension.Rider/dotnet/Plugin.props +++ b/src/XamlStyler.Extension.Rider/dotnet/Plugin.props @@ -2,7 +2,7 @@ - 2025.1.0 + 2026.1.0.1 XAML Styler XAML Styler is an extension that formats XAML source code based on a set of styling rules. This tool can help you/your team maintain a better XAML coding style as well as a much better XAML readability. diff --git a/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/Options/StringListViewModel.cs b/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/Options/StringListViewModel.cs index 6140bc8e..34fe805d 100644 --- a/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/Options/StringListViewModel.cs +++ b/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/Options/StringListViewModel.cs @@ -1,6 +1,5 @@ using System; using System.Linq; -using JetBrains.Annotations; using JetBrains.DataFlow; using JetBrains.Lifetimes; using JetBrains.Threading; @@ -12,11 +11,9 @@ public class StringListViewModel { private readonly GroupingEvent myEntryChanged; private readonly Lifetime myLifetime; - [NotNull] private readonly Property mySource; + private readonly Property mySource; - public StringListViewModel( - [NotNull] Lifetime lifetime, - [NotNull] Property source) + public StringListViewModel(Lifetime lifetime, Property source) { myLifetime = lifetime; mySource = source; @@ -61,15 +58,12 @@ private void OnEntryChanged() mySource.Value = string.Join("\n", entries); } - + public class StringListEntry { public readonly IProperty Value; - public StringListEntry( - [NotNull] Lifetime lifetime, - [NotNull] ISimpleSignal entryChanged, - string value) + public StringListEntry(Lifetime lifetime, ISimpleSignal entryChanged, string value) { Value = new Property("StringListEntry.Value", value); Value.Change.Advise_NoAcknowledgement(lifetime, entryChanged.Fire); diff --git a/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/Options/XamlStylerOptionsPage.cs b/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/Options/XamlStylerOptionsPage.cs index 6c194ccb..18ec4213 100644 --- a/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/Options/XamlStylerOptionsPage.cs +++ b/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/Options/XamlStylerOptionsPage.cs @@ -34,8 +34,8 @@ public XamlStylerOptionsPage( Lifetime lifetime, OptionsPageContext optionsPageContext, OptionsSettingsSmartContext optionsSettingsSmartContext, - [NotNull] IconHostBase iconHost, - [NotNull] ICommonFileDialogs commonFileDialogs) + IconHostBase iconHost, + ICommonFileDialogs commonFileDialogs) : base(lifetime, optionsPageContext, optionsSettingsSmartContext) { _iconHost = iconHost; diff --git a/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/Rider/RiderXamlStylerHost.cs b/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/Rider/RiderXamlStylerHost.cs index a5027234..039ebefc 100644 --- a/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/Rider/RiderXamlStylerHost.cs +++ b/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/Rider/RiderXamlStylerHost.cs @@ -1,5 +1,4 @@ using System.Threading.Tasks; -using JetBrains.Annotations; using JetBrains.Application.Parts; using JetBrains.Application.Settings; using JetBrains.DocumentManagers; @@ -16,24 +15,16 @@ namespace Xavalon.XamlStyler.Extension.Rider.Rider [SolutionComponent(Instantiation.ContainerAsyncPrimaryThread)] public class RiderXamlStylerHost { - [NotNull] private readonly Lifetime _lifetime; - - [NotNull] private readonly SolutionModel _solutionModel; - - [NotNull] private readonly ISolution _solution; - - [NotNull] private readonly DocumentManager _documentManager; public RiderXamlStylerHost( - [NotNull] Lifetime lifetime, - [NotNull] SolutionModel solutionModel, - [NotNull] ISolution solution, - [NotNull] DocumentManager documentManager - ) + Lifetime lifetime, + SolutionModel solutionModel, + ISolution solution, + DocumentManager documentManager) { _lifetime = lifetime; _solutionModel = solutionModel; @@ -41,17 +32,16 @@ [NotNull] DocumentManager documentManager _documentManager = documentManager; var rdSolutionModel = solutionModel.TryGetCurrentSolution(); - if (rdSolutionModel != null) - { - var rdXamlStylerModel = rdSolutionModel.GetXamlStylerModel(); - rdXamlStylerModel.PerformReformat.SetAsync(PerformReformatHandler); - } + + if (rdSolutionModel == null) return; + + var rdXamlStylerModel = rdSolutionModel.GetXamlStylerModel(); + rdXamlStylerModel.PerformReformat.SetAsync(PerformReformatHandler); } private Task PerformReformatHandler( Lifetime requestLifetime, - RdXamlStylerFormattingRequest request - ) + RdXamlStylerFormattingRequest request) { return Task.Run( () => @@ -86,15 +76,11 @@ RdXamlStylerFormattingRequest request .StyleDocument(request.DocumentText) .Replace("\r\n", "\n"); - if (request.DocumentText == formattedText) - { - return new RdXamlStylerFormattingResult(true, false, ""); - } - return new RdXamlStylerFormattingResult(true, true, formattedText); + return request.DocumentText == formattedText ? new RdXamlStylerFormattingResult(true, false, "") : new RdXamlStylerFormattingResult(true, true, formattedText); }, requestLifetime ) .ToRdTask(); } } -} +} \ No newline at end of file diff --git a/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/Rider/XamlStylerModel.Generated.cs b/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/Rider/XamlStylerModel.Generated.cs index 186af8a4..4df26fcd 100644 --- a/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/Rider/XamlStylerModel.Generated.cs +++ b/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/Rider/XamlStylerModel.Generated.cs @@ -36,7 +36,7 @@ namespace JetBrains.Rider.Model /// - ///

Generated from: XamlStylerModel.kt:12

+ ///

Generated from: XamlStylerModel.kt:11

///
public class XamlStylerModel : RdExtBase { diff --git a/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/StylerOptionsFactory.cs b/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/StylerOptionsFactory.cs index 543de77c..479cd071 100644 --- a/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/StylerOptionsFactory.cs +++ b/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/StylerOptionsFactory.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using JetBrains.Annotations; using JetBrains.Application.Settings; using JetBrains.ProjectModel; using JetBrains.ReSharper.Psi; @@ -16,61 +15,75 @@ public static class StylerOptionsFactory { public static IStylerOptions FromSettings( IContextBoundSettingsStoreLive settings, - [CanBeNull] ISolution solution, - [CanBeNull] IProject project, - [CanBeNull] IPsiSourceFileWithLocation psiSourceFileWithLocation) + ISolution? solution, + IProject? project, + IPsiSourceFileWithLocation? psiSourceFileWithLocation) { return FromSettings( settings: settings, - solution: solution, - projectPath: project?.ProjectFileLocation?.FullPath, + solution: solution, + projectPath: project?.ProjectFileLocation?.FullPath, sourceFilePath: psiSourceFileWithLocation?.Location.FullPath); } - + public static IStylerOptions FromSettings( IContextBoundSettingsStoreLive settings, - [CanBeNull] ISolution solution, - [CanBeNull] string projectPath, - [CanBeNull] string sourceFilePath) + ISolution? solution, + string? projectPath, + string? sourceFilePath) { - // Normalize paths, because Rider may pass them in with differing separator chars - projectPath = NormalizePath(projectPath); - sourceFilePath = NormalizePath(sourceFilePath); + // Normalize paths, because Rider may pass them in with differing separator chars + projectPath = NormalizePath(projectPath); + sourceFilePath = NormalizePath(sourceFilePath); // 1. Load global settings IStylerOptions fallbackOptions = new StylerOptions(); IStylerOptions stylerOptions = new StylerOptions(); - + stylerOptions.IndentSize = settings.GetValue((XamlStylerSettings s) => s.IndentSize); stylerOptions.IndentWithTabs = settings.GetValue((XamlStylerSettings s) => s.IndentWithTabs); - + stylerOptions.AttributesTolerance = settings.GetValue((XamlStylerSettings s) => s.AttributesTolerance); - stylerOptions.KeepFirstAttributeOnSameLine = settings.GetValue((XamlStylerSettings s) => s.KeepFirstAttributeOnSameLine); - stylerOptions.MaxAttributeCharactersPerLine = settings.GetValue((XamlStylerSettings s) => s.MaxAttributeCharactersPerLine); + stylerOptions.KeepFirstAttributeOnSameLine = + settings.GetValue((XamlStylerSettings s) => s.KeepFirstAttributeOnSameLine); + stylerOptions.MaxAttributeCharactersPerLine = + settings.GetValue((XamlStylerSettings s) => s.MaxAttributeCharactersPerLine); stylerOptions.MaxAttributesPerLine = settings.GetValue((XamlStylerSettings s) => s.MaxAttributesPerLine); stylerOptions.NoNewLineElements = settings.GetValue((XamlStylerSettings s) => s.NoNewLineElements); - stylerOptions.PutAttributeOrderRuleGroupsOnSeparateLines = settings.GetValue((XamlStylerSettings s) => s.PutAttributeOrderRuleGroupsOnSeparateLines); + stylerOptions.PutAttributeOrderRuleGroupsOnSeparateLines = settings.GetValue((XamlStylerSettings s) => + s.PutAttributeOrderRuleGroupsOnSeparateLines); stylerOptions.AttributeIndentation = settings.GetValue((XamlStylerSettings s) => s.AttributeIndentation); - stylerOptions.AttributeIndentationStyle = settings.GetValue((XamlStylerSettings s) => s.AttributeIndentationStyle); - stylerOptions.RemoveDesignTimeReferences = settings.GetValue((XamlStylerSettings s) => s.RemoveDesignTimeReferences); - stylerOptions.EnableAttributeReordering = settings.GetValue((XamlStylerSettings s) => s.EnableAttributeReordering); - stylerOptions.AttributeOrderingRuleGroups = settings.GetValue((XamlStylerSettings s) => s.AttributeOrderingRuleGroups)?.SplitByNewLine(); - if (stylerOptions.AttributeOrderingRuleGroups == null || stylerOptions.AttributeOrderingRuleGroups.Length == 0) + stylerOptions.AttributeIndentationStyle = + settings.GetValue((XamlStylerSettings s) => s.AttributeIndentationStyle); + stylerOptions.RemoveDesignTimeReferences = + settings.GetValue((XamlStylerSettings s) => s.RemoveDesignTimeReferences); + stylerOptions.EnableAttributeReordering = + settings.GetValue((XamlStylerSettings s) => s.EnableAttributeReordering); + stylerOptions.AttributeOrderingRuleGroups = settings + .GetValue((XamlStylerSettings s) => s.AttributeOrderingRuleGroups)?.SplitByNewLine(); + if (stylerOptions.AttributeOrderingRuleGroups == null || + stylerOptions.AttributeOrderingRuleGroups.Length == 0) { stylerOptions.AttributeOrderingRuleGroups = fallbackOptions.AttributeOrderingRuleGroups; } + stylerOptions.FirstLineAttributes = settings.GetValue((XamlStylerSettings s) => s.FirstLineAttributes); stylerOptions.OrderAttributesByName = settings.GetValue((XamlStylerSettings s) => s.OrderAttributesByName); - stylerOptions.PutEndingBracketOnNewLine = settings.GetValue((XamlStylerSettings s) => s.PutEndingBracketOnNewLine); - stylerOptions.RemoveEndingTagOfEmptyElement = settings.GetValue((XamlStylerSettings s) => s.RemoveEndingTagOfEmptyElement); - stylerOptions.SpaceBeforeClosingSlash = settings.GetValue((XamlStylerSettings s) => s.SpaceBeforeClosingSlash); - stylerOptions.RootElementLineBreakRule = settings.GetValue((XamlStylerSettings s) => s.RootElementLineBreakRule); + stylerOptions.PutEndingBracketOnNewLine = + settings.GetValue((XamlStylerSettings s) => s.PutEndingBracketOnNewLine); + stylerOptions.RemoveEndingTagOfEmptyElement = + settings.GetValue((XamlStylerSettings s) => s.RemoveEndingTagOfEmptyElement); + stylerOptions.SpaceBeforeClosingSlash = + settings.GetValue((XamlStylerSettings s) => s.SpaceBeforeClosingSlash); + stylerOptions.RootElementLineBreakRule = + settings.GetValue((XamlStylerSettings s) => s.RootElementLineBreakRule); stylerOptions.ReorderVSM = settings.GetValue((XamlStylerSettings s) => s.ReorderVSM); stylerOptions.ReorderGridChildren = settings.GetValue((XamlStylerSettings s) => s.ReorderGridChildren); stylerOptions.ReorderCanvasChildren = settings.GetValue((XamlStylerSettings s) => s.ReorderCanvasChildren); stylerOptions.ReorderSetters = settings.GetValue((XamlStylerSettings s) => s.ReorderSetters); stylerOptions.FormatMarkupExtension = settings.GetValue((XamlStylerSettings s) => s.FormatMarkupExtension); - stylerOptions.NoNewLineMarkupExtensions = settings.GetValue((XamlStylerSettings s) => s.NoNewLineMarkupExtensions); + stylerOptions.NoNewLineMarkupExtensions = + settings.GetValue((XamlStylerSettings s) => s.NoNewLineMarkupExtensions); stylerOptions.ThicknessStyle = settings.GetValue((XamlStylerSettings s) => s.ThicknessStyle); stylerOptions.ThicknessAttributes = settings.GetValue((XamlStylerSettings s) => s.ThicknessAttributes); stylerOptions.FormatOnSave = settings.GetValue((XamlStylerSettings s) => s.FormatOnSave); @@ -78,19 +91,22 @@ public static IStylerOptions FromSettings( stylerOptions.ConfigPath = settings.GetValue((XamlStylerSettings s) => s.ConfigPath)?.FullPath; stylerOptions.SearchToDriveRoot = settings.GetValue((XamlStylerSettings s) => s.SearchToDriveRoot); stylerOptions.SuppressProcessing = settings.GetValue((XamlStylerSettings s) => s.SuppressProcessing); - + // 2. Try finding settings in our project/solution? if (!string.IsNullOrEmpty(projectPath) || !string.IsNullOrEmpty(sourceFilePath)) { var searchToDriveRoot = settings.GetValue((XamlStylerSettings s) => s.SearchToDriveRoot); - + var highestRootPath = solution != null && !solution.IsTemporary - ? (searchToDriveRoot ? Path.GetPathRoot(solution.SolutionFilePath.FullPath) : Path.GetDirectoryName(solution.SolutionFilePath.FullPath)) + ? (searchToDriveRoot + ? Path.GetPathRoot(solution.SolutionFilePath.FullPath) + : Path.GetDirectoryName(solution.SolutionFilePath.FullPath)) : string.Empty; var itemPath = sourceFilePath; - - var configPath = (!string.IsNullOrEmpty(itemPath) && itemPath.StartsWith(highestRootPath, StringComparison.OrdinalIgnoreCase)) + + var configPath = (!string.IsNullOrEmpty(itemPath) && + itemPath.StartsWith(highestRootPath, StringComparison.OrdinalIgnoreCase)) ? GetConfigPathForProject(highestRootPath, itemPath) : GetConfigPathForProject(projectPath ?? itemPath, itemPath); if (!string.IsNullOrEmpty(configPath)) @@ -111,12 +127,14 @@ public static IStylerOptions FromSettings( // Note: stylerOptions.UseVisualStudioIndentSize is hardcoded to "True", which means we'll always use IDE settings when in IDE context. // To overcome this, we're ignoring the setting from XamlStyler settings files, and using the configuration in the IDE, so we can toggle this on/off. var schema = Shell.Instance.GetComponent(); - if (/*stylerOptions.UseVisualStudioIndentSize ||*/ settings.GetValue((XamlStylerSettings s) => s.UseIdeIndentSize)) + if ( /*stylerOptions.UseVisualStudioIndentSize ||*/ + settings.GetValue((XamlStylerSettings s) => s.UseIdeIndentSize)) { stylerOptions.IndentSize = xamlFormatterSettings.INDENT_SIZE; } - - if (/*stylerOptions.UseVisualStudioIndentWithTabs ||*/ settings.GetValue((XamlStylerSettings s) => s.UseIdeIndentWithTabs)) + + if ( /*stylerOptions.UseVisualStudioIndentWithTabs ||*/ + settings.GetValue((XamlStylerSettings s) => s.UseIdeIndentWithTabs)) { stylerOptions.IndentWithTabs = xamlFormatterSettings.INDENT_STYLE == IndentStyle.Tab; } @@ -124,14 +142,14 @@ public static IStylerOptions FromSettings( return stylerOptions; } - + private static string GetConfigPathForProject(string highestRootPath, string path) { if (path.IsNullOrEmpty()) { return null; } - + var currentDirectory = Path.GetDirectoryName(path); while (currentDirectory?.StartsWith(highestRootPath, StringComparison.InvariantCultureIgnoreCase) ?? false) { @@ -140,7 +158,7 @@ private static string GetConfigPathForProject(string highestRootPath, string pat { return configurationFilePath; } - + currentDirectory = Path.GetDirectoryName(currentDirectory); } diff --git a/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/XamlStylerReformatContextAction.cs b/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/XamlStylerReformatContextAction.cs index d0e50933..2aaace72 100644 --- a/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/XamlStylerReformatContextAction.cs +++ b/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/XamlStylerReformatContextAction.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using JetBrains.Annotations; using JetBrains.Application.Progress; using JetBrains.Application.Settings; using JetBrains.Application.UI.Controls.BulbMenu.Anchors; @@ -29,33 +28,37 @@ namespace Xavalon.XamlStyler.Extension.Rider Priority = -10)] public class XamlStylerReformatContextAction : ContextActionBase { - [NotNull] private readonly XamlContextActionDataProvider _dataProvider; - [NotNull] private readonly string _text; + private readonly XamlContextActionDataProvider _dataProvider; + private readonly string _text; private readonly ActionAppliesTo _actionAppliesTo; - public XamlStylerReformatContextAction([NotNull] XamlContextActionDataProvider dataProvider) + public XamlStylerReformatContextAction(XamlContextActionDataProvider dataProvider) : this(dataProvider, "Format with XAML Styler", ActionAppliesTo.File) { } - + private XamlStylerReformatContextAction( - [NotNull] XamlContextActionDataProvider dataProvider, - [NotNull] string text, + XamlContextActionDataProvider dataProvider, + string text, ActionAppliesTo actionAppliesTo) { _dataProvider = dataProvider ?? throw new ArgumentNullException(nameof(dataProvider)); _text = text ?? throw new ArgumentNullException(nameof(text)); _actionAppliesTo = actionAppliesTo; } - + public override string Text => _text; - + public override bool IsAvailable(IUserDataHolder cache) => _dataProvider.Document != null; public override IEnumerable CreateBulbItems() { - var mainAnchor = new SubmenuAnchor(IntentionsAnchors.ContextActionsAnchor, - new SubmenuBehavior(text: "Format with XAML Styler", icon: null, executable: true, removeFirst: true)); + var mainAnchor = new SubmenuAnchor( + IntentionsAnchors.ContextActionsAnchor, + SubmenuBehavior.Custom( + text: "Format with XAML Styler", + icon: null, + isExecutable: true)); var subAnchor2 = new InvisibleAnchor(mainAnchor); var subAnchor3 = subAnchor2.CreateNext(separate: true); @@ -64,7 +67,7 @@ IntentionAction Create(string text, ActionAppliesTo appliesTo, IAnchor anchor) return new XamlStylerReformatContextAction(_dataProvider, text, appliesTo) .ToContextActionIntention(anchor, XamlStylerThemedIcons.Logo.Id); } - + return new[] { Create(_text, _actionAppliesTo, subAnchor3), @@ -72,37 +75,41 @@ IntentionAction Create(string text, ActionAppliesTo appliesTo, IAnchor anchor) Create("Format XAML files in project", ActionAppliesTo.Project, subAnchor3), Create("Format XAML files in solution", ActionAppliesTo.Solution, subAnchor3) }; - } + } - protected override Action ExecutePsiTransaction( - [NotNull] ISolution solution, - [NotNull] IProgressIndicator progress) + protected override Action ExecutePsiTransaction(ISolution solution, IProgressIndicator progress) { // Fetch settings var lifetime = solution.GetSolutionLifetimes().MaximumLifetime; - var settings = solution.GetSettingsStore().SettingsStore.BindToContextLive(lifetime, ContextRange.Smart(solution.ToDataContext())); + var settings = solution.GetSettingsStore().SettingsStore + .BindToContextLive(lifetime, ContextRange.Smart(solution.ToDataContext())); var stylerOptions = StylerOptionsFactory.FromSettings( settings, - solution, + solution, _dataProvider.Project, - _actionAppliesTo == ActionAppliesTo.File + _actionAppliesTo == ActionAppliesTo.File ? _dataProvider.SourceFile as IPsiSourceFileWithLocation // Traverse config chain from file path - : null // Traverse config chain from project path + : null // Traverse config chain from project path ); // Bail out early if needed if (stylerOptions.SuppressProcessing) return null; - + // Perform styling var styler = new StylerService(stylerOptions, new XamlLanguageOptions { IsFormatable = true }); - - var psiSourceFiles = - _actionAppliesTo == ActionAppliesTo.File ? _dataProvider.Document.GetPsiSourceFiles(solution).AsIReadOnlyList() - : _actionAppliesTo == ActionAppliesTo.Project ? _dataProvider.Project.GetAllProjectFiles(it => it.LanguageType.Is()).SelectMany(file => file.ToSourceFiles().AsIReadOnlyList()) - : _dataProvider.Solution.GetAllProjects().SelectMany(project => project.GetAllProjectFiles(it => it.LanguageType.Is()).SelectMany(file => file.ToSourceFiles().AsIReadOnlyList())); + + var psiSourceFiles = + _actionAppliesTo == ActionAppliesTo.File + ? _dataProvider.Document.GetPsiSourceFiles(solution).AsIReadOnlyList() + : _actionAppliesTo == ActionAppliesTo.Project + ? _dataProvider.Project.GetAllProjectFiles(it => it.LanguageType.Is()) + .SelectMany(file => file.ToSourceFiles().AsIReadOnlyList()) + : _dataProvider.Solution.GetAllProjects().SelectMany(project => + project.GetAllProjectFiles(it => it.LanguageType.Is()) + .SelectMany(file => file.ToSourceFiles().AsIReadOnlyList())); foreach (var prjItem in psiSourceFiles) { diff --git a/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/Xavalon.XamlStyler.Extension.Rider.csproj b/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/Xavalon.XamlStyler.Extension.Rider.csproj index 3f4d0b2f..09314c41 100644 --- a/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/Xavalon.XamlStyler.Extension.Rider.csproj +++ b/src/XamlStyler.Extension.Rider/dotnet/Xavalon.XamlStyler.Extension.Rider/Xavalon.XamlStyler.Extension.Rider.csproj @@ -8,7 +8,9 @@ net472 + 8.0 false + enable $(DefineConstants);RIDER @@ -17,7 +19,10 @@ - + + all + compile; runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/XamlStyler.Extension.Rider/gradle.properties b/src/XamlStyler.Extension.Rider/gradle.properties index b0cf162f..9ef8680a 100644 --- a/src/XamlStyler.Extension.Rider/gradle.properties +++ b/src/XamlStyler.Extension.Rider/gradle.properties @@ -8,6 +8,6 @@ kotlin.stdlib.default.dependency=false DotnetPluginId=Xavalon.XamlStyler.Extension.Rider DotnetSolution=../XamlStyler.Rider.sln RiderPluginId=XamlStyler.Rider -PluginVersion=0.0.1337 +PluginVersion=0.0.1338 BuildConfiguration=Release diff --git a/src/XamlStyler.Extension.Rider/gradle/libs.versions.toml b/src/XamlStyler.Extension.Rider/gradle/libs.versions.toml index 2589a935..20319e65 100644 --- a/src/XamlStyler.Extension.Rider/gradle/libs.versions.toml +++ b/src/XamlStyler.Extension.Rider/gradle/libs.versions.toml @@ -6,12 +6,12 @@ # # RIDER: To be updated with new Rider release # https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library -kotlin = "2.1.10" +kotlin = "2.3.20" # https://www.jetbrains.com/intellij-repository/snapshots/com/jetbrains/intellij/rider/riderRD/maven-metadata.xml # https://www.jetbrains.com/intellij-repository/releases/com/jetbrains/intellij/rider/riderRD/maven-metadata.xml -rider = "2025.1" +rider = "2026.1" # https://search.maven.org/artifact/com.jetbrains.rd/rd-gen -rdGen = "2025.1.1" +rdGen = "2026.1.3" [libraries] kotlin-stdLib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" } @@ -20,6 +20,6 @@ rdGen = { group = "com.jetbrains.rd", name = "rd-gen", version.ref = "rdGen" } [plugins] # RIDER: May need updating with new Rider releases # https://github.com/JetBrains/intellij-platform-gradle-plugin -intellij-platform = "org.jetbrains.intellij.platform:2.5.0" +intellij-platform = "org.jetbrains.intellij.platform:2.15.0" # https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } diff --git a/src/XamlStyler.Extension.Rider/gradle/wrapper/gradle-wrapper.properties b/src/XamlStyler.Extension.Rider/gradle/wrapper/gradle-wrapper.properties index cfe19cd8..43fc96ab 100644 --- a/src/XamlStyler.Extension.Rider/gradle/wrapper/gradle-wrapper.properties +++ b/src/XamlStyler.Extension.Rider/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://cache-redirector.jetbrains.com/services.gradle.org/distributions/gradle-8.10-all.zip +distributionUrl=https\://cache-redirector.jetbrains.com/services.gradle.org/distributions/gradle-9.4.1-all.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/XamlStyler.Extension.Rider/protocol/build.gradle.kts b/src/XamlStyler.Extension.Rider/protocol/build.gradle.kts index 71972639..6dd29e96 100644 --- a/src/XamlStyler.Extension.Rider/protocol/build.gradle.kts +++ b/src/XamlStyler.Extension.Rider/protocol/build.gradle.kts @@ -23,7 +23,7 @@ val RiderPluginId: String by project rdgen { val csOutput = file("../dotnet/${DotnetPluginId}/Rider") - val ktOutput = file("../rider/main/kotlin/xavalon/plugins/${RiderPluginId.replace('.','/').toLowerCase()}") + val ktOutput = file("../rider/main/kotlin/xavalon/plugins/${RiderPluginId.replace('.','/').lowercase()}") verbose = true packages = "model.rider" diff --git a/src/XamlStyler.Extension.Rider/rider/main/kotlin/xavalon/plugins/xamlstyler/rider/XamlStylerModel.Generated.kt b/src/XamlStyler.Extension.Rider/rider/main/kotlin/xavalon/plugins/xamlstyler/rider/XamlStylerModel.Generated.kt index 44deeccb..5384031c 100644 --- a/src/XamlStyler.Extension.Rider/rider/main/kotlin/xavalon/plugins/xamlstyler/rider/XamlStylerModel.Generated.kt +++ b/src/XamlStyler.Extension.Rider/rider/main/kotlin/xavalon/plugins/xamlstyler/rider/XamlStylerModel.Generated.kt @@ -16,7 +16,7 @@ import kotlin.jvm.JvmStatic /** - * #### Generated from [XamlStylerModel.kt:12] + * #### Generated from [XamlStylerModel.kt:11] */ class XamlStylerModel private constructor( private val _performReformat: RdCall @@ -90,6 +90,11 @@ data class RdXamlStylerFormattingRequest ( val filePath: String, val documentText: String ) : IPrintable { + //write-marshaller + private fun write(ctx: SerializationCtx, buffer: AbstractBuffer) { + buffer.writeString(filePath) + buffer.writeString(documentText) + } //companion companion object : IMarshaller { @@ -104,8 +109,7 @@ data class RdXamlStylerFormattingRequest ( } override fun write(ctx: SerializationCtx, buffer: AbstractBuffer, value: RdXamlStylerFormattingRequest) { - buffer.writeString(value.filePath) - buffer.writeString(value.documentText) + value.write(ctx, buffer) } @@ -156,6 +160,12 @@ data class RdXamlStylerFormattingResult ( val hasUpdated: Boolean, val formattedText: String ) : IPrintable { + //write-marshaller + private fun write(ctx: SerializationCtx, buffer: AbstractBuffer) { + buffer.writeBool(isSuccess) + buffer.writeBool(hasUpdated) + buffer.writeString(formattedText) + } //companion companion object : IMarshaller { @@ -171,9 +181,7 @@ data class RdXamlStylerFormattingResult ( } override fun write(ctx: SerializationCtx, buffer: AbstractBuffer, value: RdXamlStylerFormattingResult) { - buffer.writeBool(value.isSuccess) - buffer.writeBool(value.hasUpdated) - buffer.writeString(value.formattedText) + value.write(ctx, buffer) }