Skip to content

Commit

Permalink
Factorize ExpressionVariableParentFinder and ExpressionVariableTypeFi…
Browse files Browse the repository at this point in the history
…nder.
  • Loading branch information
D8H committed May 2, 2024
1 parent 02314a2 commit 6a61431
Show file tree
Hide file tree
Showing 13 changed files with 527 additions and 632 deletions.
3 changes: 3 additions & 0 deletions Core/GDCore/IDE/Events/EventsVariableReplacer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ bool EventsVariableReplacer::DoVisitInstruction(gd::Instruction& instruction,
}

if (gd::ParameterMetadata::IsExpression("variable", type)) {
// TODO Find the variable path
// If there is an empty element (a bracket) don't change the type.
// When there is a bracket the drop down menu is shown.
const auto& newParameterValue = instruction.GetParameter(parameterIndex);
const auto &variableName = newParameterValue.GetPlainString();
auto itr = variableNewTypes.find(variableName);
Expand Down
11 changes: 4 additions & 7 deletions Core/GDCore/IDE/Events/ExpressionCompletionFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
* Copyright 2008-present Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#ifndef GDCORE_EXPRESSIONAUTOCOMPLETIONPROVIDER_H
#define GDCORE_EXPRESSIONAUTOCOMPLETIONPROVIDER_H
#pragma once

#include <memory>
#include <vector>
Expand All @@ -20,7 +19,7 @@
#include "GDCore/IDE/Events/ExpressionNodeLocationFinder.h"
#include "GDCore/IDE/Events/ExpressionTypeFinder.h"
#include "GDCore/IDE/Events/ExpressionVariableOwnerFinder.h"
#include "GDCore/IDE/Events/ExpressionVariableParentFinder.h"
#include "GDCore/IDE/Events/ExpressionVariablePathFinder.h"
#include "GDCore/Project/ProjectScopedContainers.h"
#include "GDCore/Project/Variable.h"

Expand Down Expand Up @@ -525,7 +524,7 @@ class GD_CORE_API ExpressionCompletionFinder
}
void OnVisitVariableAccessorNode(VariableAccessorNode& node) override {
VariableAndItsParent variableAndItsParent =
gd::ExpressionVariableParentFinder::GetLastParentOfNode(
gd::ExpressionVariablePathFinder::GetLastParentOfNode(
platform, projectScopedContainers, node);

// If no child, we're at the end of a variable (like `GrandChild` in
Expand Down Expand Up @@ -666,7 +665,7 @@ class GD_CORE_API ExpressionCompletionFinder
[&]() {
// This is a variable.
VariableAndItsParent variableAndItsParent =
gd::ExpressionVariableParentFinder::GetLastParentOfNode(
gd::ExpressionVariablePathFinder::GetLastParentOfNode(
platform, projectScopedContainers, node);

AddCompletionsForChildrenVariablesOf(
Expand Down Expand Up @@ -1113,5 +1112,3 @@ class GD_CORE_API ExpressionCompletionFinder
};

} // namespace gd

#endif // GDCORE_EXPRESSIONAUTOCOMPLETIONPROVIDER_H

0 comments on commit 6a61431

Please sign in to comment.