in remoting/server/web/web.ui/src/org/netbeans/modules/jackpot30/backend/ui/UI.java [346:402]
public String localUsages(@Context UriInfo uriInfo, @QueryParam("path") String segment, @QueryParam("relative") String relative, @QueryParam("signature") String signature, @QueryParam("position") final long position, @QueryParam("usages") boolean usages) throws URISyntaxException, IOException, InterruptedException {
List<long[]> result = new ArrayList<long[]>();
if (relative.endsWith(".java")) {
final CompilationInfo info = ResolveService.parse(segment, relative);
if (signature == null) {
ResolvedLocation location = resolveTarget(info, position, false);
signature = location.signature;
}
if (signature == null) {
return "[]";
}
for (long[] span : ResolveService.usages(info, signature)) {
result.add(new long[] {span[2], span[3]});
}
long[] declSpans = ResolveService.declarationSpans(info, signature);
if (declSpans != null) {
result.add(new long[] {declSpans[2], declSpans[3]});
}
} else {
//look for usages from resources:
String[] parts = signature.split(":");
if (parts.length >= 2 ) {
String otherSignature;
switch (parts[0]) {
case "FIELD": case "ENUM_CONSTANT":
case "METHOD":
if (parts.length >= 3) {
otherSignature = parts[1].replace(".", "[.-]") + "[.-]" + parts[2];
break;
}
default:
otherSignature = parts[1].replace(".", "[.-]");
break;
}
String urlBase = URL_BASE_OVERRIDE != null ? URL_BASE_OVERRIDE : uriInfo.getBaseUri().toString();
URI u = new URI(urlBase + "index/source/cat?path=" + escapeForQuery(segment) + "&relative=" + escapeForQuery(relative));
String content = WebUtilities.requestStringResponse(u).replace("\r\n", "\n");
java.util.regex.Matcher matcher = Pattern.compile(otherSignature).matcher(content);
while (matcher.find()) {
result.add(new long[] {matcher.start(), matcher.end()});
}
}
}
return Pojson.save(result);
}