/*
* This file is part of PKM (Persistent Knowledge Monitor).
* Copyright (c) 2020 Capgemini Group, Commissariat à l'énergie atomique et aux énergies alternatives,
* OW2, Sysgo AG, Technikon, Tree Technology, Universitat Politècnica de València.
*
* PKM is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License version 3 as published by
* the Free Software Foundation.
*
* PKM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with PKM. If not, see <https://www.gnu.org/licenses/>.
*/
/** Preprocess C Annotations
*
* @memberof PKM
* @instance
* @param {Array.<Object>} c_annotations_documents - C Annotations documents
* @param {Object} [options] - options
*
* @return {Promise.<Array.<Object>>} a promise which result is the preprocessed C Annotations documents
*/
function preprocess_c_annotations(c_annotations_documents, options = {})
{
return new Promise(function(resolve, reject)
{
const dont_split = (options !== undefined) && options.dont_split;
if(dont_split)
{
resolve(c_annotations_documents);
}
else
{
let splitted_c_annotations_documents = [];
c_annotations_documents.forEach((c_annotations_document) =>
{
c_annotations_document.annotations.forEach((annotation) =>
{
splitted_c_annotations_documents.push({ type : c_annotations_document.type, sourceFile : c_annotations_document.sourceFile, annotations : [ annotation ] });
});
});
resolve(splitted_c_annotations_documents);
}
}.bind(this));
}
module.exports.preprocess_c_annotations = preprocess_c_annotations;