@@ -230,6 +230,19 @@ export class ModelingStore extends DisposableObject {
230230 return this . state . size > 0 ;
231231 }
232232
233+ /**
234+ * Returns the method for the given database item and method signature.
235+ * Returns undefined if no method exists with that signature.
236+ */
237+ public getMethod (
238+ dbItem : DatabaseItem ,
239+ methodSignature : string ,
240+ ) : Method | undefined {
241+ return this . getState ( dbItem ) . methods . find (
242+ ( m ) => m . signature === methodSignature ,
243+ ) ;
244+ }
245+
233246 /**
234247 * Returns the methods for the given database item and method signatures.
235248 * If the `methodSignatures` argument is not provided or is undefined, returns all methods.
@@ -388,18 +401,16 @@ export class ModelingStore extends DisposableObject {
388401 } ) ;
389402 }
390403
391- public setSelectedMethod ( dbItem : DatabaseItem , methodSignature : string ) {
404+ /**
405+ * Sets which method is considered to be selected. This method will be shown in the method modeling panel.
406+ *
407+ * The `Method` and `Usage` objects must have been retrieved from the modeling store, and not from
408+ * a webview. This is because we rely on object referential identity so it must be the same object
409+ * that is held internally by the modeling store.
410+ */
411+ public setSelectedMethod ( dbItem : DatabaseItem , method : Method , usage : Usage ) {
392412 const dbState = this . getState ( dbItem ) ;
393413
394- const method = dbState . methods . find ( ( m ) => m . signature === methodSignature ) ;
395- if ( method === undefined ) {
396- throw new Error (
397- `No method with signature "${ methodSignature } " found in modeling store` ,
398- ) ;
399- }
400-
401- const usage = method . usages [ 0 ] ;
402-
403414 dbState . selectedMethod = method ;
404415 dbState . selectedUsage = usage ;
405416
0 commit comments