eclipse-platform / eclipse-platform/eclipse.platform

Moving a file inside of an operation: moved File's Charset is only available after the operation

Offen
#575 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Java
Sterne
165
Forks
174
Ø Merge
2 T. 8 Std.
Gemergte PRs (30 T.)
22

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne damit, das IWorkspace#run-Verschiebungsszenario nachzustellen, und untersuche den bestehenden Test auf das Charset-Verhalten während einer Workspace-Operation. Verfolge die Verschiebung durch Workspace#endOperation, CharsetManager.java und NotificationManager.java. Als erledigt gilt die Aufgabe, wenn das Projekt ein Verhalten ausgewählt und implementiert hat und der Test aktualisiert wurde, um diese Entscheidung zu überprüfen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
tooling
Issue-Typ
Bug
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.