-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: add support for parsing, inspecting and autocompleting in a group stage written using Spring Data MongoDB INTELLIJ-175 #132
Conversation
supported operators include: - sum - avg - first - last - max - min - push - addToSet
private fun parseComputedExpression(element: PsiElement): HasValueReference<PsiElement> { | ||
val (constant, value) = element.tryToResolveAsConstant() | ||
return HasValueReference( | ||
when { | ||
constant && value is String -> HasValueReference.Computed( | ||
element, | ||
type = ComputedBsonType( | ||
BsonAny, | ||
Node( | ||
element, | ||
listOf( | ||
HasFieldReference( | ||
FromSchema(element, value.trim('$'), value) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
constant -> HasValueReference.Constant( | ||
element, | ||
value, | ||
value?.javaClass.toBsonType(value) | ||
) | ||
!constant && element is PsiExpression -> HasValueReference.Runtime( | ||
element, | ||
element.type?.toBsonType() ?: BsonAny | ||
) | ||
else -> HasValueReference.Unknown as HasValueReference.ValueReference<PsiElement> | ||
} | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed this method so I pulled it out of class and put it as an extension method on PsiElement, down below in the file.
methodCall.argumentList.expressions.toList() | ||
} else { | ||
val fieldsObjectExpression = methodCall.argumentList.expressions.getOrNull(0) | ||
fieldsObjectExpression?.resolveFieldStringExpressionsFromFieldsObject() ?: emptyList() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a method that I am reusing from ProjectStageParser. That was originally a private method but I pulled it out as an extension method to support this.
private fun fieldObjectExpressionToProjectedFieldNode( | ||
fieldObjectExpression: PsiExpression, | ||
projectionName: Name | ||
): Node<PsiElement>? { | ||
val fieldExpression = fieldObjectExpression.resolveFieldStringExpressionFromFieldObject() | ||
?: return null | ||
return createProjectedFieldNode( | ||
fieldExpression = fieldExpression, | ||
projectionName = projectionName | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This entire method was not needed after refactor so I removed it.
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This entire logic is shifted down below as extension method
Coverage Report
|
🤖 Benchmark Comparison for
|
🤖 Benchmark Comparison for
|
Description
This PR adds support for parsing, inspecting and autocompleting in a group stage written using
Aggregation.group
and chainedGroupOperation
s usingsum
,avg
,first
,last
,max
,min
,push
andaddToSet
.Checklist
Open Questions