Skip to content

Commit

Permalink
Filtering in Types & Code Property in MetaData
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBakerEffendi committed Dec 19, 2023
1 parent 0d27d1f commit 8c10ec2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions DotNetAstGen/SyntaxMetaDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ private static SyntaxMetaData GetNodeMetadata(SyntaxNode node)
span.StartLinePosition.Line,
span.EndLinePosition.Line,
span.StartLinePosition.Character,
span.EndLinePosition.Character
span.EndLinePosition.Character,
node.GetText().ToString().Trim()
);
}

Expand Down Expand Up @@ -53,20 +54,22 @@ public SyntaxMetaData()
{
}

public SyntaxMetaData(string kind, int lineStart, int lineEnd, int columnStart, int columnEnd)
public SyntaxMetaData(string kind, int lineStart, int lineEnd, int columnStart, int columnEnd, string code)
{
Kind = kind;
LineStart = lineStart;
LineEnd = lineEnd;
ColumnStart = columnStart;
ColumnEnd = columnEnd;
Code = code;
}

public string Kind { get; set; } = "ast.None";
public int LineStart { get; set; } = -1;
public int LineEnd { get; set; } = -1;
public int ColumnStart { get; set; } = -1;
public int ColumnEnd { get; set; } = -1;
public string Code { get; set; } = "<empty>";

public override string ToString()
{
Expand Down
4 changes: 2 additions & 2 deletions DotNetAstGen/SyntaxNodePropertiesResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ internal class SyntaxNodePropertiesResolver : DefaultContractResolver
"Alias", "NamespaceOrType", "Arguments", "Expression", "Declaration", "ElementType", "Initializer", "Else",
"Condition", "Statement", "Statements", "Variables", "WhenNotNull", "AllowsAnyExpression", "Expressions",
"Modifiers", "ReturnType", "IsUnboundGenericName", "Default", "IsConst", "Parameters", "Types",
"ExplicitInterfaceSpecifier", "MetaData", "Kind", "AstRoot", "FileName"
"ExplicitInterfaceSpecifier", "MetaData", "Kind", "AstRoot", "FileName", "Code"
});

private readonly List<string> _regexToAllow = new(new[]
{
".*Token$", ".*Keyword$", ".*Lists?$", ".*Body$", "(Line|Column)(Start|End)"
".*Token$", ".*Keyword$", ".*Lists?$", ".*Body$", "(Line|Column)(Start|End)", ".*Type$",
});

private readonly List<string> _regexToIgnore = new(new[]
Expand Down

0 comments on commit 8c10ec2

Please sign in to comment.