File tree Expand file tree Collapse file tree 3 files changed +30
-3
lines changed
src/Domain/HydraScript.Domain.FrontEnd/Parser/Impl/Ast/Nodes/Expressions/ComplexLiterals Expand file tree Collapse file tree 3 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ public partial class ArrayLiteral : ComplexLiteral
1010
1111 public IReadOnlyList < Expression > Expressions => _expressions ;
1212
13+ public override string Id => Parent is AssignmentExpression assignment
14+ ? assignment . Destination . Id
15+ : NullId ;
16+
1317 public ArrayLiteral ( List < Expression > expressions )
1418 {
1519 _expressions = expressions ;
Original file line number Diff line number Diff line change @@ -2,7 +2,16 @@ namespace HydraScript.Domain.FrontEnd.Parser.Impl.Ast.Nodes.Expressions.ComplexL
22
33public abstract class ComplexLiteral : Expression
44{
5- public string Id => Parent is AssignmentExpression assignment
6- ? assignment . Destination . Id
7- : $ "_t{ GetHashCode ( ) } ";
5+ private string ? _nullId ;
6+
7+ protected string NullId
8+ {
9+ get
10+ {
11+ _nullId ??= $ "{ GetHashCode ( ) } ";
12+ return _nullId ;
13+ }
14+ }
15+
16+ public abstract string Id { get ; }
817}
Original file line number Diff line number Diff line change @@ -10,6 +10,20 @@ public partial class ObjectLiteral : ComplexLiteral
1010
1111 public IReadOnlyList < Property > Properties => _properties ;
1212
13+ public override string Id
14+ {
15+ get
16+ {
17+ if ( Parent is AssignmentExpression assignment )
18+ return assignment . Destination . Id ;
19+
20+ if ( Parent is WithExpression { Parent : AssignmentExpression withAssignment } )
21+ return withAssignment . Destination . Id ;
22+
23+ return NullId ;
24+ }
25+ }
26+
1327 public ObjectLiteral ( List < Property > properties )
1428 {
1529 _properties = properties ;
You can’t perform that action at this time.
0 commit comments