Skip to content

Commit

Permalink
Merge pull request #219 from bobi/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
bobi authored Mar 27, 2024
2 parents 88ed47e + d1cf5ae commit fc38f11
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 46 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

# Validate wrapper
- name: Gradle Wrapper Validation
uses: gradle/[email protected].1
uses: gradle/[email protected].2

# Set up Java environment for the next steps
- name: Setup Java
Expand Down Expand Up @@ -170,7 +170,7 @@ jobs:

# Run Qodana inspections
- name: Qodana - Code Inspection
uses: JetBrains/[email protected].1
uses: JetBrains/[email protected].2
with:
cache-default-branch-only: true

Expand Down Expand Up @@ -207,7 +207,7 @@ jobs:

# Cache Plugin Verifier IDEs
- name: Setup Plugin Verifier IDEs Cache
uses: actions/[email protected].1
uses: actions/[email protected].2
with:
path: ${{ needs.build.outputs.pluginVerifierHomeDir }}/ides
key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }}
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## [Unreleased]

- Removed queryBuilder from code completion

## [0.10.0] - 2024-03-13

- Added table view as IDE table
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Int> {
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<Int>()

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
}
Expand All @@ -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<Int> {
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<Int>()

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 {
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/standardDsls/aem.gdsl
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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(),
)
}
}

0 comments on commit fc38f11

Please sign in to comment.