| 905 | } |
| 906 | |
| 907 | DeclarationBuilder::ExportLiteralsAndNames DeclarationBuilder::exportedNames(QmlJS::AST::ExpressionStatement* exports) |
| 908 | { |
| 909 | ExportLiteralsAndNames res; |
| 910 | |
| 911 | if (!exports) { |
| 912 | return res; |
| 913 | } |
| 914 | |
| 915 | auto exportslist = QmlJS::AST::cast<QmlJS::AST::ArrayLiteral*>(exports->expression); |
| 916 | |
| 917 | if (!exportslist) { |
| 918 | return res; |
| 919 | } |
| 920 | |
| 921 | // Explore all the exported symbols for this component and keep only those |
| 922 | // having a version compatible with the one of this module |
| 923 | QSet<QString> knownNames; |
| 924 | |
| 925 | for (auto it = exportslist->elements; it && it->expression; it = it->next) { |
| 926 | auto stringliteral = QmlJS::AST::cast<QmlJS::AST::StringLiteral *>(it->expression); |
| 927 | |
| 928 | if (!stringliteral) { |
| 929 | continue; |
| 930 | } |
| 931 | |
| 932 | // String literal like "Namespace/Class version". |
| 933 | QStringList nameAndVersion = stringliteral->value.toString().section(QLatin1Char('/'), -1, -1).split(QLatin1Char(' ')); |
| 934 | QString name = nameAndVersion.at(0); |
| 935 | |
| 936 | if (Algorithm::insert(knownNames, name).inserted) { |
| 937 | res.append(qMakePair(stringliteral, name)); |
| 938 | } |
| 939 | } |
| 940 | |
| 941 | return res; |
| 942 | } |
| 943 | |
| 944 | |
| 945 | void DeclarationBuilder::declareExports(const ExportLiteralsAndNames& exports, |