All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Diagnostic LUA1019: "Goto statements and labels are not supported in this lua version".
- Support for floor division assignments (
//=) by @toxamin in #157. - Support for underlines before the number base prefix by @toxamin in #156.
- Fixed parsing of Luau type casts (
::) whenAcceptGotois false by @Fiusen in #164. - Parsing of empty return statements at the end of the file by @toxamin in #148.
- Implemented support for Luau interpolated strings by @GGG-KILLER in #138.
- New diagnostics:
- LUA0033: Interpolated strings must start with the backtick character: `.
- LUA0034: Interpolated strings expressions must have a corresponding closing '}' for every opening '{'.
- LUA0035: Double braces have no meaning, did you mean to escape an opening brace with '\{'?
- LUA0036: Interpolated strings are not supported in this lua version.
- New nodes:
InterpolatedStringContentSyntax: base node for the parts of the interpolated strings.InterpolatedStringTextSyntax: Plain text part of the interpolated strings.InterpolationSyntax: the expression "holes" that will be interpolated into the string.InterpolatedStringExpressionSyntax: The expression mode for interpolated strings that contains the quotes and parts of the interpolated string.
- New diagnostics:
- Added the
BacktickStringTypesetting toLuaSyntaxOptionsto switch between interpolated strings, hash strings and neither by @GGG-KILLER in #138. - Added new node
FunctionTypeParameterSyntaxthat represents a parameter to a function type/signature by @GGG-KILLER in #145.
- Identifier tokens now never have a
ContextualKindby @GGG-KILLER in #134. - [Breaking]
LuaSyntaxOptions.Luauhas been modified to enable floor division by @GGG-KILLER in #133. - [Breaking] Fixed the way invalid statement diagnostics are generated by changing them to be generated on the skipped token instead of on the full missing identifier node by @GGG-KILLER in #135.
- [Breaking]
LuaSyntaxOptions.Allnow accepts interpolated strings instead of hash strings by @GGG-KILLER in #138. - [Breaking]
FunctionTypeSyntax.Parameters(and associated method parameters) have been switched from aSeparatedSyntaxList<TypeSyntax>into aSeparatedSyntaxList<FunctionTypeParameterSyntax>by @GGG-KILLER in #145. - [Breaking]
SyntaxFactory.FunctionTypenow accepts aSeparatedSyntaxList<FunctionTypeParameterSyntax>instead of aSeparatedSyntaxList<TypeSyntax>by @GGG-KILLER in #145. - [Breaking] Strings end at unescaped line break instead of generating warnings and continuing until the next quote or EOF @GGG-KILLER in #146.
- Deprecated
LuaSyntaxOptions.AcceptHashStringsin favor ofLuaSyntaxOptions.BacktickStringTypeby @GGG-KILLER in #138.
acceptHashStringshas been removed fromLuaSyntaxOptionsconstructor and.Within favor ofbacktickStringTypeby @GGG-KILLER in #138.- Diagnostic LUA0029 (Hash strings are not supported in this lua version) has been removed (and replaced with LUA0036) by @GGG-KILLER in #138.
- Diagnostic LUA0002 (Unescaped line break in string) has been removed by @GGG-KILLER in #146.
- Fixed
continuestill being parsed as a keyword even whenContinueTypewasContinueType.Noneby @GGG-KILLER in #134; - Fixed
gotoand::label::still being parsed whenAcceptGotowasfalseby @GGG-KILLER in #134. - Fixed
typenot being interpreted as a contextual keyword by @GGG-KILLER in #144.
- Fixed
LuaSyntaxOptions.AcceptInvalidEscapesnot suppressing errors in cases whereLuaSyntaxOptions.{AcceptWhitespaceEscape,AcceptHexEscapesInStrings,AcceptUnicodeEscape}werefalseby @TheGreatSageEqualToHeaven in #116. - Fixed single line comments not getting a line break added after them in
NormalizeWhitespaceby @GGG-KILLER in #118. - Fixed warnings being generated for hex numbers on Lua 5.1, Lua 5.2 and other presets where
HexIntegerFormatwasNotSupportedandAcceptHexFloatLiteralswasfalseby @GGG-KILLER. - Fixed the
SyntaxNormalizerturning nested negation expressions into comments by @GGG-KILLER.
- Removed
LanguageNames.{CSharp,FSharp,VisualBasic}by @GGG-KILLER in #115.
- The
Loretta.CodeAnalysis.FileLinePositionSpanhas been made intoreadonly structs by @GGG-KILLER in #115.
- Fixed
ContainedScopesnot being populated. - Fixed NormalizeWhitespace not inserting spaces between expression list arguments.
- .NET Core 3.1 support has been removed as .NET Core 3.1 has officially hit EOL.
- Added the following new
SyntaxFactoryoverloads to partially restore compatibility with pre-typed-lua era:SyntaxFactory.AnonymousFunctionExpression(ParameterListSyntax parameters, StatementListSyntax body);SyntaxFactory.FunctionDeclarationStatement(FunctionNameSyntax name, ParameterListSyntax parameters, StatementListSyntax body);SyntaxFactory.LocalDeclarationName(IdentifierNameSyntax identifierName, VariableAttributeSyntax? attribute);SyntaxFactory.LocalDeclarationName(string name, VariableAttributeSyntax? attribute);SyntaxFactory.LocalFunctionDeclarationStatement(SyntaxToken localKeyword, SyntaxToken functionKeyword, IdentifierNameSyntax name, ParameterListSyntax parameters, StatementListSyntax body, SyntaxToken endKeyword, SyntaxToken semicolonToken);SyntaxFactory.NumericForStatement(IdentifierNameSyntax identifier, ExpressionSyntax initialValue, ExpressionSyntax finalValue, ExpressionSyntax? stepValue, StatementListSyntax body);SyntaxFactory.NumericForStatement(SyntaxToken forKeyword, IdentifierNameSyntax identifier, SyntaxToken equalsToken, ExpressionSyntax initialValue, SyntaxToken finalValueCommaToken, ExpressionSyntax finalValue, SyntaxToken stepValueCommaToken, ExpressionSyntax? stepValue, SyntaxToken doKeyword, StatementListSyntax body, SyntaxToken endKeyword, SyntaxToken semicolonToken);SyntaxFactory.NumericForStatement(string identifier, ExpressionSyntax initialValue, ExpressionSyntax finalValue, ExpressionSyntax? stepValue, StatementListSyntax body);SyntaxFactory.NumericForStatement(string identifier, ExpressionSyntax initialValue, ExpressionSyntax finalValue).
- Added support for typed Lua in
.NormalizeWhitespace; - Added support for local variable attributes in
.NormalizeWhitespace; - Added the new
SyntaxFactory.MethodFunctionName(FunctionNameSyntax baseName, string name)overload. - Added support for Lua 5.1's long string nesting error.
- [Breaking] The following SyntaxFactory overloads have been changed:
SyntaxFactory.NumericForStatement(TypedIdentifierNameSyntax identifier, ExpressionSyntax initialValue, ExpressionSyntax finalValue)has been changed to always require the loop's body (intoSyntaxFactory.NumericForStatement(TypedIdentifierNameSyntax identifier, ExpressionSyntax initialValue, ExpressionSyntax finalValue, StatementListSyntax body));SyntaxFactory.NumericForStatement(string identifier, ExpressionSyntax initialValue, ExpressionSyntax finalValue)has been changed to always require the loop's body (intoSyntaxFactory.NumericForStatement(string identifier, ExpressionSyntax initialValue, ExpressionSyntax finalValue, StatementListSyntax body));SyntaxFactory.IfStatement(ExpressionSyntax condition)has been changed to always require the clause's body (intoSyntaxFactory.IfStatement(ExpressionSyntax condition, StatementListSyntax body));SyntaxFactory.ElseClause(StatementListSyntax? elseBody = default)has been changed for the body to always be required (intoSyntaxFactory.ElseClause(StatementListSyntax elseBody));SyntaxFactory.LocalFunctionDeclarationStatement(IdentifierNameSyntax name)has been changed to always require the parameter list and function's body (intoSyntaxFactory.LocalFunctionDeclarationStatement(IdentifierNameSyntax name, ParameterListSyntax parameters, StatementListSyntax body));SyntaxFactory.LocalFunctionDeclarationStatement(string name)has been changed to always require the parameter list and function's body (intoLocalFunctionDeclarationStatement(string name, ParameterListSyntax parameters, StatementListSyntax body));SyntaxFactory.FunctionDeclarationStatement(FunctionNameSyntax name)has been changed to always require the parameter list and the function's body (intoSyntaxFactory.FunctionDeclarationStatement(FunctionNameSyntax name, ParameterListSyntax parameters, StatementListSyntax body));SyntaxFactory.DoStatement(StatementListSyntax? body = default)has been changed to make the body always required (intoSyntaxFactory.DoStatement(StatementListSyntax body));SyntaxFactory.CompilationUnit(StatementListSyntax? statements = default)has been changed to make the body always required (intoSyntaxFactory.CompilationUnit(StatementListSyntax statements)).
- Changed the existing handling of certain constructs in
.NormalizeWhitespace:- Tables are now kept in a single line unless one of its fields spans more than one line;
- Spaces are not added to a table if it has no elements;
- No unnecessary line breaks are added after statements anymore.
- [Breaking]
SyntaxFactory.IdentifierNamewill now throw an exception if the provided token is not an identifier. - [Breaking] The following have been changed as a result of the Lua 5.1 long string nesting error:
LuaSyntaxOptions's constructor and.Withmethod have been changed to accept the newAcceptNestingOfLongStringsoption.- An error is now generated when long strings are nested and
LuaSyntaxOptions.AcceptNestingOfLongStringsisfalse.
- [Breaking] The following have been removed:
SyntaxFactory.AnonymousFunctionExpression()(as the parameter list and function's body should always be required);SyntaxFactory.GenericForStatement(SeparatedSyntaxList<TypedIdentifierNameSyntax> identifiers, SeparatedSyntaxList<ExpressionSyntax> expressions)(as the loop's body should always be required);SyntaxFactory.WhileStatement(ExpressionSyntax condition)(as the loop's body should always be required);SyntaxFactory.RepeatUntilStatement(ExpressionSyntax condition)(as the loop's body should always be required);SyntaxFactory.ElseIfClause(ExpressionSyntax condition)(as theelseifclause should always be required);
- [Breaking] The
SyntaxKind.StartEqualsTokenhas been removed as it has been obsolete for a while.
- Fixed a bug where the leading new line was included for long strings;
- Fixed a bug where
ObjectDisplay.FormatLiteral(string value, ObjectDisplayOptions options)would escape the space character; - Fixed a bug where
ObjectDisplay.FormatLiteral(string value, ObjectDisplayOptions options)would not generate correct verbatim/long strings; - Fixed parsing of anonymous functions that had type parameters;
- Fixed union and intersection types having errors for bitwise operators generated in them.
- We've added support for LuaJIT imaginary numbers which also resulted in the following being added:
SyntaxFactory.Literal(Complex value);SyntaxFactory.Literal(string text, Complex value);SyntaxFactory.Literal(SyntaxTriviaList leading, string text, Complex value, SyntaxTriviaList trailing);ObjectDisplay.FormatLiteral(Complex value, ObjectDisplayOptions options, CultureInfo? cultureInfo = null).
- [Breaking] We've reviewed the existing
LuaSyntaxOptionspresets and the following were fixed:- Changed the Lua 5.1 preset to accept shebangs;
- Changed the Lua 5.1 preset to not accept
ifexpressions; - Changed the Lua 5.2 preset to accept shebangs;
- Changed the Lua 5.2 preset to not accept
ifexpressions; - Changed the Lua 5.3 preset to accept shebangs;
- Changed the Lua 5.3 preset to not accept
ifexpressions; - Changed the Lua 5.3 preset to accept floor division;
- Changed the Lua 5.4 preset to accept shebangs;
- Changed the Lua 5.4 preset to not accept
ifexpressions; - Changed the Lua 5.4 preset to accept floor division;
- Changed the LuaJIT 2.0 preset to not accept empty statements;
- Changed the LuaJIT 2.0 preset to accept shebangs;
- Changed the LuaJIT 2.1 preset to not accept empty statements;
- Changed the LuaJIT 2.1 preset to accept shebangs;
- Changed the FiveM preset to accept shebangs;
- Changed the FiveM preset to not accept
ifexpressions; - Changed the FiveM preset to accept floor division;
- Changed the Luau preset to not accept hex float literals;
- Changed the Luau preset to accept shebangs;
- Changed the Luau preset to not accept bitwise operators.
- Fixed
ObjectDisplay.FormatPrimitive(object? obj, ObjectDisplayOptions options)returningnullforlongs andulongs. - Fixed LuaJIT suffixes not being handled in a case-insensitive manner.
- Fixed empty type argument lists not being accepted.
- Added
LuaSyntaxOptions.AcceptLuaJITNumberSuffixes. - Added
SyntaxFactory.Literal(ulong value). - Added
SyntaxFactory.Literal(string text, ulong value). - Added support for
ULLandLLsuffixes from LuaJIT.
- Fixed
ObjectDisplay.FormatLiteral(long value, ObjectDisplayOptions options, CultureInfo? cultureInfo = null)returning numbers in hex for longs.
- Changed
LuaSyntaxOptions.ToStringto returnAcceptLuaJITNumberSuffixes
- Added
LuaSyntaxOptions.Luau.
- Changed
LuaSyntaxOptions.ToStringto return"Luau"for the luau preset.
- Fixed a bug with incremental parsing where a
System.InvalidCastExceptionwas thrown fromLoretta.CodeAnalysis.Lua.Syntax.InternalSyntax.Blender.Reader.CanReuse.
- Typed Lua Support.
- The following were added as a part of implementing typed-luau:
Loretta.CodeAnalysis.Lua.Syntax.TypeSyntax;Loretta.CodeAnalysis.Lua.Syntax.TypeBindingSyntax;Loretta.CodeAnalysis.Lua.Syntax.NilableTypeSyntax;Loretta.CodeAnalysis.Lua.Syntax.ParenthesizedTypeSyntax;Loretta.CodeAnalysis.Lua.Syntax.TypePackSyntax;Loretta.CodeAnalysis.Lua.Syntax.FunctionTypeSyntax;Loretta.CodeAnalysis.Lua.Syntax.TableBasedTypeSyntax;Loretta.CodeAnalysis.Lua.Syntax.TableTypeElementSyntax;Loretta.CodeAnalysis.Lua.Syntax.TableTypePropertySyntax;Loretta.CodeAnalysis.Lua.Syntax.TableTypeSyntax;Loretta.CodeAnalysis.Lua.Syntax.TypeCastExpressionSyntax;Loretta.CodeAnalysis.Lua.Syntax.UnionTypeSyntax;Loretta.CodeAnalysis.Lua.Syntax.IntersectionTypeSyntax;Loretta.CodeAnalysis.Lua.Syntax.EqualsTypeSyntax;Loretta.CodeAnalysis.Lua.Syntax.TypeParameterSyntax;Loretta.CodeAnalysis.Lua.Syntax.TypeParameterListSyntax;Loretta.CodeAnalysis.Lua.Syntax.TypeArgumentListSyntax;Loretta.CodeAnalysis.Lua.Syntax.TypeNameSyntax;Loretta.CodeAnalysis.Lua.Syntax.CompositeTypeNameSyntax;Loretta.CodeAnalysis.Lua.Syntax.LiteralTypeSyntax;Loretta.CodeAnalysis.Lua.Syntax.TypeofTypeSyntax;Loretta.CodeAnalysis.Lua.Syntax.VariadicTypePackSyntax;Loretta.CodeAnalysis.Lua.Syntax.GenericTypePackSyntax;Loretta.CodeAnalysis.Lua.Syntax.TypedIdentifierNameSyntax;LuaSyntaxOptions.AcceptTypedLua.
- [Breaking] The following were changed as a result of implementing typed Lua syntax:
LuaSyntaxOptions's constructor andWithwere changed to accept a bool forAcceptTypedLua;- The following were changed to accept a
TypeBindingSyntax:AnonymousFunctionExpressionSyntax.Update;FunctionDeclarationStatementSyntax.Update;LocalDeclarationNameSyntax.Update;LocalFunctionDeclarationStatementSyntax.Update;NamedParameterSyntax.Update;VarArgParameterSyntax.Update;SyntaxFactory.AnonymousFunctionExpression;SyntaxFactory.FunctionDeclarationStatement;SyntaxFactory.LocalDeclarationName;SyntaxFactory.LocalFunctionDeclarationStatement;SyntaxFactory.VarArgParameter.
- The following were changed to accept a
TypeParameterListSyntax:AnonymousFunctionExpressionSyntax.Update;FunctionDeclarationStatementSyntax.Update;LocalFunctionDeclarationStatementSyntax.Update;SyntaxFactory.AnonymousFunctionExpression;SyntaxFactory.FunctionDeclarationStatement;SyntaxFactory.LocalFunctionDeclarationStatement.
- The following were changed to accept (or be) a
TypedIdentifierNameSyntax:GenericForStatementSyntax.AddIdentifiers;GenericForStatementSyntax.Identifiers;GenericForStatementSyntax.Update;GenericForStatementSyntax.WithIdentifiers;NumericForStatementSyntax.Identifier;NumericForStatementSyntax.Update;NumericForStatementSyntax.WithIdentifier;SyntaxFactory.GenericForStatement;SyntaxFactory.NumericForStatement.
- Added
ConstantFoldingOptionswith the option to enable number extraction from strings.
- [Breaking] Changed
ConstantFoldextension method to accept aConstantFoldingOptions.
- Fixed
SyntaxFacts.GetConstantValuenot returning the correct value for tokens. - Fixed
SyntaxFacts.GetConstantValuenot returningNonefor values outside the valid range. - Fixed the constant folder turning
/into integer division when both sides are integers. - Fixed the constant folder storing the length as an integer token.
- Fixed
LuaSyntaxNode.GetStructurethrowing an exception because we do have structured trivia.
- Optimized the lexing process with a reduction of 80% in lexing time and 76% in parsing time.
- Added support for string length to the constant folder.
- The following were added as a part of implementing local variable attributes:
Loretta.CodeAnalysis.Lua.Syntax.LocalDeclarationNameSyntax;SyntaxKind.LocalDeclarationName;SyntaxFactory.LocalDeclarationName;LuaSyntaxVisitor.VisitLocalDeclarationName;LuaSyntaxVisitor<TResult>.VisitLocalDeclarationName;LuaSyntaxRewriter.VisitLocalDeclarationName;Loretta.CodeAnalysis.Lua.Syntax.VariableAttributeSyntax;SyntaxKind.VariableAttribute;SyntaxFactory.VariableAttribute;LuaSyntaxVisitor.VisitVariableAttribute;LuaSyntaxVisitor<TResult>.VisitVariableAttribute;LuaSyntaxRewriter.VisitVariableAttribute;LuaSyntaxOptions.AcceptLocalVariableAttributes;LuaSyntaxOptions.Lua54preset.
- Added
SyntaxFactory.HashStringfor creating FiveM hash string literal tokens. - The following were added as part of implementing integers:
IntegerFormats;LuaSyntaxOptions.AllWithIntegers;LuaSyntaxOptions.BinaryIntegerFormat;LuaSyntaxOptions.OctalIntegerFormat;LuaSyntaxOptions.DecimalIntegerFormat;LuaSyntaxOptions.HexIntegerFormat;ObjectDisplay.FormatLiteral(long value, ObjectDisplayOptions options, CultureInfo? cultureInfo = null);- IMPORTANT:
SyntaxFactory.Literal(long value); - IMPORTANT:
SyntaxFactory.Literal(string text, long value); - IMPORTANT:
SyntaxFactory.Literal(SyntaxTriviaList leading, string text, long value, SyntaxTriviaList trailing).
- Constant folder now attempts to preserve trivia around nodes that were folded.
- [Breaking] The following were changed as a result of implementing local variable attributes:
LocalVariableDeclarationStatementSyntax.Namesnow returns aSeparatedSyntaxList<LocalDeclarationNameSyntax>instead ofSeparatedSyntaxList<IdentifierNameSyntax>;LocalVariableDeclarationStatementSyntax.Updatenow receives aSeparatedSyntaxList<LocalDeclarationNameSyntax>instead ofSeparatedSyntaxList<IdentifierNameSyntax>;LocalVariableDeclarationStatementSyntax.AddNamesnow receives aparams LocalDeclarationNameSyntax[]instead ofparams IdentifierNameSyntax[];LocalVariableDeclarationStatementSyntax.WithNamesnow receives aSeparatedSyntaxList<LocalDeclarationNameSyntax>instead ofSeparatedSyntaxList<IdentifierNameSyntax>;SyntaxFactory.LocalVariableDeclarationStatementoverloads now receive aSeparatedSyntaxList<LocalDeclarationNameSyntax>instead ofSeparatedSyntaxList<IdentifierNameSyntax>;LuaSyntaxOptionsconstructor andWithmethod now accept anacceptLocalVariableAttributesparameter.
- [Breaking] The following were changed as a result of implementing integers:
- The Lua 5.3 preset was changed to accept integers;
- IMPORTANT:
SyntaxToken.Valuenow can be alongwhen any of the*IntegerFormatsettings are set toIntegerFormats.Int64; LuaSyntaxOptionsconstructor andWithmethod now accept 4IntegerFormatsfor each number format (binary, octal, decimal and hexadecimal);- The constant folder was modified to support integers.
- Fixed
Minifydouble-freeing a slot.
- Fixed
Minifyrenaming variables that were being used incorrectly. - Fixed
Minifynot adding a leading_for certain variable names. - Fixed
Minifyadding prefixes for variable names that were already renamed.
- [Breaking] The following were changed as a result of the move to
EqualsValuesClauseSyntax:- Replaced
EqualsTokenandValuesinAssignmentStatementSyntaxbyEqualsValues; - Replaced
EqualsTokenandValuesinLocalVariableDeclarationStatementSyntaxbyEqualsValues.
- Replaced
- [Breaking]
SyntaxFactorymethods will now throw exceptions if the lists provided to them do not have the minimum amount of items required. - [Breaking]
NamingStrategywas changed to receive a list ofIScopes instead of a single one. The received scopes are the scopes where the variable is accessed in. - [Breaking] The following strategies were changed as a result of the above:
NamingStrategies.Alphabetic;NamingStrategies.Numeric;NamingStrategies.ZeroWidth.
- [Breaking] The following were removed as a result of the move to
EqualsValuesClauseSyntax:AssignmentStatementSyntax.EqualsToken;AssignmentStatementSyntax.Values;AssignmentStatementSyntax.Update(SeparatedSyntaxList<PrefixExpressionSyntax> variables, SyntaxToken equalsToken, SeparatedSyntaxList<ExpressionSyntax> values, SyntaxToken semicolonToken);AssignmentStatementSyntax.AddValues(params ExpressionSyntax[] items);AssignmentStatementSyntax.WithEqualsToken(SyntaxToken equalsToken);AssignmentStatementSyntax.WithValues(SeparatedSyntaxList<ExpressionSyntax> values);LocalVariableDeclarationStatementSyntax.AddValues(params ExpressionSyntax[] items);LocalVariableDeclarationStatementSyntax.EqualsToken;LocalVariableDeclarationStatementSyntax.Update(SyntaxToken localKeyword, SeparatedSyntaxList<IdentifierNameSyntax> names, SyntaxToken equalsToken, SeparatedSyntaxList<ExpressionSyntax> values, SyntaxToken semicolonToken);LocalVariableDeclarationStatementSyntax.Values;LocalVariableDeclarationStatementSyntax.WithEqualsToken(SyntaxToken equalsToken);LocalVariableDeclarationStatementSyntax.WithValues(SeparatedSyntaxList<ExpressionSyntax> values);SyntaxFactory.AssignmentStatement();SyntaxFactory.AssignmentStatement(SeparatedSyntaxList<PrefixExpressionSyntax> variables, SyntaxToken equalsToken, SeparatedSyntaxList<ExpressionSyntax> values, SyntaxToken semicolonToken);SyntaxFactory.LocalVariableDeclarationStatement();SyntaxFactory.LocalVariableDeclarationStatement(SeparatedSyntaxList<IdentifierNameSyntax> names, SeparatedSyntaxList<ExpressionSyntax> values);SyntaxFactory.LocalVariableDeclarationStatement(SyntaxToken localKeyword, SeparatedSyntaxList<IdentifierNameSyntax> names, SyntaxToken equalsToken, SeparatedSyntaxList<ExpressionSyntax> values, SyntaxToken semicolonToken).
- [Breaking] The following were removed as a result of the
MinCountfix forSyntax.xml:SyntaxFactory.GenericForStatement(StatementListSyntax? body = null).
- The following were added as a result of the move to
EqualsValuesClauseSyntax:SyntaxKind.EqualsValuesClause;EqualsValuesClauseSyntax;EqualsValuesClauseSyntax.EqualsToken;EqualsValuesClauseSyntax.Values;EqualsValuesClauseSyntax.Update(SyntaxToken equalsToken, SeparatedSyntaxList<ExpressionSyntax> values);EqualsValuesClauseSyntax.WithEqualsToken(SyntaxToken equalsToken);EqualsValuesClauseSyntax.AddValues(params ExpressionSyntax[] items);EqualsValuesClauseSyntax.WithValues(SeparatedSyntaxList<ExpressionSyntax> values);EqualsValuesClauseSyntax.Accept(LuaSyntaxVisitor visitor);EqualsValuesClauseSyntax.Accept<TResult>(LuaSyntaxVisitor<TResult> visitor);AssignmentStatementSyntax.EqualsValues;AssignmentStatementSyntax.Update(SeparatedSyntaxList<PrefixExpressionSyntax> variables, EqualsValuesClauseSyntax equalsValues, SyntaxToken semicolonToken);AssignmentStatementSyntax.WithEqualsValues(EqualsValuesClauseSyntax equalsValues);LocalVariableDeclarationStatementSyntax.EqualsValues;LocalVariableDeclarationStatementSyntax.Update(SyntaxToken localKeyword, SeparatedSyntaxList<IdentifierNameSyntax> names, EqualsValuesClauseSyntax? equalsValues, SyntaxToken semicolonToken);LocalVariableDeclarationStatementSyntax.WithEqualsValues(Loretta.CodeAnalysis.Lua.Syntax.EqualsValuesClauseSyntax? equalsValues);SyntaxFactory.AssignmentStatement(SeparatedSyntaxList<PrefixExpressionSyntax> variables, EqualsValuesClauseSyntax equalsValues, SyntaxToken semicolonToken);SyntaxFactory.AssignmentStatement(SeparatedSyntaxList<PrefixExpressionSyntax> variables, EqualsValuesClauseSyntax equalsValues);SyntaxFactory.EqualsValuesClause(SyntaxToken equalsToken, SeparatedSyntaxList<ExpressionSyntax> values);SyntaxFactory.EqualsValuesClause(SeparatedSyntaxList<ExpressionSyntax> values);SyntaxFactory.LocalVariableDeclarationStatement(SyntaxToken localKeyword, SeparatedSyntaxList<IdentifierNameSyntax> names, EqualsValuesClauseSyntax? equalsValues, SyntaxToken semicolonToken);SyntaxFactory.LocalVariableDeclarationStatement(SeparatedSyntaxList<IdentifierNameSyntax> names, EqualsValuesClauseSyntax? equalsValues);SyntaxFactory.LocalVariableDeclarationStatement(SeparatedSyntaxList<IdentifierNameSyntax> names);LuaSyntaxVisitor.VisitEqualsValuesClause(EqualsValuesClauseSyntax node);LuaSyntaxVisitor<TResult>.VisitEqualsValuesClause(EqualsValuesClauseSyntax node);LuaSyntaxWalker.VisitEqualsValuesClause(EqualsValuesClauseSyntax node);LuaSyntaxRewriter.VisitEqualsValuesClause(EqualsValuesClauseSyntax node).
- Added
SyntaxFacts.GetKeywordKind(ReadOnlySpan<char> span). - The following were added as a result of the
MinCountfix forSyntax.xml:SyntaxFactory.GenericForStatement(SeparatedSyntaxList<IdentifierNameSyntax> identifiers, SeparatedSyntaxList<ExpressionSyntax> expressions).
- Added
MinifyingUtils.CanRenameto check if a variable will be renamed by the minifier. - Added
MinifyingUtils.GetUnavailableNamesto get the list of variable names that can't be used for a given scope or list of scopes. This is particularly useful for implementing your ownNamingStrategy.
- Fixed infinite loop on variable rename conflict.
- Added
Loretta.CodeAnalysis.Lua.SymbolDisplay.ObjectDisplay.NilLiteral. - Added
==and!=operators toLoretta.CodeAnalysis.FileLinePositionSpan.
- Deprecated
Loretta.CodeAnalysis.Lua.SymbolDisplay.ObjectDisplay.NullLiteralin favor ofNilLiteral.
- Removed the following unused things:
Loretta.CodeAnalysis.CaseInsensitiveComparison;Loretta.CodeAnalysis.GeneratedKind;Loretta.CodeAnalysis.Optional<T>;Loretta.CodeAnalysis.SourceReferenceResolver;Loretta.CodeAnalysis.SyntaxTreeOptionsProvider;Loretta.CodeAnalysis.ReportDiagnostic;Loretta.CodeAnalysis.LocationKind.XmlFile;Loretta.CodeAnalysis.SuppressionDescriptor;Loretta.CodeAnalysis.Diagnostics.SuppressionInfo.
- Removed the following as they did not make sense in our project:
Loretta.CodeAnalysis.SourceLocation.GetMappedLineSpan;Loretta.CodeAnalysis.WellKnownDiagnosticTags.EditAndContinue;Loretta.CodeAnalysis.WellKnownDiagnosticTags.Telemetry;Loretta.CodeAnalysis.WellKnownDiagnosticTags.AnalyzerException;Loretta.CodeAnalysis.WellKnownDiagnosticTags.CustomObsolete;Loretta.CodeAnalysis.WellKnownDiagnosticTags.CompilationEnd;Loretta.CodeAnalysis.LineVisibility;Loretta.CodeAnalysis.SyntaxTree.GetMappedLineSpan;Loretta.CodeAnalysis.SyntaxTree.GetLineVisibility;Loretta.CodeAnalysis.SyntaxTree.HasHiddenRegions;Loretta.CodeAnalysis.Location.GetMappedLineSpan;IsHiddenPositionSyntaxTreeextension method;Loretta.CodeAnalysis.Lua.LuaSyntaxTree.GetMappedLineSpan;Loretta.CodeAnalysis.Lua.LuaSyntaxTree.GetLineVisibility;Loretta.CodeAnalysis.Lua.LuaSyntaxTree.HasHiddenRegions.
- Added
IScope.ContainedScopeswhich lets you check scopes contained within another scope. - Added
IVariable.CanBeAccessedIn(IScope)which lets you check if the variable can be accessed within a given scope. - Added
IScope.FindVariable(string)which lets you try to find a variable in a scope or any of its parents. - Added
Script.RenameVariable(IVariable variable, string newName)which lets you rename a variable in a new script instance.
- Renamed
IScope.ParenttoIScope.ContainingScopeto be more consistent withContainedScopes.
- Added a minifier to the experimental package.
- Added support for the Lua 5.1 and Luau lexing bug that makes them silently accept invalid single-char escapes (e.g.: `"\A\B\C\D" will be read as "ABCD" silently without any errors or warnings).
ObjectDisplay.FormatLiteralwas not emitting Unicode escapes correctly.
- Added
Loretta.CodeAnalysis.Lua.Experimental.SyntaxExtensions.ConstantFold.
- DEPRECATED:
Loretta.CodeAnalysis.Lua.Experimental.SyntaxExtensions.FoldConstantsin favor ofConstantFold.
ObjectDisplay.FormatLiteralwas not adding the leading quote properly. This also affectedSyntaxFactory.Literal.- Constant folder was not folding
"a" .. trueto"atrue". - Constant folder was not folding
nil == niltotrue. - Constant folder was folding
not xtoxinstead of the result of the negation.
- Added support for FiveM's hash strings (thanks to @TheGreatSageEqualToHeaven).
NOTE: There is currently no support for creating hash string literal nodes from
SyntaxFactorybecause the API for that still hasn't been decided on. If you need to create a node for it useSyntaxFactory.ParseExpression.
- Added support for Luau's if expression.
- Fixed errors not being reported for missing expressions.
- Fixed an error not being reported when a compound assignment is parsed and
AcceptCompoundAssignmentis false. - Fixed typo in
SyntaxKind.StarEqualsToken(wasStartEqualsToken). SyntaxNormalizerfixes by @bmcq-0 in #37:- Fixed chained unary operators spacing;
- Fixed spaces before semicolons;
- Fixed missing space after assignment operator;
- Fixed spaces being inserted inside parenthesis;
- Fixed spacing inside table constructors;
- Fixed spacing after
ìf,elseif,untilandwhile; - Fixed two line breaks being inserted after certain statements;
- Fixed line breaks being inserted before semicolons;
- Fixed line breaks being inserted twice between statements.
- Changed the generated expression in the case of a missing expression (now it is a
IdentifierNameSyntaxwithIsMissingset totrue). - Changed the generated statement in the case of a missing expression (now it is an
ExpressionStatementSyntaxwithIsMissingset totrueand the inner expression is the one in the bullet point above). - Changed the generated error message in the case of a missing/invalid statement.
- Fixed a typo in
EmptyStatementSyntaxand its helper methods.
- Removed unused classes we got when vendoring Roslyn, of which, the following were public:
Loretta.CodeAnalysis.SourceFileResolver;Loretta.CodeAnalysis.AnalyzerConfig;Loretta.CodeAnalysis.AnalyzerConfigOptionsResult;Loretta.CodeAnalysis.AnalyzerConfigSet;Loretta.CodeAnalysis.ErrorLogOptions;Loretta.CodeAnalysis.SarifVersion;Loretta.CodeAnalysis.SarifVersionFacts.
- The following references were removed:
Microsoft.CodeAnalysis.Analyzers;System.Reflection.Metadata.
- The following references were removed for the .NET Core 3.1 build:
System.Collections.Immutable;System.Memory;System.Runtime.CompilerServices.Unsafe;System.Threading.Tasks.Extensions.
- Add support for implicit
selfparameter in methods.
- Fix parameters not having an
IVariableassociated with them.
- Fix file-level implicit
argparameter being namedargs.
- Add note about non-
CompilationUnitSyntaxrooted trees inScript.
- Add validation for
defaultimmutable arrays of syntax trees inScript. FileScopes are now only generated forCompilationUnitSyntaxes.
- Fix
FindScopenot returning anything for root statements. - Fix
CompilationUnitSyntaxes not having any associated scopes.
- Add better formatting for tables when they're multiline.
- Fix
SimpleFunctionNamehandling to:- Not always add it as a write when it's part of a composite name.
- Not assign the simple name variable to the entire name when it's a composite one.
- Fix formatting of
:(a:bwas being turned intoa : b). - Fix multiple line breaks being inserted when formatting.
- Fix line breaks not being added after single line comments.
- Fix formatting of
[and](a[a]was being turned intoa [ a ]). - Fix empty table formatting (
{}instead of{ }). - Fix excessive spacing around parenthesis.
- Fix missing
SyntaxKinds forUnaryExpressionSyntaxandBinaryExpressionSyntaxinSyntax.xml.
- Add parameterless ctor of
ScriptandScript.Emptyfor easier creation of empty scripts. - Add support for
SimpleFunctionNamein variable handling (local vars didn't have a write added to them and a global wasn't created if a local with the same name didn't exist). - Add
SyntaxFacts.IsOperatorToken,SyntaxFacts.IsUnaryOperatorTokenandSyntaxFacts.IsBinaryOperatorToken. - Add
Script.FindScope.
- Fix jumps to non-existent labels (labels that don't have a
::label::) not creating a new label. - Fix jumps to a goto label not being added to the
IGotoLabel.
- Configure
IFileScope,IFunctionScope,IGotoLabel,IScopeandIVariableto only allow internal implementations. - Make
IGotoLabel.LabelSyntaxnullable to account for the case where the label has no declarations.
- Add nuget params to
Loretta.CodeAnalysis,Loretta.CodeAnalysis.LuaandLoretta.CodeAnalysis.Lua.Experimental; - Add CD flow to publish packages to a public myget.org (not nuget.org) feed.
- Implement
ConstantFolder;
- [Breaking] Changed what is accepted as whitespace to not be unicode-aware (as lua isn't);
- Fix
SyntaxNormalizeradding a space after.s;
- Updated
Syntax.xmlto includeBangTokeninUnaryExpressionSyntaxandBangEqualsTokeninBinaryExpressionSyntax; - Fixed infinite loop in
LuaSyntaxWalkerwith emptyStatementLists;
- Implemented
\zwhitespace voider escape for short strings; - Implemented
SourceTextReaderas an attempt to reduce allocations when lexing;
- Removed GParse dependency (side effect of
SourceTextReader).
- [Breaking] Only store
IScopes that directly reference aIVariablein theIVariable.ReferencingScopes; - [Breaking] Move
CapturedVariablestoIFunctionScopeas it is not applicable to non-function scopes; - Updated the README with instructions and documentation on v0.2.
- Add
ReferencedVariablestoIScopewith allIVariables referenced by the scope and its children;
-
[Breaking] Implement 5.3 bitwise operators along with
LuaSyntaxOptionssetting for erroring on them;Breaking change: the precedences for each operator were altered.
-
Implement a warning about
\n\rbeing used as it is recognized as a single line break by Lua;
- Amortize allocations made by string parsing.