File tree 2 files changed +59
-4
lines changed
test/dotty/tools/pc/tests/edit
2 files changed +59
-4
lines changed Original file line number Diff line number Diff line change @@ -320,13 +320,14 @@ object AutoImports:
320
320
case _ => None
321
321
322
322
323
- def skipUsingDirectivesOffset (
324
- firstObjectPos : Int = firstMemberDefinitionStart(tree).getOrElse(0 )
325
- ): Int =
323
+ def skipUsingDirectivesOffset (firstObjectPos : Int = firstMemberDefinitionStart(tree).getOrElse(0 )): Int =
326
324
val firstObjectLine = pos.source.offsetToLine(firstObjectPos)
325
+
327
326
comments
328
327
.takeWhile(comment =>
329
- ! comment.isDocComment && pos.source.offsetToLine(comment.span.end) + 1 < firstObjectLine
328
+ val commentLine = pos.source.offsetToLine(comment.span.end)
329
+ val isFirstObjectComment = commentLine + 1 == firstObjectLine && ! comment.raw.startsWith(" //>" )
330
+ commentLine < firstObjectLine && ! isFirstObjectComment
330
331
)
331
332
.lastOption
332
333
.fold(0 )(_.span.end + 1 )
Original file line number Diff line number Diff line change @@ -500,3 +500,57 @@ class AutoImportsSuite extends BaseAutoImportsSuite:
500
500
|object Main{ val obj = ABC }
501
501
| """ .stripMargin
502
502
)
503
+
504
+ @ Test def scalaCliNoEmptyLineAfterDirective =
505
+ checkEdit(
506
+ """ |//> using scala 3.5.0
507
+ |object Main:
508
+ | <<Files>>
509
+ |""" .stripMargin,
510
+ """ |//> using scala 3.5.0
511
+ |import java.nio.file.Files
512
+ |object Main:
513
+ | Files
514
+ |""" .stripMargin
515
+ )
516
+
517
+ @ Test def scalaCliNoEmptyLineAfterLicense =
518
+ checkEdit(
519
+ """ |/**
520
+ | * Some license text
521
+ | */
522
+ |
523
+ |object Main:
524
+ | <<Files>>
525
+ |""" .stripMargin,
526
+ """ |/**
527
+ | * Some license text
528
+ | */
529
+ |import java.nio.file.Files
530
+ |
531
+ |object Main:
532
+ | Files
533
+ |""" .stripMargin
534
+ )
535
+
536
+ @ Test def scalaCliNoEmptyLineAfterLicenseWithPackage =
537
+ checkEdit(
538
+ """ |/**
539
+ | * Some license text
540
+ | */
541
+ |package test
542
+ |
543
+ |object Main:
544
+ | <<Files>>
545
+ |""" .stripMargin,
546
+ """ |/**
547
+ | * Some license text
548
+ | */
549
+ |package test
550
+ |
551
+ |import java.nio.file.Files
552
+ |
553
+ |object Main:
554
+ | Files
555
+ |""" .stripMargin
556
+ )
You can’t perform that action at this time.
0 commit comments