diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index df351f1..4ab34ca 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,7 +42,7 @@ jobs: # Validate wrapper - name: Gradle Wrapper Validation - uses: gradle/wrapper-validation-action@v2.1.1 + uses: gradle/wrapper-validation-action@v2.1.2 # Set up Java environment for the next steps - name: Setup Java @@ -170,7 +170,7 @@ jobs: # Run Qodana inspections - name: Qodana - Code Inspection - uses: JetBrains/qodana-action@v2023.3.1 + uses: JetBrains/qodana-action@v2023.3.2 with: cache-default-branch-only: true @@ -207,7 +207,7 @@ jobs: # Cache Plugin Verifier IDEs - name: Setup Plugin Verifier IDEs Cache - uses: actions/cache@v4.0.1 + uses: actions/cache@v4.0.2 with: path: ${{ needs.build.outputs.pluginVerifierHomeDir }}/ides key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 25d26fb..ce244df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ## [Unreleased] +- Removed queryBuilder from code completion + ## [0.10.0] - 2024-03-13 - Added table view as IDE table diff --git a/gradle.properties b/gradle.properties index 5497ca1..8ff4afe 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ pluginGroup = com.github.bobi.aemgroovyconsoleplugin pluginName = aem-groovyconsole-plugin pluginRepositoryUrl = https://github.com/bobi/aem-groovyconsole-plugin # SemVer format -> https://semver.org -pluginVersion = 0.10.0 +pluginVersion = 0.10.1 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html pluginSinceBuild = 232 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 56fbf07..f4165be 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,13 +5,13 @@ groovyConsole = "19.0.5" aecu = "6.5.0" okhttp = "4.12.0" jjwt = "0.12.5" -fastcsv = "3.0.0" +fastcsv = "3.1.0" # plugins kotlin = "1.9.23" changelog = "2.2.0" gradleIntelliJPlugin = "1.17.2" -qodana = "2023.3.1" +qodana = "2023.3.2" kover = "0.7.6" [libraries] diff --git a/src/main/kotlin/com/github/bobi/aemgroovyconsoleplugin/execution/table/AemConsoleTableSearchSession.kt b/src/main/kotlin/com/github/bobi/aemgroovyconsoleplugin/execution/table/AemConsoleTableSearchSession.kt index fe2e6c3..67d9bde 100644 --- a/src/main/kotlin/com/github/bobi/aemgroovyconsoleplugin/execution/table/AemConsoleTableSearchSession.kt +++ b/src/main/kotlin/com/github/bobi/aemgroovyconsoleplugin/execution/table/AemConsoleTableSearchSession.kt @@ -202,45 +202,6 @@ internal class AemConsoleTableSearchSession( return null } - private fun getSearchCellsRange( - startRow: Int, - startColumn: Int, - rowCount: Int, - columnCount: Int, - forward: Boolean, - includeStartCell: Boolean - ): Sequence { - val tableRange = 0 until rowCount * columnCount - - val startCell = min(tableRange.last, max(tableRange.first, startRow * columnCount + startColumn)) - - val step = if (forward) 1 else -1 - val advance = if (includeStartCell) 0 else step - - val rangeStart = startCell + advance - val rangeEnd = rangeStart - step - - var seq = emptySequence() - - if (forward) { - if (rangeStart in tableRange) { - seq += IntProgression.fromClosedRange(rangeStart, tableRange.last, step).asSequence() - } - if (rangeEnd in tableRange) { - seq += IntProgression.fromClosedRange(tableRange.first, rangeEnd, step).asSequence() - } - } else { - if (rangeStart in tableRange) { - seq += IntProgression.fromClosedRange(rangeStart, tableRange.first, step).asSequence() - } - if (rangeEnd in tableRange) { - seq += IntProgression.fromClosedRange(tableRange.last, rangeEnd, step).asSequence() - } - } - - return seq - } - fun isMatchText(text: String): Boolean { return findManager.findString(text, 0, findModel).isStringFound } @@ -261,6 +222,47 @@ internal class AemConsoleTableSearchSession( } } } + + companion object { + internal fun getSearchCellsRange( + startRow: Int, + startColumn: Int, + rowCount: Int, + columnCount: Int, + forward: Boolean, + includeStartCell: Boolean + ): Sequence { + val tableRange = 0 until rowCount * columnCount + + val startCell = min(tableRange.last, max(tableRange.first, startRow * columnCount + startColumn)) + + val step = if (forward) 1 else -1 + val advance = if (includeStartCell) 0 else step + + val rangeStart = startCell + advance + val rangeEnd = rangeStart - step + + var seq = emptySequence() + + if (forward) { + if (rangeStart in tableRange) { + seq += IntProgression.fromClosedRange(rangeStart, tableRange.last, step).asSequence() + } + if (rangeEnd in tableRange) { + seq += IntProgression.fromClosedRange(tableRange.first, rangeEnd, step).asSequence() + } + } else { + if (rangeStart in tableRange) { + seq += IntProgression.fromClosedRange(rangeStart, tableRange.first, step).asSequence() + } + if (rangeEnd in tableRange) { + seq += IntProgression.fromClosedRange(tableRange.last, rangeEnd, step).asSequence() + } + } + + return seq + } + } } interface AemConsoleTableSearchComponentListener { diff --git a/src/main/resources/standardDsls/aem.gdsl b/src/main/resources/standardDsls/aem.gdsl index c9a34d3..dbf878f 100644 --- a/src/main/resources/standardDsls/aem.gdsl +++ b/src/main/resources/standardDsls/aem.gdsl @@ -52,7 +52,6 @@ contributor(aemContext()) { field name: 'session', type: 'javax.jcr.Session' field name: 'pageManager', type: 'com.day.cq.wcm.api.PageManager' field name: 'resourceResolver', type: 'org.apache.sling.api.resource.ResourceResolver' - field name: 'queryBuilder', type: 'com.day.cq.search.QueryBuilder' field name: 'nodeBuilder', type: 'be.orbinson.aem.groovy.console.builders.NodeBuilder' field name: 'pageBuilder', type: 'be.orbinson.aem.groovy.console.builders.PageBuilder' field name: 'bundleContext', type: 'org.osgi.framework.BundleContext' diff --git a/src/test/kotlin/com/github/bobi/aemgroovyconsoleplugin/execution/table/AemConsoleTableSearchSessionTest.kt b/src/test/kotlin/com/github/bobi/aemgroovyconsoleplugin/execution/table/AemConsoleTableSearchSessionTest.kt new file mode 100644 index 0000000..c2e15e6 --- /dev/null +++ b/src/test/kotlin/com/github/bobi/aemgroovyconsoleplugin/execution/table/AemConsoleTableSearchSessionTest.kt @@ -0,0 +1,132 @@ +package com.github.bobi.aemgroovyconsoleplugin.execution.table + +import org.junit.Assert.assertEquals +import org.junit.Test + + +/** + * User: Andrey Bardashevsky + * Date/Time: 2024-03-15 20:06 + */ + +/* Table: + 0 1 2 3 4 + 5 6 7 8 9 + 10 11 12 13 14 + 15 16 17 18 19 + 20 21 22 23 24 + */ + +class AemConsoleTableSearchSessionTest { + private val rowCount = 5 + + private val columnCount = 5 + + @Test + fun getSearchCellsRangeForwardIncludeStart() { + val forward = true + val includeStartCell = true + + assertEquals( + ((6..24) + (0..5)).toList(), + AemConsoleTableSearchSession.getSearchCellsRange( + 1, 1, rowCount, columnCount, forward, includeStartCell + ).toList(), + ) + + assertEquals( + (0..24).toList(), + AemConsoleTableSearchSession.getSearchCellsRange( + -1, -1, rowCount, columnCount, forward, includeStartCell + ).toList(), + ) + + assertEquals( + ((24..24) + (0..23)).toList(), + AemConsoleTableSearchSession.getSearchCellsRange( + 10, 10, rowCount, columnCount, forward, includeStartCell + ).toList(), + ) + } + + @Test + fun getSearchCellsRangeBackwardIncludeStart() { + val forward = false + val includeStartCell = true + + assertEquals( + ((6 downTo 0) + (24 downTo 7)).toList(), + AemConsoleTableSearchSession.getSearchCellsRange( + 1, 1, rowCount, columnCount, forward, includeStartCell + ).toList(), + ) + + assertEquals( + ((0..0) + (24 downTo 1)).toList(), + AemConsoleTableSearchSession.getSearchCellsRange( + -1, -1, rowCount, columnCount, forward, includeStartCell + ).toList(), + ) + + assertEquals( + (24 downTo 0).toList(), + AemConsoleTableSearchSession.getSearchCellsRange( + 10, 10, rowCount, columnCount, forward, includeStartCell + ).toList(), + ) + } + + @Test + fun getSearchCellsRangeForwardSkipStart() { + val forward = true + val includeStartCell = false + + assertEquals( + ((7..24) + (0..6)).toList(), + AemConsoleTableSearchSession.getSearchCellsRange( + 1, 1, rowCount, columnCount, forward, includeStartCell + ).toList(), + ) + + assertEquals( + ((1..24) + (0..0)).toList(), + AemConsoleTableSearchSession.getSearchCellsRange( + -1, -1, rowCount, columnCount, forward, includeStartCell + ).toList(), + ) + + assertEquals( + (0..24).toList(), + AemConsoleTableSearchSession.getSearchCellsRange( + 10, 10, rowCount, columnCount, forward, includeStartCell + ).toList(), + ) + } + + @Test + fun getSearchCellsRangeBackwardSkipStart() { + val forward = false + val includeStartCell = false + + assertEquals( + ((5 downTo 0) + (24 downTo 6)).toList(), + AemConsoleTableSearchSession.getSearchCellsRange( + 1, 1, rowCount, columnCount, forward, includeStartCell + ).toList(), + ) + + assertEquals( + (24 downTo 0).toList(), + AemConsoleTableSearchSession.getSearchCellsRange( + -1, -1, rowCount, columnCount, forward, includeStartCell + ).toList(), + ) + + assertEquals( + ((23 downTo 0) + (24..24)).toList(), + AemConsoleTableSearchSession.getSearchCellsRange( + 10, 10, rowCount, columnCount, forward, includeStartCell + ).toList(), + ) + } +}