Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Externalize Strings Dialog] StringIndexOutOfBoundsException #1803

Closed
wolfgang-ch opened this issue Nov 20, 2024 · 1 comment · Fixed by #1805
Closed

[Externalize Strings Dialog] StringIndexOutOfBoundsException #1803

wolfgang-ch opened this issue Nov 20, 2024 · 1 comment · Fixed by #1805
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@wolfgang-ch
Copy link

The original issue is from Aug 1, 2024 eclipse-platform/.github#219, it is now moved here because of eclipse-platform/.github#219 (comment)

Steps to reproduce

Open the "Externalize Strings..." dialog with this simple class

public class NLTest {

   public static final String SYMBOL_AMPERSAND = "&";  //$NON-NLS-1$
   public static final String SYMBOL_QUOTA     = "\""; //$NON-NLS-1$
}

I expected: The NLS dialog should open

But got: The NLS dialog did not opened

With this workaround the NLS dialog opens

public class NLTest {

   public static final String SYMBOL_AMPERSAND = "&";                                       //$NON-NLS-1$
   public static final String SYMBOL_QUOTA     = new StringBuilder().append('"').toString();
}

Here is some relevant log output

From the terminal

java.lang.StringIndexOutOfBoundsException: begin 3, end 0, length 3
        at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4606)
        at java.base/java.lang.String.substring(String.java:2709)
        at org.eclipse.jdt.internal.corext.refactoring.nls.NLSHint.stripQuotes(NLSHint.java:266)
        at org.eclipse.jdt.internal.corext.refactoring.nls.NLSHint.createSubstitutions(NLSHint.java:221)
        at org.eclipse.jdt.internal.corext.refactoring.nls.NLSHint.<init>(NLSHint.java:106)
        at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.<init>(NLSRefactoring.java:92)
        at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.create(NLSRefactoring.java:113)
        at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizard.lambda$0(ExternalizeWizard.java:84)
        at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
        at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizard.open(ExternalizeWizard.java:81)
        at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run(ExternalizeStringsAction.java:191)
        at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run(ExternalizeStringsAction.java:156)
        at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:278)
        at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:252)
        at org.eclipse.jface.action.Action.runWithEvent(Action.java:474)
        at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:581)
        at org.eclipse.jface.action.ActionContributionItem.lambda$4(ActionContributionItem.java:415)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:91)
        at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4326)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1174)
        at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4124)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3712)

Tested under this environment:

  • OS & version: Windows 10
  • Eclipse IDE/Platform version (as shown in Help > About): I20240731-1800
@jukzi jukzi added bug Something isn't working good first issue Good for newcomers labels Nov 20, 2024
@nettozahler
Copy link
Contributor

I can deliver a PR for this. One question first: do we have a utility class where I can add a method like this:
public static boolean isTextBlock(String str)

nettozahler added a commit to nettozahler/eclipse.jdt.ui that referenced this issue Nov 21, 2024
nettozahler added a commit to nettozahler/eclipse.jdt.ui that referenced this issue Nov 21, 2024
nettozahler added a commit to nettozahler/eclipse.jdt.ui that referenced this issue Nov 22, 2024
nettozahler added a commit to nettozahler/eclipse.jdt.ui that referenced this issue Dec 2, 2024
jukzi pushed a commit to nettozahler/eclipse.jdt.ui that referenced this issue Dec 4, 2024
jukzi pushed a commit to nettozahler/eclipse.jdt.ui that referenced this issue Dec 4, 2024
jukzi pushed a commit to nettozahler/eclipse.jdt.ui that referenced this issue Dec 4, 2024
jukzi pushed a commit to nettozahler/eclipse.jdt.ui that referenced this issue Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants