diff options
Diffstat (limited to 'org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/GuardedPattern.java')
-rw-r--r-- | org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/GuardedPattern.java | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/GuardedPattern.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/GuardedPattern.java index 18373d993..8bc21c625 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/GuardedPattern.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/GuardedPattern.java @@ -23,7 +23,7 @@ import org.eclipse.jdt.internal.core.dom.util.DOMASTUtil; * * <pre> * GuardedPattern: - * Pattern && Expression + * Pattern when Expression * </pre> * * @since 3.27 @@ -36,7 +36,7 @@ public class GuardedPattern extends Pattern{ GuardedPattern(AST ast) { super(ast); - supportedOnlyIn18(); + supportedOnlyIn19(); unsupportedWithoutPreviewError(); } @@ -51,6 +51,11 @@ public class GuardedPattern extends Pattern{ public static final ChildPropertyDescriptor EXPRESSION_PROPERTY = new ChildPropertyDescriptor(GuardedPattern.class, "expression", Expression.class, MANDATORY, CYCLE_RISK); //$NON-NLS-1$); + /** + * A character index into the original restricted identifier source string, or <code>-1</code> if no restricted + * identifier source position information is available for this node; <code>-1</code> by default. + */ + private int restrictedIdentifierStartPosition = -1; /** * A list of property descriptors (element type: @@ -126,6 +131,7 @@ public class GuardedPattern extends Pattern{ result.setSourceRange(getStartPosition(), getLength()); result.setPattern((Pattern) getPattern().clone(target)); result.setExpression((Expression) getExpression().clone(target)); + result.setRestrictedIdentifierStartPosition(this.restrictedIdentifierStartPosition); return result; } @@ -154,11 +160,6 @@ public class GuardedPattern extends Pattern{ + (this.conditonalExpression == null ? 0 : getExpression().treeSize()); } - @Override - public List<SingleVariableDeclaration> patternVariables() { - return null; - } - /** * Returns a list of structural property descriptors for this node type. * Clients must not modify the result. @@ -198,7 +199,7 @@ public class GuardedPattern extends Pattern{ * @return the expression node, or <code>null</code> if there is none */ public Expression getExpression() { - supportedOnlyIn18(); + supportedOnlyIn19(); unsupportedWithoutPreviewError(); return this.conditonalExpression; } @@ -213,7 +214,7 @@ public class GuardedPattern extends Pattern{ * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature. */ public Pattern getPattern() { - supportedOnlyIn18(); + supportedOnlyIn19(); unsupportedWithoutPreviewError(); return this.pattern; } @@ -232,7 +233,7 @@ public class GuardedPattern extends Pattern{ * </ul> */ public void setExpression(Expression expression) { - supportedOnlyIn18(); + supportedOnlyIn19(); unsupportedWithoutPreviewError(); ASTNode oldChild = this.conditonalExpression; preReplaceChild(oldChild, expression, EXPRESSION_PROPERTY); @@ -248,7 +249,7 @@ public class GuardedPattern extends Pattern{ * @exception UnsupportedOperationException if this operation is used without previewEnabled */ public void setPattern(Pattern pattern) { - supportedOnlyIn18(); + supportedOnlyIn19(); unsupportedWithoutPreviewError(); ASTNode oldChild = this.pattern; preReplaceChild(oldChild, pattern, PATTERN_PROPERTY); @@ -256,4 +257,30 @@ public class GuardedPattern extends Pattern{ postReplaceChild(oldChild, pattern, PATTERN_PROPERTY); } + /** + * A character index into the original restricted identifier source string, or <code>-1</code> if no restricted + * identifier source position information is available for this node; <code>-1</code> by default. + * @noreference + * since 3.30 + */ + protected void setRestrictedIdentifierStartPosition(int restrictedIdentifierStartPosition) { + if (restrictedIdentifierStartPosition < 0) { + throw new IllegalArgumentException(); + } + // restrictedIdentifierStartPosition is not considered a structural property + // but we protect it nevertheless + checkModifiable(); + this.restrictedIdentifierStartPosition = restrictedIdentifierStartPosition; + } + + /** + * A character index into the original restricted identifier source string, or <code>-1</code> if no restricted + * identifier source position information is available for this node; <code>-1</code> by default. + * @noreference + * @since 3.30 + */ + public int getRestrictedIdentifierStartPosition() { + return this.restrictedIdentifierStartPosition; + } + } |