Skip to content
Merged
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
13 changes: 13 additions & 0 deletions Core/GDCore/Extensions/PlatformExtension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,19 @@ gd::String PlatformExtension::GetObjectNameFromFullObjectType(
return type.substr(separatorIndex + 2);
}

gd::String PlatformExtension::GetInstructionNameFromFullType(
const gd::String& type) {
const auto separatorPosition =
type.rfind(PlatformExtension::GetNamespaceSeparator());
if (separatorPosition == gd::String::npos) {
return type;
}
if (separatorPosition + 2 >= type.size()) {
return type;
}
return type.substr(separatorPosition + 2);
}

PlatformExtension::PlatformExtension()
: deprecated(false), category("General") {}

Expand Down
9 changes: 9 additions & 0 deletions Core/GDCore/Extensions/PlatformExtension.h
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,15 @@ static gd::String GetVariantFullType(const gd::String& extensionName,

static gd::String GetObjectNameFromFullObjectType(const gd::String& type);

/**
* \brief Get the instruction name from a full type
* (e.g. "MyExtension::DoSomething" -> "DoSomething").
*
* If no namespace separator is found or the name after the separator is
* empty, the full type is returned as-is.
*/
static gd::String GetInstructionNameFromFullType(const gd::String& type);

private:
/**
* Set the namespace (the string all actions/conditions/expressions start
Expand Down
8 changes: 3 additions & 5 deletions Core/GDCore/IDE/Events/EventsRefactorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "GDCore/Extensions/Metadata/ExpressionMetadata.h"
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
#include "GDCore/Extensions/Platform.h"
#include "GDCore/Extensions/PlatformExtension.h"
#include "GDCore/IDE/Events/ExpressionValidator.h"
#include "GDCore/IDE/Events/InstructionSentenceFormatter.h"
#include "GDCore/Project/ObjectsContainer.h"
Expand Down Expand Up @@ -945,12 +946,9 @@ bool EventsRefactorer::SearchStringInFormattedText(const gd::Platform& platform,
if (foundPosition != gd::String::npos) return true;

if (inInstructionNames) {
const gd::String& instructionType = instruction.GetType();
size_t lastSeparator = instructionType.find_last_of("::");
gd::String instructionName =
lastSeparator != gd::String::npos
? instructionType.substr(lastSeparator + 1)
: instructionType;
PlatformExtension::GetInstructionNameFromFullType(
instruction.GetType());
size_t nameFoundPosition =
matchCase ? instructionName.find(search)
: instructionName.FindCaseInsensitive(search);
Expand Down
Loading