Skip to content

Commit 9ac941c

Browse files
committed
Rename endMarkersForMethodBlocks to methodBlockEndMarkers across the codebase and update related documentation.
1 parent d7db737 commit 9ac941c

File tree

9 files changed

+32
-18
lines changed

9 files changed

+32
-18
lines changed

compiler/src/dotty/tools/dotc/config/Feature.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ object Feature:
4040
val packageObjectValues = experimental("packageObjectValues")
4141
val multiSpreads = experimental("multiSpreads")
4242
val subCases = experimental("subCases")
43-
val endMarkersForMethodBlocks = experimental("endMarkersForMethodBlocks")
43+
val methodBlockEndMarkers = experimental("methodBlockEndMarkers")
4444

4545
def experimentalAutoEnableFeatures(using Context): List[TermName] =
4646
defn.languageExperimentalFeatures
@@ -70,7 +70,7 @@ object Feature:
7070
(into, "Allow into modifier on parameter types"),
7171
(modularity, "Enable experimental modularity features"),
7272
(packageObjectValues, "Enable experimental package objects as values"),
73-
(endMarkersForMethodBlocks, "Enable experimental end markers for method blocks"),
73+
(methodBlockEndMarkers, "Enable experimental end markers for method blocks"),
7474
)
7575

7676
// legacy language features from Scala 2 that are no longer supported.

compiler/src/dotty/tools/dotc/config/SourceVersion.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ enum SourceVersion:
4747
def enablesBetterFors(using Context) = isAtLeast(`3.8`) || (isAtLeast(`3.7`) && isPreviewEnabled)
4848
/** See PR #23441 and tests/neg/i23435-min */
4949
def enablesDistributeAnd = !isAtLeast(`3.8`)
50-
def enablesEndMarkersForMethodBlocks(using Context) = isAtLeast(`3.8`) || Feature.enabled(Feature.endMarkersForMethodBlocks)
50+
def enablesMethodBlockEndMarkers(using Context) = isAtLeast(`3.8`) || Feature.enabled(Feature.methodBlockEndMarkers)
5151

