Skip to content

Commit

Permalink
use sorting to ensure consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
theron-wang committed Aug 15, 2024
1 parent 8f0ede4 commit 936e8dc
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@
import com.github.javaparser.ast.visitor.ModifierVisitor;
import com.github.javaparser.ast.visitor.Visitable;
import java.lang.annotation.ElementType;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

Expand Down Expand Up @@ -129,6 +132,10 @@ else if (targetAnnotation.isNormalAnnotationExpr()) {
newAnnotation.append("Target(");

newAnnotation.append('{');

List<ElementType> sortedElementTypes = new ArrayList<>(elementTypes);
Collections.sort(sortedElementTypes, (a, b) -> a.name().compareTo(b.name()));

Iterator<ElementType> iterator = elementTypes.iterator();
while (iterator.hasNext()) {
ElementType elementType = iterator.next();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package org.checkerframework.checker.initialization.qual;

@java.lang.annotation.Target({ java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.TYPE_USE })
@java.lang.annotation.Target({ java.lang.annotation.ElementType.TYPE_USE, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.METHOD })
public @interface Initialized {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package org.checkerframework.checker.nullness.qual;

@java.lang.annotation.Target({ java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.TYPE_USE })
@java.lang.annotation.Target({ java.lang.annotation.ElementType.TYPE_USE, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.METHOD })
public @interface NonNull {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package org.checkerframework.checker.nullness.qual;

@java.lang.annotation.Target({ java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.TYPE_USE })
@java.lang.annotation.Target({ java.lang.annotation.ElementType.TYPE_USE, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.METHOD })
public @interface UnknownKeyFor {
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example;

@java.lang.annotation.Target({ java.lang.annotation.ElementType.TYPE_USE, java.lang.annotation.ElementType.METHOD })
@java.lang.annotation.Target({ java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.TYPE_USE })
public @interface Bar {

public int value();
Expand Down

0 comments on commit 936e8dc

Please sign in to comment.