@amplication/ast-types

中文文档
0.0.2发布于 2025/03/20TypeScriptCommonJS零依赖近 30 天下载 80.9万

这个软件包为AST(Abstract Clicular Tree)节点和代码生成作者提供了常见的界面,在Ampression中使用了不同语言特有的AST软件包.

中文使用文档
文档目录8 节
  1. 接口
  2. IAst节点
  3. IWriter 编辑器
  4. 使用量
  5. 发展
  6. 大楼
  7. 测试
  8. 线性

@ ampress/ast 类型

这个软件包为AST(Abstract Clicular Tree)节点和代码生成作者提供了常见的界面,在Ampression中使用了不同语言特有的AST软件包.

接口

IAst节点

Amplex AST系统中所有AST节点的基础接口.

interface IAstNode {
  /**
   * Writes the AST node to the given writer.
   * @param writer The writer to write to
   */
  write(writer: IWriter): void;
}

IWriter 编辑器

用于处理适当缩进和格式化的代码生成作者的接口.

interface IWriter {
  /**
   * Writes text to the output buffer with proper indentation
   * @param text The text to write
   */
  write(text: string): void;

  /**
   * Writes an AST node to the output buffer
   * @param node The AST node to write
   */
  writeNode(node: IAstNode): void;

  /**
   * Writes text followed by a newline if the last line wasn't a newline
   * @param text Optional text to write before the newline
   */
  writeLine(text?: string): void;

  /**
   * Writes a newline to the output buffer
   */
  newLine(): void;

  /**
   * Writes a newline if the last line wasn't a newline
   */
  writeNewLineIfLastLineNot(): void;

  /**
   * Increases the indentation level
   */
  indent(): void;

  /**
   * Decreases the indentation level
   */
  dedent(): void;

  /**
   * Returns the current contents of the output buffer
   */
  toString(): string;
}

使用量

此软件包被语言特定 AST 软件包使用, 如 @amplication/csharp-ast 财务报告和审定财务报表 @amplication/java-ast 确保不同语言之间一致的AST节点和编剧执行.

特定语言包中的实例用法 :

import { IAstNode, IWriter } from '@amplication/ast-types';

export class MyAstNode implements IAstNode {
  write(writer: IWriter): void {
    writer.write('// My AST node implementation');
  }
}

发展

大楼

nx build ast-types

测试

nx test ast-types

线性

nx lint ast-types

版本与发布记录

@amplication/ast-types 共发布 2 个版本,首次发布于 2025/03/20;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.0.2latest2025/03/201.6 年前
0.0.12025/03/201.6 年前

关于 @amplication/ast-types 的常见问题

@amplication/ast-types 是什么?

这个软件包为AST(Abstract Clicular Tree)节点和代码生成作者提供了常见的界面,在Ampression中使用了不同语言特有的AST软件包.

如何安装 @amplication/ast-types?

在项目目录运行 npm install @amplication/ast-types,或使用 pnpm add / yarn add / bun add。

@amplication/ast-types 支持 TypeScript 吗?

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

@amplication/ast-types 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@amplication/ast-types 可以商用吗?

@amplication/ast-types 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@amplication/ast-types 的下载量有多少?

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

@amplication/ast-types 还在维护吗?

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