TypeAnnotation 类型标注
用于标注数据结构属性、逻辑的输入参数、输出参数、局部变量等概念的类型。
可以是用户自行选择的,也可以是 LanguageServer 推断的。
结构声明
- TS Declaration
- Java Class
- JSON Schema
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, // 规则对象
}
class TypeAnnotationTreeNode {
ConceptEnum concept; // 产品概念
TypeKindEnum typeKind; // 类型种类
String typeNamespace; // 类型命名空间
String typeName; // 类型名称
List<TypeAnnotationTreeNode> typeArguments; // 类型参数
List<TypeAnnotationTreeNode> returnType; // 返回类型
boolean inferred; // 是否是推断出来的
List<StructurePropertyTreeNode> properties; // 匿名数据结构属性
Object ruleMap; // 规则对象
}
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "#/definitions/TypeAnnotation",
"definitions": {
"TypeAnnotation": {
"type": "object",
"properties": {
"concept": {
"type": "string",
"const": "TypeAnnotation"
},
"typeKind": {
"type": "string",
"enum": [
"primitive",
"reference",
"generic",
"typeParam",
"function",
"union",
"anonymousStructure"
]
},
"typeNamespace": {
"type": "string"
},
"typeName": {
"type": "string"
},
"typeArguments": {
"type": "array",
"items": {
"$ref": "#/definitions/TypeAnnotation"
}
},
"returnType": {
"type": "array",
"items": {
"$ref": "#/definitions/TypeAnnotation"
}
},
"inferred": {
"type": "boolean"
},
"properties": {
"type": "array",
"items": {
"$ref": "#/definitions/StructureProperty"
}
},
"ruleMap": {
"type": "object",
"properties": {
"constructor": {
"type": "object",
"properties": {
"prototype": {},
"length": {
"type": "number"
},
"arguments": {},
"caller": {
"$ref": "#/definitions/interface-2073358172-9821-11285-2073358172-0-212510"
}
},
"required": [
"prototype",
"length",
"arguments",
"caller"
],
"additionalProperties": false
}
},
"required": [
"constructor"
],
"additionalProperties": false
}
},
"required": [
"concept",
"typeKind",
"typeNamespace",
"typeName",
"typeArguments",
"returnType",
"inferred",
"properties",
"ruleMap"
],
"additionalProperties": false
}
}
}
示例
PrimitiveTypes 原子类型
Boolean 布尔值
- JSON
- YAML
- Embedded in TS
{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Boolean",
"typeArguments": null,
"inferred": null
}
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: Boolean
typeArguments: null
inferred: null
var1: nasl.core.Boolean
Integer 整数
- JSON
- YAML
- Embedded in TS
{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Integer",
"typeArguments": null,
"inferred": null
}
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: Integer
typeArguments: null
inferred: null
var1: nasl.core.Integer
Long 长整数
- JSON
- YAML
- Embedded in TS
{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"typeArguments": null,
"inferred": null
}
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: Long
typeArguments: null
inferred: null
var1: nasl.core.Long
Double 小数
- JSON
- YAML
- Embedded in TS
{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Double",
"typeArguments": null,
"inferred": null
}
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: Double
typeArguments: null
inferred: null
var1: nasl.core.Double
Decimal 精确小数
- JSON
- YAML
- Embedded in TS
{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Decimal",
"typeArguments": null,
"ruleMap": {
"scale": 0
},
"inferred": null
}
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: Decimal
typeArguments: null
ruleMap:
scale: 0
inferred: null
var1: nasl.core.Decimal
String 字符串
- JSON
- YAML
- Embedded in TS
{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"typeArguments": null,
"inferred": null
}
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: String
typeArguments: null
inferred: null
var1: nasl.core.String
Text 长文本
- JSON
- YAML
- Embedded in TS
{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Text",
"typeArguments": null,
"inferred": null
}
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: Text
typeArguments: null
inferred: null
var1: nasl.core.Text
Binary 二进制流
- JSON
- YAML
- Embedded in TS
{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Binary",
"typeArguments": null,
"inferred": null
}
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: Binary
typeArguments: null
inferred: null
var1: nasl.core.Binary
Date 日期
- JSON
- YAML
- Embedded in TS
{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Date",
"typeArguments": null,
"inferred": null
}
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: Date
typeArguments: null
inferred: null
var1: nasl.core.Date
Time 时间
- JSON
- YAML
- Embedded in TS
{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Time",
"typeArguments": null,
"inferred": null
}
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: Time
typeArguments: null
inferred: null
var1: nasl.core.Time
DateTime 日期时间
- JSON
- YAML
- Embedded in TS
{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "DateTime",
"typeArguments": null,
"inferred": null
}
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: DateTime
typeArguments: null
inferred: null
var1: nasl.core.DateTime
Email 电子邮箱
- JSON
- YAML
- Embedded in TS
{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Email",
"typeArguments": null,
"inferred": null
}
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: Email
typeArguments: null
inferred: null
var1: nasl.core.Email
ReferenceTypes 引用类型
实体
- JSON
- YAML
- Embedded in TS
{
"concept": "TypeAnnotation",
"typeKind": "reference",
"typeNamespace": "app.dataSources.defaultDS.entities",
"typeName": "School",
"typeArguments": null,
"inferred": null
}
concept: TypeAnnotation
typeKind: reference
typeNamespace: app.dataSources.defaultDS.entities
typeName: School
typeArguments: null
inferred: null
var1: app.dataSources.defaultDS.entities.School
数据结构
- JSON
- YAML
- Embedded in TS
{
"concept": "TypeAnnotation",
"typeKind": "reference",
"typeNamespace": "app.structures",
"typeName": "Student",
"typeArguments": null,
"inferred": null
}
concept: TypeAnnotation
typeKind: reference
typeNamespace: app.structures
typeName: Student
typeArguments: null
inferred: null
var1: app.structures.Student
枚举
- JSON
- YAML
- Embedded in TS
{
"concept": "TypeAnnotation",
"typeKind": "reference",
"typeNamespace": "app.enums",
"typeName": "Status",
"typeArguments": null,
"inferred": null
}
concept: TypeAnnotation
typeKind: reference
typeNamespace: app.enums
typeName: Status
typeArguments: null
inferred: null
var1: app.enums.Status
Generic 泛型
- JSON
- YAML
- Embedded in TS
{
"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.collection
typeName: List
typeArguments:
- concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: Integer
typeArguments: null
inferred: null
inferred: null
var1: nasl.collection.List<nasl.core.Integer>
- JSON
- YAML
- Embedded in TS
{
"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.interface
typeName: ScopeOf
typeArguments:
- concept: TypeAnnotation
typeKind: reference
typeNamespace: app.dataSources.defaultDS.entities
typeName: School
typeArguments: null
inferred: null
inferred: null
var1: nasl.interface.ScopeOf<app.dataSources.defaultDS.entities.School>
- JSON
- YAML
- Embedded in TS
{
"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
}
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
var1: nasl.collection.List<nasl.collection.List<app.dataSources.defaultDS.entities.School>>