1 /******************************************************************************* 2 * Copyright (c) 2007, 2008 IBM Corporation and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * IBM Corporation - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.pde.api.tools.internal.provisional; 15 16 import java.util.HashMap; 17 18 import org.eclipse.pde.api.tools.internal.provisional.descriptors.IElementDescriptor; 19 20 /** 21 * A visitor for an API component. Component visitors must subclass this class. 22 * <p> 23 * Package nodes are visited, followed by its type nodes. Component specific 24 * nodes are visited before children nodes. 25 * </p> 26 * <p> 27 * Specific visit ordering: 28 * 29 * <pre> 30 * ComponentDescription := [visitElement[PackageDescription] endVisitElement[PackageDescription]]* 31 * PackageDescription := [visitElement[TypeDescription] endVisitElement[TypeDescription]]* 32 * TypeDescription := [[visitElement[OverrideDescription] endVisitElement[OverrideDescription]]* [visitElement[MemberDescription] endVisitElement[MemberDescription]]*]* 33 * MemberDescription := MethodDescription | FieldDescription 34 * OverrideDescription := PackageDescription | TypeDescription | MethodDescription | FieldDescription 35 * </pre> 36 * 37 * MemberDescriptions are visited in the order they are keyed for the backing 38 * {@link HashMap} 39 * </p> 40 * 41 * @since 1.0.0 42 */ 43 public abstract class ApiDescriptionVisitor { 44 45 /** 46 * Visits an element in the manifest and returns whether children nodes in 47 * the manifest should be visited. 48 * <p> 49 * The default implementation does nothing and returns <code>true</code>. 50 * Subclasses may re-implement. 51 * </p> 52 * 53 * @param element element being visited 54 * @param description description of the element visited 55 * @return whether child elements should be visited 56 */ visitElement(IElementDescriptor element, IApiAnnotations description)57 public boolean visitElement(IElementDescriptor element, IApiAnnotations description) { 58 return true; 59 } 60 61 /** 62 * End visiting an element. 63 * <p> 64 * The default implementation does nothing. Subclasses may re-implement. 65 * </p> 66 * 67 * @param element element being end-visited 68 * @param description description of the element end-visited 69 */ endVisitElement(IElementDescriptor element, IApiAnnotations description)70 public void endVisitElement(IElementDescriptor element, IApiAnnotations description) { 71 // subclasses may re-implement 72 } 73 } 74