diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000000..46f3230490a --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,13 @@ +name: CodeQL call + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + schedule: + - cron: '15 8 * * 1' + +jobs: + callCodeQLworkflow: + uses: eclipse-platform/eclipse.platform.releng.aggregator/.github/workflows/codeQLworkflow.yml@master diff --git a/.mvn/maven.config b/.mvn/maven.config new file mode 100644 index 00000000000..26de1a8fe73 --- /dev/null +++ b/.mvn/maven.config @@ -0,0 +1 @@ +-Pbuild-individual-bundles diff --git a/Jenkinsfile b/Jenkinsfile index 5292f9bc1e7..86617299e4a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,7 +18,7 @@ pipeline { wrap([$class: 'Xvnc', useXauthority: true]) { sh """ mvn -U -e -DskipTests=false -Dmaven.repo.local=$WORKSPACE/.m2/repository \ - clean verify --batch-mode --fail-at-end -Pbuild-individual-bundles \ + clean verify --batch-mode --fail-at-end \ -Pbree-libs -Papi-check -Pjavadoc \ -Dmaven.test.failure.ignore=true \ -Dcompare-version-with-baselines.skip=false diff --git a/org.eclipse.jdt.bcoview/pom.xml b/org.eclipse.jdt.bcoview/pom.xml index e36081b6018..afc033a0bfb 100644 --- a/org.eclipse.jdt.bcoview/pom.xml +++ b/org.eclipse.jdt.bcoview/pom.xml @@ -14,7 +14,7 @@ eclipse.jdt.ui eclipse.jdt.ui - 4.31.0-SNAPSHOT + 4.32.0-SNAPSHOT org.eclipse.jdt org.eclipse.jdt.bcoview diff --git a/org.eclipse.jdt.core.manipulation/.settings/.api_filters b/org.eclipse.jdt.core.manipulation/.settings/.api_filters index a42165f7e4b..3198459f671 100644 --- a/org.eclipse.jdt.core.manipulation/.settings/.api_filters +++ b/org.eclipse.jdt.core.manipulation/.settings/.api_filters @@ -59,6 +59,15 @@ + + + + + + + + + diff --git a/org.eclipse.jdt.core.manipulation/META-INF/MANIFEST.MF b/org.eclipse.jdt.core.manipulation/META-INF/MANIFEST.MF index 56a749bc440..8e27f59da13 100644 --- a/org.eclipse.jdt.core.manipulation/META-INF/MANIFEST.MF +++ b/org.eclipse.jdt.core.manipulation/META-INF/MANIFEST.MF @@ -3,19 +3,19 @@ Automatic-Module-Name: org.eclipse.jdt.core.manipulation Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.jdt.core.manipulation; singleton:=true -Bundle-Version: 1.21.0.qualifier +Bundle-Version: 1.21.100.qualifier Bundle-Vendor: %providerName Bundle-Activator: org.eclipse.jdt.internal.core.manipulation.JavaManipulationPlugin Bundle-Localization: plugin -Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", - org.eclipse.core.resources;bundle-version="[3.5.0,4.0.0)", - org.eclipse.ltk.core.refactoring;bundle-version="[3.6.0,4.0.0)", - org.eclipse.jdt.core;bundle-version="[3.36.0,4.0.0)", - org.eclipse.core.expressions;bundle-version="[3.4.100,4.0.0)", - org.eclipse.text;bundle-version="[3.12.0,4.0.0)", - org.eclipse.jdt.launching;bundle-version="3.19.400", - org.eclipse.core.filesystem;bundle-version="1.7.200", - org.eclipse.core.filebuffers;bundle-version="3.6.300", +Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.31.0,4.0.0)", + org.eclipse.core.resources;bundle-version="[3.20.0,4.0.0)", + org.eclipse.ltk.core.refactoring;bundle-version="[3.14.0,4.0.0)", + org.eclipse.jdt.core;bundle-version="[3.38.0,4.0.0)", + org.eclipse.core.expressions;bundle-version="[3.9.0,4.0.0)", + org.eclipse.text;bundle-version="[3.14.0,4.0.0)", + org.eclipse.jdt.launching;bundle-version="3.21.0", + org.eclipse.core.filesystem;bundle-version="1.10.0", + org.eclipse.core.filebuffers;bundle-version="3.8.0", org.eclipse.search.core;bundle-version="3.16.0" Bundle-ActivationPolicy: lazy Export-Package: org.eclipse.jdt.core.manipulation, diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/common/LambdaASTVisitor.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/common/LambdaASTVisitor.java index 5dc9f5b17d6..40b61b29179 100644 --- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/common/LambdaASTVisitor.java +++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/common/LambdaASTVisitor.java @@ -22,7 +22,7 @@ * * @author chammer * - * @param - type that extends HelpVisitorProvider that provides HelperVisitor + * @param - type that extends HelpVisitorProvider that provides {@code HelperVisitor} * @param - type that HelperVisitor uses as map key type * @param - type that HelperVisitor uses as map value type */ diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/JavaElementLabelsCore.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/JavaElementLabelsCore.java index 245e2e2d0a9..236f7d59ce6 100644 --- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/JavaElementLabelsCore.java +++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/JavaElementLabelsCore.java @@ -341,7 +341,7 @@ public final class JavaElementLabelsCore { public final static long ALL_POST_QUALIFIED= F_POST_QUALIFIED | M_POST_QUALIFIED | I_POST_QUALIFIED | T_POST_QUALIFIED | TP_POST_QUALIFIED | D_POST_QUALIFIED | CF_POST_QUALIFIED | CU_POST_QUALIFIED | P_POST_QUALIFIED | ROOT_POST_QUALIFIED; /** - * Default options (M_PARAMETER_TYPES, M_APP_TYPE_PARAMETERS & T_TYPE_PARAMETERS enabled) + * Default options (M_PARAMETER_TYPES, M_APP_TYPE_PARAMETERS, T_TYPE_PARAMETERS enabled) */ public final static long ALL_DEFAULT= M_PARAMETER_TYPES | M_APP_TYPE_PARAMETERS | T_TYPE_PARAMETERS; diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/MembersOrderPreferenceCacheCommon.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/MembersOrderPreferenceCacheCommon.java index 1d9952bbe24..33e463c76b4 100644 --- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/MembersOrderPreferenceCacheCommon.java +++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/MembersOrderPreferenceCacheCommon.java @@ -45,7 +45,6 @@ public class MembersOrderPreferenceCacheCommon { *
  • SM: Static Methods
  • *
  • SF: Static Fields
  • * - *

    */ public static final String APPEARANCE_MEMBER_SORT_ORDER= "outlinesortoption"; //$NON-NLS-1$ @@ -62,7 +61,6 @@ public class MembersOrderPreferenceCacheCommon { *
  • R: Protected
  • *
  • D: Default
  • * - *

    */ public static final String APPEARANCE_VISIBILITY_SORT_ORDER= "org.eclipse.jdt.ui.visibility.order"; //$NON-NLS-1$ diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/IJavaStatusConstants.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/IJavaStatusConstants.java index d28acb97083..6e89fb4eb49 100644 --- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/IJavaStatusConstants.java +++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/IJavaStatusConstants.java @@ -39,7 +39,7 @@ public interface IJavaStatusConstants { int VALIDATE_EDIT_CHANGED_CONTENT= 10003; /** - * Status constant indicating that a ChangeAbortException has been + * Status constant indicating that a ChangeAbortException has been * caught. */ int CHANGE_ABORTED= 10004; diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/util/StringMatcher.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/util/StringMatcher.java index 287b2691041..bea6a28abb5 100644 --- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/util/StringMatcher.java +++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/util/StringMatcher.java @@ -82,7 +82,7 @@ public StringMatcher(String pattern, boolean ignoreCase, boolean ignoreWildCards } } /** - * Find the first occurrence of the pattern between startstart(inclusive) * and end(exclusive). * @param text the String object to search in * @param start the starting index of the search range, inclusive diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/NecessaryParenthesesChecker.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/NecessaryParenthesesChecker.java index 0d9e9e08328..33e3077c048 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/NecessaryParenthesesChecker.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/NecessaryParenthesesChecker.java @@ -292,7 +292,6 @@ public static boolean canRemoveParentheses(Expression expression, ASTNode parent *
  • The infixExpression must not have additional operands.
  • *
  • The rightOperand node must have bindings.
  • * - *

    * * @param rightOperand the right operand in infixExpression * @param infixExpression the parent infix expression diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/OperatorPrecedence.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/OperatorPrecedence.java index d245dd84f5e..51a186c84a4 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/OperatorPrecedence.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/OperatorPrecedence.java @@ -51,7 +51,7 @@ public class OperatorPrecedence { * with higher precedence are executed before expressions * with lower precedence. * i.e. in: - *
    int a= ++3--;
    + *
    int a= ++3--;
    * * the precedence order is *
      diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/search/ExceptionOccurrencesFinder.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/search/ExceptionOccurrencesFinder.java index c190689c8d7..d2057ed9748 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/search/ExceptionOccurrencesFinder.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/search/ExceptionOccurrencesFinder.java @@ -285,7 +285,7 @@ public boolean visit(MethodDeclaration node) { for (TagElement tag : tags) { String tagName= tag.getTagName(); if (TagElement.TAG_EXCEPTION.equals(tagName) || TagElement.TAG_THROWS.equals(tagName)) { - ASTNode name= (ASTNode) tag.fragments().get(0); + ASTNode name= tag.fragments().isEmpty() ? null : (ASTNode) tag.fragments().get(0); if (name instanceof Name) { if (name != fSelectedNode && Bindings.equals(fException, ((Name) name).resolveBinding())) { fResult.add(new OccurrenceLocation(name.getStartPosition(), name.getLength(), 0, fDescription)); diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/util/BasicElementLabels.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/util/BasicElementLabels.java index aea795c4476..828df044402 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/util/BasicElementLabels.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/util/BasicElementLabels.java @@ -116,7 +116,7 @@ public static String getFileName(ITypeRoot typeRoot) { } /** - * Returns a label for Java element name. Example is 'new Test() { ...}'. + * Returns a label for Java element name. Example is {@code new Test() { ...}}. * This method should only be used for simple element names. Use * org.eclipse.jdt.ui.JavaElementLabels to create a label from a Java element or * org.eclipse.jdt.internal.ui.viewsupport.BindingLabelProvider for labels of bindings. @@ -129,7 +129,7 @@ public static String getJavaElementName(String name) { } /** - * Returns a label for Java code snippet used in a label. Example is 'Test test= new Test() { ...}'. + * Returns a label for Java code snippet used in a label. Example is {@code 'Test test= new Test() { ...}}. * * @param string the Java code snippet * @return the label for the Java code snippet diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/util/Strings.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/util/Strings.java index 62f131d78fb..f6c669312a0 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/util/Strings.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/util/Strings.java @@ -139,8 +139,8 @@ public static String removeNewLine(String message) { * don't contain any line delimiter characters. * * @param input the string - * @return the string converted into an array of strings. Returns - * null if the input string can't be converted in an array of lines. + * @return the string converted into an array of strings. Returns {@code + * null} if the input string can't be converted in an array of lines. */ public static String[] convertIntoLines(String input) { try { @@ -160,13 +160,13 @@ public static String[] convertIntoLines(String input) { } /** - * Returns true if the given string only consists of - * white spaces according to Java. If the string is empty, true - * is returned. + * Returns {@code true} if the given string only consists of + * white spaces according to Java. If the string is empty, {@code true + * } is returned. * * @param s the string to test - * @return true if the string only consists of white - * spaces; otherwise false is returned + * @return {@code true} if the string only consists of white + * spaces; otherwise {@code false} is returned * * @see java.lang.Character#isWhitespace(char) */ @@ -229,7 +229,7 @@ else if (end == 0) * * @param line the text line * @param project the java project from which to get the formatter - * preferences, or null for global preferences + * preferences, or {@code null} for global preferences * @return the number of indent units * @since 3.1 */ @@ -266,12 +266,12 @@ public static int computeIndentUnits(String line, int tabWidth, int indentWidth) /** * Computes the visual length of the indentation of a - * CharSequence, counting a tab character as the size until + * {@code CharSequence}, counting a tab character as the size until * the next tab stop and every other whitespace character as one. * * @param line the string to measure the indent of * @param tabSize the visual size of a tab in space equivalents - * @return the visual length of the indentation of line + * @return the visual length of the indentation of {@code line} * @since 3.1 */ public static int measureIndentLength(CharSequence line, int tabSize) { @@ -280,13 +280,13 @@ public static int measureIndentLength(CharSequence line, int tabSize) { /** * Removes the given number of indents from the line. Asserts that the given line - * has the requested number of indents. If indentsToRemove <= 0 + * has the requested number of indents. If {@code indentsToRemove <= 0} * the line is returned. * @param line the line * @param indentsToRemove the indents to remove * * @param project the java project from which to get the formatter - * preferences, or null for global preferences + * preferences, or {@code null} for global preferences * @return the trimmed line * * @since 3.1 @@ -297,7 +297,7 @@ public static String trimIndent(String line, int indentsToRemove, IJavaProject p /** * Removes the given number of indents from the line. Asserts that the given line - * has the requested number of indents. If indentsToRemove <= 0 + * has the requested number of indents. If {@code indentsToRemove <= 0} * the line is returned. * * @param line the line @@ -311,7 +311,7 @@ public static String trimIndent(String line, int indentsToRemove, ICompilationUn /** * Removes the given number of indents from the line. Asserts that the given line - * has the requested number of indents. If indentsToRemove <= 0 + * has the requested number of indents. If {@code indentsToRemove <= 0} * the line is returned. * @param line the line * @param indentsToRemove the indents to remove @@ -331,7 +331,7 @@ public static String trimIndent(String line, int indentsToRemove, int tabWidth, * @param lines the lines * @param project the java project from which to get the formatter - * preferences, or null for global preferences + * preferences, or {@code null} for global preferences * @since 3.1 */ public static void trimIndentation(String[] lines, IJavaProject project) { @@ -353,13 +353,13 @@ public static void trimIndentation(String[] lines, int tabWidth, int indentWidth /** * Removes the common number of indents from all lines. If a line - * only consists out of white space it is ignored. If - * considerFirstLine is false the first line will be ignored. + * only consists out of white space it is ignored. If {@code + * considerFirstLine} is false the first line will be ignored. * @param lines the lines * * @param project the java project from which to get the formatter - * preferences, or null for global preferences - * @param considerFirstLine If considerFirstLine is false the first line will be ignored. + * preferences, or {@code null} for global preferences + * @param considerFirstLine If {@code considerFirstLine} is false the first line will be ignored. * @since 3.1 */ public static void trimIndentation(String[] lines, IJavaProject project, boolean considerFirstLine) { @@ -368,12 +368,12 @@ public static void trimIndentation(String[] lines, IJavaProject project, boolean /** * Removes the common number of indents from all lines. If a line - * only consists out of white space it is ignored. If - * considerFirstLine is false the first line will be ignored. + * only consists out of white space it is ignored. If {@code + * considerFirstLine} is false the first line will be ignored. * * @param lines the lines * @param cu the compilation unit from which to get the formatter preferences - * @param considerFirstLine If considerFirstLine is false the first line will be ignored. + * @param considerFirstLine If {@code considerFirstLine} is false the first line will be ignored. */ public static void trimIndentation(String[] lines, ICompilationUnit cu, boolean considerFirstLine) { trimIndentation(lines, CodeFormatterUtil.getTabWidth(cu), CodeFormatterUtil.getIndentWidth(cu), considerFirstLine); @@ -381,12 +381,12 @@ public static void trimIndentation(String[] lines, ICompilationUnit cu, boolean /** * Removes the common number of indents from all lines. If a line - * only consists out of white space it is ignored. If - * considerFirstLine is false the first line will be ignored. + * only consists out of white space it is ignored. If {@code + * considerFirstLine} is false the first line will be ignored. * @param lines the lines * @param tabWidth the size of one tab in space equivalents * @param indentWidth the size of the indent in space equivalents - * @param considerFirstLine If considerFirstLine is false the first line will be ignored. + * @param considerFirstLine If {@code considerFirstLine} is false the first line will be ignored. * @since 3.1 */ public static void trimIndentation(String[] lines, int tabWidth, int indentWidth, boolean considerFirstLine) { @@ -423,13 +423,13 @@ public static void trimIndentation(String[] lines, int tabWidth, int indentWidth } /** - * Returns that part of the indentation of line that makes up + * Returns that part of the indentation of {@code line} that makes up * a multiple of indentation units. * * @param line the line to scan * @param project the java project from which to get the formatter - * preferences, or null for global preferences - * @return the indent part of line, but no odd spaces + * preferences, or {@code null} for global preferences + * @return the indent part of {@code line}, but no odd spaces * @since 3.1 */ public static String getIndentString(String line, IJavaProject project) { @@ -437,25 +437,25 @@ public static String getIndentString(String line, IJavaProject project) { } /** - * Returns that part of the indentation of line that makes up + * Returns that part of the indentation of {@code line} that makes up * a multiple of indentation units. * * @param line the line to scan * @param cu the compilation unit from which to get the formatter preferences - * @return the indent part of line, but no odd spaces + * @return the indent part of {@code line}, but no odd spaces */ public static String getIndentString(String line, ICompilationUnit cu) { return IndentManipulation.extractIndentString(line, CodeFormatterUtil.getTabWidth(cu), CodeFormatterUtil.getIndentWidth(cu)); } /** - * Returns that part of the indentation of line that makes up + * Returns that part of the indentation of {@code line} that makes up * a multiple of indentation units. * * @param line the line to scan * @param tabWidth the size of one tab in space equivalents * @param indentWidth the size of the indent in space equivalents - * @return the indent part of line, but no odd spaces + * @return the indent part of {@code line}, but no odd spaces * @since 3.1 */ public static String getIndentString(String line, int tabWidth, int indentWidth) { @@ -485,7 +485,7 @@ private static int findLastNonEmptyLineIndex(String[] sourceLines) { * @param codeIndentLevel level of indentation * * @param project the java project from which to get the formatter - * preferences, or null for global preferences + * preferences, or {@code null} for global preferences * @param newIndent new indent * @param lineDelim line delimiter * @return the changed code diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/GenerateHashCodeEqualsOperation.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/GenerateHashCodeEqualsOperation.java index a059dc7ffa5..a2521a0fd5f 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/GenerateHashCodeEqualsOperation.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/GenerateHashCodeEqualsOperation.java @@ -127,7 +127,6 @@ * implementation is consistent with the wrapper types java.lang.Float and * java.lang.Double. *
    - *

    * * @since 3.2 */ diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/AbstractToStringGenerator.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/AbstractToStringGenerator.java index 3793475d2a3..63a73751bbe 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/AbstractToStringGenerator.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/AbstractToStringGenerator.java @@ -76,11 +76,9 @@ * which lists all selected fields and methods. What exactly is listed and how members are separated * is determined by a format template. *

    - * - *

    * To print out items of arrays and/or limit number items printed for arrays, collections and so on, * various methods are used according to actual jdk compatibility: - * + *
    * * * @@ -110,7 +108,7 @@ * * * - * + * * * * @@ -132,7 +130,6 @@ *
    java.util.List---Arrays.toString()Arrays.toString()Arrays.asList(member)
    * Additionally, if helper method is generated it is also used for other members members (even if * other solution could be used), as it makes the code cleaner. - *

    * * @since 3.5 */ @@ -247,7 +244,7 @@ protected void createMethodComment() throws CoreException { * * @param array if true, generated method will convert array to string, otherwise - * Collection - * @return arrayToString(Object[] array) or collectionToString(Collection + * @return arrayToString(Object[] array) or collectionToString(Collection * collection) method */ protected MethodDeclaration createHelperToStringMethod(boolean array) { diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/CustomBuilderGenerator.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/CustomBuilderGenerator.java index ae98a711c8f..b2d67080a27 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/CustomBuilderGenerator.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/CustomBuilderGenerator.java @@ -64,7 +64,6 @@ *
  • Provides a result method (usually toString()), that is a method that takes no * arguments and returns a String
  • * - *

    *

    * Generated methods look like this: * @@ -77,8 +76,6 @@ * } * * - *

    - * * @since 3.5 */ public class CustomBuilderGenerator extends AbstractToStringGenerator { diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/StringBuilderChainGenerator.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/StringBuilderChainGenerator.java index 46ffdbd9699..e20bed4aacf 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/StringBuilderChainGenerator.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/StringBuilderChainGenerator.java @@ -20,10 +20,10 @@ import org.eclipse.jdt.core.dom.Block; import org.eclipse.jdt.core.dom.Expression; import org.eclipse.jdt.core.dom.IfStatement; +import org.eclipse.jdt.core.dom.InfixExpression.Operator; import org.eclipse.jdt.core.dom.MethodInvocation; import org.eclipse.jdt.core.dom.Statement; import org.eclipse.jdt.core.dom.StringLiteral; -import org.eclipse.jdt.core.dom.InfixExpression.Operator; /** *

    @@ -42,8 +42,6 @@ * } * * - *

    - * * @since 3.5 */ public class StringBuilderChainGenerator extends StringBuilderGenerator { diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/StringBuilderGenerator.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/StringBuilderGenerator.java index c1513e49c88..0ac76550b58 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/StringBuilderGenerator.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/StringBuilderGenerator.java @@ -51,8 +51,6 @@ * } * * - *

    - * * @since 3.5 */ public class StringBuilderGenerator extends AbstractToStringGenerator { diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/StringConcatenationGenerator.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/StringConcatenationGenerator.java index cd64164ce94..55c74d9bc25 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/StringConcatenationGenerator.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/StringConcatenationGenerator.java @@ -20,10 +20,10 @@ import org.eclipse.jdt.core.dom.ConditionalExpression; import org.eclipse.jdt.core.dom.Expression; import org.eclipse.jdt.core.dom.InfixExpression; +import org.eclipse.jdt.core.dom.InfixExpression.Operator; import org.eclipse.jdt.core.dom.ParenthesizedExpression; import org.eclipse.jdt.core.dom.ReturnStatement; import org.eclipse.jdt.core.dom.StringLiteral; -import org.eclipse.jdt.core.dom.InfixExpression.Operator; /** @@ -40,8 +40,6 @@ * } * * - *

    - * * @since 3.5 */ public class StringConcatenationGenerator extends AbstractToStringGenerator { diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/StringFormatGenerator.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/StringFormatGenerator.java index 3f9b76f73bb..b6e12f11af4 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/StringFormatGenerator.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/StringFormatGenerator.java @@ -43,8 +43,6 @@ * } * * - *

    - * * @since 3.5 */ public class StringFormatGenerator extends AbstractToStringGenerator { diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/ToStringTemplateParser.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/ToStringTemplateParser.java index 69be21368f6..645b58f2884 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/ToStringTemplateParser.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/ToStringTemplateParser.java @@ -35,14 +35,13 @@ * variable to the variable directly preceding the ${otherMembers}, inclusively. The * content of this part is used once for every processed member. All template variables are * available (except for ${otherMembers}). - *
  • Separator
  • - all the characters from the template variable directly preceding the + *
  • Separator - all the characters from the template variable directly preceding the * ${otherMembers} to the ${otherMembers}, exclusively. This part does not * contain template variables and is used to separate members in the generated String. *
  • Ending - all the characters from the occurrence of the ${otherMembers} * variable (exclusively) to the end of the template (inclusively). This part can also contain only * ${object.*} variables.
  • * - *

    *

    * Note: for the template to work properly, it must contain at least one ${member.*} * variable and exactly one ${otherMembers} variable. Additionally, no diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTNodeFactory.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTNodeFactory.java index ab8d279e728..93fe1fe7ddc 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTNodeFactory.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTNodeFactory.java @@ -172,7 +172,7 @@ public static Expression not(final AST ast, final Expression expression) { /** * Negates the provided expression and applies the provided copy operation on * the returned expression: - * + *

    {@code
     	 * isValid  =>  !isValid
     	 * !isValid =>  isValid
     	 * true                           =>  false
    @@ -181,6 +181,7 @@ public static Expression not(final AST ast, final Expression expression) {
     	 * isValid || isEnabled           =>  !isValid && !isEnabled
     	 * !isValid || !isEnabled         =>  isValid && isEnabled
     	 * isValid ? (i > 0) : !isEnabled =>  isValid ? (i <= 0) : isEnabled
    +	 * }
    * * @param ast The AST to create the resulting node with. * @param rewrite the rewrite @@ -195,7 +196,7 @@ public static Expression negate(final AST ast, final ASTRewrite rewrite, final E /** * Negates the provided expression and applies the provided copy operation on * the returned expression and unwraps parentheses of result (e.g. !(x > 2) => x > 2: - * + *
    {@code
     	 * isValid  =>  !isValid
     	 * !isValid =>  isValid
     	 * true                           =>  false
    @@ -204,6 +205,7 @@ public static Expression negate(final AST ast, final ASTRewrite rewrite, final E
     	 * isValid || isEnabled           =>  !isValid && !isEnabled
     	 * !isValid || !isEnabled         =>  isValid && isEnabled
     	 * isValid ? (i > 0) : !isEnabled =>  isValid ? (i <= 0) : isEnabled
    +	 * }
    * * @param ast The AST to create the resulting node with. * @param rewrite the rewrite diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTSemanticMatcher.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTSemanticMatcher.java index b0c1f641d6d..a81a6baa6d3 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTSemanticMatcher.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTSemanticMatcher.java @@ -54,6 +54,7 @@ /** * Matches two pieces of code on semantic (not on syntax). * ASTSemanticMatcher.java matches more cases than ASTMatcher.java: + *
    {@code
      * - Inverted commutative operations:
      *   k + 1
      *   1 + k
    @@ -91,6 +92,7 @@
      * - Inverted if statements or ternary expressions:
      *   if (isValid) k++; else m--;
      *   if (!isValid) m--; else k++;
    + * }
    * * You can also match opposite boolean expressions: * ASTSemanticMatcher.matchOpposite() diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/HierarchicalASTVisitor.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/HierarchicalASTVisitor.java index ee3e3d68487..688d3bbd19e 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/HierarchicalASTVisitor.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/HierarchicalASTVisitor.java @@ -28,7 +28,7 @@ *

    * *

    - * Details: + * Details: *

    * *

    @@ -667,6 +667,16 @@ public void endVisit(Pattern node) { endVisit((Expression)node); } + @Override + public boolean visit(EitherOrMultiPattern node) { + return visit((Pattern) node); + } + + @Override + public void endVisit(EitherOrMultiPattern node) { + endVisit((Pattern) node); + } + @Override public boolean visit(ParenthesizedExpression node) { return visit((Expression)node); diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/fragments/IASTFragment.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/fragments/IASTFragment.java index bc71248e4a3..727dd2d4604 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/fragments/IASTFragment.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/fragments/IASTFragment.java @@ -51,7 +51,7 @@ public interface IASTFragment { * are the same, or that they map (via getAssociatedNode()) to the * same node. * @param other the element to test with - * @return return true if the passed element matches the current element. + * @return return true if the passed element matches the current element. */ boolean matches(IASTFragment other); diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/fragments/IExpressionFragment.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/fragments/IExpressionFragment.java index 62d7748ab23..39d4700a5f5 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/fragments/IExpressionFragment.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/fragments/IExpressionFragment.java @@ -38,7 +38,7 @@ public interface IExpressionFragment extends IASTFragment { * Creates a copy of this IExpressionFragment. * * @param rewrite an ASTRewrite - * @param removeSurroundingParenthesis if set to true, a surrounding ParenthesizedExpression will not be part of + * @param removeSurroundingParenthesis if set to true, a surrounding ParenthesizedExpression will not be part of * the copied node. * @return a copy of this IExpressionFragment, ready for use in the given * rewrite diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstants.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstants.java index 17777770d5a..9f649467e3a 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstants.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstants.java @@ -645,10 +645,9 @@ public class CleanUpConstants { public static String CONTROL_STATMENTS_CONVERT_FOR_LOOP_ONLY_IF_LOOP_VAR_USED= CONTROL_STATEMENTS_CONVERT_FOR_LOOP_ONLY_IF_LOOP_VAR_USED; /** - * Replaces if/else if/else blocks to use switch where possible. + * Replaces {@code if}/{@code else if}/{@code else} blocks to use {@code switch} where possible. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -763,10 +762,9 @@ public class CleanUpConstants { public static final String USE_LAZY_LOGICAL_OPERATOR= "cleanup.lazy_logical_operator"; //$NON-NLS-1$ /** - * Replace unnecessary primitive wrappers instance creations by using static factory valueOf() method. + * Replace unnecessary primitive wrappers instance creations by using static factory {@code valueOf()} method. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -775,10 +773,9 @@ public class CleanUpConstants { public static final String VALUEOF_RATHER_THAN_INSTANTIATION= "cleanup.valueof_rather_than_instantiation"; //$NON-NLS-1$ /** - * Replaces the compareTo() method by a comparison on primitive. + * Replaces the {@code compareTo()} method by a comparison on primitive. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -790,7 +787,6 @@ public class CleanUpConstants { * Avoids to create primitive wrapper when parsing a string. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -799,10 +795,9 @@ public class CleanUpConstants { public static final String PRIMITIVE_PARSING= "cleanup.primitive_parsing"; //$NON-NLS-1$ /** - * Replaces a primitive boxing to serialize by a call to the static toString() method. + * Replaces a primitive boxing to serialize by a call to the static {@code toString()} method. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -814,7 +809,6 @@ public class CleanUpConstants { * Replace wrapper object by primitive type when an object is not necessary. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -911,7 +905,6 @@ public class CleanUpConstants { * Uses pattern matching for the instanceof operator when possible. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -975,7 +968,6 @@ public class CleanUpConstants { * method references. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -984,10 +976,9 @@ public class CleanUpConstants { public static final String SIMPLIFY_LAMBDA_EXPRESSION_AND_METHOD_REF= "cleanup.simplify_lambda_expression_and_method_ref"; //$NON-NLS-1$ /** - * Replaces a plain comparator instance by a lambda expression passed to a Comparator.comparing() method. + * Replaces a plain comparator instance by a lambda expression passed to a {@code Comparator.comparing()} method. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -999,7 +990,6 @@ public class CleanUpConstants { * Precompiles the regular expressions. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1008,10 +998,9 @@ public class CleanUpConstants { public static final String PRECOMPILE_REGEX= "cleanup.precompile_regex"; //$NON-NLS-1$ /** - * Invert calls to Object.equals(Object) and String.equalsIgnoreCase(String) when it is known that the second operand is not null and the first can be null. + * Invert calls to {@code Object.equals(Object)} and {@code String.equalsIgnoreCase(String)} when it is known that the second operand is not null and the first can be null. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1023,7 +1012,6 @@ public class CleanUpConstants { * Check for sign of bitwise operation. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1032,10 +1020,9 @@ public class CleanUpConstants { public static final String CHECK_SIGN_OF_BITWISE_OPERATION= "cleanup.bitwise_conditional_expression"; //$NON-NLS-1$ /** - * Fixes Comparable.compareTo() usage. + * Fixes {@code Comparable.compareTo()} usage. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1047,7 +1034,6 @@ public class CleanUpConstants { * Removes a String instance from a String literal. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1059,7 +1045,6 @@ public class CleanUpConstants { * Refactor access to system properties to use constants or methods *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1069,14 +1054,13 @@ public class CleanUpConstants { /** * Replace - * System.getProperty("file.separator") + * {@code System.getProperty("file.separator")} * by *

    - * File.separator
    or
    - * FileSystems.getDefault().getSeparator() (Java 7). + * {@code File.separator}
    or
    + * {@code FileSystems.getDefault().getSeparator()} (Java 7). *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1085,11 +1069,10 @@ public class CleanUpConstants { public static final String CONSTANTS_FOR_SYSTEM_PROPERTY_FILE_SEPARATOR= "cleanup.system_property_file_separator"; //$NON-NLS-1$ /** - * Replace System.getProperty("file.encoding") by

    - * Charset.defaultCharset().displayName() + * Replace {@code System.getProperty("file.encoding")} by

    + * {@code Charset.defaultCharset().displayName()} *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1098,11 +1081,10 @@ public class CleanUpConstants { public static final String CONSTANTS_FOR_SYSTEM_PROPERTY_FILE_ENCODING= "cleanup.system_property_file_encoding"; //$NON-NLS-1$ /** - * Replace System.getProperty("path.separator") by

    - * File.pathSeparator + * Replace {@code System.getProperty("path.separator")} by

    + * {@code File.pathSeparator} *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1111,11 +1093,10 @@ public class CleanUpConstants { public static final String CONSTANTS_FOR_SYSTEM_PROPERTY_PATH_SEPARATOR= "cleanup.system_property_path_separator"; //$NON-NLS-1$ /** - * Replace System.getProperty("line.separator") by

    - * System.lineSeparator() + * Replace {@code System.getProperty("line.separator")} by

    + * {@code System.lineSeparator()} *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1125,11 +1106,10 @@ public class CleanUpConstants { /** * Replace Boolean/Long/Integer conversions using System properties to methods designed - * for the purpose. For example, replace:

    Boolean.parseBoolean(System.getProperty("arbitrarykey"))

    by

    - * Boolean.getBoolean("arbitrarykey") + * for the purpose. For example, replace:

    {@code Boolean.parseBoolean(System.getProperty("arbitrarykey"))}

    by

    + * {@code Boolean.getBoolean("arbitrarykey")} *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1141,7 +1121,6 @@ public class CleanUpConstants { * Replaces Boolean.TRUE/Boolean.FALSE by true/false when used as primitive. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1170,7 +1149,6 @@ public class CleanUpConstants { * Refactors a field into a local variable if its use is only local. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1182,7 +1160,6 @@ public class CleanUpConstants { * Add a break to avoid passive for loop iterations. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1191,10 +1168,9 @@ public class CleanUpConstants { public static final String BREAK_LOOP= "cleanup.break_loop"; //$NON-NLS-1$ /** - * Replace while by do/while. + * Replace {@code while} by {@code do}/{@code while}. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1203,10 +1179,9 @@ public class CleanUpConstants { public static final String DO_WHILE_RATHER_THAN_WHILE= "cleanup.do_while_rather_than_while"; //$NON-NLS-1$ /** - * Make inner class static. + * Make inner {@code class} static. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1218,7 +1193,6 @@ public class CleanUpConstants { * Replaces String concatenation by StringBuilder when possible. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1233,7 +1207,6 @@ public class CleanUpConstants { * {@link #STRINGBUFFER_TO_STRINGBUILDER_FOR_LOCALS}
    *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1290,7 +1263,6 @@ public class CleanUpConstants { * Replace deprecated method call with specified replacement if possible. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1299,10 +1271,9 @@ public class CleanUpConstants { public static final String REPLACE_DEPRECATED_CALLS= "cleanup.replace_deprecated_calls"; //$NON-NLS-1$ /** - * Replaces String.replaceAll() by String.replace(). + * Replaces {@code String.replaceAll()} by {@code String.replace()}. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1312,12 +1283,11 @@ public class CleanUpConstants { /** * Replace - * s.strip().length() == 0 + * {@code s.strip().length() == 0} * by - * s.isBlank() (Java 11). + * {@code s.isBlank()} (Java 11). *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1499,7 +1469,6 @@ public class CleanUpConstants { * Rewrites Eclipse-autogenerated hashcode method by Eclipse-autogenerated hashcode method for Java 7. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1520,10 +1489,9 @@ public class CleanUpConstants { public static final String REMOVE_REDUNDANT_MODIFIERS= "cleanup.remove_redundant_modifiers"; //$NON-NLS-1$ /** - * Removes the second substring() parameter if this parameter is the length of the string. + * Removes the second {@code substring()} parameter if this parameter is the length of the string. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1535,7 +1503,6 @@ public class CleanUpConstants { * Replaces for loops to use String.join() where possible. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1547,7 +1514,6 @@ public class CleanUpConstants { * Replaces a for loop on an array that assigns the same value by a call to Arrays.fill(). *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1559,7 +1525,6 @@ public class CleanUpConstants { * Removes redundant null checks. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1571,7 +1536,6 @@ public class CleanUpConstants { * Raises embedded if into parent if. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1616,10 +1580,9 @@ public class CleanUpConstants { public static final String PUSH_DOWN_NEGATION= "cleanup.push_down_negation"; //$NON-NLS-1$ /** - * Directly checks boolean values instead of comparing them with true/false. + * Directly checks boolean values instead of comparing them with {@code true}/{@code false}. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1631,7 +1594,6 @@ public class CleanUpConstants { * Reduces double negation in boolean expression. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1643,7 +1605,6 @@ public class CleanUpConstants { * Removes useless bad value checks before assignments or return statements. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1655,7 +1616,6 @@ public class CleanUpConstants { * Remove super() call in constructor. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1664,10 +1624,9 @@ public class CleanUpConstants { public static final String REDUNDANT_SUPER_CALL= "cleanup.no_super"; //$NON-NLS-1$ /** - * Detect two successive if conditions that are identical and remove the second one. + * Detect two successive {@code if} conditions that are identical and remove the second one. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1676,10 +1635,9 @@ public class CleanUpConstants { public static final String UNREACHABLE_BLOCK= "cleanup.unreachable_block"; //$NON-NLS-1$ /** - * Replaces (X && Y) || (X && Z) by (X && (Y || Z)). + * Replaces {@code (X && Y) || (X && Z) by (X && (Y || Z))}. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1688,10 +1646,9 @@ public class CleanUpConstants { public static final String OPERAND_FACTORIZATION= "cleanup.operand_factorization"; //$NON-NLS-1$ /** - * Replaces (X && Y) || (!X && Z) by X ? Y : Z. + * Replaces {@code (X && Y) || (!X && Z) by X ? Y : Z}. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1700,11 +1657,10 @@ public class CleanUpConstants { public static final String TERNARY_OPERATOR= "cleanup.ternary_operator"; //$NON-NLS-1$ /** - * Replaces (X && !Y) || (!X && Y) by X ^ Y. - * Replaces also (X && Y) || (!X && !Y) by X == Y. + * Replaces {@code (X && !Y) || (!X && Y)} by {@code X ^ Y}. + * Replaces also {@code (X && Y) || (!X && !Y)} by {@code X == Y}. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1716,7 +1672,6 @@ public class CleanUpConstants { * Merge conditions of if/else if/else that have the same blocks. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1729,7 +1684,6 @@ public class CleanUpConstants { * Ultimately it removes the empty and passive if conditions. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1738,10 +1692,9 @@ public class CleanUpConstants { public static final String CONTROLFLOW_MERGE= "cleanup.controlflow_merge"; //$NON-NLS-1$ /** - * Merge consecutive if statements with same code block that end with a jump statement. + * Merge consecutive {@code if} statements with same code block that end with a jump statement. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1750,10 +1703,9 @@ public class CleanUpConstants { public static final String ONE_IF_RATHER_THAN_DUPLICATE_BLOCKS_THAT_FALL_THROUGH= "cleanup.one_if_rather_than_duplicate_blocks_that_fall_through"; //$NON-NLS-1$ /** - * Moves an inner if statement around the outer if condition. + * Moves an inner {@code if} statement around the outer {@code if} condition. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1765,7 +1717,6 @@ public class CleanUpConstants { * Merges blocks that end with a jump statement into the following same code. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1777,7 +1728,6 @@ public class CleanUpConstants { * Remove a condition on an else that is negative to the condition of the previous if. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1801,7 +1751,6 @@ public class CleanUpConstants { * Replaces creating a new Collection, then invoking Collection.addAll() on it, by creating the new Collection with the other Collection as parameter. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1813,7 +1762,6 @@ public class CleanUpConstants { * Replaces creating a new Map, then invoking Map.putAll() on it, by creating the new Map with the other Map as parameter. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1825,7 +1773,6 @@ public class CleanUpConstants { * Remove passive assignment when the variable is reassigned before being read. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1838,7 +1785,6 @@ public class CleanUpConstants { * if necessary. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1862,7 +1808,6 @@ public class CleanUpConstants { * Remove the comparator declaration if it is the default one. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1886,7 +1831,6 @@ public class CleanUpConstants { * Replace the new instance syntax by curly brackets to create an array. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1898,7 +1842,6 @@ public class CleanUpConstants { * Removes unnecessary local variable declaration or unnecessary variable assignment before a return statement. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1910,7 +1853,6 @@ public class CleanUpConstants { * Removes useless lone return at the end of a method. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1922,7 +1864,6 @@ public class CleanUpConstants { * Removes useless lone continue at the end of a loop. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1931,10 +1872,9 @@ public class CleanUpConstants { public static final String REMOVE_USELESS_CONTINUE= "cleanup.useless_continue"; //$NON-NLS-1$ /** - * Replaces a while loop that always terminates during the first iteration by an if. + * Replaces a {@code while} loop that always terminates during the first iteration by an {@code if}. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1946,7 +1886,6 @@ public class CleanUpConstants { * Replaces a loop on elements by Collection.addAll(), Collection.addAll(Arrays.asList()) or Collections.addAll(). *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -1958,7 +1897,6 @@ public class CleanUpConstants { * Reduces the code of the equals method implementation by using Objects.equals(). *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -2110,7 +2048,6 @@ public class CleanUpConstants { * Moves increment or decrement outside an expression when possible. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -2122,7 +2059,6 @@ public class CleanUpConstants { * Moves assignments inside an if condition above the if node. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -2131,10 +2067,9 @@ public class CleanUpConstants { public static final String PULL_UP_ASSIGNMENT= "cleanup.pull_up_assignment"; //$NON-NLS-1$ /** - * Uses the else if pseudo keyword. + * Uses the {@code else if} pseudo keyword. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -2146,7 +2081,6 @@ public class CleanUpConstants { * Removes useless indentation when the opposite workflow falls through. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -2155,10 +2089,9 @@ public class CleanUpConstants { public static final String REDUCE_INDENTATION= "cleanup.reduce_indentation"; //$NON-NLS-1$ /** - * Uses an instanceof expression to check an object against a hardcoded class. + * Uses an {@code instanceof} expression to check an object against a hardcoded class. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -2259,7 +2192,6 @@ public class CleanUpConstants { * Changes code to make use of Java 7 try-with-resources feature. In particular, it removes now useless finally clauses. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -2268,10 +2200,9 @@ public class CleanUpConstants { public static final String TRY_WITH_RESOURCE= "cleanup.try_with_resource"; //$NON-NLS-1$ /** - * Refactors catch clauses with the same body to use Java 7's multi-catch. + * Refactors {@code catch} clauses with the same body to use Java 7's multi-catch. *

    * Possible values: {TRUE, FALSE} - *

    * * @see CleanUpOptions#TRUE * @see CleanUpOptions#FALSE @@ -2282,8 +2213,8 @@ public class CleanUpConstants { /** * Should the Clean Up Wizard be shown when executing the Clean Up Action?
    *
    - * Possible values: {true, false}
    - * Default value: true
    + * Possible values: {@code true}, {@code false}
    + * Default value: {@code true}
    *
    * * @since 3.3 @@ -2291,7 +2222,7 @@ public class CleanUpConstants { public static final String SHOW_CLEAN_UP_WIZARD= "cleanup.showwizard"; //$NON-NLS-1$ /** - * A key to a serialized string in the InstanceScope containing all the profiles.
    + * A key to a serialized string in the {@code InstanceScope} containing all the profiles.
    * Following code snippet can load the profiles: * *

    diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/CodeStyleFixCore.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/CodeStyleFixCore.java
    index 1b395a921ca..ca27b524662 100644
    --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/CodeStyleFixCore.java	
    +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/CodeStyleFixCore.java	
    @@ -1,5 +1,5 @@
     /*******************************************************************************
    - * Copyright (c) 2019, 2023 IBM Corporation and others.
    + * Copyright (c) 2019, 2024 IBM Corporation and others.
      *
      * This program and the accompanying materials
      * are made available under the terms of the Eclipse Public License 2.0
    @@ -31,16 +31,19 @@
     import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
     import org.eclipse.jdt.core.dom.Assignment;
     import org.eclipse.jdt.core.dom.Block;
    +import org.eclipse.jdt.core.dom.BodyDeclaration;
     import org.eclipse.jdt.core.dom.ClassInstanceCreation;
     import org.eclipse.jdt.core.dom.CompilationUnit;
     import org.eclipse.jdt.core.dom.Expression;
     import org.eclipse.jdt.core.dom.ExpressionStatement;
     import org.eclipse.jdt.core.dom.FieldAccess;
    +import org.eclipse.jdt.core.dom.FieldDeclaration;
     import org.eclipse.jdt.core.dom.IBinding;
     import org.eclipse.jdt.core.dom.IMethodBinding;
     import org.eclipse.jdt.core.dom.ITypeBinding;
     import org.eclipse.jdt.core.dom.IVariableBinding;
     import org.eclipse.jdt.core.dom.Initializer;
    +import org.eclipse.jdt.core.dom.LambdaExpression;
     import org.eclipse.jdt.core.dom.MethodInvocation;
     import org.eclipse.jdt.core.dom.Modifier;
     import org.eclipse.jdt.core.dom.Name;
    @@ -266,6 +269,12 @@ public boolean visit(final FieldAccess node) {
     			if (hasConflict(expression.getStartPosition(), name, ScopeAnalyzer.VARIABLES | ScopeAnalyzer.CHECK_VISIBILITY))
     				return true;
     
    +			ASTNode ancestor= ASTNodes.getFirstAncestorOrNull(node, LambdaExpression.class, BodyDeclaration.class);
    +			if (ancestor instanceof LambdaExpression lambdaAncestor) {
    +				if (ASTNodes.getFirstAncestorOrNull(lambdaAncestor, FieldDeclaration.class) != null) {
    +					return false;
    +				}
    +			}
     			Name qualifier= ((ThisExpression) expression).getQualifier();
     			if (qualifier != null) {
     				ITypeBinding outerClass= (ITypeBinding) qualifier.resolveBinding();
    diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertLambdaToMethodReferenceFixCore.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertLambdaToMethodReferenceFixCore.java
    index db1a7ca14c0..428065aef9b 100644
    --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertLambdaToMethodReferenceFixCore.java	
    +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertLambdaToMethodReferenceFixCore.java	
    @@ -1,5 +1,5 @@
     /*******************************************************************************
    - * Copyright (c) 2023 IBM Corporation and others.
    + * Copyright (c) 2023, 2024 IBM Corporation and others.
      *
      * This program and the accompanying materials
      * are made available under the terms of the Eclipse Public License 2.0
    @@ -23,6 +23,7 @@
     import org.eclipse.jdt.core.dom.ArrayCreation;
     import org.eclipse.jdt.core.dom.ArrayType;
     import org.eclipse.jdt.core.dom.Block;
    +import org.eclipse.jdt.core.dom.CastExpression;
     import org.eclipse.jdt.core.dom.ClassInstanceCreation;
     import org.eclipse.jdt.core.dom.CompilationUnit;
     import org.eclipse.jdt.core.dom.CreationReference;
    @@ -33,7 +34,6 @@
     import org.eclipse.jdt.core.dom.InstanceofExpression;
     import org.eclipse.jdt.core.dom.LambdaExpression;
     import org.eclipse.jdt.core.dom.MethodInvocation;
    -import org.eclipse.jdt.core.dom.MethodReference;
     import org.eclipse.jdt.core.dom.Modifier;
     import org.eclipse.jdt.core.dom.Name;
     import org.eclipse.jdt.core.dom.NameQualifiedType;
    @@ -238,7 +238,7 @@ public ConvertLambdaToMethodReferenceProposalOperation(LambdaExpression lambda,
     		public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModelCore linkedModel) throws CoreException {
     			AST ast= cuRewrite.getAST();
     			ASTRewrite rewrite= cuRewrite.getASTRewrite();
    -			MethodReference replacement;
    +			ASTNode replacement;
     
     			if (exprBody instanceof ClassInstanceCreation) {
     				CreationReference creationReference= ast.newCreationReference();
    @@ -253,11 +253,11 @@ public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModelCore
     				creationReference.typeArguments().addAll(QuickAssistProcessorUtil.getCopiedTypeArguments(rewrite, cic.typeArguments()));
     			} else if (exprBody instanceof ArrayCreation) {
     				CreationReference creationReference= ast.newCreationReference();
    -				replacement= creationReference;
     
     				ArrayType arrayType= ((ArrayCreation) exprBody).getType();
     				Type copiedElementType= (Type) rewrite.createCopyTarget(arrayType.getElementType());
     				creationReference.setType(ast.newArrayType(copiedElementType, arrayType.getDimensions()));
    +				replacement= castMethodRefIfNeeded(cuRewrite, ast, creationReference);
     			} else if (exprBody instanceof SuperMethodInvocation) {
     				SuperMethodInvocation superMethodInvocation= (SuperMethodInvocation) exprBody;
     				IMethodBinding methodBinding= superMethodInvocation.resolveMethodBinding();
    @@ -265,22 +265,22 @@ public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModelCore
     
     				if (Modifier.isStatic(methodBinding.getModifiers())) {
     					TypeMethodReference typeMethodReference= ast.newTypeMethodReference();
    -					replacement= typeMethodReference;
     
     					typeMethodReference.setName((SimpleName) rewrite.createCopyTarget(superMethodInvocation.getName()));
     					ImportRewrite importRewrite= cuRewrite.getImportRewrite();
     					ITypeBinding invocationTypeBinding= ASTNodes.getInvocationType(superMethodInvocation, methodBinding, superQualifier);
     					typeMethodReference.setType(importRewrite.addImport(invocationTypeBinding.getTypeDeclaration(), ast));
     					typeMethodReference.typeArguments().addAll(QuickAssistProcessorUtil.getCopiedTypeArguments(rewrite, superMethodInvocation.typeArguments()));
    +					replacement= castMethodRefIfNeeded(cuRewrite, ast, typeMethodReference);
     				} else {
     					SuperMethodReference superMethodReference= ast.newSuperMethodReference();
    -					replacement= superMethodReference;
     
     					if (superQualifier != null) {
     						superMethodReference.setQualifier((Name) rewrite.createCopyTarget(superQualifier));
     					}
     					superMethodReference.setName((SimpleName) rewrite.createCopyTarget(superMethodInvocation.getName()));
     					superMethodReference.typeArguments().addAll(QuickAssistProcessorUtil.getCopiedTypeArguments(rewrite, superMethodInvocation.typeArguments()));
    +					replacement= castMethodRefIfNeeded(cuRewrite, ast, superMethodReference);
     				}
     			} else if (exprBody instanceof InstanceofExpression) {
     				InstanceofExpression instanceofExpression= (InstanceofExpression) exprBody;
    @@ -291,7 +291,7 @@ public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModelCore
     				typeLiteral.setType(importRewrite.addImport(instanceofTypeBinding.getTypeDeclaration(), ast));
     				expMethodReference.setName(ast.newSimpleName("isInstance")); //$NON-NLS-1$
     				expMethodReference.setExpression(typeLiteral);
    -				replacement= expMethodReference;
    +				replacement= castMethodRefIfNeeded(cuRewrite, ast, expMethodReference);
     			} else { // MethodInvocation
     				MethodInvocation methodInvocation= (MethodInvocation) exprBody;
     				IMethodBinding methodBinding= methodInvocation.resolveMethodBinding();
    @@ -302,7 +302,6 @@ public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModelCore
     
     				if (isStaticMethod || isTypeRefToInstanceMethod) {
     					TypeMethodReference typeMethodReference= ast.newTypeMethodReference();
    -					replacement= typeMethodReference;
     
     					typeMethodReference.setName((SimpleName) rewrite.createCopyTarget(methodInvocation.getName()));
     					ImportRewrite importRewrite= cuRewrite.getImportRewrite();
    @@ -311,10 +310,9 @@ public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModelCore
     					ImportRewriteContext importRewriteContext= new ContextSensitiveImportRewriteContext(lambda, importRewrite);
     					typeMethodReference.setType(importRewrite.addImport(invocationTypeBinding, ast, importRewriteContext, TypeLocation.OTHER));
     					typeMethodReference.typeArguments().addAll(QuickAssistProcessorUtil.getCopiedTypeArguments(rewrite, methodInvocation.typeArguments()));
    -
    +					replacement= castMethodRefIfNeeded(cuRewrite, ast, typeMethodReference);
     				} else {
     					ExpressionMethodReference exprMethodReference= ast.newExpressionMethodReference();
    -					replacement= exprMethodReference;
     
     					exprMethodReference.setName((SimpleName) rewrite.createCopyTarget(methodInvocation.getName()));
     					if (invocationQualifier != null) {
    @@ -355,12 +353,57 @@ public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModelCore
     						exprMethodReference.setExpression(newThisExpression);
     					}
     					exprMethodReference.typeArguments().addAll(QuickAssistProcessorUtil.getCopiedTypeArguments(rewrite, methodInvocation.typeArguments()));
    +					replacement= castMethodRefIfNeeded(cuRewrite, ast, exprMethodReference);
     				}
     			}
     
     			ASTNodes.replaceButKeepComment(rewrite, lambda, replacement, null);
     		}
     
    +		private ASTNode castMethodRefIfNeeded(final CompilationUnitRewrite cuRewrite, AST ast, Expression methodRef) {
    +			boolean needCast= false;
    +			ASTNode replacementNode= methodRef;
    +			if (lambda.getLocationInParent() == MethodInvocation.ARGUMENTS_PROPERTY) {
    +				MethodInvocation parent= (MethodInvocation) lambda.getParent();
    +				List args= parent.arguments();
    +				IMethodBinding parentBinding= parent.resolveMethodBinding();
    +				if (parentBinding != null) {
    +					ITypeBinding parentTypeBinding= parentBinding.getDeclaringClass();
    +					while (parentTypeBinding != null) {
    +						IMethodBinding[] parentTypeMethods= parentTypeBinding.getDeclaredMethods();
    +						for (IMethodBinding parentTypeMethod : parentTypeMethods) {
    +							if (parentTypeMethod.getName().equals(parentBinding.getName()) && !parentTypeMethod.isEqualTo(parentBinding)) {
    +								needCast= true;
    +								break;
    +							}
    +						}
    +						if (!needCast) {
    +							parentTypeBinding= parentTypeBinding.getSuperclass();
    +						} else {
    +							break;
    +						}
    +					}
    +					if (needCast) {
    +						for (Expression arg : args) {
    +							if (arg == lambda) {
    +								CastExpression cast= ast.newCastExpression();
    +								cast.setExpression(methodRef);
    +								ITypeBinding argTypeBinding= arg.resolveTypeBinding();
    +								if (argTypeBinding == null) {
    +									return replacementNode;
    +								}
    +								ImportRewrite importRewriter= cuRewrite.getImportRewrite();
    +								Type argType= importRewriter.addImport(argTypeBinding, ast);
    +								cast.setType(argType);
    +								replacementNode= cast;
    +							}
    +						}
    +					}
    +				}
    +			}
    +			return replacementNode;
    +		}
    +
     		/*
     		 * return TRUE if method declaration interface is super class of lambda declaration class
     		 */
    diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertToMessageFormatFixCore.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertToMessageFormatFixCore.java
    index 5a9a2fa23c9..286f3179903 100644
    --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertToMessageFormatFixCore.java	
    +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertToMessageFormatFixCore.java	
    @@ -18,8 +18,11 @@
     
     import org.eclipse.core.runtime.CoreException;
     
    +import org.eclipse.jface.text.BadLocationException;
    +
     import org.eclipse.jdt.core.ICompilationUnit;
     import org.eclipse.jdt.core.JavaModelException;
    +import org.eclipse.jdt.core.compiler.InvalidInputException;
     import org.eclipse.jdt.core.dom.AST;
     import org.eclipse.jdt.core.dom.ASTNode;
     import org.eclipse.jdt.core.dom.Assignment;
    @@ -42,7 +45,7 @@
     import org.eclipse.jdt.internal.corext.dom.Bindings;
     import org.eclipse.jdt.internal.corext.refactoring.nls.NLSElement;
     import org.eclipse.jdt.internal.corext.refactoring.nls.NLSLine;
    -import org.eclipse.jdt.internal.corext.refactoring.nls.NLSUtil;
    +import org.eclipse.jdt.internal.corext.refactoring.nls.NLSScanner;
     import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
     import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
     
    @@ -106,28 +109,24 @@ public static ConvertToMessageFormatFixCore createConvertToMessageFormatFix(Comp
     			} else {
     				// ensure either all string literals are nls-tagged or none are
     				ICompilationUnit cu= (ICompilationUnit)compilationUnit.getJavaElement();
    -				try {
    -					NLSLine nlsLine= NLSUtil.scanCurrentLine(cu, operand.getStartPosition());
    -					if (nlsLine != null) {
    -						for (NLSElement element : nlsLine.getElements()) {
    -							if (element.getPosition().getOffset() == operand.getStartPosition()) {
    -								if (element.hasTag()) {
    -									if (seenNoTag) {
    -										return null;
    -									}
    -									seenTag= true;
    -								} else {
    -									if (seenTag) {
    -										return null;
    -									}
    -									seenNoTag= true;
    +				NLSLine nlsLine= scanCurrentLine(cu, operand);
    +				if (nlsLine != null) {
    +					for (NLSElement element : nlsLine.getElements()) {
    +						if (element.getPosition().getOffset() == compilationUnit.getColumnNumber(operand.getStartPosition())) {
    +							if (element.hasTag()) {
    +								if (seenNoTag) {
    +									return null;
    +								}
    +								seenTag= true;
    +							} else {
    +								if (seenTag) {
    +									return null;
     								}
    -								break;
    +								seenNoTag= true;
     							}
    +							break;
     						}
     					}
    -				} catch (JavaModelException e) {
    -					return null;
     				}
     			}
     		}
    @@ -140,6 +139,23 @@ public static ConvertToMessageFormatFixCore createConvertToMessageFormatFix(Comp
     				new ConvertToMessageFormatProposalOperation(oldInfixExpression));
     	}
     
    +	private static NLSLine scanCurrentLine(ICompilationUnit cu, Expression exp) {
    +		CompilationUnit cUnit= (CompilationUnit)exp.getRoot();
    +		int startLine= cUnit.getLineNumber(exp.getStartPosition());
    +		int startLinePos= cUnit.getPosition(startLine, 0);
    +		int endOfLine= cUnit.getPosition(startLine + 1, 0);
    +		NLSLine[] lines;
    +		try {
    +			lines= NLSScanner.scan(cu.getBuffer().getText(startLinePos, endOfLine - startLinePos));
    +			if (lines.length > 0) {
    +				return lines[0];
    +			}
    +		} catch (IndexOutOfBoundsException | JavaModelException | InvalidInputException | BadLocationException e) {
    +			// fall-through
    +		}
    +		return null;
    +	}
    +
     	private static void collectInfixPlusOperands(Expression expression, List collector) {
     		if (expression instanceof InfixExpression && ((InfixExpression) expression).getOperator() == InfixExpression.Operator.PLUS) {
     			InfixExpression infixExpression= (InfixExpression) expression;
    @@ -187,10 +203,10 @@ public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModelCore
     			int tagsCount= 0;
     			for (Expression operand : operands) {
     				if (operand instanceof StringLiteral) {
    -					NLSLine nlsLine= NLSUtil.scanCurrentLine(cu, operand.getStartPosition());
    +					NLSLine nlsLine= scanCurrentLine(cu, operand);
     					if (nlsLine != null) {
     						for (NLSElement element : nlsLine.getElements()) {
    -							if (element.getPosition().getOffset() == operand.getStartPosition()) {
    +							if (element.getPosition().getOffset() == root.getColumnNumber(operand.getStartPosition())) {
     								if (element.hasTag()) {
     									++tagsCount;
     								}
    diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertToStringBufferFixCore.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertToStringBufferFixCore.java
    index 76bbb2c9ed2..22d2335db5c 100644
    --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertToStringBufferFixCore.java	
    +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertToStringBufferFixCore.java	
    @@ -19,8 +19,12 @@
     
     import org.eclipse.core.runtime.CoreException;
     
    +import org.eclipse.jface.text.BadLocationException;
    +
     import org.eclipse.jdt.core.ICompilationUnit;
    +import org.eclipse.jdt.core.JavaModelException;
     import org.eclipse.jdt.core.NamingConventions;
    +import org.eclipse.jdt.core.compiler.InvalidInputException;
     import org.eclipse.jdt.core.dom.AST;
     import org.eclipse.jdt.core.dom.ASTNode;
     import org.eclipse.jdt.core.dom.Assignment;
    @@ -52,7 +56,7 @@
     import org.eclipse.jdt.internal.corext.dom.ASTNodes;
     import org.eclipse.jdt.internal.corext.refactoring.nls.NLSElement;
     import org.eclipse.jdt.internal.corext.refactoring.nls.NLSLine;
    -import org.eclipse.jdt.internal.corext.refactoring.nls.NLSUtil;
    +import org.eclipse.jdt.internal.corext.refactoring.nls.NLSScanner;
     import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
     import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
     
    @@ -256,12 +260,13 @@ public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModelCore
     
     			Statement lastAppend= insertAfter;
     			int tagsCount= 0;
    +			CompilationUnit compilationUnit= (CompilationUnit)oldInfixExpression.getRoot();
     			for (Expression operand : operands) {
     				boolean tagged= false;
    -				NLSLine nlsLine= NLSUtil.scanCurrentLine(cu, operand.getStartPosition());
    +				NLSLine nlsLine= scanCurrentLine(cu, operand);
     				if (nlsLine != null) {
     					for (NLSElement element : nlsLine.getElements()) {
    -						if (element.getPosition().getOffset() == operand.getStartPosition()) {
    +						if (element.getPosition().getOffset() == compilationUnit.getColumnNumber(operand.getStartPosition())) {
     							if (element.hasTag()) {
     								tagged= true;
     								++tagsCount;
    @@ -318,5 +323,23 @@ public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModelCore
     				linkedModel.setEndPosition(rewrite.track(bufferToString));
     			}
     		}
    +
    +		private static NLSLine scanCurrentLine(ICompilationUnit cu, Expression exp) {
    +			CompilationUnit cUnit= (CompilationUnit)exp.getRoot();
    +			int startLine= cUnit.getLineNumber(exp.getStartPosition());
    +			int startLinePos= cUnit.getPosition(startLine, 0);
    +			int endOfLine= cUnit.getPosition(startLine + 1, 0);
    +			NLSLine[] lines;
    +			try {
    +				lines= NLSScanner.scan(cu.getBuffer().getText(startLinePos, endOfLine - startLinePos));
    +				if (lines.length > 0) {
    +					return lines[0];
    +				}
    +			} catch (IndexOutOfBoundsException | JavaModelException | InvalidInputException | BadLocationException e) {
    +				// fall-through
    +			}
    +			return null;
    +		}
    +
     	}
     }
    diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertToStringFormatFixCore.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertToStringFormatFixCore.java
    index 83bbcd259ef..dbb0a728d04 100644
    --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertToStringFormatFixCore.java	
    +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertToStringFormatFixCore.java	
    @@ -18,8 +18,11 @@
     
     import org.eclipse.core.runtime.CoreException;
     
    +import org.eclipse.jface.text.BadLocationException;
    +
     import org.eclipse.jdt.core.ICompilationUnit;
     import org.eclipse.jdt.core.JavaModelException;
    +import org.eclipse.jdt.core.compiler.InvalidInputException;
     import org.eclipse.jdt.core.dom.AST;
     import org.eclipse.jdt.core.dom.ASTNode;
     import org.eclipse.jdt.core.dom.Assignment;
    @@ -39,7 +42,7 @@
     import org.eclipse.jdt.internal.corext.dom.ASTNodes;
     import org.eclipse.jdt.internal.corext.refactoring.nls.NLSElement;
     import org.eclipse.jdt.internal.corext.refactoring.nls.NLSLine;
    -import org.eclipse.jdt.internal.corext.refactoring.nls.NLSUtil;
    +import org.eclipse.jdt.internal.corext.refactoring.nls.NLSScanner;
     import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
     import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
     
    @@ -107,28 +110,24 @@ public static ConvertToStringFormatFixCore createConvertToStringFormatFix(Compil
     			} else {
     				// ensure either all string literals are nls-tagged or none are
     				ICompilationUnit cu= (ICompilationUnit)compilationUnit.getJavaElement();
    -				try {
    -					NLSLine nlsLine= NLSUtil.scanCurrentLine(cu, operand.getStartPosition());
    -					if (nlsLine != null) {
    -						for (NLSElement element : nlsLine.getElements()) {
    -							if (element.getPosition().getOffset() == operand.getStartPosition()) {
    -								if (element.hasTag()) {
    -									if (seenNoTag) {
    -										return null;
    -									}
    -									seenTag= true;
    -								} else {
    -									if (seenTag) {
    -										return null;
    -									}
    -									seenNoTag= true;
    +				NLSLine nlsLine= scanCurrentLine(cu, operand);
    +				if (nlsLine != null) {
    +					for (NLSElement element : nlsLine.getElements()) {
    +						if (element.getPosition().getOffset() == compilationUnit.getColumnNumber(operand.getStartPosition())) {
    +							if (element.hasTag()) {
    +								if (seenNoTag) {
    +									return null;
    +								}
    +								seenTag= true;
    +							} else {
    +								if (seenTag) {
    +									return null;
     								}
    -								break;
    +								seenNoTag= true;
     							}
    +							break;
     						}
     					}
    -				} catch (JavaModelException e) {
    -					return null;
     				}
     			}
     		}
    @@ -140,6 +139,23 @@ public static ConvertToStringFormatFixCore createConvertToStringFormatFix(Compil
     				new ConvertToStringFormatProposalOperation(oldInfixExpression));
     	}
     
    +	private static NLSLine scanCurrentLine(ICompilationUnit cu, Expression exp) {
    +		CompilationUnit cUnit= (CompilationUnit)exp.getRoot();
    +		int startLine= cUnit.getLineNumber(exp.getStartPosition());
    +		int startLinePos= cUnit.getPosition(startLine, 0);
    +		int endOfLine= cUnit.getPosition(startLine + 1, 0);
    +		NLSLine[] lines;
    +		try {
    +			lines= NLSScanner.scan(cu.getBuffer().getText(startLinePos, endOfLine - startLinePos));
    +			if (lines.length > 0) {
    +				return lines[0];
    +			}
    +		} catch (IndexOutOfBoundsException | JavaModelException | InvalidInputException | BadLocationException e) {
    +			// fall-through
    +		}
    +		return null;
    +	}
    +
     	private static void collectInfixPlusOperands(Expression expression, List collector) {
     		if (expression instanceof InfixExpression && ((InfixExpression) expression).getOperator() == InfixExpression.Operator.PLUS) {
     			InfixExpression infixExpression= (InfixExpression) expression;
    @@ -179,10 +195,10 @@ public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModelCore
     			int tagsCount= 0;
     			for (Expression operand : operands) {
     				if (operand instanceof StringLiteral) {
    -					NLSLine nlsLine= NLSUtil.scanCurrentLine(cu, operand.getStartPosition());
    +					NLSLine nlsLine= scanCurrentLine(cu, operand);
     					if (nlsLine != null) {
     						for (NLSElement element : nlsLine.getElements()) {
    -							if (element.getPosition().getOffset() == operand.getStartPosition()) {
    +							if (element.getPosition().getOffset() == root.getColumnNumber(operand.getStartPosition())) {
     								if (element.hasTag()) {
     									++tagsCount;
     								}
    diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/LambdaExpressionAndMethodRefFixCore.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/LambdaExpressionAndMethodRefFixCore.java
    index 98a37000b0a..63a3cbe33b5 100644
    --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/LambdaExpressionAndMethodRefFixCore.java	
    +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/LambdaExpressionAndMethodRefFixCore.java	
    @@ -1,5 +1,5 @@
     /*******************************************************************************
    - * Copyright (c) 2020, 2023 Fabrice TIERCELIN and others.
    + * Copyright (c) 2020, 2024 Fabrice TIERCELIN and others.
      *
      * This program and the accompanying materials
      * are made available under the terms of the Eclipse Public License 2.0
    @@ -26,6 +26,7 @@
     import org.eclipse.jdt.core.dom.ASTVisitor;
     import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
     import org.eclipse.jdt.core.dom.Block;
    +import org.eclipse.jdt.core.dom.CastExpression;
     import org.eclipse.jdt.core.dom.ClassInstanceCreation;
     import org.eclipse.jdt.core.dom.CompilationUnit;
     import org.eclipse.jdt.core.dom.CreationReference;
    @@ -402,7 +403,8 @@ public void rewriteAST(final CompilationUnitRewrite cuRewrite, final LinkedPropo
     
     					typeMethodRef.setType(copyType(cuRewrite, ast, typeMethodInvocation, classBinding));
     					typeMethodRef.setName(ASTNodes.createMoveTarget(rewrite, typeMethodInvocation.getName()));
    -					ASTNodes.replaceButKeepComment(rewrite, visited, typeMethodRef, group);
    +					ASTNode replacementNode1= castMethodRefIfNeeded(cuRewrite, ast, typeMethodRef);
    +					ASTNodes.replaceButKeepComment(rewrite, visited, replacementNode1, group);
     					break;
     
     				case METHOD_REF:
    @@ -416,7 +418,8 @@ public void rewriteAST(final CompilationUnitRewrite cuRewrite, final LinkedPropo
     					}
     
     					methodRef.setName(ASTNodes.createMoveTarget(rewrite, methodInvocation.getName()));
    -					ASTNodes.replaceButKeepComment(rewrite, visited, methodRef, group);
    +					ASTNode replacementNode2= castMethodRefIfNeeded(cuRewrite, ast, methodRef);
    +					ASTNodes.replaceButKeepComment(rewrite, visited, replacementNode2, group);
     					break;
     
     				case SUPER_METHOD_REF:
    @@ -424,7 +427,8 @@ public void rewriteAST(final CompilationUnitRewrite cuRewrite, final LinkedPropo
     					SuperMethodInvocation superMethodInvocation= (SuperMethodInvocation) bodyExpression;
     
     					superMethodRef.setName(ASTNodes.createMoveTarget(rewrite, superMethodInvocation.getName()));
    -					ASTNodes.replaceButKeepComment(rewrite, visited, superMethodRef, group);
    +					ASTNode replacementNode3= castMethodRefIfNeeded(cuRewrite, ast, superMethodRef);
    +					ASTNodes.replaceButKeepComment(rewrite, visited, replacementNode3, group);
     					break;
     
     				case CLASS_INSTANCE_REF:
    @@ -443,7 +447,8 @@ public void rewriteAST(final CompilationUnitRewrite cuRewrite, final LinkedPropo
     
     					instanceOfMethodRef.setExpression(typeLiteral);
     					instanceOfMethodRef.setName(ast.newSimpleName("isInstance")); //$NON-NLS-1$
    -					ASTNodes.replaceButKeepComment(rewrite, visited, instanceOfMethodRef, group);
    +					ASTNode replacementNode4= castMethodRefIfNeeded(cuRewrite, ast, instanceOfMethodRef);
    +					ASTNodes.replaceButKeepComment(rewrite, visited, replacementNode4, group);
     					break;
     
     				case DO_NOTHING:
    @@ -462,6 +467,50 @@ public void rewriteAST(final CompilationUnitRewrite cuRewrite, final LinkedPropo
     			}
     		}
     
    +		private ASTNode castMethodRefIfNeeded(final CompilationUnitRewrite cuRewrite, AST ast, Expression methodRef) {
    +			boolean needCast= false;
    +			ASTNode replacementNode= methodRef;
    +			if (visited.getLocationInParent() == MethodInvocation.ARGUMENTS_PROPERTY) {
    +				MethodInvocation parent= (MethodInvocation) visited.getParent();
    +				List args= parent.arguments();
    +				IMethodBinding parentBinding= parent.resolveMethodBinding();
    +				if (parentBinding != null) {
    +					ITypeBinding parentTypeBinding= parentBinding.getDeclaringClass();
    +					while (parentTypeBinding != null) {
    +						IMethodBinding[] parentTypeMethods= parentTypeBinding.getDeclaredMethods();
    +						for (IMethodBinding parentTypeMethod : parentTypeMethods) {
    +							if (parentTypeMethod.getName().equals(parentBinding.getName()) && !parentTypeMethod.isEqualTo(parentBinding)) {
    +								needCast= true;
    +								break;
    +							}
    +						}
    +						if (!needCast) {
    +							parentTypeBinding= parentTypeBinding.getSuperclass();
    +						} else {
    +							break;
    +						}
    +					}
    +					if (needCast) {
    +						for (Expression arg : args) {
    +							if (arg == visited) {
    +								CastExpression cast= ast.newCastExpression();
    +								cast.setExpression(methodRef);
    +								ITypeBinding argTypeBinding= arg.resolveTypeBinding();
    +								if (argTypeBinding == null) {
    +									return replacementNode;
    +								}
    +								ImportRewrite importRewriter= cuRewrite.getImportRewrite();
    +								Type argType= importRewriter.addImport(argTypeBinding, ast);
    +								cast.setType(argType);
    +								replacementNode= cast;
    +							}
    +						}
    +					}
    +				}
    +			}
    +			return replacementNode;
    +		}
    +
     		private void copyParameters(final ASTRewrite rewrite, final LambdaExpression oldLambdaExpression, final LambdaExpression copyOfLambdaExpression) {
     			for (Object oldParameter : oldLambdaExpression.parameters()) {
     				ASTNode copyOfParameter= ASTNodes.createMoveTarget(rewrite, (ASTNode) oldParameter);
    diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/LambdaExpressionsFixCore.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/LambdaExpressionsFixCore.java
    index 67c48293847..967537656bd 100644
    --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/LambdaExpressionsFixCore.java	
    +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/LambdaExpressionsFixCore.java	
    @@ -1,5 +1,5 @@
     /*******************************************************************************
    - * Copyright (c) 2013, 2023 IBM Corporation and others.
    + * Copyright (c) 2013, 2024 IBM Corporation and others.
      * All rights reserved. This program and the accompanying materials
      * are made available under the terms of the Eclipse Public License v1.0
      * which accompanies this distribution, and is available at
    @@ -60,7 +60,6 @@
     import org.eclipse.jdt.core.dom.NormalAnnotation;
     import org.eclipse.jdt.core.dom.NumberLiteral;
     import org.eclipse.jdt.core.dom.QualifiedName;
    -import org.eclipse.jdt.core.dom.QualifiedType;
     import org.eclipse.jdt.core.dom.ReturnStatement;
     import org.eclipse.jdt.core.dom.SimpleName;
     import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
    @@ -751,12 +750,12 @@ public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModelCore
     									methodRef.setExpression(ast.newThisExpression());
     								}
     								methodRef.setName(ASTNodes.createMoveTarget(rewrite, methodInvocation.getName()));
    -								cicReplacement= methodRef;
    +								cicReplacement= castMethodRefIfNeeded(cuRewrite, ast, methodRef, classInstanceCreation);
     							} else if (methodInvocationCheck.status() == MethodRefStatus.TYPE_REF) {
     								TypeMethodReference typeMethodRef= ast.newTypeMethodReference();
     								typeMethodRef.setType(copyType(cuRewrite, ast, methodInvocation, methodInvocationCheck.classBinding()));
     								typeMethodRef.setName(ASTNodes.createMoveTarget(rewrite, methodInvocation.getName()));
    -								cicReplacement= typeMethodRef;
    +								cicReplacement= castMethodRefIfNeeded(cuRewrite, ast, typeMethodRef, classInstanceCreation);
     							}
     						}
     					} else if (lambdaBody instanceof ClassInstanceCreation invokedClassInstanceCreation) {
    @@ -775,7 +774,7 @@ && areSameIdentifiers(methodDeclaration, arguments)
     						if (methodDeclaration.parameters().size() == arguments.size() && areSameIdentifiers(methodDeclaration, arguments)) {
     							SuperMethodReference superMethodRef= ast.newSuperMethodReference();
     							superMethodRef.setName(ASTNodes.createMoveTarget(rewrite, superMethodInvocation.getName()));
    -							cicReplacement= superMethodRef;
    +							cicReplacement= castMethodRefIfNeeded(cuRewrite, ast, superMethodRef, classInstanceCreation);
     						}
     					} else if (lambdaBody instanceof InstanceofExpression instanceofExpression) {
     						Expression leftOp= instanceofExpression.getLeftOperand();
    @@ -785,7 +784,7 @@ && areSameIdentifiers(methodDeclaration, arguments)
     							typeLiteral.setType(copyType(cuRewrite, ast, instanceofExpression, instanceofExpression.getRightOperand().resolveBinding()));
     							instanceofMethodReference.setName(ast.newSimpleName("isInstance")); //$NON-NLS-1$
     							instanceofMethodReference.setExpression(typeLiteral);
    -							cicReplacement= instanceofMethodReference;
    +							cicReplacement= castMethodRefIfNeeded(cuRewrite, ast, instanceofMethodReference, classInstanceCreation);
     						}
     					}
     				}
    @@ -822,9 +821,11 @@ public boolean visit(final SimpleName node) {
     										&& (variableBinding.getModifiers() & Modifier.STATIC) != 0
     										&& variableBinding.isField()
     										&& inheritedTypes.contains(variableBinding.getDeclaringClass())) {
    -									Type copyOfClassName= (Type) rewrite.createCopyTarget(classInstanceCreation.getType());
    -									QualifiedType replacement= ast.newQualifiedType(copyOfClassName, ASTNodes.createMoveTarget(rewrite, node));
    -									rewrite.replace(node, replacement, group);
    +									ITypeBinding cicBinding= classInstanceCreation.getType().resolveBinding();
    +									if (cicBinding != null) {
    +										Name replacement= ast.newName(cicBinding.getName() + "." + node.getFullyQualifiedName()); //$NON-NLS-1$
    +										rewrite.replace(node, replacement, group);
    +									}
     									return false;
     								}
     							}
    @@ -961,6 +962,50 @@ public boolean visit(final ThisExpression node) {
     			}
     		}
     
    +		private Expression castMethodRefIfNeeded(final CompilationUnitRewrite cuRewrite, AST ast, Expression methodRef, Expression visited) {
    +			boolean needCast= false;
    +			Expression replacementNode= methodRef;
    +			if (visited.getLocationInParent() == MethodInvocation.ARGUMENTS_PROPERTY) {
    +				MethodInvocation parent= (MethodInvocation) visited.getParent();
    +				List args= parent.arguments();
    +				IMethodBinding parentBinding= parent.resolveMethodBinding();
    +				if (parentBinding != null) {
    +					ITypeBinding parentTypeBinding= parentBinding.getDeclaringClass();
    +					while (parentTypeBinding != null) {
    +						IMethodBinding[] parentTypeMethods= parentTypeBinding.getDeclaredMethods();
    +						for (IMethodBinding parentTypeMethod : parentTypeMethods) {
    +							if (parentTypeMethod.getName().equals(parentBinding.getName()) && !parentTypeMethod.isEqualTo(parentBinding)) {
    +								needCast= true;
    +								break;
    +							}
    +						}
    +						if (!needCast) {
    +							parentTypeBinding= parentTypeBinding.getSuperclass();
    +						} else {
    +							break;
    +						}
    +					}
    +					if (needCast) {
    +						for (Expression arg : args) {
    +							if (arg == visited) {
    +								CastExpression cast= ast.newCastExpression();
    +								cast.setExpression(methodRef);
    +								ITypeBinding argTypeBinding= arg.resolveTypeBinding();
    +								if (argTypeBinding == null) {
    +									return replacementNode;
    +								}
    +								ImportRewrite importRewriter= cuRewrite.getImportRewrite();
    +								Type argType= importRewriter.addImport(argTypeBinding, ast);
    +								cast.setType(argType);
    +								replacementNode= cast;
    +							}
    +						}
    +					}
    +				}
    +			}
    +			return replacementNode;
    +		}
    +
     		private static void collectInheritedTypes(final ITypeBinding anonymType, final Set inheritedTypes) {
     			if (anonymType != null) {
     				ITypeBinding motherType= anonymType.getSuperclass();
    @@ -1247,7 +1292,7 @@ public static boolean isFunctionalAnonymous(ClassInstanceCreation node) {
     		if (interfaces.length != 1) {
     			return false;
     		}
    -		if (interfaces[0].getFunctionalInterfaceMethod() == null) {
    +		if (interfaces[0].getFunctionalInterfaceMethod() == null || interfaces[0].getFunctionalInterfaceMethod().isGenericMethod()) {
     			return false;
     		}
     
    diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/OneIfRatherThanDuplicateBlocksThatFallThroughFixCore.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/OneIfRatherThanDuplicateBlocksThatFallThroughFixCore.java
    index 4394cf6a632..6e4fb0de3a4 100644
    --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/OneIfRatherThanDuplicateBlocksThatFallThroughFixCore.java	
    +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/OneIfRatherThanDuplicateBlocksThatFallThroughFixCore.java	
    @@ -1,5 +1,5 @@
     /*******************************************************************************
    - * Copyright (c) 2021 Fabrice TIERCELIN and others.
    + * Copyright (c) 2021, 2024 Fabrice TIERCELIN and others.
      *
      * This program and the accompanying materials
      * are made available under the terms of the Eclipse Public License 2.0
    @@ -14,7 +14,9 @@
     package org.eclipse.jdt.internal.corext.fix;
     
     import java.util.ArrayList;
    +import java.util.HashSet;
     import java.util.List;
    +import java.util.Set;
     import java.util.concurrent.atomic.AtomicInteger;
     
     import org.eclipse.core.runtime.CoreException;
    @@ -29,6 +31,10 @@
     import org.eclipse.jdt.core.dom.Expression;
     import org.eclipse.jdt.core.dom.IfStatement;
     import org.eclipse.jdt.core.dom.InfixExpression;
    +import org.eclipse.jdt.core.dom.Pattern;
    +import org.eclipse.jdt.core.dom.PatternInstanceofExpression;
    +import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
    +import org.eclipse.jdt.core.dom.TypePattern;
     import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
     import org.eclipse.jdt.core.dom.rewrite.TargetSourceRangeComputer;
     
    @@ -72,10 +78,14 @@ public boolean visit(final Block node) {
     			public boolean visit(final IfStatement visited) {
     				if (result && ASTNodes.fallsThrough(visited.getThenStatement())) {
     					List duplicateIfBlocks= new ArrayList<>(ASTNodes.EXCESSIVE_OPERAND_NUMBER - 1);
    +					Set patternNames= new HashSet<>();
    +					PatternNameVisitor visitor= new PatternNameVisitor();
    +					visited.accept(visitor);
    +					patternNames= visitor.getPatternNames();
     					AtomicInteger operandCount= new AtomicInteger(ASTNodes.getNbOperands(visited.getExpression()));
     					duplicateIfBlocks.add(visited);
     
    -					while (addOneMoreIf(duplicateIfBlocks, operandCount)) {
    +					while (addOneMoreIf(duplicateIfBlocks, patternNames, operandCount)) {
     						// OK continue
     					}
     
    @@ -89,7 +99,27 @@ public boolean visit(final IfStatement visited) {
     				return true;
     			}
     
    -			private boolean addOneMoreIf(final List duplicateIfBlocks, final AtomicInteger operandCount) {
    +			private class PatternNameVisitor extends ASTVisitor {
    +				private Set patternNames= new HashSet<>();
    +
    +				@Override
    +				public boolean visit(PatternInstanceofExpression node) {
    +					Pattern p= node.getPattern();
    +					if (p instanceof TypePattern typePattern) {
    +						List patternVariables= typePattern.patternVariables();
    +						for (SingleVariableDeclaration patternVariable : patternVariables) {
    +							patternNames.add(patternVariable.getName().getFullyQualifiedName());
    +						}
    +					}
    +					return true;
    +				}
    +
    +				public Set getPatternNames() {
    +					return patternNames;
    +				}
    +			}
    +
    +			private boolean addOneMoreIf(final List duplicateIfBlocks, final Set patternNames, final AtomicInteger operandCount) {
     				IfStatement lastBlock= duplicateIfBlocks.get(duplicateIfBlocks.size() - 1);
     
     				if (lastBlock.getElseStatement() == null) {
    @@ -99,6 +129,14 @@ private boolean addOneMoreIf(final List duplicateIfBlocks, final At
     							&& nextSibling.getElseStatement() == null
     							&& operandCount.get() + ASTNodes.getNbOperands(nextSibling.getExpression()) < ASTNodes.EXCESSIVE_OPERAND_NUMBER
     							&& ASTNodes.match(lastBlock.getThenStatement(), nextSibling.getThenStatement())) {
    +						PatternNameVisitor visitor= new PatternNameVisitor();
    +						nextSibling.getExpression().accept(visitor);
    +						Set siblingPatternNames= visitor.getPatternNames();
    +						for (String siblingPatternName : siblingPatternNames) {
    +							if (!patternNames.add(siblingPatternName)) {
    +								return false;
    +							}
    +						}
     						operandCount.addAndGet(ASTNodes.getNbOperands(nextSibling.getExpression()));
     						duplicateIfBlocks.add(nextSibling);
     						return true;
    diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/PatternMatchingForInstanceofFixCore.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/PatternMatchingForInstanceofFixCore.java
    index 003d4a7a254..108231e59ad 100644
    --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/PatternMatchingForInstanceofFixCore.java	
    +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/PatternMatchingForInstanceofFixCore.java	
    @@ -1,5 +1,5 @@
     /*******************************************************************************
    - * Copyright (c) 2021, 2023 Fabrice TIERCELIN and others.
    + * Copyright (c) 2021, 2024 Fabrice TIERCELIN and others.
      *
      * This program and the accompanying materials
      * are made available under the terms of the Eclipse Public License 2.0
    @@ -29,6 +29,7 @@
     import org.eclipse.jdt.core.dom.CompilationUnit;
     import org.eclipse.jdt.core.dom.IfStatement;
     import org.eclipse.jdt.core.dom.InfixExpression;
    +import org.eclipse.jdt.core.dom.InfixExpression.Operator;
     import org.eclipse.jdt.core.dom.InstanceofExpression;
     import org.eclipse.jdt.core.dom.Modifier;
     import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword;
    @@ -131,6 +132,13 @@ public boolean visit(final InstanceofExpression visited) {
     					return true;
     				}
     
    +				if (currentNode instanceof InfixExpression infixExp) {
    +					if (infixExp.getOperator() != Operator.CONDITIONAL_AND &&
    +							infixExp.getOperator() != Operator.CONDITIONAL_OR) {
    +						return true;
    +					}
    +				}
    +
     				IfStatement ifStatement= (IfStatement) currentNode.getParent();
     
     				if (isPositiveCaseToAnalyze) {
    diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/StringConcatToTextBlockFixCore.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/StringConcatToTextBlockFixCore.java
    index a9b72641b01..80e8061e920 100644
    --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/StringConcatToTextBlockFixCore.java	
    +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/StringConcatToTextBlockFixCore.java	
    @@ -26,11 +26,15 @@
     
     import org.eclipse.text.edits.TextEditGroup;
     
    +import org.eclipse.jface.text.BadLocationException;
    +
    +import org.eclipse.jdt.core.IBuffer;
     import org.eclipse.jdt.core.ICompilationUnit;
     import org.eclipse.jdt.core.IJavaElement;
     import org.eclipse.jdt.core.IJavaProject;
     import org.eclipse.jdt.core.JavaCore;
     import org.eclipse.jdt.core.JavaModelException;
    +import org.eclipse.jdt.core.compiler.InvalidInputException;
     import org.eclipse.jdt.core.dom.AST;
     import org.eclipse.jdt.core.dom.ASTNode;
     import org.eclipse.jdt.core.dom.ASTVisitor;
    @@ -66,7 +70,7 @@
     import org.eclipse.jdt.internal.corext.dom.AbortSearchException;
     import org.eclipse.jdt.internal.corext.refactoring.nls.NLSElement;
     import org.eclipse.jdt.internal.corext.refactoring.nls.NLSLine;
    -import org.eclipse.jdt.internal.corext.refactoring.nls.NLSUtil;
    +import org.eclipse.jdt.internal.corext.refactoring.nls.NLSScanner;
     import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
     import org.eclipse.jdt.internal.corext.util.CodeFormatterUtil;
     import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
    @@ -119,7 +123,8 @@ public boolean visit(final InfixExpression visited) {
     				return false;
     			}
     			StringLiteral rightLiteral= (StringLiteral)leftHand;
    -			hasComments= hasComments || !ASTNodes.getTrailingComments(rightLiteral).isEmpty();
    +			ICompilationUnit cu= (ICompilationUnit)cUnit.getJavaElement();
    +			hasComments= hasComments || hasNLS(ASTNodes.getTrailingComments(rightLiteral), cu);
     			literal= rightLiteral.getLiteralValue();
     			if (!literal.isEmpty() && !fAllConcats && !literal.endsWith("\n")) { //$NON-NLS-1$
     				return false;
    @@ -130,17 +135,17 @@ public boolean visit(final InfixExpression visited) {
     			}
     			int lineNo= getLineOfOffset(cUnit, leftLiteral.getStartPosition());
     			int endPosition= getLineOffset(cUnit, lineNo + 1) == -1 ? cUnit.getLength() : getLineOffset(cUnit, lineNo + 1);
    -			hasComments= hasComments || !ASTNodes.getCommentsForRegion(cUnit, leftLiteral.getStartPosition(), endPosition - leftLiteral.getStartPosition()).isEmpty();
    +			hasComments= hasComments || hasNLS(ASTNodes.getCommentsForRegion(cUnit, leftLiteral.getStartPosition(), endPosition - leftLiteral.getStartPosition()), cu);
     			lineNo= getLineOfOffset(cUnit, rightLiteral.getStartPosition());
     			endPosition= getLineOffset(cUnit, lineNo + 1) == -1 ? cUnit.getLength() : getLineOffset(cUnit, lineNo + 1);
    -			hasComments= hasComments || !ASTNodes.getCommentsForRegion(cUnit, rightLiteral.getStartPosition(), endPosition - rightLiteral.getStartPosition()).isEmpty();
    +			hasComments= hasComments || hasNLS(ASTNodes.getCommentsForRegion(cUnit, rightLiteral.getStartPosition(), endPosition - rightLiteral.getStartPosition()), cu);
     			for (int i= 0; i < extendedOperands.size(); ++i) {
     				Expression operand= extendedOperands.get(i);
     				if (operand instanceof StringLiteral) {
     					StringLiteral stringLiteral= (StringLiteral)operand;
     					lineNo= getLineOfOffset(cUnit, stringLiteral.getStartPosition());
     					endPosition= getLineOffset(cUnit, lineNo + 1) == -1 ? cUnit.getLength() : getLineOffset(cUnit, lineNo + 1);
    -					hasComments= hasComments || !ASTNodes.getCommentsForRegion(cUnit, stringLiteral.getStartPosition(), endPosition - stringLiteral.getStartPosition()).isEmpty();
    +					hasComments= hasComments || hasNLS(ASTNodes.getCommentsForRegion(cUnit, stringLiteral.getStartPosition(), endPosition - stringLiteral.getStartPosition()), cu);
     					String string= stringLiteral.getLiteralValue();
     					if (!string.isEmpty() && (fAllConcats || string.endsWith("\n") || i == extendedOperands.size() - 1)) { //$NON-NLS-1$
     						continue;
    @@ -150,31 +155,25 @@ public boolean visit(final InfixExpression visited) {
     			}
     			boolean isTagged= false;
     			if (hasComments && ASTNodes.getFirstAncestorOrNull(visited, Annotation.class) == null) {
    -				// we must ensure that NLS comments are consistent for all string literals in concatenation
    -				ICompilationUnit cu= (ICompilationUnit)((CompilationUnit)leftHand.getRoot()).getJavaElement();
    -				try {
    -				   NLSLine nlsLine= NLSUtil.scanCurrentLine(cu, leftHand.getStartPosition());
    -				   if (nlsLine == null) {
    -					   return false;
    -				   }
    -				   isTagged= nlsLine.getElements()[0].hasTag();
    -				   if (!isConsistent(nlsLine, isTagged)) {
    -					   return false;
    -				   }
    -				   nlsLine= NLSUtil.scanCurrentLine(cu, rightHand.getStartPosition());
    -				   if (!isConsistent(nlsLine, isTagged)) {
    -					   return false;
    -				   }
    -				   for (int i= 0; i < extendedOperands.size(); ++i) {
    -					   Expression operand= extendedOperands.get(i);
    -					   nlsLine= NLSUtil.scanCurrentLine(cu, operand.getStartPosition());
    -					   if (!isConsistent(nlsLine, isTagged)) {
    -						   return false;
    -					   }
    -				   }
    -				} catch (JavaModelException e) {
    +				NLSLine nlsLine= scanCurrentLine(cu, leftHand);
    +				if (nlsLine == null) {
    +					return false;
    +				}
    +				isTagged= nlsLine.getElements()[0].hasTag();
    +				if (!isConsistent(nlsLine, isTagged)) {
     					return false;
     				}
    +				nlsLine= scanCurrentLine(cu, rightHand);
    +				if (nlsLine == null || !isConsistent(nlsLine, isTagged)) {
    +					return false;
    +				}
    +				for (int i= 0; i < extendedOperands.size(); ++i) {
    +					Expression operand= extendedOperands.get(i);
    +					nlsLine= scanCurrentLine(cu, operand);
    +					if (nlsLine == null || !isConsistent(nlsLine, isTagged)) {
    +						return false;
    +					}
    +				}
     			}
     			// check if we are untagged or else if tagged, make sure we have a Statement or FieldDeclaration
     			// ancestor so we can recreate with proper single NLS tag
    @@ -184,6 +183,41 @@ public boolean visit(final InfixExpression visited) {
     			return false;
     		}
     
    +		private NLSLine scanCurrentLine(ICompilationUnit cu, Expression exp) {
    +			CompilationUnit cUnit= (CompilationUnit)exp.getRoot();
    +			int startLine= cUnit.getLineNumber(exp.getStartPosition());
    +			int endOfLine= cUnit.getPosition(startLine + 1, 0);
    +			NLSLine[] lines;
    +			try {
    +				lines= NLSScanner.scan(cu.getBuffer().getText(exp.getStartPosition(), endOfLine - exp.getStartPosition()));
    +				if (lines.length > 0) {
    +					return lines[0];
    +				}
    +			} catch (IndexOutOfBoundsException | JavaModelException | InvalidInputException | BadLocationException e) {
    +				// fall-through
    +			}
    +			return null;
    +		}
    +
    +		private boolean hasNLS(List trailingComments, ICompilationUnit cu) {
    +			if (!trailingComments.isEmpty() && cu != null) {
    +				IBuffer buffer;
    +				try {
    +					buffer= cu.getBuffer();
    +					for (Comment comment : trailingComments) {
    +						if (comment instanceof LineComment) {
    +							if (buffer.getText(comment.getStartPosition(), comment.getLength()).contains("$NON-NLS")) { //$NON-NLS-1$
    +								return true;
    +							}
    +						}
    +					}
    +				} catch (JavaModelException e) {
    +					// fall through
    +				}
    +			}
    +			return false;
    +		}
    +
     		private int getLineOfOffset(CompilationUnit astRoot, int offset) {
     			return astRoot.getLineNumber(offset) - 1;
     		}
    @@ -274,6 +308,22 @@ public void accept(Expression t) {
     			if (newLine) {
     				buf.append(fIndent);
     			}
    +			// Replace trailing un-escaped quotes with escaped quotes before adding text block end
    +			int i= buf.length() - 1;
    +			int count= 0;
    +			while (i >= 0 && buf.charAt(i) == '"' && count <= 3) {
    +				--i;
    +				++count;
    +			}
    +			if (i >= 0 && buf.charAt(i) == '\\') {
    +				--count;
    +			}
    +			for (i= count; i > 0; --i) {
    +				buf.deleteCharAt(buf.length() - 1);
    +			}
    +			for (i= count; i > 0; --i) {
    +				buf.append("\\\""); //$NON-NLS-1$
    +			}
     			buf.append("\"\"\""); //$NON-NLS-1$
     			if (!isTagged) {
     				TextBlock textBlock= (TextBlock) rewrite.createStringPlaceholder(buf.toString(), ASTNode.TEXT_BLOCK);
    @@ -336,7 +386,6 @@ private static List unescapeBlock(String escapedText) {
     				for (int j = 0; j < quoteCount % 3; j++) {
     					transformed.append("\""); //$NON-NLS-1$
     				}
    -
     				readIndex= bsIndex + 2 * quoteCount;
     			} else if (escapedText.startsWith("\\t", bsIndex)) { //$NON-NLS-1$ "\t"
     				transformed.append(escapedText.substring(readIndex, bsIndex));
    @@ -371,12 +420,12 @@ private static String escapeTrailingWhitespace(String unescaped) {
     			if (unescaped.charAt(whitespaceStart) == ' ') {
     				whitespaceStart--;
     				trailingWhitespace.append("\\s"); //$NON-NLS-1$
    +				continue;
     			} else if (unescaped.charAt(whitespaceStart) == '\t') {
     				whitespaceStart--;
     				trailingWhitespace.append("\\t"); //$NON-NLS-1$
    -			} else {
    -				break;
     			}
    +			break;
     		}
     
     		return unescaped.substring(0, whitespaceStart + 1) + trailingWhitespace;
    @@ -695,6 +744,23 @@ public SourceRange computeSourceRange(final ASTNode nodeWithComment) {
     			if (newLine) {
     				buf.append(fIndent);
     			}
    +
    +			// Replace trailing un-escaped quotes with escaped quotes before adding text block end
    +			int readIndex= buf.length() - 1;
    +			int count= 0;
    +			while (readIndex >= 0 && buf.charAt(readIndex) == '"' && count <= 3) {
    +				--readIndex;
    +				++count;
    +			}
    +			if (readIndex >= 0 && buf.charAt(readIndex) == '\\') {
    +				--count;
    +			}
    +			for (int i= count; i > 0; --i) {
    +				buf.deleteCharAt(buf.length() - 1);
    +			}
    +			for (int i= count; i > 0; --i) {
    +				buf.append("\\\""); //$NON-NLS-1$
    +			}
     			buf.append("\"\"\""); //$NON-NLS-1$
     			MethodInvocation firstToStringCall= fToStringList.get(0);
     			AST ast= firstToStringCall.getAST();
    diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/UnwrapNewArrayOperation.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/UnwrapNewArrayOperation.java
    index 087efe9ee34..783033e83f7 100644
    --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/UnwrapNewArrayOperation.java	
    +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/UnwrapNewArrayOperation.java	
    @@ -1,5 +1,5 @@
     /*******************************************************************************
    - * Copyright (c) 2019, 2020 Red Hat Inc. and others.
    + * Copyright (c) 2019, 2024 Red Hat Inc. and others.
      *
      * This program and the accompanying materials
      * are made available under the terms of the Eclipse Public License 2.0
    @@ -13,14 +13,18 @@
      *******************************************************************************/
     package org.eclipse.jdt.internal.corext.fix;
     
    +import java.util.Collections;
     import java.util.List;
     
     import org.eclipse.core.runtime.CoreException;
     
     import org.eclipse.text.edits.TextEditGroup;
     
    +import org.eclipse.jdt.core.ICompilationUnit;
    +import org.eclipse.jdt.core.dom.ASTNode;
     import org.eclipse.jdt.core.dom.ArrayCreation;
     import org.eclipse.jdt.core.dom.ClassInstanceCreation;
    +import org.eclipse.jdt.core.dom.CompilationUnit;
     import org.eclipse.jdt.core.dom.Expression;
     import org.eclipse.jdt.core.dom.MethodInvocation;
     import org.eclipse.jdt.core.dom.SuperMethodInvocation;
    @@ -29,6 +33,9 @@
     
     import org.eclipse.jdt.internal.corext.dom.ASTNodes;
     import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation;
    +import org.eclipse.jdt.internal.corext.refactoring.nls.NLSElement;
    +import org.eclipse.jdt.internal.corext.refactoring.nls.NLSLine;
    +import org.eclipse.jdt.internal.corext.refactoring.nls.NLSUtil;
     import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
     
     /**
    @@ -46,34 +53,83 @@ public UnwrapNewArrayOperation(ArrayCreation node, Expression call) {
     	@Override
     	public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModelCore linkedModel) throws CoreException {
     		ASTRewrite rewrite= cuRewrite.getASTRewrite();
    +		List expressionsInArray= node != null && node.getInitializer() != null && node.getInitializer().expressions() != null ?
    +				node.getInitializer().expressions() : Collections.EMPTY_LIST;
    +		boolean isTagged[]= new boolean[expressionsInArray.size()];
    +		ICompilationUnit cu= cuRewrite.getCu();
     
    -		ListRewrite listRewrite;
    -		if (call instanceof ClassInstanceCreation) {
    -			listRewrite= rewrite.getListRewrite(call, ClassInstanceCreation.ARGUMENTS_PROPERTY);
    -		} else if (call instanceof MethodInvocation) {
    -			listRewrite= rewrite.getListRewrite(call, MethodInvocation.ARGUMENTS_PROPERTY);
    -		} else if (call instanceof SuperMethodInvocation) {
    -			listRewrite= rewrite.getListRewrite(call, SuperMethodInvocation.ARGUMENTS_PROPERTY);
    -		} else {
    -			return;
    +		boolean tagged= false;
    +		for (int i= 0; i < expressionsInArray.size(); ++i) {
    +			Expression operand= expressionsInArray.get(i);
    +			NLSLine nlsLine= NLSUtil.scanCurrentLine(cu, operand.getStartPosition());
    +			if (nlsLine != null) {
    +				for (NLSElement element : nlsLine.getElements()) {
    +					if (element.getPosition().getOffset() == operand.getStartPosition()) {
    +						if (element.hasTag()) {
    +							tagged= true;
    +							isTagged[i]= true;
    +						}
    +					}
    +				}
    +			}
     		}
     
     		TextEditGroup group= createTextEditGroup(FixMessages.UnusedCodeFix_RemoveUnnecessaryArrayCreation_description, cuRewrite);
     
    -		if (node.getInitializer() != null && node.getInitializer().expressions() != null) {
    -			List expressionsInArray= node.getInitializer().expressions();
    -
    -			for (int i= 1; i < expressionsInArray.size(); i++) {
    -				listRewrite.insertLast(ASTNodes.createMoveTarget(rewrite, expressionsInArray.get(i)), group);
    +		if (!tagged) {
    +			ListRewrite listRewrite;
    +			if (call instanceof ClassInstanceCreation) {
    +				listRewrite= rewrite.getListRewrite(call, ClassInstanceCreation.ARGUMENTS_PROPERTY);
    +			} else if (call instanceof MethodInvocation) {
    +				listRewrite= rewrite.getListRewrite(call, MethodInvocation.ARGUMENTS_PROPERTY);
    +			} else if (call instanceof SuperMethodInvocation) {
    +				listRewrite= rewrite.getListRewrite(call, SuperMethodInvocation.ARGUMENTS_PROPERTY);
    +			} else {
    +				return;
     			}
     
    -			if (expressionsInArray.isEmpty()) {
    -				listRewrite.remove(node, group);
    +			if (node.getInitializer() != null && node.getInitializer().expressions() != null) {
    +				for (int i= 1; i < expressionsInArray.size(); i++) {
    +					listRewrite.insertLast(ASTNodes.createMoveTarget(rewrite, expressionsInArray.get(i)), group);
    +				}
    +
    +				if (expressionsInArray.isEmpty()) {
    +					listRewrite.remove(node, group);
    +				} else {
    +					listRewrite.replace(node, ASTNodes.createMoveTarget(rewrite, expressionsInArray.get(0)), group);
    +				}
     			} else {
    -				listRewrite.replace(node, ASTNodes.createMoveTarget(rewrite, expressionsInArray.get(0)), group);
    +				listRewrite.remove(node, group);
     			}
     		} else {
    -			listRewrite.remove(node, group);
    +			// to avoid replacing/calculating non-NLS markers, simply remove the array declaration and it's braces
    +			// from the original call
    +			StringBuilder buf= new StringBuilder();
    +			CompilationUnit comp= (CompilationUnit)call.getRoot();
    +			int nodeStart= comp.getExtendedStartPosition(call);
    +			int nodeEnd= comp.getExtendedStartPosition(call) + comp.getExtendedLength(call);
    +			int arrayStart= node.getStartPosition();
    +			List expressionList= node.getInitializer().expressions();
    +			int arrayExpressionStart= expressionList.get(0).getStartPosition();
    +			Expression lastExpression= expressionList.get(expressionList.size() - 1);
    +			int arrayExpressionEnd= lastExpression.getStartPosition() + lastExpression.getLength();
    +			int arrayInitializerEnd= node.getInitializer().getStartPosition() + node.getInitializer().getLength();
    +			buf.append(cu.getBuffer().getText(nodeStart, arrayStart - nodeStart));
    +			buf.append(cu.getBuffer().getText(arrayExpressionStart, arrayExpressionEnd - arrayExpressionStart));
    +			buf.append(cu.getBuffer().getText(arrayInitializerEnd, nodeEnd - arrayInitializerEnd));
    +
    +			ASTNode replacementNode= null;
    +			if (call instanceof ClassInstanceCreation) {
    +				replacementNode= rewrite.createStringPlaceholder(buf.toString(),  ASTNode.CLASS_INSTANCE_CREATION);
    +			} else if (call instanceof MethodInvocation) {
    +				replacementNode= rewrite.createStringPlaceholder(buf.toString(),  ASTNode.METHOD_INVOCATION);
    +			} else if (call instanceof SuperMethodInvocation) {
    +				replacementNode= rewrite.createStringPlaceholder(buf.toString(),  ASTNode.SUPER_METHOD_INVOCATION);
    +			} else {
    +				return;
    +			}
    +
    +			rewrite.replace(call, replacementNode, group);
     		}
     	}
     }
    diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/base/JavaStringStatusContext.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/base/JavaStringStatusContext.java
    index f0e924ba19d..d84cc69398a 100644
    --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/base/JavaStringStatusContext.java	
    +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/base/JavaStringStatusContext.java	
    @@ -21,7 +21,7 @@
     import org.eclipse.jdt.core.ISourceRange;
     
     /**
    - * A Java string context can be used to annotate a RefactoringStatusEntry
    + * A Java string context can be used to annotate a RefactoringStatusEntry
      * with detailed information about an error detected in Java source code represented
      * by a string.
      */
    diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/rename/RippleMethodFinder2.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/rename/RippleMethodFinder2.java
    index 745382f2c06..54f970989c7 100644
    --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/rename/RippleMethodFinder2.java	
    +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/rename/RippleMethodFinder2.java	
    @@ -98,7 +98,8 @@ public void init(IType type) {
     		public IType find(IType element) {
     			IType root= element;
     			IType rep= fElementToRepresentative.get(root);
    -			while (rep != null && ! rep.equals(root)) {
    +			Set visited=new HashSet<>();
    +			while (rep != null && visited.add(root)) {
     				root= rep;
     				rep= fElementToRepresentative.get(root);
     			}
    diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/structure/ImportRewriteUtil.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/structure/ImportRewriteUtil.java
    index 752dad7a3a0..278e232263f 100644
    --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/structure/ImportRewriteUtil.java	
    +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/structure/ImportRewriteUtil.java	
    @@ -46,8 +46,8 @@ public final class ImportRewriteUtil {
     	 * @param rewrite the compilation unit rewrite whose compilation unit's imports should be updated
     	 * @param context the import rewrite context, or null if none available
     	 * @param node the AST node specifying the element for which imports should be added
    -	 * @param typeImports the map of name nodes to strings (element type: Map ).
    -	 * @param staticImports the map of name nodes to strings (element type: Map ).
    +	 * @param typeImports the map of name nodes to strings (element type: {@code Map }).
    +	 * @param staticImports the map of name nodes to strings (element type: {@code Map }).
     	 * @param declarations true if method declarations are treated as abstract, false otherwise
     	 */
     	public static void addImports(final CompilationUnitRewrite rewrite, ImportRewriteContext context, final ASTNode node, final Map typeImports, final Map staticImports, final boolean declarations) {
    @@ -60,9 +60,9 @@ public static void addImports(final CompilationUnitRewrite rewrite, ImportRewrit
     	 * @param rewrite the compilation unit rewrite whose compilation unit's imports should be updated
     	 * @param context the import rewrite context, or null if none available
     	 * @param node the AST node specifying the element for which imports should be added
    -	 * @param typeImports the map of name nodes to strings (element type: Map ).
    -	 * @param staticImports the map of name nodes to strings (element type: Map ).
    -	 * @param excludeBindings the set of bindings to exclude (element type: Set ).
    +	 * @param typeImports the map of name nodes to strings (element type: {@code Map }).
    +	 * @param staticImports the map of name nodes to strings (element type: {@code Map }).
    +	 * @param excludeBindings the set of bindings to exclude (element type: {@code Set }).
     	 * @param declarations true if method declarations are treated as abstract, false otherwise
     	 */
     	public static void addImports(final CompilationUnitRewrite rewrite, ImportRewriteContext context, final ASTNode node, final Map typeImports, final Map staticImports, final Collection excludeBindings, final boolean declarations) {
    @@ -116,8 +116,8 @@ public static void addImports(final CompilationUnitRewrite rewrite, ImportRewrit
     	 *
     	 * @param project the java project containing the element
     	 * @param node the AST node specifying the element for which imports should be collected
    -	 * @param typeBindings the set of type bindings (element type: Set ).
    -	 * @param staticBindings the set of bindings (element type: Set ).
    +	 * @param typeBindings the set of type bindings (element type: {@code Set }).
    +	 * @param staticBindings the set of bindings (element type: {@code Set }).
     	 * @param declarations true if method declarations are treated as abstract, false otherwise
     	 */
     	public static void collectImports(final IJavaProject project, final ASTNode node, final Collection typeBindings, final Collection staticBindings, final boolean declarations) {
    @@ -129,9 +129,9 @@ public static void collectImports(final IJavaProject project, final ASTNode node
     	 *
     	 * @param project the java project containing the element
     	 * @param node the AST node specifying the element for which imports should be collected
    -	 * @param typeBindings the set of type bindings (element type: Set ).
    -	 * @param staticBindings the set of bindings (element type: Set ).
    -	 * @param excludeBindings the set of bindings to exclude (element type: Set ).
    +	 * @param typeBindings the set of type bindings (element type: {@code Set }).
    +	 * @param staticBindings the set of bindings (element type: {@code Set }).
    +	 * @param excludeBindings the set of bindings to exclude (element type: {@code Set }).
     	 * @param declarations true if method declarations are treated as abstract, false otherwise
     	 */
     	public static void collectImports(final IJavaProject project, final ASTNode node, final Collection typeBindings, final Collection staticBindings, final Collection excludeBindings, final boolean declarations) {
    diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/structure/MemberVisibilityAdjustor.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/structure/MemberVisibilityAdjustor.java
    index 9aa84745c10..2f80a7a621f 100644
    --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/structure/MemberVisibilityAdjustor.java	
    +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/structure/MemberVisibilityAdjustor.java	
    @@ -973,7 +973,7 @@ else if (referencedUnit != null && referencedUnit.getParent().equals(unit.getPar
     	}
     
     	/**
    -	 * Returns the existing visibility adjustments (element type: Map ).
    +	 * Returns the existing visibility adjustments (element type: {@code Map }).
     	 *
     	 * @return the visibility adjustments
     	 */
    @@ -1097,7 +1097,7 @@ public void rewriteVisibility(final IProgressMonitor monitor) throws JavaModelEx
     	}
     
     	/**
    -	 * Sets the existing visibility adjustments to be taken into account (element type: Map ).
    +	 * Sets the existing visibility adjustments to be taken into account (element type: {@code Map }).
     	 * 

    * This method must be called before calling {@link MemberVisibilityAdjustor#adjustVisibility(IProgressMonitor)}. The default is to take no existing adjustments into account. * @@ -1156,7 +1156,7 @@ public void setRewrite(final ASTRewrite rewrite, final CompilationUnit root) { } /** - * Sets the compilation unit rewrites used by this adjustor (element type: Map ). + * Sets the compilation unit rewrites used by this adjustor (element type: {@code Map }). *

    * This method must be called before calling {@link MemberVisibilityAdjustor#adjustVisibility(IProgressMonitor)}. The default is to use no existing rewrites. * diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/JavaStatusContext.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/JavaStatusContext.java index b65ee43f785..ea86e5604e5 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/JavaStatusContext.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/JavaStatusContext.java @@ -30,7 +30,7 @@ import org.eclipse.jdt.internal.corext.dom.Selection; /** - * A Java element context that can be used to annotate a RefactoringStatusEntry + * A Java element context that can be used to annotate a RefactoringStatusEntry * with detailed information about an error detected in an IJavaElement. */ public abstract class JavaStatusContext extends RefactoringStatusContext { diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/JavadocUtil.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/JavadocUtil.java index 0492e6f9508..285d45a248d 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/JavadocUtil.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/JavadocUtil.java @@ -78,7 +78,7 @@ public static TagElement createParamTag(String parameterName, AST ast, IJavaProj /** * Decide whether to add a "param" javadoc tag or not. * @param methodDeclaration the method declaration - * @return method has javadoc && (method had no parameter before || there is already an @param tag) + * @return method has javadoc {@code &&} (method had no parameter before || there is already an {@code @param} tag) */ public static boolean shouldAddParamJavadoc(MethodDeclaration methodDeclaration) { Javadoc javadoc= methodDeclaration.getJavadoc(); diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/TextChangeManager.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/TextChangeManager.java index 2092a419b79..a9e0d02f21c 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/TextChangeManager.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/TextChangeManager.java @@ -72,11 +72,11 @@ public TextChange get(ICompilationUnit cu) { } /** - * Removes the TextChange managed under the given key - * unit. + * Removes the TextChange managed under the given key + * unit. * - * @param unit the key determining the TextChange to be removed. - * @return the removed TextChange. + * @param unit the key determining the TextChange to be removed. + * @return the removed TextChange. */ public TextChange remove(ICompilationUnit unit) { return fMap.remove(unit); diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/TextEditBasedChangeManager.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/TextEditBasedChangeManager.java index a5f68a6b9c6..85e79de81b3 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/TextEditBasedChangeManager.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/TextEditBasedChangeManager.java @@ -72,11 +72,11 @@ public TextEditBasedChange get(ICompilationUnit cu) { } /** - * Removes the TextEditBasedChange managed under the given key - * unit. + * Removes the TextEditBasedChange managed under the given key + * unit. * - * @param unit the key determining the TextEditBasedChange to be removed. - * @return the removed TextEditBasedChange. + * @param unit the key determining the TextEditBasedChange to be removed. + * @return the removed TextEditBasedChange. */ public TextEditBasedChange remove(ICompilationUnit unit) { return fMap.remove(unit); diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/TextEditUtil.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/TextEditUtil.java index 4e993604d5c..0d6657e5bcd 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/TextEditUtil.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/TextEditUtil.java @@ -48,7 +48,6 @@ public static void insert(TextEdit parent, TextEdit edit) { * * * - *

    * * @param edit the edit to verify * @return true if edit is minimal diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/ControlWorkflowMatcher.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/ControlWorkflowMatcher.java index 592a0727a54..a84106d5b0d 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/ControlWorkflowMatcher.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/ControlWorkflowMatcher.java @@ -66,7 +66,7 @@ * The conditions and the expressions are analyzed as ordinary matcher using org.eclipse.jdt.internal.corext.dom.ASTSemanticMatcher. * All the remaining part of the structure may have lots of different forms: * - *
    + * 
    {@code
      * if (c1 && c2) {
      *     return A;
      * } else if (c1 && not c2) {
    @@ -76,9 +76,9 @@
      * } else if (not c1 && c3) {
      *     return C;
      * }
    - * 
    + * }
    * - *
    + * 
    {@code
      * if (c1) {
      *   if (c2) {
      *     return A;
    @@ -90,9 +90,9 @@
      *   }
      *   return D;
      * }
    - * 
    + * }
    * - *
    + * 
    {@code
      * if (c1) {
      *   if (not c2) {
      *     return B;
    @@ -106,9 +106,9 @@
      *     return C;
      *   }
      * }
    - * 
    + * }
    * - *
    + * 
    {@code
      * if (c1) {
      *   return c2 ? A : B;
      * } else {
    @@ -120,7 +120,7 @@
      * }
      *
      * return not c2 ? A : B;
    - * 
    + * }
    */ public final class ControlWorkflowMatcher implements ControlWorkflowMatcherCompletable, ControlWorkflowMatcherRunnable { /** diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/LRUMap.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/LRUMap.java index dc7c0f76515..abeaf896665 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/LRUMap.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/LRUMap.java @@ -21,8 +21,8 @@ * Least-recently-used cache. When the map tops the maximum size configured in the constructor, it * automatically removes the oldest entry in terms of last access. *

    - * Invoking the put or get method results in an access to the corresponding entry. - * The putAll method generates one entry access for each mapping in the specified map, in + * Invoking the put or get method results in an access to the corresponding entry. + * The putAll method generates one entry access for each mapping in the specified map, in * the order that key-value mappings are provided by the specified map's entry set iterator. No * other methods generate entry accesses. In particular, operations on collection-views do * not affect the order of iteration of the backing map. diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/Resources.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/Resources.java index acddba41d20..3f67847bd8d 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/Resources.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/Resources.java @@ -82,7 +82,7 @@ public static IStatus checkInSync(IResource[] resources) { /** * Makes the given resource committable. Committable means that it is * writeable and that its content hasn't changed by calling - * validateEdit for the given resource on IWorkspace. + * validateEdit for the given resource on IWorkspace. * * @param resource the resource to be checked * @param context the context passed to validateEdit @@ -98,7 +98,7 @@ public static IStatus makeCommittable(IResource resource, Object context) { * Makes the given resources committable. Committable means that all * resources are writeable and that the content of the resources hasn't * changed by calling validateEdit for a given file on - * IWorkspace. + * IWorkspace. * * @param resources the resources to be checked * @param context the context passed to validateEdit diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/SearchUtils.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/SearchUtils.java index 23bf0bce558..f56b4a4a23c 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/SearchUtils.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/SearchUtils.java @@ -68,7 +68,7 @@ public static SearchParticipant[] getDefaultSearchParticipants() { /** * Returns whether the given pattern is a camel case pattern or not. * Note: this method does not consider the - * {@link SearchPattern#R_CAMELCASE_SAME_PART_COUNT_MATCH} variant. + * {@link SearchPattern#R_CAMELCASE_SAME_PART_COUNT_MATCH} variant. * * @param pattern the pattern to inspect * @return whether it is a camel case pattern or not diff --git a/org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractTempRefactoring.java b/org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractTempRefactoring.java index a7c64b86146..3d02f460730 100644 --- a/org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractTempRefactoring.java +++ b/org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractTempRefactoring.java @@ -1119,7 +1119,7 @@ private boolean hasFinalModifer(List modifiers) { private void createAndInsertTempDeclaration() throws CoreException { Expression initializer= getSelectedExpression().createCopyTarget(fCURewrite.getASTRewrite(), true); - VariableDeclarationStatement vds= createTempDeclaration(initializer); + VariableDeclarationExpression vds= createTempDeclaration(initializer); boolean insertAtSelection; if (!fReplaceAllOccurrences) { @@ -1140,6 +1140,44 @@ private void createAndInsertTempDeclaration() throws CoreException { fDeclareFinal= true; } + if (node instanceof TryStatement tryStatement) { + if (getSelectedExpression().getAssociatedNode() instanceof Expression originalexp) { + ITypeBinding vdsBinding= originalexp.resolveTypeBinding(); + if (vdsBinding != null) { + boolean isAutoCloseable= false; + for (ITypeBinding superType : Bindings.getAllSuperTypes(vdsBinding)) { + if ("java.lang.AutoCloseable".equals(superType.getQualifiedName())) { //$NON-NLS-1$ + isAutoCloseable= true; + break; + } + } + if (isAutoCloseable) { + List resources= tryStatement.resources(); + ASTNode originalNode= getSelectedExpression().getAssociatedNode(); + boolean resourceFound= false; + for (Expression resource : resources) { + int offset= resource.getStartPosition(); + ASTNode parent= originalNode.getParent(); + while (parent != null) { + if (parent == resource) { + resourceFound= true; + node= resource; + fReplaceAllOccurrences= false; + break; + } else if (parent.getStartPosition() < offset) { + break; + } + parent= parent.getParent(); + } + if (resourceFound) { + break; + } + } + } + } + } + } + IASTFragment[] retainOnlyReplacableMatches= retainOnlyReplacableMatches(getMatchingFragments()); if (retainOnlyReplacableMatches == null) { return; @@ -1153,11 +1191,18 @@ private void createAndInsertTempDeclaration() throws CoreException { break; } } - if (node instanceof SwitchStatement || node instanceof EnhancedForStatement) { + AST ast= fCURewrite.getAST(); + if (node instanceof SwitchStatement || node instanceof EnhancedForStatement || node instanceof TryStatement) { /* must insert above switch statement */ fStartPoint= 0; fEndPoint= retainOnlyReplacableMatches.length - 1; - insertAt(node, vds); + ExpressionStatement exs= ast.newExpressionStatement(vds); + insertAt(node, exs); + return; + } else if (node != null && node.getLocationInParent() == TryStatement.RESOURCES2_PROPERTY) { + fStartPoint= 0; + fEndPoint= retainOnlyReplacableMatches.length - 1; + insertResourceAt(node, vds); return; } else { if (insertAtSelection) { @@ -1167,18 +1212,20 @@ private void createAndInsertTempDeclaration() throws CoreException { fSeen.add(retainOnlyReplacableMatches[selectNumber]); } if (realCommonASTNode != null || retainOnlyReplacableMatches.length == 0) { - insertAt(getSelectedExpression().getAssociatedNode(), vds); + ExpressionStatement exs= ast.newExpressionStatement(vds); + insertAt(getSelectedExpression().getAssociatedNode(), exs); } return; } } ASTNode realCommonASTNode= null; + ExpressionStatement exs= ast.newExpressionStatement(vds); realCommonASTNode= evalStartAndEnd(retainOnlyReplacableMatches, selectNumber, null); if (realCommonASTNode == null && selectNumber >= 0) { fSeen.add(retainOnlyReplacableMatches[selectNumber]); } if (realCommonASTNode != null) { - insertAt(realCommonASTNode, vds); + insertAt(realCommonASTNode, exs); } return; } @@ -1281,14 +1328,14 @@ private ASTNode convertToExtractNode(ASTNode target) { return target; } - private VariableDeclarationStatement createTempDeclaration(Expression initializer) throws CoreException { + private VariableDeclarationExpression createTempDeclaration(Expression initializer) throws CoreException { AST ast= fCURewrite.getAST(); VariableDeclarationFragment vdf= ast.newVariableDeclarationFragment(); vdf.setName(ast.newSimpleName(fTempName)); vdf.setInitializer(initializer); - VariableDeclarationStatement vds= ast.newVariableDeclarationStatement(vdf); + VariableDeclarationExpression vds= ast.newVariableDeclarationExpression(vdf); if (fDeclareFinal) { if (!hasFinalModifer(vds.modifiers())) { vds.modifiers().add(ast.newModifier(ModifierKeyword.FINAL_KEYWORD)); @@ -1312,12 +1359,22 @@ private VariableDeclarationStatement createTempDeclaration(Expression initialize return vds; } + private void insertResourceAt(ASTNode target, VariableDeclarationExpression exp) { + ASTRewrite rewrite= fCURewrite.getASTRewrite(); + TextEditGroup groupDescription= fCURewrite.createGroupDescription(RefactoringCoreMessages.ExtractTempRefactoring_declare_local_variable); + StructuralPropertyDescriptor locationInParent= target.getLocationInParent(); + ASTNode parent= target.getParent(); + ListRewrite listRewrite= rewrite.getListRewrite(parent, (ChildListPropertyDescriptor) locationInParent); + listRewrite.insertBefore(exp, target, groupDescription); + } + private void insertAt(ASTNode target, Statement declaration) { ASTRewrite rewrite= fCURewrite.getASTRewrite(); TextEditGroup groupDescription= fCURewrite.createGroupDescription(RefactoringCoreMessages.ExtractTempRefactoring_declare_local_variable); ASTNode parent= target.getParent(); StructuralPropertyDescriptor locationInParent= target.getLocationInParent(); - while (locationInParent != Block.STATEMENTS_PROPERTY && locationInParent != SwitchStatement.STATEMENTS_PROPERTY) { + while (locationInParent != Block.STATEMENTS_PROPERTY && locationInParent != SwitchStatement.STATEMENTS_PROPERTY + && locationInParent != TryStatement.RESOURCES2_PROPERTY) { if (locationInParent == IfStatement.THEN_STATEMENT_PROPERTY || locationInParent == IfStatement.ELSE_STATEMENT_PROPERTY || locationInParent == ForStatement.BODY_PROPERTY @@ -1695,17 +1752,18 @@ private void replaceSelectedExpressionWithTempDeclaration() throws CoreException evalStartAndEnd(retainOnlyReplacableMatches(getMatchingFragments()), 0, Integer.valueOf(selectedExpression.getStartPosition() + selectedExpression.getLength())); Expression initializer= (Expression) rewrite.createMoveTarget(selectedExpression); - VariableDeclarationStatement tempDeclaration= createTempDeclaration(initializer); + VariableDeclarationExpression tempDeclarationExpression= createTempDeclaration(initializer); ASTNode replacement; ASTNode parent= selectedExpression.getParent(); boolean isParentLambda= parent instanceof LambdaExpression; AST ast= rewrite.getAST(); + ExpressionStatement tempDeclaration= ast.newExpressionStatement(tempDeclarationExpression); if (isParentLambda) { Block blockBody= ast.newBlock(); blockBody.statements().add(tempDeclaration); if (!Bindings.isVoidType(((LambdaExpression) parent).resolveMethodBinding().getReturnType())) { - List fragments= tempDeclaration.fragments(); + List fragments= tempDeclarationExpression.fragments(); SimpleName varName= fragments.get(0).getName(); ReturnStatement returnStatement= ast.newReturnStatement(); returnStatement.setExpression(ast.newSimpleName(varName.getIdentifier())); diff --git a/org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeTypeRefactoring.java b/org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeTypeRefactoring.java index b4699b2e516..791a7e8c09b 100644 --- a/org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeTypeRefactoring.java +++ b/org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeTypeRefactoring.java @@ -1449,9 +1449,9 @@ public String getTarget() { } /** - * Returns the Collection of names of types that can be given to the selected declaration. + * Returns the {@code Collection} of names of types that can be given to the selected declaration. * (used in tests only) - * @return Collection of names of types that can be given to the selected declaration + * @return {@code Collection} of names of types that can be given to the selected declaration */ public Collection getValidTypeNames() { Collection typeNames= new ArrayList<>(); diff --git a/org.eclipse.jdt.junit.core/META-INF/MANIFEST.MF b/org.eclipse.jdt.junit.core/META-INF/MANIFEST.MF index 0d56403e4f8..78c5d84f91e 100644 --- a/org.eclipse.jdt.junit.core/META-INF/MANIFEST.MF +++ b/org.eclipse.jdt.junit.core/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.jdt.junit.core Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.jdt.junit.core;singleton:=true -Bundle-Version: 3.13.100.qualifier +Bundle-Version: 3.13.200.qualifier Bundle-Activator: org.eclipse.jdt.internal.junit.JUnitCorePlugin Bundle-ActivationPolicy: lazy Bundle-Vendor: %providerName diff --git a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/BasicElementLabels.java b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/BasicElementLabels.java index 1d16366a03a..36e117bc580 100644 --- a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/BasicElementLabels.java +++ b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/BasicElementLabels.java @@ -122,7 +122,7 @@ public static String getVersionName(String name) { /** - * Returns a label for Java element name. Example is 'new Test() { ...}'. + * Returns a label for Java element name. Example is {@code 'new Test() { ...}'}. * This method should only be used for simple element names. Use * JavaElementLabels to create a label from a Java element. * diff --git a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchConfigurationConstants.java b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchConfigurationConstants.java index d45248e367e..2d3e55b20ea 100644 --- a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchConfigurationConstants.java +++ b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchConfigurationConstants.java @@ -57,8 +57,9 @@ public class JUnitLaunchConfigurationConstants { public static final String ATTR_TEST_NAME= JUnitCorePlugin.PLUGIN_ID + ".TESTNAME"; //$NON-NLS-1$ /** - * @Deprecated use {@link #ATTR_TEST_NAME} + * @deprecated use {@link #ATTR_TEST_NAME} **/ + @Deprecated(forRemoval= true, since= "2024-03" ) public static final String ATTR_TEST_METHOD_NAME= ATTR_TEST_NAME; public static final String ATTR_KEEPRUNNING = JUnitCorePlugin.PLUGIN_ID+ ".KEEPRUNNING_ATTR"; //$NON-NLS-1$ diff --git a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestSuiteElement.java b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestSuiteElement.java index ba8e5cdc6aa..ec8e7907a57 100644 --- a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestSuiteElement.java +++ b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestSuiteElement.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2023 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -15,7 +15,6 @@ package org.eclipse.jdt.internal.junit.model; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import org.eclipse.jdt.junit.model.ITestElement; @@ -48,8 +47,7 @@ public String getSuiteTypeName() { @Override public ITestElement[] getChildren() { - TestElement[] elements= fChildren.toArray(new TestElement[fChildren.size()]); // copy list to avoid concurrency problems - return Arrays.stream(elements).filter(e -> !isSingleDynamicTest(e)).toArray(ITestElement[]::new); + return fChildren.toArray(new ITestElement[fChildren.size()]); } public void addChild(TestElement child) { @@ -156,44 +154,4 @@ public String toString() { return "TestSuite: " + getTestName() + " : " + super.toString() + " (" + fChildren.size() + ")"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } - @Override - public String getTrace() { - TestCaseElement child= getSingleDynamicChild(); - if (child != null) { - return child.getTrace(); - } - return super.getTrace(); - } - - private static boolean isSingleDynamicTest(TestElement element) { - if (element instanceof TestCaseElement) { - TestCaseElement testCase = (TestCaseElement) element; - TestSuiteElement suite = testCase.getParent(); - if (testCase.isDynamicTest() && suite.fChildren.size() == 1) { - return true; - } - } - return false; - } - - /** - * If this test suite is a {@code @TestTemplate} test case with a single child, return that child. - * @return The single dynamic test case child or {@code null} if the suite has no children or multiple or non-dynamid children. - */ - public TestCaseElement getSingleDynamicChild() { - try { - if (fChildren.size() == 1) { - TestElement child= fChildren.get(0); - if (child instanceof TestCaseElement) { - TestCaseElement testCase= (TestCaseElement) child; - if (testCase.isDynamicTest()) { - return testCase; - } - } - } - } catch (IndexOutOfBoundsException e) { - // don't care, children changed concurrently - } - return null; - } } diff --git a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationDelegate.java b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationDelegate.java index 4cd13ca9f35..0d136823008 100644 --- a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationDelegate.java +++ b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationDelegate.java @@ -53,6 +53,7 @@ import org.eclipse.jdt.core.IClasspathAttribute; import org.eclipse.jdt.core.IClasspathEntry; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IMember; @@ -458,7 +459,7 @@ protected void collectExecutionArguments(ILaunchConfiguration configuration, Lis programArguments.add("-classNames"); //$NON-NLS-1$ programArguments.add(type.getFullyQualifiedName()); collectAddOpensVmArgs(addOpensTargets, addOpensVmArgs, type, configuration); - } else if (testElement instanceof IPackageFragment || testElement instanceof IPackageFragmentRoot || testElement instanceof IJavaProject) { + } else if (testElement instanceof IPackageFragment || testElement instanceof IJavaProject) { Set pkgNames= new HashSet<>(); String fileName= createPackageNamesFile(testElement, testRunnerKind, pkgNames); programArguments.add("-packageNameFile"); //$NON-NLS-1$ @@ -468,6 +469,15 @@ protected void collectExecutionArguments(ILaunchConfiguration configuration, Lis collectAddOpensVmArgs(addOpensTargets, addOpensVmArgs, pkgName, configuration); } } + } else if (testElement instanceof IPackageFragmentRoot packageFragmentRoot) { + List typesToExecute= enumerateTypesInPackage(packageFragmentRoot); + IJavaElement[] collectedTestElements = typesToExecute.toArray(new IJavaElement[typesToExecute.size()]); + String fileName= createTestNamesFile(collectedTestElements); + programArguments.add("-testNameFile"); //$NON-NLS-1$ + programArguments.add(fileName); + for (IJavaElement singleTestType : collectedTestElements) { + collectAddOpensVmArgs(addOpensTargets, addOpensVmArgs, singleTestType, configuration); + } } else { abort(JUnitMessages.JUnitLaunchConfigurationDelegate_error_wrong_input, null, IJavaLaunchConfigurationConstants.ERR_UNSPECIFIED_MAIN_TYPE); } @@ -521,6 +531,25 @@ protected void collectExecutionArguments(ILaunchConfiguration configuration, Lis } } + private List enumerateTypesInPackage(IPackageFragmentRoot packageFragmentRoot) throws JavaModelException { + List typesToExecute = new ArrayList<>(); + for (IJavaElement child : packageFragmentRoot.getChildren()) { + if (child instanceof IPackageFragment packageFragment) { + if (packageFragment.hasChildren()) { + IJavaElement[] children= packageFragment.getChildren(); + for (IJavaElement ije : children) { + if (ije instanceof ICompilationUnit icu) { + IType[] allTypes= icu.getAllTypes(); + IType topLevelType = allTypes[0]; + typesToExecute.add(topLevelType); + } + } + } + } + } + return typesToExecute; + } + private static boolean isOnModulePath(IJavaProject javaProject, String typeToCheck) { try { IType type= javaProject.findType(typeToCheck); diff --git a/org.eclipse.jdt.junit.runtime/pom.xml b/org.eclipse.jdt.junit.runtime/pom.xml index ad35c57d6b8..a213834417a 100644 --- a/org.eclipse.jdt.junit.runtime/pom.xml +++ b/org.eclipse.jdt.junit.runtime/pom.xml @@ -14,7 +14,7 @@ eclipse.jdt.ui eclipse.jdt.ui - 4.31.0-SNAPSHOT + 4.32.0-SNAPSHOT org.eclipse.jdt org.eclipse.jdt.junit.runtime diff --git a/org.eclipse.jdt.junit/META-INF/MANIFEST.MF b/org.eclipse.jdt.junit/META-INF/MANIFEST.MF index e36e0df5d15..3658c350ebb 100644 --- a/org.eclipse.jdt.junit/META-INF/MANIFEST.MF +++ b/org.eclipse.jdt.junit/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.jdt.junit Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.jdt.junit;singleton:=true -Bundle-Version: 3.16.300.qualifier +Bundle-Version: 3.16.400.qualifier Bundle-Activator: org.eclipse.jdt.internal.junit.ui.JUnitPlugin Bundle-ActivationPolicy: lazy Bundle-Vendor: %providerName diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestViewer.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestViewer.java index a982151d7b3..48082404b49 100644 --- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestViewer.java +++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestViewer.java @@ -452,14 +452,6 @@ private OpenTestAction getOpenTestAction(TestSuiteElement testSuite) { // a group of parameterized tests return new OpenTestAction(fTestRunnerPart, (TestCaseElement) children[0], null); } - if (children.length == 0) { - // check if we have applied the workaround for: https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/945 - TestCaseElement child= testSuite.getSingleDynamicChild(); - if (child != null) { - // a parameterized test that ran only one test - return new OpenTestAction(fTestRunnerPart, child, null); - } - } int index= testName.indexOf('('); // test factory method diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/Resources.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/Resources.java index 26ed0e0eb2b..166a569abb9 100644 --- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/Resources.java +++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/Resources.java @@ -73,7 +73,7 @@ public static IStatus checkInSync(IResource[] resources) { /** * Makes the given resource committable. Committable means that it is * writeable and that its content hasn't changed by calling - * validateEdit for the given resource on IWorkspace. + * validateEdit for the given resource on IWorkspace. * * @param resource the resource to be checked * @param context the context passed to validateEdit @@ -91,7 +91,7 @@ public static IStatus makeCommittable(IResource resource, Object context) { * Makes the given resources committable. Committable means that all * resources are writeable and that the content of the resources hasn't * changed by calling validateEdit for a given file on - * IWorkspace. + * IWorkspace. * * @param resources the resources to be checked * @param context the context passed to validateEdit diff --git a/org.eclipse.jdt.junit4.runtime/pom.xml b/org.eclipse.jdt.junit4.runtime/pom.xml index 31d9c700296..51a55476cb0 100644 --- a/org.eclipse.jdt.junit4.runtime/pom.xml +++ b/org.eclipse.jdt.junit4.runtime/pom.xml @@ -14,7 +14,7 @@ eclipse.jdt.ui eclipse.jdt.ui - 4.31.0-SNAPSHOT + 4.32.0-SNAPSHOT org.eclipse.jdt org.eclipse.jdt.junit4.runtime diff --git a/org.eclipse.jdt.junit5.runtime/pom.xml b/org.eclipse.jdt.junit5.runtime/pom.xml index 41cb3bce200..390413f1ce0 100644 --- a/org.eclipse.jdt.junit5.runtime/pom.xml +++ b/org.eclipse.jdt.junit5.runtime/pom.xml @@ -14,7 +14,7 @@ eclipse.jdt.ui eclipse.jdt.ui - 4.31.0-SNAPSHOT + 4.32.0-SNAPSHOT org.eclipse.jdt org.eclipse.jdt.junit5.runtime diff --git a/org.eclipse.jdt.text.tests/META-INF/MANIFEST.MF b/org.eclipse.jdt.text.tests/META-INF/MANIFEST.MF index c6ccf5a1eba..65a500bad67 100644 --- a/org.eclipse.jdt.text.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.jdt.text.tests/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.jdt.text.tests Bundle-ManifestVersion: 2 Bundle-Name: %Plugin.name Bundle-SymbolicName: org.eclipse.jdt.text.tests;singleton:=true -Bundle-Version: 3.14.300.qualifier +Bundle-Version: 3.14.400.qualifier Bundle-Activator: org.eclipse.jdt.text.tests.JdtTextTestPlugin Bundle-ActivationPolicy: lazy Bundle-Vendor: %Plugin.providerName diff --git a/org.eclipse.jdt.text.tests/pom.xml b/org.eclipse.jdt.text.tests/pom.xml index f5c3193852b..8c2e27b6806 100644 --- a/org.eclipse.jdt.text.tests/pom.xml +++ b/org.eclipse.jdt.text.tests/pom.xml @@ -15,12 +15,12 @@ tests-pom eclipse.jdt.ui - 4.31.0-SNAPSHOT + 4.32.0-SNAPSHOT ../tests-pom/ org.eclipse.jdt org.eclipse.jdt.text.tests - 3.14.300-SNAPSHOT + 3.14.400-SNAPSHOT eclipse-test-plugin diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ChainCompletionTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ChainCompletionTest.java index 227384b3a70..e180da1ba40 100644 --- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ChainCompletionTest.java +++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ChainCompletionTest.java @@ -28,6 +28,10 @@ import org.eclipse.swt.SWT; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; + +import org.eclipse.core.resources.ProjectScope; + import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextViewer; @@ -42,7 +46,9 @@ import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.core.manipulation.JavaManipulation; +import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup; import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; @@ -87,6 +93,27 @@ public void testNullExpectedType() throws Exception { assertEquals(0, proposals.size()); } + @Test + public void testInvalidPreferenceHandling() throws Exception { + IEclipsePreferences node= new ProjectScope(fJProject.getProject()).getNode(JavaManipulation.getPreferenceNodeId()); + node.put(PreferenceConstants.PREF_MAX_CHAIN_LENGTH, "number_four"); + + StringBuffer buf= new StringBuffer(); + buf.append("package test;\n" + + "public class Foo {\n" + + " public void foo () {\n" + + " String s = \"\";\n" + + " int length = $\n" + + " }\n" + + "}"); + + int completionIndex= getCompletionIndex(buf); + ICompilationUnit cu= getCompilationUnit(pkg, buf, "Foo.java"); + + List proposals= computeCompletionProposals(cu, completionIndex); + assertEquals(0, proposals.size()); + } + @Test public void testBasic() throws Exception { StringBuffer buf= new StringBuffer(); diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CodeCompletionTest16.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CodeCompletionTest16.java new file mode 100644 index 00000000000..76bb013ceed --- /dev/null +++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CodeCompletionTest16.java @@ -0,0 +1,183 @@ +/******************************************************************************* + * Copyright (c) 2024 GK Software AG, IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Stephan Herrmann - initial API and implementation - https://bugs.eclipse.org/425183 + * IBM Corporation - initial API and implementation + * Red Hat Inc. - modified to test Java 16 + *******************************************************************************/ +package org.eclipse.jdt.text.tests.contentassist; + +import static org.junit.Assert.assertEquals; + +import java.util.Hashtable; +import java.util.List; + +import org.junit.Rule; +import org.junit.Test; + +import org.eclipse.jdt.testplugin.JavaProjectHelper; +import org.eclipse.jdt.testplugin.TestOptions; + +import org.eclipse.core.runtime.CoreException; + +import org.eclipse.jface.preference.IPreferenceStore; + +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.contentassist.ICompletionProposal; +import org.eclipse.jface.text.source.ISourceViewer; + +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IEditorReference; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPartSite; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; + +import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.IPackageFragment; +import org.eclipse.jdt.core.IPackageFragmentRoot; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; + +import org.eclipse.jdt.internal.core.manipulation.CodeTemplateContextType; +import org.eclipse.jdt.internal.core.manipulation.StubUtility; + +import org.eclipse.jdt.ui.JavaUI; +import org.eclipse.jdt.ui.PreferenceConstants; +import org.eclipse.jdt.ui.tests.core.rules.Java16ProjectTestSetup; +import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; + +import org.eclipse.jdt.internal.ui.JavaPlugin; +import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; +import org.eclipse.jdt.internal.ui.text.java.JavaAllCompletionProposalComputer; +import org.eclipse.jdt.internal.ui.text.java.JavaTypeCompletionProposalComputer; + +/** + * Those tests are made to run on Java 16 + */ +public class CodeCompletionTest16 extends AbstractCompletionTest { + @Rule + public Java16ProjectTestSetup j16s= new Java16ProjectTestSetup(true); + + private IJavaProject fJProject1; + + @Override + public void setUp() throws Exception { + fJProject1= j16s.getProject(); + fJProject1.setOption(JavaCore.COMPILER_COMPLIANCE, "16"); + fJProject1.setOption(JavaCore.COMPILER_SOURCE, "16"); + fJProject1.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, "16"); + fJProject1.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED); + + + Hashtable options= TestOptions.getDefaultOptions(); + options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1"); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); + options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); + options.put(JavaCore.CODEASSIST_FIELD_PREFIXES, "f"); + options.put(JavaCore.COMPILER_COMPLIANCE, "16"); + options.put(JavaCore.COMPILER_SOURCE, "16"); + options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, "16"); + JavaCore.setOptions(options); + + IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore(); + store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, true); + store.setValue(PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS, true); + store.setValue(PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS, true); + + StubUtility.setCodeTemplate(CodeTemplateContextType.OVERRIDECOMMENT_ID, "/* (non-Javadoc)\n * ${see_to_overridden}\n */", null); + StubUtility.setCodeTemplate(CodeTemplateContextType.DELEGATECOMMENT_ID, "/* (non-Javadoc)\n * ${see_to_target}\n */", null); + StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null); + StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORCOMMENT_ID, "/**\n * Constructor.\n */", null); + StubUtility.setCodeTemplate(CodeTemplateContextType.METHODCOMMENT_ID, "/**\n * Method.\n */", null); + StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, "//TODO\n${body_statement}", null); + StubUtility.setCodeTemplate(CodeTemplateContextType.GETTERCOMMENT_ID, "/**\n * @return the ${bare_field_name}\n */", fJProject1); + StubUtility.setCodeTemplate(CodeTemplateContextType.SETTERCOMMENT_ID, "/**\n * @param ${param} the ${bare_field_name} to set\n */", fJProject1); + } + + @Override + public void tearDown() throws Exception { + IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore(); + store.setToDefault(PreferenceConstants.CODEGEN_ADD_COMMENTS); + store.setToDefault(PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS); + store.setToDefault(PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS); + closeAllEditors(); + JavaProjectHelper.clear(fJProject1, j16s.getDefaultClasspath()); + } + + public static void closeEditor(IEditorPart editor) { + IWorkbenchPartSite site; + IWorkbenchPage page; + if (editor != null && (site= editor.getSite()) != null && (page= site.getPage()) != null) + page.closeEditor(editor, false); + } + + public static void closeAllEditors() { + for (IWorkbenchWindow window : PlatformUI.getWorkbench().getWorkbenchWindows()) { + for (IWorkbenchPage page : window.getPages()) { + for (IEditorReference editorReference : page.getEditorReferences()) { + closeEditor(editorReference.getEditor(false)); + } + } + } + } + + private JavaContentAssistInvocationContext createContext(int offset, ICompilationUnit cu) throws PartInitException, JavaModelException { + JavaEditor editor= (JavaEditor) JavaUI.openInEditor(cu); + ISourceViewer viewer= editor.getViewer(); + return new JavaContentAssistInvocationContext(viewer, offset, editor); + } + + @Test + public void testBug560674() throws CoreException { + IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src"); + + IPackageFragment pack1= sourceFolder.createPackageFragment("test1", false, null); + String contents= + "package test1\n" + + "public record X1(int abcd) {\n" + + " abc \n" + + "}\n"; + ICompilationUnit cu= pack1.createCompilationUnit("X1.java", contents, false, null); + + + String str= "abc "; + + int offset= contents.indexOf(str) + str.length() - 1; + + JavaTypeCompletionProposalComputer comp= new JavaAllCompletionProposalComputer(); + + List proposals= comp.computeCompletionProposals(createContext(offset, cu), null); + ICompletionProposal proposal = proposals.get(0); + + IEditorPart part= JavaUI.openInEditor(cu); + IDocument doc= JavaUI.getDocumentProvider().getDocument(part.getEditorInput()); + if (proposal != null) { + proposal.apply(doc); + } + + String expectedContents= + "package test1\n" + + "public record X1(int abcd) {\n" + + " /**\n" + + " * Method.\n" + + " */\n" + + " public int abcd() {\n" + + " return abcd;\n" + + " } \n" + + "}\n"; + assertEquals(expectedContents, doc.get()); + } + +} diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/JavaDocIndentStrategyTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/JavaDocIndentStrategyTest.java index 77609f05898..16b7f29b907 100644 --- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/JavaDocIndentStrategyTest.java +++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/JavaDocIndentStrategyTest.java @@ -14,9 +14,6 @@ package org.eclipse.jdt.text.tests.performance; -import junit.framework.Test; -import junit.framework.TestSuite; - import org.eclipse.jdt.testplugin.JavaProjectHelper; import org.eclipse.test.performance.Dimension; import org.eclipse.test.performance.PerformanceMeter; @@ -37,6 +34,9 @@ import org.eclipse.jdt.internal.ui.JavaPlugin; +import junit.framework.Test; +import junit.framework.TestSuite; + /** * Measurements of the {@link org.eclipse.jdt.internal.ui.text.javadoc.JavaDocAutoIndentStrategy}. * @@ -124,7 +124,7 @@ protected void setUp() throws Exception { /** * Places the caret behind a Javadoc prefix after which the declaration of a method with many * arguments and declared exceptions follows and measures the time it takes to auto edit when - * entering a newline. See also testResources/javaDocIndentStrategyTest1/Test.java. + * entering a newline. See also testResources/javaDocIndentStrategyTest1/Test.java. * * @throws Exception if something fails while executing this test */ diff --git a/org.eclipse.jdt.ui.examples.projects/pom.xml b/org.eclipse.jdt.ui.examples.projects/pom.xml index ccd5602892b..ee7c4f3138d 100644 --- a/org.eclipse.jdt.ui.examples.projects/pom.xml +++ b/org.eclipse.jdt.ui.examples.projects/pom.xml @@ -11,7 +11,7 @@ eclipse.jdt.ui eclipse.jdt.ui - 4.31.0-SNAPSHOT + 4.32.0-SNAPSHOT org.eclipse.jdt org.eclipse.jdt.ui.examples.projects diff --git a/org.eclipse.jdt.ui.junit.sampleproject/pom.xml b/org.eclipse.jdt.ui.junit.sampleproject/pom.xml index 0bc6906e00d..af7aa11f870 100644 --- a/org.eclipse.jdt.ui.junit.sampleproject/pom.xml +++ b/org.eclipse.jdt.ui.junit.sampleproject/pom.xml @@ -19,7 +19,7 @@ eclipse.jdt.ui eclipse.jdt.ui - 4.31.0-SNAPSHOT + 4.32.0-SNAPSHOT org.eclipse.jdt.ui org.eclipse.jdt.ui.junit.sampleproject diff --git a/org.eclipse.jdt.ui.tests.refactoring/pom.xml b/org.eclipse.jdt.ui.tests.refactoring/pom.xml index 61d21d39aab..9abfab53d97 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/pom.xml +++ b/org.eclipse.jdt.ui.tests.refactoring/pom.xml @@ -14,7 +14,7 @@ tests-pom eclipse.jdt.ui - 4.31.0-SNAPSHOT + 4.32.0-SNAPSHOT ../tests-pom/ org.eclipse.jdt diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ChangeSignatureTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ChangeSignatureTests.java index d76c962de56..9b38e394bd4 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ChangeSignatureTests.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ChangeSignatureTests.java @@ -1934,7 +1934,6 @@ public void testImport08() throws Exception { helperDoAll("A", "textContains", signature, newParamInfo, newIndices, oldParamNames, newParamNames, newParamTypeNames, permutation, newVisibility, deletedIndices, newReturnTypeName); } - @Ignore("BUG_83691_CORE_JAVADOC_REF") @Test public void testEnum01() throws Exception { String[] signature= {"I"}; @@ -1971,7 +1970,6 @@ public void testEnum02() throws Exception { helperDoAll("A_testEnum02_in", "A_testEnum02_in", signature, newParamInfo, newIndices, oldParamNames, newParamNames, null, permutation, newVisibility, deletedIndices, newReturnTypeName); } - @Ignore("BUG_83691_CORE_JAVADOC_REF") @Test public void testEnum03() throws Exception { String[] signature= {}; diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/DeleteTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/DeleteTest.java index 9d2c99aa41c..569eae9c22d 100644 --- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/DeleteTest.java +++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/DeleteTest.java @@ -26,7 +26,6 @@ import org.junit.Before; import org.junit.FixMethodOrder; -import org.junit.Ignore; import org.junit.Test; import org.junit.runners.MethodSorters; @@ -621,7 +620,6 @@ public void testDeleteWithinCu15() throws Exception{ ParticipantTesting.testDelete(handles); } - @Ignore("testDeleteWithinCu16 disabled for bug#55221") @Test public void testDeleteWithinCu16() throws Exception{ ParticipantTesting.reset(); diff --git a/org.eclipse.jdt.ui.tests/META-INF/MANIFEST.MF b/org.eclipse.jdt.ui.tests/META-INF/MANIFEST.MF index b096c4e3996..4a93576bcf0 100644 --- a/org.eclipse.jdt.ui.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.jdt.ui.tests/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.jdt.ui.tests Bundle-ManifestVersion: 2 Bundle-Name: %Plugin.name Bundle-SymbolicName: org.eclipse.jdt.ui.tests; singleton:=true -Bundle-Version: 3.15.300.qualifier +Bundle-Version: 3.15.400.qualifier Bundle-Activator: org.eclipse.jdt.testplugin.JavaTestPlugin Bundle-Vendor: %Plugin.providerName Bundle-Localization: plugin diff --git a/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/AddJavaNatureAction.java b/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/AddJavaNatureAction.java index d44dacf1c8a..b9f30fdd84c 100644 --- a/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/AddJavaNatureAction.java +++ b/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/AddJavaNatureAction.java @@ -27,6 +27,7 @@ import org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathsBlock; /** In plugin.xml: + *

    {@code
        
           
           
        
    +   }
    */ public class AddJavaNatureAction extends Action implements IActionDelegate { diff --git a/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/AddTestMarkersAction.java b/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/AddTestMarkersAction.java index b1439a943ba..cfa15255c15 100644 --- a/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/AddTestMarkersAction.java +++ b/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/AddTestMarkersAction.java @@ -39,6 +39,7 @@ import org.eclipse.jdt.ui.JavaUI; /** In plugin.xml: + *
    {@code
         
           
        
    +   }
    */ public class AddTestMarkersAction extends Action implements IActionDelegate { diff --git a/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/TestMoveDescriptorAction.java b/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/TestMoveDescriptorAction.java index 5d7334e24be..f8629daa2b2 100644 --- a/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/TestMoveDescriptorAction.java +++ b/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/TestMoveDescriptorAction.java @@ -46,6 +46,7 @@ import org.eclipse.jdt.core.refactoring.descriptors.MoveDescriptor; /** In plugin.xml: + *
    {@code
              
           
           
        
    +   }
    */ public class TestMoveDescriptorAction extends Action implements IActionDelegate { diff --git a/org.eclipse.jdt.ui.tests/pom.xml b/org.eclipse.jdt.ui.tests/pom.xml index 256bf2b3baa..b09156c6f75 100644 --- a/org.eclipse.jdt.ui.tests/pom.xml +++ b/org.eclipse.jdt.ui.tests/pom.xml @@ -15,12 +15,12 @@ tests-pom eclipse.jdt.ui - 4.31.0-SNAPSHOT + 4.32.0-SNAPSHOT ../tests-pom/ org.eclipse.jdt org.eclipse.jdt.ui.tests - 3.15.300-SNAPSHOT + 3.15.400-SNAPSHOT eclipse-test-plugin true diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/launcher/AdvancedJUnitLaunchConfigurationDelegateTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/launcher/AdvancedJUnitLaunchConfigurationDelegateTest.java new file mode 100644 index 00000000000..72f0ddf0024 --- /dev/null +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/launcher/AdvancedJUnitLaunchConfigurationDelegateTest.java @@ -0,0 +1,200 @@ +/******************************************************************************* + * Copyright (c) 2024 Erik Brangs and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Erik Brangs - initial implementation + *******************************************************************************/ +package org.eclipse.jdt.junit.launcher; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.List; + +import org.junit.After; +import org.junit.Test; + +import org.eclipse.jdt.junit.JUnitCore; +import org.eclipse.jdt.testplugin.JavaProjectHelper; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; + +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.debug.core.Launch; + +import org.eclipse.jdt.core.IClasspathEntry; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.IPackageFragment; +import org.eclipse.jdt.core.IPackageFragmentRoot; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; + +import org.eclipse.jdt.internal.junit.launcher.TestKindRegistry; + +public class AdvancedJUnitLaunchConfigurationDelegateTest { + + private IJavaProject fJavaProject; + + @After + public void deleteProject() throws CoreException { + if (fJavaProject != null) { + JavaProjectHelper.delete(fJavaProject); + } + } + + @Test + public void runTestsInSourceFolderHandlesMultipleSourceFoldersCorrectly() throws Exception { + String projectName= "JUnitLaunchConfigurationDelegate-TestProject-MultipleSourceFolders"; + fJavaProject= JavaProjectHelper.createJavaProject(projectName, "bin"); + String firstTestSrcFolder= "test-src1"; + IPackageFragmentRoot testSrc1= JavaProjectHelper.addSourceContainer(fJavaProject, firstTestSrcFolder); + IPackageFragmentRoot testSrc2= JavaProjectHelper.addSourceContainer(fJavaProject, "test-src2"); + String testPackage= "p1"; + IPackageFragment packageTestSrc1= testSrc1.createPackageFragment(testPackage, true, null); + String contentsTestSrc1Test= """ + public class FirstTest { + @org.junit.jupiter.api.Test + public void myTest() { } + } + """; + packageTestSrc1.createCompilationUnit("FirstTest.java", contentsTestSrc1Test, true, null); + IPackageFragment packageTestSrc2= testSrc2.createPackageFragment(testPackage, true, null); + String contentsTestSrc2Test= """ + public class ShouldNotBeRunTest { + @org.junit.jupiter.api.Test + public void shouldNotRunTest() { } + } + """; + + packageTestSrc2.createCompilationUnit("ShouldNotBeRunTest.java", contentsTestSrc2Test, true, null); + + List fileLines= showCommandLineAndExtractContentOfTestNameFile(projectName, fJavaProject, testSrc1); + String lineForFirstTest= "p1.FirstTest"; + assertThat(fileLines).contains(lineForFirstTest).size().isEqualTo(1); + } + + @Test + public void runTestsInSourceFolderHandlesMultiplePackagesInASourceFolderCorrectly() throws Exception { + String projectName= "JUnitLaunchConfigurationDelegate-TestProject-MultiplePackagesInOneFolder"; + fJavaProject= JavaProjectHelper.createJavaProject(projectName, "bin"); + String firstTestSrcFolder= "test-src1"; + IPackageFragmentRoot testSrc1= JavaProjectHelper.addSourceContainer(fJavaProject, firstTestSrcFolder); + String testPackage= "p1"; + IPackageFragment packageTestSrc1= testSrc1.createPackageFragment(testPackage, true, null); + String contentsTestSrc1Test= """ + public class FirstTest { + @org.junit.jupiter.api.Test + public void myTest() { } + } + """; + String secondTestPackage= "p2"; + packageTestSrc1.createCompilationUnit("FirstTest.java", contentsTestSrc1Test, true, null); + IPackageFragment packageTestSrc2= testSrc1.createPackageFragment(secondTestPackage, true, null); + String contentsTestSrc2Test= """ + public class SecondTest { + @org.junit.jupiter.api.Test + public void mySecondTest() { } + } + """; + packageTestSrc2.createCompilationUnit("SecondTest.java", contentsTestSrc2Test, true, null); + + List fileLines= showCommandLineAndExtractContentOfTestNameFile(projectName, fJavaProject, testSrc1); + String lineForFirstTest= "p1.FirstTest"; + String lineForSecondTest= "p2.SecondTest"; + assertThat(fileLines).contains(lineForFirstTest, lineForSecondTest).size().isEqualTo(2); + } + + @Test + public void runTestsInSourceFolderHandlesMultipleSourceFilesInPackagesInASourceFolderCorrectly() throws Exception { + String projectName= "JUnitLaunchConfigurationDelegate-TestProject-MultipleSourceFilesInOnePackage"; + fJavaProject= JavaProjectHelper.createJavaProject(projectName, "bin"); + String firstTestSrcFolder= "test-src1"; + IPackageFragmentRoot testSrc1= JavaProjectHelper.addSourceContainer(fJavaProject, firstTestSrcFolder); + String testPackage= "p1"; + IPackageFragment packageTestSrc1= testSrc1.createPackageFragment(testPackage, true, null); + String contentsTestSrc1Test= """ + public class FirstTest { + @org.junit.jupiter.api.Test + public void myTest() { } + } + """; + packageTestSrc1.createCompilationUnit("FirstTest.java", contentsTestSrc1Test, true, null); + String contentsTestSrc2Test= """ + public class SecondTest { + @org.junit.jupiter.api.Test + public void mySecondTest() { } + } + """; + packageTestSrc1.createCompilationUnit("SecondTest.java", contentsTestSrc2Test, true, null); + + List fileLines= showCommandLineAndExtractContentOfTestNameFile(projectName, fJavaProject, testSrc1); + String lineForFirstTest= "p1.FirstTest"; + String lineForSecondTest= "p1.SecondTest"; + assertThat(fileLines).contains(lineForFirstTest, lineForSecondTest).size().isEqualTo(2); + } + + @Test + public void runTestsInSourceFolderOnlyUsesTopLevelClasses() throws Exception { + String projectName= "JUnitLaunchConfigurationDelegate-TestProject-OnlyTopLevelClasses"; + fJavaProject= JavaProjectHelper.createJavaProject(projectName, "bin"); + String firstTestSrcFolder= "test-src1"; + IPackageFragmentRoot testSrc1= JavaProjectHelper.addSourceContainer(fJavaProject, firstTestSrcFolder); + String testPackage= "p1"; + IPackageFragment packageTestSrc1= testSrc1.createPackageFragment(testPackage, true, null); + String contentsTestSrc1Test= """ + public class FirstTest { + @org.junit.jupiter.api.Test + public void myTest() { } + } + + @org.junit.jupiter.api.Nest + class NestedTestClass { + @org.junit.jupiter.api.Test + public void myNestedTest() { } + } + } + """; + packageTestSrc1.createCompilationUnit("FirstTest.java", contentsTestSrc1Test, true, null); + + List fileLines= showCommandLineAndExtractContentOfTestNameFile(projectName, fJavaProject, testSrc1); + String lineForFirstTest= "p1.FirstTest"; + assertThat(fileLines).contains(lineForFirstTest).size().isEqualTo(1); + } + + private List showCommandLineAndExtractContentOfTestNameFile(String projectName, IJavaProject javaProject, IPackageFragmentRoot testSrc1) + throws CoreException, JavaModelException, IOException { + JavaProjectHelper.addRTJar18(javaProject); + IClasspathEntry cpe= JavaCore.newContainerEntry(JUnitCore.JUNIT5_CONTAINER_PATH); + JavaProjectHelper.addToClasspath(javaProject, cpe); + JavaProjectHelper.set18CompilerOptions(javaProject); + AdvancedJUnitLaunchConfigurationDelegate delegate= new AdvancedJUnitLaunchConfigurationDelegate(); + MockLaunchConfig configuration= new MockLaunchConfig(); + configuration.setProjectName(projectName); + String testRunnerKind= TestKindRegistry.JUNIT5_TEST_KIND_ID; + configuration.setTestRunnerKind(testRunnerKind); + String containerHandle= testSrc1.getHandleIdentifier(); + configuration.setContainerHandle(containerHandle); + String mode= ILaunchManager.DEBUG_MODE; + ILaunch launch= new Launch(configuration, mode, null); + IProgressMonitor progressMonitor= null; + String showCommandLine= delegate.showCommandLine(configuration, mode, launch, progressMonitor); + String firstSearchStr= "-testNameFile"; + int indexTestNameFile= showCommandLine.indexOf(firstSearchStr); + assertThat(indexTestNameFile).overridingErrorMessage("-testNameFile argument not found").isGreaterThan(-1); + String filePath= showCommandLine.substring(indexTestNameFile + firstSearchStr.length() + 1); + List fileLines= Files.readAllLines(Paths.get(filePath)); + return fileLines; + } + +} diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/launcher/JUnitLauncherTests.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/launcher/JUnitLauncherTests.java new file mode 100644 index 00000000000..86f53ba02c9 --- /dev/null +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/launcher/JUnitLauncherTests.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2024 Erik Brangs and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Erik Brangs - initial implementation + *******************************************************************************/ + +package org.eclipse.jdt.junit.launcher; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses({ +AdvancedJUnitLaunchConfigurationDelegateTest.class, +}) +public class JUnitLauncherTests { + +} diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/launcher/MockLaunchConfig.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/launcher/MockLaunchConfig.java new file mode 100644 index 00000000000..37985c56949 --- /dev/null +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/launcher/MockLaunchConfig.java @@ -0,0 +1,264 @@ +/******************************************************************************* + * Copyright (c) 2024 Erik Brangs and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Erik Brangs - initial implementation + *******************************************************************************/ +package org.eclipse.jdt.junit.launcher; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; + +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.ILaunchDelegate; + +import org.eclipse.jdt.internal.junit.launcher.JUnitLaunchConfigurationConstants; + +import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; + +class MockLaunchConfig implements ILaunchConfiguration { + + private String fProjectName; + private String fTestRunnerKind; + private String fMainTypeName; + private String fContainerHandle; + + public void setProjectName(String projectName) { + fProjectName= projectName; + } + + public void setTestRunnerKind(String testRunnerKind) { + fTestRunnerKind= testRunnerKind; + } + + public void setContainerHandle(String containerHandle) { + fContainerHandle= containerHandle; + } + + + @Override + public String getAttribute(String attributeName, String defaultValue) throws CoreException { + if (IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME.equals(attributeName)) { + return fProjectName; + } else if (JUnitLaunchConfigurationConstants.ATTR_TEST_RUNNER_KIND.equals(attributeName)) { + return fTestRunnerKind; + } else if (IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME.equals(attributeName)) { + return fMainTypeName; + } else if (JUnitLaunchConfigurationConstants.ATTR_TEST_CONTAINER.equals(attributeName)) { + return fContainerHandle; + } + return defaultValue; + } + + @Override + public List getAttribute(String attributeName, List defaultValue) throws CoreException { + return defaultValue; + } + + @Override + public boolean getAttribute(String attributeName, boolean defaultValue) throws CoreException { + return defaultValue; + } + + @Override + public T getAdapter(Class adapter) { + return null; + } + + @Override + public boolean contentsEqual(ILaunchConfiguration configuration) { + return false; + } + + @Override + public ILaunchConfigurationWorkingCopy copy(String name) throws CoreException { + return null; + } + + @Override + public void delete() throws CoreException { + } + + @Override + public void delete(int flag) throws CoreException { + } + + @Override + public boolean exists() { + return false; + } + + @Override + public int getAttribute(String attributeName, int defaultValue) throws CoreException { + return 0; + } + + @Override + public Set getAttribute(String attributeName, Set defaultValue) throws CoreException { + return null; + } + + @Override + public Map getAttribute(String attributeName, Map defaultValue) throws CoreException { + return null; + } + + @Override + public Map getAttributes() throws CoreException { + return null; + } + + @Override + public String getCategory() throws CoreException { + return null; + } + + @Override + public IFile getFile() { + return null; + } + + @SuppressWarnings("deprecation") + @Override + public IPath getLocation() { + return null; + } + + @Override + public IResource[] getMappedResources() throws CoreException { + return null; + } + + @Override + public String getMemento() throws CoreException { + return null; + } + + @Override + public String getName() { + return null; + } + + @Override + public Set getModes() throws CoreException { + return null; + } + + @Override + public ILaunchDelegate getPreferredDelegate(Set modes) throws CoreException { + return null; + } + + @Override + public ILaunchConfigurationType getType() throws CoreException { + return null; + } + + @Override + public ILaunchConfigurationWorkingCopy getWorkingCopy() throws CoreException { + return null; + } + + @Override + public boolean hasAttribute(String attributeName) throws CoreException { + return false; + } + + @Override + public boolean isLocal() { + return false; + } + + @Override + public boolean isMigrationCandidate() throws CoreException { + return false; + } + + @Override + public boolean isWorkingCopy() { + return false; + } + + @Override + public ILaunch launch(String mode, IProgressMonitor monitor) throws CoreException { + return null; + } + + @Override + public ILaunch launch(String mode, IProgressMonitor monitor, boolean build) throws CoreException { + return null; + } + + @Override + public ILaunch launch(String mode, IProgressMonitor monitor, boolean build, boolean register) throws CoreException { + return null; + } + + @Override + public void migrate() throws CoreException { + } + + @Override + public boolean supportsMode(String mode) throws CoreException { + return false; + } + + @Override + public boolean isReadOnly() { + return false; + } + + @Override + public ILaunchConfiguration getPrototype() throws CoreException { + return null; + } + + @Override + public boolean isAttributeModified(String attribute) throws CoreException { + return false; + } + + @Override + public boolean isPrototype() { + return false; + } + + @Override + public Collection getPrototypeChildren() throws CoreException { + return null; + } + + @Override + public int getKind() throws CoreException { + return 0; + } + + @Override + public Set getPrototypeVisibleAttributes() throws CoreException { + return null; + } + + @Override + public void setPrototypeAttributeVisibility(String attribute, boolean visible) throws CoreException { + } + +} diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/AutomatedSuite.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/AutomatedSuite.java index 2f5b567305a..506f7f20c8f 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/AutomatedSuite.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/AutomatedSuite.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2020 IBM Corporation and others. + * Copyright (c) 2000, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -18,6 +18,7 @@ import org.junit.runner.RunWith; import org.junit.runners.Suite; +import org.eclipse.jdt.junit.launcher.JUnitLauncherTests; import org.eclipse.jdt.junit.tests.JUnitJUnitTests; import org.eclipse.jdt.testplugin.TestOptions; @@ -73,6 +74,7 @@ RefactoringTests.class, SearchTest.class, + JUnitLauncherTests.class, JUnitJUnitTests.class, BuildpathTestSuite.class, diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/callhierarchy/CallHierarchyTestHelper.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/callhierarchy/CallHierarchyTestHelper.java index 2ac8dab76cb..d16a05270d6 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/callhierarchy/CallHierarchyTestHelper.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/callhierarchy/CallHierarchyTestHelper.java @@ -550,7 +550,6 @@ public static List convertMarkers(IMarker [] markers) throws Exception { /** * Verifies that no error markers exist in the given resource. - *

    * * @param element * The resource that is searched for error markers @@ -564,7 +563,6 @@ protected void assertBuildWithoutErrors(IJavaElement element) throws Exception { /** * Verifies that no error markers exist in the given resource. - *

    * * @param resource * The resource that is searched for error markers diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AnnotateAssistTest1d8.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AnnotateAssistTest1d8.java index b76493cd5fd..041693cd0fc 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AnnotateAssistTest1d8.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AnnotateAssistTest1d8.java @@ -638,7 +638,7 @@ public void testAnnotateParameter_Array5() throws Exception { /** * Assert two proposals ("@NonNull" and "@Nullable") on an array type in normal syntax. - * A two line entry using this selector & signature exists and will be amended. + * A two line entry using this selector and signature exists and will be amended. * Apply the second proposal and check the effect. * * @throws Exception multiple causes @@ -711,7 +711,7 @@ public void testAnnotateMethod_Array1() throws Exception { /** * Assert two proposals ("@NonNull" and "@Nullable") on an array type in extra-dims syntax. - * A two line entry using this selector & signature exists and will be amended. + * A two line entry using this selector and signature exists and will be amended. * Apply the second proposal and check the effect. * * @throws Exception multiple causes diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d7.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d7.java index c819fcd8c2b..e3fdef25ff4 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d7.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d7.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2020 IBM Corporation and others. + * Copyright (c) 2011, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -1000,6 +1000,88 @@ public void testUnwrapTryStatement() throws Exception { assertProposalDoesNotExist(proposals, REMOVE_SURROUNDING_TRY_BLOCK); } + @Test + public void testExtractLocalInTryWithResource1() throws Exception { + IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); + StringBuilder buf= new StringBuilder(); + buf.append("package test1;\n"); + buf.append("import java.io.BufferedReader;\n"); + buf.append("import java.io.FileReader;\n"); + buf.append("import java.io.Reader;\n"); + buf.append("public class E {\n"); + buf.append(" void foo() throws Exception {\n"); + buf.append(" try (Reader s = new BufferedReader(new FileReader(\"c.d\"));\n"); + buf.append(" Reader r = new BufferedReader(new FileReader(\"a.b\"))) {\n"); + buf.append(" r.read();\n"); + buf.append(" }\n"); + buf.append(" }\n"); + buf.append("}\n"); + ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); + + String str= "new FileReader(\"a.b\")"; + AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str) + str.length(), 0); + List proposals= collectAssists(context, false); + + buf= new StringBuilder(); + buf.append("package test1;\n"); + buf.append("import java.io.BufferedReader;\n"); + buf.append("import java.io.FileReader;\n"); + buf.append("import java.io.Reader;\n"); + buf.append("public class E {\n"); + buf.append(" void foo() throws Exception {\n"); + buf.append(" try (Reader s = new BufferedReader(new FileReader(\"c.d\"));\n"); + buf.append(" FileReader fileReader = new FileReader(\"a.b\");\n"); + buf.append(" Reader r = new BufferedReader(fileReader)) {\n"); + buf.append(" r.read();\n"); + buf.append(" }\n"); + buf.append(" }\n"); + buf.append("}\n"); + String expected= buf.toString(); + + assertExpectedExistInProposals(proposals, new String[] { expected }); + } + + @Test + public void testExtractLocalInTryWithResource2() throws Exception { + IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); + StringBuilder buf= new StringBuilder(); + buf.append("package test1;\n"); + buf.append("import java.io.BufferedReader;\n"); + buf.append("import java.io.FileReader;\n"); + buf.append("import java.io.Reader;\n"); + buf.append("public class E {\n"); + buf.append(" void foo() throws Exception {\n"); + buf.append(" try (Reader s = new BufferedReader(new FileReader(\"c.d\"));\n"); + buf.append(" Reader r = new BufferedReader(new FileReader(\"a.b\"))) {\n"); + buf.append(" r.read();\n"); + buf.append(" }\n"); + buf.append(" }\n"); + buf.append("}\n"); + ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); + + String str= "\"a.b\""; + AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str) + str.length(), 0); + List proposals= collectAssists(context, false); + + buf= new StringBuilder(); + buf.append("package test1;\n"); + buf.append("import java.io.BufferedReader;\n"); + buf.append("import java.io.FileReader;\n"); + buf.append("import java.io.Reader;\n"); + buf.append("public class E {\n"); + buf.append(" void foo() throws Exception {\n"); + buf.append(" String string = \"a.b\";\n"); + buf.append(" try (Reader s = new BufferedReader(new FileReader(\"c.d\"));\n"); + buf.append(" Reader r = new BufferedReader(new FileReader(string))) {\n"); + buf.append(" r.read();\n"); + buf.append(" }\n"); + buf.append(" }\n"); + buf.append("}\n"); + String expected= buf.toString(); + + assertExpectedExistInProposals(proposals, new String[] { expected }); + } + @Test public void testInferDiamondArguments() throws Exception { diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d8.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d8.java index 5f901b16ece..73f32045df3 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d8.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d8.java @@ -1598,6 +1598,63 @@ public void testConvertToLambda29() throws Exception { + "}\n"; assertExpectedExistInProposals(proposals, new String[] { expected1 }); } + @Test + public void testConvertToLambda30() throws Exception { + IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null); + String buf= "" + + "package test;\n" + + "public class C1 {\n" + + " interface IOverwriteQuery {\n" // + + " String ALL = \"ALL\";\n" // + + "\n" // + + " String queryOverwrite(String pathString);\n" // + + " }\n" // + + "\n" // + + " class ImportOperation {\n" // + + " public ImportOperation(IOverwriteQuery query) {\n" // + + " }\n" // + + " }\n" // + + "\n" // + + " public C1() {\n" // + + " ImportOperation io = new ImportOperation(new IOverwriteQuery() {\n" // + + "\n" // + + " @Override\n" // + + " public String queryOverwrite(String pathString) {\n" // + + " return ALL;\n" // + + " }\n" // + + "\n" // + + " });\n" // + + " }\n" // + + "}\n"; + ICompilationUnit cu= pack1.createCompilationUnit("C1.java", buf, false, null); + + int offset= buf.toString().indexOf("new IOverwriteQuery"); + AssistContext context= getCorrectionContext(cu, offset, 0); + assertNoErrors(context); + List proposals= collectAssists(context, false); + + assertCorrectLabels(proposals); + + String expected1= "" + + "package test;\n" + + "public class C1 {\n" + + " interface IOverwriteQuery {\n" // + + " String ALL = \"ALL\";\n" // + + "\n" // + + " String queryOverwrite(String pathString);\n" // + + " }\n" // + + "\n" // + + " class ImportOperation {\n" // + + " public ImportOperation(IOverwriteQuery query) {\n" // + + " }\n" // + + " }\n" // + + "\n" // + + " public C1() {\n" // + + " ImportOperation io = new ImportOperation(pathString -> IOverwriteQuery.ALL);\n" // + + " }\n" // + + "}\n"; + assertExpectedExistInProposals(proposals, new String[] { expected1 }); + } @Test public void testConvertToLambdaAmbiguousOverridden() throws Exception { @@ -4945,6 +5002,212 @@ public void testConvertLambdaToMethodReference6() throws Exception { assertExpectedExistInProposals(proposals, new String[] { expected1 }); } + @Test + public void testIssue1047_1() throws Exception { + IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); + StringBuilder buf1= new StringBuilder(); + buf1.append("package test1;\n"); + buf1.append("import java.util.function.Supplier;\n"); + buf1.append("\n"); + buf1.append("public class E {\n"); + buf1.append(" void func( String ... args) {\n"); + buf1.append(" }\n"); + buf1.append("\n"); + buf1.append(" private void called( Supplier r ) {\n"); + buf1.append(" }\n"); + buf1.append("\n"); + buf1.append(" void called( Runnable r ) {\n"); + buf1.append(" }\n"); + buf1.append("\n"); + buf1.append(" void test() {\n"); + buf1.append(" called(() -> func());\n"); + buf1.append(" }\n"); + buf1.append("}\n"); + ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf1.toString(), false, null); + + + int offset= buf1.toString().indexOf("func()"); + AssistContext context= getCorrectionContext(cu, offset, 0); + assertNoErrors(context); + List proposals= collectAssists(context, false); + assertCorrectLabels(proposals); + StringBuilder buf= new StringBuilder(); + buf.append("package test1;\n"); + buf.append("import java.util.function.Supplier;\n"); + buf.append("\n"); + buf.append("public class E {\n"); + buf.append(" void func( String ... args) {\n"); + buf.append(" }\n"); + buf.append("\n"); + buf.append(" private void called( Supplier r ) {\n"); + buf.append(" }\n"); + buf.append("\n"); + buf.append(" void called( Runnable r ) {\n"); + buf.append(" }\n"); + buf.append("\n"); + buf.append(" void test() {\n"); + buf.append(" called((Runnable) this::func);\n"); + buf.append(" }\n"); + buf.append("}\n"); + String expected1= buf.toString(); + assertExpectedExistInProposals(proposals, new String[] { expected1 }); + } + + @Test + public void testIssue1047_2() throws Exception { + IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); + StringBuilder buf1= new StringBuilder(); + buf1.append("package test1;\n"); + buf1.append("import java.util.function.Supplier;\n"); + buf1.append("\n"); + buf1.append("public class E1 {\n"); + buf1.append(" private void called( Supplier r ) {\n"); + buf1.append(" }\n"); + buf1.append("\n"); + buf1.append("}\n"); + pack1.createCompilationUnit("E1.java", buf1.toString(), false, null); + + StringBuilder buf= new StringBuilder(); + buf.append("package test1;\n"); + buf.append("\n"); + buf.append("public class E extends E1 {\n"); + buf.append(" void func( String ... args) {\n"); + buf.append(" }\n"); + buf.append("\n"); + buf.append(" void called( Runnable r ) {\n"); + buf.append(" }\n"); + buf.append("\n"); + buf.append(" void test() {\n"); + buf.append(" called(() -> func());\n"); + buf.append(" }\n"); + buf.append("}\n"); + ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); + + int offset= buf.toString().indexOf("func()"); + AssistContext context= getCorrectionContext(cu, offset, 0); + assertNoErrors(context); + List proposals= collectAssists(context, false); + assertCorrectLabels(proposals); + buf= new StringBuilder(); + buf.append("package test1;\n"); + buf.append("\n"); + buf.append("public class E extends E1 {\n"); + buf.append(" void func( String ... args) {\n"); + buf.append(" }\n"); + buf.append("\n"); + buf.append(" void called( Runnable r ) {\n"); + buf.append(" }\n"); + buf.append("\n"); + buf.append(" void test() {\n"); + buf.append(" called((Runnable) this::func);\n"); + buf.append(" }\n"); + buf.append("}\n"); + String expected1= buf.toString(); + assertExpectedExistInProposals(proposals, new String[] { expected1 }); + } + + @Test + public void testIssue1047_3() throws Exception { + IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); + StringBuilder buf1= new StringBuilder(); + buf1.append("package test1;\n"); + buf1.append("import java.util.function.Supplier;\n"); + buf1.append("\n"); + buf1.append("public class E1 {\n"); + buf1.append(" void func( String ... args) {\n"); + buf1.append(" }\n"); + buf1.append(" private void called( Supplier r ) {\n"); + buf1.append(" }\n"); + buf1.append("\n"); + buf1.append("}\n"); + pack1.createCompilationUnit("E1.java", buf1.toString(), false, null); + + StringBuilder buf= new StringBuilder(); + buf.append("package test1;\n"); + buf.append("\n"); + buf.append("public class E extends E1 {\n"); + buf.append("\n"); + buf.append(" void called( Runnable r ) {\n"); + buf.append(" }\n"); + buf.append("\n"); + buf.append(" void test() {\n"); + buf.append(" called(() -> super.func());\n"); + buf.append(" }\n"); + buf.append("}\n"); + ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); + + int offset= buf.toString().indexOf("func()"); + AssistContext context= getCorrectionContext(cu, offset, 0); + assertNoErrors(context); + List proposals= collectAssists(context, false); + assertCorrectLabels(proposals); + buf= new StringBuilder(); + buf.append("package test1;\n"); + buf.append("\n"); + buf.append("public class E extends E1 {\n"); + buf.append("\n"); + buf.append(" void called( Runnable r ) {\n"); + buf.append(" }\n"); + buf.append("\n"); + buf.append(" void test() {\n"); + buf.append(" called((Runnable) super::func);\n"); + buf.append(" }\n"); + buf.append("}\n"); + String expected1= buf.toString(); + assertExpectedExistInProposals(proposals, new String[] { expected1 }); + } + + @Test + public void testIssue1047_4() throws Exception { + IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); + StringBuilder buf1= new StringBuilder(); + buf1.append("package test1;\n"); + buf1.append("import java.util.function.Supplier;\n"); + buf1.append("\n"); + buf1.append("public class E1 {\n"); + buf1.append(" public static void func( String ... args) {\n"); + buf1.append(" }\n"); + buf1.append(" private void called( Supplier r ) {\n"); + buf1.append(" }\n"); + buf1.append("\n"); + buf1.append("}\n"); + pack1.createCompilationUnit("E1.java", buf1.toString(), false, null); + + StringBuilder buf= new StringBuilder(); + buf.append("package test1;\n"); + buf.append("\n"); + buf.append("public class E extends E1 {\n"); + buf.append("\n"); + buf.append(" void called( Runnable r ) {\n"); + buf.append(" }\n"); + buf.append("\n"); + buf.append(" void test() {\n"); + buf.append(" called(() -> E1.func());\n"); + buf.append(" }\n"); + buf.append("}\n"); + ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); + + int offset= buf.toString().indexOf("func()"); + AssistContext context= getCorrectionContext(cu, offset, 0); + assertNoErrors(context); + List proposals= collectAssists(context, false); + assertCorrectLabels(proposals); + buf= new StringBuilder(); + buf.append("package test1;\n"); + buf.append("\n"); + buf.append("public class E extends E1 {\n"); + buf.append("\n"); + buf.append(" void called( Runnable r ) {\n"); + buf.append(" }\n"); + buf.append("\n"); + buf.append(" void test() {\n"); + buf.append(" called((Runnable) E1::func);\n"); + buf.append(" }\n"); + buf.append("}\n"); + String expected1= buf.toString(); + assertExpectedExistInProposals(proposals, new String[] { expected1 }); + } + @Test public void testFixParenthesesInLambdaExpressionAdd() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest15.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest15.java index 9355ec43e53..09417cd8291 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest15.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest15.java @@ -110,7 +110,21 @@ public void testConcatToTextBlock() throws Exception { + " public void testConcatInConstructor() {\n" // + " new StringBuffer(\"abc\\n\" + \"def\\n\" + \"ghi\");\n" // + " }\n" // - + "}\n"; + + " public void testTabStart() {\n" // + + " String x =\"\\tif (true) {\\n\" +\n" // + + " \"\\t\\tstuff();\\n\" +\n" // + + " \"\\t} else\\n\" +\n" // + + " \"\\t\\tnoStuff\";\n" // + + " }\n" // + + " public void testEndEscapedQuotes() {\n" // + + " String a =\n" // + + " \"1\\n\" +\n" // + + " \"2\\n\" +\n" // + + " \"3\\n\" +\n" // + + " \"4\\n\" +\n" // + + " \"\\\"\\\"\\\"\\\"\";\n" // + + " }\n" // + + "}\n"; ICompilationUnit cu1= pack1.createCompilationUnit("E.java", sample, false, null); @@ -182,7 +196,23 @@ public void testConcatToTextBlock() throws Exception { + " def\n" // + " ghi\"\"\");\n" // + " }\n" // - + "}\n"; + + " public void testTabStart() {\n" // + + " String x =\"\"\"\n" // + + " \tif (true) {\n" // + + " \t\tstuff();\n" // + + " \t} else\n" // + + " \t\tnoStuff\"\"\";\n" // + + " }\n" // + + " public void testEndEscapedQuotes() {\n" // + + " String a =\n" // + + " \"\"\"\n" // + + " 1\n" // + + " 2\n" // + + " 3\n" // + + " 4\n" // + + " \\\"\"\"\\\"\"\"\";\n" // + + " }\n" // + + "}\n"; assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 }, null); } @@ -230,6 +260,11 @@ public void testConcatToTextBlock2() throws Exception { + " \"def\\n\" +\n" // + " \"ghi\\n\";\n" // + " new StringBuffer(\"abc\\n\" + \"def\\n\" + \"ghi\");\n" // + + " new StringBuffer(\"1\\n\" +\n" // + + " \"2\\n\" +\n" // + + " \"3\\n\" +\n" // + + " \"4\\n\" +\n" // + + " \"\\\"\\\"\\\"\");\n" // + " }\n" // + "}"; @@ -288,7 +323,13 @@ public void testConcatToTextBlock2() throws Exception { + " abc\n" // + " def\n" // + " ghi\"\"\");\n" // - + " }\n" // + + " new StringBuffer(\"\"\"\n" // + + " 1\n" // + + " 2\n" // + + " 3\n" // + + " 4\n" // + + " \\\"\\\"\\\"\"\"\");\n" // + + " }\n" // + "}"; assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 }, null); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest16.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest16.java index d3564c120ad..c0156c06555 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest16.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest16.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2023 Red Hat Inc. and others. + * Copyright (c) 2020, 2024 Red Hat Inc. and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -160,17 +160,6 @@ public void testPatternMatchingForInstanceof() throws Exception { + " return 0;\n" // + " }\n" // + "\n" // - + "\n" // - + " public long matchPatternInAndExpression(Object object, boolean isValid) {\n" // - + " if (object instanceof Date & isValid) {\n" // - + " // Keep this comment\n" // - + " Date date = (Date) object;\n" // - + " return date.getTime();\n" // - + " }\n" // - + "\n" // - + " return 0;\n" // - + " }\n" // - + "\n" // + " public long matchPatternInElse(Object object) {\n" // + " if (!(object instanceof Date)) {\n" // + " return 0;\n" // @@ -189,15 +178,6 @@ public void testPatternMatchingForInstanceof() throws Exception { + " }\n" // + " }\n" // + "\n" // - + " public long matchPatternInOrExpression(Object object, boolean isValid) {\n" // - + " if (isValid | !(object instanceof Date)) {\n" // - + " return 0;\n" // - + " } else {\n" // - + " Date date = (Date) object;\n" // - + " return date.getTime();\n" // - + " }\n" // - + " }\n" // - + "\n" // + " public long matchPatternInElse(Object object) {\n" // + " if (!(object instanceof Date)) {\n" // + " return 0;\n" // @@ -254,16 +234,6 @@ public void testPatternMatchingForInstanceof() throws Exception { + " return 0;\n" // + " }\n" // + "\n" // - + "\n" // - + " public long matchPatternInAndExpression(Object object, boolean isValid) {\n" // - + " if (object instanceof Date date & isValid) {\n" // - + " // Keep this comment\n" // - + " return date.getTime();\n" // - + " }\n" // - + "\n" // - + " return 0;\n" // - + " }\n" // - + "\n" // + " public long matchPatternInElse(Object object) {\n" // + " if (!(object instanceof Date date)) {\n" // + " return 0;\n" // @@ -280,14 +250,6 @@ public void testPatternMatchingForInstanceof() throws Exception { + " }\n" // + " }\n" // + "\n" // - + " public long matchPatternInOrExpression(Object object, boolean isValid) {\n" // - + " if (isValid | !(object instanceof Date date)) {\n" // - + " return 0;\n" // - + " } else {\n" // - + " return date.getTime();\n" // - + " }\n" // - + " }\n" // - + "\n" // + " public long matchPatternInElse(Object object) {\n" // + " if (!(object instanceof Date date)) {\n" // + " return 0;\n" // @@ -370,6 +332,68 @@ public void testPatternMatchingForInstanceof2() throws Exception { // https://gi new HashSet<>(Arrays.asList(MultiFixMessages.PatternMatchingForInstanceofCleanup_description))); } + @Test + public void testOneIfWithPatternInstanceof() throws Exception { // https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/1200 + IPackageFragment pack= fSourceFolder.createPackageFragment("test1", false, null); + String sample= "" // + + "package test1;\n" // + + "\n" // + + "public class E {\n" // + + "\n" // + + " protected String getString(Number number) {\n" // + + "\n" // + + " if (number instanceof Long n) {\n" // + + " return n.toString();\n" // + + " }\n" // + + " if (number instanceof Float n) {\n" // + + " return n.toString();\n" // + + " }\n" // + + " if (number instanceof Double n) {\n" // + + " return n.toString();\n" // + + " }\n" // + + " if (number instanceof Float n && n.isInfinite()) {\n" // + + " return \"Inf\"; //$NON-NLS-1$\n" // + + " }\n" // + + " if (number instanceof Double m && m.isInfinite()) {\n" // + + " return \"Inf\"; //$NON-NLS-1$\n" // + + " }\n" // + + "\n" // + + " return null;\n" // + + " }\n" // + + "\n" // + + "}\n"; // + ICompilationUnit cu= pack.createCompilationUnit("E.java", sample, false, null); + + enable(CleanUpConstants.ONE_IF_RATHER_THAN_DUPLICATE_BLOCKS_THAT_FALL_THROUGH); + + String expected= "" // + + "package test1;\n" // + + "\n" // + + "public class E {\n" // + + "\n" // + + " protected String getString(Number number) {\n" // + + "\n" // + + " if (number instanceof Long n) {\n" // + + " return n.toString();\n" // + + " }\n" // + + " if (number instanceof Float n) {\n" // + + " return n.toString();\n" // + + " }\n" // + + " if (number instanceof Double n) {\n" // + + " return n.toString();\n" // + + " }\n" // + + " if ((number instanceof Float n && n.isInfinite()) || (number instanceof Double m && m.isInfinite())) {\n" // + + " return \"Inf\"; //$NON-NLS-1$\n" // + + " }\n" // + + "\n" // + + " return null;\n" // + + " }\n" // + + "\n" // + + "}\n"; // + assertRefactoringResultAsExpected(new ICompilationUnit[] { cu }, new String[] { expected }, + new HashSet<>(Arrays.asList(MultiFixMessages.OneIfRatherThanDuplicateBlocksThatFallThroughCleanUp_description))); + } + @Test public void testDoNotMatchPatternForInstanceof() throws Exception { IPackageFragment pack= fSourceFolder.createPackageFragment("test1", false, null); @@ -478,7 +502,25 @@ public void testDoNotMatchPatternForInstanceof() throws Exception { + " Integer i = (Integer) bah;\n" // + " System.out.println(i);\n" // + " }\n" // - + "}\n"; + + "\n" // + + " public void doNotMatchBitWiseAnd(boolean useStrikethroughForCompleted, Object data) {\n" // + + " if (data instanceof Long & useStrikethroughForCompleted) {\n" // + + " Long task = (Long)data;\n" // + + " if (task.intValue() == 0) {\n" // + + " int i = 0;\n" // + + " }\n" // + + " }\n" // + + " }\n" // + + "\n" // + + " public void doNotMatchBitWiseOr(boolean useStrikethroughForCompleted, Object data) {\n" // + + " if (data instanceof Long | useStrikethroughForCompleted) {\n" // + + " Long task = (Long)data;\n" // + + " if (task.intValue() == 0) {\n" // + + " int i = 0;\n" // + + " }\n" // + + " }\n" // + + " }\n" // + + "}\n"; ICompilationUnit cu= pack.createCompilationUnit("E.java", sample, false, null); enable(CleanUpConstants.USE_PATTERN_MATCHING_FOR_INSTANCEOF); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d5.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d5.java index 5b0e3fdba3a..be0856609ab 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d5.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d5.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2023 IBM Corporation and others. + * Copyright (c) 2019, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -3107,6 +3107,52 @@ public void testUnnecessaryArray_default_package() throws Exception { } } + @Test + public void testUnnecessaryArrayNLS() throws Exception { // https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/1213 + try { + // Given + IPackageFragment pack1= fSourceFolder.createPackageFragment("", false, null); + String given= "" // + + "import java.util.Arrays;\n" // + + "import java.util.List;\n" // + + "\n" // + + "public class NLS {\n" // + + " private static final List WHITELISTED_IDS = Arrays\n" // + + " .asList(new String[] { \"org.eclipse.search.text.FileSearchResultPage\", //$NON-NLS-1$\n" // + + " \"org.eclipse.jdt.ui.JavaSearchResultPage\", //$NON-NLS-1$\n" // + + " \"org.eclipse.jdt.ui.CodeGeneration\", \n" // + + " \"org.eclipse.jdt.ui.ISharedImages\", //$NON-NLS-1$\n" // + + " \"org.eclipse.jdt.ui.IWorkingCopyManager\" }); //$NON-NLS-1$\n" // + + "}\n"; // + String expected= "" // + + "import java.util.Arrays;\n" // + + "import java.util.List;\n" // + + "\n" // + + "public class NLS {\n" // + + " private static final List WHITELISTED_IDS = Arrays\n" // + + " .asList(\"org.eclipse.search.text.FileSearchResultPage\", //$NON-NLS-1$\n" // + + " \"org.eclipse.jdt.ui.JavaSearchResultPage\", //$NON-NLS-1$\n" // + + " \"org.eclipse.jdt.ui.CodeGeneration\", \n" // + + " \"org.eclipse.jdt.ui.ISharedImages\", //$NON-NLS-1$\n" // + + " \"org.eclipse.jdt.ui.IWorkingCopyManager\"); //$NON-NLS-1$\n" // + + "}\n"; // + + // When + ICompilationUnit cu= pack1.createCompilationUnit("A.java", given, false, null); + enable(CleanUpConstants.REMOVE_UNNECESSARY_ARRAY_CREATION); + + // Then + assertNotEquals("The class must be changed", given, expected); + assertRefactoringResultAsExpected(new ICompilationUnit[] { cu }, new String[] { expected }, + new HashSet<>(Arrays.asList(FixMessages.UnusedCodeFix_RemoveUnnecessaryArrayCreation_description))); + } catch (Exception e) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + e.printStackTrace(pw); + fail(sw.toString()); + } + } + @Test public void testUnnecessaryEmptyArray() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d8.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d8.java index 4bca01031ef..c13d1cb645b 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d8.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d8.java @@ -417,6 +417,63 @@ public void testConvertToLambda07() throws Exception { assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 }, null); } + @Test + public void testConvertToLambda08() throws Exception { + IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); + String sample= "" // + + "package test1;\n" + + "public class C1 {\n" + + " interface IOverwriteQuery {\n" // + + " String ALL = \"ALL\";\n" // + + "\n" // + + " String queryOverwrite(String pathString);\n" // + + " }\n" // + + "\n" // + + " class ImportOperation {\n" // + + " public ImportOperation(IOverwriteQuery query) {\n" // + + " }\n" // + + " }\n" // + + "\n" // + + " public C1() {\n" // + + " ImportOperation io = new ImportOperation(new IOverwriteQuery() {\n" // + + "\n" // + + " @Override\n" // + + " public String queryOverwrite(String pathString) {\n" // + + " return ALL;\n" // + + " }\n" // + + "\n" // + + " });\n" // + + " }\n" // + + "}\n"; + String original= sample; + ICompilationUnit cu1= pack1.createCompilationUnit("C1.java", original, false, null); + + enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES); + enable(CleanUpConstants.USE_LAMBDA); + + sample= "" // + + "package test1;\n" + + "public class C1 {\n" + + " interface IOverwriteQuery {\n" // + + " String ALL = \"ALL\";\n" // + + "\n" // + + " String queryOverwrite(String pathString);\n" // + + " }\n" // + + "\n" // + + " class ImportOperation {\n" // + + " public ImportOperation(IOverwriteQuery query) {\n" // + + " }\n" // + + " }\n" // + + "\n" // + + " public C1() {\n" // + + " ImportOperation io = new ImportOperation(pathString -> IOverwriteQuery.ALL);\n" // + + " }\n" // + + "}\n"; + String expected1= sample; + + assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 }, null); + } + @Test public void testConvertToLambdaWithConstant() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null); @@ -1816,6 +1873,219 @@ public void testDoNotSimplifyLambdaExpression() throws Exception { assertRefactoringHasNoChange(new ICompilationUnit[] { cu }); } + @Test + public void testIssue1047_1() throws Exception { + // Given + IPackageFragment pack= fSourceFolder.createPackageFragment("test1", false, null); + String given= "" // + + "import java.util.function.Supplier;\n" // + + "\n" // + + "public class E {\n" // + + "\n" // + + " void func( String ... args) {\n" // + + "\n" // + + " }\n" // + + " void called( Runnable r ) {\n" // + + "\n" // + + " }\n" // + + " void called( Supplier r ) {\n" // + + "\n" // + + " }\n" // + + " void test() {\n" // + + " called(() -> func());\n" // + + " }\n" // + + "}\n"; // + + String expected= "" // + + "import java.util.function.Supplier;\n" // + + "\n" // + + "public class E {\n" // + + "\n" // + + " void func( String ... args) {\n" // + + "\n" // + + " }\n" // + + " void called( Runnable r ) {\n" // + + "\n" // + + " }\n" // + + " void called( Supplier r ) {\n" // + + "\n" // + + " }\n" // + + " void test() {\n" // + + " called((Runnable) this::func);\n" // + + " }\n" // + + "}\n"; // + // When + ICompilationUnit cu= pack.createCompilationUnit("E.java", given, false, null); + enable(CleanUpConstants.SIMPLIFY_LAMBDA_EXPRESSION_AND_METHOD_REF); + + // Then + assertNotEquals("The class must be changed", given, expected); + assertRefactoringResultAsExpected(new ICompilationUnit[] { cu }, new String[] { expected }, + new HashSet<>(Arrays.asList(MultiFixMessages.LambdaExpressionAndMethodRefCleanUp_description))); + } + + @Test + public void testIssue1047_2() throws Exception { + // Given + IPackageFragment pack= fSourceFolder.createPackageFragment("test1", false, null); + String given1= "" // + + "import java.util.function.Supplier;\n" // + + "\n" // + + "public class E1 {\n" // + + "\n" // + + " void called( Supplier r ) {\n" // + + "\n" // + + " }\n" // + + "}\n"; // + ICompilationUnit cu1= pack.createCompilationUnit("E1.java", given1, false, null); + + String given= "" // + + "import java.util.function.Supplier;\n" // + + "\n" // + + "public class E extends E1 {\n" // + + "\n" // + + " void func( String ... args) {\n" // + + "\n" // + + " }\n" // + + " void called( Runnable r ) {\n" // + + "\n" // + + " }\n" // + + " void test() {\n" // + + " called(() -> func());\n" // + + " }\n" // + + "}\n"; // + + String expected= "" // + + "import java.util.function.Supplier;\n" // + + "\n" // + + "public class E extends E1 {\n" // + + "\n" // + + " void func( String ... args) {\n" // + + "\n" // + + " }\n" // + + " void called( Runnable r ) {\n" // + + "\n" // + + " }\n" // + + " void test() {\n" // + + " called((Runnable) this::func);\n" // + + " }\n" // + + "}\n"; // + // When + ICompilationUnit cu= pack.createCompilationUnit("E.java", given, false, null); + enable(CleanUpConstants.SIMPLIFY_LAMBDA_EXPRESSION_AND_METHOD_REF); + + // Then + assertNotEquals("The class must be changed", given, expected); + assertRefactoringResultAsExpected(new ICompilationUnit[] { cu, cu1 }, new String[] { expected, given1 }, + new HashSet<>(Arrays.asList(MultiFixMessages.LambdaExpressionAndMethodRefCleanUp_description))); + } + + @Test + public void testIssue1047_3() throws Exception { + // Given + IPackageFragment pack= fSourceFolder.createPackageFragment("test1", false, null); + String given1= "" // + + "import java.util.function.Supplier;\n" // + + "\n" // + + "public class E1 {\n" // + + "\n" // + + " void func( String ... args) {\n" // + + "\n" // + + " }\n" // + + " void called( Supplier r ) {\n" // + + "\n" // + + " }\n" // + + "}\n"; // + ICompilationUnit cu1= pack.createCompilationUnit("E1.java", given1, false, null); + + String given= "" // + + "import java.util.function.Supplier;\n" // + + "\n" // + + "public class E extends E1 {\n" // + + "\n" // + + " void called( Runnable r ) {\n" // + + "\n" // + + " }\n" // + + " void test() {\n" // + + " called(() -> super.func());\n" // + + " }\n" // + + "}\n"; // + + String expected= "" // + + "import java.util.function.Supplier;\n" // + + "\n" // + + "public class E extends E1 {\n" // + + "\n" // + + " void called( Runnable r ) {\n" // + + "\n" // + + " }\n" // + + " void test() {\n" // + + " called((Runnable) super::func);\n" // + + " }\n" // + + "}\n"; // + // When + ICompilationUnit cu= pack.createCompilationUnit("E.java", given, false, null); + enable(CleanUpConstants.SIMPLIFY_LAMBDA_EXPRESSION_AND_METHOD_REF); + + // Then + assertNotEquals("The class must be changed", given, expected); + assertRefactoringResultAsExpected(new ICompilationUnit[] { cu, cu1 }, new String[] { expected, given1 }, + new HashSet<>(Arrays.asList(MultiFixMessages.LambdaExpressionAndMethodRefCleanUp_description))); + } + + @Test + public void testIssue1047_4() throws Exception { + // Given + IPackageFragment pack= fSourceFolder.createPackageFragment("test1", false, null); + String given1= "" // + + "import java.util.function.Supplier;\n" // + + "\n" // + + "public class E1 {\n" // + + "\n" // + + " static void func( String ... args) {\n" // + + "\n" // + + " }\n" // + + " void called( Supplier r ) {\n" // + + "\n" // + + " }\n" // + + "}\n"; // + ICompilationUnit cu1= pack.createCompilationUnit("E1.java", given1, false, null); + + String given= "" // + + "import java.util.function.Supplier;\n" // + + "\n" // + + "public class E extends E1 {\n" // + + "\n" // + + " void called( Runnable r ) {\n" // + + "\n" // + + " }\n" // + + " void test() {\n" // + + " called(() -> E1.func());\n" // + + " }\n" // + + "}\n"; // + + String expected= "" // + + "import java.util.function.Supplier;\n" // + + "\n" // + + "public class E extends E1 {\n" // + + "\n" // + + " void called( Runnable r ) {\n" // + + "\n" // + + " }\n" // + + " void test() {\n" // + + " called((Runnable) E1::func);\n" // + + " }\n" // + + "}\n"; // + // When + ICompilationUnit cu= pack.createCompilationUnit("E.java", given, false, null); + enable(CleanUpConstants.SIMPLIFY_LAMBDA_EXPRESSION_AND_METHOD_REF); + + // Then + assertNotEquals("The class must be changed", given, expected); + assertRefactoringResultAsExpected(new ICompilationUnit[] { cu, cu1 }, new String[] { expected, given1 }, + new HashSet<>(Arrays.asList(MultiFixMessages.LambdaExpressionAndMethodRefCleanUp_description))); + } + @Test public void testBug579393() throws Exception { // Given @@ -1991,6 +2261,41 @@ public void testDoNotConvertLocalRecursiveClass() throws Exception { assertRefactoringHasNoChange(new ICompilationUnit[] { cu }); } + @Test + public void testDoNotConvertGenericInterface() throws Exception { + IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); + String sample= "" // + + "package test1;\n" // + + "\n" // + + "public class C2 {\n" // + + "\n" // + + " public interface IInteractionContext {\n" // + + " }\n" // + + "\n" // + + " public interface IAdaptable {\n" // + + " public T getAdapter(Class adapter);\n" // + + " }\n" // + + "\n" // + + " @SuppressWarnings(\"unchecked\")\n" // + + " public IAdaptable asAdaptable(final IInteractionContext result) {\n" // + + " return new IAdaptable() {\n" // + + " public Object getAdapter(Class adapter) {\n" // + + " if (adapter == IInteractionContext.class) {\n" // + + " return result;\n" // + + " }\n" // + + " return null;\n" // + + " }\n" // + + " };\n" // + + " }\n" // + + "}\n"; // + ICompilationUnit cu= pack1.createCompilationUnit("C2.java", sample, false, null); + + enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES); + enable(CleanUpConstants.USE_LAMBDA); + + assertRefactoringHasNoChange(new ICompilationUnit[] { cu }); + } + @Test public void testComparingOnCriteria() throws Exception { // Given @@ -6211,4 +6516,79 @@ public void testDoNotDoDeprecatedCleanup4() throws Exception { // https://github assertRefactoringHasNoChange(new ICompilationUnit[] { cu1, cu2 }); } + @Test + public void testRemoveThisIssue1211() throws Exception { // https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/1211 + IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); + + String sample= "" // + + "package test1;\n" // + + "\n" // + + "public class A {\n" // + + " public interface PropertyChangeListener {\n" // + + " void propertyChange(Object evt);\n" // + + "\n" // + + " }\n" // + + "\n" // + + " private final PropertyChangeListener listener = evt -> {\n" // + + " this.clientCache.get();\n" // + + " };\n" // + + "\n" // + + " public void x() {\n" // + + " PropertyChangeListener listener = evt -> {\n" // + + " this.clientCache.get();\n" // + + " };\n" // + + " listener.propertyChange(listener);\n" // + + " }\n" // + + " interface Cache {\n" // + + " V get();\n" // + + " }\n" // + + "\n" // + + " final Cache clientCache = new Cache<>() {\n" // + + " @Override\n" // + + " public String get() {\n" // + + " listener.propertyChange(null);\n" // + + " return \"\";\n" // + + " }\n" // + + " };\n" // + + "}\n"; + ICompilationUnit cu1= pack1.createCompilationUnit("A.java", sample, false, null); + + enable(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS); + enable(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_IF_NECESSARY); + + sample= "" // + + "package test1;\n" // + + "\n" // + + "public class A {\n" // + + " public interface PropertyChangeListener {\n" // + + " void propertyChange(Object evt);\n" // + + "\n" // + + " }\n" // + + "\n" // + + " private final PropertyChangeListener listener = evt -> {\n" // + + " this.clientCache.get();\n" // + + " };\n" // + + "\n" // + + " public void x() {\n" // + + " PropertyChangeListener listener = evt -> {\n" // + + " clientCache.get();\n" // + + " };\n" // + + " listener.propertyChange(listener);\n" // + + " }\n" // + + " interface Cache {\n" // + + " V get();\n" // + + " }\n" // + + "\n" // + + " final Cache clientCache = new Cache<>() {\n" // + + " @Override\n" // + + " public String get() {\n" // + + " listener.propertyChange(null);\n" // + + " return \"\";\n" // + + " }\n" // + + " };\n" // + + "}\n"; + String expected1= sample; + assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 }, null); + } + } diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTestCase.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTestCase.java index cf446327559..96de0ca5c98 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTestCase.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTestCase.java @@ -176,45 +176,6 @@ private void collectGroupCategories(Set result, Change change) { } } - /** - * @param cus The compilation units - * @param setOfExpectedGroupCategories The expected group categories - * @throws CoreException The core exception - * @deprecated Use assertRefactoringResultAsExpected(ICompilationUnit[] cus, String[] expected, Set expectedGroupCategories) instead. - */ - @Deprecated - protected void assertGroupCategoryUsed(ICompilationUnit[] cus, Set setOfExpectedGroupCategories) throws CoreException { - final CleanUpRefactoring ref= new CleanUpRefactoring(); - ref.setUseOptionsFromProfile(true); - ICleanUp[] cleanUps= JavaPlugin.getDefault().getCleanUpRegistry().createCleanUps(); - - for (ICompilationUnit cu : cus) { - assertNotNull("No compilation unit should be null", cu); - ref.addCompilationUnit(cu); - } - - for (ICleanUp cleanUp : cleanUps) { - ref.addCleanUp(cleanUp); - } - - final CreateChangeOperation create= new CreateChangeOperation( - new CheckConditionsOperation(ref, CheckConditionsOperation.ALL_CONDITIONS), - RefactoringStatus.FATAL); - - create.run(new NullProgressMonitor()); - Change change= create.getChange(); - - Set actualCategories= new HashSet<>(); - - collectGroupCategories(actualCategories, change); - - for (GroupCategory actualCategory : actualCategories) { - if (!setOfExpectedGroupCategories.contains(actualCategory.getName())) { - fail("Unexpected group category: " + actualCategory.getName() + ", should find: " + String.join(", ", setOfExpectedGroupCategories)); - } - } - } - protected RefactoringStatus assertRefactoringResultAsExpected(ICompilationUnit[] cus, String[] expected) throws CoreException { return assertRefactoringResultAsExpected(cus, expected, null); } diff --git a/org.eclipse.jdt.ui.unittest.junit.feature/feature.xml b/org.eclipse.jdt.ui.unittest.junit.feature/feature.xml index e8255a90688..8b4e0fe504b 100644 --- a/org.eclipse.jdt.ui.unittest.junit.feature/feature.xml +++ b/org.eclipse.jdt.ui.unittest.junit.feature/feature.xml @@ -2,7 +2,7 @@ @@ -43,9 +43,6 @@ + version="0.0.0"/> diff --git a/org.eclipse.jdt.ui.unittest.junit.feature/pom.xml b/org.eclipse.jdt.ui.unittest.junit.feature/pom.xml index 2082ab4695a..3894b718092 100644 --- a/org.eclipse.jdt.ui.unittest.junit.feature/pom.xml +++ b/org.eclipse.jdt.ui.unittest.junit.feature/pom.xml @@ -16,11 +16,11 @@ eclipse.jdt.ui eclipse.jdt.ui - 4.31.0-SNAPSHOT + 4.32.0-SNAPSHOT org.eclipse.jdt.feature org.eclipse.jdt.ui.unittest.junit.feature - 1.1.300-SNAPSHOT + 1.1.400-SNAPSHOT eclipse-feature diff --git a/org.eclipse.jdt.ui.unittest.junit/META-INF/MANIFEST.MF b/org.eclipse.jdt.ui.unittest.junit/META-INF/MANIFEST.MF index 358db2bf998..8bad523c585 100644 --- a/org.eclipse.jdt.ui.unittest.junit/META-INF/MANIFEST.MF +++ b/org.eclipse.jdt.ui.unittest.junit/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.jdt.ui.unittest.junit Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.jdt.ui.unittest.junit;singleton:=true -Bundle-Version: 1.1.300.qualifier +Bundle-Version: 1.1.400.qualifier Bundle-Activator: org.eclipse.jdt.ui.unittest.junit.JUnitTestPlugin Bundle-ActivationPolicy: lazy Bundle-Vendor: %providerName diff --git a/org.eclipse.jdt.ui.unittest.junit/pom.xml b/org.eclipse.jdt.ui.unittest.junit/pom.xml index 31c8fe6b35f..9e8f72f76c2 100644 --- a/org.eclipse.jdt.ui.unittest.junit/pom.xml +++ b/org.eclipse.jdt.ui.unittest.junit/pom.xml @@ -14,11 +14,11 @@ eclipse.jdt.ui eclipse.jdt.ui - 4.31.0-SNAPSHOT + 4.32.0-SNAPSHOT org.eclipse.jdt org.eclipse.jdt.ui.unittest.junit - 1.1.300-SNAPSHOT + 1.1.400-SNAPSHOT eclipse-plugin true diff --git a/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/ui/BasicElementLabels.java b/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/ui/BasicElementLabels.java index f6e00fd0cd6..a8dd1d7ce46 100644 --- a/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/ui/BasicElementLabels.java +++ b/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/ui/BasicElementLabels.java @@ -122,9 +122,9 @@ public static String getVersionName(String name) { } /** - * Returns a label for Java element name. Example is 'new Test() - * { ...}'. This method should only be used for simple element names. Use - * JavaElementLabels to create a label from a Java element. + * Returns a label for Java element name. Example is {@code 'new Test() { ...}'}. This method should only be used for simple element names. + * Use JavaElementLabels to create a label from a Java element. * * @param name the Java element name. * @return the label for the Java element diff --git a/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/ui/JUnitTestViewSupport.java b/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/ui/JUnitTestViewSupport.java index 746b49779f2..d1b19eeab64 100644 --- a/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/ui/JUnitTestViewSupport.java +++ b/org.eclipse.jdt.ui.unittest.junit/src/org/eclipse/jdt/ui/unittest/junit/ui/JUnitTestViewSupport.java @@ -193,7 +193,7 @@ public ILaunchConfiguration getRerunLaunchConfiguration(List tests ILaunchConfigurationWorkingCopy res; try { res = launchConfiguration.copy(launchConfiguration.getName() + " - rerun"); //$NON-NLS-1$ - res.setAttribute(JUnitLaunchConfigurationConstants.ATTR_TEST_METHOD_NAME, testMethodName); + res.setAttribute(JUnitLaunchConfigurationConstants.ATTR_TEST_NAME, testMethodName); return res; } catch (CoreException e) { JUnitTestPlugin.log(e); diff --git a/org.eclipse.jdt.ui/META-INF/MANIFEST.MF b/org.eclipse.jdt.ui/META-INF/MANIFEST.MF index a09c6d69d6c..09093ddcfa4 100644 --- a/org.eclipse.jdt.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.jdt.ui/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.jdt.ui Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.jdt.ui; singleton:=true -Bundle-Version: 3.32.0.qualifier +Bundle-Version: 3.32.100.qualifier Bundle-Activator: org.eclipse.jdt.internal.ui.JavaPlugin Bundle-ActivationPolicy: lazy Bundle-Vendor: %providerName diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/buildpath/ClasspathModifier.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/buildpath/ClasspathModifier.java index 182fad83cfa..6a930f35124 100644 --- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/buildpath/ClasspathModifier.java +++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/buildpath/ClasspathModifier.java @@ -857,7 +857,7 @@ public static void exclude(IPath path, List existingEntries, List * @param project the Java project * @param monitor progress monitor, can be null * - * @return the resulting IResource + * @return the resulting IResource */ public static IResource exclude(IJavaElement javaElement, CPListElement entry, IJavaProject project, IProgressMonitor monitor) { if (monitor == null) @@ -1031,8 +1031,10 @@ public static void commitClassPath(CPJavaProject cpProject, IProgressMonitor mon * * @param entries a list of entries to find an appropriate representation * for. The list can contain elements of two types: + *
      *
    • IResource
    • *
    • IJavaElement
    • + *
    * @param project the Java project * @return a list of elements corresponding to the passed entries. */ diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/JavaContextType.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/JavaContextType.java index 45868ae127c..62e8ffe03f4 100644 --- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/JavaContextType.java +++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/JavaContextType.java @@ -18,12 +18,12 @@ /** * The context type for templates inside Java code. * The same class is used for several context types: - *
    + *
      *
    • templates for all Java code locations
    • *
    • templates for member locations
    • *
    • templates for statement locations
    • *
    • templates for module-info.java files
    • - *
    + * */ public class JavaContextType extends AbstractJavaContextType { diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/SWTContextType.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/SWTContextType.java index 61374014bca..30427804e9e 100644 --- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/SWTContextType.java +++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/SWTContextType.java @@ -18,11 +18,11 @@ /** * The context type for templates inside SWT code. * The same class is used for several context types: - *
    + *
      *
    • templates for all Java code locations
    • *
    • templates for member locations
    • *
    • templates for statement locations
    • - *
    + * * @since 3.4 */ public class SWTContextType extends AbstractJavaContextType { diff --git a/org.eclipse.jdt.ui/pom.xml b/org.eclipse.jdt.ui/pom.xml index 71d85eba510..4092233e12d 100644 --- a/org.eclipse.jdt.ui/pom.xml +++ b/org.eclipse.jdt.ui/pom.xml @@ -14,11 +14,11 @@ eclipse.jdt.ui eclipse.jdt.ui - 4.31.0-SNAPSHOT + 4.32.0-SNAPSHOT org.eclipse.jdt org.eclipse.jdt.ui - 3.32.0-SNAPSHOT + 3.32.100-SNAPSHOT eclipse-plugin diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/FoldingActionGroup.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/FoldingActionGroup.java index 38cc3ac8525..3e43d3ca4a0 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/FoldingActionGroup.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/FoldingActionGroup.java @@ -198,7 +198,7 @@ public void run() { /** * Returns true if the group is enabled. *
    -	 * Invariant: isEnabled() <=> fViewer and all actions are != null.
    +	 * Invariant: isEnabled() == fViewer and all actions are != null.
     	 * 
    * * @return true if the group is enabled diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/MembersView.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/MembersView.java index d90651d7e36..a9e06508636 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/MembersView.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/MembersView.java @@ -155,7 +155,7 @@ private IJavaElement[] getCategoryFilterActionGroupInput() { * input for this part. * * @param element the object to test - * @return if the given element is a valid input + * @return true if the given element is a valid input */ @Override protected boolean isValidInput(Object element) { @@ -171,7 +171,7 @@ protected boolean isValidInput(Object element) { * element for this part. * * @param element the object to test - * @return if the given element is a valid element + * @return true if the given element is a valid element */ @Override protected boolean isValidElement(Object element) { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/PackagesView.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/PackagesView.java index 0999bf26988..7e5c7fc8e83 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/PackagesView.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/PackagesView.java @@ -281,7 +281,7 @@ protected String getLinkToEditorKey() { * input for this part. * * @param element the object to test - * @return if the given element is a valid input + * @return true if the given element is a valid input */ @Override protected boolean isValidInput(Object element) { @@ -301,7 +301,7 @@ protected boolean isValidInput(Object element) { * element for this part. * * @param element the object to test - * @return if the given element is a valid element + * @return true if the given element is a valid element */ @Override protected boolean isValidElement(Object element) { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/ProjectsView.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/ProjectsView.java index b72660282cc..ef87cb6af94 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/ProjectsView.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/ProjectsView.java @@ -130,7 +130,7 @@ protected void setInitialInput() { * input for this part. * * @param element the object to test - * @return if the given element is a valid input + * @return true if the given element is a valid input */ @Override protected boolean isValidInput(Object element) { @@ -142,7 +142,7 @@ protected boolean isValidInput(Object element) { * element for this part. * * @param element the object to test - * @return if the given element is a valid element + * @return true if the given element is a valid element */ @Override protected boolean isValidElement(Object element) { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/TypesView.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/TypesView.java index ecefe507310..8228c8eaba2 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/TypesView.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/TypesView.java @@ -86,7 +86,7 @@ protected void addFilters() { * input for this part. * * @param element the object to test - * @return if the given element is a valid input + * @return true if the given element is a valid input */ @Override protected boolean isValidInput(Object element) { @@ -98,7 +98,7 @@ protected boolean isValidInput(Object element) { * element for this part. * * @param element the object to test - * @return if the given element is a valid element + * @return true if the given element is a valid element */ @Override protected boolean isValidElement(Object element) { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/commands/JavaElementReferenceConverter.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/commands/JavaElementReferenceConverter.java index 3f0f8f2bd26..ccac855b498 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/commands/JavaElementReferenceConverter.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/commands/JavaElementReferenceConverter.java @@ -52,7 +52,6 @@ * * where parameterSignatures uses the signature format documented * in the {@link org.eclipse.jdt.core.Signature Signature} class. - *

    * * @since 3.2 */ diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dnd/JdtViewerDropAdapter.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dnd/JdtViewerDropAdapter.java index 9c7f7a0e73a..61bfe3832f4 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dnd/JdtViewerDropAdapter.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dnd/JdtViewerDropAdapter.java @@ -40,7 +40,6 @@ * * The setFeedbackEnabled method can be called to turn on and off * visual insertion feedback (on by default). - *

    *

    * THIS IS (ALMOST) A ONE-TO-ONE COPY OF PLATFORMS ViewerDropAdapter * REFERE THERE FIRST IF YOU NEED TO FIX SOMETHING. diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dnd/ResourceTransferDragAdapter.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dnd/ResourceTransferDragAdapter.java index 62222dc09ec..cbf97f5dcea 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dnd/ResourceTransferDragAdapter.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dnd/ResourceTransferDragAdapter.java @@ -48,10 +48,9 @@ import org.eclipse.jdt.internal.ui.util.SWTUtil; /** - * A drag adapter that transfers the current selection as - * IResource. Only those elements in the selection are part - * of the transfer which can be converted into an IResource - * . + * A drag adapter that transfers the current selection as IResource. Only those + * elements in the selection are part of the transfer which can be converted into an + * IResource. */ public class ResourceTransferDragAdapter extends DragSourceAdapter implements TransferDragSourceListener { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/ConstantsForSystemPropertyCleanUp.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/ConstantsForSystemPropertyCleanUp.java index fb326f3594b..044c769a9e3 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/ConstantsForSystemPropertyCleanUp.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/ConstantsForSystemPropertyCleanUp.java @@ -19,14 +19,13 @@ /** * A fix that replaces System.getProperty(xxx) by Java methods: *

      - *
    • Beware! The code doesn't any longer take the system property into account!
    • - * - * System.getProperties() can be overridden by calls to System.setProperty(String key, String value) + *
    • System.getProperties() can be overridden by calls to System.setProperty(String key, String value) * or with command line parameters -Dfile.separator=/ + *
      Beware! The code doesn't any longer take the system property into account! * - * File.separator gets the separator for the default filesystem. + *
    • File.separator gets the separator for the default filesystem. * - * FileSystems.getDefault() gets you the default filesystem. + *
    • FileSystems.getDefault() gets you the default filesystem. *
    */ public class ConstantsForSystemPropertyCleanUp extends AbstractCleanUpCoreWrapper { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/LazyLogicalCleanUp.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/LazyLogicalCleanUp.java index 2c78c526dbb..372575ca618 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/LazyLogicalCleanUp.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/LazyLogicalCleanUp.java @@ -44,8 +44,8 @@ /** * A fix that uses lazy logical operator when possible: *
      - *
    • Replaces & by &&,
    • - *
    • Replaces | by ||.
    • + *
    • Replaces {@code &} by {@code &&},
    • + *
    • Replaces {@code |} by {@code ||}.
    • *
    */ public class LazyLogicalCleanUp extends AbstractMultiFix { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/OperandFactorizationCleanUp.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/OperandFactorizationCleanUp.java index edecf4bc559..a33fcb5f4d2 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/OperandFactorizationCleanUp.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/OperandFactorizationCleanUp.java @@ -45,7 +45,7 @@ import org.eclipse.jdt.ui.text.java.IProblemLocation; /** - * A fix that replaces (X && Y) || (X && Z) by (X && (Y || Z)): + * A fix that replaces {@code (X && Y) || (X && Z) by (X && (Y || Z))}: *
      *
    • The operators can be lazy or eager,
    • *
    • The factor operand must be passive and primitive,
    • @@ -54,7 +54,7 @@ *
    * * Truth table: - *
    + * 
    {@code
        -------------------------------------------------------------------------------------------
        | a | b | c | (a && b) || (a && c) | a && (b || c) | (a || b) && (a || c) | a || (b && c) |
        | 0 | 0 | 0 |                    0 |             0 |                    0 |             0 |
    @@ -66,7 +66,7 @@
        | 1 | 1 | 0 |                    1 |             1 |                    1 |             1 |
        | 1 | 1 | 1 |                    1 |             1 |                    1 |             1 |
        -------------------------------------------------------------------------------------------
    -   
    + }
    */ public class OperandFactorizationCleanUp extends AbstractMultiFix { public OperandFactorizationCleanUp() { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/RedundantModifiersCleanUp.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/RedundantModifiersCleanUp.java index 31291a9e069..34e55698093 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/RedundantModifiersCleanUp.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/RedundantModifiersCleanUp.java @@ -52,7 +52,7 @@ *
  • Within an interface modifiers public, static and final * are redundant for field declarations.
  • *
  • Within an interface modifier public and - * abstract + * abstract are redundant for method declarations.
  • *
  • Within a final class the final modifier is redundant for method * declarations.
  • *
  • For nested interfaces the static modifier is redundant.
  • diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/StrictlyEqualOrDifferentCleanUp.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/StrictlyEqualOrDifferentCleanUp.java index 7c03abd9b58..d1b25d36398 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/StrictlyEqualOrDifferentCleanUp.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/StrictlyEqualOrDifferentCleanUp.java @@ -49,7 +49,7 @@ import org.eclipse.jdt.ui.text.java.IProblemLocation; /** - * A fix that replaces (X && !Y) || (!X && Y) by X ^ Y: + * A fix that replaces {@code (X && !Y) || (!X && Y)} by {@code X ^ Y}: *
      *
    • Only works on boolean,
    • *
    • Works with lazy or eager operators,
    • diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/TernaryOperatorCleanUp.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/TernaryOperatorCleanUp.java index 10d4487a95d..38aa0753699 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/TernaryOperatorCleanUp.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/TernaryOperatorCleanUp.java @@ -46,7 +46,7 @@ import org.eclipse.jdt.ui.text.java.IProblemLocation; /** - * A fix that replaces (X && Y) || (!X && Z) by X ? Y : Z: + * A fix that replaces {@code (X && Y) || (!X && Z)} by {@code X ? Y : Z}: *
        *
      • The operands must be passive and boolean.
      • *
      diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarimport/JarImportWizard.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarimport/JarImportWizard.java index 7e18ae36722..eb42a23242d 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarimport/JarImportWizard.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarimport/JarImportWizard.java @@ -80,7 +80,6 @@ * for associated refactorings, the wizard executes eventual refactorings, * copies the JAR file over its old version, the dialog closes, and the call to * open returns. - *

      * * @since 3.2 */ diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackager/JarPackageWizard.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackager/JarPackageWizard.java index 600ba2897d3..3ea48e28a1f 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackager/JarPackageWizard.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackager/JarPackageWizard.java @@ -70,7 +70,6 @@ * user. When the user hits Finish, the user-selected workspace resources * are exported to the user-specified zip file, the dialog closes, and the call * to open returns. - *

      */ public class JarPackageWizard extends Wizard implements IExportWizard { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java index 38ae06ef1a2..1372bf69f47 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java @@ -1118,7 +1118,7 @@ protected void setCaretPosition(final int position) { * not its enclosing Java element. *
    • If the selection spans one or more partitions of the document, then all * partitions covered by the selection are entirely formatted.
    • - *

      + *

    * Partitions at the end of the selection are not completed, except for comments. * * @since 3.0 @@ -3822,7 +3822,7 @@ public ISelectionProvider getSelectionProvider() { * Returns the cached selected range, which allows * to query it from a non-UI thread. *

    - * The result might be outdated if queried from a non-UI thread.

    + * The result might be outdated if queried from a non-UI thread. * * @return the caret offset in the master document * @see ITextViewer#getSelectedRange() diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaMoveLinesAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaMoveLinesAction.java index 14b6e102254..55782274f5e 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaMoveLinesAction.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaMoveLinesAction.java @@ -132,7 +132,7 @@ public void endCompoundEdit() { * [0] move up * [1] move down * [2] copy up (duplicate) - * [3] copy down (duplicate & select) + * [3] copy down (duplicate and select) * @param bundle the resource bundle * @param editor the editor * @return the quadruple of actions diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaSelectAnnotationRulerAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaSelectAnnotationRulerAction.java index bbd73438b44..b21c4e01caf 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaSelectAnnotationRulerAction.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaSelectAnnotationRulerAction.java @@ -50,7 +50,7 @@ * Action which gets triggered when selecting (annotations) in the vertical ruler. * *

    - * Was originally called >code>JavaSelectMarkerRulerAction. + * Was originally called JavaSelectMarkerRulerAction. *

    */ public class JavaSelectAnnotationRulerAction extends SelectMarkerRulerAction { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingReconciler.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingReconciler.java index a92a05d8be8..72880716f8b 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingReconciler.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingReconciler.java @@ -512,7 +512,7 @@ private void updatePresentation(TextPresentation textPresentation, List { // check Editor not reused otherwise meanwhile - if (document == fSourceViewer.getDocument()) { + if (fSourceViewer != null && document == fSourceViewer.getDocument()) { runnable.run(); } }); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/saveparticipant/IPostSaveListener.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/saveparticipant/IPostSaveListener.java index c8d4dba23e5..fc62b605980 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/saveparticipant/IPostSaveListener.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/saveparticipant/IPostSaveListener.java @@ -88,13 +88,13 @@ public interface IPostSaveListener { *
  • must not assume to be called in the UI thread
  • *
  • should be as fast as possible since this code is executed every time the compilationUnit is saved
  • * - * The compilation unit document provider can disable a listener that violates any of the above rules.

    + * The compilation unit document provider can disable a listener that violates any of the above rules. * * @param compilationUnit * the compilation unit which was saved * @param changedRegions * the regions where the compilationUnit has changed since the last save - * or null if requiresChangedRegions did return false. + * or null if requiresChangedRegions did return false. * The changed regions do not include changes introduced by other save participants. * @param monitor * the progress monitor for reporting progress diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/saveparticipant/ISaveParticipantPreferenceConfiguration.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/saveparticipant/ISaveParticipantPreferenceConfiguration.java index 0e08038c80f..02d432bfc8b 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/saveparticipant/ISaveParticipantPreferenceConfiguration.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/saveparticipant/ISaveParticipantPreferenceConfiguration.java @@ -89,7 +89,7 @@ public interface ISaveParticipantPreferenceConfiguration { /** * Called when a compilation unit is saved. - *

    + * * @param context the context in which the compilation unit is saved * @return true if the corresponding {@link IPostSaveListener} needs to be informed */ diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/PackageExplorerPart.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/PackageExplorerPart.java index 6b9fea51743..9fd9317c069 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/PackageExplorerPart.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/PackageExplorerPart.java @@ -581,7 +581,7 @@ private ProblemTreeViewer createViewer(Composite composite) { /** * Answers whether this part shows the packages flat or hierarchical. - * @return if flat layout is selected + * @return true if flat layout is selected * * @since 2.1 */ diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/FilteredPreferenceTree.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/FilteredPreferenceTree.java index ba82b65e75b..a14c6fac0e5 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/FilteredPreferenceTree.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/FilteredPreferenceTree.java @@ -68,7 +68,6 @@ *

  • pattern ~valueFilter
  • *
  • ~valueFilter pattern
  • * - *

    */ public class FilteredPreferenceTree { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/IPropertiesFilePartitions.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/IPropertiesFilePartitions.java index 0073e6d2140..382e41fa0be 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/IPropertiesFilePartitions.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/IPropertiesFilePartitions.java @@ -46,7 +46,6 @@ public interface IPropertiesFilePartitions { /** * Array with properties file partitions. - * Value: {@value} */ String[] PARTITIONS= new String[] { COMMENT, PROPERTY_VALUE }; diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileAutoEditStrategy.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileAutoEditStrategy.java index 15bf57e7601..318fc46c688 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileAutoEditStrategy.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileAutoEditStrategy.java @@ -52,7 +52,6 @@ * {@link PropertiesFileEscapes#containsInvalidEscapeSequence(String)} *
  • a character which requires Unicode escapes
  • * - *

    * * @since 3.7 */ diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/AddImportCorrectionProposal.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/AddImportCorrectionProposal.java deleted file mode 100644 index cab2585956a..00000000000 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/AddImportCorrectionProposal.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2024 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - * Red Hat Inc - separate core logic from UI images - *******************************************************************************/ -package org.eclipse.jdt.internal.ui.text.correction.proposals; - -import org.eclipse.swt.graphics.Image; - -import org.eclipse.core.runtime.CoreException; - -import org.eclipse.jface.text.IDocument; - -import org.eclipse.ui.IEditorPart; - -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.dom.SimpleName; -import org.eclipse.jdt.core.dom.rewrite.ASTRewrite; - -import org.eclipse.jdt.internal.corext.util.QualifiedTypeNameHistory; - -import org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposal; - -public class AddImportCorrectionProposal extends ASTRewriteCorrectionProposal { - - static String JAVA_BASE= AddImportCorrectionProposalCore.JAVA_BASE; - private AddModuleRequiresCorrectionProposal additional = null; - public AddImportCorrectionProposal(AddImportCorrectionProposalCore core, Image image) { - super(core.getName(), core.getCompilationUnit(), null, core.getRelevance(), image, core); - } - public AddImportCorrectionProposal(String name, ICompilationUnit cu, int relevance, Image image, String qualifierName, String typeName, SimpleName node) { - super(name, cu, ASTRewrite.create(node.getAST()), relevance, image, new AddImportCorrectionProposalCore(name, cu, relevance, qualifierName, typeName, node)); - } - - public String getQualifiedTypeName() { - return ((AddImportCorrectionProposalCore) getDelegate()).getQualifiedTypeName(); - } - - public AddModuleRequiresCorrectionProposal getAdditionalProposal() { - if( additional == null ) { - AddImportCorrectionProposalCore del = (AddImportCorrectionProposalCore) getDelegate(); - AddModuleRequiresCorrectionProposalCore core= del.getAdditionalChangeCorrectionProposal(); - additional = new AddModuleRequiresCorrectionProposal(core); - } - return additional; - } - - @Override - protected void performChange(IEditorPart activeEditor, IDocument document) throws CoreException { - super.performChange(activeEditor, document); - rememberSelection(); - } - - private void rememberSelection() { - QualifiedTypeNameHistory.remember(getQualifiedTypeName()); - } -} diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ChainCompletionProposalComputer.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ChainCompletionProposalComputer.java index 51aa84c854d..e466ea797f8 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ChainCompletionProposalComputer.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ChainCompletionProposalComputer.java @@ -152,13 +152,21 @@ private boolean matchesExpectedPrefix(final IJavaElement element) { } private List executeCallChainSearch() { - final int maxChains= Integer.parseInt(JavaManipulation.getPreference(PreferenceConstants.PREF_MAX_CHAINS, ctx.getProject())); - final int minDepth= Integer.parseInt(JavaManipulation.getPreference(PreferenceConstants.PREF_MIN_CHAIN_LENGTH, ctx.getProject())); - final int maxDepth= Integer.parseInt(JavaManipulation.getPreference(PreferenceConstants.PREF_MAX_CHAIN_LENGTH, ctx.getProject())); + final int maxChains, minDepth, maxDepth; + try { + maxChains= Integer.parseInt(JavaManipulation.getPreference(PreferenceConstants.PREF_MAX_CHAINS, ctx.getProject())); + minDepth= Integer.parseInt(JavaManipulation.getPreference(PreferenceConstants.PREF_MIN_CHAIN_LENGTH, ctx.getProject())); + maxDepth= Integer.parseInt(JavaManipulation.getPreference(PreferenceConstants.PREF_MAX_CHAIN_LENGTH, ctx.getProject())); + } catch (NumberFormatException e) { + return Collections.emptyList(); + } - excludedTypes= JavaManipulation.getPreference(PreferenceConstants.PREF_CHAIN_IGNORED_TYPES, ctx.getProject()).split("\\|"); //$NON-NLS-1$ - for (int i= 0; i < excludedTypes.length; ++i) { - excludedTypes[i]= "L" + excludedTypes[i].replace('.', '/'); //$NON-NLS-1$ + String excludedTypesVal = JavaManipulation.getPreference(PreferenceConstants.PREF_CHAIN_IGNORED_TYPES, ctx.getProject()); + if (excludedTypesVal != null) { + excludedTypes= excludedTypesVal.split("\\|"); //$NON-NLS-1$ + for (int i= 0; i < excludedTypes.length; ++i) { + excludedTypes[i]= "L" + excludedTypes[i].replace('.', '/'); //$NON-NLS-1$ + } } final IType invocationType= ctx.getCompilationUnit().findPrimaryType(); @@ -172,7 +180,13 @@ private List executeCallChainSearch() { finder.startChainSearch(entrypoints, maxChains, minDepth, maxDepth); } }); - long timeout= Long.parseLong(JavaManipulation.getPreference(PreferenceConstants.PREF_CHAIN_TIMEOUT, ctx.getProject())); + + long timeout; + try { + timeout= Long.parseLong(JavaManipulation.getPreference(PreferenceConstants.PREF_CHAIN_TIMEOUT, ctx.getProject())); + } catch (NumberFormatException e) { + timeout = 1; + } future.get(timeout, TimeUnit.SECONDS); } catch (final Exception e) { finder.cancel(); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalComputerRegistry.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalComputerRegistry.java index 9a882499eea..922c60a0c63 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalComputerRegistry.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalComputerRegistry.java @@ -224,7 +224,6 @@ List getProposalComputerDescriptors() { * Returns the list of proposal categories contributed to the * javaCompletionProposalComputer extension point. *

    - *

    * The returned list is read-only and is sorted in the order that the extensions were read in. * There are no duplicate elements in the returned list. The returned list may change if * plug-ins are loaded or unloaded while the application is running. diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ContentAssistProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ContentAssistProcessor.java index 6ce0d6c80f3..df7b1876744 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ContentAssistProcessor.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ContentAssistProcessor.java @@ -93,7 +93,6 @@ * contexts are provided) *

  • getErrorMessage to change error reporting
  • * - *

    * * @since 3.2 */ diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/FillArgumentNamesCompletionProposalCollector.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/FillArgumentNamesCompletionProposalCollector.java index bfd826b9392..e74c36d941a 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/FillArgumentNamesCompletionProposalCollector.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/FillArgumentNamesCompletionProposalCollector.java @@ -37,7 +37,6 @@ *

    * This collector is used when * {@link PreferenceConstants#CODEASSIST_FILL_ARGUMENT_NAMES} is enabled. - *

    */ public final class FillArgumentNamesCompletionProposalCollector extends CompletionProposalCollector { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaTextMessages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaTextMessages.java index b5af4445934..87ad327e042 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaTextMessages.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaTextMessages.java @@ -44,6 +44,7 @@ private JavaTextMessages() { public static String GetterSetterCompletionProposal_setter_label; public static String MethodCompletionProposal_constructor_label; public static String MethodCompletionProposal_method_label; + public static String RecordAccessorCompletionProposal_accessor_label; static { NLS.initializeMessages(BUNDLE_NAME, JavaTextMessages.class); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaTextMessages.properties b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaTextMessages.properties index 1b0425d22b8..50ccc4519bf 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaTextMessages.properties +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaTextMessages.properties @@ -51,6 +51,7 @@ GetterSetterCompletionProposal_getter_label=Getter for ''{0}'' GetterSetterCompletionProposal_setter_label=Setter for ''{0}'' MethodCompletionProposal_constructor_label=Constructor MethodCompletionProposal_method_label=Method stub +RecordAccessorCompletionProposal_accessor_label=Record accessor stub ContentAssistProcessor_computing_proposals=Computing completion proposals ContentAssistProcessor_collecting_proposals=Collecting proposals diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/MethodDeclarationCompletionProposal.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/MethodDeclarationCompletionProposal.java index d2bfaaf4cb1..c532d166aec 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/MethodDeclarationCompletionProposal.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/MethodDeclarationCompletionProposal.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 IBM Corporation and others. + * Copyright (c) 2000, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -28,6 +28,7 @@ import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.TextUtilities; +import org.eclipse.jdt.core.IField; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.Signature; @@ -58,6 +59,7 @@ public class MethodDeclarationCompletionProposal extends JavaTypeCompletionPropo public static void evaluateProposals(IType type, String prefix, int offset, int length, int relevance, Set suggestedMethods, Collection result) throws CoreException { IMethod[] methods= type.getMethods(); + IField[] components= type.getRecordComponents(); if (!type.isInterface()) { String constructorName= type.getElementName(); if (constructorName.length() > 0 && constructorName.startsWith(prefix) && !hasMethod(methods, constructorName) && suggestedMethods.add(constructorName)) { @@ -65,9 +67,10 @@ public static void evaluateProposals(IType type, String prefix, int offset, int } } - if (prefix.length() > 0 && !"main".equals(prefix) && !hasMethod(methods, prefix) && suggestedMethods.add(prefix)) { //$NON-NLS-1$ - if (!JavaConventionsUtil.validateMethodName(prefix, type).matches(IStatus.ERROR)) + if (prefix.length() > 0 && !"main".equals(prefix) && !hasMethod(methods, prefix) && !hasRecordComponent(components, prefix) && suggestedMethods.add(prefix)) { //$NON-NLS-1$ + if (!JavaConventionsUtil.validateMethodName(prefix, type).matches(IStatus.ERROR)) { result.add(new MethodDeclarationCompletionProposal(type, prefix, Signature.SIG_VOID, offset, length, relevance)); + } } } @@ -80,6 +83,15 @@ private static boolean hasMethod(IMethod[] methods, String name) { return false; } + private static boolean hasRecordComponent(IField[] components, String name) { + for (IField curr : components) { + if (curr.getElementName().equals(name)) { + return true; + } + } + return false; + } + private final IType fType; private final String fReturnTypeSig; private final String fMethodName; @@ -140,7 +152,9 @@ protected boolean updateReplacementString(IDocument document, char trigger, int } } if (fReturnTypeSig != null) { - if (!isInterface) { + if (fType.isRecord()) { + buf.append("public "); //$NON-NLS-1$ + } else if (!isInterface) { buf.append("private "); //$NON-NLS-1$ } } else { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/RecordAccessorCompletionProposal.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/RecordAccessorCompletionProposal.java new file mode 100644 index 00000000000..d7b5028e4be --- /dev/null +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/RecordAccessorCompletionProposal.java @@ -0,0 +1,176 @@ +/******************************************************************************* + * Copyright (c) 2024 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.internal.ui.text.java; + +import java.util.Collection; +import java.util.Set; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; + +import org.eclipse.jface.viewers.StyledString; + +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.IRegion; +import org.eclipse.jface.text.TextUtilities; + +import org.eclipse.jdt.core.IField; +import org.eclipse.jdt.core.IMethod; +import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.Signature; +import org.eclipse.jdt.core.dom.rewrite.ImportRewrite; +import org.eclipse.jdt.core.formatter.CodeFormatter; +import org.eclipse.jdt.core.manipulation.CodeGeneration; + +import org.eclipse.jdt.internal.core.manipulation.util.Strings; +import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings; +import org.eclipse.jdt.internal.corext.util.CodeFormatterUtil; +import org.eclipse.jdt.internal.corext.util.JavaConventionsUtil; + +import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal; + +import org.eclipse.jdt.internal.ui.JavaPluginImages; +import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings; +import org.eclipse.jdt.internal.ui.preferences.formatter.FormatterProfileManager; + + +/** + * Record accessor declaration proposal. + */ +public class RecordAccessorCompletionProposal extends JavaTypeCompletionProposal { + + + public static void evaluateProposals(IType type, String prefix, int offset, int length, int relevance, Set suggestedMethods, Collection result) throws CoreException { + IMethod[] methods= type.getMethods(); + if (!type.isRecord()) { + return; + } + if (prefix.length() > 0 && !hasMethod(methods, prefix)) { + if (!JavaConventionsUtil.validateMethodName(prefix, type).matches(IStatus.ERROR)) { + IField[] fields= type.getRecordComponents(); + for (IField field : fields) { + if (field.getElementName().startsWith(prefix)) { + if (suggestedMethods.add(field.getElementName())) { + result.add(new RecordAccessorCompletionProposal(type, field.getElementName(), field.getTypeSignature(), offset, length, relevance + 1)); + } + } + } + } + } + } + + private static boolean hasMethod(IMethod[] methods, String name) { + for (IMethod curr : methods) { + if (curr.getElementName().equals(name) && curr.getParameterTypes().length == 0) { + return true; + } + } + return false; + } + + private final IType fType; + private final String fReturnTypeSig; + private final String fMethodName; + + public RecordAccessorCompletionProposal(IType type, String methodName, String returnTypeSig, int start, int length, int relevance) { + super("", type.getCompilationUnit(), start, length, null, getDisplayName(methodName, returnTypeSig), relevance); //$NON-NLS-1$ + Assert.isNotNull(type); + Assert.isNotNull(methodName); + Assert.isNotNull(returnTypeSig); + + fType= type; + fMethodName= methodName; + fReturnTypeSig= returnTypeSig; + + setImage(JavaPluginImages.get(JavaPluginImages.IMG_MISC_PUBLIC)); + } + + private static StyledString getDisplayName(String methodName, String returnTypeSig) { + StyledString buf= new StyledString(); + buf.append(methodName); + buf.append('('); + buf.append(')'); + buf.append(" : "); //$NON-NLS-1$ + buf.append(Signature.toString(returnTypeSig)); + buf.append(" - ", StyledString.QUALIFIER_STYLER); //$NON-NLS-1$ + buf.append(JavaTextMessages.RecordAccessorCompletionProposal_accessor_label, StyledString.QUALIFIER_STYLER); + return buf; + } + + @Override + protected boolean updateReplacementString(IDocument document, char trigger, int offset, ImportRewrite impRewrite) throws CoreException, BadLocationException { + + CodeGenerationSettings settings= JavaPreferencesSettings.getCodeGenerationSettings(fType.getJavaProject()); + boolean addComments= settings.createComments; + + String[] empty= new String[0]; + String lineDelim= TextUtilities.getDefaultLineDelimiter(document); + String declTypeName= fType.getTypeQualifiedName('.'); + + StringBuilder buf= new StringBuilder(); + if (addComments) { + String comment= CodeGeneration.getMethodComment(fType.getCompilationUnit(), declTypeName, fMethodName, empty, empty, fReturnTypeSig, empty, null, lineDelim); + if (comment != null) { + buf.append(comment); + buf.append(lineDelim); + } + } + buf.append("public "); //$NON-NLS-1$ + + if (fReturnTypeSig != null) { + buf.append(Signature.toString(fReturnTypeSig)); + } + buf.append(' '); + buf.append(fMethodName); + buf.append("() {"); //$NON-NLS-1$ + buf.append(lineDelim); + + String returnStatement= "return " + fMethodName + ";"; //$NON-NLS-1$ //$NON-NLS-2$ + buf.append(returnStatement); + buf.append(lineDelim); + buf.append("}"); //$NON-NLS-1$ + buf.append(lineDelim); + String stub= buf.toString(); + + // use the code formatter + IRegion region= document.getLineInformationOfOffset(getReplacementOffset()); + int lineStart= region.getOffset(); + int indent= Strings.computeIndentUnits(document.get(lineStart, getReplacementOffset() - lineStart), settings.tabWidth, settings.indentWidth); + + String replacement= CodeFormatterUtil.format(CodeFormatter.K_CLASS_BODY_DECLARATIONS, stub, indent, lineDelim, FormatterProfileManager.getProjectSettings(fType.getJavaProject())); + + if (replacement.endsWith(lineDelim)) { + replacement= replacement.substring(0, replacement.length() - lineDelim.length()); + } + + setReplacementString(Strings.trimLeadingTabsAndSpaces(replacement)); + return true; + } + + @Override + public CharSequence getPrefixCompletionText(IDocument document, int completionOffset) { + return ""; // don't let method stub proposals complete incrementally //$NON-NLS-1$ + } + + /* + * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension4#isAutoInsertable() + */ + @Override + public boolean isAutoInsertable() { + return false; + } + +} diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/PropertiesFileSpellCheckIterator.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/PropertiesFileSpellCheckIterator.java index f3d59f31cac..a770afbb1b4 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/PropertiesFileSpellCheckIterator.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/PropertiesFileSpellCheckIterator.java @@ -13,9 +13,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.ui.text.spelling; -import java.util.Locale; - import java.text.BreakIterator; +import java.util.Locale; import org.eclipse.core.runtime.IProgressMonitor; @@ -25,7 +24,7 @@ /** * Iterator to spell check Java properties files - * where '&' is ignored. + * where {@code '&'} is ignored. * * @since 3.3 */ diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/WordCompletionProposalComputer.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/WordCompletionProposalComputer.java index da4a59a3be2..e8b4d8e34a7 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/WordCompletionProposalComputer.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/WordCompletionProposalComputer.java @@ -43,10 +43,7 @@ * Note: This is currently not supported because the spelling engine * cannot return word proposals but only correction proposals. *

    - * If we enable this again we must register the computer in plugin.xml: - *

    - * 
    - *

    + * If we enable this again we must register the computer in plugin.xml * * @since 3.0 */ diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java index 989db8adeb0..e70756d9e27 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java @@ -21,7 +21,6 @@ *

    * This algorithm uses an adapted version double metaphone algorithm by * Lawrence Philips. - *

    * * @since 3.0 */ diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/engine/package.html b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/engine/package.html index 6ecebe09e10..036be974965 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/engine/package.html +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/engine/package.html @@ -16,59 +16,59 @@

    spell-check iterators, or replaced by more specialized algorithms for a particular group of languages.

    Spell Check Engine

    -The central point to access the spell-checker functionality is the interface ISpellCheckEngine. +The central point to access the spell-checker functionality is the interface ISpellCheckEngine. Implementations of this interface provide support for life-cycle management, registering and unregistering dictionaries, changing the locale of the engine and creating a spell-checker for a specific language.

    The following steps are needed to obtain a spell-checker for a specific language:

      -
    • Create an instance of ISpellCheckEngine. In this package, no default implementation is provided, +
    • Create an instance of ISpellCheckEngine. In this package, no default implementation is provided, since the management of the dictionary registering and loading is application dependent. Usually, instances -of ISpellCheckEngine are implemented as singletons.
    • +of ISpellCheckEngine are implemented as singletons.
    • Create the appropriate dictionaries that should be used during the spell-check process. All dictionaries that -can be registered with ISpellCheckEngine must implement the interface ISpellCheckDictionary. -For this interface, an abstract implementation is provided in the class AbstractSpellDictionary. +can be registered with ISpellCheckEngine must implement the interface ISpellCheckDictionary. +For this interface, an abstract implementation is provided in the class AbstractSpellDictionary. Depending on the language of the words contained in this dictionary, custom algorithms for the phonetic hash - (IPhoneticHashProvider) and the edit distance (IPhoneticDistanceAlgorithm) should be implemented + (IPhoneticHashProvider) and the edit distance (IPhoneticDistanceAlgorithm) should be implemented and registered with the dictionary.
    • -
    • Instances of spell-checkers can now be created by calling createSpellChecker(Locale), where the locale +
    • Instances of spell-checkers can now be created by calling createSpellChecker(Locale), where the locale denotes the language that the spell-checker should use while executing.
    -When requesting a new spell-checker with a different locale via createSpellChecker(Locale), the spell-checker is +When requesting a new spell-checker with a different locale via createSpellChecker(Locale), the spell-checker is reconfigured with the new dictionaries. More concretely, the old dictionary is unregistered and a new one registered for the desired locale is associated with the spell-checker. If no such dictionary is available, no spell-checker is returned and the locale of the engine is reset to its default locale.

    Dictionaries

    Dictionaries are the data structures to hold word lists for a particular language. All implementations of dictionaries must -implement the interface ISpellDictionary. It provides support for life-cycle management as well as the facility to query +implement the interface ISpellDictionary. It provides support for life-cycle management as well as the facility to query words from the list, add words to the list and get correction proposals for incorrectly spelt words.

    -This package provides a default implementation of a dictionary (AbstractSpellDictionary) that uses algorithms +This package provides a default implementation of a dictionary (AbstractSpellDictionary) that uses algorithms convenient for english languages.
    Every dictionary needs two kinds of algorithms to be plugged in:

      -
    • An edit distance algorithm: Edit distance algorithms implement the interface IPhoneticDistanceAlgorithm. The algorithm -is used to determine the similarity between two words. This package provides a default implementation for languages using the latin alphabet (DefaultPhoneticDistanceAlgorithm). +
    • An edit distance algorithm: Edit distance algorithms implement the interface IPhoneticDistanceAlgorithm. The algorithm +is used to determine the similarity between two words. This package provides a default implementation for languages using the latin alphabet (DefaultPhoneticDistanceAlgorithm). The default algorithm uses the Levenshtein text edit distance.
    • -
    • A hash algorithm: Phonetic hash providers implement the interface IPhoneticHashProvider. The purpose of +
    • A hash algorithm: Phonetic hash providers implement the interface IPhoneticHashProvider. The purpose of phonetic hashes is to have a representation of words which allows comparing it to other, similar words. This package provides a default implementation which is convenient for slavic and english languages. It uses the double metaphone algorithm by published Lawrence Philips.
    -By plugging in custom implementations of one or both of these algorithms the abstract implementation AbstractSpellDictionary can +By plugging in custom implementations of one or both of these algorithms the abstract implementation AbstractSpellDictionary can be customized to specified languages and alphabets.

    Spell Check Iterators

    -Instances of ISpellChecker are usually language-, locale- and medium independent implementations and therefore need an input provider. The -interface ISpellCheckIterator serves this purpose by abstracting the tokenizing of text media to a simple iteration. The actual spell-check process -is launched by calling ISpellChecker#execute(ISpellCheckIterator). This method uses the indicated spell-check iterator to determine the +Instances of ISpellChecker are usually language-, locale- and medium independent implementations and therefore need an input provider. The +interface ISpellCheckIterator serves this purpose by abstracting the tokenizing of text media to a simple iteration. The actual spell-check process +is launched by calling ISpellChecker#execute(ISpellCheckIterator). This method uses the indicated spell-check iterator to determine the words that are to be spell-checked. This package provides no default implementation of a spell-check iterator.

    Event Handling

    To communicate the results of a spell-check pass, spell-checkers fire spell events that inform listeners about the status of a particular word being spell-checked. Instances that are interested in receiving spell events must implement -the interface ISpellEventListener and register with the spell-checker before the spell-check process starts.

    +the interface ISpellEventListener and register with the spell-checker before the spell-check process starts.

    A spell event contains the following information:

    • The word being spell-checked
    • diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/package.html b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/package.html index f880e28473d..936038e0f74 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/package.html +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/package.html @@ -20,14 +20,14 @@

      word completion proposals to the content assist processor.

      Spell-check engine

      -SpellCheckEngine is the default implementation of the interface ISpellCheckEngine. +SpellCheckEngine is the default implementation of the interface ISpellCheckEngine. It provides a facade for dealing with the setup of a spell-checker. This class provides methods to retrieve the available dictionaries and is responsible for the registration of those with the spell-checker. -SpellCheckEngine also has support for life-cycle management. Single dictionaries can be temporarily +SpellCheckEngine also has support for life-cycle management. Single dictionaries can be temporarily unloaded from memory or unregistered.
      To contribute own dictionaries use the methods to register locale sensitive or insensitive dictionaries. A dictionary can be associated to a specified locale, but can also be available for spell-checking arbitrary text in arbitrary languages. -The actual spell-checker for a specified language can then be obtained by calling createSpellChecker(Locale). +The actual spell-checker for a specified language can then be obtained by calling createSpellChecker(Locale). This is the central point to working with the spell-checker. When requesting a spell-checker for a specified locale, the engine looks up the corresponding dictionary and registers it with the spell-checker. Note that the dictionaries are lazily loaded and can be further optimized by prefiltering the queried words. diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyViewPart.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyViewPart.java index 315a641c6eb..734f7aa1618 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyViewPart.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyViewPart.java @@ -1886,7 +1886,7 @@ public void setViewersInput() { * Sets whether empty viewers should keep showing. If false, replace with fEmptyTypesViewer. * * @param keepShowingEmptyViewers true if the empty viewers can be shown, - * false otherwise + * false otherwise * * @since 3.6 */ @@ -1898,7 +1898,7 @@ public void setKeepShowingEmptyViewers(boolean keepShowingEmptyViewers) { * Returns value that determines whether the empty viewers should keep showing. If false, * replace with fEmptyTypesViewer. * - * @return true if the empty viewers can be shown, false otherwise + * @return true if the empty viewers can be shown, false otherwise * * @since 3.6 */ diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/ElementValidator.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/ElementValidator.java index 70f952e6873..7355c2f3ee7 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/ElementValidator.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/ElementValidator.java @@ -37,7 +37,7 @@ import org.eclipse.jdt.internal.ui.JavaUIMessages; /** - * Helper class to check if a set of IJavaElement objects can be + * Helper class to check if a set of IJavaElement objects can be * modified by an operation. * * @since 2.1 diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/PatternMatcher.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/PatternMatcher.java index f403248d5ff..7322e0eb7fd 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/PatternMatcher.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/PatternMatcher.java @@ -15,12 +15,12 @@ import org.eclipse.jdt.core.search.SearchPattern; -import org.eclipse.jdt.internal.corext.util.SearchUtils; import org.eclipse.jdt.internal.core.manipulation.util.Strings; +import org.eclipse.jdt.internal.corext.util.SearchUtils; /** * A pattern matcher can match strings against various kinds of patterns supported by {@link SearchPattern}: - * Prefix, "*" and "?" patterns, camelCase, exact match with " " or "<" at the end of the pattern. + * Prefix, "*" and "?" patterns, camelCase, exact match with " " or {@code "<"} at the end of the pattern. * * @since 3.8 */ diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/ViewerPane.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/ViewerPane.java index 101d3a69e7e..44999f5e0ed 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/ViewerPane.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/ViewerPane.java @@ -25,7 +25,6 @@ /** * A ViewerPane is a convenience class which installs a * CLabel and a Toolbar in a ViewForm. - *

      */ public class ViewerPane extends ViewForm { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewTypeDropDownAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewTypeDropDownAction.java index 0fbb50de906..c989e521fbe 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewTypeDropDownAction.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewTypeDropDownAction.java @@ -49,6 +49,7 @@ /** * A type wizard is added to the type drop down if it has a paramater 'javatype': + *

      {@code
        *     
        *      
      + * }
      */ public class NewTypeDropDownAction extends Action implements IMenuCreator, IWorkbenchWindowPulldownDelegate2 { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/newsourcepage/ClasspathModifierQueries.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/newsourcepage/ClasspathModifierQueries.java index 1d97f8902ef..39883bce8cb 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/newsourcepage/ClasspathModifierQueries.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/newsourcepage/ClasspathModifierQueries.java @@ -33,13 +33,13 @@ import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels; import org.eclipse.jdt.internal.corext.util.Messages; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess; import org.eclipse.jdt.internal.ui.JavaPlugin; -import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels; import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages; import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; import org.eclipse.jdt.internal.ui.wizards.buildpaths.ExclusionInclusionDialog; @@ -65,9 +65,11 @@ public static abstract class OutputFolderValidator { * * @param newElements a list of elements that will be added * to the buildpath. The list's items can be of type: + *
        *
      • IJavaProject
      • *
      • IPackageFragment
      • *
      • IFolder
      • + *
      * @param project the Java project */ public OutputFolderValidator(List newElements, IJavaProject project) throws JavaModelException { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetModel.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetModel.java index 402c293d4ff..2bd57252966 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetModel.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetModel.java @@ -417,8 +417,7 @@ private void addNewlyCreatedWorkingSets(List result) { *

      * Note : All the active working sets must be contained in allWorkingSets and the relative * ordering of the active working sets must be same in both allWorkingSets and activeWorkingSets - * arrays, else the method throws an IllegalArgumentException + * arrays, else the method throws an IllegalArgumentException. * * @param allWorkingSets the array of all working sets * @param isSortingEnabled true if sorting is enabled, false otherwise diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/CompletionProposalCollector.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/CompletionProposalCollector.java index d3156d9a6be..a828a125096 100755 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/CompletionProposalCollector.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/CompletionProposalCollector.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2023 IBM Corporation and others. + * Copyright (c) 2000, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -18,11 +18,19 @@ import java.util.List; import java.util.Set; +import org.eclipse.swt.graphics.Image; + import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.StyledString; + +import org.eclipse.jface.text.contentassist.IContextInformation; + import org.eclipse.jdt.core.CompletionContext; import org.eclipse.jdt.core.CompletionProposal; import org.eclipse.jdt.core.CompletionRequestor; @@ -35,9 +43,11 @@ import org.eclipse.jdt.core.Signature; import org.eclipse.jdt.core.compiler.IProblem; import org.eclipse.jdt.core.formatter.CodeFormatter; + import org.eclipse.jdt.internal.corext.util.CodeFormatterUtil; import org.eclipse.jdt.internal.corext.util.CollectionsUtil; import org.eclipse.jdt.internal.corext.util.TypeFilter; + import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.preferences.formatter.FormatterProfileManager; import org.eclipse.jdt.internal.ui.text.java.AnnotationAtttributeProposalInfo; @@ -57,14 +67,11 @@ import org.eclipse.jdt.internal.ui.text.java.MethodProposalInfo; import org.eclipse.jdt.internal.ui.text.java.OverrideCompletionProposal; import org.eclipse.jdt.internal.ui.text.java.ProposalContextInformation; +import org.eclipse.jdt.internal.ui.text.java.RecordAccessorCompletionProposal; import org.eclipse.jdt.internal.ui.text.java.RelevanceComputer; import org.eclipse.jdt.internal.ui.text.javadoc.JavadocInlineTagCompletionProposal; import org.eclipse.jdt.internal.ui.text.javadoc.JavadocLinkTypeCompletionProposal; import org.eclipse.jdt.internal.ui.viewsupport.ImageDescriptorRegistry; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.text.contentassist.IContextInformation; -import org.eclipse.jface.viewers.StyledString; -import org.eclipse.swt.graphics.Image; /** * Java UI implementation of CompletionRequestor. Produces @@ -677,6 +684,7 @@ private void acceptPotentialMethodDeclaration(CompletionProposal proposal) { int relevance= computeRelevance(proposal); GetterSetterCompletionProposal.evaluateProposals(type, prefix, completionStart, completionEnd - completionStart, relevance + 2, fSuggestedMethodNames, fJavaProposals); + RecordAccessorCompletionProposal.evaluateProposals(type, prefix, completionStart, completionEnd - completionStart, relevance + 1, fSuggestedMethodNames, fJavaProposals); MethodDeclarationCompletionProposal.evaluateProposals(type, prefix, completionStart, completionEnd - completionStart, relevance, fSuggestedMethodNames, fJavaProposals); } } catch (CoreException e) { diff --git a/pom.xml b/pom.xml index 8c1cca029f2..5e8d2538d02 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ org.eclipse eclipse-platform-parent - 4.31.0-SNAPSHOT + 4.32.0-SNAPSHOT ../eclipse-platform-parent diff --git a/tests-pom/pom.xml b/tests-pom/pom.xml index 3c33d520a40..d3bb90ac3b2 100644 --- a/tests-pom/pom.xml +++ b/tests-pom/pom.xml @@ -14,7 +14,7 @@ eclipse.jdt.ui eclipse.jdt.ui - 4.31.0-SNAPSHOT + 4.32.0-SNAPSHOT tests-pom pom