"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.StrictPlatformInfoGeneratorTest = void 0;
const ProjectInfoItem_1 = require("./ProjectInfoItem");
const IProjectItemData_1 = require("../app/IProjectItemData");
const IInfoItemData_1 = require("./IInfoItemData");
const EntityTypeDefinition_1 = require("../minecraft/EntityTypeDefinition");
const ItemTypeDefinition_1 = require("../minecraft/ItemTypeDefinition");
const ProjectInfoUtilities_1 = require("./ProjectInfoUtilities");
var StrictPlatformInfoGeneratorTest;
(function (StrictPlatformInfoGeneratorTest) {
    StrictPlatformInfoGeneratorTest[StrictPlatformInfoGeneratorTest["entityTypeUsesAMinecraftIdentifier"] = 100] = "entityTypeUsesAMinecraftIdentifier";
    StrictPlatformInfoGeneratorTest[StrictPlatformInfoGeneratorTest["entityTypeUsesAMinecraftRuntimeIdentifier"] = 101] = "entityTypeUsesAMinecraftRuntimeIdentifier";
    StrictPlatformInfoGeneratorTest[StrictPlatformInfoGeneratorTest["itemTypeUsesAMinecraftIdentifier"] = 104] = "itemTypeUsesAMinecraftIdentifier";
})(StrictPlatformInfoGeneratorTest = exports.StrictPlatformInfoGeneratorTest || (exports.StrictPlatformInfoGeneratorTest = {}));
class StrictPlatformInfoGenerator {
    id = "STRICT";
    title = "Strict Platform Info Generator";
    canAlwaysProcess = true;
    identifierOverridesAreErrors = false;
    getTopicData(topicId) {
        return {
            title: ProjectInfoUtilities_1.default.getTitleFromEnum(StrictPlatformInfoGeneratorTest, topicId),
        };
    }
    summarize(info, infoSet) { }
    async generate(project, contentIndex) {
        const infoItems = [];
        const itemsCopy = project.getItemsCopy();
        for (let i = 0; i < itemsCopy.length; i++) {
            const pi = itemsCopy[i];
            if (pi.itemType === IProjectItemData_1.ProjectItemType.entityTypeBehavior) {
                await pi.loadFileContent();
                if (pi.primaryFile) {
                    const bpEntityType = await EntityTypeDefinition_1.default.ensureOnFile(pi.primaryFile);
                    if (bpEntityType) {
                        await bpEntityType.load();
                        if (bpEntityType && bpEntityType._data && bpEntityType._data.description) {
                            const desc = bpEntityType._data.description;
                            if (desc.identifier !== undefined && desc.identifier.toLowerCase().startsWith("minecraft:")) {
                                infoItems.push(new ProjectInfoItem_1.default(this.identifierOverridesAreErrors ? IInfoItemData_1.InfoItemType.error : IInfoItemData_1.InfoItemType.warning, this.id, StrictPlatformInfoGeneratorTest.entityTypeUsesAMinecraftIdentifier, `Uses a minecraft: identifier override`, pi, desc.identifier));
                            }
                            if (desc.runtime_identifier !== undefined &&
                                desc.runtime_identifier.toLowerCase !== undefined &&
                                desc.runtime_identifier.toLowerCase().startsWith("minecraft:")) {
                                infoItems.push(new ProjectInfoItem_1.default(this.identifierOverridesAreErrors ? IInfoItemData_1.InfoItemType.error : IInfoItemData_1.InfoItemType.warning, this.id, StrictPlatformInfoGeneratorTest.entityTypeUsesAMinecraftRuntimeIdentifier, `Uses a runtime_identifier override`, pi, desc.runtime_identifier));
                            }
                        }
                    }
                }
            }
            else if (pi.itemType === IProjectItemData_1.ProjectItemType.itemTypeBehavior) {
                await pi.loadFileContent();
                if (pi.primaryFile) {
                    const bpItemType = await ItemTypeDefinition_1.default.ensureOnFile(pi.primaryFile);
                    if (bpItemType) {
                        await bpItemType.load();
                        if (bpItemType && bpItemType.data && bpItemType.data.description) {
                            const desc = bpItemType.data.description;
                            if (desc.identifier !== undefined && desc.identifier.toLowerCase().startsWith("minecraft:")) {
                                infoItems.push(new ProjectInfoItem_1.default(this.identifierOverridesAreErrors ? IInfoItemData_1.InfoItemType.error : IInfoItemData_1.InfoItemType.warning, this.id, StrictPlatformInfoGeneratorTest.itemTypeUsesAMinecraftIdentifier, `Uses a minecraft: identifier override`, pi, desc.identifier));
                            }
                        }
                    }
                }
            }
        }
        return infoItems;
    }
}
exports.default = StrictPlatformInfoGenerator;

//# sourceMappingURL=../maps/info/StrictPlatformInfoGenerator.js.map
