Changelog¶ ↑
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.
[Unreleased]¶ ↑
[6.3.0] - 2025-07-16¶ ↑
Added¶ ↑
-
The
--extensioncommand line option has been added to the CLI to specify what type of content is coming from stdin. -
The
--configcommand line option has been added to the CLI to specify the path to the configuration file.
Changed¶ ↑
-
Fix formatting of character literals when single quotes is enabled.
-
Pass ignore files option to the language server.
-
Hash keys should remain unchanged when there are any omitted values in the hash.
-
We now properly handle compilation errors in the parser.
6.2.0 - 2023-09-20¶ ↑
Added¶ ↑
-
Fix
WithScopefor destructured post arguments.
Changed¶ ↑
-
Always use
do/endfor multi-line lambdas.
6.1.1 - 2023-03-21¶ ↑
Changed¶ ↑
-
Fixed a bug where the call chain formatter was incorrectly looking at call messages.
6.1.0 - 2023-03-20¶ ↑
Added¶ ↑
-
The
stree ctagscommand for generating ctags likeuniversal-ctagsorripper-tagswould. -
The
definedivarYARV instruction has been added to match CRuby’s implementation. -
We now generate better Sorbet RBI files for the nodes in the tree and the visitors.
-
SyntaxTree::Reflection.nodesnow includes the visitor method.
Changed¶ ↑
-
We now explicitly require
ppin environments that need it.
6.0.2 - 2023-03-03¶ ↑
Added¶ ↑
-
The
WithScopevisitor mixin will now additionally report local variables defined through regular expression named captures. -
The
WithScopevisitor mixin now properly handles destructured splat arguments in required positions.
Changed¶ ↑
-
Fixed the AST output by adding blocks to
CommandandCommandCallnodes in theFieldVisitor. -
Fixed the location of lambda local variables (e.g.,
->(; a) {}).
6.0.1 - 2023-02-26¶ ↑
Added¶ ↑
-
The class declarations returned as the result of the indexing operation now have their superclass as a field. It is returned as an array of constants. If the superclass is anything other than a constant lookup, then it raises an error.
Changed¶ ↑
-
The
nestingfield on the results of the indexing operation is no longer a single flat array. Instead it is an array of arrays, where each array is a single nesting level. This more accurately reflects the nesting of the nodes in the tree. For example,class Foo::Bar::Baz; endwould result in[Foo, Bar, Baz], but that incorrectly implies that you can see constants at each of those levels. Now this would result in[[Foo, Bar, Baz]]to indicate that it can see either the top level or constants within the scope ofFoo::Bar::Bazonly. -
When formatting hashes that have omitted values and mixed hash rockets with labels, the formatting now maintains whichever delimiter was used in the source. This is because forcing the use of hash rockets with omitted values results in a syntax error.
-
Handle the case where a bare hash is used after the
break,next, orreturnkeywords. Previously this would result in hash labels which is not valid syntax. Now it maintains the delimiters used in the source. -
The
<<operator will now break on chained<<expressions. Previously it would always stay flat.
6.0.0 - 2023-02-10¶ ↑
Added¶ ↑
-
SyntaxTree::BasicVisitor::visit_methodshas been added to allow you to check multiple visit methods inside of a block. There was a method calledvisit_methodspreviously, but it was undocumented because it was meant as a private API. That method has been renamed tovalid_visit_methods. -
rake sorbet:rbihas been added as a task within the repository to generate an RBI file corresponding to the nodes in the tree. This can be used to help aid consumers of Syntax Tree that are using Sorbet. -
SyntaxTree::Reflectionhas been added to allow you to get information about the nodes in the tree. It is not required by default, since it takes a small amount of time to parsenode.rband get all of the information. -
SyntaxTree::Node#to_mermaidhas been added to allow you to generate a Mermaid diagram of the node and its children. This is useful for debugging and understanding the structure of the tree. -
SyntaxTree::Translationhas been added as an experimental API to transform the Syntax Tree syntax tree into the syntax trees represented by the whitequark/parser and rubocop/rubocop-ast gems. -
SyntaxTree::Translation.to_parser(node, buffer)will return aParser::AST::Nodeobject. -
SyntaxTree::Translation.to_rubocop_ast(node, buffer)will return aRuboCop::AST::Nodeobject. -
SyntaxTree::indexandSyntaxTree::index_filehave been added to allow you to get a list of all of the classes, modules, and methods defined in a given source string or file. -
Various convenience methods have been added:
-
SyntaxTree::format_file- which calls format with the result of reading the file -
SyntaxTree::format_node- which formats the node directly -
SyntaxTree::parse_file- which calls parse with the result of reading the file -
SyntaxTree::search_file- which calls search with the result of reading the file -
SyntaxTree::Node#start_char- which is the same as callingnode.location.start_char -
SyntaxTree::Node#end_char- which is the same as callingnode.location.end_char -
SyntaxTree::Assocnodes can now be formatted on their own without a parent hash node. -
SyntaxTree::BlockVar#arg0?has been added to check if a single required block parameter is present and would potentially be expanded. -
More experimental APIs have been added to the
SyntaxTree::YARVmodule, including: -
SyntaxTree::YARV::ControlFlowGraph -
SyntaxTree::YARV::DataFlowGraph -
SyntaxTree::YARV::SeaOfNodes
Changed¶ ↑
Major changes¶ ↑
-
BREAKING Updates to
WithEnvironment: -
The
WithEnvironmentmodule has been renamed toWithScope. -
The
current_environmentmethod has been renamed tocurrent_scope. -
The
with_current_environmentmethod has been removed. -
Previously scopes were always able to look up the tree, as in:
a = 1; def foo; a = 2; endwould see only a singleavariable. That has been corrected. -
Previously accessing variables from inside of blocks that were not shadowed would mark them as being local to the block only. This has been correct.
-
BREAKING Lots of constants moved out of
SyntaxTree::Visitorto justSyntaxTree: -
SyntaxTree::Visitor::FieldVisitoris nowSyntaxTree::FieldVisitor -
SyntaxTree::Visitor::JSONVisitoris nowSyntaxTree::JSONVisitor -
SyntaxTree::Visitor::MatchVisitoris nowSyntaxTree::MatchVisitor -
SyntaxTree::Visitor::MutationVisitoris nowSyntaxTree::MutationVisitor -
SyntaxTree::Visitor::PrettyPrintVisitoris nowSyntaxTree::PrettyPrintVisitor -
BREAKING Lots of constants are now autoloaded instead of required by default. This is only particularly relevant if you are in a forking environment and want to preload constants before forking for better memory usage with copy-on-write.
-
BREAKING The
SyntaxTree::Statements#initializemethod no longer accepts a parser as the first argument. It now mirrors the other nodes in that it accepts its children and location. As a result, Syntax Tree nodes are now marshalable (and therefore can be sent over DRb). Previously theStatementsnode was not able to be marshaled because it held a reference to the parser.
Minor changes¶ ↑
-
Many places where embedded documents (
=beginto=end) were being treated as real comments have been fixed for formatting. -
Dynamic symbols in keyword pattern matching now have better formatting.
-
Endless method definitions used to have a
SyntaxTree::BodyStmtnode that had any kind of node as itsstatementsfield. That has been corrected to be more consistent such that now going fromdef_node.bodystmt.statementsalways returns aSyntaxTree::Statementsnode, which is more consistent. -
We no longer assume that
fiddleis able to be required, and only require it when it is actually needed.
Tiny changes¶ ↑
-
Empty parameter nodes within blocks now have more accurate location information.
-
Pinned variables have more correct location information now. (Previously the location was just around the variable itself, but it now includes the pin.)
-
Array patterns in pattern matching now have more accurate location information when they are using parentheses with a constant present.
-
Find patterns in pattern matching now have more correct location information for their
leftandrightfields. -
Lots of nodes have more correct types in the comments on their attributes.
-
The expressions
break foo.bar :baz do |qux| qux endandnext fun foo do endnow correctly parses as a control-flow statement with a method call that has a block attached, as opposed to a control-flow statement with a block attached. -
The expression
self::a, b = 1, 2would previously yield aSyntaxTree::ConstPathFieldnode for the first element of the left-hand-side of the multiple assignment. Semantically this is incorrect, and we have fixed this to now be aSyntaxTree::Fieldnode instead.
5.3.0 - 2023-01-26¶ ↑
Added¶ ↑
-
arity has been added to
DefNode,BlockNode, andParams. The method returns a range where the lower bound is the minimum and the upper bound is the maximum number of arguments that can be used to invoke that block/method definition. -
arity has been added to
CallNode,Command,CommandCall, andVCallnodes. The method returns the number of arguments included in the invocation. For splats, double splats, or argument forwards, this method returnsFloat::INFINITY. -
SyntaxTree::indexandSyntaxTree::index_fileAPIs have been added to collect a list of classes, modules, and methods defined in a given source string or file, respectively. These APIs are experimental and subject to change. -
A
plugin/disable_auto_ternaryplugin has been added the disables the formatted that automatically changes permissableif/elseclauses into ternaries.
Changed¶ ↑
-
Files are now only written from the CLI if the content of them changes, which should match watching files less chaotic.
-
In the case that
rb_iseq_loadcannot be found,Fiddle::DLErroris now rescued. -
Previously if there were invalid UTF-8 byte sequences after the
__END__keyword the parser could potentially have crashed when parsing comments. This has been fixed. -
Previously there was special formatting for array literals that contained only variable references (either locals, method calls, or constants). For consistency, this has been removed and all array literals are now formatted the same way.
5.2.0 - 2023-01-04¶ ↑
Added¶ ↑
-
An experiment in evaluating compiled instruction sequences has been added to Syntax Tree. This is subject to change, so it will not be well documented or testing at the moment. It does not impact other functionality.
Changed¶ ↑
-
Empty parentheses on method calls will now be left in place. Previously they were left in place if the method being called looked like a constant. Now they are left in place for all method calls since the method name can mirror the name of a local variable, in which case the parentheses are required.
5.1.0 - 2022-12-28¶ ↑
Added¶ ↑
-
An experiment in working with instruction sequences has been added to Syntax Tree. This is subject to change, so it is not well documented or tested at the moment. It does not impact other functionality.
-
You can now format at a different base layer of indentation. This is an optional third argument to
SyntaxTree::format.
Changed¶ ↑
-
Support forwarding anonymous keyword arguments with
**. -
The
BodyStmtnode now has a more correct location information. -
Ignore the
textDocument/documentColorrequest coming into the language server to support clients that require that request be received. -
Do not attempt to convert
if..elseinto ternaries if the predicate has aBinarynode. -
Properly handle nested pattern matching when a rightward assignment is inside a
whenclause.
5.0.1 - 2022-11-10¶ ↑
Changed¶ ↑
-
Fix the plugin parsing on the CLI so that they are respected.
5.0.0 - 2022-11-09¶ ↑
Added¶ ↑
-
Every node now implements the copy(**) method, which provides a copy of the node with the given attributes replaced.
-
Every node now implements the ===(other) method, which checks if the given node matches the current node for all attributes except for comments and location.
-
There is a new
SyntaxTree::Visitor::MutationVisitorand its convenience methodSyntaxTree.mutationwhich can be used to mutate a syntax tree. For details on how to use this visitor, check the README.
Changed¶ ↑
-
Nodes no longer have a
comments:keyword on their initializers. By default, they initialize to an empty array. If you were previously passing comments into the initializer, you should now create the node first, then callnode.comments.concatto add your comments. -
A lot of nodes have been folded into other nodes to make it easier to interact with the AST. This means that a lot of visit methods have been removed from the visitor and a lot of class definitions are no longer present. This also means that the nodes that received more function now have additional methods or fields to be able to differentiate them. Note that none of these changes have resulted in different formatting. The changes are listed below:
-
IfMod,UnlessMod,WhileMod,UntilModhave been folded intoIfNode,UnlessNode,WhileNode, andUntilNode. Each of the nodes now have amodifier?method to tell if it was originally in the modifier form. Consequently, thevisit_if_mod,visit_unless_mod,visit_while_mod, andvisit_until_modmethods have been removed from the visitor. -
VarAliasis no longer a node, and theAliasnode has been renamed. They have been folded into theAliasNodenode. TheAliasNodenode now has avar_alias?method to tell you if it is aliasing a global variable. Consequently, thevisit_var_aliasmethod has been removed from the visitor interface. If you were previously using this method, you should now usevisit_aliasinstead. -
Yield0is no longer a node, and theYieldnode has been renamed. They has been folded into theYieldNodenode. TheYieldNodenode can now have itsargumentsfield benil. Consequently, thevisit_yield0method has been removed from the visitor interface. If you were previously using this method, you should now usevisit_yieldinstead. -
FCallis no longer a node, and theCallnode has been renamed. They have been folded into theCallNodenode. TheCallNodenode can now have itsreceiverandoperatorfields benil. Consequently, thevisit_fcallmethod has been removed from the visitor interface. If you were previously using this method, you should now usevisit_callinstead. -
Dot2andDot3are no longer nodes. Instead they have become a single newRangeNodenode. This node looks the same asDot2andDot3, except that it additionally has anoperatorfield that contains the operator that created the node. Consequently, thevisit_dot2andvisit_dot3methods have been removed from the visitor interface. If you were previously using these methods, you should now usevisit_rangeinstead. -
Def,DefEndless, andDefshave been folded into theDefNodenode. TheDefNodenode now has thetargetandoperatorfields which originally came fromDefswhich can both benil. It also now has anendless?method on it to tell if the original node was found in the endless form. Finally thebodystmtfield can now either be aBodyStmtas it was or any other kind of node since that was the body of theDefEndlessnode. Thevisit_defsandvisit_def_endlessmethods on the visitor have therefore been removed. -
DoBlockandBraceBlockhave now been folded into aBlockNodenode. TheBlockNodenode now has akeywords?method on it that returns true if the block was constructed with thedo..endkeywords. Thevisit_do_blockandvisit_brace_blockmethods on the visitor have therefore been removed and replaced with thevisit_blockmethod. -
Return0is no longer a node, and theReturnnode has been renamed. They have been folded into theReturnNodenode. TheReturnNodenode can now have itsargumentsfield benil. Consequently, thevisit_return0method has been removed from the visitor interface. If you were previously using this method, you should now usevisit_returninstead. -
The
ArgsForward,Redo,Retry, andZSupernodes no longer havevaluefields associated with them (which were always string literals corresponding to the keyword being used). -
The
CommandandCommandCallnodes now hasblockattributes on them. These attributes are used in the place where you would previously have had aMethodAddBlockstructure. Where before theMethodAddBlockwould have the command and block as its two children, you now just have one command node with theblockattribute set to theBlocknode. -
Previously the formatting options were defined on an unfrozen hash called
SyntaxTree::Formatter::OPTIONS. It was globally mutable, which made it impossible to reference from within a Ractor. As such, it has now been replaced withSyntaxTree::Formatter::Options.newwhich creates a new options object instance that can be modified without impacting global state. As a part of this change, formatting can now be performed from within a non-main Ractor. In order to check if theplugin/single_quotesplugin has been loaded, check ifSyntaxTree::Formatter::SINGLE_QUOTESis defined. In order to check if theplugin/trailing_commaplugin has been loaded, check ifSyntaxTree::Formatter::TRAILING_COMMAis defined.
4.3.0 - 2022-10-28¶ ↑
Added¶ ↑
-
#183 - Support TruffleRuby by eliminating internal pattern matching in some places and stopping some tests from running in other places.
-
#184 - Remove internal pattern matching entirely.
Changed¶ ↑
-
#183 - Pattern matching works against dynamic symbols now.
-
#184 - Exit with the correct exit status within the rake tasks.
4.2.0 - 2022-10-25¶ ↑
Added¶ ↑
-
#182 - The new
stree exprCLI command will function similarly to thestree matchCLI command except that it only outputs the first expression of the program. -
#182 - Added the
SyntaxTree::Patternclass for compilinginexpressions into procs.
Changed¶ ↑
-
#182 - Much more syntax is now supported by the search command.
4.1.0 - 2022-10-24¶ ↑
Added¶ ↑
-
#180 - The new
stree searchCLI command and the correspondingSyntaxTree::Searchclass for searching for a pattern against a given syntax tree.
4.0.2 - 2022-10-19¶ ↑
Changed¶ ↑
-
#177 - Fix up various other issues with the environment visitor addition.
4.0.1 - 2022-10-18¶ ↑
Changed¶ ↑
-
#172 - Use a refinement for
Symbol#nameaddition so that other runtimes or tools don’t get confused by its availability. -
#173 - Fix the
current_environmentusage to use the method instead of the instance variable. -
#175 - Update
prettier_printrequirement since v1.0.0 had a bug with breakable_return.
4.0.0 - 2022-10-17¶ ↑
Added¶ ↑
-
#169 - You can now pass
--ignore-filesmultiple times. -
#157 - We now support tracking local variable definitions throughout the visitor. This allows you to access scope information while visiting the tree.
-
#170 - There is now an undocumented
STREE_FAST_FORMATenvironment variable checked when formatting. It has the effect of turning off formatting call chains and ternaries in special ways. This improves performance quite a bit. I’m leaving it undocumented because ideally we just improve the performance as a whole. This is meant as a stopgap until we get there.
Changed¶ ↑
-
#170 - We now require at least version
1.0.0ofprettier_print. This is to take advantage of the first-class string support in the doc tree. -
#170 - Pattern matching has been removed from usage internal to this library (excluding the language server). This should hopefully enable runtimes that don’t have pattern matching fully implemented yet (e.g., TruffleRuby) to run this gem.
3.6.3 - 2022-10-11¶ ↑
Changed¶ ↑
-
#167 - Change the error encountered when an
elsenode does not have an associatedendtoken to be a parse error.
3.6.2 - 2022-10-04¶ ↑
Changed¶ ↑
-
#165 - Conditionals (
if/unless), loops (for/while/until) and lambdas all had issues when comments immediately succeeded the declaration of the node where the comment could potentially be dropped. That has now been fixed. -
#166 - Blocks can now be formatted even if they are the top node of the tree. Previously they were looking to their parent for some additional metadata, so we now handle the case where the parent is nil.
3.6.1 - 2022-09-28¶ ↑
Changed¶ ↑
-
#161 - Previously, we were checking if STDIN was a TTY to determine if there was content to be read. Instead, we now check if no filenames were passed, and in that case we attempt to read from STDIN. This should fix errors users were experiencing in non-TTY environments like CI.
-
#162 - Parse errors shouldn’t crash the language server anymore.
3.6.0 - 2022-09-19¶ ↑
Added¶ ↑
-
#158 - Support the ability to pass
--ignore-filesto the CLI and the Rake tasks to ignore a certain pattern of files.
3.5.0 - 2022-08-26¶ ↑
Added¶ ↑
-
#148 - Support Ruby 2.7.0 (previously we only supported back to 2.7.3).
-
#152 - Support the
-einline script option for thestreeCLI.
Changed¶ ↑
-
#141 - Use
q.formatforSyntaxTree.formatso that the main node gets pushed onto the stack for checking parent nodes. -
#147 - Fix rightward assignment token management such that
inand=>stay the same regardless of their context.
3.4.0 - 2022-08-19¶ ↑
Added¶ ↑
-
#127 - Allow the language server to handle other file extensions if it is activated for those extensions.
-
#133 - Add documentation on supporting vim and neovim.
Changed¶ ↑
-
#132 - Provide better error messages when end quotes and end keywords are missing from tokens.
-
#134 - Ensure the correct
endkeyword is getting removed bybegin..rescueclauses. -
#137 - Better support regular expressions with no ending token.
3.3.0 - 2022-08-02¶ ↑
Added¶ ↑
-
#123 - Allow the rake tasks to configure print width.
-
#125 - Add support for an
.streercfile in the current working directory to configure the CLI.
3.2.1 - 2022-07-22¶ ↑
Changed¶ ↑
-
#119 - If there are conditionals in the assignment we cannot convert it to the modifier form. There was a bug where it would stop checking for assignment nodes if there were any optional child nodes.
3.2.0 - 2022-07-19¶ ↑
Added¶ ↑
-
#116 - Pass the
--print-widthoption in the CLI to the language server.
3.1.0 - 2022-07-19¶ ↑
Added¶ ↑
-
#115 - Support the
--print-widthoption in the CLI for the actions that support it.
3.0.1 - 2022-07-15¶ ↑
Changed¶ ↑
-
#112 - Fix parallel CLI execution by not short-circuiting with the
||operator.
3.0.0 - 2022-07-04¶ ↑
Changed¶ ↑
-
#102 - Handle requests to the language server for files that do not yet exist on disk.
Removed¶ ↑
-
#108 - Remove old inlay hints code.
2.9.0 - 2022-07-04¶ ↑
Added¶ ↑
-
#106 - Add inlay hint support to match the LSP specification.
2.8.0 - 2022-06-21¶ ↑
Added¶ ↑
-
#95 - The
HeredocEndnode has been added which effectively results in the ability to determine the location of the ending of a heredoc from source. -
#99 - The LSP now allows you to pass the same configuration options as the other CLI commands which allows formatting to be modified in the VSCode extension.
-
#100 - The LSP now explicitly responds to the shutdown request so that VSCode never deadlocks.
Changed¶ ↑
-
#96 - The CLI now runs in parallel by default. There is a worker created for each processor on the running machine (as determined by
Etc.nprocessors). -
#97 - Syntax Tree now handles the case where
DidYouMeanis not available for whatever reason, as well as handles the newerdetailed_messageAPI for errors.
2.7.1 - 2022-05-25¶ ↑
Added¶ ↑
-
#92 - (Internal) Drastically increase test coverage, including many more tests for the language server and the CLI.
Changed¶ ↑
-
#87 - Don’t convert quotes on strings if it would result in more escapes.
-
#91 - Always use
[]with array patterns. There are just too many edge cases where you have to use them anyway. This simplifies the look and makes it more consistent. -
#92 - Remodel the currently shipped plugins such that they’re modifying an options hash instead of overriding methods. This should make it easier for other plugins to reference the already loaded plugins, e.g., the RBS plugin referencing the quotes.
-
#92 - Fix up the language server inlay hints to continue walking the tree once a pattern is found. This should increase useability.
2.7.0 - 2022-05-19¶ ↑
Added¶ ↑
-
#88 - Provide a
SyntaxTree::BasicVisitorthat has no visit methods implemented.
Changed¶ ↑
-
#90 - Provide better formatting for
SyntaxTree::AryPtnwhen its nested inside aSyntaxTree::RAssign.
2.6.0 - 2022-05-16¶ ↑
Added¶ ↑
-
#74 - Add Rake test to run check and format commands.
-
#83 - Add a trailing commas plugin.
-
#84 - Handle lambda block-local variables.
Changed¶ ↑
-
#85 - Better handle trailing operators on command calls.
2.5.0 - 2022-05-13¶ ↑
Added¶ ↑
-
#79 - Support an optional
maxwidthsecond argument toSyntaxTree.format.
Changed¶ ↑
-
#77 - Correct the pattern for checking if a dynamic symbol can be converted into a label as a hash key.
-
#72 - Disallow conditionals with
notwithout parentheses in the predicate from turning into a ternary.
2.4.1 - 2022-05-10¶ ↑
-
#73 - Fix nested hash patterns from accidentally adding a
thento their output.
2.4.0 - 2022-05-07¶ ↑
Added¶ ↑
-
#65 - Add a rubocop config at
config/rubocop.ymlthat we can ship with the gem so folks can inherit from it to get their styling correct. -
#65 - Improve hash pattern formatting by a lot - multiple lines are now not so ugly.
-
#62 - Add
optionsas a method onSyntaxTree::RegexpLiteral, add it to pattern matching, and describe it using theSyntaxTree::Visitor::FieldVisitorclass. -
#69 - The
construct_keysoption has been added to everySyntaxTree::Nodedescendant. This allows building a pattern match expression that can be used later. It is meant as a reflection API, not necessarily something that should be eval’d. -
#69 - You can now call
stree jsonto get a JSON representation of your syntax tree. -
#69 - You can now call
stree matchto get a Ruby pattern matching expression to match against the given input.
Changed¶ ↑
-
#69 - Fixed a long-standing bug with pretty-print where if certain things were required in different orders you could end up with a bug in
PPwhen calling pretty-print with a confusing error referring to inspect keys. -
#69 -
SyntaxTree.readcan now handle an empty file.
2.3.1 - 2022-04-22¶ ↑
Changed¶ ↑
-
SyntaxTree::Ifnodes inside ofSyntaxTree::Commandarguments should include a space before if they are flat.
2.3.0 - 2022-04-22¶ ↑
Added¶ ↑
-
#52 -
SyntaxTree::Formatter.formatfor formatting an already parsed node. -
#56 -
ifandunlesscan now be transformed into ternaries if they’re simple enough. -
#56 - Nicely format call chains by one indentation.
-
#56 - Handle trailing operators in call chains when they are necessary because of comments.
-
#56 - Add some specialized formatting for Sorbet
sigblocks to make them appear nicer.
Changed¶ ↑
-
#53 - Optional keyword arguments on method declarations have a value of
nilnow instead offalse. This makes it easier to use the visitor. -
#54 - Flow control operators can now skip parentheses for simple, individual arguments. e.g.,
break(1)becomesbreak 1. -
#54 - Don’t allow modifier conditionals to modify ternaries.
-
#55 - Skip parentheses and brackets on arrays for flow control operators. e.g.,
break([1, 2, 3])becomesbreak 1, 2, 3. -
#56 - Don’t add parentheses to method calls if you don’t need them.
-
#56 - Format comments on empty parameter sets. e.g.,
def foo # barshould keeps its comment. -
#56 -
%s[]symbols on assignments should not indent to the next line. -
#56 - Empty hash and array literals with comments inside of them should be formatted correctly.
2.2.0 - 2022-04-19¶ ↑
Added¶ ↑
-
#51 -
SyntaxTree::Locationnodes now have pattern matching. -
#51 -
SyntaxTree::Heredocnow have adedentfield that indicates the number of spaces to strip from the beginning of the string content.
Changed¶ ↑
-
#51 -
SyntaxTree::HshPtnwill now add athenif you use a bare**andSyntaxTree::AryPtnwill do the same for a bare*on the end. -
#51 -
SyntaxTree::MLHSParennow has a comma field in case a trailing comma has been added to a parenthesis destructuring, as in((foo,)). -
#51 -
SyntaxTree::FndPtnhas much improved parsing now.
2.1.1 - 2022-04-16¶ ↑
Changed¶ ↑
-
#45 - Fix parsing expressions like
foo.instance_exec(&T.must(block)), where there are twoargs_add_blockcalls with a single&. Previously it was associating the&with the wrong block. -
#47 - Handle expressions like
not(). -
#48 - Handle special call syntax with
::operator. -
#49 - Handle expressions like
case foo; in {}; end. -
#50 - Parsing expressions like
case foo; in **nil; end.
2.1.0 - 2022-04-12¶ ↑
Added¶ ↑
-
The
SyntaxTree::Visitorclass now implements the visitor pattern for Ruby nodes. -
The
SyntaxTree::Visitor.visit_method(name)method. -
Support for Ruby 2.7.
-
Support for comments on
rescueandelsekeywords. -
SyntaxTree::Locationnow additionally hasstart_columnandend_column. -
The CLI now accepts content over STDIN for the
ast,check,debug,doc,format, andwritecommands.
Removed¶ ↑
-
The missing hash value inlay hints have been removed.
2.0.1 - 2022-03-31¶ ↑
Changed¶ ↑
-
Move the
SyntaxTree.register_handlermethod to the correct location.
2.0.0 - 2022-03-31¶ ↑
Added¶ ↑
-
The new
SyntaxTree.register_handlerhook for plugins. -
The new
--plugins=option on the CLI.
Changed¶ ↑
-
Changed
SyntaxTreefrom being a class to being a module. The parser functionality is moved intoSyntaxTree::Parser. -
There is now a parent class for all of the nodes named
SyntaxTree::Node. -
The
Implicitsclass has been renamed toInlayHintsto match the new LSP spec.
Removed¶ ↑
-
The disassembly code action has been removed to limit the scope of this project overall.
1.2.0 - 2022-01-09¶ ↑
Added¶ ↑
-
Support for Ruby 3.1 syntax, including: blocks without names, hash keys without values, endless methods without parentheses, and new argument forwarding.
-
Support for pinned expressions and variables within pattern matching.
-
Support endless ranges as the final argument to a
whenclause.
1.1.1 - 2021-12-09¶ ↑
Added¶ ↑
-
#7 Better formatting for hashes and arrays that are values in hashes.
-
#9 Special handling for RSpec matchers when nesting
CommandCallnodes. -
#10 Force the maintaining of the modifier forms of conditionals and loops if the statement includes an assignment. Also, for the maintaining of the block form of conditionals and loops if the predicate includes an assignment.
1.1.0 - 2021-12-08¶ ↑
Added¶ ↑
-
Better handling for formatting files with errors.
-
Colorize the output snippet using IRB.
1.0.0 - 2021-12-08¶ ↑
Added¶ ↑
-
The ability to “check” formatting by formatting the output of the first format.
-
Comments can now be attached to the
casekeyword. -
Remove escaped forward slashes from regular expression literals when converting to
%r. -
Allow arrays of
CHARnodes to be converted toQWordsunder certain conditions. -
Allow
HashLiteralopening braces to have trailing comments. -
Add parentheses if
Yieldbreaks onto multiple lines. -
Ensure all nodes that could have heredocs nested know about their end lines.
-
Ensure comments on assignment after the
=before the value keep their place. -
Trailing comments on parameters with no parentheses now do not force a break.
-
Allow
ArrayLiteralopening brackets to have trailing comments. -
Allow different line suffix nodes to have different priorities.
-
Better support for encoding by properly reading encoding magic comments.
-
Support singleton single-line method definitions.
-
Support
stree-ignorecomments to ignore formatting nodes. -
Add special formatting for arrays of
VarRefnodes whose sum width is greater than 2 * the maximum width. -
Better output formatting for the CLI.
Changed¶ ↑
-
Force a break if a block is attached to a
CommandorCommandCallnode. -
Don’t indent
CommandCallarguments if they don’t fit aligned. -
Force a break in
Callnodes if there are comments on the receiver. -
Do not change block bounds if inside of a
CommandorCommandCallnode. -
Handle empty parentheses inside method calls.
-
Skip indentation for special array literals on assignment nodes.
-
Ensure a final breakable is inserted when converting an
ArrayLiteralto aQSymbols. -
Fix up the
doc_widthcalculation forCommandCallnodes. -
Ensure parameters inside a lambda literal when there are no parentheses are grouped.
-
Ensure when converting an
ArrayLiteralto aQWordsthat the strings do not contain[. -
Stop looking for parent
CommandorCommandCallnodes in blocks once you hitStatements. -
Ensure nested
Lambdanodes get their correct bounds. -
Ensure we do not change block bounds within control flow constructs.
-
Ensure parentheses are added around keywords changing to their modifier forms.
-
Allow conditionals to take modifier form if they are using the
thenkeyword with aVoidStmt. -
UntilModandWhileModnodes that wrap aBeginshould be forced into their modifier forms. -
Ensure
Forloops keep their trailing commas. -
Replicate content for
__END__keyword exactly. -
Keep block
If,Unless,While, andUntilforms if there is an assignment in the predicate. -
Force using braces if the block is within the predicate of a conditional or loop.
-
Allow for the possibility that
CommandCallnodes might not have arguments. -
Explicitly handle
?"so that it formats properly. -
Check that a block is within the predicate in a more relaxed way.
-
Ensure the
Returnbreaks with brackets and not parentheses. -
Ensure trailing comments on parameter declarations are consistent.
-
Make
CommandandCommandCallaware that their arguments could exceed their normal expected bounds because of heredocs. -
Only unescape forward slashes in regular expressions if converting from slash bounds to
%rbounds. -
Allow
Whennodes to grab trailing comments away from their statements lists. -
Allow flip-flop operators to be formatted correctly within
IfModandUnlessModnodes. -
Allow
IfModandUnlessModto know about heredocs moving their bounds. -
Properly handle breaking parameters when there are no parentheses.
-
Properly handle trailing operators in call chains with attached comments.
-
Force using braces if the block is within the predicate of a ternary.
-
Properly handle trailing comments after a
thenoperator on aWhenorInclause. -
Ensure nested
HshPtnnodes use braces. -
Force using braces if the block is within a
Binarywithin the predicate of a loop or conditional. -
Make sure
StringLiteralandStringEmbExprknow that they can be extended by heredocs. -
Ensure
Intnodes with preceding unary+get formatted properly. -
Properly handle byte-order mark column offsets at the beginnings of files.
-
Ensure
Words,Symbols,QWords, andQSymbolsproperly format when their contents contain brackets. -
Ensure ternaries being broken out into
if…else…endget wrapped in parentheses if necessary.
Removed¶ ↑
-
The
AccessCtrlnode in favor of just formatting correctly when you hit aStatementsnode. -
The
MethodAddArgnode is removed in favor of an optionalargumentsfield onCallandFCall.
0.1.0 - 2021-11-16¶ ↑
Added¶ ↑
-
🎉 Initial release! 🎉