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

Method jumpToDefinition

hi_scripting/scripting/ScriptProcessor.cpp:1119–1211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1117
1118
1119void JavascriptProcessor::jumpToDefinition(const String& token, const String& namespaceId)
1120{
1121#if USE_BACKEND
1122 if (token.isNotEmpty())
1123 {
1124 if(token.startsWithChar('"'))
1125 {
1126 auto scriptRoot = dynamic_cast<Processor*>(this)->getMainController()->getCurrentFileHandler().getSubDirectory(FileHandlerBase::Scripts);
1127
1128 auto sf = scriptRoot.getChildFile(token.substring(1)).withFileExtension("js");
1129
1130 if (sf.existsAsFile())
1131 {
1132 DebugableObject::Location l;
1133 l.fileName = sf.getFullPathName();
1134 l.charNumber = 0;
1135
1136 DebugableObject::Helpers::gotoLocation(nullptr, this, l);
1137 return;
1138 }
1139 }
1140 if (auto l = getScriptEngine()->preprocessor->getLocationForPreprocessor(token))
1141 {
1142 DebugableObject::Helpers::gotoLocation(nullptr, this, l);
1143 return;
1144 }
1145
1146 auto trimmedToken = token.fromLastOccurrenceOf("[", false, false);
1147
1148 trimmedToken = trimmedToken.removeCharacters("!");
1149
1150 const String c = namespaceId.isEmpty() ? trimmedToken : namespaceId + "." + trimmedToken;
1151
1152 auto infos = DebugableObject::Helpers::getDebugInformationFromString(getScriptEngine(), c);
1153
1154 if(infos.size() == 1)
1155 {
1156 if(DebugableObject::Helpers::gotoLocation(dynamic_cast<Processor*>(this), infos[0].get()))
1157 return;
1158 }
1159 else if (!infos.isEmpty())
1160 {
1161 PopupMenu m;
1162
1163 m.addSectionHeader("Choose Goto target");
1164
1165 int index = 1;
1166
1167 for(auto i: infos)
1168 m.addItem(index++, i->getTextForName(), true, false);
1169
1170 if(auto r = m.show())
1171 {
1172 if(DebugableObject::Helpers::gotoLocation(dynamic_cast<Processor*>(this), infos[r-1].get()))
1173 return;
1174 }
1175 else
1176 return;

Callers 1

jumpToFromShortcutMethod · 0.45

Calls 15

startsWithCharMethod · 0.80
getCurrentFileHandlerMethod · 0.80
removeCharactersMethod · 0.80
addSectionHeaderMethod · 0.80
getScriptEngineMethod · 0.80
isNotEmptyMethod · 0.45
getSubDirectoryMethod · 0.45
getMainControllerMethod · 0.45
withFileExtensionMethod · 0.45
getChildFileMethod · 0.45
substringMethod · 0.45

Tested by

no test coverage detected