@@ -71,7 +71,7 @@ extension ActionGenerator {
7171 }
7272
7373 // insert content
74- if withReplaceTexts && token. contentLength . utf8Length > 0 {
74+ if withReplaceTexts && token. trimmedLength . utf8Length > 0 {
7575 actions. append ( . replaceText( offset: contentStart, length: 0 , text: content) )
7676 }
7777
@@ -88,7 +88,7 @@ extension ActionGenerator {
8888 }
8989
9090 // actions to perform at the content-end position
91- let contentEnd = ( position + token. leadingTriviaLength + token. contentLength ) . utf8Offset
91+ let contentEnd = ( position + token. leadingTriviaLength + token. trimmedLength ) . utf8Offset
9292 for rearAction in actionToken. rearActions {
9393 switch rearAction {
9494 case . cursorInfo:
@@ -194,7 +194,7 @@ public final class TypoActionGenerator: ActionGenerator {
194194 return ( " } " , " " )
195195 case . rightAngle:
196196 return ( " > " , " " )
197- case . rightSquareBracket :
197+ case . rightSquare :
198198 return ( " ] " , " " )
199199 case . identifier( let spelling) :
200200 switch spelling. prefix ( 1 ) {
@@ -218,7 +218,7 @@ public final class TypoActionGenerator: ActionGenerator {
218218 let token = actionToken. token
219219 guard let spelling = updateSpelling ( token. tokenKind) , token. presence == . present else { return [ ] }
220220 let contentStart = token. positionAfterSkippingLeadingTrivia. utf8Offset
221- let contentLength = token. contentLength . utf8Length
221+ let contentLength = token. trimmedLength . utf8Length
222222
223223 var actions : [ Action ] = [
224224 . replaceText( offset: contentStart, length: contentLength, text: spelling. new) ,
@@ -305,7 +305,7 @@ public final class ConcurrentRewriteActionGenerator: ActionGenerator {
305305 var actions = generatePositionActions ( for: actionToken, at: position, withReplaceTexts: true )
306306
307307 // range actions
308- let rangeEnd = ( position + token. leadingTriviaLength + token. contentLength ) . utf8Offset
308+ let rangeEnd = ( position + token. leadingTriviaLength + token. trimmedLength ) . utf8Offset
309309 actions += actionToken. endedRangeStartTokens. map { startToken in
310310 // The start token should be:
311311 // 1) from the same group, or
@@ -380,7 +380,7 @@ public final class InsideOutRewriteActionGenerator: ActionGenerator {
380380 var actions = generatePositionActions ( for: actionToken, at: position, withReplaceTexts: true )
381381
382382 // range actions for ranges this token ends
383- let rangeEnd = ( position + token. leadingTriviaLength + token. contentLength ) . utf8Offset
383+ let rangeEnd = ( position + token. leadingTriviaLength + token. trimmedLength ) . utf8Offset
384384 actions += actionToken. endedRangeStartTokens. compactMap { startToken in
385385 guard let startTokenStart = getPlacedStart ( of: startToken, in: groups) else { return nil }
386386 let rangeStart = startTokenStart. utf8Offset
@@ -392,7 +392,7 @@ public final class InsideOutRewriteActionGenerator: ActionGenerator {
392392 let rangeStart = ( position + token. leadingTriviaLength) . utf8Offset
393393 actions += actionToken. startedRangeEndTokens. compactMap { endToken in
394394 guard let endTokenStart = getPlacedStart ( of: endToken, in: groups) else { return nil }
395- let rangeEnd = ( endTokenStart + endToken. contentLength ) . utf8Offset
395+ let rangeEnd = ( endTokenStart + endToken. trimmedLength ) . utf8Offset
396396 assert ( rangeEnd - rangeStart > 0 )
397397 return Action . rangeInfo ( offset: rangeStart, length: rangeEnd - rangeStart)
398398 }
@@ -461,18 +461,18 @@ private struct ActionToken {
461461 self . frontExpectedResult = ActionToken . expectedResult ( for: token)
462462
463463 var previous : TokenSyntax ? = token
464- self . endedRangeStartTokens = token. tokenKind == . eof ? [ ] : token. ancestors
465- . prefix { $0. lastToken == token }
464+ self . endedRangeStartTokens = token. tokenKind == . endOfFile ? [ ] : token. ancestors
465+ . prefix { $0. lastToken ( viewMode : . sourceAccurate ) == token }
466466 . compactMap { ancestor in
467- defer { previous = ancestor. firstToken }
468- return ancestor. firstToken == previous ? nil : ancestor. firstToken
467+ defer { previous = ancestor. firstToken ( viewMode : . sourceAccurate ) }
468+ return ancestor. firstToken ( viewMode : . sourceAccurate ) == previous ? nil : ancestor. firstToken ( viewMode : . sourceAccurate )
469469 }
470470 previous = token
471- self . startedRangeEndTokens = token. tokenKind == . eof ? [ ] : token. ancestors
472- . prefix { $0. firstToken == token }
471+ self . startedRangeEndTokens = token. tokenKind == . endOfFile ? [ ] : token. ancestors
472+ . prefix { $0. firstToken ( viewMode : . sourceAccurate ) == token }
473473 . compactMap { ancestor in
474- defer { previous = ancestor. lastToken }
475- return ancestor. lastToken == previous ? nil : ancestor. lastToken
474+ defer { previous = ancestor. lastToken ( viewMode : . sourceAccurate ) }
475+ return ancestor. lastToken ( viewMode : . sourceAccurate ) == previous ? nil : ancestor. lastToken ( viewMode : . sourceAccurate )
476476 }
477477 }
478478
@@ -490,30 +490,30 @@ private struct ActionToken {
490490 guard let parent = token. parent else { return nil }
491491
492492 // Report argument label completions for any arguments other than the first
493- if let tupleElem = parent. as ( TupleExprElementSyntax . self) , tupleElem. label == token {
493+ if let tupleElem = parent. as ( LabeledExprSyntax . self) , tupleElem. label == token {
494494 switch tupleElem. parent? . parent? . kind {
495495 case . functionCallExpr: fallthrough
496496 case . subscriptCallExpr: fallthrough
497497 case . expressionSegment:
498- if tupleElem. parent? . as ( TupleExprElementListSyntax . self) ? . first == tupleElem {
498+ if tupleElem. parent? . as ( LabeledExprListSyntax . self) ? . first == tupleElem {
499499 return nil
500500 }
501501 return ExpectedResult ( name: SwiftName ( base: token. textWithoutBackticks + " : " , labels: [ ] ) , kind: . reference)
502502 default :
503503 return nil
504504 }
505505 }
506- if let parent = parent. as ( IdentifierExprSyntax . self) , parent. identifier == token {
507- if let refArgs = parent. declNameArguments {
506+ if let parent = parent. as ( DeclReferenceExprSyntax . self) , parent. baseName == token {
507+ if let refArgs = parent. argumentNames {
508508 let name = SwiftName ( base: token. text, labels: refArgs. arguments. map { $0. name. text } )
509509 return ExpectedResult ( name: name, kind: . reference)
510510 }
511511 if let ( kind, callArgs) = getParentArgs ( of: parent) {
512512 let name = SwiftName ( base: token. text, labels: callArgs)
513513 return ExpectedResult ( name: name, kind: kind)
514514 }
515- if let parentsParent = parent. parent? . as ( MemberAccessExprSyntax . self) , parentsParent. name == token {
516- if let refArgs = parentsParent. declNameArguments {
515+ if let parentsParent = parent. parent? . as ( MemberAccessExprSyntax . self) , parentsParent. declName . baseName == token {
516+ if let refArgs = parentsParent. declName . argumentNames {
517517 let name = SwiftName ( base: token. text, labels: refArgs. arguments. map { $0. name. text } )
518518 return ExpectedResult ( name: name, kind: . reference)
519519 }
@@ -531,8 +531,8 @@ private struct ActionToken {
531531 guard let parent = syntax. parent else { return nil }
532532 if let call = parent. as ( FunctionCallExprSyntax . self) {
533533 // Check for: Bar.foo(instanceOfBar)(x:1)
534- if call. argumentList . count == 1 &&
535- call. argumentList . allSatisfy ( { $0. label == nil } ) {
534+ if call. arguments . count == 1 &&
535+ call. arguments . allSatisfy ( { $0. label == nil } ) {
536536 if let outerCall = call. parent? . as ( FunctionCallExprSyntax . self) ,
537537 Syntax ( outerCall. calledExpression) == parent {
538538 // The outer call args correspond to foo if they have any labels. If
@@ -550,7 +550,7 @@ private struct ActionToken {
550550 // at least one parameter, the extras are assumed to be variadic terms
551551 // of the last parameter. If foo has no parameters however, there's no
552552 // possibly-variadic parameter to match arguments, so it will fail.
553- return ( . call, outerCall. argumentList . map { $0. label? . text ?? " _ " } )
553+ return ( . call, outerCall. arguments . map { $0. label? . text ?? " _ " } )
554554 }
555555 }
556556 let kind : ExpectedResult . Kind
@@ -559,7 +559,7 @@ private struct ActionToken {
559559 } else {
560560 kind = . call
561561 }
562- return ( kind, call. argumentList . map { $0. label? . text ?? " _ " } )
562+ return ( kind, call. arguments . map { $0. label? . text ?? " _ " } )
563563 }
564564 return nil
565565 }
@@ -612,7 +612,7 @@ private class ActionTokenCollector: SyntaxAnyVisitor {
612612 if token. isIdentifier {
613613 return [ . cursorInfo, . format, . codeComplete, . typeContextInfo, . conformingMethodList]
614614 }
615- if !token. isOperator && token. ancestors. contains ( where: { ( $0. isProtocol ( ExprSyntaxProtocol . self) || $0. isProtocol ( TypeSyntaxProtocol . self) ) && $0. firstToken == token} ) {
615+ if !token. isOperator && token. ancestors. contains ( where: { ( $0. isProtocol ( ExprSyntaxProtocol . self) || $0. isProtocol ( TypeSyntaxProtocol . self) ) && $0. firstToken ( viewMode : . sourceAccurate ) == token} ) {
616616 return [ . format, . codeComplete, . typeContextInfo, . conformingMethodList]
617617 }
618618 if case . keyword( let keyword) = token. tokenKind, [ . get, . set, . didSet, . willSet] . contains ( keyword) {
@@ -625,7 +625,7 @@ private class ActionTokenCollector: SyntaxAnyVisitor {
625625 if token. isIdentifier {
626626 return [ . codeComplete, . typeContextInfo, . conformingMethodList]
627627 }
628- if !token. isOperator && token. ancestors. contains ( where: { ( $0. isProtocol ( ExprSyntaxProtocol . self) || $0. isProtocol ( TypeSyntaxProtocol . self) ) && $0. lastToken == token} ) {
628+ if !token. isOperator && token. ancestors. contains ( where: { ( $0. isProtocol ( ExprSyntaxProtocol . self) || $0. isProtocol ( TypeSyntaxProtocol . self) ) && $0. lastToken ( viewMode : . sourceAccurate ) == token} ) {
629629 return [ . codeComplete, . typeContextInfo, . conformingMethodList]
630630 }
631631 if case . keyword( let keyword) = token. tokenKind, [ . get, . set, . didSet, . willSet] . contains ( keyword) {
0 commit comments