Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Check range when set module scope member #1899

Open
wants to merge 123 commits into
base: main
Choose a base branch
from

Conversation

ZhiruiLi
Copy link

Record module range when saving current module, and check if doclet in
range when call setModuleScopeMemberOf function.

Q A
Bug fix? yes
New feature? no
Breaking change? no
Deprecations? yes
Tests added? no
Fixed issues list below
License Apache-2.0

When walking through AST, vistor will treat the enum as module, which will cause wrong full name for the next element.
For example:

/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
"use strict";

var $protobuf = require("protobufjs/minimal");

// Exported root namespace
var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});

/**
 * MyEnum enum.
 * @exports MyEnum
 * @enum {number}
 * @property {number} UNKNOWN=0 UNKNOWN value
 */
$root.MyEnum = (function () {
  var valuesById = {},
    values = Object.create(valuesById);
  values[(valuesById[0] = "UNKNOWN")] = 0;
  return values;
})();

$root.MyMessage2 = (function () {
  /**
   * Properties of a MyMessage2.
   * @exports IMyMessage2
   * @interface IMyMessage2
   */

  /**
   * Constructs a new MyMessage2.
   * @exports MyMessage2
   * @classdesc Represents a MyMessage2.
   * @implements IMyMessage2
   * @constructor
   * @param {IMyMessage2=} [properties] Properties to set
   */
  function MyMessage2(properties) {
    if (properties)
      for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
        if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]];
  }

  return MyMessage2;
})();

module.exports = $root;

After visit MyEnum, the currentModule will become module:MyEnum, and the longname of IMyMessage2 will become module:MyEnum~IMyMessage2 even if it does not belong to MyEnum.

Here, we need to check if current element is out of current module, if it is, the branch should not be executed.

renovate-bot and others added 29 commits March 21, 2021 01:18
Record module range when saving current module, and check if doclet in
range when call `setModuleScopeMemberOf` function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants