Skip to content

Commit 29e1978

Browse files
committed
Increased a test coverage.
1 parent 79e811d commit 29e1978

44 files changed

Lines changed: 244 additions & 192 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Luthetus.Common.RazorLib.Drags.Displays;
2+
using Luthetus.Common.RazorLib.Drags.Models;
3+
4+
namespace Luthetus.Common.RazorLib.Drags.Extensions;
5+
6+
public static class IDragServiceExtension
7+
{
8+
public static void WithAction(this IDragService dragService,
9+
Func<DragState, DragState> action)
10+
{
11+
action(dragService.DragStateWrap.Value);
12+
}
13+
}

Source/Lib/Common/Drags/Models/IDragService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ namespace Luthetus.Common.RazorLib.Drags.Models;
66
public interface IDragService
77
{
88
public IState<DragState> DragStateWrap { get; }
9-
}
9+
}

Source/Lib/Common/Keymaps/Models/Keymap.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,32 @@ public bool TryRegister(KeymapArgs args, CommandNoType command)
4747
return true;
4848
}
4949

50+
public bool TryMap(KeymapArgs args, out CommandNoType command)
51+
{
52+
lock (_syncRoot)
53+
{
54+
var keybind = new Keybind(args, command);
55+
56+
if (args.Key is not null)
57+
{
58+
if (!_mapKey.ContainsKey(args.Key))
59+
_mapKey.Add(args.Key, new());
60+
61+
_mapKey[args.Key].Add(keybind);
62+
}
63+
64+
if (args.Code is not null)
65+
{
66+
if (!_mapCode.ContainsKey(args.Code))
67+
_mapCode.Add(args.Code, new());
68+
69+
_mapCode[args.Code].Add(keybind);
70+
}
71+
}
72+
73+
return true;
74+
}
75+
5076
public (List<Keybind>? keyMatchList, List<Keybind>? codeMatchList) MapAll(KeymapArgs args)
5177
{
5278
List<Keybind>? keyMatchList = null;

Source/Lib/CompilerServices/CSharp/Luthetus.CompilerServices.CSharp.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>net8.0</TargetFramework>
@@ -14,6 +14,7 @@
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17+
<PackageReference Include="OneOf" Version="3.0.271" />
1718
<PackageReference Include="System.Reflection.MetadataLoadContext" Version="8.0.0" />
1819
</ItemGroup>
1920

Source/Lib/TextEditor/CompilerServices/GenericLexer/GenericLanguageDefinition.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Luthetus.TextEditor.RazorLib.CompilerServices.GenericLexer;
44

5-
public class GenericLanguageDefinition
5+
public record GenericLanguageDefinition
66
{
77
public GenericLanguageDefinition(
88
string stringStart,

Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/ConstructorDefinitionNode.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,23 @@
66

77
namespace Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes;
88

9+
using FunctionBodyCodeBlockNode = Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.CodeBlockNode;
10+
911
public sealed class ConstructorDefinitionNode : ICodeBlockOwner
1012
{
1113
public ConstructorDefinitionNode(
1214
TypeClauseNode returnTypeClauseNode,
1315
IdentifierToken functionIdentifier,
1416
GenericArgumentsListingNode? genericArgumentsListingNode,
1517
FunctionArgumentsListingNode functionArgumentsListingNode,
16-
CodeBlockNode? codeBlockNode,
18+
FunctionBodyCodeBlockNode? functionBodyCodeBlockNode,
1719
ConstraintNode? constraintNode)
1820
{
1921
ReturnTypeClauseNode = returnTypeClauseNode;
2022
FunctionIdentifier = functionIdentifier;
2123
GenericArgumentsListingNode = genericArgumentsListingNode;
2224
FunctionArgumentsListingNode = functionArgumentsListingNode;
23-
CodeBlockNode = codeBlockNode;
25+
CodeBlockNode = functionBodyCodeBlockNode;
2426
ConstraintNode = constraintNode;
2527
}
2628

@@ -31,7 +33,7 @@ public ConstructorDefinitionNode(
3133
public IdentifierToken FunctionIdentifier { get; }
3234
public GenericArgumentsListingNode? GenericArgumentsListingNode { get; }
3335
public FunctionArgumentsListingNode FunctionArgumentsListingNode { get; }
34-
public CodeBlockNode? CodeBlockNode { get; private set; }
36+
public FunctionBodyCodeBlockNode? CodeBlockNode { get; private set; }
3537
public ConstraintNode? ConstraintNode { get; }
3638

3739
// (2024-11-08)

Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/FunctionArgumentsListingNode.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public sealed class FunctionArgumentsListingNode : IExpressionNode
1111
{
1212
public FunctionArgumentsListingNode(
1313
OpenParenthesisToken openParenthesisToken,
14-
List<FunctionArgumentEntryNode> functionArgumentEntryNodeList,
14+
IList<FunctionArgumentEntryNode> functionArgumentEntryNodeList,
1515
CloseParenthesisToken closeParenthesisToken)
1616
{
1717
OpenParenthesisToken = openParenthesisToken;
@@ -23,7 +23,7 @@ public FunctionArgumentsListingNode(
2323
private bool _childListIsDirty = true;
2424

2525
public OpenParenthesisToken OpenParenthesisToken { get; }
26-
public List<FunctionArgumentEntryNode> FunctionArgumentEntryNodeList { get; }
26+
public IList<FunctionArgumentEntryNode> FunctionArgumentEntryNodeList { get; }
2727
public CloseParenthesisToken CloseParenthesisToken { get; }
2828
TypeClauseNode IExpressionNode.ResultTypeClauseNode => TypeFacts.Pseudo.ToTypeClause();
2929

Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/FunctionDefinitionNode.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes;
88

9+
using FunctionBodyCodeBlockNode = CodeBlockNode;
10+
911
/// <summary>
1012
/// TODO: Track the open and close braces for the function body.
1113
/// </summary>
@@ -17,7 +19,7 @@ public FunctionDefinitionNode(
1719
IdentifierToken functionIdentifierToken,
1820
GenericParametersListingNode? genericArgumentsListingNode,
1921
FunctionArgumentsListingNode functionArgumentsListingNode,
20-
CodeBlockNode? codeBlockNode,
22+
FunctionBodyCodeBlockNode? codeBlockNode,
2123
ConstraintNode? constraintNode)
2224
{
2325
AccessModifierKind = accessModifierKind;

Source/Lib/TextEditor/TextEditors/States/TextEditorState.Main.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
using System.Collections.Immutable;
21
using Fluxor;
32
using Luthetus.Common.RazorLib.Keys.Models;
4-
using Luthetus.TextEditor.RazorLib.TextEditors.Models;
53
using Luthetus.TextEditor.RazorLib.Lexers.Models;
4+
using Luthetus.TextEditor.RazorLib.TextEditors.Models;
5+
using System.Collections.Immutable;
6+
using System.Linq;
67

78
namespace Luthetus.TextEditor.RazorLib.TextEditors.States;
89

@@ -58,7 +59,7 @@ namespace Luthetus.TextEditor.RazorLib.TextEditors.States;
5859
public partial record TextEditorState
5960
{
6061
private readonly Dictionary<ResourceUri, TextEditorModel> _modelMap = new();
61-
private readonly Dictionary<Key<TextEditorViewModel>, TextEditorViewModel> _viewModelMap = new();
62+
private readonly Dictionary<Key<TextEditorViewModel>, TextEditorViewModel> _viewModelMap = new();
6263

6364
public (TextEditorModel? TextEditorModel, TextEditorViewModel? TextEditorViewModel) GetModelAndViewModelOrDefault(
6465
ResourceUri resourceUri, Key<TextEditorViewModel> viewModelKey)
@@ -149,7 +150,10 @@ public int ModelGetModelsCount()
149150

150151
return 0;
151152
}
152-
153+
154+
public ImmutableList<KeyValuePair<ResourceUri, TextEditorModel>> ModelList => [.. ModelGetModels()];
155+
156+
153157
public ImmutableArray<TextEditorViewModel> ModelGetViewModelsOrEmpty(ResourceUri resourceUri)
154158
{
155159
try

Source/Tests/BUnit/Luthetus.BUnit.Tests/TextEditors/MutableVirtualizationResult/TrySomething.razor

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
@using Luthetus.TextEditor.RazorLib.Virtualizations.Models
2121
@using Luthetus.TextEditor.RazorLib.Exceptions
2222
@using Luthetus.Ide.RazorLib.Installations.Models
23+
@using OneOf
2324

2425
@inherits EditLogicTestBase
2526
@code
@@ -84,14 +85,15 @@
8485
Console.WriteLine($"EntryList.Length: {viewModel.VirtualizationResult.EntryList.Length}");
8586
}
8687

87-
public void ConsoleWriteVirtualizationResultToString(VirtualizationResult<List<RichCharacter>> virtualizationResult)
88+
public void ConsoleWriteVirtualizationResultToString(OneOf<VirtualizationResult<RichCharacter[]>, VirtualizationResult<List<RichCharacter>>> virtualizationResult)
8889
{
90+
8991
Console.WriteLine("==============");
9092
Console.WriteLine($"{nameof(VirtualizationResult<List<RichCharacter>>)}:");
9193

9294
var stringBuilder = new StringBuilder();
9395

94-
foreach (var entry in virtualizationResult.EntryList)
96+
foreach (var entry in virtualizationResult.AsT1.EntryList)
9597
{
9698
foreach (var richCharacter in entry.Item)
9799
{

0 commit comments

Comments
 (0)