Releases: LorettaDevs/Loretta
Releases · LorettaDevs/Loretta
v0.2.9-beta.2
Added
- Added
ConstantFoldingOptions
with the option to enable number extraction from strings.
Changed
- [Breaking] Changed
ConstantFold
extension method to accept aConstantFoldingOptions
.
Fixed
- Fixed
SyntaxFacts.GetConstantValue
not returning the correct value for tokens. - Fixed
SyntaxFacts.GetConstantValue
not returningNone
for values outside of 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.GetStructure
throwing an exception because we do have structured trivia.
v0.2.9-beta.1
Changed
- Optimized the lexing process with a reduction of 80% in lexing time and 76% in parsing time.
v0.2.8
Added
- 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.Lua54
preset.
- Added
SyntaxFactory.HashString
for 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)
.
Changed
- 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.Names
now returns aSeparatedSyntaxList<LocalDeclarationNameSyntax>
instead ofSeparatedSyntaxList<IdentifierNameSyntax>
;LocalVariableDeclarationStatementSyntax.Update
now receives aSeparatedSyntaxList<LocalDeclarationNameSyntax>
instead ofSeparatedSyntaxList<IdentifierNameSyntax>
;LocalVariableDeclarationStatementSyntax.AddNames
now receives aparams LocalDeclarationNameSyntax[]
instead ofparams IdentifierNameSyntax[]
;LocalVariableDeclarationStatementSyntax.WithNames
now receives aSeparatedSyntaxList<LocalDeclarationNameSyntax>
instead ofSeparatedSyntaxList<IdentifierNameSyntax>
;SyntaxFactory.LocalVariableDeclarationStatement
overloads now receive aSeparatedSyntaxList<LocalDeclarationNameSyntax>
instead ofSeparatedSyntaxList<IdentifierNameSyntax>
;LuaSyntaxOptions
constructor andWith
method now accept anacceptLocalVariableAttributes
parameter.
- [Breaking] The following were changed as a result of implementing integers:
- The Lua 5.3 preset was changed to accept integers;
- IMPORTANT:
SyntaxToken.Value
now can be along
when any of the*IntegerFormat
settings are set toIntegerFormats.Int64
; LuaSyntaxOptions
constructor andWith
method now accept 4IntegerFormats
for each number format (binary, octal, decimal and hexadecimal);- The constant folder was modified to support integers.
v0.2.7-beta.13
Fixed
- Fixed
Minify
double-freeing a slot.
v0.2.7-beta.12
Fixed
- Fixed
Minify
renaming variables that were being used incorrectly. - Fixed
Minify
not adding a leading_
for certain variable names. - Fixed
Minify
adding prefixes for variable names that were already renamed.
Changed
- [Breaking] The following were changed as a result of the move to
EqualsValuesClauseSyntax
:- Replaced
EqualsToken
andValues
inAssignmentStatementSyntax
byEqualsValues
; - Replaced
EqualsToken
andValues
inLocalVariableDeclarationStatementSyntax
byEqualsValues
.
- Replaced
- [Breaking]
SyntaxFactory
methods will now throw exceptions if the lists provided to them do not have the minimum amount of items required. - [Breaking]
NamingStrategy
was changed to receive a list ofIScope
s 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
.
Removed
- [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
MinCount
fix forSyntax.xml
:SyntaxFactory.GenericForStatement(StatementListSyntax? body = null)
.
Added
- 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
MinCount
fix forSyntax.xml
:SyntaxFactory.GenericForStatement(SeparatedSyntaxList<IdentifierNameSyntax> identifiers, SeparatedSyntaxList<ExpressionSyntax> expressions)
.
- Added
MinifyingUtils.CanRename
to check if a variable will be renamed by the minifier. - Added
MinifyingUtils.GetUnavailableNames
to 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
.
v0.2.7-beta.11
Fixed
- Fixed infinite loop on variable rename conflict.
v0.2.7-beta.9
Added
- Added
IScope.ContainedScopes
which 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.
Changed
- Renamed
IScope.Parent
toIScope.ContainingScope
to be more consistent withContainedScopes
.
v0.2.7-beta.10
Added
- Added
Loretta.CodeAnalysis.Lua.SymbolDisplay.ObjectDisplay.NilLiteral
. - Added
==
and!=
operators toLoretta.CodeAnalysis.FileLinePositionSpan
.
Deprecated
- Deprecated
Loretta.CodeAnalysis.Lua.SymbolDisplay.ObjectDisplay.NullLiteral
in favor ofNilLiteral
.
Removed
- 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
;IsHiddenPosition
SyntaxTree
extension method;Loretta.CodeAnalysis.Lua.LuaSyntaxTree.GetMappedLineSpan
;Loretta.CodeAnalysis.Lua.LuaSyntaxTree.GetLineVisibility
;Loretta.CodeAnalysis.Lua.LuaSyntaxTree.HasHiddenRegions
.
v0.2.7-beta.8
Added
- 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).
Fixed
ObjectDisplay.FormatLiteral
was not emitting unicode escapes correctly.
v0.2.7-beta.7
Added
- Added
Loretta.CodeAnalysis.Lua.Experimental.SyntaxExtensions.ConstantFold
.
Changed
- DEPRECATED:
Loretta.CodeAnalysis.Lua.Experimental.SyntaxExtensions.FoldConstants
in favor ofConstantFold
.
Fixed
ObjectDisplay.FormatLiteral
was not adding the leading quote properly.
This also affectedSyntaxFactory.Literal
.- Constant folder was not folding
"a" .. true
to"atrue"
. - Constant folder was not folding
nil == nil
totrue
. - Constant folder was folding
not x
tox
instead of the result of the negation.