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.List; |
18 | |
19 | /** |
20 | * Abstract base class of AST nodes that represent patterns. |
21 | * There are several kinds of patterns. |
22 | * <pre> |
23 | * Expression: |
24 | * {@link TypePattern}, {@link GuardedPattern} and {@link NullPattern} |
25 | * |
26 | |
27 | * </pre> |
28 | * |
29 | * @since 3.27 |
30 | * @noreference This class is not intended to be referenced by clients. |
31 | */ |
32 | public abstract class Pattern extends Expression { |
33 | |
34 | /** |
35 | * Creates a new AST node for an expression owned by the given AST. |
36 | * <p> |
37 | * N.B. This constructor is package-private. |
38 | * </p> |
39 | * |
40 | * @param ast the AST that is to own this node |
41 | */ |
42 | Pattern(AST ast) { |
43 | super(ast); |
44 | supportedOnlyIn18(); |
45 | unsupportedWithoutPreviewError(); |
46 | |
47 | } |
48 | |
49 | /** |
50 | * Creates and returns a structural property descriptor for the |
51 | * "pattern" property declared on the given concrete node type). |
52 | * |
53 | * @return the pattern property descriptor |
54 | */ |
55 | @SuppressWarnings("rawtypes") |
56 | static final ChildPropertyDescriptor internalPatternPropertyFactory(Class nodeClass) { |
57 | return new ChildPropertyDescriptor(nodeClass, "pattern", Javadoc.class, MANDATORY, NO_CYCLE_RISK); //$NON-NLS-1$ |
58 | } |
59 | |
60 | /** |
61 | * Returns the list of pattern variables |
62 | * |
63 | * @return the list of pattern variables |
64 | * (element type: {@link SingleVariableDeclaration}) |
65 | * @exception UnsupportedOperationException if this operation is not used for JLS18 |
66 | * @exception UnsupportedOperationException if this operation is not used with previewEnabled flag as true |
67 | * @noreference This method is not intended to be referenced by clients. |
68 | */ |
69 | public abstract List<SingleVariableDeclaration> patternVariables(); |
70 | |
71 | } |
72 | |
73 |