Skip to content

Commit 3c18a03

Browse files
committed
Remove 'custom' from annotation functions
1 parent 0363a55 commit 3c18a03

14 files changed

Lines changed: 52 additions & 52 deletions

File tree

src/transformation/transformers/access.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as ts from "typescript";
22
import * as tstl from "../../LuaAST";
33
import { transformBuiltinPropertyAccessExpression } from "../builtins";
44
import { FunctionVisitor, TransformationContext, TransformerPlugin } from "../context";
5-
import { AnnotationKind, getCustomTypeAnnotations } from "../utils/annotations";
5+
import { AnnotationKind, getTypeAnnotations } from "../utils/annotations";
66
import { createExpressionPlusOne } from "../utils/lua-ast";
77
import { isArrayType, isNumberType, isStringType } from "../utils/typescript";
88

@@ -50,7 +50,7 @@ const transformPropertyAccessExpression: FunctionVisitor<ts.PropertyAccessExpres
5050
const property = expression.name.text;
5151
const type = context.checker.getTypeAtLocation(expression.expression);
5252

53-
const annotations = getCustomTypeAnnotations(context, type);
53+
const annotations = getTypeAnnotations(context, type);
5454
// Do not output path for member only enums
5555
if (annotations.has(AnnotationKind.CompileMembersOnly)) {
5656
if (ts.isPropertyAccessExpression(expression.expression)) {

src/transformation/transformers/binary-expression/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as ts from "typescript";
22
import * as tstl from "../../../LuaAST";
33
import { FunctionVisitor, TransformationContext, TransformerPlugin } from "../../context";
4-
import { AnnotationKind, getCustomTypeAnnotations } from "../../utils/annotations";
4+
import { AnnotationKind, getTypeAnnotations } from "../../utils/annotations";
55
import { InvalidInstanceOfExtension, InvalidInstanceOfLuaTable, UnsupportedKind } from "../../utils/errors";
66
import { createImmediatelyInvokedFunctionExpression, wrapInToStringForConcat } from "../../utils/lua-ast";
77
import { LuaLibFeature, transformLuaLibFunction } from "../../utils/lualib";
@@ -172,7 +172,7 @@ const transformBinaryExpression: FunctionVisitor<ts.BinaryExpression> = (node, c
172172
const lhs = context.transformExpression(node.left);
173173
const rhs = context.transformExpression(node.right);
174174
const rhsType = context.checker.getTypeAtLocation(node.right);
175-
const annotations = getCustomTypeAnnotations(context, rhsType);
175+
const annotations = getTypeAnnotations(context, rhsType);
176176

177177
if (annotations.has(AnnotationKind.Extension) || annotations.has(AnnotationKind.MetaExtension)) {
178178
// Cannot use instanceof on extension classes

src/transformation/transformers/class/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as ts from "typescript";
22
import * as tstl from "../../../LuaAST";
33
import { getOrUpdate, isNonNull } from "../../../utils";
44
import { FunctionVisitor, TransformationContext, TransformerPlugin } from "../../context";
5-
import { AnnotationKind, getCustomTypeAnnotations } from "../../utils/annotations";
5+
import { AnnotationKind, getTypeAnnotations } from "../../utils/annotations";
66
import {
77
ForbiddenLuaTableNonDeclaration,
88
ForbiddenStaticClassPropertyName,
@@ -91,7 +91,7 @@ function transformClassDeclaration(
9191
}
9292
}
9393

94-
const annotations = getCustomTypeAnnotations(context, context.checker.getTypeAtLocation(classDeclaration));
94+
const annotations = getTypeAnnotations(context, context.checker.getTypeAtLocation(classDeclaration));
9595

9696
// Find out if this class is extension of existing class
9797
const extensionDirective = annotations.get(AnnotationKind.Extension);
@@ -112,15 +112,15 @@ function transformClassDeclaration(
112112

113113
if (!(isExtension || isMetaExtension) && extendsType) {
114114
// Non-extensions cannot extend extension classes
115-
const extendsAnnotations = getCustomTypeAnnotations(context, extendsType);
115+
const extendsAnnotations = getTypeAnnotations(context, extendsType);
116116
if (extendsAnnotations.has(AnnotationKind.Extension) || extendsAnnotations.has(AnnotationKind.MetaExtension)) {
117117
throw InvalidExtendsExtension(classDeclaration);
118118
}
119119
}
120120

121121
// You cannot extend LuaTable classes
122122
if (extendsType) {
123-
const annotations = getCustomTypeAnnotations(context, extendsType);
123+
const annotations = getTypeAnnotations(context, extendsType);
124124
if (annotations.has(AnnotationKind.LuaTable)) {
125125
throw InvalidExtendsLuaTable(classDeclaration);
126126
}

src/transformation/transformers/class/new.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as ts from "typescript";
22
import * as tstl from "../../../LuaAST";
33
import { FunctionVisitor, TransformationContext } from "../../context";
4-
import { AnnotationKind, getCustomTypeAnnotations } from "../../utils/annotations";
4+
import { AnnotationKind, getTypeAnnotations } from "../../utils/annotations";
55
import { InvalidAnnotationArgumentNumber, InvalidNewExpressionOnExtension } from "../../utils/errors";
66
import { importLuaLibFeature, LuaLibFeature } from "../../utils/lualib";
77
import { transformArguments } from "../call";
@@ -37,7 +37,7 @@ export const transformNewExpression: FunctionVisitor<ts.NewExpression> = (node,
3737

3838
checkForLuaLibType(context, type);
3939

40-
const annotations = getCustomTypeAnnotations(context, type);
40+
const annotations = getTypeAnnotations(context, type);
4141

4242
if (annotations.has(AnnotationKind.Extension) || annotations.has(AnnotationKind.MetaExtension)) {
4343
throw InvalidNewExpressionOnExtension(node);

src/transformation/transformers/class/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as ts from "typescript";
22
import { TransformationContext } from "../../context";
3-
import { AnnotationKind, getCustomTypeAnnotations } from "../../utils/annotations";
3+
import { AnnotationKind, getTypeAnnotations } from "../../utils/annotations";
44

55
export function isStaticNode(node: ts.Node): boolean {
66
return node.modifiers !== undefined && node.modifiers.some(m => m.kind === ts.SyntaxKind.StaticKeyword);
@@ -14,7 +14,7 @@ export function getExtendedTypeNode(
1414
for (const clause of node.heritageClauses) {
1515
if (clause.token === ts.SyntaxKind.ExtendsKeyword) {
1616
const superType = context.checker.getTypeAtLocation(clause.types[0]);
17-
const annotations = getCustomTypeAnnotations(context, superType);
17+
const annotations = getTypeAnnotations(context, superType);
1818
if (!annotations.has(AnnotationKind.PureAbstract)) {
1919
return clause.types[0];
2020
}

src/transformation/transformers/enum.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as ts from "typescript";
22
import * as tstl from "../../LuaAST";
33
import { FunctionVisitor, TransformationContext, TransformerPlugin } from "../context";
4-
import { AnnotationKind, getCustomTypeAnnotations } from "../utils/annotations";
4+
import { AnnotationKind, getTypeAnnotations } from "../utils/annotations";
55
import { getSymbolExportScope } from "../utils/export";
66
import { createLocalOrExportedOrGlobalDeclaration } from "../utils/lua-ast";
77
import { transformIdentifier } from "./identifier";
@@ -25,7 +25,7 @@ const transformEnumDeclaration: FunctionVisitor<ts.EnumDeclaration> = (node, con
2525
}
2626

2727
const type = context.checker.getTypeAtLocation(node);
28-
const membersOnly = getCustomTypeAnnotations(context, type).has(AnnotationKind.CompileMembersOnly);
28+
const membersOnly = getTypeAnnotations(context, type).has(AnnotationKind.CompileMembersOnly);
2929
const result: tstl.Statement[] = [];
3030

3131
if (!membersOnly) {

src/transformation/transformers/loops/for-of.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as ts from "typescript";
22
import * as tstl from "../../../LuaAST";
33
import { cast, castEach } from "../../../utils";
44
import { FunctionVisitor, TransformationContext, TransformerPlugin } from "../../context";
5-
import { AnnotationKind, getCustomTypeAnnotations, isForRangeType, isLuaIteratorType } from "../../utils/annotations";
5+
import { AnnotationKind, getTypeAnnotations, isForRangeType, isLuaIteratorType } from "../../utils/annotations";
66
import {
77
InvalidForRangeCall,
88
MissingForOfVariables,
@@ -115,7 +115,7 @@ function transformForOfLuaIteratorStatement(
115115
): tstl.Statement {
116116
const luaIterator = context.transformExpression(statement.expression);
117117
const type = context.checker.getTypeAtLocation(statement.expression);
118-
const tupleReturn = getCustomTypeAnnotations(context, type).has(AnnotationKind.TupleReturn);
118+
const tupleReturn = getTypeAnnotations(context, type).has(AnnotationKind.TupleReturn);
119119
if (tupleReturn) {
120120
// LuaIterator + TupleReturn
121121
if (ts.isVariableDeclarationList(statement.initializer)) {

src/transformation/transformers/lua-table.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as ts from "typescript";
22
import * as tstl from "../../LuaAST";
33
import { FunctionVisitor, TransformationContext, TransformerPlugin } from "../context";
4-
import { AnnotationKind, getCustomTypeAnnotations } from "../utils/annotations";
4+
import { AnnotationKind, getTypeAnnotations } from "../utils/annotations";
55
import { ForbiddenLuaTableUseException, UnsupportedKind, UnsupportedProperty } from "../utils/errors";
66
import { transformArguments } from "./call";
77

@@ -68,7 +68,7 @@ const transformExpressionStatement: FunctionVisitor<ts.ExpressionStatement> = (n
6868

6969
if (ts.isCallExpression(expression) && ts.isPropertyAccessExpression(expression.expression)) {
7070
const ownerType = context.checker.getTypeAtLocation(expression.expression.expression);
71-
const annotations = getCustomTypeAnnotations(context, ownerType);
71+
const annotations = getTypeAnnotations(context, ownerType);
7272
if (annotations.has(AnnotationKind.LuaTable)) {
7373
return transformLuaTableExpressionAsExpressionStatement(context, expression);
7474
}
@@ -97,7 +97,7 @@ function transformLuaTableCallExpression(
9797
const transformCallExpression: FunctionVisitor<ts.CallExpression> = (node, context) => {
9898
if (ts.isPropertyAccessExpression(node.expression) || ts.isElementAccessExpression(node.expression)) {
9999
const ownerType = context.checker.getTypeAtLocation(node.expression.expression);
100-
const annotations = getCustomTypeAnnotations(context, ownerType);
100+
const annotations = getTypeAnnotations(context, ownerType);
101101

102102
if (annotations.has(AnnotationKind.LuaTable)) {
103103
return transformLuaTableCallExpression(context, node);
@@ -109,7 +109,7 @@ const transformCallExpression: FunctionVisitor<ts.CallExpression> = (node, conte
109109

110110
const transformPropertyAccessExpression: FunctionVisitor<ts.PropertyAccessExpression> = (node, context) => {
111111
const type = context.checker.getTypeAtLocation(node.expression);
112-
const annotations = getCustomTypeAnnotations(context, type);
112+
const annotations = getTypeAnnotations(context, type);
113113
if (annotations.has(AnnotationKind.LuaTable)) {
114114
const [luaTable, propertyName] = parseLuaTableExpression(context, node);
115115
switch (node.name.text) {
@@ -124,7 +124,7 @@ const transformPropertyAccessExpression: FunctionVisitor<ts.PropertyAccessExpres
124124
};
125125

126126
const transformElementAccessExpression: FunctionVisitor<ts.ElementAccessExpression> = (node, context) => {
127-
const annotations = getCustomTypeAnnotations(context, context.checker.getTypeAtLocation(node.expression));
127+
const annotations = getTypeAnnotations(context, context.checker.getTypeAtLocation(node.expression));
128128
if (annotations.has(AnnotationKind.LuaTable)) {
129129
throw UnsupportedKind("LuaTable access expression", node.kind, node);
130130
}
@@ -134,7 +134,7 @@ const transformElementAccessExpression: FunctionVisitor<ts.ElementAccessExpressi
134134

135135
const transformNewExpression: FunctionVisitor<ts.NewExpression> = (node, context) => {
136136
const type = context.checker.getTypeAtLocation(node);
137-
const annotations = getCustomTypeAnnotations(context, type);
137+
const annotations = getTypeAnnotations(context, type);
138138
if (annotations.has(AnnotationKind.LuaTable)) {
139139
if (node.arguments && node.arguments.length > 0) {
140140
throw ForbiddenLuaTableUseException("No parameters are allowed when constructing a LuaTable object.", node);

src/transformation/transformers/modules/import.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as path from "path";
22
import * as ts from "typescript";
33
import * as tstl from "../../../LuaAST";
44
import { FunctionVisitor, TransformationContext, TransformerPlugin } from "../../context";
5-
import { AnnotationKind, getCustomSymbolAnnotations, getCustomTypeAnnotations } from "../../utils/annotations";
5+
import { AnnotationKind, getSymbolAnnotations, getTypeAnnotations } from "../../utils/annotations";
66
import { UnresolvableRequirePath } from "../../utils/errors";
77
import { createDefaultExportStringLiteral } from "../../utils/export";
88
import { createHoistableVariableDeclarationStatement } from "../../utils/lua-ast";
@@ -49,7 +49,7 @@ function shouldResolveModulePath(context: TransformationContext, moduleSpecifier
4949
const moduleOwnerSymbol = context.checker.getSymbolAtLocation(moduleSpecifier);
5050
if (!moduleOwnerSymbol) return true;
5151

52-
const annotations = getCustomSymbolAnnotations(context, moduleOwnerSymbol);
52+
const annotations = getSymbolAnnotations(context, moduleOwnerSymbol);
5353
return !annotations.has(AnnotationKind.NoResolution);
5454
}
5555

@@ -76,7 +76,7 @@ export function createModuleRequire(
7676
}
7777

7878
function shouldBeImported(context: TransformationContext, importNode: ts.ImportClause | ts.ImportSpecifier): boolean {
79-
const annotations = getCustomTypeAnnotations(context, context.checker.getTypeAtLocation(importNode));
79+
const annotations = getTypeAnnotations(context, context.checker.getTypeAtLocation(importNode));
8080

8181
return (
8282
context.resolver.isReferencedAliasDeclaration(importNode) &&

src/transformation/transformers/namespace.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as ts from "typescript";
22
import * as tstl from "../../LuaAST";
33
import { FunctionVisitor, TransformationContext, TransformerPlugin } from "../context";
4-
import { AnnotationKind, getCustomTypeAnnotations } from "../utils/annotations";
4+
import { AnnotationKind, getTypeAnnotations } from "../utils/annotations";
55
import { addExportToIdentifier, createExportedIdentifier, getIdentifierExportScope } from "../utils/export";
66
import {
77
createHoistableVariableDeclarationStatement,
@@ -50,7 +50,7 @@ const currentNamespaces = new WeakMap<TransformationContext, ts.ModuleDeclaratio
5050
export const getCurrentNamespace = (context: TransformationContext) => currentNamespaces.get(context);
5151

5252
const transformModuleDeclaration: FunctionVisitor<ts.ModuleDeclaration> = (node, context) => {
53-
const annotations = getCustomTypeAnnotations(context, context.checker.getTypeAtLocation(node));
53+
const annotations = getTypeAnnotations(context, context.checker.getTypeAtLocation(node));
5454
// If phantom namespace elide the declaration and return the body
5555
if (annotations.has(AnnotationKind.Phantom) && node.body && ts.isModuleBlock(node.body)) {
5656
return context.transformStatements(node.body.statements);

0 commit comments

Comments
 (0)