Skip to content

Conversation

@yaronskaya
Copy link
Contributor

No description provided.

Copy link
Member

@astansler astansler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some description of PR next time. Describe what you did and your intention on merging to master or just to keeping an updates on WIP.
Possibly regexs not working and can be optimized, I include fix in comments. Also, we should make tests in next PR.
I will implement empty methods and integrate those classes.

override fun extractImports(fileContent: List<String>): List<String> {
val libraries = mutableSetOf<String>()

val quoteRegex = Regex("#import\\s+\"(\\w+)[/\\w+]*\\.\\w+\"")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test it? Probably shouldn't work.
Also, you can use only one regex with OR: #import\s+[\"|<](\w+)[/\w+]*.\w+[\"|>]

Copy link
Member

@astansler astansler Sep 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix double slash everywhere.
updates: Double slash ok here, but better to use triple quotes.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#include maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

override fun extractImports(fileContent: List<String>): List<String> {
val libraries = mutableSetOf<String>()

val regex = Regex("use\\s+(\\w+)[\\\\\\w+]*")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

require, require_once?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include, include once?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

override fun extractImports(fileContent: List<String>): List<String> {
val libraries = mutableSetOf<String>()

val csLibraries = File("data/libraries/cs_libraries.txt")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be definitely optimized cuz everytime extractImports called a file will be read. IO operations take a lot of time. I'll do it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

override fun extractImports(fileContent: List<String>): List<String> {
val libraries = mutableSetOf<String>()

val javaLibraries = File("data/libraries/java_libraries.txt")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some Extractors you using list of imports, in some not, why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends. In js, there are sometimes no import lines, that's why we tokenize all lines and see what tokens are in the import list. In this case we should catch things like ((com|ru).)?organization.library.modules.* and also skip imports of inner files.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you gonna use this libraries files in a classifier for every language?

override fun extractImports(fileContent: List<String>): List<String> {
val libraries = mutableSetOf<String>()

val importQuotesRegex = Regex("#import\\s+\"(\\w+)[/\\w+]*\\.\\w+\"")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use OR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

import app.model.DiffFile
import java.io.File

class CsharpExtractor : ExtractorInterface {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CSharpExtractor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.


class CExtractor : ExtractorInterface {
override fun extract(files: List<DiffFile>): List<CommitStats> {
TODO("not implemented")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mean that exception will be thrown if this method will be called. Not a good idea to merge such things to master.

@astansler astansler changed the title Add import detection(APP-77) feat: add import detection (APP-77) Sep 8, 2017
override fun extractImports(fileContent: List<String>): List<String> {
val libraries = mutableSetOf<String>()

val quoteRegex = Regex("#import\\s+\"(\\w+)[/\\w+]*\\.\\w+\"")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#include maybe?

override fun extractImports(fileContent: List<String>): List<String> {
val libraries = mutableSetOf<String>()

val quoteRegex = Regex("#import\\s+\"(\\w+)[/\\w+]*\\.\\w+\"")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

val regex = Regex("import\\s+(\\w+[.\\w+]*)")
fileContent.forEach {
val res = regex.find(it)
if (res != null) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (res == null) return – inverse it to achieve lesser amount of nesting

override fun extractImports(fileContent: List<String>): List<String> {
val libraries = mutableSetOf<String>()

val regex = Regex("use\\s+(\\w+)[\\\\\\w+]*")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include, include once?

Copy link
Member

@sergey48k sergey48k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved by see comments

files.map { file ->
file.old.imports = extractImports(file.old.content)
file.new.imports = extractImports(file.new.content)
file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last line is return value.

val TYPE_LANGUAGE = 1
val TYPE_KEYWORD = 2

val SEPARATOR = ">"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this used at all? maybe it can be removed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used in JavaExtractor for example to separate language from tech (or keywords, etc). "Java>Keyword".


package app.model

import org.eclipse.jgit.diff.Edit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copyright/author

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is.

@astansler astansler merged commit 03dec51 into master Sep 11, 2017
@astansler astansler deleted the APP-77 branch September 11, 2017 10:03
asurkov pushed a commit that referenced this pull request Sep 11, 2017
* feat: add import detection(APP-77)

* feat: integrate import detection

* feat: add data for libraries, fix php regex matching
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants