File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 - z A - Z 0 - 9 ] + ) \s + ( p k ) [ ^ a - z A - Z 0 - 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
Original file line number Diff line number Diff line change 11pragma cashscript ^0.6.0;
22
33contract 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));
You can’t perform that action at this time.
0 commit comments