in remoting/server/web/web.ui/src/org/netbeans/modules/jackpot30/backend/ui/UI.java [98:159]
public String searchSymbol(@Context UriInfo uriInfo, @QueryParam("path") List<String> paths, @QueryParam("prefix") String prefix) throws URISyntaxException, IOException {
String urlBase = URL_BASE_OVERRIDE != null ? URL_BASE_OVERRIDE : uriInfo.getBaseUri().toString();
Map<String, Map<?, ?>> segment2Result = new HashMap<String, Map<?, ?>>();
if (paths == null) {
Map<String,Map<String, String>> pathsList = list(urlBase);
paths = new ArrayList<String>(pathsList.keySet());
}
for (String path : paths) {
URI u = new URI(urlBase + "index/symbol/search?path=" + escapeForQuery(path) + "&prefix=" + escapeForQuery(prefix));
@SuppressWarnings("unchecked") //XXX: should not trust something got from the network!
Map<String, List<Map<String, Object>>> symbols = Pojson.load(LinkedHashMap.class, u);
URI typeSearch = new URI(urlBase + "index/type/search?path=" + escapeForQuery(path) + "&prefix=" + escapeForQuery(prefix));
@SuppressWarnings("unchecked") //XXX: should not trust something got from the network!
Map<String, List<String>> types = Pojson.load(LinkedHashMap.class, typeSearch);
for (Entry<String, List<String>> e : types.entrySet()) {
List<Map<String, Object>> thisSourceRootResults = new ArrayList<Map<String, Object>>(e.getValue().size());
for (String fqn : e.getValue()) {
Map<String, Object> result = new HashMap<String, Object>();
result.put("kind", "CLASS");
result.put("fqn", fqn);
String simpleName = fqn;
String enclosingFQN = "";
if (simpleName.lastIndexOf('.') > 0) {
simpleName = simpleName.substring(simpleName.lastIndexOf('.') + 1);
enclosingFQN = fqn.substring(0, fqn.lastIndexOf('.'));
}
if (simpleName.lastIndexOf('$') > 0) {
simpleName = simpleName.substring(simpleName.lastIndexOf('$') + 1);
enclosingFQN = fqn.substring(0, fqn.lastIndexOf('$'));
}
result.put("simpleName", simpleName);
result.put("enclosingFQN", enclosingFQN);
if (fqn.contains("$")) {
fqn = fqn.substring(0, fqn.indexOf("$"));
}
result.put("file", e.getKey() + fqn.replace('.', '/') + ".java");
thisSourceRootResults.add(result);
}
List<Map<String, Object>> putInto = symbols.get(e.getKey());
if (putInto == null) symbols.put(e.getKey(), thisSourceRootResults);
else putInto.addAll(thisSourceRootResults);
}
segment2Result.put(path, Collections.singletonMap("found", symbols));
}
return Pojson.save(segment2Result);
}