From 14f2275431a0dbe151f1cb50f1c8f4a6ab654fdb Mon Sep 17 00:00:00 2001 From: Carsten Hammer Date: Tue, 9 Aug 2022 00:21:59 +0200 Subject: [PATCH] Cover zero hit case (#194) --- .../ltk/internal/ui/refactoring/PreviewWizardPage.java | 8 +++++--- .../internal/ui/refactoring/RefactoringUIMessages.java | 2 ++ .../ui/refactoring/RefactoringUIMessages.properties | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/PreviewWizardPage.java b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/PreviewWizardPage.java index f233651d4ed..c3c7d25449d 100644 --- a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/PreviewWizardPage.java +++ b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/PreviewWizardPage.java @@ -305,7 +305,7 @@ public PreviewWizardPage() { */ public PreviewWizardPage(boolean wizard) { super(PAGE_NAME, wizard); - setDescription(RefactoringUIMessages.PreviewWizardPage_description_s); + setDescription(RefactoringUIMessages.PreviewWizardPage_description_z); } /** @@ -562,8 +562,10 @@ protected void setTreeViewerInput() { if (fTreeViewerInputChange != null) { input= AbstractChangeNode.createNode(null, fTreeViewerInputChange); int filenumber= fTreeViewerInputChange.getFilenumber(); - String fullDescription= RefactoringUIMessages.PreviewWizardPage_description_s; - if (filenumber > 1) { + String fullDescription= RefactoringUIMessages.PreviewWizardPage_description_z; + if (filenumber == 1) { + fullDescription= RefactoringUIMessages.PreviewWizardPage_description_s; + } else if (filenumber > 1) { fullDescription= MessageFormat.format(RefactoringUIMessages.PreviewWizardPage_description_m, String.valueOf(filenumber)); } setDescription(fullDescription); diff --git a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/RefactoringUIMessages.java b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/RefactoringUIMessages.java index 456eabb332b..8a503ded5ce 100644 --- a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/RefactoringUIMessages.java +++ b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/RefactoringUIMessages.java @@ -124,6 +124,8 @@ public final class RefactoringUIMessages extends NLS { public static String PreviewWizardPage_changes_filtered2; + public static String PreviewWizardPage_description_z; + public static String PreviewWizardPage_description_s; public static String PreviewWizardPage_description_m; diff --git a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/RefactoringUIMessages.properties b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/RefactoringUIMessages.properties index 32ed890c708..2cddb283aa3 100644 --- a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/RefactoringUIMessages.properties +++ b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/RefactoringUIMessages.properties @@ -63,6 +63,7 @@ PreviewWizardPage_changes_filter_derived=derived resources hidden PreviewWizardPage_hideDerived_text=&Hide derived resources PreviewWizardPage_refactoring= Refactoring PreviewWizardPage_Internal_error=An unexpected exception while creating a preview. See the error log for more details. +PreviewWizardPage_description_z= No changes to perform. PreviewWizardPage_description_s= The following change to 1 file is necessary to perform the refactoring. PreviewWizardPage_description_m= The following changes to {0} files are necessary to perform the refactoring. PreviewWizardPage_changeElementLabelProvider_textFormat= {0} - {1}