Search in sources :

Example 1 with ReverseStep

use of org.eclipse.wst.xml.xpath2.processor.internal.ast.ReverseStep in project webtools.sourceediting by eclipse.

the class DefaultEvaluator method visit.

/**
 * visit a reverse step expression
 *
 * @param e
 *            is the reverse step.
 * @return a new function
 */
// XXX unify with top
public Object visit(ReverseStep e) {
    // get context node
    AnyType ci = focus().context_item();
    if (!(ci instanceof NodeType))
        report_error(TypeError.ci_not_node(ci.string_type()));
    NodeType cn = (NodeType) ci;
    // get the nodes on the axis
    ReverseAxis axis = e.iterator();
    ResultBuffer result = new ResultBuffer();
    // short for "gimme da parent"
    if (e.axis() == ReverseStep.DOTDOT) {
        new ParentAxis().iterate(cn, result, _dc.getLimitNode());
        return result.getSequence();
    }
    assert axis != null;
    axis.iterate(cn, result, null);
    // get all nodes in the axis, and principal node
    Pair arg = new Pair(axis.principal_node_kind().string_type(), result.getSequence());
    // do the name test
    _param = arg;
    ResultSequence rs = (ResultSequence) e.node_test().accept(this);
    return rs;
}
Also used : ResultBuffer(org.eclipse.wst.xml.xpath2.api.ResultBuffer) ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) NodeType(org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType) ParentAxis(org.eclipse.wst.xml.xpath2.processor.internal.ParentAxis) ReverseAxis(org.eclipse.wst.xml.xpath2.processor.internal.ReverseAxis) AnyType(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType) VarExprPair(org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair)

Example 2 with ReverseStep

use of org.eclipse.wst.xml.xpath2.processor.internal.ast.ReverseStep in project webtools.sourceediting by eclipse.

the class StaticNameResolver method visit.

/**
 * Validate a reverse step.
 *
 * @param e
 *            is the expression.
 * @return null.
 */
public Object visit(ReverseStep e) {
    NodeTest nt = e.node_test();
    if (nt != null)
        nt.accept(this);
    ReverseAxis iterator = e.iterator();
    if (iterator != null)
        _axes.add(iterator.name());
    return null;
}
Also used : ReverseAxis(org.eclipse.wst.xml.xpath2.processor.internal.ReverseAxis) NodeTest(org.eclipse.wst.xml.xpath2.processor.internal.ast.NodeTest)

Example 3 with ReverseStep

use of org.eclipse.wst.xml.xpath2.processor.internal.ast.ReverseStep in project webtools.sourceediting by eclipse.

the class Normalizer method visit.

/**
 * @param e
 *            is the reverse step.
 * @return e
 */
public Object visit(ReverseStep e) {
    if (e.axis() == ReverseStep.DOTDOT) {
        NodeTest nt = new AnyKindTest();
        Step s = new ReverseStep(ReverseStep.PARENT, nt);
        return s;
    }
    NodeTest nt = e.node_test();
    if (nt != null)
        nt.accept(this);
    return e;
}
Also used : ReverseStep(org.eclipse.wst.xml.xpath2.processor.internal.ast.ReverseStep) AxisStep(org.eclipse.wst.xml.xpath2.processor.internal.ast.AxisStep) ForwardStep(org.eclipse.wst.xml.xpath2.processor.internal.ast.ForwardStep) ReverseStep(org.eclipse.wst.xml.xpath2.processor.internal.ast.ReverseStep) Step(org.eclipse.wst.xml.xpath2.processor.internal.ast.Step) NodeTest(org.eclipse.wst.xml.xpath2.processor.internal.ast.NodeTest) AnyKindTest(org.eclipse.wst.xml.xpath2.processor.internal.ast.AnyKindTest)

Aggregations

ReverseAxis (org.eclipse.wst.xml.xpath2.processor.internal.ReverseAxis)2 NodeTest (org.eclipse.wst.xml.xpath2.processor.internal.ast.NodeTest)2 ResultBuffer (org.eclipse.wst.xml.xpath2.api.ResultBuffer)1 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)1 ParentAxis (org.eclipse.wst.xml.xpath2.processor.internal.ParentAxis)1 AnyKindTest (org.eclipse.wst.xml.xpath2.processor.internal.ast.AnyKindTest)1 AxisStep (org.eclipse.wst.xml.xpath2.processor.internal.ast.AxisStep)1 ForwardStep (org.eclipse.wst.xml.xpath2.processor.internal.ast.ForwardStep)1 ReverseStep (org.eclipse.wst.xml.xpath2.processor.internal.ast.ReverseStep)1 Step (org.eclipse.wst.xml.xpath2.processor.internal.ast.Step)1 VarExprPair (org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair)1 AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)1 NodeType (org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType)1