Skip to content

Commit

Permalink
fixed an issue with the Expression Reference Regex where it was accep…
Browse files Browse the repository at this point in the history
…ting any two characters as ".." instead of just periods.
  • Loading branch information
Carson-McCombs committed Jun 26, 2024
1 parent ef8395e commit 6597015
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/model/RegexPatterns.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class RegexPatterns {
companion object{
val spacingRegex = Regex("(([0-9](?=([^0-9(,\\s.])))|([a-zA-Z](?=[^a-zA-Z(,\\s]))|([(,)+\\-*/$%^](?=\\S)))")
val moreThanOneSpaces = Regex("\\s{2,}")
val referenceRegex = Regex("@\\(\\s*(?<LOCAL>..)?(?<PATH>[a-zA-Z0-9/_-]+)\\s*\\)")
val referenceRegex = Regex("@\\(\\s*(?<LOCAL>\\.\\.)?(?<PATH>[a-zA-Z0-9/_-]+)\\s*\\)")
val operatorRegex = Regex("[-+/*%^u]")
val functionRegex = Regex("random|roll|ceil|floor|round|min|max")
val punctuationRegex = Regex("[(,)]")
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/model/dataObjects/ClipboardReference.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ClipboardReference(private val scope: CoroutineScope, private val reposito
scope.launch(Dispatchers.IO) {
val groupDescendantsMapState = repository.groupDescendantsMap.value
val groupExpressionDescendantsMapState = repository.groupExpressionDescendantsMap.value
deepGroupIds = (groupIds + groupIds.fastFlatMap { groupId -> groupDescendantsMapState[groupId]!! }).distinct()
deepGroupIds = (groupIds + groupIds.fastFlatMap { groupId -> groupDescendantsMapState[groupId]?: emptyList() }).distinct()
deepExpressionIds = (expressionIds + groupIds.fastFlatMap { groupId -> groupExpressionDescendantsMapState[groupId]!! })

val groupMapState = repository.groupMap.value
Expand Down
8 changes: 6 additions & 2 deletions app/src/main/java/model/database/dao/GroupDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ interface GroupDao {
"INNER JOIN descendant_group_table AS group_table " +
"ON group_table.groupId = child.parentId " +
") " +
"SELECT DISTINCT groups.id AS parentId, groups.groupId AS groupIds FROM descendant_group_table AS groups")
"SELECT DISTINCT groups.id AS parentId, groups.groupId AS groupIds FROM descendant_group_table AS groups " +
"UNION ALL " +
"SELECT groupEntity.parentId AS parentId, groupEntity.id AS groupIds FROM groupEntity")
fun getGroupDescendantsMap(): Flow<Map<@MapColumn(columnName = "parentId") Long, List<@MapColumn(columnName = "groupIds")Long>>>

@Transaction
Expand All @@ -50,7 +52,9 @@ interface GroupDao {
"INNER JOIN descendant_group_table AS groups " +
"ON groups.groupId = expressions.parentId OR groups.id = expressions.parentId" +
") " +
"SELECT DISTINCT expressions.id AS parentId, expressions.expressionId AS expressionIds FROM descendant_expression_table AS expressions")
"SELECT DISTINCT expressions.id AS parentId, expressions.expressionId AS expressionIds FROM descendant_expression_table AS expressions " +
"UNION ALL " +
"SELECT expressionEntity.parentId AS parentId, expressionEntity.id AS expressionIds FROM expressionEntity")
fun getExpressionDescendantsMap(): Flow<Map<@MapColumn(columnName = "parentId") Long, List<@MapColumn(columnName = "expressionIds")Long>>>

@Upsert
Expand Down

0 comments on commit 6597015

Please sign in to comment.