Skip to content

Commit aab1a11

Browse files
contract + functions
1 parent c44cd96 commit aab1a11

4 files changed

Lines changed: 42 additions & 3 deletions

File tree

client/src/CashscriptHoverProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class CashscriptHoverProvider implements vscode.HoverProvider{
3838

3939
getMiscellaneousHovers(document:vscode.TextDocument, position:vscode.Position):vscode.MarkdownString[]{
4040

41-
const reg = /(contract|function) (\w+)/;
41+
const reg = /(contract|function)\s+(\w+)\s*\(.*\)/;
4242
let range = document.getWordRangeAtPosition(position, reg);
4343
let word = document.getText(range);
4444
if(word.includes("\n")) return null;

client/testFixture/p.cash

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
pragma cashscript ^0.5.6;
1+
pragma cashscript ^0.6.0;
22

33
contract MyContract() {
44

55
function myFunction(int num) {
6-
6+
require(num == 1);
7+
}
8+
9+
function spend(bool b) {
10+
require(b == true);
711
}
812

913
}

client/testFixture/p.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"contractName": "MyContract",
3+
"constructorInputs": [],
4+
"abi": [
5+
{
6+
"name": "myFunction",
7+
"covenant": false,
8+
"inputs": [
9+
{
10+
"name": "num",
11+
"type": "int"
12+
}
13+
]
14+
},
15+
{
16+
"name": "spend",
17+
"covenant": false,
18+
"inputs": [
19+
{
20+
"name": "b",
21+
"type": "bool"
22+
}
23+
]
24+
}
25+
],
26+
"bytecode": "OP_DUP OP_0 OP_NUMEQUAL OP_IF OP_SWAP OP_1 OP_NUMEQUAL OP_NIP OP_ELSE OP_1 OP_NUMEQUALVERIFY OP_1 OP_EQUAL OP_ENDIF",
27+
"source": "pragma cashscript ^0.6.0;\r\n\r\ncontract MyContract() {\r\n \r\n function myFunction(int num) {\r\n require(num == 1);\r\n }\r\n\r\n function spend(bool b) {\r\n require(b == true);\r\n }\r\n\r\n}",
28+
"compiler": {
29+
"name": "cashc",
30+
"version": "0.6.0"
31+
},
32+
"updatedAt": "2021-04-28T15:57:05.356Z"
33+
}

server/src/completionService.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export default class CompletionService {
1111
this.offset = doc?.offsetAt(pos) || 0;
1212
}
1313

14+
15+
1416
getAllCompletions(): CompletionItem[]{
1517
console.log("completion TRIGG")
1618
let completions:CompletionItem[] = [];

0 commit comments

Comments
 (0)