aboutsummaryrefslogtreecommitdiff
path: root/src/main
AgeCommit message (Collapse)Author
2020-06-03Add support for explicit receiver parametersJason O'Brien
Annotated "this" arguments for instance methods and non-static nested class constructors were added in Java 8. This special cases "this" and "OuterClass.this" so that they are allowed as parameter names.
2020-04-20Don't copy parameter annotations when creating a ParameterSpec. (#770)Daniel Santiago
* Don't copy parameter annotations when creating a ParameterSpec. This further preserves the behaviour discussed in https://github.com/square/javapoet/issues/482. Unifying it for both MethodSpec.overriding and ParameterSpec.get. * Add compilation test for when overriding a method with private annotations. * Address PR comments: * Remove unused import * Rename newly added test
2020-01-14Add a comment about dropping parameter annotations in MethodSpec.overridingEgor Andreevici
2020-01-13Remove parameter annotations in MethodSpec.overridingEgor Andreevici
- Change to not copy parameter annotations was first introduced in 9505ad0e027a1f125b5352ac722ea141831fbf1c. - Change to properly copy mirror annotations in ParameterSpec.get was introduced in a0eadbbf0e7b70f0fbbc66043536e4328c3808fd, breaking the behavior of MethodSpec.overriding. - This change preserves the correct behavior of ParameterSpec.get while also removing annotations in MethodSpec.overriding.
2020-01-06Test for JavaFile.writeToPathEgor Andreevici
2020-01-06Add writeTo methods returning Path/File written to #691Galder Zamarreño
2020-01-06Add alwaysQualify() API to avoid collisions with known colliding types (#734)Zac Sweers
* Add alwaysQualify() API to avoid collisions with known colliding types Implementation based on https://github.com/square/javapoet/issues/77#issuecomment-507387399 Resolves #77 CC @eamonnmcmanus * Add utility avoidClashesWithNestedClasses methods for Class/TypeElement * Fix style issues * Move scope to TypeSpecs * Check superclasses and superinterfaces * Add superclass and superinterface overloads * Style fixes * Add qualified names to toBuilder test * Add Map.Entry test + doc regression tests
2020-01-04added convenience overloads for code blocks in control flow (#752)Florian Enner
* added convenience overloads for code blocks in control flow * added javadoc and test * added test for do while block * fixed continuation space count
2020-01-02Hardcoded line separator bug (#684)Vlad Topala
* Use regex for new line character to cover both dos and unix endings when calling emitAndIndent - fixes #552 * Update CodeWriter to use linebreak matcher instead of \r\n
2020-01-01Copy originating elements in toBuilder() as well (#750)Zac Sweers
* Copy originating elements in toBuilder() as well Fixes #749 * Add test
2020-01-01Ensure trailing newlines in javadocs and method bodies (#732)Zac Sweers
* Add RecordingAppendable in LineWrapper for tracking last emitted char * Check lastChar in javadoc emission to emit newline if necessary Resolves #731 * Move trailing newline check to emit() overload for reuse Allows using from anywhere emitting a CodeBlock * Ensure trailing newlines in method bodies Resolves #722 * Add dedicated trailing newline in javadoc test * Fix modifier ordering * Fix rebase conflict Co-authored-by: Egor Andreevich <andreevich.egor@gmail.com>
2020-01-01Mutable builder list fields (#650)Zac Sweers
* Make modifiers and annotations in FieldSpec public * Make AnnotationSpec members public * Make JavaFile staticImports public * Make modifiers and annotations in parameterspec public * Make methodspec modifiers, params, typevars, and annotations public * Make typespec builder lists public * Move TypeSpec.Builder validations to build() where appropriate * Move AnnotationSpec.Builder validations to build() where appropriate * Fix line length style
2019-12-21Add checks to ParameterSpec with VariableElement + copy over annotations (#681)Shaishav Gandhi
* Add checks to ParameterSpec with VariableElement + copy over annotations Signed-off-by: shaishavgandhi05 <shaishgandhi@gmail.com> * Add test for variable element Signed-off-by: shaishavgandhi05 <shaishgandhi@gmail.com> * Extract util methods into TestUtil * Fix formatting * Make findFirst more generic Co-authored-by: Egor Andreevich <andreevich.egor@gmail.com>
2019-08-10Add CodeBlock.Builder#clear() methodZac Sweers
Analogous to the change added in KotlinPoet
2019-06-04easier_way_provide_encoding (#712)Rene Fischer
* provide an easier way for an other encoding than UTF-8 * formatting * no final on argument and fix for javadoc * checkstyle line length checkstyle line length
2019-05-03Nit: Simplify a CodeBlockRon Shapiro
2019-05-01Fix an issue where ClassName could not handle classes in the default (empty) ↵Almog Gavra
package
2019-04-16Memoize ClassName.simpleNames()Ron Shapiro
In addition to being used repeatedly in CodeWriter.lookupName(), the current implementation is N^2 (albeit for a usually low N) since it recursively calls itself on the enclosing class name. This should get rid of some of the garbage created in code writing.
2019-03-25Remove argument whose value isn't neededJake Wharton
The single-argument overload will use the end of the String as the end index automatically.
2019-02-05Remove n^2 algorithm in CodeWriter.resolve() by precomputing all of the ↵Ron Shapiro
nested simple names of a TypeSpec For one large (100K lines) file, this saved 3.5s/build
2019-02-04Allow setting method name on MethodSpec.Builder (#702)Shaishav Gandhi
* Allow setting method name on MethodSpec.Builder * Fix indentation
2018-11-11Public getter for canonical name of ClassName (#687)Daniil Popov
2018-10-03Add Javadoc to ParameterSpec (#676)Shaishav Gandhi
* Add Javadoc to ParameterSpec Signed-off-by: shaishavgandhi05 <shaishgandhi@gmail.com> * Move emission to same CodeBlock Signed-off-by: shaishavgandhi05 <shaishgandhi@gmail.com> * Remove eager javadoc addition and fallback to adding doc when emitting Signed-off-by: shaishavgandhi05 <shaishgandhi@gmail.com> * Fix formatting Signed-off-by: shaishavgandhi05 <shaishgandhi@gmail.com> * Add new line before emitting parameter javadoc Signed-off-by: shaishavgandhi05 <shaishgandhi@gmail.com> * Emit new line before @param only if method javadoc is present Signed-off-by: shaishavgandhi05 <shaishgandhi@gmail.com>
2018-10-03Check parameter Modifiers (#678)Shaishav Gandhi
* Check parameter modifiers for non final modifiers Signed-off-by: shaishavgandhi05 <shaishgandhi@gmail.com> * Add extra line Signed-off-by: shaishavgandhi05 <shaishgandhi@gmail.com> * Fix formatting Signed-off-by: shaishavgandhi05 <shaishgandhi@gmail.com>
2018-08-21Qualify types masked by type variables (#657)Ron Shapiro
* Use fully qualified names if a type variable masks a type name, even if it is in the same package * Add a makeshift multiset to handle https://github.com/square/javapoet/pull/657\#discussion_r205514292
2018-08-01`java.lang.List` has no `size()` methodRon Shapiro
... but `java.util.List` does :)
2018-05-16Fix TypeName.get() on top-level error types (#646)Ron Shapiro
* Fix TypeName.get() on top-level error types Discussion: https://github.com/square/javapoet/commit/1c897e44ddd6b50e22180b6d32e4a3c69223614a#commitcomment-28905786 * Use an ElementVisitor instead of instanceof checks * Remove unused import
2018-04-28Avoid TypeElement.getKind() in ClassName.get().Jesse Wilson
There's some bug that's triggered by Buck's ABI builds and avoiding this API avoids triggering that bug.
2018-04-28Tighten up the code that handles emitting type annotations.Jesse Wilson
I found the previous code difficult to follow. Hopefully this is less so.
2018-04-23Remove unused listJake Wharton
2018-03-12Fail fast with null AnnotationSpec on type.Eric Cochran
2018-03-10Add tests for Java 8 TYPE_USE annotations on arrays (#614). (#618)Roberto Lublinerman
* Add tests for Java 8 TYPE_USE annotations on arrays (#614). * Implement TYPE_USE annotations semantics. * Cleanup in AnnotatedTypeTest. * Nits from review
2018-03-04Use contextual type parameters for throws types. (#625)Eric Cochran
2018-03-04Disable overriding methods in final classes. (#626)Eric Cochran
2018-03-03Update the codebase now that we require Java 8 (#617)Thomas Broyer
2018-02-23Require valid annotation member names. (#620)Eric Cochran
2018-01-28Fix checkState message in CodeWriter (#609)Ron Shapiro
I was scanning through this file and this error message seemed wrong to me. If the checkState fails, the packageName _not_ be set, right?
2018-01-28Fix "Do not submit" from https://github.com/square/javapoet/pull/598 ↵Ron Shapiro
😬😬😬 (#608)
2018-01-26Use $Z in method parameter lists. (#605)Jesse Wilson
Now we wrap automatically after the method name, if appropriate.
2018-01-26Fix search of annotated type parameters in importszhurs
2018-01-26Add isEmpty to CodeBlock.Builder. (#596)Jake Wharton
2018-01-26Implement CodeBlock.join() and CodeBlock.joining() (#599)Ron Shapiro
Closes https://github.com/square/javapoet/issues/595
2018-01-26Adds `$B` as an optional newline if a line will exceed 100 chars (#598)Ron Shapiro
* Adds `$B` as an optional newline if a line will exceed 100 chars Closes https://github.com/square/javapoet/issues/588 * Switch from $B to $Z
2017-08-13Include annotations when emitting type variables. (#574)Jake Wharton
Turns out this was already covered in a test but we had the wrong expected output declared.
2017-07-01Switch from StringWriter to StringBuilder. (#568)Jake Wharton
The former has needless synchronization.
2017-06-23addStatement(CodeBlock) overloads for CodeBlock and MethodSpec (#567)Ron Shapiro
2017-05-23Fix ClassName regression for class names starting with a $ (#562)Phil Glass
2017-05-13Support anonymous inner classes in ClassName#get (#526)Kay Roepke
* Support anonymous inner classes in ClassName#get ClassName#get incorrectly used Class#getSimpleName for anonymous inner classes, which is an empty string. With this change it falls back to using Class#getName for anonymous classes and taking the compiler generated name for the class. * fix automatic import rearrangement * remove try-catch block from test
2017-05-13Fix conflicts with types with same name as type being declared (#559)Thomas Broyer
* Add failing tests for types conflicting with type being declared Also removes previous (flawed) test, which should have been in JavaFileTest anyway, and add a separate test for the "superclass references self" case (already handled in TypeSpecTest#interfaceExtends btw, but this makes it clearer what is tested and expected). And add a separate test for classes in the same package conflicting with a superclass, for completeness. Reproduces #470 * Fix conflicts with types with same name as type being declared Those types (annotations, or referenced in annotation values, in type variable bounds, superclass, or superinterfaces) were erroneously imported rather than being emitted with their qualified name. Fixes #470
2017-05-12Add convenience anonymousClassBuilder(CodeBlock) (#560)Zac Sweers
* Add convenience anonymousClassBuilder(CodeBlock) Resolves #558 * Fix indent