MCPcopy Create free account
hub / github.com/KDE/kdevelop / importJSONFile

Method importJSONFile

plugins/meson/mintro/mesonintrospectjob.cpp:107–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107QString MesonIntrospectJob::importJSONFile(const BuildDir& buildDir, MesonIntrospectJob::Type type, QJsonObject* out)
108{
109 QString typeStr = getTypeString(type);
110 QString fileName = QStringLiteral("intro-") + typeStr + QStringLiteral(".json");
111 QString infoDir = buildDir.buildDir.toLocalFile() + QStringLiteral("/") + QStringLiteral("meson-info");
112 QFile introFile(infoDir + QStringLiteral("/") + fileName);
113
114 if (!introFile.exists()) {
115 return i18n("Introspection file '%1' does not exist", QFileInfo(introFile).canonicalFilePath());
116 }
117
118 if (!introFile.open(QFile::ReadOnly | QFile::Text)) {
119 return i18n("Failed to open introspection file '%1'", QFileInfo(introFile).canonicalFilePath());
120 }
121
122 QJsonParseError error;
123 QJsonDocument doc = QJsonDocument::fromJson(introFile.readAll(), &error);
124 if (error.error) {
125 return i18n("In %1:%2: %3", QFileInfo(introFile).canonicalFilePath(), error.offset, error.errorString());
126 }
127
128 if (doc.isArray()) {
129 (*out)[typeStr] = doc.array();
130 } else if (doc.isObject()) {
131 (*out)[typeStr] = doc.object();
132 } else {
133 return i18n("The introspection file '%1' contains neither an array nor an object",
134 QFileInfo(introFile).canonicalFilePath());
135 }
136
137 return QString();
138}
139
140QString MesonIntrospectJob::importMesonAPI(const BuildDir& buildDir, MesonIntrospectJob::Type type, QJsonObject* out)
141{

Callers

nothing calls this directly

Calls 8

toLocalFileMethod · 0.80
existsMethod · 0.80
objectMethod · 0.80
QFileInfoClass · 0.50
QStringClass · 0.50
openMethod · 0.45
errorStringMethod · 0.45
arrayMethod · 0.45

Tested by

no test coverage detected