Skip to content

Commit

Permalink
annotation/parameterless annotation
Browse files Browse the repository at this point in the history
Parameterless annotations aren't necessarily marker annotations.
All we can tell about a use of an annotation is that it's parameterless,
and that's how 4.8.5 is specified.

Related: #360

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=286650854
  • Loading branch information
cushon authored and kluever committed Dec 23, 2019
1 parent 45e4afb commit 8a215cd
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3546,26 +3546,27 @@ private boolean hasTrailingToken(Input input, List<? extends Tree> nodes, String

/**
* Can a local with a set of modifiers be declared with horizontal annotations? This is currently
* true if there is at most one marker annotation, and no others.
* true if there is at most one parameterless annotation, and no others.
*
* @param modifiers the list of {@link ModifiersTree}s
* @return whether the local can be declared with horizontal annotations
*/
private Direction canLocalHaveHorizontalAnnotations(ModifiersTree modifiers) {
int markerAnnotations = 0;
int parameterlessAnnotations = 0;
for (AnnotationTree annotation : modifiers.getAnnotations()) {
if (annotation.getArguments().isEmpty()) {
markerAnnotations++;
parameterlessAnnotations++;
}
}
return markerAnnotations <= 1 && markerAnnotations == modifiers.getAnnotations().size()
return parameterlessAnnotations <= 1
&& parameterlessAnnotations == modifiers.getAnnotations().size()
? Direction.HORIZONTAL
: Direction.VERTICAL;
}

/**
* Should a field with a set of modifiers be declared with horizontal annotations? This is
* currently true if all annotations are marker annotations.
* currently true if all annotations are parameterless annotations.
*/
private Direction fieldAnnotationDirection(ModifiersTree modifiers) {
for (AnnotationTree annotation : modifiers.getAnnotations()) {
Expand Down

0 comments on commit 8a215cd

Please sign in to comment.