Bug 44613 - [misc] some actions go to disk everytime they are selected
Summary: [misc] some actions go to disk everytime they are selected
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: 3.0.1   Edit
Assignee: Dani Megert CLA
QA Contact:
URL:
Whiteboard:
Keywords: investigate
: 76945 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-10-09 17:16 EDT by Tod Creasey CLA
Modified: 2004-10-25 13:28 EDT (History)
1 user (show)

See Also:


Attachments
diff for TextFileDocumentProvider.diff (647 bytes, patch)
2004-05-04 04:53 EDT, alexander korobov CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tod Creasey CLA 2003-10-09 17:16:42 EDT
20031009

When ever you invoke an accelerator in the java editor the disk is accessed.

STEPS
1) Create a project with a java file on your floppy
2) Open the file
3) Select format (Ctrl+SHift+F)
4) You will hear a disk access
Comment 1 Chris McLaren CLA 2003-10-27 14:52:24 EST
i'm guessing this is an issue with the JDT actions themselves. 

tod, can you confirm that this happens *only* using the keyboard to invoke 
these actions and not by choosing the actions off of the menu?
Comment 2 Tod Creasey CLA 2003-11-19 14:30:47 EST
Just popping up the menu without selecting anything does this. However the 
disk access only seems to happen when the file is dirty
Comment 3 Douglas Pollock CLA 2003-12-02 15:08:40 EST
-------------------------------------------------------------------------------
| Task                                  | Goes to Disk?                       |
----------------------------------------|--------------------------------------
| Selecting the file in the navigator   | NO                                  |
| Opening the file from the navigator   | YES                                 |
| Changing focus to the java editor     | YES                                 |
| Right-clicking within the editor      | NO                                  |
| Right-clicking within the navigator   | NO                                  |
| Navigating the menus                  | NO                                  |
| Formatting the source (key or menu)   | YES                                 |
-------------------------------------------------------------------------------

From this, I'm thinking it's either a problem with the text editor or with the
source editor.  I'll punt it to text....
Comment 4 Dani Megert CLA 2004-01-06 09:41:41 EST
Tod, can you be a bit more specifc. Reading the table in comment 3 the following
two actions have to read the disk:
- Opening the file from the navigator 
  obvious
- Changing focus to the java editor
  file must be reconciled since it might have changed

So, is it correct that only the formatting actions seems to incorrectly access
the disk?

Which menu (main or context)?
Comment 5 Tod Creasey CLA 2004-01-06 10:00:39 EST
Creating a project and then a class on the floppy  went to disk with the 
following actions

1) Hitting return in a text editor
2) Formatting using Ctrl+Shift+F
3) Popping up the context menu
Comment 6 Dani Megert CLA 2004-01-06 10:04:29 EST
1) only the first time, right? (needs to check file state, e.g. read-only)

2) and 3) need to be investigated
Comment 7 Tom Hofmann CLA 2004-01-06 10:15:20 EST
could preferences lookup play a role here?
Comment 8 Tod Creasey CLA 2004-01-06 10:23:58 EST
Only the first time or after saving yes.
Comment 9 Dani Megert CLA 2004-01-06 10:28:05 EST
could well be: format action reads the formatting profile
Comment 10 alexander korobov CLA 2004-04-02 12:01:53 EST
Also using code assistance (i.e. pressing ctrl-space) triggers editor to start
doing at least 1 i/o on edited file during :
1. text selection. per each char/line selected at least 1 i/o access to edited file
2. text editing(next-word, previous-word, etc)
3. other editing commands(incremental find, etc...)

this makes editing text on smb mounted partitions quite painful.

On windows this i/o can easily be tracked on windows by using
filemon(sysinternals.com).
Comment 11 Dani Megert CLA 2004-04-06 07:27:43 EDT
needs to be investigated for final 3.0
Comment 12 alexander korobov CLA 2004-04-30 01:27:36 EDT
I just tried to figure out what's going on and it seems for every modification 
event in text editor eclipse checks whether file is modifiable. For a single 
character selection TextEditor calls canModifyEditor() several times(probably 
different events)
Here's related stack trace :
Thread [main] (Suspended (breakpoint at line 179 in java.io.File))
	java.io.File.<init>(java.lang.String) line: 179
	org.eclipse.core.runtime.Path.toFile() line: 762
	org.eclipse.core.filebuffers.FileBuffers.getSystemFileAtLocation
(org.eclipse.core.runtime.IPath) line: 103
	org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider
(org.eclipse.ui.editors.text.TextFileDocumentProvider).getSystemFile
(org.eclipse.ui.editors.text.TextFileDocumentProvider$FileInfo) line: 983
	org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider
(org.eclipse.ui.editors.text.TextFileDocumentProvider).isSystemFileReadOnly
(org.eclipse.ui.editors.text.TextFileDocumentProvider$FileInfo) line: 987
	org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider
(org.eclipse.ui.editors.text.TextFileDocumentProvider).isModifiable
(java.lang.Object) line: 807
	org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor
(org.eclipse.ui.texteditor.AbstractTextEditor).isEditorInputModifiable() line: 
4538
	org.eclipse.ui.texteditor.TextOperationAction
(org.eclipse.ui.texteditor.TextEditorAction).canModifyEditor() line: 109
	org.eclipse.ui.texteditor.TextOperationAction.update() line: 136


Not sure what would be the proper fix for this but i'd check buffer last 
modification time and writablility once when user switches to buffer and keep 
that information cached.
Comment 13 alexander korobov CLA 2004-05-04 04:53:54 EDT
Created attachment 10246 [details]
diff  for TextFileDocumentProvider.diff

Not sure this is correct fix but it seems working well(still testing).
Instead of calling isSystemFileReadOnly it returns FileInfo
fCachedReadOnlyState that i suppose initialized in createFileInfo.
Comment 14 Dani Megert CLA 2004-05-04 07:53:47 EDT
Note: the read-only state can change, either via Eclipse or outside.
Comment 15 alexander korobov CLA 2004-05-12 01:00:49 EDT
Sorry for late response. Glad you asked about refreshing. 
In case when buffers are not automatically generated code but rather normal 
files opened by user eclipse nicely detect read-only/writable when user 
switches between buffers(ie this is refreshed when editor gets focus). If file 
permissions are changed when user edits the file and tries to save it eclipse 
shows nice warning saying file is read-only and marks it as r/o.  So i do not 
see any regression in this case. As for editors containing dynamically 
generated code(do not know if this possible but assume it is) this property 
should be handled by applications/plugins.
Comment 16 Kai-Uwe Maetzel CLA 2004-06-25 11:00:12 EDT
Removing target milestone, no further action for 3.0.
Comment 17 Erich Gamma CLA 2004-09-07 09:23:41 EDT
As discussed with Kai this one can be considered a regression. The regression 
is really painfull when the file comes from a remote file system.

Fix this problem should also be released into 3.0.1
Comment 18 Dani Megert CLA 2004-09-07 12:12:49 EDT
Alexander's analysis is correct. I did not use his patch.
We now call isReadOnly(element) instead of isSystemFileReadOnly(info).
Comment 19 Dani Megert CLA 2004-09-07 12:55:33 EDT
Fixed in R3_0_maintenance branch.
Released into I200409080800.
Comment 20 Dani Megert CLA 2004-09-08 11:53:37 EDT
We forgot to release the change into the map file. Will be in next M-build.
Comment 21 Dani Megert CLA 2004-09-08 16:21:42 EDT
Verified in M-M20040908-200409081421
Comment 22 Christof Marti CLA 2004-10-25 13:28:13 EDT
*** Bug 76945 has been marked as a duplicate of this bug. ***