-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use ExtractorBase for Swift #346
Conversation
} | ||
object SwiftExtractor : ExtractorBase( | ||
language = Lang.SWIFT, | ||
importRegex = Regex("""^(.*import)\s[^\n]*"""), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extractImportRegex
used for actually extracting of imports for choosing right classifiers
importRegex
used to filter tokens from imports and as @yaronskaya works slightly faster
Here importRegex
(less accurate version) used for both extracting and filter tokens. @yaronskaya review this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anatolystansler Curious, whether it is noticeable at all. Having two nearly identical regexps affects on code readability and its maintenance. So if it's not a perf problem, then I would choose simplicity over optimization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asurkov this regex doesn't extract imports. Please, use 'extractImportRegex' from previous version of SwiftExtractor. I wonder if it passes tests:)
} | ||
object SwiftExtractor : ExtractorBase( | ||
language = Lang.SWIFT, | ||
importRegex = Regex("""^(.*import)\s[^\n]*"""), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asurkov this regex doesn't extract imports. Please, use 'extractImportRegex' from previous version of SwiftExtractor. I wonder if it passes tests:)
@yaronskaya now I see what you say. The tests indeed pass, which means it has to be a problem with the tests. For example, there's one |
@asurkov it turned out that we don't have tests of imports for Swift, there are only tests for libraries extraction. Could you please add them? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Please address the comment and we will merge it.
"import UIKit" | ||
) | ||
var actualLineImports = SwiftExtractor.extractImports(lines) | ||
assertEquals(actualLineImports, listOf("UIKit")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use assertExtractsImport
No description provided.