@NotNull @SuppressWarnings("Duplicates") private Collection<String> checkWatchable( String reportedPath, boolean isExact, boolean fastPath) { if (reportedPath == null) return Collections.emptyList(); List<String> flatWatchRoots = myFlatWatchRoots; List<String> recursiveWatchRoots = myRecursiveWatchRoots; if (flatWatchRoots.isEmpty() && recursiveWatchRoots.isEmpty()) return Collections.emptyList(); List<Pair<String, String>> mapping = myMapping; Collection<String> affectedPaths = new SmartList<String>(reportedPath); for (Pair<String, String> map : mapping) { if (FileUtil.startsWith(reportedPath, map.first)) { affectedPaths.add(map.second + reportedPath.substring(map.first.length())); } else if (FileUtil.startsWith(reportedPath, map.second)) { affectedPaths.add(map.first + reportedPath.substring(map.second.length())); } } Collection<String> changedPaths = new SmartList<String>(); ext: for (String path : affectedPaths) { if (fastPath && !changedPaths.isEmpty()) break; for (String root : flatWatchRoots) { if (FileUtil.namesEqual(path, root)) { changedPaths.add(path); continue ext; } if (isExact) { String parentPath = new File(path).getParent(); if (parentPath != null && FileUtil.namesEqual(parentPath, root)) { changedPaths.add(path); continue ext; } } } for (String root : recursiveWatchRoots) { if (FileUtil.startsWith(path, root)) { changedPaths.add(path); continue ext; } if (!isExact) { String parentPath = new File(root).getParent(); if (parentPath != null && FileUtil.namesEqual(path, parentPath)) { changedPaths.add(root); continue ext; } } } } return changedPaths; }