@@ -125,7 +125,10 @@ function allFeatures(classifier: Classifier) {
125
125
export class LionwebNode extends NodeAdapter {
126
126
127
127
parent : LionwebNode ;
128
- public readonly nodeDefinition : NodeDefinition ;
128
+ private _nodeDefinition ?: NodeDefinition ;
129
+ public get nodeDefinition ( ) : NodeDefinition {
130
+ return this . _nodeDefinition ! ;
131
+ }
129
132
130
133
constructor (
131
134
public readonly classifier : Classifier ,
@@ -136,20 +139,37 @@ export class LionwebNode extends NodeAdapter {
136
139
allFeatures ( classifier ) . forEach ( f => {
137
140
properties [ f . name ] = featureToProperty ( f ) ;
138
141
} ) ;
139
- this . nodeDefinition = {
142
+ this . _nodeDefinition = {
140
143
name : classifier . name ,
141
144
properties : properties ,
142
145
resolved : true
143
146
} ;
144
147
}
145
148
146
149
// eslint-disable-next-line @typescript-eslint/no-unused-vars
147
- get ( ...path : string [ ] ) : NodeAdapter | undefined {
148
- return undefined ; // TODO
150
+ get ( ...path : string [ ] ) : LionwebNode | undefined {
151
+ let result : LionwebNode | undefined = undefined ;
152
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
153
+ let parent : LionwebNode = this ;
154
+ for ( const element of path ) {
155
+ result = parent . getChild ( element ) as LionwebNode ;
156
+ if ( result ) {
157
+ parent = result ;
158
+ } else {
159
+ return undefined ;
160
+ }
161
+ }
162
+ return result ;
149
163
}
150
164
151
165
getAttributes ( ) : { [ p : string ] : any } {
152
- return { } ; // TODO
166
+ const attributes = { } ;
167
+ for ( const p in this . nodeDefinition . properties ) {
168
+ if ( ! this . nodeDefinition . properties [ p ] . child ) {
169
+ attributes [ p ] = this . getAttribute ( p ) ;
170
+ }
171
+ }
172
+ return attributes ;
153
173
}
154
174
155
175
getId ( ) : string {
0 commit comments