|
1 | 1 | import * as vscode from "vscode"; |
2 | 2 | import { Kind, parse } from "graphql"; |
3 | | -import { OperationLocation } from "./types"; |
4 | 3 | import { Disposable } from "vscode"; |
5 | 4 |
|
6 | 5 | import { Signal } from "@preact/signals-core"; |
7 | 6 | import { dataConnectConfigs, firebaseRC } from "./config"; |
8 | 7 | import { EmulatorsController } from "../core/emulators"; |
9 | | -import { GenerateOperationInput } from "./execution/execution"; |
| 8 | +import { ExecutionInput, GenerateOperationInput } from "./execution/execution"; |
10 | 9 | import { findCommentsBlocks } from "../utils/find_comments"; |
11 | 10 |
|
12 | 11 | export enum InstanceType { |
@@ -91,31 +90,40 @@ export class OperationCodeLensProvider extends ComputedCodeLensProvider { |
91 | 90 | const line = x.loc.startToken.line - 1; |
92 | 91 | const range = new vscode.Range(line, 0, line, 0); |
93 | 92 | const position = new vscode.Position(line, 0); |
94 | | - const operationLocation: OperationLocation = { |
95 | | - document: documentText, |
96 | | - documentPath: document.fileName, |
97 | | - position: position, |
98 | | - }; |
99 | | - const service = fdcConfigs.findEnclosingServiceForPath( |
100 | | - document.fileName, |
101 | | - ); |
| 93 | + const service = fdcConfigs.findEnclosingServiceForPath(document.fileName); |
102 | 94 | if (service) { |
103 | | - codeLenses.push( |
104 | | - new vscode.CodeLens(range, { |
105 | | - title: `$(play) Run (local)`, |
106 | | - command: "firebase.dataConnect.executeOperation", |
107 | | - tooltip: "Execute the operation (⌘+enter or Ctrl+Enter)", |
108 | | - arguments: [x, operationLocation, InstanceType.LOCAL], |
109 | | - }), |
110 | | - ); |
| 95 | + { |
| 96 | + const arg: ExecutionInput = { |
| 97 | + operationAst: x, |
| 98 | + document: documentText, |
| 99 | + documentPath: document.fileName, |
| 100 | + position: position, |
| 101 | + instance: InstanceType.LOCAL, |
| 102 | + }; |
| 103 | + codeLenses.push( |
| 104 | + new vscode.CodeLens(range, { |
| 105 | + title: `$(play) Run (local)`, |
| 106 | + command: "firebase.dataConnect.executeOperation", |
| 107 | + tooltip: "Execute the operation (⌘+enter or Ctrl+Enter)", |
| 108 | + arguments: [arg], |
| 109 | + }), |
| 110 | + ); |
| 111 | + } |
111 | 112 |
|
112 | 113 | if (projectId) { |
| 114 | + const arg: ExecutionInput = { |
| 115 | + operationAst: x, |
| 116 | + document: documentText, |
| 117 | + documentPath: document.fileName, |
| 118 | + position: position, |
| 119 | + instance: InstanceType.PRODUCTION, |
| 120 | + }; |
113 | 121 | codeLenses.push( |
114 | 122 | new vscode.CodeLens(range, { |
115 | 123 | title: `$(play) Run (Production – Project: ${projectId})`, |
116 | 124 | command: "firebase.dataConnect.executeOperation", |
117 | 125 | tooltip: "Execute the operation (⌘+enter or Ctrl+Enter)", |
118 | | - arguments: [x, operationLocation, InstanceType.PRODUCTION], |
| 126 | + arguments: [arg], |
119 | 127 | }), |
120 | 128 | ); |
121 | 129 | } |
|
0 commit comments