Skip to content

Commit b624446

Browse files
author
builduser
committed
Merged branch idea251.release into idea251.x
2 parents 592a3c8 + 975f86f commit b624446

File tree

6 files changed

+77
-35
lines changed

6 files changed

+77
-35
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package org.jetbrains.plugins.scala.codeInsight.hints
2+
3+
import com.intellij.openapi.editor.Editor
4+
import com.intellij.psi.PsiElement
5+
import org.jetbrains.plugins.scala.annotator.hints.{Hint, Text}
6+
import org.jetbrains.plugins.scala.editor.documentationProvider.ScalaDocQuickInfoGenerator
7+
import org.jetbrains.plugins.scala.extensions.{&, PsiElementExt, ResolvesTo}
8+
import org.jetbrains.plugins.scala.incremental.Highlighting.ElementHighlightingExt
9+
import org.jetbrains.plugins.scala.lang.psi.api.expr.{ScMethodCall, ScReferenceExpression}
10+
import org.jetbrains.plugins.scala.lang.psi.api.statements.ScFunction
11+
import org.jetbrains.plugins.scala.settings.ScalaApplicationSettings.{getInstance => ScalaApplicationSettings}
12+
13+
private[codeInsight] trait ScalaApplyMethodHintsPass {
14+
protected def collectApplyMethodHints(editor: Editor, root: PsiElement): Seq[Hint] = {
15+
if (!(ScalaHintsSettings.xRayMode && ScalaApplicationSettings.XRAY_SHOW_APPLY_METHOD_HINTS)) return Seq.empty
16+
17+
root.elements(_.isVisible).collect {
18+
case ScMethodCall((r: ScReferenceExpression) & ResolvesTo(f: ScFunction), _) if f.name == "apply" && !r.textMatches("apply") =>
19+
val tooltip = () => ScalaDocQuickInfoGenerator.getQuickNavigateInfo(f, r)
20+
Hint(Seq(Text("."), Text("apply", navigatable = Some(f), tooltip = tooltip)), r, suffix = true, relatesToPrecedingElement = true)
21+
}.toSeq
22+
}
23+
}

