aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/syntax/Printer.java
Commit message (Collapse)AuthorAge
* Skylark Pretty Printer: shorten empty listGravatar Klaus Aehlig2018-06-14
| | | | | | | | | | | | | | When pretty printing a Skylark value, lists are presented as the opening bracket on a line by itself, each entry on its own line, and the closing bracket again on its own line. While this generally improves readability, for the empty list this is not the case, as the expression [] can easily be understood at a glance. In fact, the additional line even makes the outer structure harder to see, as it is spread over even more lines. Therefore, shorten the printing of the empty list to be on a single line. Change-Id: I032d1550b1f99bce47dbec7e77a4d5c6656d78a1 PiperOrigin-RevId: 200558784
* Add a pretty-printer class to SkylarkGravatar Klaus Aehlig2018-05-29
| | | | | | | | | | | With the recording of the results of repository rules (that eventually will lead to an implementation of the WORKSPACE.resolved proposal) bazel started writing out lengthy Skylark values. To make this file more readable for humans, add a Skylkark printer that does at least some basic line breaking and indenting. Change-Id: I469d029421df9212b43747509dd17bd6c64da4a8 PiperOrigin-RevId: 198389112
* Fix Printer.getPrinter(boolean)Gravatar brandjon2018-04-09
| | | | | | | Also rename it to a separate function since boolean args are vague. RELNOTES: None PiperOrigin-RevId: 192201308
* Split Args#add into three methods.Gravatar tomlu2018-04-05
| | | | | | | | | | | Args#add(value, *, arg, format) Args#add_all(value, *, arg, map_each, format_each, before_each, omit_if_empty, uniquify) Args#add_joined(value, *, arg, join_with, map_each, format_each, format_joined, omit_if_empty, uniquify) The old Args#add remains backwards compatible, but we add a flag to disable this compatibility mode. RELNOTES: None PiperOrigin-RevId: 191804482
* Add option to restrict format strings to %sGravatar brandjon2018-04-04
| | | | | | | This is useful for contexts like ctx.actions.args()'s methods, where %d and %r aren't appropriate placeholders. RELNOTES: None PiperOrigin-RevId: 191629195
* Change Skylark's print() on a rule target to print the Skylark-exposed ↵Gravatar cparsons2018-02-16
| | | | | | | | | provider keys. This change only affects printing a rule target directly -- it intentionally does not affect the behavior of str(target), as we want to avoid skylark code being able to parse potentially-private provider keys. RELNOTES: In skylark, print(target) now shows the provider keys of a target, as debug information. PiperOrigin-RevId: 186046226
* Break dependency on vfs from the interface of syntax and cmdline.Gravatar tomlu2017-11-06
| | | | | | | | These libs are exposed externally, implying that the vfs is also exposed externally. We break out PathFragment from vfs to still use this in their interface. This class is a much smaller dependency than the entire vfs. PiperOrigin-RevId: 174729373
* Remove deprecated legacy string representations of Skylark objectsGravatar vladmos2017-10-13
| | | | | | | | RELNOTES[INC]: The flag --incompatible_descriptive_string_representations is no longer available, old style string representations of objects are not supported anymore. PiperOrigin-RevId: 171952621
* Use SkylarkSemantics in place of options class in the interpreterGravatar brandjon2017-10-06
| | | | | | | Mainly this just means using getters instead of fields to access option values. RELNOTES: None PiperOrigin-RevId: 171101597
* Fix NPE in PrinterGravatar brandjon2017-08-17
| | | | | RELNOTES: None PiperOrigin-RevId: 165489091
* Clean up string representations for unknown objectsGravatar vladmos2017-07-17
| | | | | | | | Don't call the `toString` method on unknown objects as it potentially breaks hermeticity and determinism. Use a generic string like "<unknown object package.ClassName>" instead. PiperOrigin-RevId: 161970449
* Automated rollback of commit 0d2aa6369b09940d584b544fb10796387e0fafa0.Gravatar brandjon2017-07-12
| | | | | | *** Reason for rollback *** PiperOrigin-RevId: 161567104
* Clean up string representations for unknown objectsGravatar vladmos2017-07-12
| | | | | | | | Don't call the `toString` method on unknown objects as it potentially breaks hermeticity and determinism. Use a generic string like "<unknown object package.ClassName>" instead. PiperOrigin-RevId: 161544828
* Make some objects SkylarkValuesGravatar vladmos2017-07-11
| | | | | | | | | Skylark's Printer.BasePrinter doesn't guarantee it will call `.toString` on objects of unknown types, and in the future that won't be the case anymore. In order to keep their current string representations objects should implement the SkylarkValue interface by providing an explicit implementation of `repr`. PiperOrigin-RevId: 161526182
* Clean up string representations for labelsGravatar vladmos2017-07-05
| | | | | | | | | | | If --incompatible_descriptive_string_representations is passed, labels are converted to strings using `repr` differently: `Label("//package:name")` instead of `"//package:name"` This CL doesn't affect representations of other object types but provides the necessary infrastructure for it. PiperOrigin-RevId: 160955284
* Refactor PrinterGravatar vladmos2017-07-03
| | | | | | | It's now easier to customize Printer if in different situations objects should be printed differently. Also its API is cleaner now. Names of methods of SkylarkValue objects now reflect names of Skylark functions: SkylarkValue#repr and SkylarkPrintableValue#str. PiperOrigin-RevId: 160635154
* Add a pretty printer for Skylark ASTsGravatar brandjon2017-06-28
| | | | | | | This can be used to canonically compare ASTs for equality, e.g. in tests. RELNOTES: None PiperOrigin-RevId: 160283160
* Add missing fall through commentGravatar Liam Miller-Cushon2017-02-20
| | | | | | -- PiperOrigin-RevId: 147892584 MOS_MIGRATED_REVID=147892584
* Do not sort dict keys when printingGravatar Vladimir Moskva2017-02-17
| | | | | | | | | | Dict keys can in theory belong to different types, it's not allowed anymore to compare such objects by < in Skylark, so the Printer class shouldn't do it either. -- PiperOrigin-RevId: 147827109 MOS_MIGRATED_REVID=147827109
* Disallow comparison of objects of different types in SkylarkGravatar Vladimir Moskva2017-02-16
| | | | | | | | | | RELNOTES[INC]: It's not allowed anymore to compare objects of different types (i.e. a string to an integer) and objects for which comparison rules are not defined (i.e. a dict to another dict) using order operators. -- PiperOrigin-RevId: 147710942 MOS_MIGRATED_REVID=147710942
* Automated cleanupGravatar Laurent Le Brun2016-10-12
| | | | | -- MOS_MIGRATED_REVID=135816105
* Make SkylarkList a List.Gravatar Francois-Rene Rideau2016-01-22
| | | | | | | | | | | | | | | SkylarkList now implements the List interfaces, except that its mutating methods throw an UnsupportedOperationException, just like ImmutableList does. To actually mutate a SkylarkList, you need to pass a Location and a suitable Environment object with a matching Mutability while it is still active. Introduce SkylarkMutable and SkylarkMutable.MutableCollection to better handle mutable data structures. Remove some functions in EvalUtils made obsolete by this and previous changes regarding Skylark lists. -- MOS_MIGRATED_REVID=112768457
* Move annotation classes used for referencing framework Java classes from ↵Gravatar John Field2015-12-16
| | | | | | | | | | | | | | Skylark into their own package. This allows, e.g., classes in the syntax package to access classes in the cmdline package without creating circular dependencies. While we're here: - Removed a couple of unused BUILD deps flagged in []. - Updated SkylarkRuleImplementationFunctionsTest to remove non-ASCII characters and clarify the intent of the test. -- MOS_MIGRATED_REVID=110360763
* Optionally limits the length of the output of Printer.printList() (default = ↵Gravatar Florian Weikert2015-10-05
| | | | | | | no). -- MOS_MIGRATED_REVID=104655508
* Rollback of commit d7b64bd03100300b79cd33d04904ce9b0e6a5332.Gravatar Janak Ramakrishnan2015-10-05
| | | | | | | | | *** Reason for rollback *** Some rules write the toString representation of lists of files to disk and then read it back again. This breaks that. -- MOS_MIGRATED_REVID=104524336
* Limit the length of the output of Printer.printList().Gravatar Florian Weikert2015-09-30
| | | | | -- MOS_MIGRATED_REVID=104197461
* Rationalize copyright headersGravatar Damien Martin-Guillerez2015-09-25
| | | | | | | | | | | The headers were modified with `find . -type f -exec 'sed' '-Ei' 's|Copyright 201([45]) Google|Copyright 201\1 The Bazel Authors|' '{}' ';'` And manual edit for not Google owned copyright. Because of the nature of ijar, I did not modified the header of file owned by Alan Donovan. The list of authors were extracted from the git log. It is missing older Google contributors that can be added on-demand. -- MOS_MIGRATED_REVID=103938715
* Move Label from the lib.syntax to the lib.cmdline package so that:Gravatar Lukacs Berki2015-09-21
| | | | | | | | | | - Label parsing can be simplified - lib.syntax is only contains the code for Skylark and is reasonably independent from the problem domain of building things This change is mostly only changes to imports declarations. The rest is reversing the dependency between :cmdline and :syntax and moving a tiny amount of code between Printer and FilesetEntry and the addition of SkylarkPrintableValue that I couldn't be bothered to separate out into its own change. -- MOS_MIGRATED_REVID=103527877
* Refactor SkylarkList to allow MutableListGravatar Francois-Rene Rideau2015-09-21
| | | | | | | | Make SkylarkList no longer read-only to match Python and the BUILD language. Instead, subject it to a Mutability object inherited from the Environment. -- MOS_MIGRATED_REVID=103332973
* Cleanup Skylark types some moreGravatar Francois-Rene Rideau2015-09-17
| | | | | | | | | | | Clarify the criterion for being a valid Skylark value; stop claiming immutability is "the" criterion when Skylark now has mutable values; stop relying on a reflection with a magic list (this also fixes the SkylarkShell build). Clarify the criterion for determining immutable types when making a SkylarkNestedSet. Clarify and use the criterion for being a valid Skylark dict key. -- MOS_MIGRATED_REVID=103313934
* Create an abstraction for user defined data types in Skylark.Gravatar Lukacs Berki2015-09-17
| | | | | | | This will be used to remove Blaze-specific data types, FilesetEntry, Label and GlobList from the .syntax package. -- MOS_MIGRATED_REVID=103281375
* Remove dead code, set private visibilityGravatar Laurent Le Brun2015-09-14
| | | | | -- MOS_MIGRATED_REVID=102986851
* Move global objects to RuntimeGravatar Francois-Rene Rideau2015-08-31
| | | | | | | | Move away global constants and global namespaces out of Environment and into a new file Runtime. -- MOS_MIGRATED_REVID=101940218
* Refactor skylark format internalsGravatar Francois-Rene Rideau2015-08-26
| | | | | | | | | | Rename some methods to avoid clashes. Add function formattable to create lazily-formatted objects, remove now unused strFormattable and reprFormattable. Also some whitespace cleanup. -- MOS_MIGRATED_REVID=101459565
* Changes related to the order of Skylark dictionaries:Gravatar Florian Weikert2015-08-04
| | | | | | | | | - Objects of different types can now be compared. - Printer now prints dictionaries in a deterministic order, even when the keys have different types. - testEval() in EvaluationTestCases evaluates both expressions instead of comparing expression strings. Consequently, if a statement describes a collection, its order does no longer matter when doing the comparison. -- MOS_MIGRATED_REVID=99829458
* Printer can be configured to use single quotation marks instead of double ↵Gravatar Florian Weikert2015-07-01
| | | | | | | quotation marks -- MOS_MIGRATED_REVID=97320494
* Rollback of commit 13ef26d0817a429bf214d3dc4c5551e616e403fe.Gravatar Laurent Le Brun2015-06-30
| | | | | | | | | | | | | | | | | *** Reason for rollback *** Breaks 'blaze query' *** Original change description *** Skylark: write labels readably Write a label as Label("//x:x") instead of merely "//x:x", so it can be read and evaluated back, as per the Python convention. However, the OutputFormatter for BUILD files still needs to output "//x:x". -- MOS_MIGRATED_REVID=97156166
* Skylark: write labels readablyGravatar Francois-Rene Rideau2015-06-18
| | | | | | | | | Write a label as Label("//x:x") instead of merely "//x:x", so it can be read and evaluated back, as per the Python convention. However, the OutputFormatter for BUILD files still needs to output "//x:x". -- MOS_MIGRATED_REVID=96209979
* Skylark: support %r format specifierGravatar Francois-Rene Rideau2015-06-17
| | | | | | | | Refactor the implementation of format. Add %r. Improve some error messages. -- MOS_MIGRATED_REVID=96154542
* Implement Skylark function reprGravatar Francois-Rene Rideau2015-06-15
| | | | | | | | | | | | | | | | | Move printing code from EvalUtils to Printer. Rename functions in Printer: printValue becomes str or print, prettyPrintValue becomes repr or write, formatString becomes format, makeFormattable becomes strFormattable, prettyPrintValues becomes listString. write being self-sufficient is made the reference, and print is the one that is a wrapper around write, rather than the other way around, avoiding mutual recursion. -- MOS_MIGRATED_REVID=95897834
* Skylark: fix escaping of backslashGravatar Francois-Rene Rideau2015-06-08
Create a Printer class into which to eventually move all printing infrastructure currently in EvalUtils. For now, only move string escaping there. Fix the forgotten case of backslash. Allow any style of Python quotes, while we're at it, but keep using simple double-quote as the default. -- MOS_MIGRATED_REVID=95328052