Commit Graph
511 Commits
Author SHA1 Message Date
Guice TeamandGuice Team 15ce8eb669 Avoid defensive clone() in ParameterizedType.getActualTypeArguments() when possible.
PiperOrigin-RevId: 347701829
2020-12-15 15:12:54 -08:00
Guice TeamandGuice Team 363f568b6d Fix quadratic behavior of AbstractProcessor.process() observed in profiles.
The received lists are always ArrayList, for which removing items one-by-one
from the left is inefficient.

This changes the behavior on exception.  Unlike std::remove_if,
ArrayList.removeIf() buffers all filter results before shifting any elements.

PiperOrigin-RevId: 347469725
2020-12-14 14:27:57 -08:00
Guice TeamandGuice Team 2712230640 Fix formatting of source with module stack. Add NullInjectedIntoNonNullable tests.
PiperOrigin-RevId: 346890324
2020-12-10 16:30:51 -08:00
Guice TeamandGuice Team a795fcc1b8 Clarify wording of the MissingConstructor Guice error message
PiperOrigin-RevId: 345502715
2020-12-03 11:57:18 -08:00
Guice TeamandGuice Team 338d0039c1 Add documentation for AbstractBindingBuilder.
PiperOrigin-RevId: 340925080
2020-11-05 14:07:24 -08:00
Guice TeamandGuice Team 383d377436 Bump snapshot version, update README & prior API xml
PiperOrigin-RevId: 339910400
2020-10-30 11:43:16 -07:00
Guice TeamandGuice Team 9e7afde656 Documentation nit: update text to match variable name.
PiperOrigin-RevId: 339493357
2020-10-28 10:55:31 -07:00
Guice TeamandGuice Team f3f8fc0c7c Update the AbstractModule javadoc
PiperOrigin-RevId: 339493051
2020-10-28 10:52:53 -07:00
Guice TeamandGuice Team ba5b90a9f6 Update ASM to version 9.0.
Closes #1400

PiperOrigin-RevId: 338751330
2020-10-23 15:00:54 -07:00
Guice TeamandGuice Team 80b91afae2 Update tests to support running with Java 15.
In Java 15, the annotation `toString` implementation omits the member name.

PiperOrigin-RevId: 338746927
2020-10-23 14:37:28 -07:00
Guice TeamandGuice Team b97095d388 Delete obsolete methods in Messages and migrate callers to use equivalent methods in SourceFormatter.
PiperOrigin-RevId: 338582362
2020-10-22 17:32:37 -07:00
Guice TeamandGuice Team d3df2d5854 Delete deprecated dependency stack APIs.
PiperOrigin-RevId: 338343877
2020-10-21 14:44:42 -07:00
Guice TeamandGuice Team 50e7c7e02c Remove obsolete error message flag and clean up dead code.
PiperOrigin-RevId: 338104581
2020-10-20 11:55:35 -07:00
Guice TeamandGuice Team 5caa549395 Enable the new Guice error messages.
Changes include:

 - update Guice tests that asserts error messages
 - export new errors tests
 - update Guice compiler flag so parameter names are available at runtime, which is required for the errors tests

PiperOrigin-RevId: 337602195
2020-10-16 16:55:03 -07:00
Guice TeamandGuice Team 9a8e46716e Revert previous change because it broke some tests when running with openjdk8.
PiperOrigin-RevId: 337517262
2020-10-16 09:13:55 -07:00
Guice TeamandGuice Team 2c8c7fed12 Enable the new Guice error messages.
Changes include:
- update Guice tests that asserts error messages
- export new errors tests
- update Guice compiler flag so parameter names are available at runtime, which is required for the errors tests

PiperOrigin-RevId: 337401912
2020-10-15 16:06:22 -07:00
Liam Miller-CushonandGuice Team 180ed4ead4 Replace annotations-in-comments with real annotations
PiperOrigin-RevId: 337365709
2020-10-15 13:03:29 -07:00
Guice TeamandGuice Team 1ae63eb443 Strip embedded class name legend in the case that one Guice error is included in another Guice error.
PiperOrigin-RevId: 336366033
2020-10-09 14:30:12 -07:00
Guice TeamandGuice Team 0781568a6c Fix test when bytecode generation is disabled.
PiperOrigin-RevId: 336311235
2020-10-09 09:51:37 -07:00
Guice TeamandGuice Team dd873be400 Remove AOP build variant.
Changes include:

