MCPcopy Create free account
hub / github.com/christophhart/HISE / gotoLocation

Method gotoLocation

hi_scripting/scripting/components/ScriptingPanelTypes.cpp:297–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295}
296
297void 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

Callers

nothing calls this directly

Calls 15

getNumSnippetsMethod · 0.80
getNumWatchedFilesMethod · 0.80
getWatchedFileMethod · 0.80
getIndexInLineMethod · 0.80
isEmptyMethod · 0.45
containsMethod · 0.45
upToFirstOccurrenceOfMethod · 0.45
getCallbackNameMethod · 0.45
getSnippetMethod · 0.45
getFileNameMethod · 0.45
getEditorMethod · 0.45
getDocumentMethod · 0.45

Tested by

no test coverage detected