@@ -88,8 +88,9 @@ export class TaskListLangiumModelServerFacade extends AbstractLangiumModelServer
88
88
}
89
89
90
90
const newTransition = semantic . Transition . createNew ( sourceTask , targetTask )
91
- if ( ! this . identityManager . getIdentityIndex ( lmsDocument ) . transitions . isNameFit ( newTransition . name ) ) {
92
- return ModificationResult . failedValidation ( `Unable to fit supplied transition name ${ newTransition . name } : invalid value` )
91
+ const newTransitionName = identity . TransitionDerivativeName . ofNew ( newTransition )
92
+ if ( ! this . identityManager . getIdentityIndex ( lmsDocument ) . transitions . isNameFit ( newTransitionName ) ) {
93
+ return ModificationResult . failedValidation ( `Unable to fit supplied transition name ${ newTransitionName } : invalid value` )
93
94
}
94
95
95
96
let anchorModel : semantic . IdentifiedTransition | undefined
@@ -101,7 +102,7 @@ export class TaskListLangiumModelServerFacade extends AbstractLangiumModelServer
101
102
}
102
103
const textEdit = this . computeTransitionCreation ( newTransition , anchorModel )
103
104
104
- return this . applyTextEdit ( lmsDocument , textEdit , 'Created new transition: ' + newTransition . name )
105
+ return this . applyTextEdit ( lmsDocument , textEdit , 'Created new transition: ' + newTransitionName )
105
106
}
106
107
107
108
public updateTask ( rootModelId : string , modelId : string , taskModification : Modification < Task > ) : MaybePromise < ModificationResult > | undefined {
@@ -170,18 +171,19 @@ export class TaskListLangiumModelServerFacade extends AbstractLangiumModelServer
170
171
}
171
172
172
173
const newTransition = semantic . Transition . createNew ( newSourceTask ?? transition . sourceTask , newTargetTask ?? transition . targetTask )
173
- if ( ! transition . identity . isNewNameFit ( newTransition . name ) ) {
174
- return ModificationResult . failedValidation ( `Unable to fit supplied transition name ${ newTransition . name } : invalid value` )
174
+ const newTransitionName = identity . TransitionDerivativeName . ofNew ( newTransition )
175
+ if ( ! transition . identity . isNewNameFit ( newTransitionName ) ) {
176
+ return ModificationResult . failedValidation ( `Unable to fit supplied transition name ${ newTransitionName } : invalid value` )
175
177
}
176
178
177
179
const sourceEdit = this . computeTransitionUpdate ( lmsDocument , transition , newTransition )
178
180
179
181
if ( sourceEdit . size > 0 ) {
180
- const rollback = transition . identity . updateName ( newTransition . name )
182
+ const rollback = transition . identity . updateName ( newTransitionName )
181
183
if ( ! rollback ) {
182
- return ModificationResult . failedValidation ( `Unable to rename transition to '${ newTransition . name } '` )
184
+ return ModificationResult . failedValidation ( `Unable to rename transition to '${ newTransitionName } '` )
183
185
}
184
- return this . applySourceEdit ( sourceEdit , 'Updated transition: ' + transition . name + 'to ' + newTransition . name , rollback )
186
+ return this . applySourceEdit ( sourceEdit , 'Updated transition: ' + transition . identity . name + 'to ' + newTransitionName , rollback )
185
187
} else {
186
188
return ModificationResult . unmodified ( )
187
189
}
@@ -331,7 +333,7 @@ export class TaskListLangiumModelServerFacade extends AbstractLangiumModelServer
331
333
332
334
private computeTransitionUpdate ( lmsDocument : LmsDocument , transition : semantic . IdentifiedTransition , newTransition : semantic . NewTransition ) : SourceEdit {
333
335
if ( ! transition . $cstNode ) {
334
- throw new Error ( 'Cannot locate model ' + transition . name + '(' + transition . id + ') in text' )
336
+ throw new Error ( 'Cannot locate model ' + transition . identity . name + '(' + transition . id + ') in text' )
335
337
}
336
338
const sourceEdit = new SourceEdit ( )
337
339
if ( newTransition . sourceTask !== transition . sourceTask ) {
@@ -392,10 +394,10 @@ export class TaskListLangiumModelServerFacade extends AbstractLangiumModelServer
392
394
// TODO: Extract to separate component (that will be responsible for TextEdit computation)
393
395
private computeTransitionDeletion ( lmsDocument : LmsDocument , transition : semantic . IdentifiedTransition ) : [ SourceEdit , string ] {
394
396
395
- console . debug ( 'Computing Deletion edit for Transition with name' , transition . name )
397
+ console . debug ( 'Computing Deletion edit for Transition with name' , transition . identity . name )
396
398
const task = transition . sourceTask
397
399
if ( ! transition . $cstNode || ! task . $cstNode ) {
398
- throw new Error ( 'Cannot locate model ' + transition . name + '(' + transition . id + ') in text' )
400
+ throw new Error ( 'Cannot locate model ' + transition . identity . name + '(' + transition . id + ') in text' )
399
401
}
400
402
401
403
let start : Position
@@ -417,7 +419,7 @@ export class TaskListLangiumModelServerFacade extends AbstractLangiumModelServer
417
419
}
418
420
const sourceEdit = SourceEdit . ofSingleEdit ( lmsDocument . uri , TextEdit . del ( { start, end } ) )
419
421
420
- return [ sourceEdit , 'Deleted transition ' + transition . name ]
422
+ return [ sourceEdit , 'Deleted transition ' + transition . identity . name ]
421
423
}
422
424
423
425
private applyTextEdit ( lmsDocument : LmsDocument , textEdit : TextEdit , label : string , rollback ?: id . StateRollback ) : Promise < ModificationResult > {
0 commit comments