@@ -22,8 +22,13 @@ class CashscriptHoverProvider implements vscode.HoverProvider{
2222
2323 // check special words
2424
25+ const dotHovers = this . getTxDotHovers ( document , position ) ;
26+ if ( dotHovers ) return new vscode . Hover ( dotHovers , range )
27+
2528 const varTypes = this . getVariableTypes ( document , word ) ; // fix this
26- return new vscode . Hover ( varTypes , range ) ;
29+ if ( varTypes ) return new vscode . Hover ( varTypes , range ) ;
30+
31+ return null ;
2732 }
2833
2934
@@ -65,6 +70,58 @@ class CashscriptHoverProvider implements vscode.HoverProvider{
6570 ]
6671 }
6772
73+ getTxDotHovers ( document :vscode . TextDocument , position :vscode . Position ) :vscode . MarkdownString [ ] {
74+ const reg = / t x .[ a - z A - Z 0 - 9 ] + / ;
75+ let range = document . getWordRangeAtPosition ( position , reg ) ;
76+ let word = document . getText ( range ) . substring ( 3 ) ;
77+
78+ // /### tx.(\w+)\n+```solidity\n(.+)\n```/
79+ const TX_HOVERS = {
80+ time :{
81+ code :'require(tx.time >= <expression>);'
82+ } ,
83+ age :{
84+ code :'require(tx.age >= <expression>);'
85+ } ,
86+ version :{
87+ code :'bytes4 tx.version'
88+ } ,
89+ hashPrevouts :{
90+ code :'bytes32 tx.hashPrevouts'
91+ } ,
92+ hashSequence :{
93+ code :'bytes32 tx.hashSequence'
94+ } ,
95+ outpoint :{
96+ code :'bytes36 tx.outpoint'
97+ } ,
98+ bytecode :{
99+ code :'bytes tx.bytecode'
100+ } ,
101+ value :{
102+ code :'bytes8 value'
103+ } ,
104+ sequence :{
105+ code :'bytes4 tx.sequence'
106+ } ,
107+ hashOutputs :{
108+ code :'bytes32 tx.hashOutputs'
109+ } ,
110+ locktime :{
111+ code :'bytes4 tx.locktime'
112+ } ,
113+ hashtype :{
114+ code :'bytes4 tx.hashtype'
115+ } ,
116+ }
117+
118+
119+ this . channel . appendLine ( "dot: " + word ) ;
120+ return [
121+ new vscode . MarkdownString ( ) . appendCodeblock ( TX_HOVERS [ word ] . code )
122+ ] ;
123+ }
124+
68125}
69126
70127export default CashscriptHoverProvider ;
0 commit comments