-
Notifications
You must be signed in to change notification settings - Fork 114
Expand file tree
/
Copy pathCsharpAstNode.cs
More file actions
68 lines (64 loc) · 2.49 KB
/
CsharpAstNode.cs
File metadata and controls
68 lines (64 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
namespace DbModel
{
public enum AstSymbolTypeEnum
{
Variable,
Method,
Class,
Struct,
Namespace,
Enum,
EnumMember,
EtcEntity
}
public enum AstTypeEnum
{
Declaration,
Definition,
Usage,
Read,
Write,
Expression
}
public class CsharpAstNode
{
public ulong Id { get; set; }
public string? AstValue { get; set; }
public AstSymbolTypeEnum AstSymbolType { get; set; }
public AstTypeEnum AstType { get; set; }
public Accessibility Accessibility { get; set; }
public long Location_range_start_line { get; set; }
public long Location_range_start_column { get; set; }
public long Location_range_end_line { get; set; }
public long Location_range_end_column { get; set; }
public string? Path { get; set; }
public long EntityHash { get; set; }
public SyntaxKind RawKind { get; set; } //SyntaxKind Enum
public void SetLocation(FileLinePositionSpan f)
{
Location_range_start_line = f.StartLinePosition.Line+1;
Location_range_start_column = f.StartLinePosition.Character+1;
Location_range_end_line = f.EndLinePosition.Line+1;
Location_range_end_column = f.EndLinePosition.Character+1;
Path = f.Path;
}
public bool isRangeSmaller(CsharpAstNode other){
if (Location_range_start_line == other.Location_range_start_line){
if (Location_range_end_line == other.Location_range_end_line){
return Location_range_end_column - Location_range_start_column <
other.Location_range_end_column - other.Location_range_start_column;
}
return Location_range_end_line < other.Location_range_end_line;
} else if (Location_range_end_line - Location_range_start_line ==
other.Location_range_end_line - other.Location_range_start_line){
return Location_range_end_column - Location_range_start_column <
other.Location_range_end_column - other.Location_range_start_column;
}
return Location_range_end_line - Location_range_start_line <
other.Location_range_end_line - other.Location_range_start_line;
}
}
}