Skip to content

Commit df0d784

Browse files
committed
refactoring
1 parent 610bf9e commit df0d784

1 file changed

Lines changed: 9 additions & 55 deletions

File tree

src/main/java/com/ss/editor/model/workspace/Workspace.java

Lines changed: 9 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ public void notifyRestored() {
116116
*
117117
* @return the current edited file.
118118
*/
119-
@Nullable
120-
public String getCurrentEditedFile() {
119+
public @Nullable String getCurrentEditedFile() {
121120
return currentEditedFile;
122121
}
123122

@@ -140,16 +139,14 @@ public synchronized void updateCurrentEditedFile(@Nullable final Path file) {
140139
/**
141140
* @return the table with states of editors.
142141
*/
143-
@NotNull
144-
private Map<String, EditorState> getEditorStateMap() {
142+
private @NotNull Map<String, EditorState> getEditorStateMap() {
145143
return notNull(editorStateMap);
146144
}
147145

148146
/**
149147
* @return the list of expanded folders.
150148
*/
151-
@NotNull
152-
private List<String> getExpandedFolders() {
149+
private @NotNull List<String> getExpandedFolders() {
153150
return notNull(expandedFolders);
154151
}
155152

@@ -158,8 +155,7 @@ private List<String> getExpandedFolders() {
158155
*
159156
* @return the list of expanded absolute folders.
160157
*/
161-
@NotNull
162-
public synchronized Array<Path> getExpandedAbsoluteFolders() {
158+
public synchronized @NotNull Array<Path> getExpandedAbsoluteFolders() {
163159

164160
final Array<Path> result = ArrayFactory.newArray(Path.class);
165161
final Path assetFolder = getAssetFolder();
@@ -194,9 +190,8 @@ public synchronized void updateExpandedFolders(@NotNull final Array<Path> folder
194190
* @param stateFactory the state factory.
195191
* @return the state of the editor.
196192
*/
197-
@NotNull
198-
public synchronized <T extends EditorState> T getEditorState(@NotNull final Path file,
199-
@NotNull final Supplier<EditorState> stateFactory) {
193+
public synchronized <T extends EditorState> @NotNull T getEditorState(@NotNull final Path file,
194+
@NotNull final Supplier<EditorState> stateFactory) {
200195

201196
final Path assetFile = getAssetFile(getAssetFolder(), file);
202197
final String assetPath = toAssetPath(assetFile);
@@ -213,23 +208,6 @@ public synchronized <T extends EditorState> T getEditorState(@NotNull final Path
213208
return unsafeCast(editorStateMap.get(assetPath));
214209
}
215210

216-
/**
217-
* Update an editor state of a file.
218-
*
219-
* @param file the file.
220-
* @param editorState the editor state.
221-
*/
222-
public synchronized void updateEditorState(@NotNull final Path file, @NotNull final EditorState editorState) {
223-
224-
final Path assetFile = getAssetFile(getAssetFolder(), file);
225-
final String assetPath = toAssetPath(assetFile);
226-
227-
final Map<String, EditorState> editorStateMap = getEditorStateMap();
228-
editorStateMap.put(assetPath, editorState);
229-
230-
incrementChanges();
231-
}
232-
233211
/**
234212
* Remove an editor state of a file.
235213
*
@@ -246,28 +224,6 @@ public synchronized void removeEditorState(@NotNull final Path file) {
246224
incrementChanges();
247225
}
248226

249-
/**
250-
* Update an editor state for moved/renamed file.
251-
*
252-
* @param prevFile the previous file.
253-
* @param newFile the new file.
254-
*/
255-
public synchronized void updateEditorState(@NotNull final Path prevFile, @NotNull final Path newFile) {
256-
257-
final Path prevAssetFile = getAssetFile(getAssetFolder(), prevFile);
258-
final String prevAssetPath = toAssetPath(prevAssetFile);
259-
260-
final Map<String, EditorState> editorStateMap = getEditorStateMap();
261-
final EditorState editorState = editorStateMap.remove(prevAssetPath);
262-
if (editorState == null) return;
263-
264-
final Path newAssetFile = getAssetFile(getAssetFolder(), newFile);
265-
final String newAssetPath = toAssetPath(newAssetFile);
266-
267-
editorStateMap.put(newAssetPath, editorState);
268-
incrementChanges();
269-
}
270-
271227
/**
272228
* Sets asset folder.
273229
*
@@ -282,8 +238,7 @@ public void setAssetFolder(@NotNull final Path assetFolder) {
282238
*
283239
* @return the table of opened files.
284240
*/
285-
@NotNull
286-
public Map<String, String> getOpenedFiles() {
241+
public @NotNull Map<String, String> getOpenedFiles() {
287242
return notNull(openedFiles);
288243
}
289244

@@ -328,8 +283,7 @@ public synchronized void removeOpenedFile(@NotNull final Path file) {
328283
*
329284
* @return the asset folder of this workspace.
330285
*/
331-
@NotNull
332-
public Path getAssetFolder() {
286+
public @NotNull Path getAssetFolder() {
333287
return notNull(assetFolder);
334288
}
335289

@@ -381,7 +335,7 @@ public void save(final boolean force) {
381335
}
382336

383337
} catch (final UnsupportedOperationException | IllegalArgumentException e) {
384-
// we can igone that
338+
// we can ignore that
385339
} catch (final IOException e) {
386340
LOGGER.warning(e);
387341
}

0 commit comments

Comments
 (0)