Skip to main content
Version: 2.22

TypeAnnotation 类型标注

用于标注数据结构属性、逻辑的输入参数、输出参数、局部变量等概念的类型。

可以是用户自行选择的,也可以是 LanguageServer 推断的。

结构声明

interface TypeAnnotation {
"concept": "TypeAnnotation", // 产品概念
"typeKind": "primitive" | "reference" | "generic" | "typeParam" | "function" | "union" | "anonymousStructure", // 类型种类
"typeNamespace": string, // 类型命名空间
"typeName": string, // 类型名称
"typeArguments": Array<TypeAnnotation>, // 类型参数
"returnType": Array<TypeAnnotation>, // 返回类型
"inferred": boolean, // 是否是推断出来的
"properties": Array<StructureProperty>, // 匿名数据结构属性
"ruleMap": Object, // 规则对象
}

示例

PrimitiveTypes 原子类型

Boolean 布尔值

{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Boolean",
"typeArguments": null,
"inferred": null
}

Integer 整数

{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Integer",
"typeArguments": null,
"inferred": null
}

Long 长整数

{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"typeArguments": null,
"inferred": null
}

Double 小数

{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Double",
"typeArguments": null,
"inferred": null
}

Decimal 精确小数

{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Decimal",
"typeArguments": null,
"ruleMap": {
"scale": 0
},
"inferred": null
}

String 字符串

{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"typeArguments": null,
"inferred": null
}

Text 长文本

{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Text",
"typeArguments": null,
"inferred": null
}

Binary 二进制流

{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Binary",
"typeArguments": null,
"inferred": null
}

Date 日期

{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Date",
"typeArguments": null,
"inferred": null
}

Time 时间

{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Time",
"typeArguments": null,
"inferred": null
}

DateTime 日期时间

{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "DateTime",
"typeArguments": null,
"inferred": null
}

Email 电子邮箱

{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Email",
"typeArguments": null,
"inferred": null
}

ReferenceTypes 引用类型

实体

{
"concept": "TypeAnnotation",
"typeKind": "reference",
"typeNamespace": "app.dataSources.defaultDS.entities",
"typeName": "School",
"typeArguments": null,
"inferred": null
}

数据结构

{
"concept": "TypeAnnotation",
"typeKind": "reference",
"typeNamespace": "app.structures",
"typeName": "Student",
"typeArguments": null,
"inferred": null
}

枚举

{
"concept": "TypeAnnotation",
"typeKind": "reference",
"typeNamespace": "app.enums",
"typeName": "Status",
"typeArguments": null,
"inferred": null
}

Generic 泛型

{
"concept": "TypeAnnotation",
"typeKind": "generic",
"typeNamespace": "nasl.collection",
"typeName": "List",
"typeArguments": [{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Integer",
"typeArguments": null,
"inferred": null
}],
"inferred": null
}
{
"concept": "TypeAnnotation",
"typeKind": "generic",
"typeNamespace": "nasl.interface",
"typeName": "ScopeOf",
"typeArguments": [{
"concept": "TypeAnnotation",
"typeKind": "reference",
"typeNamespace": "app.dataSources.defaultDS.entities",
"typeName": "School",
"typeArguments": null,
"inferred": null
}],
"inferred": null
}
{
"concept": "TypeAnnotation",
"typeKind": "generic",
"typeNamespace": "nasl.collection",
"typeName": "List",
"typeArguments": [{
"concept": "TypeAnnotation",
"typeKind": "generic",
"typeNamespace": "nasl.collection",
"typeName": "List",
"typeArguments": [{
"concept": "TypeAnnotation",
"typeKind": "reference",
"typeNamespace": "app.structures",
"typeName": "Student",
"typeArguments": null,
"inferred": null
}],
"inferred": null
}],
"inferred": null
}