Check the current selection for reference. If no selection is active, expand the current selection. @return
(boolean selectIfFound)
| 2290 | * @return |
| 2291 | */ |
| 2292 | protected String referenceCheck(boolean selectIfFound) { |
| 2293 | int start = textarea.getSelectionStart(); |
| 2294 | int stop = textarea.getSelectionStop(); |
| 2295 | if (stop < start) { |
| 2296 | int temp = stop; |
| 2297 | stop = start; |
| 2298 | start = temp; |
| 2299 | } |
| 2300 | char[] c = textarea.getText().toCharArray(); |
| 2301 | |
| 2302 | // System.out.println("checking reference"); |
| 2303 | if (start == stop) { |
| 2304 | while (start > 0 && functionable(c[start - 1])) { |
| 2305 | start--; |
| 2306 | } |
| 2307 | while (stop < c.length && functionable(c[stop])) { |
| 2308 | stop++; |
| 2309 | } |
| 2310 | // System.out.println("start is stop"); |
| 2311 | } |
| 2312 | String text = new String(c, start, stop - start).trim(); |
| 2313 | // System.out.println(" reference piece is '" + text + "'"); |
| 2314 | if (checkParen(c, stop, c.length)) { |
| 2315 | text += "_"; |
| 2316 | } |
| 2317 | String ref = mode.lookupReference(text); |
| 2318 | if (selectIfFound) { |
| 2319 | textarea.select(start, stop); |
| 2320 | } |
| 2321 | return ref; |
| 2322 | } |
| 2323 | |
| 2324 | |
| 2325 | protected void handleFindReference() { |
no test coverage detected