Skip to content

Commit

Permalink
Fix bug with body token
Browse files Browse the repository at this point in the history
  • Loading branch information
keyroll-99 committed Jun 1, 2024
1 parent 6d920bd commit fdf2dff
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 2 additions & 0 deletions ide/src/Fiona.IDE.ProjectManager/Models/ProjectFile.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Fiona.IDE.ProjectManager.Exceptions;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;

namespace Fiona.IDE.ProjectManager.Models;
Expand All @@ -7,6 +8,7 @@ public sealed class ProjectFile
{
public string Path { get; }
public string Name { get; }
[NotMapped]
public Class Class { get; }
public const string Extension = "fn";

Expand Down
4 changes: 2 additions & 2 deletions ide/src/Fiona.IDE.Tokenizer/TokenFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ internal static class TokenFactory

static TokenFactory()
{
foreach (TokenType tokenType in Enum.GetValues<TokenType>())
foreach (TokenType tokenType in Enum.GetValues<TokenType>().ToList().GetTokenTypesWithKeyword())
{
TokenKeywords[tokenType] = tokenType.GetTokenKeyword();
}
Expand Down Expand Up @@ -129,7 +129,7 @@ private static void AppendLines(StringBuilder body, IList<string> lines, string
}

private static IEnumerable<TokenType> GetTokenTypesToCheck(string input)
=> Enum.GetValues<TokenType>().Where(tokenType => input.Contains(TokenKeywords[tokenType])).Where(x => x != TokenType.Body);
=> Enum.GetValues<TokenType>().Where(tokenType => input.Contains(TokenKeywords[tokenType]));

private static IToken? GetStartUsingToken(string command)
=> GetTokenEquals(command, TokenType.UsingBegin);
Expand Down
4 changes: 2 additions & 2 deletions ide/src/Fiona.IDE.Tokenizer/TokenListHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ public static (List<IToken> tokens, int endSearchIndex) GetUsingTokens(this IRea
break;
case TokenType.UsingEnd:
isUsingPart = false;
break;
return (result, i);
case TokenType.Using:
if (isUsingPart)
{
result.Add(currentToken);
}
return (result, i);
break;
case TokenType.Comment:
continue;
}
Expand Down
6 changes: 5 additions & 1 deletion ide/src/Fiona.IDE.Tokenizer/TokenType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ public static string GetTokenKeyword(this TokenType tokenType)
TokenType.Parameter => "input:",
TokenType.Dependency => "inject:",
TokenType.Namespace => "namespace:",
TokenType.Body => "",
_ => throw new ArgumentOutOfRangeException(nameof(tokenType), tokenType, null)
};
}

public static IEnumerable<TokenType> GetTokenTypesWithKeyword(this List<TokenType> tokens)
{
return tokens.Where(x => x != TokenType.Body);
}
}

0 comments on commit fdf2dff

Please sign in to comment.