@@ -90,19 +90,23 @@ protected IScriptCompletionProposal createMethodReferenceProposal(
90
90
CompletionProposal methodProposal ) {
91
91
AbstractScriptCompletionProposal methodReferenceProposal = (AbstractScriptCompletionProposal ) super
92
92
.createMethodReferenceProposal (methodProposal );
93
- if (methodProposal .getExtraInfo () != null ) {
93
+ final Object extraInfo = methodProposal .getExtraInfo ();
94
+ if (extraInfo != null ) {
94
95
methodReferenceProposal .setProposalInfo (new JavaScriptProposalInfo (
95
- methodProposal . getExtraInfo () ));
96
+ extraInfo ));
96
97
}
97
98
StringBuilder sb = null ;
98
- if (methodProposal .getExtraInfo () instanceof Method ) {
99
- Method method = (Method ) methodProposal .getExtraInfo ();
100
- EList <Parameter > parameters = method .getParameters ();
99
+ final Integer paramLimit = (Integer ) methodProposal
100
+ .getAttribute (ScriptCompletionProposalCollector .ATTR_PARAM_LIMIT );
101
+ if (extraInfo instanceof Method ) {
102
+ final Method method = (Method ) extraInfo ;
103
+ final EList <Parameter > parameters = method .getParameters ();
101
104
if (parameters .size () > 0 ) {
102
105
sb = new StringBuilder ();
106
+ int index = 0 ;
103
107
for (Parameter parameter : parameters ) {
104
108
if (sb .length () > 0 )
105
- sb .append (',' );
109
+ sb .append (", " );
106
110
if (parameter .getKind () == ParameterKind .OPTIONAL )
107
111
sb .append ('[' );
108
112
if (parameter .getType () != null ) {
@@ -117,18 +121,19 @@ protected IScriptCompletionProposal createMethodReferenceProposal(
117
121
sb .append ("..." );
118
122
if (parameter .getKind () == ParameterKind .OPTIONAL )
119
123
sb .append (']' );
120
-
124
+ if (paramLimit != null && ++index >= paramLimit .intValue ())
125
+ break ;
121
126
}
122
127
}
123
- } else if (methodProposal .getExtraInfo () instanceof IValueReference ) {
124
- IRMethod method = (IRMethod ) ((IValueReference ) methodProposal
125
- .getExtraInfo ())
128
+ } else if (extraInfo instanceof IValueReference ) {
129
+ final IRMethod method = (IRMethod ) ((IValueReference ) extraInfo )
126
130
.getAttribute (IReferenceAttributes .R_METHOD );
127
131
if (method != null && method .getParameterCount () > 0 ) {
128
132
sb = new StringBuilder ();
133
+ int index = 0 ;
129
134
for (IRParameter parameter : method .getParameters ()) {
130
135
if (sb .length () > 0 )
131
- sb .append (',' );
136
+ sb .append (", " );
132
137
if (parameter .isOptional ())
133
138
sb .append ('[' );
134
139
if (parameter .getType () != null ) {
@@ -142,17 +147,21 @@ protected IScriptCompletionProposal createMethodReferenceProposal(
142
147
sb .append ("..." );
143
148
if (parameter .isOptional ())
144
149
sb .append (']' );
150
+ if (paramLimit != null && ++index >= paramLimit .intValue ())
151
+ break ;
145
152
}
146
153
}
147
154
}
148
155
if (sb != null ) {
149
- ProposalContextInformation contextInformation = new JavaScriptProposalContextInformation (
156
+ final ProposalContextInformation contextInformation = new JavaScriptProposalContextInformation (
150
157
methodProposal , sb .toString ());
151
-
152
- contextInformation .setContextInformationPosition (methodProposal
153
- .getReplaceStart ()
154
- + methodProposal .getCompletion ().length () + 1 );
155
- methodReferenceProposal .setContextInformation (contextInformation );
158
+ final int pos = methodProposal .getCompletion ().indexOf ('(' );
159
+ if (pos >= 0 ) {
160
+ contextInformation .setContextInformationPosition (methodProposal
161
+ .getReplaceStart () + pos + 1 );
162
+ methodReferenceProposal
163
+ .setContextInformation (contextInformation );
164
+ }
156
165
}
157
166
158
167
return methodReferenceProposal ;
0 commit comments