From f60cfc9d40164d4b0adbef1e58c3b72ee967f82a Mon Sep 17 00:00:00 2001 From: David Thompson Date: Mon, 29 Jan 2024 15:23:02 -0500 Subject: [PATCH] [WIP] fix some warnings Signed-off-by: David Thompson --- .../jdt/core/tests/dom/ASTConverter_RecordPattern_Test.java | 6 +++--- .../dom/org/eclipse/jdt/core/dom/ASTMatcher.java | 2 +- .../dom/org/eclipse/jdt/core/dom/GuardedPattern.java | 4 ++-- .../org/eclipse/jdt/internal/formatter/SpacePreparator.java | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter_RecordPattern_Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter_RecordPattern_Test.java index 5919d50f59b..336ebc3c6a1 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter_RecordPattern_Test.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter_RecordPattern_Test.java @@ -180,7 +180,7 @@ public void testGuardedPattern() throws CoreException { SwitchCase caseInteger = (SwitchCase) statements.get(0); Expression guardedPattern = (Expression)caseInteger.expressions().get(0); assertEquals("Guarded Pattern", ASTNode.GUARDED_PATTERN, guardedPattern.getNodeType()); - Pattern pattern = ((GuardedPattern)guardedPattern).getPattern(); + Pattern pattern = ((GuardedPattern)guardedPattern).patterns().get(0); SingleVariableDeclaration patternVariable = ((TypePattern)pattern).getPatternVariable(); assertEquals("Type Pattern Integer", "Integer", patternVariable.getType().toString()); SingleVariableDeclaration patternVariable2 = ((TypePattern)pattern).patternVariables().get(0); @@ -193,7 +193,7 @@ public void testGuardedPattern() throws CoreException { SwitchCase caseString = (SwitchCase) statements.get(2); guardedPattern = (Expression)caseString.expressions().get(0); assertEquals("Guarded Pattern", guardedPattern.getNodeType(), ASTNode.GUARDED_PATTERN); - pattern = ((GuardedPattern)guardedPattern).getPattern(); + pattern = ((GuardedPattern)guardedPattern).patterns().get(0); patternVariable = ((TypePattern)pattern).getPatternVariable(); assertEquals("Type Pattern String", "String", patternVariable.getType().toString()); patternVariable2 = ((TypePattern)pattern).patternVariables().get(0); @@ -566,6 +566,6 @@ public void testRecordPattern004() throws CoreException { SwitchCase caseStmt = (SwitchCase) switchStatements.get(0); assertEquals("incorrect type", ASTNode.GUARDED_PATTERN, ((Expression)caseStmt.expressions().get(0)).getNodeType()); GuardedPattern guardedPattern = (GuardedPattern)caseStmt.expressions().get(0); - assertEquals("There should be 1 Record Pattern", ASTNode.RECORD_PATTERN , guardedPattern.getPattern().getNodeType()); + assertEquals("There should be 1 Record Pattern", ASTNode.RECORD_PATTERN , guardedPattern.patterns().get(0).getNodeType()); } } diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTMatcher.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTMatcher.java index 102be3378b1..85244da76bd 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTMatcher.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTMatcher.java @@ -1108,7 +1108,7 @@ public boolean match(GuardedPattern node, Object other) { return false; } GuardedPattern o = (GuardedPattern) other; - return safeSubtreeMatch(node.getPattern(), o.getPattern()) + return safeSubtreeListMatch(node.patterns(), o.patterns()) && safeSubtreeMatch(node.getExpression(), o.getExpression()); } 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 74acb58b8ab..f033df44db6 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 @@ -31,7 +31,7 @@ * @noreference This class is not intended to be referenced by clients. */ -@SuppressWarnings("rawtypes") +@SuppressWarnings({"rawtypes", "unchecked"}) public class GuardedPattern extends Pattern{ GuardedPattern(AST ast) { @@ -249,7 +249,7 @@ public Pattern getPattern() { * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature. * @since 3.37 */ - public List patterns() { + public List patterns() { supportedOnlyIn21(); return this.patterns; } diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/SpacePreparator.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/SpacePreparator.java index c1befdcdd5d..be8002494c8 100644 --- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/SpacePreparator.java +++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/SpacePreparator.java @@ -476,7 +476,7 @@ public boolean visit(RecordPattern node) { @Override public boolean visit(GuardedPattern node) { - handleTokenAfter(node.getPattern(), TokenNameRestrictedIdentifierWhen, true, true); + handleCommas(node.patterns(), false, true); return true; }