File tree 3 files changed +34
-1
lines changed
e2e/suite/testcases/completion
3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -141,7 +141,8 @@ export class ReferenceCompletionProcessor implements ScopeProcessor {
141
141
data : additionalData ,
142
142
} )
143
143
} else if ( node instanceof Contract ) {
144
- const suffix = this . ctx . isInitOfName ? "()" : ""
144
+ const parameters = node . initFunction ( ) ?. parametersPresentation ( ) ?? "()"
145
+ const suffix = this . ctx . isInitOfName ? parameters : ""
145
146
const initFunction = node . initFunction ( )
146
147
const needParens = this . ctx . isInitOfName && ! this . ctx . beforeParen
147
148
const hasParameters = initFunction !== null && initFunction . parameters ( ) . length > 0
Original file line number Diff line number Diff line change @@ -54,3 +54,29 @@ fun test() {
54
54
------------------------------------------------------------------------
55
55
3 Bar()
56
56
3 Foo()
57
+
58
+ ========================================================================
59
+ initOf contract name completion with parens and init function
60
+ ========================================================================
61
+ contract Foo {
62
+ init(age: Int, value: String) {}
63
+ }
64
+
65
+ contract Bar {
66
+ init(age: Int) {}
67
+ }
68
+
69
+ contract Baz {
70
+ init() {}
71
+ }
72
+
73
+ trait Some {}
74
+ trait Some2 {}
75
+
76
+ fun test() {
77
+ initOf <caret>()
78
+ }
79
+ ------------------------------------------------------------------------
80
+ 3 Bar(age: Int)
81
+ 3 Baz()
82
+ 3 Foo(age: Int, value: String)
Original file line number Diff line number Diff line change @@ -162,6 +162,12 @@ export class InitFunction extends Node {
162
162
return `init${ parametersNode . text } `
163
163
}
164
164
165
+ public parametersPresentation ( ) : string {
166
+ const parametersNode = this . node . childForFieldName ( "parameters" )
167
+ if ( ! parametersNode ) return "()"
168
+ return parametersNode . text
169
+ }
170
+
165
171
public endParen ( ) : SyntaxNode | null {
166
172
const parametersNode = this . node . childForFieldName ( "parameters" )
167
173
if ( ! parametersNode ) return null
You can’t perform that action at this time.
0 commit comments