src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java
changeset 58713 ad69fd32778e
parent 55306 ea43db53de91
child 59021 cfc7bb9a5a92
equal deleted inserted replaced
58712:14e098407bb0 58713:ad69fd32778e
    24  */
    24  */
    25 
    25 
    26 package com.sun.source.util;
    26 package com.sun.source.util;
    27 
    27 
    28 import com.sun.source.tree.*;
    28 import com.sun.source.tree.*;
    29 import com.sun.source.tree.CaseTree.CaseKind;
       
    30 
    29 
    31 /**
    30 /**
    32  * A TreeVisitor that visits all the child tree nodes.
    31  * A TreeVisitor that visits all the child tree nodes.
    33  * To visit nodes of a particular type, just override the
    32  * To visit nodes of a particular type, just override the
    34  * corresponding visitXYZ method.
    33  * corresponding visitXYZ method.
   333         r = scanAndReduce(node.getCases(), p, r);
   332         r = scanAndReduce(node.getCases(), p, r);
   334         return r;
   333         return r;
   335     }
   334     }
   336 
   335 
   337     /**
   336     /**
   338      * {@inheritDoc} This implementation scans the children in left to right order.
   337      * {@preview Associated with switch expressions, a preview feature of
   339      *
   338      *           the Java language.
   340      * @param node  {@inheritDoc}
   339      *
   341      * @param p  {@inheritDoc}
   340      *           This method is associated with <i>switch expressions</i>, a preview
   342      * @return the result of scanning
   341      *           feature of the Java language. Preview features
   343      *
   342      *           may be removed in a future release, or upgraded to permanent
   344      * @deprecated
   343      *           features of the Java language.}
   345      * This method is modeling switch expressions,
   344      *
   346      * which are part of a preview feature and may be removed
   345      * {@inheritDoc} This implementation scans the children in left to right order.
   347      * if the preview feature is removed.
   346      *
   348      */
   347      * @param node  {@inheritDoc}
   349     @Override
   348      * @param p  {@inheritDoc}
   350     @Deprecated(forRemoval=true, since="12")
   349      * @return the result of scanning
   351     @SuppressWarnings("removal")
   350      */
       
   351     @Override
       
   352     @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
       
   353     @SuppressWarnings("preview")
   352     public R visitSwitchExpression(SwitchExpressionTree node, P p) {
   354     public R visitSwitchExpression(SwitchExpressionTree node, P p) {
   353         R r = scan(node.getExpression(), p);
   355         R r = scan(node.getExpression(), p);
   354         r = scanAndReduce(node.getCases(), p, r);
   356         r = scanAndReduce(node.getCases(), p, r);
   355         return r;
   357         return r;
   356     }
   358     }
   361      * @param node  {@inheritDoc}
   363      * @param node  {@inheritDoc}
   362      * @param p  {@inheritDoc}
   364      * @param p  {@inheritDoc}
   363      * @return the result of scanning
   365      * @return the result of scanning
   364      */
   366      */
   365     @Override
   367     @Override
   366     @SuppressWarnings("removal")
   368     @SuppressWarnings("preview")
   367     public R visitCase(CaseTree node, P p) {
   369     public R visitCase(CaseTree node, P p) {
   368         R r = scan(node.getExpressions(), p);
   370         R r = scan(node.getExpressions(), p);
   369         if (node.getCaseKind() == CaseKind.RULE)
   371         if (node.getCaseKind() == CaseTree.CaseKind.RULE)
   370             r = scanAndReduce(node.getBody(), p, r);
   372             r = scanAndReduce(node.getBody(), p, r);
   371         else
   373         else
   372             r = scanAndReduce(node.getStatements(), p, r);
   374             r = scanAndReduce(node.getStatements(), p, r);
   373         return r;
   375         return r;
   374     }
   376     }
   934     public R visitErroneous(ErroneousTree node, P p) {
   936     public R visitErroneous(ErroneousTree node, P p) {
   935         return null;
   937         return null;
   936     }
   938     }
   937 
   939 
   938     /**
   940     /**
       
   941      * {@preview Associated with switch expressions, a preview feature of
       
   942      *           the Java language.
       
   943      *
       
   944      *           This method is associated with <i>switch expressions</i>, a preview
       
   945      *           feature of the Java language. Preview features
       
   946      *           may be removed in a future release, or upgraded to permanent
       
   947      *           features of the Java language.}
       
   948      *
   939      * {@inheritDoc} This implementation returns {@code null}.
   949      * {@inheritDoc} This implementation returns {@code null}.
   940      *
   950      *
   941      * @param node  {@inheritDoc}
   951      * @param node  {@inheritDoc}
   942      * @param p  {@inheritDoc}
   952      * @param p  {@inheritDoc}
   943      * @return the result of scanning
   953      * @return the result of scanning
   944      *
   954      */
   945      * @deprecated
   955     @Override
   946      * This method is modeling switch expressions,
   956     @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
   947      * which are part of a preview feature and may be removed
   957     @SuppressWarnings("preview")
   948      * if the preview feature is removed.
       
   949      */
       
   950     @Override
       
   951     @Deprecated(forRemoval=true, since="13")
       
   952     @SuppressWarnings("removal")
       
   953     public R visitYield(YieldTree node, P p) {
   958     public R visitYield(YieldTree node, P p) {
   954         return scan(node.getValue(), p);
   959         return scan(node.getValue(), p);
   955     }
   960     }
   956 }
   961 }