Bug 438306 - Unexpected opening of a method declaration while selecting method with CTRL key down
Summary: Unexpected opening of a method declaration while selecting method with CTRL k...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.3.2   Edit
Hardware: All All
: P5 normal with 3 votes (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2014-06-26 13:33 EDT by Laurent Barbareau CLA
Modified: 2023-04-27 16:48 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Laurent Barbareau CLA 2014-06-26 13:33:52 EDT
Here is a little strange and annoying behavior that I wanna try to describe :

So just image you want to copy/paste a method that is called at any location in Java source code and then, at that time, while selecting the method call by clicking and sliding the cursor above it, you press the (left) CTRL key, to prepare yourself to complete that shortcut with the C or V key, according to what you want to make. Then sometimes, just before you press the C or V key, you are redirected automatically to the method declaration you were about to copy or paste.

This is very annoying when it occurs because if you were about to paste a method name to replace the one you've just selected, when you finally press the V key, you're not at all on the method call but on the method declaration and then your action modify the wrong element...

I can't figure out why this happens but this is not new, I encountered that strange behavior for quite some previous versions of Eclipse.

Do you see what I mean ? Someone else would already encountered this behavior ?



-- Configuration Details --
Product: Eclipse 2.0.2.20140224-0000 (org.eclipse.epp.package.jee.product)
Installed Features:
 org.eclipse.jdt 3.9.2.v20140221-1700
Comment 1 Dani Megert CLA 2014-06-30 11:02:37 EDT
Ctrl+Click goes to the declaration. If you hit Ctrl and then move over the method and click on it while it is underlined, it will go to the method. This is expected and won't change.

You have three choices:
- be more precise i.e. only click when to the left of the method
- don't hit Ctrl before actually starting to copy
- assign another modifier for the hyperlink feature ('Hyperlinking' pref page)
Comment 2 Laurent Barbareau CLA 2014-06-30 12:59:34 EDT
This not so easy to explain but don't suppose that it's a newbie assertion, thank you.

Keep in mind that it does not occur every time. And forget the click on the method name, this is of course a normal behavior but it does not correspond to what I tried to explain.

I think (I can't reproduce it on demand) it may occur for instance when I click at the beginning of a line, left CTRL down, left click down and sliding to the right to copy a block of code and when the mouse is above a method, a class or a variable call, I'm redirected to their definition.

There's something maybe with the underlying or background tasks and the synchronization and concurrent accesses. I have no precise idea because I don't know enough about the UI mechanisms. This is of course related to the CTRL + left click but not at a expected time. 

As you propose, I can of course try not to press the CTRL key before finishing my selection but most of the time this is not a problem. When you need to go fast, it's difficult to loose an habit that was not a problem until a certain version of Eclipse... This is quite recent, but I can't say which one (maybe since E3.7).

I'm not expecting it can be fixed rapidly, I guess it's something touchy...

But as I'm sure that editors will embed always more and more functionalities, consuming always more resources, maybe this is a kind of precursor sign of other issues.

Any idea of what could provoke that behavior ?
Comment 3 Dani Megert CLA 2014-06-30 15:09:24 EDT
> Any idea of what could provoke that behavior ?

It can easily be reproduced if one hits Ctrl and then starts to select via left-click.

As said we won't work on this.
Comment 4 Laurent Barbareau CLA 2014-06-30 15:45:38 EDT
Can you reproduce it systematically ? Personally I can't...
On Windows too ?

If you are sure to do exactly what I describe, do see any particular factors that provoke that behavior ? Lots of opened projects, any other factor...

Thx
Comment 5 Dani Megert CLA 2014-06-30 16:04:58 EDT
(In reply to Laurent Barbareau from comment #4)
> Can you reproduce it systematically ? Personally I can't...
> On Windows too ?

Yes, it's as simple as outlined in my previous comment when applied on a method call.
Comment 6 Laurent Barbareau CLA 2014-07-22 04:31:49 EDT
(In reply to Dani Megert from comment #5)
Ok, why not, this is not my case but I believe you.

By the way, I realize that it's not related to any left click in my problem. I thought it was because that's often what I'm about to do (selecting something to copy it) when I'm untimely redirected.
In fact, I just have to push CTRL key and moving the mouse above a class name to be redirected, from time to time, to the matching class declaration, without clicking !

Ok ? Do you find it's a normal behavior ?
Comment 7 Laurent Barbareau CLA 2014-07-31 05:24:25 EDT
New element : maybe it's related to an underlying error or warning at the moment that it is reported (or maybe not) into the Error Log.

For instance, I've just got the issue while I was selecting some code and I've got the Error Log view that opened with the trace :

Warning
Thu Jul 31 11:09:43 CEST 2014
Could not create java element for handle: =xxxxxxxxnoyau/C:\/Program Files \(x86)\/Java\/jdk1.5.0_22\/jre\/lib\/rt.jar<java.sql(ResultSet.class[ResultSet~getString~Ljava.lang.String;

java.lang.ArrayIndexOutOfBoundsException
	at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:536)
	at java.lang.StringBuffer.append(StringBuffer.java:322)
	at org.eclipse.jdt.internal.core.util.MementoTokenizer.nextToken(MementoTokenizer.java:112)
	at org.eclipse.jdt.internal.core.JavaProject.getHandleFromMemento(JavaProject.java:1595)
	at org.eclipse.jdt.internal.core.JavaElement.getHandleFromMemento(JavaElement.java:279)
	at org.eclipse.jdt.internal.core.JavaModel.getHandleFromMemento(JavaModel.java:167)
	at org.eclipse.jdt.internal.core.JavaElement.getHandleFromMemento(JavaElement.java:279)
	at org.eclipse.jdt.core.JavaCore.create(JavaCore.java:3006)
	at org.eclipse.jdt.core.JavaCore.create(JavaCore.java:2981)
	at org.eclipse.ajdt.core.AspectJCore.create(AspectJCore.java:134)
	at org.eclipse.ajdt.core.AspectJCore.create(AspectJCore.java:60)
	at org.eclipse.ajdt.mylyn.ui.AspectJStructureBridge.getObjectForHandle(Unknown Source)
	at org.eclipse.mylyn.internal.java.ui.JavaStructureBridge.canBeLandmark(JavaStructureBridge.java:192)
	at org.eclipse.mylyn.internal.context.core.InteractionContextManager.checkForLandmarkDeltaAndNotify(InteractionContextManager.java:281)
	at org.eclipse.mylyn.internal.context.core.InteractionContextManager.internalProcessInteractionEvent(InteractionContextManager.java:764)
	at org.eclipse.mylyn.internal.context.core.InteractionContextManager.internalProcessInteractionEvent(InteractionContextManager.java:723)
	at org.eclipse.mylyn.internal.context.core.InteractionContextManager.processInteractionEvent(InteractionContextManager.java:1200)
	at org.eclipse.mylyn.internal.context.core.InteractionContextManager.processInteractionEvent(InteractionContextManager.java:1193)
	at org.eclipse.mylyn.internal.context.core.InteractionContextManager.processInteractionEvent(InteractionContextManager.java:1189)
	at org.eclipse.mylyn.monitor.ui.AbstractUserInteractionMonitor.handleElementEdit(AbstractUserInteractionMonitor.java:133)
	at org.eclipse.mylyn.monitor.ui.AbstractUserInteractionMonitor.handleElementEdit(AbstractUserInteractionMonitor.java:91)
	at org.eclipse.mylyn.internal.java.ui.JavaEditingMonitor.handleWorkbenchPartSelection(JavaEditingMonitor.java:130)
	at org.eclipse.mylyn.monitor.ui.AbstractUserInteractionMonitor.selectionChanged(AbstractUserInteractionMonitor.java:72)
	at org.eclipse.ui.internal.e4.compatibility.SelectionService.notifyPostSelectionListeners(SelectionService.java:173)
	at org.eclipse.ui.internal.e4.compatibility.SelectionService.updateSelection(SelectionService.java:120)
	at org.eclipse.ui.internal.WorkbenchPage$E4PartListener.partActivated(WorkbenchPage.java:191)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl$2.run(PartServiceImpl.java:192)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.firePartActivated(PartServiceImpl.java:190)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:609)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:553)
	at org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer.activate(AbstractPartRenderer.java:104)
	at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer$9.handleEvent(StackRenderer.java:920)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1081)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066)
	at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1453)
	at org.eclipse.swt.widgets.Shell.WM_MOUSEACTIVATE(Shell.java:2334)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4655)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1627)
	at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2075)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2544)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4706)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2544)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4706)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2544)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4706)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2544)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4706)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2544)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4706)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2544)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4706)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2544)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4706)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2544)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4706)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
	at org.eclipse.swt.internal.win32.OS.PeekMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.PeekMessage(OS.java:3141)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:140)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
	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:354)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
	
