Skip to content

Commit c56ee0e

Browse files
data types
1 parent aab1a11 commit c56ee0e

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

client/src/CashscriptHoverProvider.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ class CashscriptHoverProvider implements vscode.HoverProvider{
1717
const annotation = this.getHoverAnnotation(word);
1818
if(annotation) return new vscode.Hover(annotation, range);
1919

20+
const miscel = this.getMiscellaneousHovers(document, position);
21+
if(miscel) return new vscode.Hover(miscel, range)
2022

2123
// check special words
2224

23-
return new vscode.Hover(this.getMiscellaneousHovers(document, position), range);
25+
const varTypes = this.getVariableTypes(document, word);
26+
return new vscode.Hover(varTypes, range);
2427
}
2528

2629

@@ -47,7 +50,17 @@ class CashscriptHoverProvider implements vscode.HoverProvider{
4750
new vscode.MarkdownString().appendCodeblock(word)
4851
];
4952
}
50-
53+
54+
getVariableTypes(document:vscode.TextDocument, targetWord:string):vscode.MarkdownString[]{
55+
const reg = /([a-zA-Z0-9]+)\s+(pk)[^a-zA-Z0-9]/;
56+
const text = document.getText();
57+
const matches = text.match(new RegExp(`([a-zA-Z0-9]+)\\s+(${targetWord})[^a-zA-Z0-9]`));
58+
if(!matches) return null;
59+
60+
return [
61+
new vscode.MarkdownString().appendCodeblock(`${matches[1]} ${matches[2]}`),
62+
]
63+
}
5164

5265
}
5366

client/testFixture/P2PKH.cash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pragma cashscript ^0.6.0;
22

33
contract P2PKH(bytes20 pkh) {
4-
function spend(pubkey pk, sig s) {
4+
function spend( pubkey pk , sig s) {
55
require(hash160(pk) == pkh);
66
require(checkSig(s, pk));
77
require(checkSig(s, pk));

0 commit comments

Comments
 (0)