File tree Expand file tree Collapse file tree 2 files changed +48
-28
lines changed
src/main/dotty/tools/pc/completions
test/dotty/tools/pc/tests/edit Expand file tree Collapse file tree 2 files changed +48
-28
lines changed Original file line number Diff line number Diff line change @@ -511,10 +511,10 @@ object OverrideCompletions:
511
511
Context
512
512
): Option [Int ] =
513
513
defn match
514
- case td : TypeDef if text.charAt(td.rhs.span.end) == ':' =>
514
+ case td : TypeDef if (td.rhs.span.end < text.length) && text.charAt(td.rhs.span.end) == ':' =>
515
515
Some (td.rhs.span.end)
516
516
case TypeDef (_, temp : Template ) =>
517
- temp.parentsOrDerived.lastOption.map(_.span.end).filter(text.charAt(_ ) == ':' )
517
+ temp.parentsOrDerived.lastOption.map(_.span.end).filter(idx => text.length > idx && text. charAt(idx ) == ':' )
518
518
case _ => None
519
519
520
520
private def fallbackFromParent (parent : Tree , name : String )(using Context ) =
Original file line number Diff line number Diff line change @@ -75,39 +75,59 @@ class AutoImplementAbstractMembersSuite extends BaseCodeActionSuite:
75
75
|""" .stripMargin
76
76
)
77
77
78
- @ Test def `empty-lines-between-members ` =
78
+ @ Test def `no-new-line ` =
79
79
checkEdit(
80
80
""" |package a
81
- |
82
- |object A {
83
- | trait Base {
84
- | def foo(x: Int): Int
85
- | def bar(x: String): String
86
- | }
87
- | class <<Concrete>> extends Base {
88
- |
89
- | def bar(x: String): String = ???
90
- |
91
- | }
92
- |}
93
- |""" .stripMargin,
81
+ |
82
+ |trait X:
83
+ | def foo: Unit
84
+ |
85
+ |class <<Y>> extends X""" .stripMargin,
94
86
""" |package a
95
87
|
96
- |object A {
97
- | trait Base {
98
- | def foo(x: Int): Int
99
- | def bar(x: String): String
100
- | }
101
- | class Concrete extends Base {
102
- |
88
+ |trait X:
89
+ | def foo: Unit
103
90
|
104
- | override def foo(x: Int): Int = ???
91
+ |class Y extends X {
105
92
|
106
- | def bar(x: String): String = ???
93
+ | override def foo: Unit = ???
107
94
|
108
- | }
109
- |}
110
- |""" .stripMargin
95
+ |}""" .stripMargin,
96
+ )
97
+
98
+ @ Test def `empty-lines-between-members` =
99
+ checkEdit(
100
+ """ |package a
101
+ |
102
+ |object A {
103
+ | trait Base {
104
+ | def foo(x: Int): Int
105
+ | def bar(x: String): String
106
+ | }
107
+ | class <<Concrete>> extends Base {
108
+ |
109
+ | def bar(x: String): String = ???
110
+ |
111
+ | }
112
+ |}
113
+ |""" .stripMargin,
114
+ """ |package a
115
+ |
116
+ |object A {
117
+ | trait Base {
118
+ | def foo(x: Int): Int
119
+ | def bar(x: String): String
120
+ | }
121
+ | class Concrete extends Base {
122
+ |
123
+ |
124
+ | override def foo(x: Int): Int = ???
125
+ |
126
+ | def bar(x: String): String = ???
127
+ |
128
+ | }
129
+ |}
130
+ |""" .stripMargin
111
131
)
112
132
113
133
@ Test def `objectdef` =
You can’t perform that action at this time.
0 commit comments