number = 100 let SourceFileSyntax CodeBlockItemListSyntax CodeBlockItemSyntax VariableDeclSyntax PatternBindingListSyntax PatternBindingSyntax IdentifierPatternSyntax InitializerClauseSyntax IntegerLiteralExprSyntax endOfFile number = 100 let
number = 100 let SourceFileSyntax CodeBlockItemListSyntax CodeBlockItemSyntax VariableDeclSyntax PatternBindingListSyntax PatternBindingSyntax IdentifierPatternSyntax InitializerClauseSyntax IntegerLiteralExprSyntax endOfFile number = 100 let
func () { let number = 0 } CodeBlockItem PatternBindingListSyntax PatternBindingSyntax IdentifierPatternSyntax number VariableDeclSyntax OptionalBindingConditionSyntax let IdentifierPatternSyntax number ConditionElementSyntax func round(number: Int) { ... } FunctionParameterSyntax number FunctionParameterListSyntax πϦʔͷܗΛߏతʹϚονϯά͢Δ
let locationConverter = SourceLocationConverter(fileName: "", tree: sourceFile) ... let identifier = pattern.identifier let start = identifier.startLocation(converter: locationConverter) let end = identifier.endLocation(converter: locationConverter) print("\(start.line):\(start.column)...\(end.line):\(end.column)") 1:5...1:11
let locationConverter = SourceLocationConverter(fileName: "", tree: sourceFile) ... let identifier = pattern.identifier let start = identifier.startLocation(converter: locationConverter) let end = identifier.endLocation(converter: locationConverter) print("\(start.line):\(start.column)...\(end.line):\(end.column)") 1:5...1:11 let start = identifier.startLocation(converter: locationConverter) let end = identifier.endLocation(converter: locationConverter) print("\(start.line):\(start.column)...\(end.line):\(end.column)") let number = 100 1:5 1:11
age: Int let birthday: Date? } class Person { let name: String let age: Int let birthday: Date? } } init( name: String, age: Int, birthday: Date? ) { self.name = name self.age = age self.birthday = birthday }
node: AttributeSyntax, providingMembersOf declaration: some DeclGroupSyntax, in context: some MacroExpansionContext ) throws -> [DeclSyntax] { ... } } @Init class Person { let name: String let age: Int let birthday: Date? }
* b DeclReferenceExprSyntax c InfixOperatorExprSyntax DeclReferenceExprSyntax BinaryOperatorExpr a + DeclReferenceExprSyntax BinaryOperatorExpr * b DeclReferenceExprSyntax c InfixOperatorExprSyntax if a + b * c == d { ... } 1BSTF 'PME
ಠࣗఆٛͷԋࢉࢠ ͕ԋࢉࢠ͕͋Δͱࣦഊ͢Δ r ϚΫϩͷ߹ɺࣗಈͰંΓͨͨΜͩ4ZOUBY5SFF͕͞ΕΔ ‣ ࣗͰ1BSTFͨ͠4ZOUBY5SFFͱҟͳ͍ͬͯͯ͋Θͯͳ͍ r ϚΫϩͷ߹ɺಠࣗఆٛͷԋࢉࢠ͕͋ͬͯڧҾʹંΓͨͨΉ ‣ ༏ઌॱҐ͕ؒҧͬͯંΓͨͨ·ΕΔ ߹͕͋Δ r ͕͋Δ߹4ZOUBY5SFF͔ΒιʔείʔυΛੜͯࣗ͠Ͱ࠶1BSTF͢Δ
if node.tokenKind == .leftBrace { if let previousToken = node.previousToken(viewMode: .sourceAccurate), previousToken.trailingTrivia == .space { let position = node.positionAfterSkippingLeadingTrivia violations.append(position) } } return .visitChildren }
if node.tokenKind == .leftBrace { if let previousToken = node.previousToken(viewMode: .sourceAccurate), previousToken.trailingTrivia == .space { let position = node.positionAfterSkippingLeadingTrivia violations.append(position) } } return .visitChildren }
if node.tokenKind == .leftBrace { if let previousToken = node.previousToken(viewMode: .sourceAccurate), previousToken.trailingTrivia == .space { let position = node.positionAfterSkippingLeadingTrivia violations.append(position) } } return .visitChildren }
-JUFSBMXPSETBOEQVODUVBUJPOBSFJOEJDBUFECZCPMEGBDFDPOTUBOUXJEUIUFYUBOEBQQFBSPOMZPO UIFSJHIUIBOETJEFPGBHSBNNBSQSPEVDUJPOSVMF r "MUFSOBUJWFHSBNNBSQSPEVDUJPOTBSFTFQBSBUFECZWFSUJDBMCBST c 8IFOBMUFSOBUJWF QSPEVDUJPOTBSFUPPMPOHUPSFBEFBTJMZ UIFZ`SFCSPLFOJOUPNVMUJQMFHSBNNBSQSPEVDUJPOSVMFT POOFXMJOFT r *OBGFXDBTFT SFHVMBSGPOUUFYUJTVTFEUPEFTDSJCFUIFSJHIUIBOETJEFPGBHSBNNBSQSPEVDUJPO SVMF r 0QUJPOBMTZOUBDUJDDBUFHPSJFTBOEMJUFSBMTBSFNBSLFECZBUSBJMJOHRVFTUJPONBSL
r GPSJOXIJMFSFQFBUXIJMFJGHVBSEEFGFSEPEPDBUDI r FOVNTUSVDUDMBTTBDUPSQSPUPDPMFYUFOTJPOએݴ r QSFDFEFODFHSPVQએݴ r TXJUDI$MPTVSF %FDM(SPVQ4ZOUBY 8JUI$PEF#MPDL4ZOUBY 8JUI4UBUFNFOUT4ZOUBY
NFTTBHFɺ fi MFɺMJOFͷσϑΥϧτҾʹҙ͢Δ r ුಈখΛൺֱ͢Δ9$5"TTFSU&RVBM @@BDDVSBDZ@ fi MFMJOF ؔର֎ r ෆશͳιʔείʔυ͕ͬͯ͘Δ߹͕͋Δ r ղྫ IUUQTHJUIVCDPNLJTIJLBXBLBUTVNJTXJGUQPXFSBTTFSUQVMM
r 4XJGU-BOHVBHF3FGFSFODF IUUQTEPDTTXJGUPSHTXJGUCPPLEPDVNFOUBUJPOUIFTXJGUQSPHSBNNJOHMBOHVBHFBCPVUUIFMBOHVBHFSFGFSFODF r 4XJGU.BDSPT IUUQTHJUIVCDPNLS[ZT[UPG[BCMPDLJ4XJGU.BDSPT