@@ -3,13 +3,12 @@ import * as lua from "../../LuaAST";
33import { transformBuiltinPropertyAccessExpression } from "../builtins" ;
44import { FunctionVisitor , TransformationContext } from "../context" ;
55import { AnnotationKind , getTypeAnnotations } from "../utils/annotations" ;
6- import { invalidMultiReturnAccess , optionalChainingNotSupported } from "../utils/diagnostics" ;
6+ import { annotationRemoved , invalidMultiReturnAccess , optionalChainingNotSupported } from "../utils/diagnostics" ;
77import { addToNumericExpression } from "../utils/lua-ast" ;
88import { LuaLibFeature , transformLuaLibFunction } from "../utils/lualib" ;
99import { isArrayType , isNumberType , isStringType } from "../utils/typescript" ;
1010import { tryGetConstEnumValue } from "./enum" ;
1111import { returnsMultiType } from "./language-extensions/multi" ;
12- import { transformLuaTablePropertyAccessExpression , validateLuaTableElementAccessExpression } from "./lua-table" ;
1312
1413export function transformElementAccessArgument (
1514 context : TransformationContext ,
@@ -27,8 +26,6 @@ export function transformElementAccessArgument(
2726}
2827
2928export const transformElementAccessExpression : FunctionVisitor < ts . ElementAccessExpression > = ( node , context ) => {
30- validateLuaTableElementAccessExpression ( context , node ) ;
31-
3229 const constEnumValue = tryGetConstEnumValue ( context , node ) ;
3330 if ( constEnumValue ) {
3431 return constEnumValue ;
@@ -59,53 +56,50 @@ export const transformElementAccessExpression: FunctionVisitor<ts.ElementAccessE
5956 return lua . createTableIndexExpression ( table , accessExpression , node ) ;
6057} ;
6158
62- export const transformPropertyAccessExpression : FunctionVisitor < ts . PropertyAccessExpression > = (
63- expression ,
64- context
65- ) => {
66- if ( ts . isOptionalChain ( expression ) ) {
67- context . diagnostics . push ( optionalChainingNotSupported ( expression ) ) ;
59+ export const transformPropertyAccessExpression : FunctionVisitor < ts . PropertyAccessExpression > = ( node , context ) => {
60+ const property = node . name . text ;
61+ const type = context . checker . getTypeAtLocation ( node . expression ) ;
62+
63+ const annotations = getTypeAnnotations ( type ) ;
64+
65+ if ( annotations . has ( AnnotationKind . LuaTable ) ) {
66+ context . diagnostics . push ( annotationRemoved ( node , AnnotationKind . LuaTable ) ) ;
6867 }
6968
70- const constEnumValue = tryGetConstEnumValue ( context , expression ) ;
71- if ( constEnumValue ) {
72- return constEnumValue ;
69+ if ( ts . isOptionalChain ( node ) ) {
70+ context . diagnostics . push ( optionalChainingNotSupported ( node ) ) ;
7371 }
7472
75- const luaTableResult = transformLuaTablePropertyAccessExpression ( context , expression ) ;
76- if ( luaTableResult ) {
77- return luaTableResult ;
73+ const constEnumValue = tryGetConstEnumValue ( context , node ) ;
74+ if ( constEnumValue ) {
75+ return constEnumValue ;
7876 }
7977
80- const builtinResult = transformBuiltinPropertyAccessExpression ( context , expression ) ;
78+ const builtinResult = transformBuiltinPropertyAccessExpression ( context , node ) ;
8179 if ( builtinResult ) {
8280 return builtinResult ;
8381 }
8482
85- if ( ts . isCallExpression ( expression . expression ) && returnsMultiType ( context , expression . expression ) ) {
86- context . diagnostics . push ( invalidMultiReturnAccess ( expression ) ) ;
83+ if ( ts . isCallExpression ( node . expression ) && returnsMultiType ( context , node . expression ) ) {
84+ context . diagnostics . push ( invalidMultiReturnAccess ( node ) ) ;
8785 }
8886
89- const property = expression . name . text ;
90- const type = context . checker . getTypeAtLocation ( expression . expression ) ;
91-
92- const annotations = getTypeAnnotations ( type ) ;
9387 // Do not output path for member only enums
9488 if ( annotations . has ( AnnotationKind . CompileMembersOnly ) ) {
95- if ( ts . isPropertyAccessExpression ( expression . expression ) ) {
89+ if ( ts . isPropertyAccessExpression ( node . expression ) ) {
9690 // in case of ...x.enum.y transform to ...x.y
9791 return lua . createTableIndexExpression (
98- context . transformExpression ( expression . expression . expression ) ,
92+ context . transformExpression ( node . expression . expression ) ,
9993 lua . createStringLiteral ( property ) ,
100- expression
94+ node
10195 ) ;
10296 } else {
103- return lua . createIdentifier ( property , expression ) ;
97+ return lua . createIdentifier ( property , node ) ;
10498 }
10599 }
106100
107- const callPath = context . transformExpression ( expression . expression ) ;
108- return lua . createTableIndexExpression ( callPath , lua . createStringLiteral ( property ) , expression ) ;
101+ const callPath = context . transformExpression ( node . expression ) ;
102+ return lua . createTableIndexExpression ( callPath , lua . createStringLiteral ( property ) , node ) ;
109103} ;
110104
111105export const transformQualifiedName : FunctionVisitor < ts . QualifiedName > = ( node , context ) => {
0 commit comments