Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion editor/editor_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "editor/gui/editor_file_dialog.h"
#include "editor/editor_file_dialog.h"

class DocTools;
class EditorFileDialog;
Expand Down
24 changes: 12 additions & 12 deletions javascript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,19 +269,19 @@ Ref<Resource> ResourceFormatLoaderJavaScript::load(const String &p_path, const S
if (r_error)
*r_error = err;
ERR_FAIL_COND_V_MSG(err != OK, Ref<Resource>(), "Cannot load script file '" + p_path + "'.");
Ref<JavaScript> script;
script.instantiate();
script->set_script_path(p_path);
script->bytecode = module->get_bytecode();
script->set_source_code(module->get_source_code());
err = script->reload();
Ref<JavaScript> s;
s.instantiate();
s->set_script_path(p_path);
s->bytecode = module->get_bytecode();
s->set_source_code(module->get_source_code());
err = s->reload();
if (r_error)
*r_error = err;
ERR_FAIL_COND_V_MSG(err != OK, Ref<Resource>(), "Parse source code from file '" + p_path + "' failed.");
#ifdef TOOLS_ENABLED
JavaScriptLanguage::get_singleton()->get_scripts().insert(script);
JavaScriptLanguage::get_singleton()->get_scripts().insert(s);
#endif
return script;
return s;
}

void ResourceFormatLoaderJavaScript::get_recognized_extensions(List<String> *p_extensions) const {
Expand All @@ -308,10 +308,10 @@ bool ResourceFormatLoaderJavaScript::recognize_path(const String &p_path, const
}

Error ResourceFormatSaverJavaScript::save(const Ref<Resource> &p_resource, const String &p_path, uint32_t p_flags) {
Ref<JavaScript> script = p_resource;
ERR_FAIL_COND_V(script.is_null(), ERR_INVALID_PARAMETER);
Ref<JavaScript> resource = p_resource;
ERR_FAIL_COND_V(resource.is_null(), ERR_INVALID_PARAMETER);

String source = script->get_source_code();
String source = resource->get_source_code();

Error err;
Ref<FileAccess> file = FileAccess::open(p_path, FileAccess::WRITE, &err);
Expand All @@ -322,7 +322,7 @@ Error ResourceFormatSaverJavaScript::save(const Ref<Resource> &p_resource, const
}

if (ScriptServer::is_reload_scripts_on_save_enabled()) {
script->reload();
resource->reload();
}

return OK;
Expand Down
8 changes: 4 additions & 4 deletions javascript_language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,11 @@ void JavaScriptLanguage::get_string_delimiters(List<String> *p_delimiters) const
}

Ref<Script> JavaScriptLanguage::make_template(const String &p_template, const String &p_class_name, const String &p_base_class_name) const {
Ref<JavaScript> script;
script.instantiate();
Ref<JavaScript> s;
s.instantiate();
String src = p_template.replace("%BASE%", p_base_class_name).replace("%CLASS%", p_class_name);
script->set_source_code(src);
return script;
s->set_source_code(src);
return s;
}

Vector<ScriptLanguage::ScriptTemplate> JavaScriptLanguage::get_built_in_templates(StringName p_object) {
Expand Down
3 changes: 1 addition & 2 deletions register_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,12 @@ class EditorExportJavaScript : public EditorExportPlugin {
public:
virtual void _export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features) override {
String script_key;
const Ref<EditorExportPreset> &preset = get_export_preset();
String extension = p_path.get_extension();
if (extension != EXT_JSCLASS && extension != EXT_JSMODULE) {
return;
}
}
virtual String get_name() const override { return "JavaScript"; }
virtual String _get_name() const override { return "JavaScript"; }
};

#endif
Expand Down