Skip to content

Commit f228056

Browse files
committed
Rename #myLine to #line now that it's just a normal macro
1 parent 20ff3b6 commit f228056

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

Sources/SwiftSyntaxMacros/MacroSystem+Examples.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import SwiftSyntaxBuilder
33

44
// Macros used for testing purposes
55
struct LineMacro: ExpressionMacro {
6-
static var name: String { "myLine" }
6+
static var name: String { "line" }
77

88
static func apply(
99
_ macro: MacroExpansionExprSyntax, in context: MacroEvaluationContext

Sources/SwiftSyntaxMacros/SwiftSyntaxMacros.docc/SwiftSyntaxMacros.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ Use `swift-parser-cli` to test out your macros and see what kind of syntactic tr
2424

2525
A number of example macros have been implemented in the file `MacroSytem+Examples.swift`. They include:
2626

27-
* `#myLine`: behaves like the `#line` expression.
27+
* `#line`: Implements the `#line` expression.
2828
* `#stringify(x)`: returns both the value `x` and the string form of its expression, as a tuple.
2929
* `#myColorLiteral(red: <value>, green: <value>, blue: <value>, alpha: <value>)`: behaves like the `#colorLiteral` expression.
3030

3131
New example macros can be added by defining new types that conform to the appropriate `*Macro` protocols, and adding those macros to the example macro system created by `MacroSystem.exampleSystem`. Have fun!
3232

3333
## What's the future for this library?
3434

35-
Well, that depends. The `SwiftSyntaxMacros` module is part of a potential vision for a macros feature in Swift, where the effect of macro evaluation is as it works here---executable Swift code that transforms a given syntax tree into another syntax tree. That design also integrates macros into the type checker, so that macros are only evaluated on well-typed inputs and are expected to either produce well-typed syntax trees as output or emit diagnostics along the way. If that design is accepted as the design for Swift, much of this module will remain as it is---but the examples themselves will be divided into a builtin set of macros that are always available to the compiler (e.g., to provide the implementation for things like `#line`) or moved into a separate examples module to provide documentation on how to use the feature.
35+
Well, that depends. The `SwiftSyntaxMacros` module is part of a potential vision for a macros feature in Swift, where the effect of macro evaluation is as it works here---executable Swift code that transforms a given syntax tree into another syntax tree. That design also integrates macros into the type checker, so that macros are only evaluated on well-typed inputs and are expected to either produce well-typed syntax trees as output or emit diagnostics along the way. If that design is accepted as the design for Swift, much of this module will remain as it is---but the examples themselves will be divided into a builtin set of macros that are always available to the compiler (e.g., to provide the implementation for things like `#line`) or moved into a separate examples module to provide documentation on how to use the feature.

Tests/SwiftSyntaxMacrosTest/MacroSystemTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ final class MacroSystemTests: XCTestCase {
88
func testExpressionExpansion() {
99
let sf: SourceFileSyntax =
1010
"""
11-
#myLine
12-
let a = (#myLine)
11+
#line
12+
let a = (#line)
1313
let b = #stringify(x + y)
1414
#myColorLiteral(red: 0.5, green: 0.5, blue: 0.25, alpha: 1.0)
1515
"""

0 commit comments

Comments
 (0)