Skip to content

Commit 8539420

Browse files
author
nathanielCherian
committed
dot completions for tx
1 parent cc44e07 commit 8539420

2 files changed

Lines changed: 91 additions & 3 deletions

File tree

src/CashscriptCompletionProvider.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,19 @@ export default class CashscriptCompletionProvider implements vscode.CompletionIt
5353

5454
protected getDotCompletions():CompletionItem[]{
5555

56-
const re = /(\w+).$/ // EX: "tx."
56+
const re = /(\w+)(\[.+\])?.$/ // EX: "tx."
5757
const range:Range = new Range(new vscode.Position(this.pos.line, 0), this.pos)
5858
const text = this.doc.getText(range);
5959
var arr, keyword;
6060
if((arr=text?.match(re))){
6161
keyword = arr[1];
62+
if(arr[2]) keyword+="_indexed"; // ex. inputs[0].
6263
console.log("keyword: ", keyword);
6364

65+
// return [{
66+
// label:keyword,
67+
// kind:CompletionItemKind.Field
68+
// }]
6469
return DOT_COMPLETIONS[keyword];
6570
}
6671

src/LanguageDesc.ts

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ let TYPECASTS:Data = {
110110
let LANGUAGE:Data = {...GLOBAL_FUNCTIONS, ...OUTPUT_INSTANTIATION, ...STATEMENTS};
111111

112112

113-
let DOT_COMPLETIONS:{[key:string]:CompletionItem[]} = {
114-
tx:[
113+
/*
115114
{
116115
label:"time",
117116
kind:CompletionItemKind.Field,
@@ -160,6 +159,90 @@ let DOT_COMPLETIONS:{[key:string]:CompletionItem[]} = {
160159
label:"hashtype",
161160
kind:CompletionItemKind.Field
162161
},
162+
*/
163+
164+
let DOT_COMPLETIONS:{[key:string]:CompletionItem[]} = {
165+
tx:[
166+
{
167+
label:"version",
168+
kind:CompletionItemKind.Field
169+
},
170+
{
171+
label:"locktime",
172+
kind:CompletionItemKind.Field
173+
},
174+
{
175+
label:"inputs",
176+
kind:CompletionItemKind.Field
177+
},
178+
{
179+
label:"outputs",
180+
kind:CompletionItemKind.Field
181+
}
182+
],
183+
184+
inputs: [
185+
{
186+
label:"length",
187+
kind:CompletionItemKind.Field
188+
}
189+
],
190+
191+
inputs_indexed: [
192+
{
193+
label:"value",
194+
kind:CompletionItemKind.Field
195+
},
196+
{
197+
label:"lockingBytecode",
198+
kind:CompletionItemKind.Field
199+
},
200+
{
201+
label:"outpointTransactionHash",
202+
kind:CompletionItemKind.Field
203+
},
204+
{
205+
label:"outpointIndex",
206+
kind:CompletionItemKind.Field
207+
},
208+
{
209+
label:"unlockingBytecode",
210+
kind:CompletionItemKind.Field
211+
},
212+
{
213+
label:"sequenceNumber",
214+
kind:CompletionItemKind.Field
215+
},
216+
],
217+
218+
outputs: [
219+
{
220+
label:"length",
221+
kind:CompletionItemKind.Field
222+
},
223+
224+
],
225+
226+
outputs_indexed: [
227+
{
228+
label:"value",
229+
kind:CompletionItemKind.Field
230+
},
231+
{
232+
label:"lockingBytecode",
233+
kind:CompletionItemKind.Field
234+
},
235+
],
236+
237+
this:[
238+
{
239+
label: "activeInputIndex",
240+
kind:CompletionItemKind.Field
241+
},
242+
{
243+
label: "activeBytecode",
244+
kind:CompletionItemKind.Field
245+
},
163246
]
164247
}
165248

0 commit comments

Comments
 (0)