scala/codeInsight/src/org/jetbrains/plugins/scala/codeInsight/implicits/ImplicitHintsPass.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import org.jetbrains.plugins.scala.caches.{ModTracker, cachedInUserData}
1919
import org.jetbrains.plugins.scala.codeInsight.ScalaCodeInsightBundle
2020
import org.jetbrains.plugins.scala.codeInsight.hints.methodChains.ScalaMethodChainInlayHintsPass
2121
import org.jetbrains.plugins.scala.codeInsight.hints.rangeHints.RangeInlayHintsPass
22-
import org.jetbrains.plugins.scala.codeInsight.hints.{ScalaHintsSettings, ScalaInlayParameterHintsPass, ScalaTypeHintsPass}
22+
import org.jetbrains.plugins.scala.codeInsight.hints.{ScalaApplyMethodHintsPass, ScalaHintsSettings, ScalaInlayParameterHintsPass, ScalaTypeHintsPass}
2323
import org.jetbrains.plugins.scala.codeInsight.implicits.ImplicitHintsPass._
2424
import org.jetbrains.plugins.scala.editor.documentationProvider.ScalaDocQuickInfoGenerator
2525
import org.jetbrains.plugins.scala.extensions._
@@ -50,6 +50,7 @@ class ImplicitHintsPass(
5050
/*runIntentionPassAfter*/ false
5151
) with ScalaTypeHintsPass
5252
with ScalaInlayParameterHintsPass
53+
with ScalaApplyMethodHintsPass
5354
with ScalaMethodChainInlayHintsPass
5455
with RangeInlayHintsPass {
5556

@@ -69,6 +70,7 @@ class ImplicitHintsPass(
6970
// TODO Use a dedicated pass when built-in "advanced" hint API will be available in IDEA, SCL-14502
7071
hints ++= collectTypeHints(editor, rootElement)
7172
hints ++= collectParameterHints(editor, rootElement)
73+
hints ++= collectApplyMethodHints(editor, rootElement)
7274
collectConversionsAndArguments()
7375
collectMethodChainHints(editor, rootElement)
7476
collectRangeHints(editor, rootElement)

scala/scala-impl/resources/messages/ScalaBundle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2320,6 +2320,7 @@ scala.project.settings.form.tabs.xray.mode=X-Ray Mode
23202320

23212321
### org/jetbrains/plugins/scala/settings/sections/XRayModeSettingsSectionPanel.form
23222322
scala.project.settings.form.xray.activate=Activate on:
2323+
scala.project.settings.form.xray.apply.method.hints=Apply method hints
23232324
scala.project.settings.form.xray.double.press.and.hold=Double-press and hold {0}
23242325
scala.project.settings.form.xray.for.all.chains=for all method chains
23252326
scala.project.settings.form.xray.for.all.parameters=for all parameters

scala/scala-impl/src/org/jetbrains/plugins/scala/settings/ScalaApplicationSettings.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public enum pluginBranch {Release, EAP, Nightly}
9898
public boolean XRAY_PRESS_AND_HOLD = false;
9999
public boolean XRAY_SHOW_PARAMETER_HINTS = true;
100100
public boolean XRAY_SHOW_ARGUMENT_HINTS = true;
101+
public boolean XRAY_SHOW_APPLY_METHOD_HINTS = true;
101102
public boolean XRAY_SHOW_TYPE_HINTS = true;
102103
public boolean XRAY_SHOW_MEMBER_VARIABLE_HINTS = true;
103104
public boolean XRAY_SHOW_LOCAL_VARIABLE_HINTS = true;

scala/scala-impl/src/org/jetbrains/plugins/scala/settings/sections/XRayModeSettingsSectionPanel.form

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
<text resource-bundle="messages/ScalaBundle" key="scala.project.settings.form.xray.widget"/>
9191
</properties>
9292
</component>
93-
<grid id="e4db3" layout-manager="GridLayoutManager" row-count="14" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
93+
<grid id="e4db3" layout-manager="GridLayoutManager" row-count="15" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
9494
<margin top="0" left="0" bottom="0" right="0"/>
9595
<constraints>
9696
<grid row="4" column="0" row-span="14" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="2" indent="0" use-parent-layout="false"/>
@@ -108,132 +108,140 @@
108108
</component>
109109
<component id="c2735" class="javax.swing.JCheckBox" binding="myShowMethodChainHintsCheckbox">
110110
<constraints>
111-
<grid row="10" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
111+
<grid row="11" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
112112
</constraints>
113113
<properties>
114114
<text resource-bundle="messages/ScalaBundle" key="scala.project.settings.form.xray.method.chain.hints"/>
115115
</properties>
116116
</component>
117117
<component id="11b9" class="javax.swing.JCheckBox" binding="myShowIndentGuidesCheckbox">
118118
<constraints>
119-
<grid row="12" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
119+
<grid row="13" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
120120
</constraints>
121121
<properties>
122122
<text resource-bundle="messages/ScalaBundle" key="scala.project.settings.form.xray.indent.guides"/>
123123
</properties>
124124
</component>
125125
<component id="2e3dd" class="javax.swing.JCheckBox" binding="myShowMethodSeparatorsCheckbox">
126126
<constraints>
127-
<grid row="13" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
127+
<grid row="14" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
128128
</constraints>
129129
<properties>
130130
<text resource-bundle="messages/ScalaBundle" key="scala.project.settings.form.xray.method.separators"/>
131131
</properties>
132132
</component>
133133
<component id="cb34d" class="javax.swing.JCheckBox" binding="myShowImplicitHintsCheckbox">
134134
<constraints>
135-
<grid row="11" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
135+
<grid row="12" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
136136
</constraints>
137137
<properties>
138138
<text resource-bundle="messages/ScalaBundle" key="scala.project.settings.form.xray.implicit.hints"/>
139139
</properties>
140140
</component>
141141
<component id="e9533" class="javax.swing.JCheckBox" binding="myShowTypeHintsCheckbox">
142142
<constraints>
143-
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
143+
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
144144
</constraints>
145145
<properties>
146146
<text resource-bundle="messages/ScalaBundle" key="scala.project.settings.form.xray.type.hints"/>
147147
</properties>
148148
</component>
149149
<component id="60d43" class="javax.swing.JCheckBox" binding="myShowMethodResultsCheckbox">
150150
<constraints>
151-
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
151+
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
152152
</constraints>
153153
<properties>
154154
<text resource-bundle="messages/ScalaBundle" key="scala.project.settings.form.xray.method.results"/>
155155
</properties>
156156
</component>
157157
<component id="fdd19" class="javax.swing.JCheckBox" binding="myShowMemberVariablesCheckbox">
158158
<constraints>
159-
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
159+
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
160160
</constraints>
161161
<properties>
162162
<text resource-bundle="messages/ScalaBundle" key="scala.project.settings.form.xray.member.variables"/>
163163
</properties>
164164
</component>
165165
<component id="77772" class="javax.swing.JCheckBox" binding="myShowLocalVariablesCheckbox">
166166
<constraints>
167-
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
167+
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
168168
</constraints>
169169
<properties>
170170
<text resource-bundle="messages/ScalaBundle" key="scala.project.settings.form.xray.local.variables"/>
171171
</properties>
172172
</component>
173173
<component id="c67ba" class="javax.swing.JCheckBox" binding="myShowLambdaParametersCheckbox">
174174
<constraints>
175-
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
175+
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
176176
</constraints>
177177
<properties>
178178
<text resource-bundle="messages/ScalaBundle" key="scala.project.settings.form.xray.lambda.parameters"/>
179179
</properties>
180180
</component>
181181
<component id="ba88a" class="javax.swing.JCheckBox" binding="myShowLambdaPlaceholdersCheckbox">
182182
<constraints>
183-
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
183+
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
184184
</constraints>
185185
<properties>
186186
<text resource-bundle="messages/ScalaBundle" key="scala.project.settings.form.xray.lambda.placeholders"/>
187187
</properties>
188188
</component>
189189
<component id="9e5e8" class="javax.swing.JCheckBox" binding="myShowVariablePatternsCheckbox">
190190
<constraints>
191-
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
191+
<grid row="10" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
192192
</constraints>
193193
<properties>
194194
<text resource-bundle="messages/ScalaBundle" key="scala.project.settings.form.xray.variable.patterns"/>
195195
</properties>
196196
</component>
197197
<component id="5a8c6" class="javax.swing.JCheckBox" binding="myShowParameterHintsCheckbox">
198198
<constraints>
199-
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
199+
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
200200
</constraints>
201201
<properties>
202202
<text resource-bundle="messages/ScalaBundle" key="scala.project.settings.form.xray.parameter.name.hints"/>
203203
</properties>
204204
</component>
205205
<component id="ff917" class="javax.swing.JCheckBox" binding="myShowArgumentHintsCheckbox">
206206
<constraints>
207-
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
207+
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
208208
</constraints>
209209
<properties>
210210
<text resource-bundle="messages/ScalaBundle" key="scala.project.settings.form.xray.by-name.argument.hints"/>
211211
</properties>
212212
</component>
213213
<component id="4c123" class="javax.swing.JCheckBox" binding="myForAllParametersCheckbox">
214214
<constraints>
215-
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
215+
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
216216
</constraints>
217217
<properties>
218218
<text resource-bundle="messages/ScalaBundle" key="scala.project.settings.form.xray.for.all.parameters"/>
219219
</properties>
220220
</component>
221221
<component id="6cc4" class="javax.swing.JCheckBox" binding="myForAllTypesCheckbox">
222222
<constraints>
223-
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
223+
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
224224
</constraints>
225225
<properties>
226226
<text resource-bundle="messages/ScalaBundle" key="scala.project.settings.form.xray.for.all.types"/>
227227
</properties>
228228
</component>
229229
<component id="d983b" class="javax.swing.JCheckBox" binding="myForAllChainsCheckbox">
230230
<constraints>
231-
<grid row="10" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
231+
<grid row="11" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
232232
</constraints>
233233
<properties>
234234
<text resource-bundle="messages/ScalaBundle" key="scala.project.settings.form.xray.for.all.chains"/>
235235
</properties>
236236
</component>
237+
<component id="bd9a2" class="javax.swing.JCheckBox" binding="myShowApplyMethodHintsCheckbox">
238+
<constraints>
239+
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
240+
</constraints>
241+
<properties>
242+
<text resource-bundle="messages/ScalaBundle" key="scala.project.settings.form.xray.apply.method.hints"/>
243+
</properties>
244+
</component>
237245
</children>
238246
</grid>
239247
</children>

0 commit comments

Comments
 (0)