| 1 | /******************************************************************************* |
|---|---|
| 2 | * Copyright (c) 2016, 2017 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 | * IBM Corporation - initial API and implementation |
| 12 | *******************************************************************************/ |
| 13 | package org.eclipse.jdt.core.dom; |
| 14 | |
| 15 | import java.util.ArrayList; |
| 16 | import java.util.List; |
| 17 | |
| 18 | /** |
| 19 | * Exports directive AST node type (added in JLS9 API). |
| 20 | * <pre> |
| 21 | * ExportsDirective: |
| 22 | * <b>exports</b> PackageName [ <b>to</b> ModuleName {<b>,</b> ModuleName } ] <b>;</b> |
| 23 | * </pre> |
| 24 | * |
| 25 | * @since 3.14 |
| 26 | * |
| 27 | * @noextend This class is not intended to be subclassed by clients. |
| 28 | * @noinstantiate This class is not intended to be instantiated by clients. |
| 29 | */ |
| 30 | @SuppressWarnings({"rawtypes"}) |
| 31 | public class ExportsDirective extends ModulePackageAccess { |
| 32 | |
| 33 | /** |
| 34 | * The "name" structural property of this node type (child type: {@link Name}). |
| 35 | */ |
| 36 | public static final ChildPropertyDescriptor NAME_PROPERTY = |
| 37 | internalNamePropertyFactory(ExportsDirective.class); |
| 38 | |
| 39 | /** |
| 40 | * The "modules" structural property of this node type (element type: {@link Name}). |
| 41 | */ |
| 42 | public static final ChildListPropertyDescriptor MODULES_PROPERTY = |
| 43 | internalModulesPropertyFactory(ExportsDirective.class); |
| 44 | |
| 45 | /** |
| 46 | * A list of property descriptors (element type: |
| 47 | * {@link StructuralPropertyDescriptor}), |
| 48 | * or null if uninitialized. |
| 49 | */ |
| 50 | private static final List PROPERTY_DESCRIPTORS_9_0; |
| 51 | |
| 52 | static { |
| 53 | List properyList = new ArrayList(3); |
| 54 | createPropertyList(ExportsDirective.class, properyList); |
| 55 | addProperty(NAME_PROPERTY, properyList); |
| 56 | addProperty(MODULES_PROPERTY, properyList); |
| 57 | PROPERTY_DESCRIPTORS_9_0 = reapPropertyList(properyList); |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Returns a list of structural property descriptors for this node type. |
| 62 | * Clients must not modify the result. |
| 63 | * |
| 64 | * @param apiLevel the API level; one of the |
| 65 | * <code>AST.JLS*</code> constants |
| 66 | |
| 67 | * @return a list of property descriptors (element type: |
| 68 | * {@link StructuralPropertyDescriptor}) |
| 69 | */ |
| 70 | public static List propertyDescriptors(int apiLevel) { |
| 71 | return PROPERTY_DESCRIPTORS_9_0; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Creates a new AST node for an export directive owned by the |
| 76 | * given AST. The export directive initially is a regular (non-targetted) |
| 77 | * single package export for an unspecified, but legal, Java package name. |
| 78 | * <p> |
| 79 | * N.B. This constructor is package-private; all subclasses must be |
| 80 | * declared in the same package; clients are unable to declare |
| 81 | * additional subclasses. |
| 82 | * </p> |
| 83 | * |
| 84 | * @param ast the AST that is to own this node |
| 85 | */ |
| 86 | ExportsDirective(AST ast) { |
| 87 | super(ast); |
| 88 | } |
| 89 | |
| 90 | @Override |
| 91 | final List internalStructuralPropertiesForType(int apiLevel) { |
| 92 | return propertyDescriptors(apiLevel); |
| 93 | } |
| 94 | |
| 95 | @Override |
| 96 | final ChildPropertyDescriptor internalNameProperty() { |
| 97 | return NAME_PROPERTY; |
| 98 | } |
| 99 | |
| 100 | @Override |
| 101 | final ChildListPropertyDescriptor internalModulesProperty() { |
| 102 | return MODULES_PROPERTY; |
| 103 | } |
| 104 | |
| 105 | @Override |
| 106 | final int getNodeType0() { |
| 107 | return EXPORTS_DIRECTIVE; |
| 108 | } |
| 109 | |
| 110 | @Override |
| 111 | ASTNode clone0(AST target) { |
| 112 | return cloneHelper(target, new ExportsDirective(target)); |
| 113 | } |
| 114 | |
| 115 | @Override |
| 116 | final boolean subtreeMatch0(ASTMatcher matcher, Object other) { |
| 117 | // dispatch to correct overloaded match method |
| 118 | return matcher.match(this, other); |
| 119 | } |
| 120 | |
| 121 | @Override |
| 122 | void accept0(ASTVisitor visitor) { |
| 123 | boolean visitChildren = visitor.visit(this); |
| 124 | acceptVisitChildren(visitChildren, visitor); |
| 125 | visitor.endVisit(this); |
| 126 | } |
| 127 | } |
| 128 |
Members