aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/syntax/SkylarkNestedSet.java
Commit message (Collapse)AuthorAge
* Fix crash when unioning depsets with different ordersGravatar brandjon2017-07-14
| | | | | | | Also refactor FAIL_FAST_HANDLER to throw something more specific than IllegalArgumentException. This bug was masked because the test assertion that would've caught it considered IllegalArgumentException to be an expected error, the same as EvalException. RELNOTES: None PiperOrigin-RevId: 161809957
* Misc cleanups of syntax dirGravatar brandjon2017-07-12
| | | | | RELNOTES: None PiperOrigin-RevId: 161560683
* 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
* Make depset.to_list() return a non-frozen listGravatar brandjon2017-04-10
| | | | | | | Previously it returned a frozen list. Using frozen mutables as part of the API specification is an unnecessary complication and should be avoided. RELNOTES[INC]: The return type of depset.to_list() is now a list rather than a frozen list. (Modifying the list has no effect on the depset.) PiperOrigin-RevId: 152504943
* Update depset constructor/method docsGravatar Jon Brandvein2017-02-27
| | | | | | -- PiperOrigin-RevId: 148469323 MOS_MIGRATED_REVID=148469323
* Add more depset documentationGravatar Jon Brandvein2017-02-27
| | | | | | | | | | Updated class doc, added examples to depsets.md. Constructor/method doc updates will be a follow-up CL. -- PiperOrigin-RevId: 148463032 MOS_MIGRATED_REVID=148463032
* Update doc wrt set vs depset.Gravatar Laurent Le Brun2017-02-20
| | | | | | -- PiperOrigin-RevId: 147908180 MOS_MIGRATED_REVID=147908180
* Fix the documentation of set/depsetGravatar Vladimir Moskva2017-02-14
| | | | | | -- PiperOrigin-RevId: 147456653 MOS_MIGRATED_REVID=147456653
* Change depset conversion to stringsGravatar Vladimir Moskva2017-01-30
| | | | | | | | | | RELNOTES[INC]: Depsets (former sets) are converted to strings as "depset(...)" instead of "set(...)". -- PiperOrigin-RevId: 145990995 MOS_MIGRATED_REVID=145990995
* Refactor SkylarkNestedSet to not implement IterableGravatar Jon Brandvein2017-01-20
| | | | | | | | | | | | | | This is not intended to be a user-visible semantic change, aside from error messages. This is to help avoid unintentional flattening of depsets, and to narrow down the number of call sites where this can occur, to help us print warning/deprecation messages. EvalUtils#toIterable will now return an ImmutableList in place of SkylarkNestedSet. This should be ok since the caller shouldn't be relying on the result being a Skylark-safe type. Code that takes Iterable because it accepts either a list or set, can instead be changed to take Object and use EvalUtils#toIterableStrict for validation. Note that NestedSet still implements Iterable, so native code can still easily and accidentally flatten sets. -- PiperOrigin-RevId: 145044023 MOS_MIGRATED_REVID=145044023
* Add new names for depset traversal ordersGravatar Jon Brandvein2017-01-20
| | | | | | | | | | The old names are deprecated but still supported for now. A flag for enforcing the deprecation will come in a later change. RELNOTES[INC]: The traversal orders for depsets have been renamed. The old names are deprecated and will be removed in the future. New names: "stable" -> "default", "compile" -> "postorder", "link" -> "topological", "naive_link" -> "preorder". -- PiperOrigin-RevId: 145004718 MOS_MIGRATED_REVID=145004718
* Add a to_list() method to depsetsGravatar Jon Brandvein2017-01-16
| | | | | | | | | | | | This is the preferred way to test for membership in, or iterate over, depsets (aka nested sets, aka plain old set()). The old way of doing membership tests or iterations over the raw depset itself is deprecated and may be removed in the future. Note that membership testing in a depset was always an O(n) operation, perhaps contrary to the user's expectation, so using to_list() does not make things asymptotically worse. It just makes things more explicit. RELNOTES: To iterate over or test for membership in a set, prefer using the new to_list() method. E.g., "for x in myset.to_list():", or "print(x in myset.to_list())". Iteration/membership-test on the raw set itself is deprecated. -- PiperOrigin-RevId: 144452510 MOS_MIGRATED_REVID=144452510
* Refactor SkylarkNestedSet type checks and testsGravatar Jon Brandvein2017-01-13
| | | | | | | | Moved some tests, fixed formatting, changed to use assertThat(). -- PiperOrigin-RevId: 144356402 MOS_MIGRATED_REVID=144356402
* Rollback of commit 0d1dc5537903a8c2ad56e66cee129b8f4d4e2592.Gravatar Pedro Liberal Fernandez2017-01-11
| | | | | | -- PiperOrigin-RevId: 144194956 MOS_MIGRATED_REVID=144194956
* Improve performance and semantics of union of Skylark setsGravatar Jon Brandvein2017-01-10
| | | | | | | | | | | | | | | | | | | | | | == Before this change == Previously, if a and b are sets, then a + b created a new set c whose direct and transitive elements were all those of a, and with b appended as an additional transitive element. If on the other hand b is a list instead of a set, then its contents were appended as additional direct elements of c. In both cases, you can think of c as a copy of a that also knows about b. This copying of a's elements into c can lead to accumulation when you do it repeatedly, e.g. x += y in a loop. Each union can take O(n) time so you get O(n^2) time overall. Nested set union is supposed to be O(1) time per operation and O(n) time overall. It also leads to surprising iteration orders. If you do a + b + c + d (left-associative), where each one is a set, then when you do a post-order traversal you get the elements of b, c, d, and a, in that order. This is because b, c, and d each get appended as transitive children of the copies of a. == After this change == If a and b are sets, then a + b returns a new set c with a and b as its two transitive children. If b is a list, then c has a as its only transitive child and b's elements as its only direct elements. This is straightforward, O(1), and avoids the problem with the confusing order. It is implemented by removing the items/transitiveItems fields and just relying on NestedSetBuilder. RELNOTES[INC]: (Skylark) Set union is now O(1). As a side-effect, the iteration order of sets produced by union has changed. "print(set([1]) + set([2]) + set([3]))" will now give back the order 1, 2, 3 instead of 2, 3, 1. -- PiperOrigin-RevId: 143972165 MOS_MIGRATED_REVID=143972165
* Make depsets temporarily completely backward compatibleGravatar Vladimir Moskva2016-12-27
| | | | | | | | | `str(depset(...))` should return "set(...)" for now as some of the existing code may rely on it. -- PiperOrigin-RevId: 143014369 MOS_MIGRATED_REVID=143014369
* Add `depset` as an alias to `set` in SkylarkGravatar Vladimir Moskva2016-12-27
| | | | | | | | | | Renamed all occurrences of `set` to `depset`, added a `set` object constructor for (temporary) backward compatibility. `type(depset())` still temporarily returns "set", that will be changed in the future. RELNOTES: The `set` constructor is deprecated in favor of `depset` -- PiperOrigin-RevId: 142851587 MOS_MIGRATED_REVID=142851587
* Remove weird restriction on '|' operator from SkylarkNestedSets.Gravatar Dmitry Lomov2016-11-23
| | | | | -- MOS_MIGRATED_REVID=139926067
* Supported "in" operator for all SkylarkIndexable objects.Gravatar Vladimir Moskva2016-10-07
| | | | | -- MOS_MIGRATED_REVID=135483694
* Make SkylarkClassObject "Bazel-specific".Gravatar Dmitry Lomov2016-08-05
| | | | | | | This in preparation to DeclaredProviders implementation. -- MOS_MIGRATED_REVID=129420617
* Check that deeply nested values in sets are immutableGravatar Jon Brandvein2016-08-04
| | | | | -- MOS_MIGRATED_REVID=129331086
* Reorganize Skylark Reference documentation.Gravatar Dmitry Lomov2016-06-29
| | | | | -- MOS_MIGRATED_REVID=126081020
* Introduce skylark provider for objc.Gravatar Cal Peyser2016-03-18
| | | | | -- MOS_MIGRATED_REVID=117485208
* Reinstate mutable maps, again.Gravatar Francois-Rene Rideau2016-02-17
| | | | | -- MOS_MIGRATED_REVID=114860576
* Rollback of commit f941d56acfad5f8c819c81b494f806ea74ea7fd8.Gravatar Carmi Grushko2016-02-02
| | | | | | | | | | | | | | | | | | *** Reason for rollback *** Breaks many targets, see [] *** Original change description *** Reinstate mutable SkylarkDict Add <String, Object> annotation to optionMap invocation in SkylarkAttr, to make JDK 1.7 happy. Give the visible name "aspect" to class SkylarkAspect. -- MOS_MIGRATED_REVID=113543873
* Reinstate mutable SkylarkDictGravatar Francois-Rene Rideau2016-02-01
| | | | | | | | | | Add <String, Object> annotation to optionMap invocation in SkylarkAttr, to make JDK 1.7 happy. Give the visible name "aspect" to class SkylarkAspect. -- MOS_MIGRATED_REVID=113394826
* Rollback of commit c0a8c58b9230a1f5d76269eb7dc6b11e18f19686.Gravatar Damien Martin-Guillerez2016-01-29
| | | | | | | | | | | | | | | | | | | | | | | *** Reason for rollback *** Break Java 1.7 builds of Bazel. See http://ci.bazel.io/job/Bazel/JAVA_VERSION=1.7,PLATFORM_NAME=linux-x86_64/327/console Test: git clone ... && git revert c0a8c58 && export JAVA_VERSION=1.7 && export BAZEL_COMPILE_TARGET=compile && bash -c "source scripts/ci/build.sh; bazel_build" *** Original change description *** Make Skylark dicts mutable Represent Skylark dict using a new subclass SkylarkDict<K, V> of Map<K, V>. Back it with a TreeMap to provide a deterministic iteration order. Also make SkylarkList generic in its element type <E>. Have Artifact implement Comparable<Object> so it can be used as TreeMap key. -- MOS_MIGRATED_REVID=113359718
* Make Skylark dicts mutableGravatar Francois-Rene Rideau2016-01-29
| | | | | | | | | | Represent Skylark dict using a new subclass SkylarkDict<K, V> of Map<K, V>. Back it with a TreeMap to provide a deterministic iteration order. Also make SkylarkList generic in its element type <E>. Have Artifact implement Comparable<Object> so it can be used as TreeMap key. -- MOS_MIGRATED_REVID=113277489
* 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
* Fix documentation of set.Gravatar Laurent Le Brun2015-12-16
| | | | | | | Type "map" doesn't exist. "struct" is not allowed. -- MOS_MIGRATED_REVID=110265638
* Use Bazel Preconditions variant which avoids varargs array creationGravatar Mark Schaller2015-12-10
| | | | | | | Reduces garbage. -- MOS_MIGRATED_REVID=109914243
* Workaround javac 1.7 bugGravatar Dmitry Lomov2015-11-19
| | | | | -- MOS_MIGRATED_REVID=108243881
* Minor improvements to set documentation.Gravatar Laurent Le Brun2015-10-16
| | | | | -- MOS_MIGRATED_REVID=105591091
* 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
* 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
* Change URLs to bazelbuildGravatar Kristina Chodorow2015-09-01
| | | | | -- MOS_MIGRATED_REVID=102022958
* Improve documentation and error messages for sets.Gravatar Laurent Le Brun2015-08-28
| | | | | -- MOS_MIGRATED_REVID=101765937
* Split Skylark Library into multiple pages, one per module. Add collapsibleGravatar David Chen2015-08-18
| | | | | | | | submenus to sidebar, and expand and highlight the link for the current page. Collapse sidebar on mobile and expose button for toggling sidebar. -- MOS_MIGRATED_REVID=100836792
* Documented the iteration order of SkylarkNestedSets.Gravatar Florian Weikert2015-07-29
| | | | | | | Also added additional tests that check for the correct behavior regarding order. -- MOS_MIGRATED_REVID=99370126
* 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
* The Order enum now supports the conversion of its values to and from strings.Gravatar Florian Weikert2015-06-10
| | | | | | | This functionality used to be part of SkylarkNestedSet. -- MOS_MIGRATED_REVID=95526136
* Skylark: Update doc for setsGravatar Laurent Le Brun2015-04-09
| | | | | -- MOS_MIGRATED_REVID=90707320
* Skylark: 'in' works on sets.Gravatar Laurent Le Brun2015-03-31
| | | | | -- MOS_MIGRATED_REVID=89977206
* Skylark: Show ordering when pretty-printing sets.Gravatar Laurent Le Brun2015-03-10
| | | | | -- MOS_MIGRATED_REVID=88149329
* Some cleanup changes.Gravatar Ulf Adams2015-03-05
| | | | | -- MOS_MIGRATED_REVID=87821306
* Add Union, contains() to SkylarkTypeGravatar Francois-Rene Rideau2015-03-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactor SkylarkType, notably adding Union types and runtime typechecks. These are pre-requisites to unifying all Skylark function calls to use the same code path, that will check types (like SkylarkFunction currently does) as well handle a more complete Python calling convention (like MixedModeFunction is almost but not quite able to do). A SkylarkType can be either * a Simple type corresponding to a Java class, with special types TOP and BOTTOM corresponding respectively to Object and EmptyType (similar to Void). * a Combination of a generic class (LIST, MAP or SET) and an argument type * a Union of a finite number of types * a FunctionType associated with a name and a returnType (with ugly validation-time side-effects that we should probably move out of the type) Unions are necessary because: 1- the type of some builtin function arguments are actually the Union of some type and a function type for a callback that computes the actual value. 2- the type of some builtin function arguments declared as "List" is actually the Union of java List and SkylarkList. 3- instead of adding lots of special cases at the point of argument validation, it's cleaner and more generally useful to have explicit Union types, that can then be displayed to users for documentation or debugging purposes. Validation-time "type inference" is re-expressed simply as type intersection. None is treated specially as inferred into TOP instead of NoneType. Combination types are printed as genericType of argTypes, e.g. "dict of ints". "type" and "generic1" become "genericType" and "argType". In SkylarkList and SkylarkNestedSet, genericType becomes contentType. -- MOS_MIGRATED_REVID=87340881
* Tweaks off of upcoming changes to SkylarkType.Gravatar Francois-Rene Rideau2015-02-25
| | | | | -- MOS_MIGRATED_REVID=87154772
* Lots of comments, clarification and correction in Skylark docs.Gravatar Laszlo Csomor2015-02-16
| | | | | -- MOS_MIGRATED_REVID=86436572
* Cosmetic changes moved out of []Gravatar Francois-Rene Rideau2015-02-11
| | | | | | | | These shouldn't affect the semantic of the program in any significant way, but will hush the linter and other such metaprograms. -- MOS_MIGRATED_REVID=86089271
* Skylark: Fix SkylarkNestedSet.toStringGravatar Laurent Le Brun2015-02-09
| | | | | -- MOS_MIGRATED_REVID=85874312