From 4db1684235bf52efd78df9ff4b3b5ec6b3f8f55b Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Wed, 19 Jul 2023 13:15:44 +0800 Subject: [PATCH] tsp, use operation.sourceOperation (#2248) --- typespec-extension/src/operation-utils.ts | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/typespec-extension/src/operation-utils.ts b/typespec-extension/src/operation-utils.ts index 0ccc9be609..09a3bf1690 100644 --- a/typespec-extension/src/operation-utils.ts +++ b/typespec-extension/src/operation-utils.ts @@ -1,4 +1,4 @@ -import { ModelProperty, Operation, Program, SyntaxKind, ignoreDiagnostics, resolvePath } from "@typespec/compiler"; +import { ModelProperty, Operation, Program, ignoreDiagnostics, resolvePath } from "@typespec/compiler"; import { HttpOperation, getHeaderFieldName, @@ -145,15 +145,6 @@ export function getServiceVersion(client: CodeModelClient | CodeModel): ServiceV } export function isLroNewPollingStrategy(httpOperation: HttpOperation, lroMetadata: LroMetadata): boolean { - // at present, checks if operation uses template from Azure.Core - const azureCoreLroSvs = [ - "LongRunningResourceCreateOrReplace", - "LongRunningResourceCreateOrUpdate", - "LongRunningResourceDelete", - "LongRunningResourceAction", - "LongRunningRpcOperation", - ]; - const operation = httpOperation.operation; let useNewStrategy = false; if ( @@ -162,12 +153,8 @@ export function isLroNewPollingStrategy(httpOperation: HttpOperation, lroMetadat lroMetadata.pollingInfo.responseModel.name === "OperationStatus" && getNamespace(lroMetadata.pollingInfo.responseModel) === "Azure.Core.Foundations" ) { - if (operation.node.signature.kind === SyntaxKind.OperationSignatureReference) { - if (operation.node.signature.baseOperation.target.kind === SyntaxKind.MemberExpression) { - const sv = operation.node.signature.baseOperation.target.id.sv; - useNewStrategy = azureCoreLroSvs.includes(sv); - } - } + useNewStrategy = + operation.sourceOperation !== undefined && getNamespace(operation.sourceOperation) === "Azure.Core"; } if (!useNewStrategy) {