UNPKG

ui5plugin-parser

Version:
65 lines (64 loc) 2.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AbstractUI5Parser = void 0; const glob = require("glob"); const path = require("path"); const fs = require("fs"); const path_1 = require("path"); const PackageParserConfigHandler_1 = require("../../classes/config/PackageParserConfigHandler"); const ParserPool_1 = require("../pool/ParserPool"); class AbstractUI5Parser { constructor(packagePath = (0, path_1.join)(process.cwd(), "/package.json")) { this._customData = {}; this.packagePath = packagePath; ParserPool_1.default.register(this); } setCustomData(key, data) { this._customData[key] = data; } getCustomData(key) { return this._customData[key]; } async initializeLibsAndManifest(globalStoragePath = path.join(__dirname, "./node_modules/.cache/ui5plugin")) { this.fileReader.globalStoragePath = globalStoragePath; await this._preloadStandardLibMetadata(); this.fileReader.rereadAllManifests(); } initializeCustomClasses() { this.fileReader.readCustomClasses(); } initializeFragments() { this.fileReader.readFragments(); } initializeViews() { this.fileReader.readViews(); } initializeI18n() { this.fileReader.readI18n(); } async _preloadStandardLibMetadata() { const SAPNodes = await this.nodeDAO.getAllNodes(); await Promise.all([this.metadataDAO.loadMetadata(SAPNodes), this.icons.preloadIcons()]); this.nodeDAO.recursiveModuleAssignment(); } clearCache(globalStoragePath) { fs.rmSync(globalStoragePath, { force: true, recursive: true }); } static getIsTypescriptProject(workspaceFolder, configHandler = new PackageParserConfigHandler_1.PackageParserConfigHandler()) { const escapedFileSeparator = "\\" + path.sep; const wsFolderFSPath = workspaceFolder.fsPath.replace(new RegExp(`${escapedFileSeparator}`, "g"), "/"); const exclusions = configHandler.getExcludeFolderPatterns(); const exclusionPaths = exclusions.map(excludeString => { return `${wsFolderFSPath}/${excludeString}`; }); const tsFiles = glob.sync(`${wsFolderFSPath}/**/*.ts`, { ignore: exclusionPaths }); const tsConfig = glob.sync(`${wsFolderFSPath}/tsconfig.json`); return (!!tsFiles.length && !!tsConfig.length) || false; } } exports.AbstractUI5Parser = AbstractUI5Parser;