| 295 | } |
| 296 | |
| 297 | void CodeEditorPanel::gotoLocation(Processor* p, const String& fileName, int charNumber) |
| 298 | { |
| 299 | if (fileName.isEmpty() || fileName == "onInit") |
| 300 | { |
| 301 | changeContentWithUndo(0); |
| 302 | } |
| 303 | else if (fileName.contains("()")) |
| 304 | { |
| 305 | auto jp = dynamic_cast<JavascriptProcessor*>(p); |
| 306 | auto snippetId = Identifier(fileName.upToFirstOccurrenceOf("()", false, false)); |
| 307 | |
| 308 | for (int i = 0; i < jp->getNumSnippets(); i++) |
| 309 | { |
| 310 | if (jp->getSnippet(i)->getCallbackName() == snippetId) |
| 311 | { |
| 312 | changeContentWithUndo(i); |
| 313 | break; |
| 314 | } |
| 315 | } |
| 316 | } |
| 317 | else |
| 318 | { |
| 319 | auto jp = dynamic_cast<JavascriptProcessor*>(p); |
| 320 | |
| 321 | int fileIndex = -1; |
| 322 | |
| 323 | for (int i = 0; i < jp->getNumWatchedFiles(); i++) |
| 324 | { |
| 325 | auto f = jp->getWatchedFile(i); |
| 326 | |
| 327 | if (f.getFullPathName() == fileName || |
| 328 | f.getFileName() == fileName) |
| 329 | { |
| 330 | fileIndex = i; |
| 331 | break; |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | if (fileIndex != -1) |
| 336 | { |
| 337 | changeContentWithUndo(jp->getNumSnippets() + fileIndex); |
| 338 | } |
| 339 | else |
| 340 | return; |
| 341 | } |
| 342 | |
| 343 | if (auto c = getContent<PopupIncludeEditor>()) |
| 344 | { |
| 345 | PopupIncludeEditor::EditorType* editor = c->getEditor(); |
| 346 | |
| 347 | CodeDocument::Position pos(editor->editor.getDocument(), charNumber); |
| 348 | |
| 349 | editor->editor.scrollToLine(pos.getLineNumber(), true); |
| 350 | mcl::Selection newSelection(pos.getLineNumber(), pos.getIndexInLine(), pos.getLineNumber(), pos.getIndexInLine()); |
| 351 | editor->editor.getTextDocument().setSelection(0, newSelection, false); |
| 352 | } |
| 353 | } |
| 354 |
nothing calls this directly
no test coverage detected