I don't think it's always MyLyn that toggles the issue because my utilization of it is very recent.
Comment 8 Dani Megert CLA 2014-07-31 05:39:30 EDT
(In reply to Laurent Barbareau from comment #7)
> New element : maybe it's related to an underlying error or warning at the
> moment that it is reported (or maybe not) into the Error Log.
> 
> For instance, I've just got the issue while I was selecting some code and
> I've got the Error Log view that opened with the trace :

Please report that exception against Mylyn.
Comment 9 Laurent Barbareau CLA 2014-07-31 06:01:46 EDT
> Please report that exception against Mylyn.
I'll do it if I find any specific conditions to reproduce it (and also time).
Please don't focus on Mylyn. thx
Comment 10 Laurent Barbareau CLA 2015-03-05 07:25:31 EST
I found at least one person who is facing the same problem.

I also figured out that it is not proper to the JDT editor, I think it can occur with other ones (e.g. JSP editor).

What can provoke the opening of a element declaration without applying a full shortcut (CTRL + left click) ? I repeat, only CTRL key pressed and mouse hovering an element can sometimes provoke that behavior.
Comment 11 Laurent Barbareau CLA 2015-10-27 10:01:06 EDT
Really irritating this bug when it occurs !
Comment 12 Laurent Barbareau CLA 2019-05-14 10:59:11 EDT
Still no idea to address this bug?

What can interfere like this...
Comment 13 Eclipse Genie CLA 2021-05-04 16:56:12 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 14 Laurent Barbareau CLA 2021-05-04 18:26:43 EDT
It still occurs from time to time until at least version 2020-06 (4.16.0)
Comment 15 Joël DRIGO CLA 2021-05-04 18:49:06 EDT
It still occurs in Version 2021-03 (4.19.0) build 20210312-0638.
Comment 16 Eclipse Genie CLA 2023-04-27 16:48:30 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.