mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup: extract method
This commit is contained in:
@@ -95,18 +95,22 @@ public abstract class PerFileMappingsBase<T> implements PersistentStateComponent
|
||||
}
|
||||
if (mappings == null) return null;
|
||||
synchronized (mappings) {
|
||||
for (VirtualFile cur = file; cur != null; cur = cur.getParent()) {
|
||||
T t = mappings.get(cur);
|
||||
if (t != null) return t;
|
||||
}
|
||||
for (VirtualFile cur = originalFile; cur != null; cur = cur.getParent()) {
|
||||
T t = mappings.get(cur);
|
||||
if (t != null) return t;
|
||||
}
|
||||
T t = getMappingForHierarchy(file, mappings);
|
||||
if (t != null) return t;
|
||||
t = getMappingForHierarchy(originalFile, mappings);
|
||||
if (t != null) return t;
|
||||
return mappings.get(null);
|
||||
}
|
||||
}
|
||||
|
||||
private static <T> T getMappingForHierarchy(@Nullable VirtualFile file, @NotNull Map<VirtualFile, T> mappings) {
|
||||
for (VirtualFile cur = file; cur != null; cur = cur.getParent()) {
|
||||
T t = mappings.get(cur);
|
||||
if (t != null) return t;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T chosenToStored(VirtualFile file, T value) {
|
||||
return value;
|
||||
|
||||
Reference in New Issue
Block a user