Sprint 6 Step 193: semantic library tags
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
#pragma once
|
||||
#include "ASTNode.h"
|
||||
#include <vector>
|
||||
|
||||
class ExternalModule : public ASTNode {
|
||||
public:
|
||||
std::string name;
|
||||
std::string version;
|
||||
std::string language;
|
||||
std::vector<std::string> semanticTags;
|
||||
|
||||
ExternalModule() { conceptType = "ExternalModule"; }
|
||||
ExternalModule(const std::string& id, const std::string& name,
|
||||
|
||||
@@ -103,11 +103,13 @@ inline json propertiesToJson(const ASTNode* node) {
|
||||
props["name"] = n->name;
|
||||
if (!n->version.empty()) props["version"] = n->version;
|
||||
if (!n->language.empty()) props["language"] = n->language;
|
||||
if (!n->semanticTags.empty()) props["semanticTags"] = n->semanticTags;
|
||||
}
|
||||
else if (ct == "TypeSignature") {
|
||||
auto* n = static_cast<const TypeSignature*>(node);
|
||||
props["name"] = n->name;
|
||||
props["variadic"] = n->variadic;
|
||||
if (!n->semanticTags.empty()) props["semanticTags"] = n->semanticTags;
|
||||
}
|
||||
// Annotations
|
||||
else if (ct == "DerefStrategy") {
|
||||
@@ -286,11 +288,23 @@ inline void setPropertiesFromJson(ASTNode* node, const json& props) {
|
||||
if (props.contains("name")) n->name = props["name"].get<std::string>();
|
||||
if (props.contains("version")) n->version = props["version"].get<std::string>();
|
||||
if (props.contains("language")) n->language = props["language"].get<std::string>();
|
||||
if (props.contains("semanticTags") && props["semanticTags"].is_array()) {
|
||||
n->semanticTags.clear();
|
||||
for (const auto& tag : props["semanticTags"]) {
|
||||
if (tag.is_string()) n->semanticTags.push_back(tag.get<std::string>());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ct == "TypeSignature") {
|
||||
auto* n = static_cast<TypeSignature*>(node);
|
||||
if (props.contains("name")) n->name = props["name"].get<std::string>();
|
||||
if (props.contains("variadic")) n->variadic = props["variadic"].get<bool>();
|
||||
if (props.contains("semanticTags") && props["semanticTags"].is_array()) {
|
||||
n->semanticTags.clear();
|
||||
for (const auto& tag : props["semanticTags"]) {
|
||||
if (tag.is_string()) n->semanticTags.push_back(tag.get<std::string>());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ct == "DerefStrategy") {
|
||||
auto* n = static_cast<DerefStrategy*>(node);
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#pragma once
|
||||
#include "ASTNode.h"
|
||||
#include <vector>
|
||||
|
||||
class TypeSignature : public ASTNode {
|
||||
public:
|
||||
std::string name;
|
||||
bool variadic = false;
|
||||
std::vector<std::string> semanticTags;
|
||||
|
||||
TypeSignature() { conceptType = "TypeSignature"; }
|
||||
TypeSignature(const std::string& id, const std::string& name, bool variadic = false)
|
||||
|
||||
Reference in New Issue
Block a user