|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
927 bytes
|
| Line | |
|---|
| 1 | "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|---|
| 2 | var _getIdentifierNames = require('./util/getIdentifierNames'); var _getIdentifierNames2 = _interopRequireDefault(_getIdentifierNames);
|
|---|
| 3 |
|
|---|
| 4 | class NameManager {
|
|---|
| 5 | __init() {this.usedNames = new Set()}
|
|---|
| 6 |
|
|---|
| 7 | constructor(code, tokens) {;NameManager.prototype.__init.call(this);
|
|---|
| 8 | this.usedNames = new Set(_getIdentifierNames2.default.call(void 0, code, tokens));
|
|---|
| 9 | }
|
|---|
| 10 |
|
|---|
| 11 | claimFreeName(name) {
|
|---|
| 12 | const newName = this.findFreeName(name);
|
|---|
| 13 | this.usedNames.add(newName);
|
|---|
| 14 | return newName;
|
|---|
| 15 | }
|
|---|
| 16 |
|
|---|
| 17 | findFreeName(name) {
|
|---|
| 18 | if (!this.usedNames.has(name)) {
|
|---|
| 19 | return name;
|
|---|
| 20 | }
|
|---|
| 21 | let suffixNum = 2;
|
|---|
| 22 | while (this.usedNames.has(name + String(suffixNum))) {
|
|---|
| 23 | suffixNum++;
|
|---|
| 24 | }
|
|---|
| 25 | return name + String(suffixNum);
|
|---|
| 26 | }
|
|---|
| 27 | } exports.default = NameManager;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.