UNPKG

igniteui-react-core

Version:
356 lines (355 loc) 13 kB
/* THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE: https://www.infragistics.com/legal/license/igultimate-la https://www.infragistics.com/legal/license/igultimate-eula GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company. */ import { __extends, __values } from "tslib"; import { Base, String_$type, fromEnum, markType } from "./type"; import { Dictionary$2 } from "./Dictionary$2"; import { List$1 } from "./List$1"; import { HashSet$1 } from "./HashSet$1"; import { StringBuilder } from "./StringBuilder"; import { stringJoin1, stringStartsWith } from "./string"; /** * @hidden */ var CodeGeneratingImportManager = /** @class */ /*@__PURE__*/ (function (_super) { __extends(CodeGeneratingImportManager, _super); function CodeGeneratingImportManager() { var _this = _super !== null && _super.apply(this, arguments) || this; _this._packageOverride = null; _this._isImportsOnly = false; _this.k = new List$1(String_$type, 0); _this.i = new HashSet$1(String_$type, 0); _this.j = new List$1(String_$type, 0); _this.h = new HashSet$1(String_$type, 0); _this.f = new Dictionary$2(String_$type, List$1.$.specialize(String_$type), 0); _this.g = new Dictionary$2(String_$type, HashSet$1.$.specialize(String_$type), 0); return _this; } Object.defineProperty(CodeGeneratingImportManager.prototype, "packageOverride", { get: function () { return this._packageOverride; }, set: function (a) { this._packageOverride = a; }, enumerable: false, configurable: true }); Object.defineProperty(CodeGeneratingImportManager.prototype, "isImportsOnly", { get: function () { return this._isImportsOnly; }, set: function (a) { this._isImportsOnly = a; }, enumerable: false, configurable: true }); CodeGeneratingImportManager.prototype.addUsing = function (a) { if (!this.i.contains(a)) { this.i.add_1(a); this.k.add(a); } }; Object.defineProperty(CodeGeneratingImportManager.prototype, "hasPackageImports", { get: function () { return this.f.count > 0; }, enumerable: false, configurable: true }); CodeGeneratingImportManager.prototype.packageImportsToString = function () { var a = new StringBuilder(0); for (var b = 0; b < this.j.count; b++) { var c = this.j._inner[b]; var d = this.f.item(c); var e = stringJoin1(String_$type, ", ", d); if (this.isImportsOnly && b > 0) { a.u(","); } if (this.isImportsOnly) { a.l(e); } else { if (this.h.contains(c)) { if (e == "@SELF@") { a.u("import '" + c + "';"); } else { a.u("import " + e + " from '" + c + "';"); } } else { a.u("import { " + e + " } from '" + c + "';"); } } } return a.toString(); }; CodeGeneratingImportManager.prototype.usingsToString = function (a) { var b = new StringBuilder(0); for (var c = 0; c < this.k.count; c++) { if (!stringStartsWith(this.k._inner[c].trim(), "@") && a) { b.u("@" + this.k._inner[c]); } else { b.u(this.k._inner[c]); } } return b.toString(); }; CodeGeneratingImportManager.prototype.any = function () { return this.j.count > 0 || this.k.count > 0; }; CodeGeneratingImportManager.prototype.addPackageImport = function (a, b) { if (this.packageOverride != null) { a = this.packageOverride; } if (!this.g.containsKey(a)) { this.j.add(a); this.g.addItem(a, new HashSet$1(String_$type, 0)); this.f.addItem(a, new List$1(String_$type, 0)); } if (!this.g.item(a).contains(b)) { this.g.item(a).add_1(b); this.f.item(a).add(b); } }; CodeGeneratingImportManager.prototype.addDefaultImport = function (a, b) { if (this.packageOverride != null) { a = this.packageOverride; } if (!this.g.containsKey(a)) { this.j.add(a); this.g.addItem(a, new HashSet$1(String_$type, 0)); this.f.addItem(a, new List$1(String_$type, 0)); this.h.add_1(a); } if (!this.g.item(a).contains(b)) { this.g.item(a).add_1(b); this.f.item(a).add(b); } }; CodeGeneratingImportManager.merge = function (a, b) { var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f; var c = new CodeGeneratingImportManager(); if (a.isImportsOnly || b.isImportsOnly) { c.isImportsOnly = true; } if (b.f.count > 0 || a.f.count > 0) { try { for (var _g = __values(fromEnum(a.f.keys)), _h = _g.next(); !_h.done; _h = _g.next()) { var d = _h.value; try { for (var _j = (e_2 = void 0, __values(fromEnum(a.f.item(d)))), _k = _j.next(); !_k.done; _k = _j.next()) { var e = _k.value; if (a.h.contains(d)) { c.addDefaultImport(d, e); } else { c.addPackageImport(d, e); } } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_k && !_k.done && (_b = _j.return)) _b.call(_j); } finally { if (e_2) throw e_2.error; } } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_h && !_h.done && (_a = _g.return)) _a.call(_g); } finally { if (e_1) throw e_1.error; } } try { for (var _l = __values(fromEnum(b.f.keys)), _m = _l.next(); !_m.done; _m = _l.next()) { var f = _m.value; try { for (var _o = (e_4 = void 0, __values(fromEnum(b.f.item(f)))), _p = _o.next(); !_p.done; _p = _o.next()) { var g = _p.value; if (b.h.contains(f)) { c.addDefaultImport(f, g); } else { c.addPackageImport(f, g); } } } catch (e_4_1) { e_4 = { error: e_4_1 }; } finally { try { if (_p && !_p.done && (_d = _o.return)) _d.call(_o); } finally { if (e_4) throw e_4.error; } } } } catch (e_3_1) { e_3 = { error: e_3_1 }; } finally { try { if (_m && !_m.done && (_c = _l.return)) _c.call(_l); } finally { if (e_3) throw e_3.error; } } } else { try { for (var _q = __values(fromEnum(a.k)), _r = _q.next(); !_r.done; _r = _q.next()) { var h = _r.value; c.addUsing(h); } } catch (e_5_1) { e_5 = { error: e_5_1 }; } finally { try { if (_r && !_r.done && (_e = _q.return)) _e.call(_q); } finally { if (e_5) throw e_5.error; } } try { for (var _s = __values(fromEnum(b.k)), _t = _s.next(); !_t.done; _t = _s.next()) { var i = _t.value; c.addUsing(i); } } catch (e_6_1) { e_6 = { error: e_6_1 }; } finally { try { if (_t && !_t.done && (_f = _s.return)) _f.call(_s); } finally { if (e_6) throw e_6.error; } } } return c; }; CodeGeneratingImportManager.prototype.removeDuplicates = function (a) { var e_7, _a, e_8, _b, e_9, _c; var b = CodeGeneratingImportManager.merge(this, new CodeGeneratingImportManager()); if (this.isImportsOnly) { b.isImportsOnly = true; } if (a.f.count > 0) { try { for (var _d = __values(fromEnum(a.f.keys)), _e = _d.next(); !_e.done; _e = _d.next()) { var c = _e.value; if (this.f.containsKey(c)) { try { for (var _f = (e_8 = void 0, __values(fromEnum(a.f.item(c)))), _g = _f.next(); !_g.done; _g = _f.next()) { var d = _g.value; if (b.g.containsKey(c) && b.g.item(c).contains(d)) { b.g.item(c).remove(d); b.f.item(c).remove(d); if (b.f.item(c).count == 0) { b.j.remove(c); b.h.remove(c); b.g.removeItem(c); b.f.removeItem(c); } } } } catch (e_8_1) { e_8 = { error: e_8_1 }; } finally { try { if (_g && !_g.done && (_b = _f.return)) _b.call(_f); } finally { if (e_8) throw e_8.error; } } } } } catch (e_7_1) { e_7 = { error: e_7_1 }; } finally { try { if (_e && !_e.done && (_a = _d.return)) _a.call(_d); } finally { if (e_7) throw e_7.error; } } } else { try { for (var _h = __values(fromEnum(a.k)), _j = _h.next(); !_j.done; _j = _h.next()) { var e = _j.value; if (b.i.contains(e)) { b.i.remove(e); b.k.remove(e); } } } catch (e_9_1) { e_9 = { error: e_9_1 }; } finally { try { if (_j && !_j.done && (_c = _h.return)) _c.call(_h); } finally { if (e_9) throw e_9.error; } } } return b; }; CodeGeneratingImportManager.$t = markType(CodeGeneratingImportManager, 'CodeGeneratingImportManager'); return CodeGeneratingImportManager; }(Base)); export { CodeGeneratingImportManager };