File tree Expand file tree Collapse file tree 1 file changed +6
-16
lines changed
scalafix-rules/src/main/scala/scalafix/internal/rule Expand file tree Collapse file tree 1 file changed +6
-16
lines changed Original file line number Diff line number Diff line change @@ -113,22 +113,12 @@ final class DisableSyntax(config: DisableSyntaxConfig)
113
113
Diagnostic (" noXml" , " xml literals should be avoided" , token.pos)
114
114
case token : Token .Ident
115
115
if token.value == " asInstanceOf" && config.noAsInstanceOf =>
116
- val isMatchableCast = {
117
- val tokenIndex = doc.tree.tokens.indexOf(token)
118
- if (tokenIndex >= 0 ) {
119
- val subsequentTokens = doc.tree.tokens.drop(tokenIndex + 1 )
120
- val nonSpaceTokens = subsequentTokens.filterNot(_.is[Token .Space ])
121
-
122
- nonSpaceTokens.take(3 ).toList match {
123
- case (_ : Token .LeftBracket ) ::
124
- (ident : Token .Ident ) ::
125
- (_ : Token .RightBracket ) :: Nil
126
- if ident.value == " Matchable" =>
127
- true
128
- case _ => false
129
- }
130
- } else false
131
- }
116
+ val isMatchableCast =
117
+ doc.tokenList
118
+ .trailing(token)
119
+ .takeWhile(! _.is[Token .RightBracket ])
120
+ .collectFirst { case Token .Ident (" Matchable" ) => }
121
+ .isDefined
132
122
133
123
if (isMatchableCast) {
134
124
Diagnostic (
You can’t perform that action at this time.
0 commit comments