MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / find_function

Method find_function

modules/gdscript/gdscript_editor.cpp:232–255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232int GDScriptLanguage::find_function(const String &p_function, const String &p_code) const {
233 GDScriptTokenizerText tokenizer;
234 tokenizer.set_source_code(p_code);
235 int indent = 0;
236 GDScriptTokenizer::Token current = tokenizer.scan();
237 while (current.type != GDScriptTokenizer::Token::TK_EOF && current.type != GDScriptTokenizer::Token::ERROR) {
238 if (current.type == GDScriptTokenizer::Token::INDENT) {
239 indent++;
240 } else if (current.type == GDScriptTokenizer::Token::DEDENT) {
241 indent--;
242 }
243 if (indent == 0 && current.type == GDScriptTokenizer::Token::FUNC) {
244 current = tokenizer.scan();
245 if (current.is_identifier()) {
246 String identifier = current.get_identifier();
247 if (identifier == p_function) {
248 return current.start_line;
249 }
250 }
251 }
252 current = tokenizer.scan();
253 }
254 return -1;
255}
256
257Script *GDScriptLanguage::create_script() const {
258 return memnew(GDScript);

Callers 2

add_callbackMethod · 0.45

Calls 4

is_identifierMethod · 0.80
set_source_codeMethod · 0.45
scanMethod · 0.45
get_identifierMethod · 0.45

Tested by

no test coverage detected