1 | /******************************************************************************* |
---|---|
2 | * Copyright (c) 2021, 2022 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 | |
15 | package org.eclipse.jdt.core.dom; |
16 | |
17 | import java.util.ArrayList; |
18 | import java.util.List; |
19 | |
20 | /** |
21 | * Null Pattern node. |
22 | * |
23 | * @since 3.27 |
24 | * @noreference This class is not intended to be referenced by clients. |
25 | * @noinstantiate This class is not intended to be instantiated by clients. |
26 | */ |
27 | @SuppressWarnings("rawtypes") |
28 | public class NullPattern extends Pattern { |
29 | |
30 | /** |
31 | * A list of property descriptors (element type: |
32 | * {@link StructuralPropertyDescriptor}), |
33 | * or null if uninitialized. |
34 | */ |
35 | private static final List PROPERTY_DESCRIPTORS; |
36 | |
37 | static { |
38 | List propertyList = new ArrayList(1); |
39 | createPropertyList(NullPattern.class, propertyList); |
40 | PROPERTY_DESCRIPTORS = reapPropertyList(propertyList); |
41 | } |
42 | |
43 | /** |
44 | * Returns a list of structural property descriptors for this node type. |
45 | * Clients must not modify the result. |
46 | * |
47 | * @param apiLevel the API level; one of the |
48 | * <code>AST.JLS*</code> constants |
49 | |
50 | * @return a list of property descriptors (element type: |
51 | * {@link StructuralPropertyDescriptor}) |
52 | */ |
53 | public static List propertyDescriptors(int apiLevel) { |
54 | return PROPERTY_DESCRIPTORS; |
55 | } |
56 | |
57 | /** |
58 | * Creates a new unparented null literal node owned by the given AST. |
59 | * <p> |
60 | * N.B. This constructor is package-private. |
61 | * </p> |
62 | * |
63 | * @param ast the AST that is to own this node |
64 | */ |
65 | NullPattern(AST ast) { |
66 | super(ast); |
67 | supportedOnlyIn18(); |
68 | unsupportedWithoutPreviewError(); |
69 | } |
70 | |
71 | @Override |
72 | final List internalStructuralPropertiesForType(int apiLevel) { |
73 | return propertyDescriptors(apiLevel); |
74 | } |
75 | |
76 | @Override |
77 | final int getNodeType0() { |
78 | return NULL_PATTERN; |
79 | } |
80 | |
81 | @Override |
82 | ASTNode clone0(AST target) { |
83 | NullPattern result = new NullPattern(target); |
84 | result.setSourceRange(getStartPosition(), getLength()); |
85 | return result; |
86 | } |
87 | |
88 | @Override |
89 | final boolean subtreeMatch0(ASTMatcher matcher, Object other) { |
90 | // dispatch to correct overloaded match method |
91 | return matcher.match(this, other); |
92 | } |
93 | |
94 | @Override |
95 | void accept0(ASTVisitor visitor) { |
96 | visitor.visit(this); |
97 | visitor.endVisit(this); |
98 | } |
99 | |
100 | @Override |
101 | int memSize() { |
102 | return BASE_NODE_SIZE; |
103 | } |
104 | |
105 | @Override |
106 | int treeSize() { |
107 | return memSize(); |
108 | } |
109 | |
110 | @Override |
111 | public List<SingleVariableDeclaration> patternVariables() { |
112 | return null; |
113 | } |
114 | } |
115 | |
116 |
Members