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

Fix PsiClass.packageName extension #101

Merged
merged 6 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ object ProtoData {
* The version of ProtoData dependencies.
*/
val version: String
private const val fallbackVersion = "0.60.2"
private const val fallbackVersion = "0.61.3"

/**
* The distinct version of ProtoData used by other build tools.
Expand All @@ -74,7 +74,7 @@ object ProtoData {
* transitional dependencies, this is the version used to build the project itself.
*/
val dogfoodingVersion: String
private const val fallbackDfVersion = "0.60.2"
private const val fallbackDfVersion = "0.61.3"

/**
* The artifact for the ProtoData Gradle plugin.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ object Spine {
*
* @see <a href="https://github.com/SpineEventEngine/base">spine-base</a>
*/
const val base = "2.0.0-SNAPSHOT.211"
const val base = "2.0.0-SNAPSHOT.212"

/**
* The version of [Spine.reflect].
Expand Down Expand Up @@ -89,7 +89,7 @@ object Spine {
*
* @see <a href="https://github.com/SpineEventEngine/mc-java">spine-mc-java</a>
*/
const val mcJava = "2.0.0-SNAPSHOT.217"
const val mcJava = "2.0.0-SNAPSHOT.241"

/**
* The version of [Spine.baseTypes].
Expand Down
28 changes: 14 additions & 14 deletions dependencies.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


# Dependencies of `io.spine.tools:spine-plugin-base:2.0.0-SNAPSHOT.225`
# Dependencies of `io.spine.tools:spine-plugin-base:2.0.0-SNAPSHOT.226`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -752,12 +752,12 @@

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Sun Sep 15 17:54:57 WEST 2024** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Mon Oct 07 19:46:39 WEST 2024** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine.tools:spine-plugin-testlib:2.0.0-SNAPSHOT.225`
# Dependencies of `io.spine.tools:spine-plugin-testlib:2.0.0-SNAPSHOT.226`

## Runtime
1. **Group** : com.google.auto.value. **Name** : auto-value-annotations. **Version** : 1.10.2.
Expand Down Expand Up @@ -1620,12 +1620,12 @@ This report was generated on **Sun Sep 15 17:54:57 WEST 2024** using [Gradle-Lic

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Sun Sep 15 17:54:58 WEST 2024** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Mon Oct 07 19:46:40 WEST 2024** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine.tools:spine-psi:2.0.0-SNAPSHOT.225`
# Dependencies of `io.spine.tools:spine-psi:2.0.0-SNAPSHOT.226`

## Runtime
1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3.
Expand Down Expand Up @@ -2631,12 +2631,12 @@ This report was generated on **Sun Sep 15 17:54:58 WEST 2024** using [Gradle-Lic

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Sun Sep 15 17:54:58 WEST 2024** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Mon Oct 07 19:46:40 WEST 2024** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine.tools:spine-psi-java:2.0.0-SNAPSHOT.225`
# Dependencies of `io.spine.tools:spine-psi-java:2.0.0-SNAPSHOT.226`

## Runtime
1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3.
Expand Down Expand Up @@ -4320,12 +4320,12 @@ This report was generated on **Sun Sep 15 17:54:58 WEST 2024** using [Gradle-Lic

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Sun Sep 15 17:54:59 WEST 2024** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Mon Oct 07 19:46:40 WEST 2024** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine.tools:spine-psi-java-bundle-jar:2.0.0-SNAPSHOT.225`
# Dependencies of `io.spine.tools:spine-psi-java-bundle-jar:2.0.0-SNAPSHOT.226`

## Runtime
1. **Group** : be.cyberelf.nanoxml. **Name** : nanoxml. **Version** : 2.2.3.
Expand Down Expand Up @@ -5944,12 +5944,12 @@ This report was generated on **Sun Sep 15 17:54:59 WEST 2024** using [Gradle-Lic

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Sun Sep 15 17:54:59 WEST 2024** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Mon Oct 07 19:46:41 WEST 2024** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine.tools:spine-psi-java-bundle-test:2.0.0-SNAPSHOT.225`
# Dependencies of `io.spine.tools:spine-psi-java-bundle-test:2.0.0-SNAPSHOT.226`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -6645,12 +6645,12 @@ This report was generated on **Sun Sep 15 17:54:59 WEST 2024** using [Gradle-Lic

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Sun Sep 15 17:55:00 WEST 2024** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Mon Oct 07 19:46:41 WEST 2024** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine.tools:spine-tool-base:2.0.0-SNAPSHOT.225`
# Dependencies of `io.spine.tools:spine-tool-base:2.0.0-SNAPSHOT.226`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -7451,4 +7451,4 @@ This report was generated on **Sun Sep 15 17:55:00 WEST 2024** using [Gradle-Lic

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Sun Sep 15 17:55:00 WEST 2024** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Mon Oct 07 19:46:41 WEST 2024** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ all modules and does not describe the project structure per-subproject.
-->
<groupId>io.spine.tools</groupId>
<artifactId>tool-base</artifactId>
<version>2.0.0-SNAPSHOT.225</version>
<version>2.0.0-SNAPSHOT.226</version>

<inceptionYear>2015</inceptionYear>

Expand Down Expand Up @@ -146,7 +146,7 @@ all modules and does not describe the project structure per-subproject.
<dependency>
<groupId>io.spine</groupId>
<artifactId>spine-base</artifactId>
<version>2.0.0-SNAPSHOT.211</version>
<version>2.0.0-SNAPSHOT.212</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ public fun PsiClass.method(name: String): PsiMethod {
*/
public val PsiClass.packageName: String
get() {
var current = this;
var current = this
while (current.containingClass != null) {
current = containingClass!!
current = current.containingClass!!
}
val qualifiedName = current.qualifiedName
val result = qualifiedName?.substringBeforeLast('.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,39 @@ internal class PsiClassExtsSpec: PsiTest() {
cls.implements(inAnotherPackage) shouldBe true
}
}

@Nested inner class
`obtain a package` {

@Test
fun `of top level class`() {
cls.packageName shouldBe packageName
}

@Test
fun `of a nested class`() {
val nestedClassName = "Nested"
val nested = elementFactory.createClass(nestedClassName)
execute {
cls.addLast(nested)
}
cls.findInnerClassByName(nestedClassName, false)!!.packageName shouldBe packageName
}

@Test
fun `of a deeper nested class`() {
val level2 = "Level2"
val level3 = "Level3"
val level2Class = elementFactory.createClass(level2)
val level3Class = elementFactory.createClass(level3)

execute {
level2Class.addLast(level3Class)
cls.addLast(level2Class)
}

cls.findInnerClassByName(level2, false)!!
.findInnerClassByName(level3, false)!!.packageName shouldBe packageName
}
}
}
2 changes: 1 addition & 1 deletion version.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

val versionToPublish: String by extra("2.0.0-SNAPSHOT.225")
val versionToPublish: String by extra("2.0.0-SNAPSHOT.226")
Loading