| Summary: | [nls tooling] Eclipse style NLS: Property key hyperlinks do not work for properties files coming from a JAR | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Deepak Azad <deepakazad> | ||||||||||||
| Component: | Text | Assignee: | Dani Megert <daniel_megert> | ||||||||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||||||||
| Severity: | normal | ||||||||||||||
| Priority: | P3 | CC: | daniel_megert, markus.kell.r, nicolas.bros, raksha.vasisht | ||||||||||||
| Version: | 3.7 | Flags: | raksha.vasisht:
review-
raksha.vasisht: review- |
||||||||||||
| Target Milestone: | 4.3 M2 | ||||||||||||||
| Hardware: | All | ||||||||||||||
| OS: | All | ||||||||||||||
| Whiteboard: | |||||||||||||||
| Attachments: |
|
||||||||||||||
|
Description
Deepak Azad
Created attachment 185629 [details] fix v0.9 - The patch enables hyperlinks for properties files coming from a JAR if Eclipse style NLS is used (Java search is used) - If non Eclipse style NLS is used, the Text search returns 0 matches from the JAR. (see Bug 23341) - If Eclipse style NLS is used - i.e. Java search case - and more than one match is found the selection dialog shows Java element names instead of file names. Created attachment 185631 [details]
selection dialog with Java elements screenshot
Created attachment 189458 [details] fix v1.0 The patch enables hyperlinks for properties files coming from a JAR If Eclipse style NLS is used - Java search is used to find matches. - If more than one match is found the selection dialog shows Java element names instead of file names. If non Eclipse style NLS is used - Text search is used which returns 0 matches from the JAR. (see Bug 23341) - In the non-jar case, if more than one match is found the selection dialog continues to show file names. Dani, ok to go ahead with these UI changes ? Raksha, please make the initial review. Ping. The patch does not seem to work, it gives a Class Cast Exception failing with this error : "Cannot open default editor" Reason : "Error searching references to the selected properties key" Steps : --------- 1) check out o.e.jdt.ui project in a fresh workspace 2) open some properties file from a jar (I tried /org/eclipse/ui/internal/navigator/messages.properties, /org/eclipse/ui/texteditor/TextEditorMessages.properties, /org/eclipse/core/filebuffers/manipulation/FileBuffersMessages.properties) 3) Ctrl+click on any key -> gives CCE 4) Also try /org/eclipse/ui/texteditor/ConstructedTextEditorMessages.properties, ctrl+click here does nothing but shows "Found No references..." message in the staus line . Shouldn't this show the corresponding declaration? Stack trace for CCE: --------------------- java.lang.ClassCastException: org.eclipse.core.internal.resources.Project at org.eclipse.jdt.internal.ui.propertiesfileeditor.PropertyKeyHyperlink$4$1.acceptSearchMatch(PropertyKeyHyperlink.java:447) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.report(MatchLocator.java:1812) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportAccurateFieldReference(MatchLocator.java:2080) at org.eclipse.jdt.internal.core.search.matching.FieldLocator.matchReportReference(FieldLocator.java:236) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2175) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2694) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2421) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.process(MatchLocator.java:1673) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1083) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1124) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1256) at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:94) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches(BasicSearchEngine.java:231) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.search(BasicSearchEngine.java:515) at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:584) at org.eclipse.jdt.internal.ui.propertiesfileeditor.PropertyKeyHyperlink$4.run(PropertyKeyHyperlink.java:444) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121) Stack Trace for Core Ex ------------------------- org.eclipse.core.runtime.CoreException: Error searching references to the selected properties key at org.eclipse.jdt.internal.ui.propertiesfileeditor.PropertyKeyHyperlink.search(PropertyKeyHyperlink.java:487) at org.eclipse.jdt.internal.ui.propertiesfileeditor.PropertyKeyHyperlink.open(PropertyKeyHyperlink.java:260) at org.eclipse.jface.text.hyperlink.HyperlinkManager.mouseUp(HyperlinkManager.java:429) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:219) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4126) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3715) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494) at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:592) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) at org.eclipse.equinox.launcher.Main.run(Main.java:1410) at org.eclipse.equinox.launcher.Main.main(Main.java:1386) Caused by: java.lang.ClassCastException: org.eclipse.core.internal.resources.Project at org.eclipse.jdt.internal.ui.propertiesfileeditor.PropertyKeyHyperlink$4$1.acceptSearchMatch(PropertyKeyHyperlink.java:447) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.report(MatchLocator.java:1812) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportAccurateFieldReference(MatchLocator.java:2080) at org.eclipse.jdt.internal.core.search.matching.FieldLocator.matchReportReference(FieldLocator.java:236) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2219) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2694) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2421) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.process(MatchLocator.java:1673) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1083) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1124) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1256) at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:94) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches(BasicSearchEngine.java:231) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.search(BasicSearchEngine.java:515) at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:584) at org.eclipse.jdt.internal.ui.propertiesfileeditor.PropertyKeyHyperlink$4.run(PropertyKeyHyperlink.java:444) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121) Created attachment 190113 [details]
fix v1.1
Both exceptions are the same.
Fixed in this patch.
(In reply to comment #7) > Created attachment 190113 [details] [diff] > fix v1.1 > > Both exceptions are the same. > > Fixed in this patch. >4) Also try >/org/eclipse/ui/texteditor/ConstructedTextEditorMessages.properties, ctrl+click >here does nothing but shows "Found No references..." message in the staus line >. Shouldn't this show the corresponding declaration? How about this? The patch still does not work for plugin.properties and plugin.xml: 1) ctrl+click on a name in plugin.xml (from a JAR)does not show the hyperlink at all 2) ctrl+click on a key plugin.properties (from a JAR) shows hyperlink but does not do anything except show an error in the status line. (In reply to comment #8) > How about this? > > The patch still does not work for plugin.properties and plugin.xml: > > 1) ctrl+click on a name in plugin.xml (from a JAR)does not show the hyperlink > at all > 2) ctrl+click on a key plugin.properties (from a JAR) shows hyperlink but does > not do anything except show an error in the status line. Yes, that is expected as mentioned in comment 3 (relevant part quoted below) (In reply to comment #3) > - Text search is used which returns 0 matches from the JAR. (see Bug 23341) (In reply to comment #9) > Yes, that is expected as mentioned in comment 3 (relevant part quoted below) Oh sorry, I missed that. The patch almost works now except I did stumble upon cases where I found a NPE and BadLoc Exception: //Main.java public class Main { private static String HI; //Try 2 public static void main(String[] args) { System.out.println(Messages.getString("HI")); // Try 1 System.out.println(HI); //Try 2 } } //Messages.properties HI= hi //Messages.java import java.util.MissingResourceException; import java.util.ResourceBundle; public class Messages { private static final String BUNDLE_NAME = "messages"; //$NON-NLS-1$ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle .getBundle(BUNDLE_NAME); private Messages() { } public static String getString(String key) { try { return RESOURCE_BUNDLE.getString(key); } catch (MissingResourceException e) { return '!' + key + '!'; } } } 1) Test case 1 : --------------- a)comment out everything except 'Try 1' b) ctrl+click on 'HI' in properties file ==> gives a NPE and BLE 2) Test case 2: --------------- a)comment out everything but 'Try 2' b) ctrl+click on 'HI' in properties file (if it does not work paste the try 2 code in a new project with the properties file) ==> gives the same BLE and also a dialog with references inside JARs after doing a text search, showing the file as the Java Project. (see screen shot) java.lang.NullPointerException at org.eclipse.jdt.internal.ui.propertiesfileeditor.PropertyKeyHyperlink$1.decorateText(PropertyKeyHyperlink.java:308) at org.eclipse.ui.model.WorkbenchLabelProvider.getText(WorkbenchLabelProvider.java:254) at org.eclipse.ui.dialogs.FilteredList.setElements(FilteredList.java:278) at org.eclipse.ui.dialogs.AbstractElementListSelectionDialog.setListElements(AbstractElementListSelectionDialog.java:178) at org.eclipse.ui.dialogs.TwoPaneElementSelector.createDialogArea(TwoPaneElementSelector.java:141) at org.eclipse.jface.dialogs.Dialog.createContents(Dialog.java:760) at org.eclipse.jface.window.Window.create(Window.java:431) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089) at org.eclipse.ui.dialogs.SelectionStatusDialog.create(SelectionStatusDialog.java:153) at org.eclipse.ui.dialogs.AbstractElementListSelectionDialog.access$superCreate(AbstractElementListSelectionDialog.java:427) at org.eclipse.ui.dialogs.AbstractElementListSelectionDialog.access$2(AbstractElementListSelectionDialog.java:426) at org.eclipse.ui.dialogs.AbstractElementListSelectionDialog$4.run(AbstractElementListSelectionDialog.java:438) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) at org.eclipse.ui.dialogs.AbstractElementListSelectionDialog.create(AbstractElementListSelectionDialog.java:436) at org.eclipse.jface.window.Window.open(Window.java:790) at org.eclipse.ui.dialogs.AbstractElementListSelectionDialog.open(AbstractElementListSelectionDialog.java:422) at org.eclipse.jdt.internal.ui.propertiesfileeditor.PropertyKeyHyperlink.select(PropertyKeyHyperlink.java:342) at org.eclipse.jdt.internal.ui.propertiesfileeditor.PropertyKeyHyperlink.open(PropertyKeyHyperlink.java:280) at org.eclipse.jdt.internal.ui.propertiesfileeditor.PropertyKeyHyperlink.open(PropertyKeyHyperlink.java:270) at org.eclipse.jface.text.hyperlink.HyperlinkManager.mouseUp(HyperlinkManager.java:429) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:219) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4126) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3715) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494) at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:592) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) at org.eclipse.equinox.launcher.Main.run(Main.java:1410) at org.eclipse.equinox.launcher.Main.main(Main.java:1386) ---------------------------------------------------------------------------- org.eclipse.jface.text.BadLocationException at org.eclipse.jface.text.ListLineTracker.getLineNumberOfOffset(ListLineTracker.java:140) at org.eclipse.jface.text.AbstractLineTracker.getLineNumberOfOffset(AbstractLineTracker.java:161) at org.eclipse.jface.text.AbstractDocument.getLineOfOffset(AbstractDocument.java:915) at org.eclipse.core.internal.filebuffers.SynchronizableDocument.getLineOfOffset(SynchronizableDocument.java:394) at org.eclipse.jdt.internal.ui.propertiesfileeditor.PropertyKeyHyperlink$KeyReference.getLabel(PropertyKeyHyperlink.java:156) at org.eclipse.ui.model.WorkbenchLabelProvider.getText(WorkbenchLabelProvider.java:251) at org.eclipse.ui.dialogs.FilteredList.setElements(FilteredList.java:278) at org.eclipse.ui.dialogs.AbstractElementListSelectionDialog.setListElements(AbstractElementListSelectionDialog.java:178) at org.eclipse.ui.dialogs.TwoPaneElementSelector.createDialogArea(TwoPaneElementSelector.java:141) at org.eclipse.jface.dialogs.Dialog.createContents(Dialog.java:760) at org.eclipse.jface.window.Window.create(Window.java:431) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089) at org.eclipse.ui.dialogs.SelectionStatusDialog.create(SelectionStatusDialog.java:153) at org.eclipse.ui.dialogs.AbstractElementListSelectionDialog.access$superCreate(AbstractElementListSelectionDialog.java:427) at org.eclipse.ui.dialogs.AbstractElementListSelectionDialog.access$2(AbstractElementListSelectionDialog.java:426) at org.eclipse.ui.dialogs.AbstractElementListSelectionDialog$4.run(AbstractElementListSelectionDialog.java:438) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) at org.eclipse.ui.dialogs.AbstractElementListSelectionDialog.create(AbstractElementListSelectionDialog.java:436) at org.eclipse.jface.window.Window.open(Window.java:790) at org.eclipse.ui.dialogs.AbstractElementListSelectionDialog.open(AbstractElementListSelectionDialog.java:422) at org.eclipse.jdt.internal.ui.propertiesfileeditor.PropertyKeyHyperlink.select(PropertyKeyHyperlink.java:342) at org.eclipse.jdt.internal.ui.propertiesfileeditor.PropertyKeyHyperlink.open(PropertyKeyHyperlink.java:280) at org.eclipse.jdt.internal.ui.propertiesfileeditor.PropertyKeyHyperlink.open(PropertyKeyHyperlink.java:270) at org.eclipse.jface.text.hyperlink.HyperlinkManager.mouseUp(HyperlinkManager.java:429) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:219) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4126) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3715) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494) at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:592) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) at org.eclipse.equinox.launcher.Main.run(Main.java:1410) at org.eclipse.equinox.launcher.Main.main(Main.java:1386) Created attachment 190246 [details]
Screen shot of the open selection dialog with JARS
*** Bug 355039 has been marked as a duplicate of this bug. *** I could not reproduce the IAEs and BLEs. The example is also a corner case which exhibits another problem. See bug 388112 for details. The patch works for me except that I did not like that the hyperlink and the 'Open' action are enabled in the non-Eclipse NLS case. I've changed that in the commit. Fixed with http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=a5222bd063f338b1f942f7e141362e71e08f845d Filed bug 388114 for the traditional case which requires to search the text in the JARs. Dani, thanks for looking at this! |