String currentPath = getCurrentPath(); P f = getPath(prefix); if (exists(f)) { if (isDirectory(f)) { if (prefix.endsWith(sep)) { Collection<P> children = getChilren(f); if (children != null) { if (children.size() > 0) { return listDir(f, ""); } else { return Completion.create(); Collection<P> children = getChilren(f); if (children == null) { return Completion.create(); } else if (isFile(f)) { return Completion.create("", true); String filter; if (pos == 0) { f = getPath(sep); filter = prefix.substring(1); } else { f = getPath(prefix.substring(0, pos)); filter = prefix.substring(pos + 1);
private Completion listDir(P dir, final String filter) throws Exception { Collection<P> children = getChilren(dir); if (children != null) { Completion.Builder builder = Completion.builder(filter); for (P child : children) { String name = getName(child); if (name.startsWith(filter)) { String suffix = name.substring(filter.length()); if (isDirectory(child)) { Collection<P> grandChildren = getChilren(child); if (grandChildren != null) { builder.add(suffix + File.separator, false); } else { // Skip it } } else { builder.add(suffix, true); } } } return builder.build(); } else { return Completion.create(); } } }
return pc.complete(parameter, prefix);
return pc.complete(parameter, prefix);
String currentPath = getCurrentPath(); P f = getPath(prefix); if (exists(f)) { if (isDirectory(f)) { if (prefix.endsWith(sep)) { Collection<P> children = getChilren(f); if (children != null) { if (children.size() > 0) { return listDir(f, ""); } else { return Completion.create(); Collection<P> children = getChilren(f); if (children == null) { return Completion.create(); } else if (isFile(f)) { return Completion.create("", true); String filter; if (pos == 0) { f = getPath(sep); filter = prefix.substring(1); } else { f = getPath(prefix.substring(0, pos)); filter = prefix.substring(pos + 1);
private Completion listDir(P dir, final String filter) throws Exception { Collection<P> children = getChilren(dir); if (children != null) { Completion.Builder builder = Completion.builder(filter); for (P child : children) { String name = getName(child); if (name.startsWith(filter)) { String suffix = name.substring(filter.length()); if (isDirectory(child)) { Collection<P> grandChildren = getChilren(child); if (grandChildren != null) { builder.add(suffix + File.separator, false); } else { // Skip it } } else { builder.add(suffix, true); } } } return builder.build(); } else { return Completion.create(); } } }
return pc.complete(parameter, prefix);
String currentPath = getCurrentPath(); P f = getPath(prefix); if (exists(f)) { if (isDirectory(f)) { if (prefix.endsWith(sep)) { Collection<P> children = getChilren(f); if (children != null) { if (children.size() > 0) { return listDir(f, ""); } else { return Completion.create(); Collection<P> children = getChilren(f); if (children == null) { return Completion.create(); } else if (isFile(f)) { return Completion.create("", true); String filter; if (pos == 0) { f = getPath(sep); filter = prefix.substring(1); } else { f = getPath(prefix.substring(0, pos)); filter = prefix.substring(pos + 1);
private Completion listDir(P dir, final String filter) throws Exception { Collection<P> children = getChilren(dir); if (children != null) { Completion.Builder builder = Completion.builder(filter); for (P child : children) { String name = getName(child); if (name.startsWith(filter)) { String suffix = name.substring(filter.length()); if (isDirectory(child)) { Collection<P> grandChildren = getChilren(child); if (grandChildren != null) { builder.add(suffix + File.separator, false); } else { // Skip it } } else { builder.add(suffix, true); } } } return builder.build(); } else { return Completion.create(); } } }