stevedlawrence commented on a change in pull request #394: URL: https://github.com/apache/incubator-daffodil/pull/394#discussion_r455882154
########## File path: daffodil-core/src/test/scala/org/apache/daffodil/dsom/walker/BasicWalker.scala ########## @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.daffodil.dsom.walker + +import scala.collection.mutable.ArrayBuffer + +class BasicWalker(ignoreTypeWrappers: Boolean = false, onlyElements: Boolean = false) extends AbstractDSOMWalker { + + var nodeArr: ArrayBuffer[Either[TermView, TypeView]] = ArrayBuffer() + + override protected def onWalkBegin(root: RootView): Unit = {} + + override protected def onWalkEnd(root: RootView): Unit = {} + + override def onTermBegin(termElement: TermView): Unit = { + if (onlyElements) { + termElement match { + case _: ElementBaseView => nodeArr += Left(termElement) + case _ => + } + } else { + nodeArr += Left(termElement) + } + } + + override def onTermEnd(termElement: TermView): Unit = {} + + override def onTypeBegin(typeElement: TypeView): Unit = { + if (!ignoreTypeWrappers) { + nodeArr += Right(typeElement) + } + } + + override def onTypeEnd(typeElement: TypeView): Unit = {} +} Review comment: Understood, but we should still have tests that verify that end events are happening correctly. If there were a bug in the AbstractDSOMWalker that caused certain end events to never happen or to happen out of order, we wouldn't know about it. Whether this test walker does those checks or if it's handled by in each test itself doesn't really seem that important, but something should be able to verify that it's correct. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
