forked from scala-ide/scala-ide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MethodTest.scala
178 lines (164 loc) · 3.93 KB
/
MethodTest.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
package scala.tools.eclipse.semantichighlighting.classifier
import SymbolTypes._
import org.junit._
class MethodTest extends AbstractSymbolClassifierTest {
@Test
def method() {
checkSymbolClassification("""
object A {
def method(): Int = method
}""", """
object A {
def $METH$(): Int = $METH$
}""",
Map("METH" -> Method))
}
@Test
def method_with_backticks() {
checkSymbolClassification("""
object A {
{
def `method` = 42
`method`
}
}""", """
object A {
{
def $ METH $ = 42
$ METH $
}
}""",
Map("METH" -> Method))
}
@Test
def bug_with_backticks() {
checkSymbolClassification("""
object A {
List.`apply`(42)
}""", """
object A {
List.$METH $(42)
}""",
Map("METH" -> Method))
}
@Test
def import_method() {
checkSymbolClassification("""
import System.currentTimeMillis
""", """
import System.$ METH $
""",
Map("METH" -> Method))
}
@Test
def classOf() {
checkSymbolClassification("""
class A { classOf[A] }
""", """
class A { $METH $[A] }
""",
Map("METH" -> Method))
}
@Test
@Ignore("The renamed method doesn't have a symbol and the current classification strategy needs the symbol's name.")
def import_renaming() {
checkSymbolClassification("""
import System.{ currentTimeMillis => bobble }
class A {
bobble
}""", """
import System.{ $ METH $ => $METH$ }
class A {
$METH$
}""",
Map("METH" -> Method))
}
@Test
def test_synthetic_function_param() {
checkSymbolClassification("""
object A {
{
def addOne(x: Int): Int = x + 1
List(3) map addOne
}
}""", """
object A {
{
def addOne(x: Int): Int = x + 1
List(3) map $METH$
}
}""",
Map("METH" -> Method))
}
@Test
@Ignore("does not work until presentation compiler stores more information in the AST (ticket #1001223)")
def param_of_classOf() {
checkSymbolClassification("""
object X {
val x = classOf[Int]
}
""", """
object X {
val x = classOf[$T$]
}
""",
Map("T" -> Type))
}
@Test
@Ignore("does not work until presentation compiler stores more information in the AST (ticket #1001228)")
def combination_of_implicit_conversion_and_higher_order_method_call() {
checkSymbolClassification("""
object X {
val s: String = Seq(1).map(param=>param)
implicit def l2s(i: Seq[Int]): String = i.mkString
}
""", """
object X {
val s: String = $O$(1).$M$($P $=>$P $)
implicit def l2s(i: Seq[Int]): String = i.mkString
}
""",
Map("O" -> Object, "M" -> Method, "P" -> Param))
}
@Test
@Ignore("does not work until presentation compiler stores more information in the AST (ticket #1001242)")
def internal_notation_of_operator_names() {
checkSymbolClassification("""
object X {
val xs = Nil $colon$colon 0
}
""", """
object X {
val xs = Nil $METHOD $ 0
}
""",
Map("METHOD" -> Method))
}
@Test
@Ignore("does not work until presentation compiler stores more information in the AST (ticket #1001259)")
def param_of_super() {
checkSymbolClassification("""
object X {
val bool = super[Object].equals(this)
}
""", """
object X {
val bool = super[$CLS $].equals(this)
}
""",
Map("CLS" -> Class))
}
@Test(expected = Predef.classOf[AssertionError])
def while_keyword_is_not_treated_as_method() {
checkSymbolClassification("""
object X {
while (false) {}
}
""", """
object X {
$MET$ (false) {}
}
""",
Map("MET" -> Method))
}
}