@aws/fully-qualified-names

中文文档
2.1.4发布于 2024/02/24Apache-2.0TypeScriptESM + CJS近 30 天下载 2697

For extracting def use statements from code.

原始使用文档
文档目录6 节
  1. How to use
  2. Background
  3. Names
  4. Declaration -- Usage
  5. Security
  6. License

Fully Qualified Names

A name cannot be dissected any further by means of a definition: it is a primitive sign -- Ludwig Wittgenstein

Powered by tree-sitter, fully-qualified-names lets you extract simple and fully qualified names from code written in JavaScript, TypeScript, Python or Java. Those names are further split into declarations and usages which provides a convenient simplification of more complex ASTs for static analysis.

How to use

The package offers a Rust and a JS API, the latter based on WASM. To get names from a Python code snippet in Rust you would use something like the following.

use fully-qualified-names::Python;

let code = r#"class Person:
  def __init__(self, name):
    self.name = name

  def hello(self):
    return f"Hello, {self.name}"
"#;

let names = Python::find_names(code).unwrap();
println!("{names:?}");

The same in JS would look as follows.

import { Python } from '@aws/fully-qualified-names';

const code = `class Person:
  def __init__(self, name):
    self.name = name

  def hello(self):
    return f"Hello, {self.name}"
`;

const names = await Python.findNames(code);
console.log(JSON.stringify(names));

Background

In programming, identifers are used to refer to values, types and code passages.

Names

Those all have simple names which are context-specific, and fully qualified names (subsequently abbreviated as FQNs), which are unambiguous and unique across projects.

Take e.g. the following Rust code snippet.

let list = std::vec::Vec::new();

Here we have several simple names (list, std, vec, Vec, new), which include variable (list), module (std, vec), type (Vec) and method (new) names.

All of those have FQNs as well, the new method's FQN is explicitly stated as std::vec::Vec::new, the list variable's FQN can only be determined with knowledge of the surrounding package and module structure.

Declaration -- Usage

The names introduced above can be furthermore be separated into declarations (list) and usages (std::vec::Vec::new)

Declaration: A declaration is a statement which introduces a name into a scope.

Value Usage: A symbol name is used in an expression which requires evaluating (i.e. looking up) the symbol’s definition.

Type Usage: A type name is used by the compiler in a left-hand-side context to

  • ensure a value in a right-right-hand side context has the required type
  • avoid type propagation/inference across scopes

Security

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.

版本与发布记录

@aws/fully-qualified-names 共发布 17 个版本,首次发布于 2022/12/08;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.1.4latest2024/02/242 年前
2.1.32024/02/202 年前
2.1.22023/03/233 年前
2.1.12023/03/033 年前
2.1.02023/03/013 年前
2.0.62023/02/033 年前

关于 @aws/fully-qualified-names 的常见问题

@aws/fully-qualified-names 是什么?

For extracting def use statements from code.

如何安装 @aws/fully-qualified-names?

在项目目录运行 npm install @aws/fully-qualified-names,或使用 pnpm add / yarn add / bun add。

@aws/fully-qualified-names 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@aws/fully-qualified-names 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@aws/fully-qualified-names 可以商用吗?

@aws/fully-qualified-names 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@aws/fully-qualified-names 的下载量有多少?

根据 npm 官方下载统计,@aws/fully-qualified-names 在 2026/10/08 – 2026/11/06 这 30 天内被下载 2,697 次,日均约 90 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@aws/fully-qualified-names 还在维护吗?

最新版本 2.1.4 发布于 2024/02/24(2 年前);至今共发布 17 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/12/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。