Skip to content

Commit

Permalink
tsp, use operation.sourceOperation (#2248)
Browse files Browse the repository at this point in the history
  • Loading branch information
weidongxu-microsoft authored Jul 19, 2023
1 parent 5dc8a81 commit 4db1684
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions typespec-extension/src/operation-utils.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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 (
Expand All @@ -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) {
Expand Down

0 comments on commit 4db1684

Please sign in to comment.