cleanup: extract method

This commit is contained in:
Konstantin Ulitin
2015-07-29 19:50:02 +03:00
parent ad57909a77
commit de1a88d517
@@ -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;