5252
def requiresNewSyntax = isAtLeast(future)
5353

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,7 +1544,7 @@ object Parsers {
15441544
def updateSpanOfLast(last: T): Unit =
15451545
last match
15461546
case last: WithEndMarker[t] => last.withEndMarker()
1547-
case apply: Apply if sourceVersion.enablesEndMarkersForMethodBlocks => apply.setEndMarker()
1547+
case apply: Apply if sourceVersion.enablesMethodBlockEndMarkers => apply.setEndMarker()
15481548
case _ =>
15491549
last.span = last.span.withEnd(in.lastCharOffset)
15501550

@@ -1564,7 +1564,7 @@ object Parsers {
15641564
case _: Match => in.token == MATCH
15651565
case _: New => in.token == NEW
15661566
case _: (ForYield | ForDo) => in.token == FOR
1567-
case apply: Apply if sourceVersion.enablesEndMarkersForMethodBlocks =>
1567+
case apply: Apply if sourceVersion.enablesMethodBlockEndMarkers =>
15681568
// Extract method name from Apply node
15691569
val methodName = apply.attachmentOrElse(untpd.MethodName, null)
15701570
if methodName != null then
@@ -2936,7 +2936,7 @@ object Parsers {
29362936
val res = Apply(fn, args._1)
29372937
if args._2 then res.setApplyKind(ApplyKind.Using)
29382938
// Track method name for end marker support when using colon syntax
2939-
if sourceVersion.enablesEndMarkersForMethodBlocks then
2939+
if sourceVersion.enablesMethodBlockEndMarkers then
29402940
val methodName = fn match
29412941
case Select(_, name) => name
29422942
case Ident(name) => name

docs/_docs/reference/experimental/end-markers-method-blocks.md renamed to docs/_docs/reference/experimental/method-block-end-markers.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# End Markers for Method Blocks
1+
# Method Block End Markers
22

3-
End markers for method blocks allow you to explicitly mark the end of method application blocks that use colon syntax (braceless arguments).
3+
Method block end markers allow you to explicitly mark the end of method application blocks that use colon syntax (braceless arguments).
44

55
## Syntax
66

@@ -17,7 +17,7 @@ end methodName
1717
### Simple Method Blocks
1818

1919
```scala
20-
import scala.language.experimental.endMarkersForMethodBlocks
20+
import scala.language.experimental.methodBlockEndMarkers
2121

2222
def test(name: String)(body: => Unit): Unit =
2323
println(s"Running test: $name")
@@ -85,18 +85,18 @@ This rule ensures that the end marker always corresponds to the syntactically vi
8585
To use end markers for method blocks, you need to enable the experimental feature:
8686

8787
```scala
88-
import scala.language.experimental.endMarkersForMethodBlocks
88+
import scala.language.experimental.methodBlockEndMarkers
8989
```
9090

9191
Alternatively, you can enable it globally with the compiler flag:
9292

9393
```
94-
-language:experimental.endMarkersForMethodBlocks
94+
-language:experimental.methodBlockEndMarkers
9595
```
9696

9797
## When to Use
9898

99-
End markers for method blocks are particularly useful when:
99+
Method block end markers are particularly useful when:
100100

101101
- You have deeply nested method calls with colon syntax
102102
- You want to improve code readability by explicitly marking block boundaries

docs/_docs/reference/experimental/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ All experimental language features can be found under the `scala.language.experi
1111
They are enabled by importing the feature or using the `-language` compiler flag.
1212

1313
* [`erasedDefinitions`](./erased-defs.md): Enable support for `erased` modifier.
14-
* [`endMarkersForMethodBlocks`](./end-markers-method-blocks.md): Enable support for end markers for method blocks.
14+
* [`methodBlockEndMarkers`](./method-block-end-markers.md): Enable support for end markers for method blocks.
1515
* `fewerBraces`: Enable support for using indentation for arguments.
1616
* [`genericNumberLiterals`](./numeric-literals.md): Enable support for generic number literals.
1717
* [`namedTypeArguments`](./named-typeargs.md): Enable support for named type arguments

library/src/scala/runtime/stdLibPatches/language.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ object language:
178178
*
179179
* @see [[https://github.com/scala/improvement-proposals/pull/77]]
180180
*/
181-
@compileTimeOnly("`endMarkersForMethodBlocks` can only be used at compile time in import statements")
182-
object endMarkersForMethodBlocks
181+
@compileTimeOnly("`methodBlockEndMarkers` can only be used at compile time in import statements")
182+
object methodBlockEndMarkers
183183
end experimental
184184

185185
/** The deprecated object contains features that are no longer officially suypported in Scala.

presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,14 @@ class Completions(
108108
case _ => false
109109
else false
110110

111-
if generalExclude then false
111+
def isLanguageExperimental: Boolean =
112+
val n = sym.fullName.show
113+
n.contains(".language.experimental.") || n.endsWith(".language.experimental")
114+
115+
val excludeLanguageExperimental =
116+
!completionMode.is(Mode.ImportOrExport) && isLanguageExperimental
117+
118+
if generalExclude || excludeLanguageExperimental then false
112119
else if completionMode.is(Mode.Type) then true
113120
else !isWildcardParam(sym) && (sym.isTerm || sym.is(Package))
114121
end if
@@ -585,6 +592,13 @@ class Completions(
585592
if completionMode.is(Mode.Scope) && query.nonEmpty then
586593
val visitor = new CompilerSearchVisitor(sym =>
587594
if Completion.isValidCompletionSymbol(sym, completionMode, isNew) &&
595+
// Avoid suggesting experimental language import symbols (`scala.language.experimental.*`)
596+
// as auto-import completions in regular identifier positions.
597+
// They are still available in import positions.
598+
{
599+
val n = sym.fullName.show
600+
!n.contains(".language.experimental.") && !n.endsWith(".language.experimental")
601+
} &&
588602
!(sym.is(Flags.ExtensionMethod) || (sym.maybeOwner.is(Flags.Implicit) && sym.maybeOwner.isClass))
589603
then
590604
indexedContext.lookupSym(sym) match

tests/neg/end-markers-method-blocks.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import scala.language.experimental.endMarkersForMethodBlocks
1+
import scala.language.experimental.methodBlockEndMarkers
22

33
object Test:
44
def test(name: String)(body: => Unit): Unit =

tests/pos/end-markers-method-blocks.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import scala.language.experimental.endMarkersForMethodBlocks
1+
import scala.language.experimental.methodBlockEndMarkers
22

33
object Test:
44
def test(name: String)(body: => Unit): Unit =

0 commit comments

Comments
 (0)