MCPcopy Create free account
hub / github.com/Snapchat/Valdi / parse

Method parse

valdi_core/src/valdi_core/cpp/Context/ComponentPath.cpp:20–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18 : _resourceId(std::move(resourceId)), _symbolName(std::move(symbolName)) {}
19
20ComponentPath ComponentPath::parse(const StringBox& componentPathString) {
21 static constexpr char targetSuffix[] = ".valdi";
22 if (componentPathString.hasSuffix(targetSuffix)) {
23 // Backward compatibility
24 return parse(componentPathString
25 .substring(0, componentPathString.length() - std::string::traits_type::length(targetSuffix))
26 .append(".vue.generated")
27 .prepend("ComponentClass@"));
28 }
29
30 StringBox resolvedSymbolName;
31 StringBox resolvedComponentPath;
32
33 auto symbolSeparator = componentPathString.indexOf('@');
34 if (symbolSeparator) {
35 auto parts = componentPathString.split(*symbolSeparator);
36 resolvedSymbolName = std::move(parts.first);
37 resolvedComponentPath = std::move(parts.second);
38 } else {
39 resolvedComponentPath = componentPathString;
40 }
41
42 auto result = JavaScriptPathResolver::resolveResourceId(resolvedComponentPath);
43 if (!result) {
44 return ComponentPath();
45 }
46 return ComponentPath(result.moveValue(), std::move(resolvedSymbolName));
47}
48
49const ResourceId& ComponentPath::getResourceId() const {
50 return _resourceId;

Callers

nothing calls this directly

Calls 10

hasSuffixMethod · 0.80
substringMethod · 0.80
splitMethod · 0.80
ComponentPathClass · 0.70
prependMethod · 0.65
appendMethod · 0.65
parseFunction · 0.50
lengthFunction · 0.50
lengthMethod · 0.45
indexOfMethod · 0.45

Tested by

no test coverage detected