rhdunn / xquery-intellij-plugin

XQuery, XPath and XSLT Language Support for the IntelliJ IDE
https://rhdunn.github.io/xquery-intellij-plugin/
Apache License 2.0
25 stars 9 forks source link

XdmSimpleExpression for Literal values #75

Closed rhdunn closed 6 years ago

rhdunn commented 6 years ago
interface XdmSimpleExpression {
    val derivedType: XdmType
    val constantValue: Any?
}

This provides the data model for representing expressions that can evaluate to a single constant value, specifically OrExpr nodes. This allows support for constant code warnings and folding, as well as other static analysis.

This issue implements XdmSimpleExpression for OrExpr nodes that contain a single Literal node as follows:

  1. single XdmAtomicValue child:
    derivedType = child.lexicalValue
    constantValue = child.lexicalRepresentation
  2. single XdmSimpleExpression child:
    derivedType = child.derivedType
    constantValue = child.constantValue
  3. all other cases:
    derivedType = XsUntyped // may not be an atomic type, so cannot be XsUntypedAtomic
    constantValue = null // cannot determine a constant value

Simple Expression Nodes:

rhdunn commented 6 years ago

The design and optree model for this has changed. Additionally, simple (value) type forwarding is no longer needed as a result of the PSI tree simplification.