qsharp-lang 1.0.34-dev → 1.1.0-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,202 +1,50 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
- import * as wasm from "../../lib/web/qsc_wasm.js";
4
3
  import { log } from "../log.js";
5
- import { mapDiagnostics, mapUtf16UnitsToUtf8Units, mapUtf8UnitsToUtf16Units, } from "../vsdiagnostic.js";
6
4
  export const qsharpLibraryUriScheme = "qsharp-library-source";
7
5
  export class QSharpLanguageService {
8
6
  constructor(wasm, readFile = () => Promise.resolve(null), listDir = () => Promise.resolve([]), getManifest = () => Promise.resolve(null)) {
9
7
  this.eventHandler = new EventTarget();
10
- // We need to keep a copy of the code for mapping diagnostics to utf16 offsets
11
- this.code = {};
12
8
  log.info("Constructing a QSharpLanguageService instance");
13
9
  this.languageService = new wasm.LanguageService();
14
10
  this.backgroundWork = this.languageService.start_background_work(this.onDiagnostics.bind(this), readFile, listDir, getManifest);
15
11
  this.readFile = readFile;
16
12
  }
17
- async loadFile(uri) {
18
- const result = this.code[uri];
19
- if (result === undefined || result === null) {
20
- return await this.readFile(uri);
21
- }
22
- if (result === null || result === undefined) {
23
- log.error("File", uri, "wasn't in document map when we expected it to be");
24
- return null;
25
- }
26
- return result;
27
- }
28
13
  async updateConfiguration(config) {
29
14
  this.languageService.update_configuration(config);
30
15
  }
31
16
  async updateDocument(documentUri, version, code) {
32
- this.code[documentUri] = code;
33
17
  this.languageService.update_document(documentUri, version, code);
34
18
  }
35
19
  async updateNotebookDocument(notebookUri, version, metadata, cells) {
36
- // Note: If a cell was deleted, its uri & contents will remain in the map.
37
- // This is harmless and it keeps the code simpler to just leave it this way
38
- // instead of trying to maintain a perfect map.
39
- for (const cell of cells) {
40
- this.code[cell.uri] = cell.code;
41
- }
42
20
  this.languageService.update_notebook_document(notebookUri, metadata, cells);
43
21
  }
44
22
  async closeDocument(documentUri) {
45
- delete this.code[documentUri];
46
23
  this.languageService.close_document(documentUri);
47
24
  }
48
25
  async closeNotebookDocument(documentUri) {
49
26
  this.languageService.close_notebook_document(documentUri);
50
27
  }
51
- async getCompletions(documentUri, offset) {
52
- const code = await this.loadFile(documentUri);
53
- if (code === null) {
54
- log.error(`getCompletions: expected ${documentUri} to be in the document map`);
55
- return { items: [] };
56
- }
57
- const convertedOffset = mapUtf16UnitsToUtf8Units([offset], code)[offset];
58
- const result = this.languageService.get_completions(documentUri, convertedOffset);
59
- result.items.forEach((item) => item.additionalTextEdits?.forEach((edit) => {
60
- updateSpanFromUtf8ToUtf16(edit.range, code);
61
- }));
62
- return result;
63
- }
64
- async getHover(documentUri, offset) {
65
- const code = await this.loadFile(documentUri);
66
- if (code === null) {
67
- log.error(`getHover: expected ${documentUri} to be in the document map`);
68
- return undefined;
69
- }
70
- const convertedOffset = mapUtf16UnitsToUtf8Units([offset], code)[offset];
71
- const result = this.languageService.get_hover(documentUri, convertedOffset);
72
- if (result) {
73
- updateSpanFromUtf8ToUtf16(result.span, code);
74
- }
75
- return result;
28
+ async getCompletions(documentUri, position) {
29
+ return this.languageService.get_completions(documentUri, position);
76
30
  }
77
- async getDefinition(documentUri, offset) {
78
- const sourceCode = await this.loadFile(documentUri);
79
- if (sourceCode === undefined || sourceCode === null) {
80
- log.error(`getDefinition: expected ${documentUri} to be in the document map`);
81
- return undefined;
82
- }
83
- const convertedOffset = mapUtf16UnitsToUtf8Units([offset], sourceCode)[offset];
84
- const result = this.languageService.get_definition(documentUri, convertedOffset);
85
- if (result) {
86
- let targetCode = (await this.loadFile(result.source)) || null;
87
- if (targetCode === null) {
88
- // Inspect the URL protocol (equivalent to the URI scheme + ":").
89
- // If the scheme is our library scheme, we need to call the wasm to
90
- // provide the library file's contents to do the utf8->utf16 mapping.
91
- const url = new URL(result.source);
92
- if (url.protocol === qsharpLibraryUriScheme + ":") {
93
- targetCode = wasm.get_library_source_content(url.pathname) || null;
94
- if (targetCode === undefined) {
95
- log.error(`getDefinition: expected ${url} to be in the library`);
96
- return undefined;
97
- }
98
- }
99
- }
100
- if (targetCode) {
101
- updateSpanFromUtf8ToUtf16(result.span, targetCode);
102
- }
103
- else {
104
- // https://github.com/microsoft/qsharp/issues/851
105
- log.error(`cannot do utf8->utf16 mapping for ${result.source} since contents are not available`);
106
- }
107
- }
108
- return result;
31
+ async getHover(documentUri, position) {
32
+ return this.languageService.get_hover(documentUri, position);
109
33
  }
110
- async getReferences(documentUri, offset, includeDeclaration) {
111
- const sourceCode = await this.loadFile(documentUri);
112
- if (sourceCode === undefined || sourceCode === null) {
113
- log.error(`getReferences: expected ${documentUri} to be in the document map`);
114
- return [];
115
- }
116
- const convertedOffset = mapUtf16UnitsToUtf8Units([offset], sourceCode)[offset];
117
- const results = this.languageService.get_references(documentUri, convertedOffset, includeDeclaration);
118
- if (results && results.length > 0) {
119
- const references = [];
120
- for (const result of results) {
121
- let resultCode = await this.loadFile(result.source);
122
- // Inspect the URL protocol (equivalent to the URI scheme + ":").
123
- // If the scheme is our library scheme, we need to call the wasm to
124
- // provide the library file's contents to do the utf8->utf16 mapping.
125
- const url = new URL(result.source);
126
- if (url.protocol === qsharpLibraryUriScheme + ":") {
127
- resultCode = wasm.get_library_source_content(url.pathname) || null;
128
- if (resultCode === undefined) {
129
- log.error(`getReferences: expected ${url} to be in the library`);
130
- }
131
- }
132
- if (resultCode) {
133
- updateSpanFromUtf8ToUtf16(result.span, resultCode);
134
- references.push(result);
135
- }
136
- else {
137
- // https://github.com/microsoft/qsharp/issues/851
138
- log.error(`cannot do utf8->utf16 mapping for ${result.source} since contents are not available`);
139
- }
140
- }
141
- return references;
142
- }
143
- else {
144
- return [];
145
- }
34
+ async getDefinition(documentUri, position) {
35
+ return this.languageService.get_definition(documentUri, position);
146
36
  }
147
- async getSignatureHelp(documentUri, offset) {
148
- const code = await this.loadFile(documentUri);
149
- if (code === null) {
150
- log.error(`expected ${documentUri} to be in the document map`);
151
- return undefined;
152
- }
153
- const convertedOffset = mapUtf16UnitsToUtf8Units([offset], code)[offset];
154
- const result = this.languageService.get_signature_help(documentUri, convertedOffset);
155
- if (result) {
156
- result.signatures = result.signatures.map((sig) => {
157
- sig.parameters = sig.parameters.map((param) => {
158
- updateSpanFromUtf8ToUtf16(param.label, sig.label);
159
- return param;
160
- });
161
- return sig;
162
- });
163
- }
164
- return result;
37
+ async getReferences(documentUri, position, includeDeclaration) {
38
+ return this.languageService.get_references(documentUri, position, includeDeclaration);
165
39
  }
166
- async getRename(documentUri, offset, newName) {
167
- const code = await this.loadFile(documentUri);
168
- if (code === null) {
169
- log.error(`expected ${documentUri} to be in the document map`);
170
- return undefined;
171
- }
172
- const convertedOffset = mapUtf16UnitsToUtf8Units([offset], code)[offset];
173
- const result = this.languageService.get_rename(documentUri, convertedOffset, newName);
174
- const mappedChanges = [];
175
- for (const [uri, edits] of result.changes) {
176
- const code = await this.loadFile(uri);
177
- if (code) {
178
- const mappedEdits = edits.map((edit) => {
179
- updateSpanFromUtf8ToUtf16(edit.range, code);
180
- return edit;
181
- });
182
- mappedChanges.push([uri, mappedEdits]);
183
- }
184
- }
185
- result.changes = mappedChanges;
186
- return result;
187
- }
188
- async prepareRename(documentUri, offset) {
189
- const code = await this.loadFile(documentUri);
190
- if (code === null) {
191
- log.error(`expected ${documentUri} to be in the document map`);
192
- return undefined;
193
- }
194
- const convertedOffset = mapUtf16UnitsToUtf8Units([offset], code)[offset];
195
- const result = this.languageService.prepare_rename(documentUri, convertedOffset);
196
- if (result) {
197
- updateSpanFromUtf8ToUtf16(result.range, code);
198
- }
199
- return result;
40
+ async getSignatureHelp(documentUri, position) {
41
+ return this.languageService.get_signature_help(documentUri, position);
42
+ }
43
+ async getRename(documentUri, position, newName) {
44
+ return this.languageService.get_rename(documentUri, position, newName);
45
+ }
46
+ async prepareRename(documentUri, position) {
47
+ return this.languageService.prepare_rename(documentUri, position);
200
48
  }
201
49
  async dispose() {
202
50
  this.languageService.stop_background_work();
@@ -211,26 +59,11 @@ export class QSharpLanguageService {
211
59
  }
212
60
  async onDiagnostics(uri, version, diagnostics) {
213
61
  try {
214
- const code = await this.loadFile(uri);
215
- const empty = diagnostics.length === 0;
216
- if (code === null && !empty) {
217
- // We need the contents of the document to convert error offsets to utf16.
218
- // But the contents aren't available after a document is closed.
219
- // It is possible to get diagnostics events for a document after it's been closed,
220
- // since document events are handled asynchronously by the language service.
221
- // We just drop those diagnostics, assuming that eventually we will receive further
222
- // events that will bring the diagnostics up to date.
223
- // However, if we receive an *empty* array of diagnostics for a document, we don't want
224
- // to drop that update. It's necessary for the diagnostics to get cleared for a document
225
- // that has been closed.
226
- log.warn(`onDiagnostics: received diagnostics for ${uri} which is not in the document map`);
227
- return;
228
- }
229
62
  const event = new Event("diagnostics");
230
63
  event.detail = {
231
64
  uri,
232
65
  version: version ?? 0,
233
- diagnostics: empty ? [] : mapDiagnostics(diagnostics, code),
66
+ diagnostics,
234
67
  };
235
68
  this.eventHandler.dispatchEvent(event);
236
69
  }
@@ -239,8 +72,3 @@ export class QSharpLanguageService {
239
72
  }
240
73
  }
241
74
  }
242
- function updateSpanFromUtf8ToUtf16(span, code) {
243
- const mappedSpan = mapUtf8UnitsToUtf16Units([span.start, span.end], code);
244
- span.start = mappedSpan[span.start];
245
- span.end = mappedSpan[span.end];
246
- }
package/dist/main.d.ts CHANGED
@@ -15,3 +15,4 @@ export declare function getLanguageService(readFile?: (uri: string) => Promise<s
15
15
  manifestDirectory: string;
16
16
  } | null>): ILanguageService;
17
17
  export declare function getLanguageServiceWorker(): ILanguageServiceWorker;
18
+ export * as utils from "./utils.js";
package/dist/main.js CHANGED
@@ -89,3 +89,4 @@ export function getLanguageServiceWorker() {
89
89
  worker.addListener("message", proxy.onMsgFromWorker);
90
90
  return proxy;
91
91
  }
92
+ export * as utils from "./utils.js";
@@ -1,6 +1,12 @@
1
- declare const _default: {
1
+ declare const _default: ({
2
2
  title: string;
3
3
  shots: number;
4
4
  code: string;
5
- }[];
5
+ omitFromTests?: undefined;
6
+ } | {
7
+ title: string;
8
+ shots: number;
9
+ code: string;
10
+ omitFromTests: boolean;
11
+ })[];
6
12
  export default _default;
@@ -78,5 +78,23 @@ export default [
78
78
  "title": "Shor",
79
79
  "shots": 1,
80
80
  "code": "/// # Sample\n/// Shor's algorithm\n///\n/// # Description\n/// Shor's algorithm is a quantum algorithm for finding the prime factors of an\n/// integer.\n///\n/// This Q# program implements Shor's algorithm.\nnamespace Sample {\n open Microsoft.Quantum.Convert;\n open Microsoft.Quantum.Diagnostics;\n open Microsoft.Quantum.Random;\n open Microsoft.Quantum.Math;\n open Microsoft.Quantum.Unstable.Arithmetic;\n open Microsoft.Quantum.Arrays;\n\n @EntryPoint()\n operation Main() : (Int, Int) {\n let n = 143; // 11*13;\n // You can try these other examples for a lengthier computation.\n // let n = 16837; // = 113*149\n // let n = 22499; // = 149*151\n\n // Use Shor's algorithm to factor a semiprime integer.\n let (a, b) = FactorSemiprimeInteger(n);\n Message($\"Found factorization {n} = {a} * {b} \");\n return (a, b);\n }\n\n /// # Summary\n /// Uses Shor's algorithm to factor an input number.\n ///\n /// # Input\n /// ## number\n /// A semiprime integer to be factored.\n ///\n /// # Output\n /// Pair of numbers p > 1 and q > 1 such that p⋅q = `number`\n operation FactorSemiprimeInteger(number : Int) : (Int, Int) {\n // First check the most trivial case (the provided number is even).\n if number % 2 == 0 {\n Message(\"An even number has been given; 2 is a factor.\");\n return (number / 2, 2);\n }\n // These mutables will keep track of whether we found the factors, and\n // if so, what they are. The default value for the factors is (1,1).\n mutable foundFactors = false;\n mutable factors = (1, 1);\n mutable attempt = 1;\n repeat {\n Message($\"*** Factorizing {number}, attempt {attempt}.\");\n // Try to guess a number co-prime to `number` by getting a random\n // integer in the interval [1, number-1]\n let generator = DrawRandomInt(1, number - 1);\n\n // Check if the random integer is indeed co-prime.\n // If true use Quantum algorithm for Period finding.\n if GreatestCommonDivisorI(generator, number) == 1 {\n Message($\"Estimating period of {generator}.\");\n\n // Call Quantum Period finding algorithm for\n // `generator` mod `number`.\n let period = EstimatePeriod(generator, number);\n\n // Set the flag and factors values if the continued\n // fractions classical algorithm succeeds.\n set (foundFactors, factors) =\n MaybeFactorsFromPeriod(number, generator, period);\n }\n // In this case, we guessed a divisor by accident.\n else {\n // Find divisor.\n let gcd = GreatestCommonDivisorI(number, generator);\n Message($\"We have guessed a divisor {gcd} by accident. \" +\n \"No quantum computation was done.\");\n\n // Set the flag `foundFactors` to true, indicating that we\n // succeeded in finding factors.\n set foundFactors = true;\n set factors = (gcd, number / gcd);\n }\n set attempt = attempt+1;\n if (attempt > 100) {\n fail \"Failed to find factors: too many attempts!\";\n }\n }\n until foundFactors\n fixup {\n Message(\"The estimated period did not yield a valid factor. \" +\n \"Trying again.\");\n }\n\n // Return the factorization\n return factors;\n }\n\n /// # Summary\n /// Tries to find the factors of `modulus` given a `period` and `generator`.\n ///\n /// # Input\n /// ## modulus\n /// The modulus which defines the residue ring Z mod `modulus` in which the\n /// multiplicative order of `generator` is being estimated.\n /// ## generator\n /// The unsigned integer multiplicative order (period) of which is being\n /// estimated. Must be co-prime to `modulus`.\n /// ## period\n /// The estimated period (multiplicative order) of the generator mod\n /// `modulus`.\n ///\n /// # Output\n /// A tuple of a flag indicating whether factors were found successfully,\n /// and a pair of integers representing the factors that were found.\n /// Note that the second output is only meaningful when the first output is\n /// `true`.\n function MaybeFactorsFromPeriod(\n modulus : Int,\n generator : Int,\n period : Int)\n : (Bool, (Int, Int)) {\n\n // Period finding reduces to factoring only if period is even\n if period % 2 == 0 {\n // Compute `generator` ^ `period/2` mod `number`.\n let halfPower = ExpModI(generator, period / 2, modulus);\n\n // If we are unlucky, halfPower is just -1 mod N, which is a trivial\n // case and not useful for factoring.\n if halfPower != modulus - 1 {\n // When the halfPower is not -1 mod N, halfPower-1 or\n // halfPower+1 share non-trivial divisor with `number`. Find it.\n let factor = MaxI(\n GreatestCommonDivisorI(halfPower - 1, modulus),\n GreatestCommonDivisorI(halfPower + 1, modulus)\n );\n\n // Add a flag that we found the factors, and return only if computed\n // non-trivial factors (not like 1:n or n:1)\n if (factor != 1) and (factor != modulus) {\n Message($\"Found factor={factor}\");\n return (true, (factor, modulus / factor));\n }\n }\n // Return a flag indicating we hit a trivial case and didn't get\n // any factors.\n Message($\"Found trivial factors.\");\n return (false, (1, 1));\n } else {\n // When period is odd we have to pick another generator to estimate\n // period of and start over.\n Message($\"Estimated period {period} was odd, trying again.\");\n return (false, (1, 1));\n }\n }\n\n /// # Summary\n /// Find the period of a number from an input frequency.\n ///\n /// # Input\n /// ## modulus\n /// The modulus which defines the residue ring Z mod `modulus` in which the\n /// multiplicative order of `generator` is being estimated.\n /// ## frequencyEstimate\n /// The frequency that we want to convert to a period.\n /// ## bitsPrecision\n /// Number of bits of precision with which we need to estimate s/r to\n /// recover period r using continued fractions algorithm.\n /// ## currentDivisor\n /// The divisor of the generator period found so far.\n ///\n /// # Output\n /// The period as calculated from the estimated frequency via the continued\n /// fractions algorithm.\n function PeriodFromFrequency(\n modulus : Int,\n frequencyEstimate : Int,\n bitsPrecision : Int,\n currentDivisor : Int)\n : Int {\n // Now we use the ContinuedFractionConvergentI function to recover s/r\n // from dyadic fraction k/2^bitsPrecision.\n let (numerator, period) = ContinuedFractionConvergentI(\n (frequencyEstimate, 2 ^ bitsPrecision),\n modulus);\n\n // ContinuedFractionConvergentI does not guarantee the signs of the\n // numerator and denominator. Here we make sure that both are positive\n // using AbsI.\n let (numeratorAbs, periodAbs) = (AbsI(numerator), AbsI(period));\n\n // Compute and return the newly found divisor.\n let period =\n (periodAbs * currentDivisor) /\n GreatestCommonDivisorI(currentDivisor, periodAbs);\n Message($\"Found period={period}\");\n return period;\n }\n\n /// # Summary\n /// Finds a multiplicative order of the generator in the residue ring Z mod\n /// `modulus`.\n ///\n /// # Input\n /// ## generator\n /// The unsigned integer multiplicative order (period) of which is being\n /// estimated. Must be co-prime to `modulus`.\n /// ## modulus\n /// The modulus which defines the residue ring Z mod `modulus` in which the\n /// multiplicative order of `generator` is being estimated.\n ///\n /// # Output\n /// The period (multiplicative order) of the generator mod `modulus`\n operation EstimatePeriod(generator : Int, modulus : Int) : Int {\n // Here we check that the inputs to the EstimatePeriod operation are\n // valid.\n Fact(\n GreatestCommonDivisorI(generator, modulus) == 1,\n \"`generator` and `modulus` must be co-prime\");\n\n // Number of bits in the modulus with respect to which we are estimating\n // the period.\n let bitsize = BitSizeI(modulus);\n\n // The EstimatePeriod operation estimates the period r by finding an\n // approximation k/2^(bits precision) to a fraction s/r, where s is some\n // integer. Note that if s and r have common divisors we will end up\n // recovering a divisor of r and not r itself.\n\n // Number of bits of precision with which we need to estimate s/r to\n // recover period r, using continued fractions algorithm.\n let bitsPrecision = 2 * bitsize + 1;\n\n // Current estimate for the frequency of the form s/r.\n let frequencyEstimate = EstimateFrequency(generator, modulus, bitsize);\n if frequencyEstimate != 0 {\n return PeriodFromFrequency(\n modulus, frequencyEstimate, bitsPrecision, 1);\n }\n else {\n Message(\"The estimated frequency was 0, trying again.\");\n return 1;\n }\n }\n\n /// # Summary\n /// Estimates the frequency of a generator in the residue ring Z mod\n /// `modulus`.\n ///\n /// # Input\n /// ## generator\n /// The unsigned integer multiplicative order (period) of which is being\n /// estimated. Must be co-prime to `modulus`.\n /// ## modulus\n /// The modulus which defines the residue ring Z mod `modulus` in which the\n /// multiplicative order of `generator` is being estimated.\n /// ## bitsize\n /// Number of bits needed to represent the modulus.\n ///\n /// # Output\n /// The numerator k of dyadic fraction k/2^bitsPrecision approximating s/r.\n operation EstimateFrequency(generator : Int,modulus : Int, bitsize : Int)\n : Int {\n mutable frequencyEstimate = 0;\n let bitsPrecision = 2 * bitsize + 1;\n Message($\"Estimating frequency with bitsPrecision={bitsPrecision}.\");\n\n // Allocate qubits for the superposition of eigenstates of the oracle\n // that is used in period finding.\n use eigenstateRegister = Qubit[bitsize];\n\n // Initialize eigenstateRegister to 1, which is a superposition of the\n // eigenstates we are estimating the phases of.\n // We are interpreting the register as encoding an unsigned integer in\n // little-endian format.\n ApplyXorInPlace(1, eigenstateRegister);\n\n // Use phase estimation with a semiclassical Fourier transform to\n // estimate the frequency.\n use c = Qubit();\n for idx in bitsPrecision-1..-1..0 {\n H(c);\n Controlled ApplyOrderFindingOracle(\n [c],\n (generator, modulus, 1 <<< idx, eigenstateRegister));\n R1Frac(frequencyEstimate, bitsPrecision-1-idx, c);\n H(c);\n if M(c) == One {\n X(c); // Reset\n set frequencyEstimate += 1 <<< (bitsPrecision-1-idx);\n }\n }\n\n // Return all the qubits used for oracle's eigenstate back to 0 state\n // using ResetAll.\n ResetAll(eigenstateRegister);\n Message($\"Estimated frequency={frequencyEstimate}\");\n return frequencyEstimate;\n }\n\n /// # Summary\n /// Interprets `target` as encoding unsigned little-endian integer k\n /// and performs transformation |k⟩ ↦ |gᵖ⋅k mod N ⟩ where\n /// p is `power`, g is `generator` and N is `modulus`.\n ///\n /// # Input\n /// ## generator\n /// The unsigned integer multiplicative order (period)\n /// of which is being estimated. Must be co-prime to `modulus`.\n /// ## modulus\n /// The modulus which defines the residue ring Z mod `modulus`\n /// in which the multiplicative order of `generator` is being estimated.\n /// ## power\n /// Power of `generator` by which `target` is multiplied.\n /// ## target\n /// Register interpreted as little-endian which is multiplied by\n /// given power of the generator. The multiplication is performed modulo\n /// `modulus`.\n internal operation ApplyOrderFindingOracle(\n generator : Int, modulus : Int, power : Int, target : Qubit[]\n )\n : Unit\n is Adj + Ctl {\n // The oracle we use for order finding implements |x⟩ ↦ |x⋅a mod N⟩. We\n // also use `ExpModI` to compute a by which x must be multiplied. Also\n // note that we interpret target as unsigned integer in little-endian\n // format.\n ModularMultiplyByConstant(\n modulus,\n ExpModI(generator, power, modulus),\n target);\n }\n\n /// # Summary\n /// Performs modular in-place multiplication by a classical constant.\n ///\n /// # Description\n /// Given the classical constants `c` and `modulus`, and an input quantum\n /// register |𝑦⟩ in little-endian format, this operation computes\n /// `(c*x) % modulus` into |𝑦⟩.\n ///\n /// # Input\n /// ## modulus\n /// Modulus to use for modular multiplication\n /// ## c\n /// Constant by which to multiply |𝑦⟩\n /// ## y\n /// Quantum register of target\n internal operation ModularMultiplyByConstant(modulus : Int, c : Int, y : Qubit[])\n : Unit is Adj + Ctl {\n use qs = Qubit[Length(y)];\n for idx in IndexRange(y) {\n let shiftedC = (c <<< idx) % modulus;\n Controlled ModularAddConstant(\n [y[idx]],\n (modulus, shiftedC, qs));\n }\n for idx in IndexRange(y) {\n SWAP(y[idx], qs[idx]);\n }\n let invC = InverseModI(c, modulus);\n for idx in IndexRange(y) {\n let shiftedC = (invC <<< idx) % modulus;\n Controlled ModularAddConstant(\n [y[idx]],\n (modulus, modulus - shiftedC, qs));\n }\n }\n\n /// # Summary\n /// Performs modular in-place addition of a classical constant into a\n /// quantum register.\n ///\n /// Given the classical constants `c` and `modulus`, and an input quantum\n /// register |𝑦⟩ in little-endian format, this operation computes\n /// `(x+c) % modulus` into |𝑦⟩.\n ///\n /// # Input\n /// ## modulus\n /// Modulus to use for modular addition\n /// ## c\n /// Constant to add to |𝑦⟩\n /// ## y\n /// Quantum register of target\n internal operation ModularAddConstant(modulus : Int, c : Int, y : Qubit[])\n : Unit is Adj + Ctl {\n body (...) {\n Controlled ModularAddConstant([], (modulus, c, y));\n }\n controlled (ctrls, ...) {\n // We apply a custom strategy to control this operation instead of\n // letting the compiler create the controlled variant for us in\n // which the `Controlled` functor would be distributed over each\n // operation in the body.\n //\n // Here we can use some scratch memory to save ensure that at most\n // one control qubit is used for costly operations such as\n // `AddConstant` and `CompareGreaterThenOrEqualConstant`.\n if Length(ctrls) >= 2 {\n use control = Qubit();\n within {\n Controlled X(ctrls, control);\n } apply {\n Controlled ModularAddConstant([control], (modulus, c, y));\n }\n } else {\n use carry = Qubit();\n Controlled IncByI(ctrls, (c, y + [carry]));\n Controlled Adjoint IncByI(ctrls, (modulus, y + [carry]));\n Controlled IncByI([carry], (modulus, y));\n Controlled ApplyIfLessOrEqualL(ctrls, (X, IntAsBigInt(c), y, carry));\n }\n }\n }\n}\n"
81
+ },
82
+ {
83
+ "title": "Dynamics (Resource Estimation)",
84
+ "shots": 1,
85
+ "code": "/// # Sample\n/// Quantum Dynamics\n///\n/// # Description\n/// This example demonstrates quantum dynamics in a style tailored for\n/// resource estimation. The sample is specifically the simulation\n/// of an Ising model Hamiltonian on an N1xN2 2D lattice using a\n/// fourth-order Trotter Suzuki product formula, assuming\n/// a 2D qubit architecture with nearest-neighbor connectivity.\n/// The is an example of a program that is not amenable to simulating\n/// classically, but can be run through resource estimation to determine\n/// what size of quantum system would be needed to solve the problem.\nnamespace QuantumDynamics {\n\n open Microsoft.Quantum.Math;\n open Microsoft.Quantum.Arrays;\n\n\n @EntryPoint()\n operation Main() : Unit {\n // n : Int, m : Int, t: Double, u : Double, tstep : Double\n \n let n = 30;\n let m = 30;\n\n let J = 1.0;\n let g = 1.0;\n\n let totTime = 30.0;\n let dt = 0.9;\n\n IsingModel2DSim(n, m, J, g, totTime, dt);\n }\n\n /// # Summary\n /// The function below creates a sequence containing the rotation angles that will be applied with the two operators used in the expansion of the Trotter-Suzuki formula.\n /// # Input\n /// ## p (Double) : Constant used for fourth-order formulas\n /// \n /// ## dt (Double) : Time-step used to compute rotation angles\n /// \n /// ## J (Double) : coefficient for 2-qubit interactions\n /// \n /// ## g (Double) : coefficient for transverse field\n ///\n /// # Output\n /// ## values (Double[]) : The list of rotation angles to be applies in sequence with the corresponding operators\n ///\n function SetAngleSequence(p : Double, dt : Double, J : Double, g : Double) : Double[] {\n\n let len1 = 3;\n let len2 = 3;\n let valLength = 2*len1+len2+1;\n mutable values = [0.0, size=valLength];\n\n let val1 = J*p*dt;\n let val2 = -g*p*dt;\n let val3 = J*(1.0 - 3.0*p)*dt/2.0;\n let val4 = g*(1.0 - 4.0*p)*dt/2.0;\n\n for i in 0..len1 {\n \n if (i % 2 == 0) {\n set values w/= i <- val1;\n }\n else {\n set values w/= i <- val2;\n }\n\n }\n\n for i in len1+1..len1+len2 {\n if (i % 2 == 0) {\n set values w/= i <- val3;\n }\n else {\n set values w/= i <- val4;\n }\n }\n\n for i in len1+len2+1..valLength-1 {\n if (i % 2 == 0) {\n set values w/= i <- val1;\n }\n else {\n set values w/= i <- val2;\n }\n }\n return values;\n }\n\n /// # Summary\n /// Applies e^-iX(theta) on all qubits in the 2D lattice as part of simulating the transverse field in the Ising model\n /// # Input\n /// ## n (Int) : Lattice size for an n x n lattice\n /// \n /// ## qArr (Qubit[][]) : Array of qubits representing the lattice\n /// \n /// ## theta (Double) : The angle/time-step for which the unitary simulation is done.\n /// \n operation ApplyAllX(n : Int, qArr : Qubit[][], theta : Double) : Unit {\n // This applies `Rx` with an angle of `2.0 * theta` to all qubits in `qs`\n // using partial application\n for row in 0..n-1 {\n ApplyToEach(Rx(2.0 * theta, _), qArr[row]);\n }\n }\n\n /// # Summary\n /// Applies e^-iP(theta) where P = Z o Z as part of the repulsion terms.\n /// # Input\n /// ## n, m (Int, Int) : Lattice sizes for an n x m lattice\n /// \n /// ## qArr (Qubit[]) : Array of qubits representing the lattice\n /// \n /// ## theta (Double) : The angle/time-step for which unitary simulation is done.\n /// \n /// ## dir (Bool) : Direction is true for vertical direction.\n ///\n /// ## grp (Bool) : Group is true for odd starting indices\n ///\n operation ApplyDoubleZ(n : Int, m : Int, qArr : Qubit[][], theta : Double, dir : Bool, grp : Bool) : Unit {\n let start = grp ? 1 | 0; // Choose either odd or even indices based on group number\n let P_op = [PauliZ, PauliZ];\n let c_end = dir ? m-1 | m-2;\n let r_end = dir ? m-2 | m-1;\n\n for row in 0..r_end {\n for col in start..2..c_end { // Iterate through even or odd columns based on `grp`\n\n let row2 = dir ? row+1 | row;\n let col2 = dir ? col | col+1;\n\n Exp(P_op, theta, [qArr[row][col], qArr[row2][col2]]);\n }\n }\n }\n\n /// # Summary\n /// The main function that takes in various parameters and calls the operations needed to simulate fourth order Trotterizatiuon of the Ising Hamiltonian for a given time-step\n /// # Input\n /// ## N1, N2 (Int, Int) : Lattice sizes for an N1 x N2 lattice\n /// \n /// ## J (Double) : coefficient for 2-qubit interactions\n /// \n /// ## g (Double) : coefficient for transverse field\n ///\n /// ## totTime (Double) : The total time-step for which unitary simulation is done.\n ///\n /// ## dt (Double) : The time the simulation is done for each timestep\n ///\n operation IsingModel2DSim(N1 : Int, N2 : Int, J : Double, g : Double, totTime : Double, dt : Double) : Unit {\n \n use qs = Qubit[N1*N2];\n let qubitArray = Chunks(N2, qs); // qubits are re-arranged to be in an N1 x N2 array\n\n let p = 1.0 / (4.0 - 4.0^(1.0 / 3.0));\n let t = Ceiling(totTime / dt);\n\n let seqLen = 10 * t + 1;\n\n let angSeq = SetAngleSequence(p, dt, J, g);\n\n for i in 0..seqLen - 1 {\n let theta = (i==0 or i==seqLen-1) ? J*p*dt/2.0 | angSeq[i%10];\n\n // for even indexes\n if i % 2 == 0 {\n ApplyAllX(N1, qubitArray, theta);\n } else {\n // iterate through all possible combinations for `dir` and `grp`.\n for (dir, grp) in [(true, true), (true, false), (false, true), (false, false)] {\n ApplyDoubleZ(N1, N2, qubitArray, theta, dir, grp);\n }\n }\n }\n }\n\n}\n",
86
+ "omitFromTests": true
87
+ },
88
+ {
89
+ "title": "Precalculated (Resource Estimation)",
90
+ "shots": 1,
91
+ "code": "/// # Sample\n/// Using pre-calculated logical counts for resource estimation\n///\n/// # Description\n/// This sample demonstrates how to use the `AccountForEstimates` function to\n/// estimate the resources required to run a factoring program from pre-calculated\n/// logical counts. The logical counts used in this sample are the ones obtained\n/// for a 2048-bit integer factoring application based on the implementation\n/// described in [[Quantum 5, 433 (2021)](https://quantum-journal.org/papers/q-2021-04-15-433/)].\n/// Our implementation incorporates all techniques described in the paper, except for\n/// carry runways.\nnamespace PrecalculatedEstimates {\n open Microsoft.Quantum.ResourceEstimation;\n\n @EntryPoint()\n operation FactoringFromLogicalCounts() : Unit {\n use qubits = Qubit[12581];\n\n AccountForEstimates(\n [TCount(12), RotationCount(12), RotationDepth(12),\n CczCount(3731607428), MeasurementCount(1078154040)],\n PSSPCLayout(), qubits);\n }\n\n}\n",
92
+ "omitFromTests": true
93
+ },
94
+ {
95
+ "title": "Shor (Resource Estimation)",
96
+ "shots": 1,
97
+ "code": "/// # Sample\n/// Estimating Frequency for Shor's algorithm\n///\n/// # Description\n/// In this sample we concentrate on costing the `EstimateFrequency`\n/// operation, which is the core quantum operation in Shor's algorithm, and\n/// we omit the classical pre- and post-processing. This makes it ideal for\n/// use with the Azure Quantum Resource Estimator.\nnamespace Shors {\n open Microsoft.Quantum.Arrays;\n open Microsoft.Quantum.Canon;\n open Microsoft.Quantum.Convert;\n open Microsoft.Quantum.Diagnostics;\n open Microsoft.Quantum.Intrinsic;\n open Microsoft.Quantum.Math;\n open Microsoft.Quantum.Measurement;\n open Microsoft.Quantum.Unstable.Arithmetic;\n open Microsoft.Quantum.ResourceEstimation;\n\n @EntryPoint()\n operation RunProgram() : Unit {\n let bitsize = 31;\n\n // When chooseing parameters for `EstimateFrequency`, make sure that\n // generator and modules are not co-prime\n let _ = EstimateFrequency(11, 2^bitsize - 1, bitsize);\n }\n\n /// # Summary\n /// Estimates the frequency of a generator\n /// in the residue ring Z mod `modulus`.\n ///\n /// # Input\n /// ## generator\n /// The unsigned integer multiplicative order (period)\n /// of which is being estimated. Must be co-prime to `modulus`.\n /// ## modulus\n /// The modulus which defines the residue ring Z mod `modulus`\n /// in which the multiplicative order of `generator` is being estimated.\n /// ## bitsize\n /// Number of bits needed to represent the modulus.\n ///\n /// # Output\n /// The numerator k of dyadic fraction k/2^bitsPrecision\n /// approximating s/r.\n operation EstimateFrequency(\n generator : Int,\n modulus : Int,\n bitsize : Int\n )\n : Int {\n mutable frequencyEstimate = 0;\n let bitsPrecision = 2 * bitsize + 1;\n\n // Allocate qubits for the superposition of eigenstates of\n // the oracle that is used in period finding.\n use eigenstateRegister = Qubit[bitsize];\n\n // Initialize eigenstateRegister to 1, which is a superposition of\n // the eigenstates we are estimating the phases of.\n // We first interpret the register as encoding an unsigned integer\n // in little endian encoding.\n ApplyXorInPlace(1, eigenstateRegister);\n let oracle = ApplyOrderFindingOracle(generator, modulus, _, _);\n\n // Use phase estimation with a semiclassical Fourier transform to\n // estimate the frequency.\n use c = Qubit();\n for idx in bitsPrecision - 1..-1..0 {\n within {\n H(c);\n } apply {\n // `BeginEstimateCaching` and `EndEstimateCaching` are the operations\n // exposed by Azure Quantum Resource Estimator. These will instruct\n // resource counting such that the if-block will be executed\n // only once, its resources will be cached, and appended in\n // every other iteration.\n if BeginEstimateCaching(\"ControlledOracle\", SingleVariant()) {\n Controlled oracle([c], (1 <<< idx, eigenstateRegister));\n EndEstimateCaching();\n }\n R1Frac(frequencyEstimate, bitsPrecision - 1 - idx, c);\n }\n if MResetZ(c) == One {\n set frequencyEstimate += 1 <<< (bitsPrecision - 1 - idx);\n }\n }\n\n // Return all the qubits used for oracle's eigenstate back to 0 state\n // using Microsoft.Quantum.Intrinsic.ResetAll.\n ResetAll(eigenstateRegister);\n\n return frequencyEstimate;\n }\n\n /// # Summary\n /// Interprets `target` as encoding unsigned little-endian integer k\n /// and performs transformation |k⟩ ↦ |gᵖ⋅k mod N ⟩ where\n /// p is `power`, g is `generator` and N is `modulus`.\n ///\n /// # Input\n /// ## generator\n /// The unsigned integer multiplicative order (period)\n /// of which is being estimated. Must be co-prime to `modulus`.\n /// ## modulus\n /// The modulus which defines the residue ring Z mod `modulus`\n /// in which the multiplicative order of `generator` is being estimated.\n /// ## power\n /// Power of `generator` by which `target` is multiplied.\n /// ## target\n /// Register interpreted as little-endian which is multiplied by\n /// given power of the generator. The multiplication is performed modulo\n /// `modulus`.\n internal operation ApplyOrderFindingOracle(\n generator : Int, modulus : Int, power : Int, target : Qubit[]\n )\n : Unit\n is Adj + Ctl {\n // The oracle we use for order finding implements |x⟩ ↦ |x⋅a mod N⟩. We\n // also use `ExpModI` to compute a by which x must be multiplied. Also\n // note that we interpret target as unsigned integer in little-endian\n // format.\n ModularMultiplyByConstant(\n modulus,\n ExpModI(generator, power, modulus),\n target);\n }\n\n /// # Summary\n /// Performs modular in-place multiplication by a classical constant.\n ///\n /// # Description\n /// Given the classical constants `c` and `modulus`, and an input quantum\n /// register |𝑦⟩ in little-endian format, this operation computes\n /// `(c*x) % modulus` into |𝑦⟩.\n ///\n /// # Input\n /// ## modulus\n /// Modulus to use for modular multiplication\n /// ## c\n /// Constant by which to multiply |𝑦⟩\n /// ## y\n /// Quantum register of target\n internal operation ModularMultiplyByConstant(modulus : Int, c : Int, y : Qubit[])\n : Unit is Adj + Ctl {\n use qs = Qubit[Length(y)];\n for idx in IndexRange(y) {\n let shiftedC = (c <<< idx) % modulus;\n Controlled ModularAddConstant(\n [y[idx]],\n (modulus, shiftedC, qs));\n }\n for idx in IndexRange(y) {\n SWAP(y[idx], qs[idx]);\n }\n let invC = InverseModI(c, modulus);\n for idx in IndexRange(y) {\n let shiftedC = (invC <<< idx) % modulus;\n Controlled ModularAddConstant(\n [y[idx]],\n (modulus, modulus - shiftedC, qs));\n }\n }\n\n /// # Summary\n /// Performs modular in-place addition of a classical constant into a\n /// quantum register.\n ///\n /// Given the classical constants `c` and `modulus`, and an input quantum\n /// register |𝑦⟩ in little-endian format, this operation computes\n /// `(x+c) % modulus` into |𝑦⟩.\n ///\n /// # Input\n /// ## modulus\n /// Modulus to use for modular addition\n /// ## c\n /// Constant to add to |𝑦⟩\n /// ## y\n /// Quantum register of target\n internal operation ModularAddConstant(modulus : Int, c : Int, y : Qubit[])\n : Unit is Adj + Ctl {\n body (...) {\n Controlled ModularAddConstant([], (modulus, c, y));\n }\n controlled (ctrls, ...) {\n // We apply a custom strategy to control this operation instead of\n // letting the compiler create the controlled variant for us in\n // which the `Controlled` functor would be distributed over each\n // operation in the body.\n //\n // Here we can use some scratch memory to save ensure that at most\n // one control qubit is used for costly operations such as\n // `AddConstant` and `CompareGreaterThenOrEqualConstant`.\n if Length(ctrls) >= 2 {\n use control = Qubit();\n within {\n Controlled X(ctrls, control);\n } apply {\n Controlled ModularAddConstant([control], (modulus, c, y));\n }\n } else {\n use carry = Qubit();\n Controlled IncByI(ctrls, (c, y + [carry]));\n Controlled Adjoint IncByI(ctrls, (modulus, y + [carry]));\n Controlled IncByI([carry], (modulus, y));\n Controlled ApplyIfLessOrEqualL(ctrls, (X, IntAsBigInt(c), y, carry));\n }\n }\n }\n}\n",
98
+ "omitFromTests": true
81
99
  }
82
100
  ];
@@ -0,0 +1,24 @@
1
+ export type Tick = {
2
+ value: number;
3
+ label: string;
4
+ };
5
+ export declare function CreateIntegerTicks(min: number, max: number): Tick[];
6
+ export declare function CreateTimeTicks(min: number, max: number): Tick[];
7
+ type SeriesOfPoints = Array<{
8
+ items: Array<{
9
+ x: number;
10
+ y: number;
11
+ }>;
12
+ }>;
13
+ export declare function getMinMaxXYForItems(data: SeriesOfPoints): [number, number, number, number];
14
+ export declare function getRanges(data: SeriesOfPoints, rangeCoefficient: number): {
15
+ rangeX: {
16
+ min: number;
17
+ max: number;
18
+ };
19
+ rangeY: {
20
+ min: number;
21
+ max: number;
22
+ };
23
+ };
24
+ export {};
@@ -123,3 +123,26 @@ export function CreateTimeTicks(min, max) {
123
123
  }
124
124
  return result;
125
125
  }
126
+ // Given an array of object, and each of those objects has an 'items' property
127
+ // that is another array of objects with number properties x & y, return a
128
+ // tuple of [minX, maxX, minY, maxY] covering all items given
129
+ export function getMinMaxXYForItems(data) {
130
+ return data.reduce((priorSeriesResult, curr) => curr.items.reduce((priorItemResult, curr) => [
131
+ Math.min(priorItemResult[0], curr.x),
132
+ Math.max(priorItemResult[1], curr.x),
133
+ Math.min(priorItemResult[2], curr.y),
134
+ Math.max(priorItemResult[3], curr.y),
135
+ ], priorSeriesResult), [Number.MAX_VALUE, Number.MIN_VALUE, Number.MAX_VALUE, Number.MIN_VALUE]);
136
+ }
137
+ export function getRanges(data, rangeCoefficient) {
138
+ const [minX, maxX, minY, maxY] = getMinMaxXYForItems(data);
139
+ const rangeX = {
140
+ min: minX / rangeCoefficient,
141
+ max: maxX * rangeCoefficient,
142
+ };
143
+ const rangeY = {
144
+ min: minY / rangeCoefficient,
145
+ max: maxY * rangeCoefficient,
146
+ };
147
+ return { rangeX, rangeY };
148
+ }
@@ -740,38 +740,38 @@ class LanguageService {
740
740
  }
741
741
  /**
742
742
  * @param {string} uri
743
- * @param {number} offset
743
+ * @param {IPosition} position
744
744
  * @returns {ICompletionList}
745
745
  */
746
- get_completions(uri, offset) {
746
+ get_completions(uri, position) {
747
747
  const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
748
748
  const len0 = WASM_VECTOR_LEN;
749
- const ret = wasm.languageservice_get_completions(this.__wbg_ptr, ptr0, len0, offset);
749
+ const ret = wasm.languageservice_get_completions(this.__wbg_ptr, ptr0, len0, addHeapObject(position));
750
750
  return takeObject(ret);
751
751
  }
752
752
  /**
753
753
  * @param {string} uri
754
- * @param {number} offset
754
+ * @param {IPosition} position
755
755
  * @returns {ILocation | undefined}
756
756
  */
757
- get_definition(uri, offset) {
757
+ get_definition(uri, position) {
758
758
  const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
759
759
  const len0 = WASM_VECTOR_LEN;
760
- const ret = wasm.languageservice_get_definition(this.__wbg_ptr, ptr0, len0, offset);
760
+ const ret = wasm.languageservice_get_definition(this.__wbg_ptr, ptr0, len0, addHeapObject(position));
761
761
  return takeObject(ret);
762
762
  }
763
763
  /**
764
764
  * @param {string} uri
765
- * @param {number} offset
765
+ * @param {IPosition} position
766
766
  * @param {boolean} include_declaration
767
767
  * @returns {(ILocation)[]}
768
768
  */
769
- get_references(uri, offset, include_declaration) {
769
+ get_references(uri, position, include_declaration) {
770
770
  try {
771
771
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
772
772
  const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
773
773
  const len0 = WASM_VECTOR_LEN;
774
- wasm.languageservice_get_references(retptr, this.__wbg_ptr, ptr0, len0, offset, include_declaration);
774
+ wasm.languageservice_get_references(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(position), include_declaration);
775
775
  var r0 = getInt32Memory0()[retptr / 4 + 0];
776
776
  var r1 = getInt32Memory0()[retptr / 4 + 1];
777
777
  var v2 = getArrayJsValueFromWasm0(r0, r1).slice();
@@ -783,49 +783,49 @@ class LanguageService {
783
783
  }
784
784
  /**
785
785
  * @param {string} uri
786
- * @param {number} offset
786
+ * @param {IPosition} position
787
787
  * @returns {IHover | undefined}
788
788
  */
789
- get_hover(uri, offset) {
789
+ get_hover(uri, position) {
790
790
  const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
791
791
  const len0 = WASM_VECTOR_LEN;
792
- const ret = wasm.languageservice_get_hover(this.__wbg_ptr, ptr0, len0, offset);
792
+ const ret = wasm.languageservice_get_hover(this.__wbg_ptr, ptr0, len0, addHeapObject(position));
793
793
  return takeObject(ret);
794
794
  }
795
795
  /**
796
796
  * @param {string} uri
797
- * @param {number} offset
797
+ * @param {IPosition} position
798
798
  * @returns {ISignatureHelp | undefined}
799
799
  */
800
- get_signature_help(uri, offset) {
800
+ get_signature_help(uri, position) {
801
801
  const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
802
802
  const len0 = WASM_VECTOR_LEN;
803
- const ret = wasm.languageservice_get_signature_help(this.__wbg_ptr, ptr0, len0, offset);
803
+ const ret = wasm.languageservice_get_signature_help(this.__wbg_ptr, ptr0, len0, addHeapObject(position));
804
804
  return takeObject(ret);
805
805
  }
806
806
  /**
807
807
  * @param {string} uri
808
- * @param {number} offset
808
+ * @param {IPosition} position
809
809
  * @param {string} new_name
810
810
  * @returns {IWorkspaceEdit}
811
811
  */
812
- get_rename(uri, offset, new_name) {
812
+ get_rename(uri, position, new_name) {
813
813
  const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
814
814
  const len0 = WASM_VECTOR_LEN;
815
815
  const ptr1 = passStringToWasm0(new_name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
816
816
  const len1 = WASM_VECTOR_LEN;
817
- const ret = wasm.languageservice_get_rename(this.__wbg_ptr, ptr0, len0, offset, ptr1, len1);
817
+ const ret = wasm.languageservice_get_rename(this.__wbg_ptr, ptr0, len0, addHeapObject(position), ptr1, len1);
818
818
  return takeObject(ret);
819
819
  }
820
820
  /**
821
821
  * @param {string} uri
822
- * @param {number} offset
822
+ * @param {IPosition} position
823
823
  * @returns {ITextEdit | undefined}
824
824
  */
825
- prepare_rename(uri, offset) {
825
+ prepare_rename(uri, position) {
826
826
  const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
827
827
  const len0 = WASM_VECTOR_LEN;
828
- const ret = wasm.languageservice_prepare_rename(this.__wbg_ptr, ptr0, len0, offset);
828
+ const ret = wasm.languageservice_prepare_rename(this.__wbg_ptr, ptr0, len0, addHeapObject(position));
829
829
  return takeObject(ret);
830
830
  }
831
831
  }
@@ -1260,8 +1260,8 @@ module.exports.__wbindgen_memory = function() {
1260
1260
  return addHeapObject(ret);
1261
1261
  };
1262
1262
 
1263
- module.exports.__wbindgen_closure_wrapper593 = function(arg0, arg1, arg2) {
1264
- const ret = makeMutClosure(arg0, arg1, 221, __wbg_adapter_46);
1263
+ module.exports.__wbindgen_closure_wrapper598 = function(arg0, arg1, arg2) {
1264
+ const ret = makeMutClosure(arg0, arg1, 219, __wbg_adapter_46);
1265
1265
  return addHeapObject(ret);
1266
1266
  };
1267
1267