- skip tests that are testing bytecode generation enabled behaviors
- make line number and source file name information available even when bytecode generation is disabled since it does not use bytecode generation and makes testing easier (some tests rely on the information being available)
- update maven pom files to stop producing a no-aop version of Guice
- added test profile to execute tests with bytecode generation disabled

PiperOrigin-RevId: 336306344
2020-10-09 09:23:54 -07:00
Guice TeamandGuice Team 6c6eb52332 Rename guice_aop_option flag to guice_bytecode_gen_option.
This makes it explicit that the flag controls whether Guice uses bytecode generation at runtime and not just method interception (AOP).

PiperOrigin-RevId: 336196985
2020-10-08 17:19:56 -07:00
Guice TeamandGuice Team 36b710d441 Add internal support for recognizing Kotlin nullability in Guice. This will be available publicly in a later CL.
PiperOrigin-RevId: 335965575
2020-10-07 15:29:19 -07:00
Guice TeamandGuice Team deb5a1b3f0 Add an option to control whether AOP is enabled or not.
Also remove some unnecessary methods by inlining the calls.

PiperOrigin-RevId: 335917232
2020-10-07 11:47:10 -07:00
Guice TeamandGuice Team 3bc61ccec2 Add internal support for recognizing Kotlin nullability in Guice. This will be available publicly in a later CL.
PiperOrigin-RevId: 335756454
2020-10-06 17:25:44 -07:00
Guice TeamandGuice Team b7cadc1cfa Migrate several tests to junit4 so that tests that rely on AOP can be skipped using Assume.assumeTrue.
PiperOrigin-RevId: 335755255
2020-10-06 17:18:53 -07:00
Guice TeamandGuice Team b0e5ade45e Add internal support for recognizing Kotlin nullability in Guice. This will be available publicly in a later CL.
PiperOrigin-RevId: 335739263
2020-10-06 15:59:25 -07:00
Guice TeamandGuice Team 690e189a7d Use assumeTrue to skip tests that only need to run under certain conditions.
This requires migrating some tests from JUnit3 to JUnit4.

PiperOrigin-RevId: 335094691
2020-10-02 13:55:43 -07:00
Guice TeamandGuice Team 67c957b5e4 Include the @RestrictedBindingSource explanation as a missing binding suggestion.
PiperOrigin-RevId: 334803319
2020-10-01 06:48:28 -07:00
Guice TeamandGuice Team 9997527a93 Quote the duplicate key in DuplicateMapKeyError.
This will ensure that the key will not be modified by Guice's package name compressor.

Also fix package name compressor to handle single letter class names.

PiperOrigin-RevId: 334653432
2020-09-30 12:24:00 -07:00
Guice TeamandGuice Team 471a25f1c7 Do not compress package names in string literals.
Previously any string that matches the package name pattern will be shortened and this is undesirable when the text is not actually meant to be interpreted as a package name.

This change gives user a way to disable the package name compressor by putting the text in double quotation marks.

PiperOrigin-RevId: 334254171
2020-09-28 15:48:31 -07:00
Guice TeamandGuice Team fae2e289df Internal change.
PiperOrigin-RevId: 332883178
2020-09-21 10:42:42 -07:00
Guice TeamandGuice Team 0beaff51e0 Add a check for OptionalBinder infinite recursion.
When an optional binder binding was linked to the same class like below, infinite recursion occurs. There is a check for recursive binding in BindingProcessor class for all linked bindings but that did not work for OptionalBinder since OptionalBinder original key annotation is wrapped into something. So, comparing the original key and linked binding key didn't work.

Added a check for that.

Example:

```
OptionalBinder.newOptionalBinder(binder(), MyClass.class)
    .setBinding()
    .to(MyClass.class);
```

PiperOrigin-RevId: 332062297
2020-09-16 12:29:41 -07:00
Guice TeamandGuice Team 9b45ad8536 Tweak DuplicateMapKeyError so the summary include what the duplicate key is.
This makes it easier to assert the error in user code since people usually care about what the duplicate keys are.

