6 #ifndef GDCORE_EXPRESSIONAUTOCOMPLETIONPROVIDER_H
7 #define GDCORE_EXPRESSIONAUTOCOMPLETIONPROVIDER_H
12 #include "GDCore/Events/Parsers/ExpressionParser2.h"
13 #include "GDCore/Events/Parsers/ExpressionParser2Node.h"
14 #include "GDCore/Events/Parsers/ExpressionParser2NodePrinter.h"
15 #include "GDCore/Events/Parsers/ExpressionParser2NodeWorker.h"
16 #include "GDCore/Events/Parsers/GrammarTerminals.h"
17 #include "GDCore/Extensions/Metadata/ExpressionMetadata.h"
18 #include "GDCore/Extensions/Metadata/InstructionMetadata.h"
19 #include "GDCore/Extensions/Metadata/ValueTypeMetadata.h"
20 #include "GDCore/IDE/Events/ExpressionNodeLocationFinder.h"
21 #include "GDCore/IDE/Events/ExpressionTypeFinder.h"
22 #include "GDCore/IDE/Events/ExpressionVariableOwnerFinder.h"
23 #include "GDCore/IDE/Events/ExpressionVariableParentFinder.h"
24 #include "GDCore/Project/ProjectScopedContainers.h"
25 #include "GDCore/Project/Variable.h"
29 class ObjectsContainer;
31 class ParameterMetadata;
32 class ExpressionMetadata;
33 class ObjectConfiguration;
65 size_t replacementStartPosition_,
66 size_t replacementEndPosition_,
69 BehaviorWithPrefix, replacementStartPosition_, replacementEndPosition_);
70 description.SetPrefix(prefix_);
71 description.SetObjectName(objectName_);
82 size_t replacementStartPosition_,
83 size_t replacementEndPosition_,
84 const bool isLastParameter_,
87 TextWithPrefix, replacementStartPosition_, replacementEndPosition_);
88 description.SetObjectName(objectName_);
89 description.SetType(type_);
90 description.SetPrefix(prefix_);
91 description.SetIsLastParameter(isLastParameter_);
92 description.SetParameterMetadata(parameterMetadata_);
103 size_t replacementStartPosition_,
104 size_t replacementEndPosition_,
108 replacementStartPosition_,
109 replacementEndPosition_);
110 description.SetObjectName(objectName_);
111 description.SetBehaviorName(behaviorName_);
112 description.SetType(type_);
113 description.SetPrefix(prefix_);
119 return completionKind == other.completionKind && type == other.type &&
120 variableType == other.variableType && prefix == other.prefix &&
121 objectName == other.objectName && completion == other.completion &&
122 behaviorName == other.behaviorName;
145 gd::Variable::Type variableType_) {
146 variableType = variableType_;
167 completion = completion_;
179 objectName = objectName_;
194 behaviorName = behaviorName_;
219 return replacementStartPosition;
231 isLastParameter = isLastParameter_;
246 parameterMetadata = ¶meterMetadata_;
254 return parameterMetadata != &badParameterMetadata;
262 return *parameterMetadata;
271 objectConfiguration = objectConfiguration_;
272 if (!objectConfiguration) objectConfiguration = &badObjectConfiguration;
280 return objectConfiguration != &badObjectConfiguration;
288 return *objectConfiguration;
293 (GetType() ||
"no type") +
", " +
295 (GetPrefix() ||
"no prefix") +
", " +
296 (GetCompletion() ||
"no completion") +
", " +
297 (GetObjectName() ||
"no object name") +
", " +
298 (GetBehaviorName() ||
"no behavior name") +
", " +
299 (IsExact() ?
"exact" :
"non-exact") +
", " +
300 (IsLastParameter() ?
"last parameter" :
"not last parameter") +
302 (HasParameterMetadata() ?
"with parameter metadata"
303 :
"no parameter metadata") +
305 (HasObjectConfiguration() ?
"with object configuration"
306 :
"no object configuration") +
314 size_t replacementStartPosition_,
315 size_t replacementEndPosition_)
316 : completionKind(completionKind_),
318 replacementStartPosition(replacementStartPosition_),
319 replacementEndPosition(replacementEndPosition_),
321 isLastParameter(false),
322 parameterMetadata(&badParameterMetadata),
323 objectConfiguration(&badObjectConfiguration) {}
326 CompletionKind completionKind;
327 gd::Variable::Type variableType;
331 size_t replacementStartPosition;
332 size_t replacementEndPosition;
336 bool isLastParameter;
348 std::ostream& os, ExpressionCompletionDescription
const& value);
362 static std::vector<ExpressionCompletionDescription>
368 size_t searchedPosition) {
373 if (nodeAtLocation ==
nullptr) {
374 std::vector<ExpressionCompletionDescription> emptyCompletions;
375 return emptyCompletions;
381 projectScopedContainers,
384 maybeParentNodeAtLocation);
385 nodeAtLocation->Visit(autocompletionProvider);
392 const std::vector<ExpressionCompletionDescription>&
400 void OnVisitSubExpressionNode(SubExpressionNode& node)
override {
401 auto type = gd::ExpressionTypeFinder::GetType(
402 platform, projectScopedContainers, rootType, node);
404 AddCompletionsForAllIdentifiersMatchingSearch(
"", type);
405 completions.push_back(
407 type,
"", searchedPosition + 1, searchedPosition + 1));
409 void OnVisitOperatorNode(OperatorNode& node)
override {
412 void OnVisitUnaryOperatorNode(UnaryOperatorNode& node)
override {
414 platform, projectScopedContainers, rootType, node);
416 AddCompletionsForAllIdentifiersMatchingSearch(
"", type);
417 completions.push_back(
419 type,
"", searchedPosition + 1, searchedPosition + 1));
421 void OnVisitNumberNode(NumberNode& node)
override {
425 void OnVisitTextNode(TextNode& node)
override {
428 FunctionCallNode* functionCall =
429 dynamic_cast<FunctionCallNode*
>(maybeParentNodeAtLocation);
430 if (functionCall !=
nullptr) {
431 int parameterIndex = -1;
432 for (
int i = 0; i < functionCall->parameters.size(); i++) {
433 if (functionCall->parameters.at(i).get() == &node) {
438 if (parameterIndex < 0) {
442 size_t visibleParameterIndex = 0;
443 size_t metadataParameterIndex =
445 functionCall->objectName, functionCall->behaviorName);
446 const auto& objectsContainersList =
447 projectScopedContainers.GetObjectsContainersList();
449 MetadataProvider::GetFunctionCallMetadata(
450 platform, objectsContainersList, *functionCall);
453 while (metadataParameterIndex < metadata.parameters.size()) {
454 if (!metadata.parameters[metadataParameterIndex].IsCodeOnly()) {
455 if (visibleParameterIndex == parameterIndex) {
456 parameterMetadata = &metadata.parameters[metadataParameterIndex];
458 visibleParameterIndex++;
460 metadataParameterIndex++;
462 const int visibleParameterCount = visibleParameterIndex;
463 if (parameterMetadata ==
nullptr) {
470 if (type ==
"string") {
475 bool isLastParameter = parameterIndex == visibleParameterCount - 1;
480 node.location.GetStartPosition(),
481 node.location.GetEndPosition(),
483 functionCall->objectName));
486 void OnVisitVariableNode(VariableNode& node)
override {
487 const auto& objectsContainersList =
488 projectScopedContainers.GetObjectsContainersList();
490 platform, projectScopedContainers, rootType, node);
494 bool eagerlyCompleteIfExactMatch = node.child ==
nullptr;
497 if (type ==
"globalvar" || type ==
"scenevar") {
498 const auto* variablesContainer =
500 ? projectScopedContainers.GetVariablesContainersList()
501 .GetTopMostVariablesContainer()
502 : projectScopedContainers.GetVariablesContainersList()
503 .GetBottomMostVariablesContainer();
504 if (variablesContainer) {
505 AddCompletionsForVariablesMatchingSearch(*variablesContainer,
508 eagerlyCompleteIfExactMatch);
510 }
else if (type ==
"objectvar") {
512 platform, objectsContainersList, rootObjectName, node);
514 AddCompletionsForObjectOrGroupVariablesMatchingSearch(
515 objectsContainersList,
519 eagerlyCompleteIfExactMatch);
522 AddCompletionsForObjectsAndVariablesMatchingSearch(
523 node.name, type, node.nameLocation, eagerlyCompleteIfExactMatch);
526 void OnVisitVariableAccessorNode(VariableAccessorNode& node)
override {
527 VariableAndItsParent variableAndItsParent =
528 gd::ExpressionVariableParentFinder::GetLastParentOfNode(
529 platform, projectScopedContainers, node);
535 node.child ==
nullptr ? node.name :
"";
536 AddCompletionsForChildrenVariablesOf(variableAndItsParent,
538 eagerlyCompleteForVariableName);
540 void OnVisitVariableBracketAccessorNode(
541 VariableBracketAccessorNode& node)
override {}
542 void OnVisitIdentifierNode(IdentifierNode& node)
override {
543 const auto& objectsContainersList =
544 projectScopedContainers.GetObjectsContainersList();
546 platform, projectScopedContainers, rootType, node);
549 AddCompletionsForObjectMatchingSearch(
550 node.identifierName, type, node.location);
552 if (type ==
"globalvar" || type ==
"scenevar") {
553 const auto* variablesContainer =
555 ? projectScopedContainers.GetVariablesContainersList()
556 .GetTopMostVariablesContainer()
557 : projectScopedContainers.GetVariablesContainersList()
558 .GetBottomMostVariablesContainer();
559 if (variablesContainer) {
560 if (IsCaretOn(node.identifierNameDotLocation) ||
561 IsCaretOn(node.childIdentifierNameLocation)) {
563 if (variablesContainer->Has(node.identifierName)) {
564 AddCompletionsForChildrenVariablesOf(
565 &variablesContainer->Get(node.identifierName),
566 node.childIdentifierNameLocation,
567 node.childIdentifierName);
574 bool eagerlyCompleteIfPossible =
575 !node.identifierNameDotLocation.IsValid();
576 AddCompletionsForVariablesMatchingSearch(
579 node.identifierNameLocation,
580 eagerlyCompleteIfPossible);
583 }
else if (type ==
"objectvar") {
585 platform, objectsContainersList, rootObjectName, node);
587 if (IsCaretOn(node.identifierNameDotLocation) ||
588 IsCaretOn(node.childIdentifierNameLocation)) {
590 const auto* variablesContainer =
591 objectsContainersList.GetObjectOrGroupVariablesContainer(
593 if (variablesContainer &&
594 variablesContainer->Has(node.identifierName)) {
595 AddCompletionsForChildrenVariablesOf(
596 &variablesContainer->Get(node.identifierName),
597 node.childIdentifierNameLocation,
598 node.childIdentifierName);
605 bool eagerlyCompleteIfPossible =
606 !node.identifierNameDotLocation.IsValid();
607 AddCompletionsForObjectOrGroupVariablesMatchingSearch(
608 objectsContainersList,
611 node.identifierNameLocation,
612 eagerlyCompleteIfPossible);
617 if (IsCaretOn(node.identifierNameLocation)) {
620 bool eagerlyCompleteIfPossible =
621 !node.identifierNameDotLocation.IsValid();
622 AddCompletionsForAllIdentifiersMatchingSearch(
625 node.identifierNameLocation,
626 eagerlyCompleteIfPossible);
627 if (!node.identifierNameDotLocation.IsValid()) {
628 completions.push_back(
632 node.identifierNameLocation.GetStartPosition(),
633 node.identifierNameLocation.GetEndPosition()));
635 }
else if (IsCaretOn(node.identifierNameDotLocation) ||
636 IsCaretOn(node.childIdentifierNameLocation)) {
640 projectScopedContainers.MatchIdentifierWithName<
void>(
644 const gd::String& objectName = node.identifierName;
645 AddCompletionsForObjectOrGroupVariablesMatchingSearch(
646 objectsContainersList,
648 node.childIdentifierName,
649 node.childIdentifierNameLocation,
652 completions.push_back(
654 node.childIdentifierName,
655 node.childIdentifierNameLocation.GetStartPosition(),
656 node.childIdentifierNameLocation.GetEndPosition(),
658 completions.push_back(
661 node.childIdentifierName,
662 node.childIdentifierNameLocation.GetStartPosition(),
663 node.childIdentifierNameLocation.GetEndPosition(),
668 VariableAndItsParent variableAndItsParent =
669 gd::ExpressionVariableParentFinder::GetLastParentOfNode(
670 platform, projectScopedContainers, node);
672 AddCompletionsForChildrenVariablesOf(
673 variableAndItsParent,
674 node.childIdentifierNameLocation,
675 node.childIdentifierName);
691 void OnVisitObjectFunctionNameNode(ObjectFunctionNameNode& node)
override {
693 platform, projectScopedContainers, rootType, node);
694 if (!node.behaviorFunctionName.empty() ||
695 node.behaviorNameNamespaceSeparatorLocation.IsValid()) {
698 if (IsCaretOn(node.objectNameLocation)) {
699 AddCompletionsForObjectMatchingSearch(
700 node.objectName, type, node.objectNameLocation);
701 }
else if (IsCaretOn(node.objectNameDotLocation) ||
702 IsCaretOn(node.objectFunctionOrBehaviorNameLocation)) {
703 completions.push_back(
705 node.objectFunctionOrBehaviorName,
706 node.objectFunctionOrBehaviorNameLocation.GetStartPosition(),
707 node.objectFunctionOrBehaviorNameLocation.GetEndPosition(),
709 }
else if (IsCaretOn(node.behaviorNameNamespaceSeparatorLocation) ||
710 IsCaretOn(node.behaviorFunctionNameLocation)) {
711 completions.push_back(
714 node.behaviorFunctionName,
715 node.behaviorFunctionNameLocation.GetStartPosition(),
716 node.behaviorFunctionNameLocation.GetEndPosition(),
718 node.objectFunctionOrBehaviorName));
722 if (IsCaretOn(node.objectNameLocation)) {
723 AddCompletionsForObjectMatchingSearch(
724 node.objectName, type, node.objectNameLocation);
725 }
else if (IsCaretOn(node.objectNameDotLocation) ||
726 IsCaretOn(node.objectFunctionOrBehaviorNameLocation)) {
727 completions.push_back(
729 node.objectFunctionOrBehaviorName,
730 node.objectFunctionOrBehaviorNameLocation.GetStartPosition(),
731 node.objectFunctionOrBehaviorNameLocation.GetEndPosition(),
733 completions.push_back(
736 node.objectFunctionOrBehaviorName,
737 node.objectFunctionOrBehaviorNameLocation.GetStartPosition(),
738 node.objectFunctionOrBehaviorNameLocation.GetEndPosition(),
743 void OnVisitFunctionCallNode(FunctionCallNode& node)
override {
745 platform, projectScopedContainers, rootType, node);
746 bool isCaretOnParenthesis = IsCaretOn(node.openingParenthesisLocation) ||
747 IsCaretOn(node.closingParenthesisLocation);
749 if (!node.behaviorName.empty()) {
751 if (IsCaretOn(node.objectNameLocation)) {
752 AddCompletionsForObjectMatchingSearch(
753 node.objectName, type, node.objectNameLocation);
754 }
else if (IsCaretOn(node.objectNameDotLocation) ||
755 IsCaretOn(node.behaviorNameLocation)) {
756 completions.push_back(
759 node.behaviorNameLocation.GetStartPosition(),
760 node.behaviorNameLocation.GetEndPosition(),
763 completions.push_back(
767 node.functionNameLocation.GetStartPosition(),
768 node.functionNameLocation.GetEndPosition(),
773 }
else if (!node.objectName.empty()) {
775 if (IsCaretOn(node.objectNameLocation)) {
776 AddCompletionsForObjectMatchingSearch(
777 node.objectName, type, node.objectNameLocation);
784 if (!isCaretOnParenthesis) {
785 completions.push_back(
788 node.objectNameLocation.GetStartPosition(),
789 node.objectNameLocation.GetEndPosition(),
793 completions.push_back(
797 node.functionNameLocation.GetStartPosition(),
798 node.functionNameLocation.GetEndPosition(),
804 completions.push_back(
808 node.functionNameLocation.GetStartPosition(),
809 node.functionNameLocation.GetEndPosition())
813 void OnVisitEmptyNode(EmptyNode& node)
override {
815 platform, projectScopedContainers, rootType, node);
817 AddCompletionsForAllIdentifiersMatchingSearch(
818 node.text, type, node.location);
819 completions.push_back(
823 node.location.GetStartPosition(),
824 node.location.GetEndPosition()));
828 bool IsCaretOn(
const ExpressionParserLocation& location,
829 bool inclusive =
false) {
830 if (!location.IsValid())
return false;
832 return (location.GetStartPosition() <= searchedPosition &&
833 ((!inclusive && searchedPosition < location.GetEndPosition()) ||
834 (inclusive && searchedPosition <= location.GetEndPosition())));
841 bool IsIdentifierSafe(
const gd::String& name) {
842 if (name.
empty())
return false;
844 for (
auto character : name) {
853 void AddCompletionsForChildrenVariablesOf(
854 VariableAndItsParent variableAndItsParent,
855 const ExpressionParserLocation& location,
856 gd::String eagerlyCompleteForVariableName =
"") {
857 if (variableAndItsParent.parentVariable) {
858 AddCompletionsForChildrenVariablesOf(variableAndItsParent.parentVariable,
860 eagerlyCompleteForVariableName);
861 }
else if (variableAndItsParent.parentVariablesContainer) {
862 AddCompletionsForVariablesMatchingSearch(
863 *variableAndItsParent.parentVariablesContainer,
"", location);
867 void AddCompletionsForChildrenVariablesOf(
869 const ExpressionParserLocation& location,
870 gd::String eagerlyCompleteForVariableName =
"") {
871 if (!variable)
return;
873 if (variable->
GetType() == gd::Variable::Structure) {
875 if (!IsIdentifierSafe(name))
continue;
877 const auto& childVariable = variable->
GetChild(name);
878 ExpressionCompletionDescription description(
879 ExpressionCompletionDescription::Variable,
880 location.GetStartPosition(),
881 location.GetEndPosition());
882 description.SetCompletion(name);
883 description.SetVariableType(childVariable.GetType());
884 completions.push_back(description);
886 if (name == eagerlyCompleteForVariableName) {
887 AddEagerCompletionForVariableChildren(childVariable, name, location);
896 void AddEagerCompletionForVariableChildren(
899 const ExpressionParserLocation& location) {
900 if (variable.
GetType() == gd::Variable::Structure) {
904 IsIdentifierSafe(name)
906 : (variableName +
"[" +
907 gd::ExpressionParser2NodePrinter::PrintStringLiteral(name) +
910 const auto& childVariable = variable.
GetChild(name);
911 ExpressionCompletionDescription description(
912 ExpressionCompletionDescription::Variable,
913 location.GetStartPosition(),
914 location.GetEndPosition());
915 description.SetCompletion(completion);
916 description.SetVariableType(childVariable.GetType());
917 completions.push_back(description);
922 void AddCompletionsForVariablesMatchingSearch(
925 const ExpressionParserLocation& location,
926 bool eagerlyCompleteIfExactMatch =
false) {
930 ExpressionCompletionDescription description(
931 ExpressionCompletionDescription::Variable,
932 location.GetStartPosition(),
933 location.GetEndPosition());
934 description.SetCompletion(variableName);
935 description.SetVariableType(variable.
GetType());
936 completions.push_back(description);
938 if (eagerlyCompleteIfExactMatch && variableName == search) {
939 AddEagerCompletionForVariableChildren(
940 variable, variableName, location);
945 void AddCompletionsForObjectOrGroupVariablesMatchingSearch(
949 const ExpressionParserLocation& location,
950 bool eagerlyCompleteIfExactMatch) {
955 ExpressionCompletionDescription description(
956 ExpressionCompletionDescription::Variable,
957 location.GetStartPosition(),
958 location.GetEndPosition());
959 description.SetCompletion(variableName);
960 description.SetVariableType(variable.
GetType());
961 completions.push_back(description);
963 if (eagerlyCompleteIfExactMatch && variableName == search) {
964 AddEagerCompletionForVariableChildren(
965 variable, variableName, location);
970 void AddCompletionsForObjectMatchingSearch(
973 const ExpressionParserLocation& location) {
974 projectScopedContainers.GetObjectsContainersList()
975 .ForEachNameMatchingSearch(
979 ExpressionCompletionDescription description(
980 ExpressionCompletionDescription::Object,
981 location.GetStartPosition(),
982 location.GetEndPosition());
983 description.SetObjectConfiguration(objectConfiguration);
984 description.SetCompletion(name);
985 description.SetType(type);
986 completions.push_back(description);
990 void AddCompletionsForObjectsAndVariablesMatchingSearch(
993 const ExpressionParserLocation& location,
994 bool eagerlyCompleteIfExactMatch) {
995 projectScopedContainers.ForEachIdentifierMatchingSearch(
998 const ObjectConfiguration* objectConfiguration) {
999 ExpressionCompletionDescription description(
1000 ExpressionCompletionDescription::Object,
1001 location.GetStartPosition(),
1002 location.GetEndPosition());
1003 description.SetObjectConfiguration(objectConfiguration);
1004 description.SetCompletion(objectName);
1005 description.SetType(type);
1006 completions.push_back(description);
1009 ExpressionCompletionDescription description(
1010 ExpressionCompletionDescription::Variable,
1011 location.GetStartPosition(),
1012 location.GetEndPosition());
1013 description.SetCompletion(variableName);
1014 description.SetVariableType(variable.
GetType());
1015 completions.push_back(description);
1017 if (eagerlyCompleteIfExactMatch && variableName == search) {
1018 AddEagerCompletionForVariableChildren(
1019 variable, variableName, location);
1030 void AddCompletionsForAllIdentifiersMatchingSearch(
const gd::String& search,
1032 AddCompletionsForAllIdentifiersMatchingSearch(
1035 ExpressionParserLocation(searchedPosition + 1, searchedPosition + 1));
1038 void AddCompletionsForAllIdentifiersMatchingSearch(
1041 const ExpressionParserLocation& location,
1042 bool eagerlyCompleteIfExactMatch =
false) {
1043 projectScopedContainers.ForEachIdentifierMatchingSearch(
1046 const ObjectConfiguration* objectConfiguration) {
1047 ExpressionCompletionDescription description(
1048 ExpressionCompletionDescription::Object,
1049 location.GetStartPosition(),
1050 location.GetEndPosition());
1051 description.SetObjectConfiguration(objectConfiguration);
1052 description.SetCompletion(objectName);
1053 description.SetType(type);
1054 completions.push_back(description);
1057 ExpressionCompletionDescription description(
1058 ExpressionCompletionDescription::Variable,
1059 location.GetStartPosition(),
1060 location.GetEndPosition());
1061 description.SetCompletion(variableName);
1062 description.SetVariableType(variable.
GetType());
1063 completions.push_back(description);
1065 if (eagerlyCompleteIfExactMatch && variableName == search) {
1066 AddEagerCompletionForVariableChildren(
1067 variable, variableName, location);
1071 ExpressionCompletionDescription description(
1072 ExpressionCompletionDescription::Property,
1073 location.GetStartPosition(),
1074 location.GetEndPosition());
1075 description.SetCompletion(property.GetName());
1076 description.SetType(property.GetType());
1077 completions.push_back(description);
1080 ExpressionCompletionDescription description(
1081 ExpressionCompletionDescription::Parameter,
1082 location.GetStartPosition(),
1083 location.GetEndPosition());
1084 description.SetCompletion(parameter.GetName());
1085 description.SetType(parameter.GetType());
1086 completions.push_back(description);
1090 ExpressionCompletionFinder(
1094 size_t searchedPosition_,
1096 : searchedPosition(searchedPosition_),
1097 maybeParentNodeAtLocation(maybeParentNodeAtLocation_),
1098 platform(platform_),
1099 projectScopedContainers(projectScopedContainers_),
1100 rootType(rootType_),
1105 std::vector<ExpressionCompletionDescription> completions;
1106 size_t searchedPosition;
Returns the list of completion descriptions for an expression node.
Definition: ExpressionCompletionFinder.h:356
const std::vector< ExpressionCompletionDescription > & GetCompletionDescriptions()
Return the completions found for the visited node.
Definition: ExpressionCompletionFinder.h:393
static std::vector< ExpressionCompletionDescription > GetCompletionDescriptionsFor(const gd::Platform &platform, const gd::ProjectScopedContainers &projectScopedContainers, const gd::String &rootType, gd::ExpressionNode &node, size_t searchedPosition)
Given the expression, find the node at the specified location and returns completions for it.
Definition: ExpressionCompletionFinder.h:363
Find the deepest node at the specified location in an expression.
Definition: ExpressionNodeLocationFinder.h:30
ExpressionNode * GetParentNode()
Return the parent of deepest node found at the search position, if any.
Definition: ExpressionNodeLocationFinder.h:72
ExpressionNode * GetNode()
Return the deepest node found at the search position, if any.
Definition: ExpressionNodeLocationFinder.h:66
static size_t WrittenParametersFirstIndex(const gd::String &objectName, const gd::String &behaviorName)
Definition: ExpressionParser2.h:73
The interface for any worker class ("visitor" pattern) that want to interact with the nodes of a pars...
Definition: ExpressionParser2NodeWorker.h:36
static const gd::String GetType(const gd::Platform &platform, const gd::ProjectScopedContainers &projectScopedContainers, const gd::String &rootType, gd::ExpressionNode &node)
Helper function to find the type of the expression or sub-expression that a given node represents.
Definition: ExpressionTypeFinder.h:52
const gd::String & GetObjectName()
Get all the errors.
Definition: ExpressionVariableOwnerFinder.h:75
Used to describe a property shown in a property grid.
Definition: NamedPropertyDescriptor.h:21
Base class used to represent an object configuration. For example, this can be the animations in a sp...
Definition: ObjectConfiguration.h:38
Represent an object of a platform.
Definition: Object.h:37
A list of objects containers, useful for accessing objects in a scoped way, along with methods to acc...
Definition: ObjectsContainersList.h:29
void ForEachObjectOrGroupVariableMatchingSearch(const gd::String &objectOrGroupName, const gd::String &search, std::function< void(const gd::String &variableName, const gd::Variable &variable)> fn) const
Call the callback for each variable of the object (or group) matching the search passed in parameter.
Definition: ObjectsContainersList.cpp:243
Holds references to variables, objects, properties and other containers.
Definition: ProjectScopedContainers.h:30
String represents an UTF8 encoded string.
Definition: String.h:31
static String From(T value)
Method to create a gd::String from a number (float, double, int, ...)
Definition: String.h:219
void push_back(value_type character)
Add a character (from its codepoint) at the end of the String.
Definition: String.cpp:221
bool empty() const
Returns true if the string is empty.
Definition: String.h:155
Defines a variable which can be used by an object, a layout or a project.
Definition: Variable.h:29
Variable & GetChild(const gd::String &name)
Return the child with the specified name.
Definition: Variable.cpp:140
Type GetType() const
Get the type of the variable.
Definition: Variable.h:60
std::vector< gd::String > GetAllChildrenNames() const
Get the names of all children.
Definition: Variable.cpp:306
Class defining a container for gd::Variable.
Definition: VariablesContainer.h:30
void ForEachVariableMatchingSearch(const gd::String &search, std::function< void(const gd::String &name, const gd::Variable &variable)> fn) const
Call the callback for each variable with a name matching the specified search.
Definition: VariablesContainer.cpp:165
bool IsAllowedInIdentifier(gd::String::value_type character)
Definition: GrammarTerminals.h:99
Definition: CommonTools.h:24
std::ostream & operator<<(std::ostream &os, ExpressionCompletionDescription const &value)
Turn an ExpressionCompletionDescription to a string.
Definition: ExpressionCompletionFinder.cpp:19
Describe completions to be shown to the user.
Definition: ExpressionCompletionFinder.h:41
const gd::String & GetCompletion() const
Return the completion that must be inserted.
Definition: ExpressionCompletionFinder.h:163
const gd::String & GetPrefix() const
Return the prefix that must be completed.
Definition: ExpressionCompletionFinder.h:153
bool operator==(const ExpressionCompletionDescription &other) const
Definition: ExpressionCompletionFinder.h:118
ExpressionCompletionDescription()
Definition: ExpressionCompletionFinder.h:311
bool IsExact() const
Check if the completion description is exact, i.e: it's not used to complete anything....
Definition: ExpressionCompletionFinder.h:213
const gd::String & GetObjectName() const
Return the object name, if completing an object expression or a behavior.
Definition: ExpressionCompletionFinder.h:175
ExpressionCompletionDescription & SetObjectConfiguration(const gd::ObjectConfiguration *objectConfiguration_)
Set the object configuration, in the case the completion is about an object.
Definition: ExpressionCompletionFinder.h:269
ExpressionCompletionDescription & SetParameterMetadata(const gd::ParameterMetadata ¶meterMetadata_)
Set the parameter metadata, in the case the completion is about a parameter of a function call.
Definition: ExpressionCompletionFinder.h:244
static ExpressionCompletionDescription ForBehaviorWithPrefix(const gd::String &prefix_, size_t replacementStartPosition_, size_t replacementEndPosition_, const gd::String &objectName_)
Create a completion for a behavior with the given prefix, for the specified object.
Definition: ExpressionCompletionFinder.h:63
bool HasParameterMetadata() const
Check if the completion is about a parameter of a function call.
Definition: ExpressionCompletionFinder.h:253
ExpressionCompletionDescription & SetIsLastParameter(bool isLastParameter_)
Set if the expression is the last child of a function call.
Definition: ExpressionCompletionFinder.h:230
const gd::ObjectConfiguration & GetObjectConfiguration() const
Return the parameter metadata, if the completion is about a object. Returns an empty configuration ot...
Definition: ExpressionCompletionFinder.h:287
CompletionKind
Definition: ExpressionCompletionFinder.h:49
size_t GetReplacementStartPosition() const
Return the first character index of the autocompleted part.
Definition: ExpressionCompletionFinder.h:218
const gd::String & GetBehaviorName() const
Return the behavior name, if completing an object behavior expression.
Definition: ExpressionCompletionFinder.h:190
gd::Variable::Type GetVariableType() const
Return the type of the variable, for a variable completion.
Definition: ExpressionCompletionFinder.h:142
size_t GetReplacementEndPosition() const
Return the first character index after the autocompleted part.
Definition: ExpressionCompletionFinder.h:225
static ExpressionCompletionDescription ForTextWithPrefix(const gd::String &type_, const gd::ParameterMetadata ¶meterMetadata_, const gd::String &prefix_, size_t replacementStartPosition_, size_t replacementEndPosition_, const bool isLastParameter_, const gd::String &objectName_="")
Create a completion for a text with the given prefix.
Definition: ExpressionCompletionFinder.h:78
CompletionKind GetCompletionKind() const
Return the kind of the completion.
Definition: ExpressionCompletionFinder.h:126
const gd::String & GetType() const
Return the type of the completion (same type as types supported in expressions). For properties,...
Definition: ExpressionCompletionFinder.h:132
ExpressionCompletionDescription & SetIsExact(bool isExact_)
Set if the completion description is exact, i.e: it's not used to complete anything....
Definition: ExpressionCompletionFinder.h:203
bool HasObjectConfiguration() const
Check if the completion is about an object.
Definition: ExpressionCompletionFinder.h:279
static ExpressionCompletionDescription ForExpressionWithPrefix(const gd::String &type_, const gd::String &prefix_, size_t replacementStartPosition_, size_t replacementEndPosition_, const gd::String &objectName_="", const gd::String &behaviorName_="")
Create a completion for an expression (free, object or behavior expression) with the given prefix.
Definition: ExpressionCompletionFinder.h:100
const gd::ParameterMetadata & GetParameterMetadata() const
Return the parameter metadata, if the completion is about a parameter of a function call....
Definition: ExpressionCompletionFinder.h:261
bool IsLastParameter() const
Check if the expression is the last child of a function call.
Definition: ExpressionCompletionFinder.h:238
The base node, from which all nodes in the tree of an expression inherits from.
Definition: ExpressionParser2Node.h:93