Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync with the ultimate master #244

Merged
merged 2 commits into from
Jan 31, 2025
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
5 changes: 3 additions & 2 deletions resharper/src/Application/Settings/SettingsSynchronizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace JetBrains.ReSharper.Plugins.Godot.Application.Settings
{
[SolutionComponent(InstantiationEx.LegacyDefault)]
[SolutionComponent(Instantiation.LaterAsyncAnyThreadSafe)]
public class SettingsSynchronizer
{
public SettingsSynchronizer(Lifetime lifetime, ISolution solution, FrontendBackendHost host,
Expand Down Expand Up @@ -44,7 +44,8 @@ private static void BindSettingToProperty<TKeyClass, TEntryMemberType>(
{
var name = entry.GetInstanceMemberName();
var setting = boundStore.Schema.GetScalarEntry(entry);
boundStore.GetValueProperty<TEntryMemberType>(lifetime, setting, null).Change.Advise_HasNew(lifetime,
var apartmentForNotifications = ApartmentForNotifications.Primary(solution.Locks);
boundStore.GetValueProperty2<TEntryMemberType>(lifetime, setting, null, apartmentForNotifications).Change.Advise_HasNew(lifetime,
args =>
{
solution.Locks.ExecuteOrQueueEx(lifetime, name, () =>
Expand Down
19 changes: 3 additions & 16 deletions resharper/src/Protocol/FrontendBackendHost.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,27 @@
using System;
using JetBrains.Annotations;
using JetBrains.Application.Parts;
using JetBrains.Application.Threading;
using JetBrains.Lifetimes;
using JetBrains.ProjectModel;
using JetBrains.RdBackend.Common.Features;
using JetBrains.ReSharper.Feature.Services.Protocol;
using JetBrains.Rider.Model.Godot.FrontendBackend;

namespace JetBrains.ReSharper.Plugins.Godot.Protocol
{
[SolutionComponent(InstantiationEx.LegacyDefault)]
[SolutionComponent(Instantiation.DemandAnyThreadSafe)]
public class FrontendBackendHost
{
private readonly bool myIsInTests;

// This will only ever be null when running tests. The value does not change for the lifetime of the solution.
// Prefer using this field over calling GetFrontendBackendModel(), as that method will throw in tests
[CanBeNull] public readonly GodotFrontendBackendModel Model;

public FrontendBackendHost(Lifetime lifetime, ISolution solution, IShellLocks shellLocks,
bool isInTests = false)
public FrontendBackendHost(ISolution solution)
{
myIsInTests = isInTests;
if (myIsInTests)
return;

// This will throw in tests, as GetProtocolSolution will return null
var model = solution.GetProtocolSolution().GetGodotFrontendBackendModel();
Model = model;
}

public bool IsAvailable => !myIsInTests && Model != null;
public bool IsAvailable => Model != null;

// Convenience method to fire and forget an action on the model (e.g. set a value, fire a signal, etc). Fire and
// forget means it's safe to use during testing, when there won't be a frontend model available, and Model will
Expand All @@ -40,9 +30,6 @@ public FrontendBackendHost(Lifetime lifetime, ISolution solution, IShellLocks sh
// Model directly in this case, check for null and do whatever is appropriate for the callsite.
public void Do(Action<GodotFrontendBackendModel> action)
{
if (myIsInTests)
return;

action(Model);
}
}
Expand Down
Loading