Skip to content
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

Splitting intellij module into 3 modules: core, java-psi, kotlin-psi #22

Merged
merged 12 commits into from
Dec 15, 2023

Conversation

anchouls
Copy link
Contributor

No description provided.

Copy link

@onewhl onewhl left a comment

Choose a reason for hiding this comment

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

Thank you! I have several comments.
1). I think the structure of the main and test folders should be consistent. For example, there is an inconsistency in the kotlin-psi module: org/jetbrains/academy/test/kotlin and org/jetbrains/academy/test/system/ij/kotlin. In one case you use system and in another you don't.
Screen Shot 2023-08-30 at 1 04 07 PM
2). It's not needed to add .gitignore to each module, we need one .gitingore file in the root folder.
3). I suggest renaming ij.core to ij.common, but it's a very minor thing.
Please, let me know what you think about.

@anchouls
Copy link
Contributor Author

@onewhl Thank you! About item (2) - the formatting check is the same for both Java and Kotlin, but the tests are different for them, that's why I defined it that way. But I can write tests for Java and Kotlin for the formatting function in a common module.

@onewhl
Copy link

onewhl commented Aug 30, 2023

@anchouls yes, I get it, you're absolutely right, I already removed the comment.

Copy link

@onewhl onewhl left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks!
I'm only not sure if we need to update intellij version to 1.15.0 in this PR, but if it breaks nothing, maybe it's ok.

Copy link
Collaborator

@nbirillo nbirillo left a comment

Choose a reason for hiding this comment

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

Also, please bump the framework version. I also committed a small change of the main gradle, hope you don't mind

ij/common/build.gradle.kts Outdated Show resolved Hide resolved
@@ -1,4 +1,4 @@
package org.jetbrains.academy.test.system.ij.analyzer
package org.jetbrains.academy.test.system.kotlin.ij.analyzer
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess this file has to be moved into the common module since it works with PSI elements, not with KtElements

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why? It works with KtElements

Copy link
Collaborator

Choose a reason for hiding this comment

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

Because now you have a lot of the same methods in Java and Kotlin modules, e.g.

fun PsiFile.hasClass(className: String): Boolean = hasElementOfTypeWithName(PsiClass::class.java, className

and

fun PsiFile.hasClass(className: String): Boolean = hasElementOfTypeWithName(KtClass::class.java, className)

Instead it you can move these methods in the ij core module and here just call them with necessary arguments

Copy link
Collaborator

@nbirillo nbirillo left a comment

Choose a reason for hiding this comment

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

Thank you! I have several suggestions

@@ -0,0 +1,196 @@
package org.jetbrains.academy.test.system.java.ij.analyzer
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd suggest to separate this file into several ones, since it is loo long now, e.g.:

PsiFileAnalyzerUtil
IjCodeAnalyzerUtil
PsiElementAnalyzerUtil

What do you think?

Comment on lines 167 to 186
var methodName = "method(\"Content\")"
var methodsList = listOf("outerFunction", "method2")
assert(methodsList.equals(findMethodUsages(methodName))) {
"Method $methodName should be called in methods: $methodsList"
}
methodName = "method(\"y is greater than 5\")"
methodsList = listOf("method1")
assert(methodsList.equals(findMethodUsages(methodName))) {
"Method $methodName should be called in methods: $methodsList"
}
methodName = "method(\"y is less than 5\")"
methodsList = listOf("method1")
assert(methodsList.equals(findMethodUsages(methodName))) {
"Method $methodName should be called in methods: $methodsList"
}
methodName = "method(content)"
methodsList = listOf()
assert(methodsList.equals(findMethodUsages(methodName))) {
"Method $methodName should not be called"
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we change this test into a parametrized one?


class BaseIjTestClassTests : BaseIjTestClass() {

fun testFindMethodsWithContent() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can also make this test as a parametrized one

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or at least to move common functionality and call a function here

}
""".trimIndent()
myFixture.configureByText("Task.java", example)
var expression = "productPrice.size()"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same

@@ -1,4 +1,4 @@
package org.jetbrains.academy.test.system.ij.analyzer
package org.jetbrains.academy.test.system.kotlin.ij.analyzer
Copy link
Collaborator

Choose a reason for hiding this comment

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

Because now you have a lot of the same methods in Java and Kotlin modules, e.g.

fun PsiFile.hasClass(className: String): Boolean = hasElementOfTypeWithName(PsiClass::class.java, className

and

fun PsiFile.hasClass(className: String): Boolean = hasElementOfTypeWithName(KtClass::class.java, className)

Instead it you can move these methods in the ij core module and here just call them with necessary arguments

Copy link
Collaborator

@nbirillo nbirillo left a comment

Choose a reason for hiding this comment

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

Thank you!

@nbirillo nbirillo merged commit 282faa4 into main Dec 15, 2023
4 checks passed
@nbirillo nbirillo deleted the intellij-java-module branch December 15, 2023 12:24
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.

3 participants