PiperOrigin-RevId: 330613716
2020-09-08 16:42:17 -07:00
Colin DeckerandGuice Team 835084290b Replace some usernames in TODOs.
PiperOrigin-RevId: 329928334
2020-09-03 09:01:02 -07:00
Guice TeamandGuice Team fb63a55517 Roll forward with fixes and an extra test.
*** Original change description ***

Support custom formatting for CHILD_BINDING_ALREADY_SET error.

PiperOrigin-RevId: 329793504
2020-09-02 14:53:44 -07:00
Guice TeamandGuice Team 59a07fad81 Automated rollback of commit 7e6a6cf83f.
*** Reason for rollback ***

Broke some tests, see b/167569290

*** Original change description ***

Support custom formatting for CHILD_BINDING_ALREADY_SET error.

***

PiperOrigin-RevId: 329731579
2020-09-02 09:51:35 -07:00
Guice TeamandGuice Team 7e6a6cf83f Support custom formatting for CHILD_BINDING_ALREADY_SET error.
PiperOrigin-RevId: 329571324
2020-09-01 13:35:01 -07:00
Guice TeamandGuice Team ee1c02fc77 Add custom formatting for duplicate element error in Multibinder.
This now supports printing all the duplicate elements in the set not just the first pair.

PiperOrigin-RevId: 329558785
2020-09-01 12:30:39 -07:00
Guice TeamandGuice Team a689de7884 Only compress class names with at least 2 package names.
This avoid mistaking normal sentences in user added error message as class names. It is also rare and less useful to compress a short class name anyway.

PiperOrigin-RevId: 329401381
2020-08-31 16:28:41 -07:00
Guice TeamandGuice Team 77abaf34d6 Minor changes to error formatting.
- Only add an empty line between summary and detail of the error for custom formatted errors. This removes a weird new line for errors that are formatted in a generic way.
- Indent sources for generic error detail and keep the prepositions, this preserves existing convention and add a bit of visual separation between errors.

PiperOrigin-RevId: 329341133
2020-08-31 11:24:15 -07:00
Guice TeamandColin Decker 83c9a329f4 Automatic code cleanup.
PiperOrigin-RevId: 328979463
2020-08-28 15:28:47 -04:00
xiaomingjiaandDavid P. Baker 96319f854c Change to use "while locating" when referring to a key since "for" can be really confusing.
This is also make it consistent with `TypeLiteral`.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=328846120
2020-08-28 11:17:23 -04:00
xiaomingjiaandDavid P. Baker 16e0e9508e Add custom formatting to duplicate key in MapBinder error.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=328842950
2020-08-28 11:17:23 -04:00
xiaomingjiaandDavid P. Baker e586f654a9 Omit redundant prefixes in error messages since the id already identifies the error.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=328831597
2020-08-28 11:17:23 -04:00
xiaomingjiaandDavid P. Baker 2ebc207348 Make error identifier optional, since it's not very useful to print out [Guice/Other].
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=328825320
2020-08-28 11:17:23 -04:00
xiaomingjiaandDavid P. Baker de20ce15cd Change Guice metrics recorder to use exception instead.
This allows us to track the type of exception in addition to types of errors. Follow up CL will add a new metric to track the type of the exception.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=327721684
2020-08-21 13:22:17 -04:00
xiaomingjiaandDavid P. Baker 9af6a50bea Support hints in new MissingImplementationError.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=327697744
2020-08-21 13:22:17 -04:00
gloriosoandDavid P. Baker 9372d329a2 Optimize some String.format calls that are easily replaceable with String concatenation.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=327667005
2020-08-21 13:22:17 -04:00
xiaomingjiaandDavid P. Baker f6325c90e3 Omit prepositions from the first source in error messages.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=327644450
2020-08-21 13:22:17 -04:00
xiaomingjiaandDavid P. Baker c26e1c0d6d Apply formatting to the error message.
- add an option to enable or disable the formatting in error messages
- minor update on BindingAlreadySet error to be more concise

Note that the tests in errors directory currently are not exported since there is no way to turn on the new error message in opensource version. Those tests will be included once the new error messages are enabled.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=327483098
2020-08-20 11:42:52 -04:00