Skip to content

Commit 3418f69

Browse files
committed
input property
1 parent 0e47475 commit 3418f69

File tree

11 files changed

+46
-52
lines changed

11 files changed

+46
-52
lines changed

src/SimpleStateMachine.StructuralSearch.Sandbox/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.IO;
34
using System.Linq;
45
using System.Text.Json;
56
using System.Text.RegularExpressions;

src/SimpleStateMachine.StructuralSearch/EmptyInput.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,11 @@ public Result<char, T> Parse<T>(Parser<char, T> parser)
88
{
99
throw new System.NotImplementedException();
1010
}
11+
12+
public string Extension => string.Empty;
13+
public string Path => string.Empty;
14+
public string Name => string.Empty;
15+
public string Data => string.Empty;
16+
public long Lenght => 0;
1117
}
1218
}

src/SimpleStateMachine.StructuralSearch/FileInput.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,11 @@ public Result<char, T> Parse<T>(Parser<char, T> parser)
1616
{
1717
return parser.Parse(FileInfo.OpenText());
1818
}
19+
20+
public string Extension => FileInfo.Extension;
21+
public string Path => System.IO.Path.GetFullPath(FileInfo.FullName);
22+
public string Name => System.IO.Path.GetFileNameWithoutExtension(FileInfo.Name);
23+
public string Data => FileInfo.OpenText().ReadToEnd();
24+
public long Lenght => FileInfo.Length;
1925
}
2026
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Pidgin;
2+
3+
namespace SimpleStateMachine.StructuralSearch
4+
{
5+
public interface IInput
6+
{
7+
Result<char, T> Parse<T>(Parser<char, T> parser);
8+
9+
string Extension { get; }
10+
string Path { get; }
11+
string Name { get; }
12+
string Data { get; }
13+
public long Lenght { get; }
14+
}
15+
}

src/SimpleStateMachine.StructuralSearch/ISource.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/SimpleStateMachine.StructuralSearch/ParsingContext.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ public ParsingContext(IInput input)
1010
}
1111
public Dictionary<string, Placeholder> Placeholders { get; } = new();
1212

13-
public FileProperty File { get; }
14-
1513
public IInput Input { get; }
1614

1715
public bool TryGetPlaceholder(string name, out Placeholder value)

src/SimpleStateMachine.StructuralSearch/Placeholder/FileProperty.cs

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/SimpleStateMachine.StructuralSearch/Placeholder/Placeholder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public Placeholder(IParsingContext context, string name, string value, LinePrope
2020
public readonly LineProperty Line;
2121
public readonly ColumnProperty Column;
2222
public readonly OffsetProperty Offset;
23-
23+
public IInput Input => _context.Input;
2424

2525
public static Placeholder CreateEmpty(IParsingContext context, string name, string value)
2626
{

src/SimpleStateMachine.StructuralSearch/Rules/Parameters/FileProperty.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ public enum FileProperty
44
{
55
Path = 0,
66
Data,
7+
Extension,
78
Name,
8-
Directory,
99
Lenght
1010
}
1111
}

src/SimpleStateMachine.StructuralSearch/Rules/Parameters/PlaceholderFileParameter.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,16 @@ public PlaceholderFileParameter(PlaceholderParameter parameter, FileProperty pro
1515

1616
public string GetValue()
1717
{
18-
// TODO
19-
// var file = PlaceholderParameter.GetPlaceholder().File;
20-
// return Property switch
21-
// {
22-
// FileProperty.Path => file.Path,
23-
// FileProperty.Data => file.Data,
24-
// FileProperty.Name => file.Name,
25-
// FileProperty.Directory => file.Directory,
26-
// FileProperty.Lenght => file.Lenght.ToString(),
27-
// _ => throw new ArgumentOutOfRangeException()
28-
// };
18+
var input = PlaceholderParameter.GetPlaceholder().Input;
19+
return Property switch
20+
{
21+
FileProperty.Path => input.Path,
22+
FileProperty.Data => input.Data,
23+
FileProperty.Extension => input.Extension,
24+
FileProperty.Name => input.Name,
25+
FileProperty.Lenght => input.Lenght.ToString(),
26+
_ => throw new ArgumentOutOfRangeException()
27+
};
2928

3029
return null;
3130
}

0 commit comments

Comments
 (0)