eclipse-platform / eclipse-platform/eclipse.platform
Moving a file inside of an operation: moved File's Charset is only available after the operation
- Lingua principale
- Java
- Stelle
- 165
- Fork
- 174
- Merge medio
- 2g 8h
- PR unite (30g)
- 22
Descrizione
When scheduling a job using IWorkspace#run that moves a file, I instantly want to be able to manipulate the file inside of the job.
This is not currently possible due to charset information only being updated after the Job was ran.
### Under the Hood
Move uses the Java-Internal File-rename operation, which internally calls a FS-move.
As part of [Workspace#endOperation](https://github.com/eclipse-platform/eclipse.platform/blob/14226717ec1d696df7a07e02ea67e3751a53bc48/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java#L1552), all listeners are notified of the file move-event.
The workspace-own [CharsetManager](https://github.com/eclipse-platform/eclipse.platform/blob/master/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/CharsetManager.java) implements it's own [ResourceChangeListener](https://github.com/eclipse-platform/eclipse.platform/blob/14226717ec1d696df7a07e02ea67e3751a53bc48/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/CharsetManager.java#L148) which is [notified](https://github.com/eclipse-platform/eclipse.platform/blob/14226717ec1d696df7a07e02ea67e3751a53bc48/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/NotificationManager.java#L300) by the [NotificationManager](https://github.com/eclipse-platform/eclipse.platform/blob/master/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/NotificationManager.java#L300)
### Proceeding
There are two conflicting behaviors/expectations:
1. Updates of charset settings due to the movement of a resource are processed through the CharsetManager after the workspace operation has been completed. Any changes on the resource within the operation will not see its proper charset.
2. Changes to the resource within the operation expect the proper charset to be available for the resource.
Currently, the implementation accepts that 2. is not fulfilled. To achieve 2. the charset of a resource has to be updated just-in-time after a movement/copy during a workspace operation. This would, however, require a change of 1. since charsets cannot be updated asynchronously after a workspace operation completed.
There are two options to proceed:
1. Ensure that charset settings are updated just-in-time. This may require larger changes and have unpredictable side effects.
2. Accept the current behavior and remove the test or change it to expect the "faulty" charset during the workspace operation so that it documents the acceptance of the current behavior.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia riproducendo lo scenario di spostamento di IWorkspace#run ed esamina il test esistente relativo al comportamento di charset durante un'operazione di workspace. Segui lo spostamento attraverso Workspace#endOperation, CharsetManager.java e NotificationManager.java. Il lavoro è completo quando il progetto ha scelto e implementato un comportamento e il test è stato aggiornato per verificare tale decisione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- java
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 30/100