Skip to content

Commit

Permalink
REVIEW: IDE error markers over lack of this keyword use
Browse files Browse the repository at this point in the history
".... can't be called from this context by implicit receiver.
 Use the explicit one if necessary"

Think it is an IDE issue using 1.9.21 capable editor against
a 1.3 configured codebase?
  • Loading branch information
dlmiles committed Dec 11, 2023
1 parent 88c2712 commit cc7ee17
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.gradle.testkit.runner.TaskOutcome
fun Assert<BuildResult>.task(taskPath: String) =
transform(name = "task $taskPath") { actual ->
actual.task(taskPath)
?: expected("to include task '$taskPath', but was: ${show(actual.tasks.map { it.path })}")
?: this.expected("to include task '$taskPath', but was: ${show(actual.tasks.map { it.path })}")
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ object XjcGenerateTest : Spek({
}

assertThat(task, "task").all {
prop(XjcGenerate::targetVersion).hasValueEqualTo("XYZ")
prop(XjcGenerate::encoding).hasValueEqualTo("ISO-8859-1")
prop(XjcGenerate::docLocale).hasValueEqualTo(Locale.ITALIAN.toString())
prop(XjcGenerate::strictCheck).isFalse()
prop(XjcGenerate::packageLevelAnnotations).isFalse()
prop(XjcGenerate::noFileHeader).isFalse()
prop(XjcGenerate::enableIntrospection).isTrue()
prop(XjcGenerate::contentForWildcard).isTrue()
prop(XjcGenerate::readOnly).isTrue()
prop(XjcGenerate::extension).isTrue()
this.prop(XjcGenerate::targetVersion).hasValueEqualTo("XYZ")
this.prop(XjcGenerate::encoding).hasValueEqualTo("ISO-8859-1")
this.prop(XjcGenerate::docLocale).hasValueEqualTo(Locale.ITALIAN.toString())
this.prop(XjcGenerate::strictCheck).isFalse()
this.prop(XjcGenerate::packageLevelAnnotations).isFalse()
this.prop(XjcGenerate::noFileHeader).isFalse()
this.prop(XjcGenerate::enableIntrospection).isTrue()
this.prop(XjcGenerate::contentForWildcard).isTrue()
this.prop(XjcGenerate::readOnly).isTrue()
this.prop(XjcGenerate::extension).isTrue()
}
}

Expand Down Expand Up @@ -104,9 +104,9 @@ object XjcGenerateTest : Spek({

it("should create an XjcGenerate task for each existing source set") {
assertThat(project.tasks, name = "tasks").all {
containsItem("xjcGenerate")
this.containsItem("xjcGenerate")
.isInstanceOf(XjcGenerate::class)
containsItem("xjcGenerateTest")
this.containsItem("xjcGenerateTest")
.isInstanceOf(XjcGenerate::class)
}
}
Expand All @@ -125,13 +125,13 @@ object XjcGenerateTest : Spek({
}

assertThat(task, name = "task").all {
prop(XjcGenerate::source)
this.prop(XjcGenerate::source)
.containsOnly(project.file("src/main/schema/schema.xsd"))
prop(XjcGenerate::bindingFiles)
this.prop(XjcGenerate::bindingFiles)
.containsOnly(project.file("src/main/schema/binding.xjb"))
prop(XjcGenerate::urlSources)
this.prop(XjcGenerate::urlSources)
.containsOnly(project.file("src/main/schema/externals.url"))
prop(XjcGenerate::catalogs)
this.prop(XjcGenerate::catalogs)
.containsOnly(project.file("src/main/schema/catalog.cat"))
}
}
Expand All @@ -148,9 +148,9 @@ object XjcGenerateTest : Spek({
)

assertThat(task, name = "task").all {
prop(XjcGenerate::pluginClasspath)
this.prop(XjcGenerate::pluginClasspath)
.containsOnly(project.file("custom-jaxb-plugin-1.2.3.jar"))
prop(XjcGenerate::episodes)
this.prop(XjcGenerate::episodes)
.containsOnly(project.file("custom-episode-1.2.3.jar"))
}
}
Expand All @@ -162,7 +162,7 @@ object XjcGenerateTest : Spek({
val resolved = XjcGenerate.resolveArtifactsForMavenUri(catalogResolutionConfig)

assertThat(task, name = "task").all {
prop(XjcGenerate::catalogSerializableResolvedArtifact)
this.prop(XjcGenerate::catalogSerializableResolvedArtifact)
.hasValueEqualTo(resolved)
}
}
Expand All @@ -178,9 +178,9 @@ object XjcGenerateTest : Spek({
xjcSourceSetConvention.xjcGenerateEpisode.set(true)

assertThat(task, name = "task").all {
prop(XjcGenerate::targetPackage)
this.prop(XjcGenerate::targetPackage)
.hasValueEqualTo("com.example")
prop(XjcGenerate::generateEpisode)
this.prop(XjcGenerate::generateEpisode)
.hasValueEqualTo(true)
}
}
Expand Down Expand Up @@ -211,9 +211,9 @@ object XjcGenerateTest : Spek({
val task = project.tasks.getByName("xjcGenerate") as XjcGenerate

assertThat(task, name = "task").all {
prop(XjcGenerate::outputDirectory)
this.prop(XjcGenerate::outputDirectory)
.dirValue().isEqualTo(project.file("build/generated/sources/xjc/java/main"))
prop(XjcGenerate::episodeOutputDirectory)
this.prop(XjcGenerate::episodeOutputDirectory)
.dirValue().isEqualTo(project.file("build/generated/resources/xjc/main"))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,9 @@ import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.tasks.SourceSetContainer
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
import org.unbrokendome.gradle.plugins.xjc.testutil.assertions.containsItem
import org.unbrokendome.gradle.plugins.xjc.testutil.assertions.hasConvention
import org.unbrokendome.gradle.plugins.xjc.testutil.assertions.hasExtension
import org.unbrokendome.gradle.plugins.xjc.testutil.assertions.hasValueEqualTo
import org.unbrokendome.gradle.plugins.xjc.spek.applyPlugin
import org.unbrokendome.gradle.plugins.xjc.spek.setupGradleProject
import org.unbrokendome.gradle.plugins.xjc.testutil.assertions.extendsOnlyFrom
import org.unbrokendome.gradle.plugins.xjc.testutil.assertions.isFalse
import org.unbrokendome.gradle.plugins.xjc.testutil.assertions.isTrue
import org.unbrokendome.gradle.plugins.xjc.testutil.assertions.*
import org.unbrokendome.gradle.plugins.xjc.testutil.evaluate
import org.unbrokendome.gradle.plugins.xjc.testutil.requiredExtension
import org.unbrokendome.gradle.plugins.xjc.testutil.sourceSets
Expand Down Expand Up @@ -48,17 +42,17 @@ object XjcPluginTest : Spek({
it("xjc DSL extension should apply defaults") {
assertThat(project)
.hasExtension<XjcExtension>().all {
prop(XjcExtension::xjcVersion).hasValueEqualTo(XjcExtension.DEFAULT_XJC_VERSION)
prop(XjcExtension::xjcVersionUnsupportedStrategy).hasValueEqualTo(XjcExtension.DEFAULT_XJC_VERSION_UNSUPPORTED_STRATEGY)
prop(XjcExtension::srcDirName).hasValueEqualTo(XjcExtension.DEFAULT_SRC_DIR_NAME)
prop(XjcExtension::encoding).hasValueEqualTo("UTF-8")
prop(XjcExtension::strictCheck).isTrue()
prop(XjcExtension::packageLevelAnnotations).isTrue()
prop(XjcExtension::noFileHeader).isTrue()
prop(XjcExtension::enableIntrospection).isFalse()
prop(XjcExtension::contentForWildcard).isFalse()
prop(XjcExtension::readOnly).isFalse()
prop(XjcExtension::extension).isFalse()
this.prop(XjcExtension::xjcVersion).hasValueEqualTo(XjcExtension.DEFAULT_XJC_VERSION)
this.prop(XjcExtension::xjcVersionUnsupportedStrategy).hasValueEqualTo(XjcExtension.DEFAULT_XJC_VERSION_UNSUPPORTED_STRATEGY)
this.prop(XjcExtension::srcDirName).hasValueEqualTo(XjcExtension.DEFAULT_SRC_DIR_NAME)
this.prop(XjcExtension::encoding).hasValueEqualTo("UTF-8")
this.prop(XjcExtension::strictCheck).isTrue()
this.prop(XjcExtension::packageLevelAnnotations).isTrue()
this.prop(XjcExtension::noFileHeader).isTrue()
this.prop(XjcExtension::enableIntrospection).isFalse()
this.prop(XjcExtension::contentForWildcard).isFalse()
this.prop(XjcExtension::readOnly).isFalse()
this.prop(XjcExtension::extension).isFalse()
}
}

Expand All @@ -81,28 +75,28 @@ object XjcPluginTest : Spek({

assertThat(project)
.hasExtension<XjcExtension>().all {
prop(XjcExtension::xjcVersion).hasValueEqualTo("3.0")
prop(XjcExtension::xjcVersionUnsupportedStrategy).hasValueEqualTo("default")
prop(XjcExtension::srcDirName).hasValueEqualTo("xjc")
prop(XjcExtension::targetVersion).hasValueEqualTo("2.2")
prop(XjcExtension::encoding).hasValueEqualTo("ISO-8859-1")
prop(XjcExtension::docLocale).hasValueEqualTo(Locale.ITALIAN.toString())
prop(XjcExtension::strictCheck).isFalse()
prop(XjcExtension::packageLevelAnnotations).isFalse()
prop(XjcExtension::noFileHeader).isFalse()
prop(XjcExtension::enableIntrospection).isTrue()
prop(XjcExtension::contentForWildcard).isTrue()
prop(XjcExtension::readOnly).isTrue()
prop(XjcExtension::extension).isTrue()
this.prop(XjcExtension::xjcVersion).hasValueEqualTo("3.0")
this.prop(XjcExtension::xjcVersionUnsupportedStrategy).hasValueEqualTo("default")
this.prop(XjcExtension::srcDirName).hasValueEqualTo("xjc")
this.prop(XjcExtension::targetVersion).hasValueEqualTo("2.2")
this.prop(XjcExtension::encoding).hasValueEqualTo("ISO-8859-1")
this.prop(XjcExtension::docLocale).hasValueEqualTo(Locale.ITALIAN.toString())
this.prop(XjcExtension::strictCheck).isFalse()
this.prop(XjcExtension::packageLevelAnnotations).isFalse()
this.prop(XjcExtension::noFileHeader).isFalse()
this.prop(XjcExtension::enableIntrospection).isTrue()
this.prop(XjcExtension::contentForWildcard).isTrue()
this.prop(XjcExtension::readOnly).isTrue()
this.prop(XjcExtension::extension).isTrue()
}
}


it("should create global XJC configurations") {
assertThat(project.configurations, "configurations").all {
containsItem("xjcTool")
containsItem("xjcClasspathGlobal")
containsItem("xjcCatalogResolutionGlobal")
this.containsItem("xjcTool")
this.containsItem("xjcClasspathGlobal")
this.containsItem("xjcCatalogResolutionGlobal")
}
}
}
Expand All @@ -119,9 +113,9 @@ object XjcPluginTest : Spek({
val sourceSets = project.extensions.getByType(SourceSetContainer::class.java)

assertThat(sourceSets).all {
containsItem("main")
this.containsItem("main")
.hasConvention<XjcSourceSetConvention>()
containsItem("test")
this.containsItem("test")
.hasConvention<XjcSourceSetConvention>()
}
}
Expand All @@ -136,17 +130,17 @@ object XjcPluginTest : Spek({

it("should create XJC configurations for each existing source set") {
assertThat(project.configurations, name = "configurations").all {
containsItem("xjcClasspath")
this.containsItem("xjcClasspath")
.extendsOnlyFrom("xjcClasspathGlobal")
containsItem("xjcEpisodes")
containsItem("xjcCatalogResolution").all {
this.containsItem("xjcEpisodes")
this.containsItem("xjcCatalogResolution").all {
extendsOnlyFrom("xjcCatalogResolutionGlobal", "compileClasspath")
}

containsItem("testXjcClasspath")
this.containsItem("testXjcClasspath")
.extendsOnlyFrom("xjcClasspathGlobal")
containsItem("testXjcEpisodes")
containsItem("testXjcCatalogResolution").all {
this.containsItem("testXjcEpisodes")
this.containsItem("testXjcCatalogResolution").all {
extendsOnlyFrom("xjcCatalogResolutionGlobal", "testCompileClasspath")
}
}
Expand All @@ -156,7 +150,7 @@ object XjcPluginTest : Spek({
it("should create XJC configurations for each new source set") {
project.sourceSets.create("foo")
assertThat(project.configurations, name = "configurations").all {
containsItem("fooXjcClasspath")
this.containsItem("fooXjcClasspath")
.extendsOnlyFrom("xjcClasspathGlobal")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ object XjcSourceSetConventionTest : Spek({

it("should return the correct task and configuration names") {
assertThat(xjcSourceSetConvention).all {
prop(XjcSourceSetConvention::xjcGenerateTaskName)
this.prop(XjcSourceSetConvention::xjcGenerateTaskName)
.isEqualTo("xjcGenerate")
prop(XjcSourceSetConvention::xjcClasspathConfigurationName)
this.prop(XjcSourceSetConvention::xjcClasspathConfigurationName)
.isEqualTo("xjcClasspath")
prop(XjcSourceSetConvention::xjcEpisodesConfigurationName)
this.prop(XjcSourceSetConvention::xjcEpisodesConfigurationName)
.isEqualTo("xjcEpisodes")
prop(XjcSourceSetConvention::xjcCatalogResolutionConfigurationName)
this.prop(XjcSourceSetConvention::xjcCatalogResolutionConfigurationName)
.isEqualTo("xjcCatalogResolution")
}
}
Expand All @@ -66,27 +66,27 @@ object XjcSourceSetConventionTest : Spek({

it("should return the correct task and configuration names") {
assertThat(xjcSourceSetConvention).all {
prop(XjcSourceSetConvention::xjcGenerateTaskName)
this.prop(XjcSourceSetConvention::xjcGenerateTaskName)
.isEqualTo("xjcGenerateCustom")
prop(XjcSourceSetConvention::xjcClasspathConfigurationName)
this.prop(XjcSourceSetConvention::xjcClasspathConfigurationName)
.isEqualTo("customXjcClasspath")
prop(XjcSourceSetConvention::xjcEpisodesConfigurationName)
this.prop(XjcSourceSetConvention::xjcEpisodesConfigurationName)
.isEqualTo("customXjcEpisodes")
prop(XjcSourceSetConvention::xjcCatalogResolutionConfigurationName)
this.prop(XjcSourceSetConvention::xjcCatalogResolutionConfigurationName)
.isEqualTo("customXjcCatalogResolution")
}
}


it("should set default include filters") {
assertThat(xjcSourceSetConvention).all {
prop("xjcSchema") { it.xjcSchema }
this.prop("xjcSchema") { it.xjcSchema }
.prop("includes") { it.includes }
.containsOnly("**/*.xsd")
prop("xjcBinding") { it.xjcBinding }
this.prop("xjcBinding") { it.xjcBinding }
.prop("includes") { it.includes }
.containsOnly("**/*.xjb")
prop("xjcUrl") { it.xjcUrl }
this.prop("xjcUrl") { it.xjcUrl }
.prop("includes") { it.includes }
.containsOnly("**/*.url")
}
Expand All @@ -98,13 +98,13 @@ object XjcSourceSetConventionTest : Spek({
xjc.srcDirName.set("xjc")

assertThat(xjcSourceSetConvention).all {
prop("xjcSchema") { it.xjcSchema }
this.prop("xjcSchema") { it.xjcSchema }
.prop("srcDirs") { it.srcDirs }
.containsOnly(project.file("src/custom/xjc"))
prop("xjcBinding") { it.xjcBinding }
this.prop("xjcBinding") { it.xjcBinding }
.prop("srcDirs") { it.srcDirs }
.containsOnly(project.file("src/custom/xjc"))
prop("xjcUrl") { it.xjcUrl }
this.prop("xjcUrl") { it.xjcUrl }
.prop("srcDirs") { it.srcDirs }
.containsOnly(project.file("src/custom/xjc"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.gradle.api.artifacts.Configuration

fun Assert<Configuration>.extendsFrom(other: String) = given { actual ->
if (other in actual.extendsFrom.map { it.name }) return
expected(
this.expected(
"to extend from configuration \"$other\", but extends from: ${show(actual.extendsFrom)}",
actual = actual.extendsFrom, expected = other
)
Expand All @@ -21,7 +21,7 @@ fun Assert<Configuration>.extendsOnlyFrom(vararg others: String) = given { actua
val extendsFromNames = actual.extendsFrom.map { it.name }.toSet()
if (others.toSet() == extendsFromNames) return

expected(
this.expected(
"to extend only from configuration(s) ${show(others)}, but extends from: ${show(extendsFromNames)}",
actual = extendsFromNames, expected = others
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import org.gradle.api.NamedDomainObjectCollection

fun <T : Any> Assert<NamedDomainObjectCollection<T>>.containsItem(name: String) =
transform(name = "${this.name}[\"$name\"]") { actual ->
actual.findByName(name) ?: expected("to contain an item named \"$name\"", actual = actual.names)
actual.findByName(name) ?: this.expected("to contain an item named \"$name\"", actual = actual.names)
}


fun <T : Any> Assert<NamedDomainObjectCollection<T>>.doesNotContainItem(name: String) = given { actual ->
val item = actual.findByName(name)
if (item != null) {
expected("to contain no item named \"$name\", but did contain: ${show(item)}", actual = actual.names)
this.expected("to contain no item named \"$name\", but did contain: ${show(item)}", actual = actual.names)
}
}
Loading

0 comments on commit cc7ee17

Please sign in to comment.