Skip to content

Releases: LorettaDevs/Loretta

v0.2.9-beta.2

22 Feb 20:17
Compare
Choose a tag to compare
v0.2.9-beta.2 Pre-release
Pre-release

Added

  • Added ConstantFoldingOptions with the option to enable number extraction from strings.

Changed

  • [Breaking] Changed ConstantFold extension method to accept a ConstantFoldingOptions.

Fixed

  • Fixed SyntaxFacts.GetConstantValue not returning the correct value for tokens.
  • Fixed SyntaxFacts.GetConstantValue not returning None 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

18 Feb 22:13
Compare
Choose a tag to compare
v0.2.9-beta.1 Pre-release
Pre-release

Changed

  • Optimized the lexing process with a reduction of 80% in lexing time and 76% in parsing time.

v0.2.8

16 Feb 21:05
Compare
Choose a tag to compare

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 a SeparatedSyntaxList<LocalDeclarationNameSyntax> instead of SeparatedSyntaxList<IdentifierNameSyntax>;
    • LocalVariableDeclarationStatementSyntax.Update now receives a SeparatedSyntaxList<LocalDeclarationNameSyntax> instead of SeparatedSyntaxList<IdentifierNameSyntax>;
    • LocalVariableDeclarationStatementSyntax.AddNames now receives a params LocalDeclarationNameSyntax[] instead of params IdentifierNameSyntax[];
    • LocalVariableDeclarationStatementSyntax.WithNames now receives a SeparatedSyntaxList<LocalDeclarationNameSyntax> instead of SeparatedSyntaxList<IdentifierNameSyntax>;
    • SyntaxFactory.LocalVariableDeclarationStatement overloads now receive a SeparatedSyntaxList<LocalDeclarationNameSyntax> instead of SeparatedSyntaxList<IdentifierNameSyntax>;
    • LuaSyntaxOptions constructor and With method now accept an acceptLocalVariableAttributes 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 a long when any of the *IntegerFormat settings are set to IntegerFormats.Int64;
    • LuaSyntaxOptions constructor and With method now accept 4 IntegerFormats for each number format (binary, octal, decimal and hexadecimal);
    • The constant folder was modified to support integers.

v0.2.7-beta.13

27 Jan 17:06
Compare
Choose a tag to compare
v0.2.7-beta.13 Pre-release
Pre-release

Fixed

  • Fixed Minify double-freeing a slot.

v0.2.7-beta.12

25 Jan 00:19
Compare
Choose a tag to compare
v0.2.7-beta.12 Pre-release
Pre-release

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 and Values in AssignmentStatementSyntax by EqualsValues;
    • Replaced EqualsToken and Values in LocalVariableDeclarationStatementSyntax by EqualsValues.
  • [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 of IScopes 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 for Syntax.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 for Syntax.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 own NamingStrategy.

v0.2.7-beta.11

17 Jan 18:19
Compare
Choose a tag to compare
v0.2.7-beta.11 Pre-release
Pre-release

Fixed

  • Fixed infinite loop on variable rename conflict.

v0.2.7-beta.9

12 Jan 01:52
Compare
Choose a tag to compare
v0.2.7-beta.9 Pre-release
Pre-release

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 to IScope.ContainingScope to be more consistent with ContainedScopes.

v0.2.7-beta.10

12 Jan 23:19
Compare
Choose a tag to compare
v0.2.7-beta.10 Pre-release
Pre-release

Added

  • Added Loretta.CodeAnalysis.Lua.SymbolDisplay.ObjectDisplay.NilLiteral.
  • Added == and != operators to Loretta.CodeAnalysis.FileLinePositionSpan.

Deprecated

  • Deprecated Loretta.CodeAnalysis.Lua.SymbolDisplay.ObjectDisplay.NullLiteral in favor of NilLiteral.

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

10 Jan 15:21
Compare
Choose a tag to compare
v0.2.7-beta.8 Pre-release
Pre-release

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

04 Jan 19:23
Compare
Choose a tag to compare
v0.2.7-beta.7 Pre-release
Pre-release

Added

  • Added Loretta.CodeAnalysis.Lua.Experimental.SyntaxExtensions.ConstantFold.

Changed

  • DEPRECATED: Loretta.CodeAnalysis.Lua.Experimental.SyntaxExtensions.FoldConstants in favor of ConstantFold.

Fixed

  • ObjectDisplay.FormatLiteral was not adding the leading quote properly.
    This also affected SyntaxFactory.Literal.
  • Constant folder was not folding "a" .. true to "atrue".
  • Constant folder was not folding nil == nil to true.
  • Constant folder was folding not x to x instead of the result of the negation.