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 | * Opens directive AST node type (added in JLS9 API). |
20 | * <pre> |
21 | * OpensDirective: |
22 | * <b>opens</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 OpensDirective 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(OpensDirective.class); |
38 | /** |
39 | * The "modules" structural property of this node type (element type: {@link Name}). |
40 | */ |
41 | public static final ChildListPropertyDescriptor MODULES_PROPERTY = |
42 | internalModulesPropertyFactory(OpensDirective.class); |
43 | |
44 | /** |
45 | * A list of property descriptors (element type: |
46 | * {@link StructuralPropertyDescriptor}), |
47 | * or null if uninitialized. |
48 | */ |
49 | private static final List PROPERTY_DESCRIPTORS_9_0; |
50 | |
51 | static { |
52 | List properyList = new ArrayList(3); |
53 | createPropertyList(OpensDirective.class, properyList); |
54 | addProperty(NAME_PROPERTY, properyList); |
55 | addProperty(MODULES_PROPERTY, properyList); |
56 | PROPERTY_DESCRIPTORS_9_0 = reapPropertyList(properyList); |
57 | } |
58 | |
59 | /** |
60 | * Returns a list of structural property descriptors for this node type. |
61 | * Clients must not modify the result. |
62 | * |
63 | * @param apiLevel the API level; one of the |
64 | * <code>AST.JLS*</code> constants |
65 | |
66 | * @return a list of property descriptors (element type: |
67 | * {@link StructuralPropertyDescriptor}) |
68 | */ |
69 | public static List propertyDescriptors(int apiLevel) { |
70 | return PROPERTY_DESCRIPTORS_9_0; |
71 | } |
72 | |
73 | /** |
74 | * Creates a new AST node for an opens directive owned by the |
75 | * given AST. The open directive initially is a regular (non-targetted) |
76 | * single package open for an unspecified, but legal, Java package name. |
77 | * <p> |
78 | * N.B. This constructor is package-private; all subclasses must be |
79 | * declared in the same package; clients are unable to declare |
80 | * additional subclasses. |
81 | * </p> |
82 | * |
83 | * @param ast the AST that is to own this node |
84 | */ |
85 | OpensDirective(AST ast) { |
86 | super(ast); |
87 | } |
88 | |
89 | @Override |
90 | final List internalStructuralPropertiesForType(int apiLevel) { |
91 | return propertyDescriptors(apiLevel); |
92 | } |
93 | |
94 | @Override |
95 | final ChildPropertyDescriptor internalNameProperty() { |
96 | return NAME_PROPERTY; |
97 | } |
98 | |
99 | @Override |
100 | final ChildListPropertyDescriptor internalModulesProperty() { |
101 | return MODULES_PROPERTY; |
102 | } |
103 | |
104 | @Override |
105 | final int getNodeType0() { |
106 | return OPENS_DIRECTIVE; |
107 | } |
108 | |
109 | @Override |
110 | ASTNode clone0(AST target) { |
111 | return cloneHelper(target, new OpensDirective(target)); |
112 | } |
113 | |
114 | @Override |
115 | final boolean subtreeMatch0(ASTMatcher matcher, Object other) { |
116 | // dispatch to correct overloaded match method |
117 | return matcher.match(this, other); |
118 | } |
119 | |
120 | @Override |
121 | void accept0(ASTVisitor visitor) { |
122 | boolean visitChildren = visitor.visit(this); |
123 | acceptVisitChildren(visitChildren, visitor); |
124 | visitor.endVisit(this); |
125 | } |
126 | } |
127 |
Members