Skip to content

Commit

Permalink
Move the Report Checker
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst authored Dec 12, 2023
1 parent 1308bb3 commit 8b53131
Show file tree
Hide file tree
Showing 30 changed files with 88 additions and 87 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.checkerframework.common.util.report.qual;
package org.checkerframework.common.util.count.report.qual;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.checkerframework.common.util.report.qual;
package org.checkerframework.common.util.count.report.qual;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.checkerframework.common.util.report.qual;
package org.checkerframework.common.util.count.report.qual;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.checkerframework.common.util.report.qual;
package org.checkerframework.common.util.count.report.qual;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.checkerframework.common.util.report.qual;
package org.checkerframework.common.util.count.report.qual;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.checkerframework.common.util.report.qual;
package org.checkerframework.common.util.count.report.qual;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Expand All @@ -11,7 +11,7 @@

/**
* An annotation intended solely for representing an unqualified type in the qualifier hierarchy for
* the Report Checker.
* the Report Checker. This is the only type qualifier in the type hierarchy.
*/
@Documented
@Retention(RetentionPolicy.SOURCE) // do not store in class file
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.checkerframework.common.util.report.qual;
package org.checkerframework.common.util.count.report.qual;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.checkerframework.common.util.report.qual;
package org.checkerframework.common.util.count.report.qual;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Expand Down
5 changes: 5 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ Version 3.41.1 (January 2, 2023)

**User-visible changes:**

In `org.checkerframework.common.util.debug`, renamed `EmptyProcessor` to `DoNothingProcessor`.
Removed `org.checkerframework.common.util.report.DoNothingChecker`.
Moved `ReportChecker` from `org.checkerframework.common.util.report` to `org.checkerframework.common.util.count.report`.


**Implementation details:**

**Closed issues:**
Expand Down
3 changes: 2 additions & 1 deletion docs/developer/developer-manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,8 @@ <h2 id="Counting_annotations">Counting annotations</h2>
<ul>
<li><a href="https://checkerframework.org/api/org/checkerframework/common/util/count/AnnotationStatistics.html">AnnotationStatistics</a></li>
<li><a href="https://checkerframework.org/api/org/checkerframework/common/util/count/JavaCodeStatistics.html">JavaCodeStatistics</a></li>
<li><a href="https://github.com/typetools/checker-framework/blob/master/checker/bin-devel/count-suppression-reasons">count-suppression-reasons"></a></li>
<li><a href="https://checkerframework.org/api/org/checkerframework/common/util/count/report/ReportChecker.html">ReportChecker</a></li>
<li><a href="https://github.com/typetools/checker-framework/blob/master/checker/bin-devel/count-suppression-reasons">count-suppression-reasons</a></li>
</ul>


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import org.checkerframework.common.util.report.qual.*;
import org.checkerframework.common.util.count.report.qual.*;

package java.util.concurrent;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
* @summary Adapted test case for Issue 2147
* https://github.com/typetools/checker-framework/issues/2147 using framework package quals
*
* @compile/fail/ref=WithoutStub.out -XDrawDiagnostics -processor org.checkerframework.common.util.report.ReportChecker -AstubWarnIfNotFound AnnotationFileParserEnumTest.java
* @compile/fail/ref=WithStub.out -XDrawDiagnostics -processor org.checkerframework.common.util.report.ReportChecker -AstubWarnIfNotFound -Astubs=AnnotationFileParserEnum.astub AnnotationFileParserEnumTest.java
* @compile/fail/ref=WithoutStub.out -XDrawDiagnostics -processor org.checkerframework.common.util.count.report.ReportChecker -AstubWarnIfNotFound AnnotationFileParserEnumTest.java
* @compile/fail/ref=WithStub.out -XDrawDiagnostics -processor org.checkerframework.common.util.count.report.ReportChecker -AstubWarnIfNotFound -Astubs=AnnotationFileParserEnum.astub AnnotationFileParserEnumTest.java
*/

import static java.util.concurrent.TimeUnit.*;

import java.util.concurrent.TimeUnit;
import org.checkerframework.common.util.report.qual.*;
import org.checkerframework.common.util.count.report.qual.*;

public class AnnotationFileParserEnumTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
* </ul>
*
* @see JavaCodeStatistics
* @see org.checkerframework.common.util.count.report.ReportChecker
*/
/*
* TODO: add an option to only list declaration or type annotations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.checkerframework.javacutil.TreeUtils;

/**
* An annotation processor for counting the size of Java code:
* An annotation processor for counting a few specific aspects about the size of Java code:
*
* <ul>
* <li>The number of type parameter declarations and uses.
Expand All @@ -39,6 +39,7 @@
* </pre>
*
* @see AnnotationStatistics
* @see org.checkerframework.common.util.count.report.ReportChecker
*/
@SupportedSourceVersion(SourceVersion.RELEASE_8)
public class JavaCodeStatistics extends SourceChecker {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.checkerframework.common.util.count.report;

import javax.annotation.processing.SupportedOptions;
import org.checkerframework.common.basetype.BaseTypeChecker;

/**
* The Report Checker performs semantic searches over a program, for example, to find all methods
* that override a specific method, all classes that inherit from a specific class, or all uses of
* do-while-loops (and not also while loops!).
*
* <p>The search is specified in two different ways.
*
* <p>The first way is to write a stub specification file using the annotations in {@code
* org.checkerframework.common.util.count.report.qual.*}. You can see examples in the Checker
* Framework repository at {@code framework/tests/report/reporttest.astub} and {@code
* framework/jtreg/StubParserEnum/AnnotationFileParserEnum.astub}.
*
* <p>The second way is the {@code -AreportTreeKinds} and {@code -AreportModifiers} options, which
* search for specific tree kinds or modifiers.
*
* <p>Some similar features are available from IDEs (e.g., show references), but this tool provides
* much more flexibility and a command-line tool.
*
* <p>Options:
*
* <ul>
* <li><code>-AreportTreeKinds</code>: comma-separated list of <code>Tree.Kind</code>s that should
* be reported
* <li><code>-AreportModifiers</code>: comma-separated list of modifiers that should be reported
* </ul>
*
* @see org.checkerframework.common.util.count.AnnotationStatistics
* @see org.checkerframework.common.util.count.JavaCodeStatistics
*/
@SupportedOptions({"reportTreeKinds", "reportModifiers"})
public class ReportChecker extends BaseTypeChecker {

/** Creates a ReportChecker. */
public ReportChecker() {}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.checkerframework.common.util.report;
package org.checkerframework.common.util.count.report;

import com.sun.source.tree.ArrayAccessTree;
import com.sun.source.tree.AssignmentTree;
Expand Down Expand Up @@ -29,13 +29,13 @@
import org.checkerframework.common.basetype.BaseTypeChecker;
import org.checkerframework.common.basetype.BaseTypeValidator;
import org.checkerframework.common.basetype.BaseTypeVisitor;
import org.checkerframework.common.util.report.qual.ReportCall;
import org.checkerframework.common.util.report.qual.ReportCreation;
import org.checkerframework.common.util.report.qual.ReportInherit;
import org.checkerframework.common.util.report.qual.ReportOverride;
import org.checkerframework.common.util.report.qual.ReportReadWrite;
import org.checkerframework.common.util.report.qual.ReportUse;
import org.checkerframework.common.util.report.qual.ReportWrite;
import org.checkerframework.common.util.count.report.qual.ReportCall;
import org.checkerframework.common.util.count.report.qual.ReportCreation;
import org.checkerframework.common.util.count.report.qual.ReportInherit;
import org.checkerframework.common.util.count.report.qual.ReportOverride;
import org.checkerframework.common.util.count.report.qual.ReportReadWrite;
import org.checkerframework.common.util.count.report.qual.ReportUse;
import org.checkerframework.common.util.count.report.qual.ReportWrite;
import org.checkerframework.framework.type.AnnotatedTypeFactory;
import org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType;
import org.checkerframework.framework.util.AnnotatedTypes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@
import javax.lang.model.element.TypeElement;

/**
* Empty simple processor.
* This is an annotation processor that does nothing.
*
* <p>It is useful in debugging compiler behavior with an annotation processor present.
* <p>Use it when you are required to provide an annotation processor, or when you want to debug
* compiler behavior with an annotation processor present.
*/
@SupportedAnnotationTypes("*")
public class EmptyProcessor extends AbstractProcessor {
public class DoNothingProcessor extends AbstractProcessor {

/** Creates a DoNothingProcessor. */
public DoNothingProcessor() {}

@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
System.out.println("Empty Processor run!");
return false;
}

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ReportModifiersTest extends CheckerFrameworkPerDirectoryTest {
public ReportModifiersTest(List<File> testFiles) {
super(
testFiles,
org.checkerframework.common.util.report.ReportChecker.class,
org.checkerframework.common.util.count.report.ReportChecker.class,
"report",
"-AreportModifiers=native");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ReportTest extends CheckerFrameworkPerDirectoryTest {
public ReportTest(List<File> testFiles) {
super(
testFiles,
org.checkerframework.common.util.report.ReportChecker.class,
org.checkerframework.common.util.count.report.ReportChecker.class,
"report",
"-Astubs=tests/report/reporttest.astub");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ReportTreeKindsTest extends CheckerFrameworkPerDirectoryTest {
public ReportTreeKindsTest(List<File> testFiles) {
super(
testFiles,
org.checkerframework.common.util.report.ReportChecker.class,
org.checkerframework.common.util.count.report.ReportChecker.class,
"report",
"-AreportTreeKinds=WHILE_LOOP,CONDITIONAL_AND");
}
Expand Down
2 changes: 1 addition & 1 deletion framework/tests/report/Accesses.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import org.checkerframework.common.util.report.qual.*;
import org.checkerframework.common.util.count.report.qual.*;

public class Accesses {
class Demo {
Expand Down
2 changes: 1 addition & 1 deletion framework/tests/report/CallOverrides.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import org.checkerframework.common.util.report.qual.*;
import org.checkerframework.common.util.count.report.qual.*;

public class CallOverrides {
class A {
Expand Down
2 changes: 1 addition & 1 deletion framework/tests/report/Creation.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import org.checkerframework.common.util.report.qual.*;
import org.checkerframework.common.util.count.report.qual.*;

public class Creation {
class TestOne {
Expand Down
2 changes: 1 addition & 1 deletion framework/tests/report/Inherit.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import org.checkerframework.common.util.report.qual.*;
import org.checkerframework.common.util.count.report.qual.*;

public class Inherit {
@ReportInherit
Expand Down
2 changes: 1 addition & 1 deletion framework/tests/report/Interface.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// https://github.com/typetools/checker-framework/issues/658
// @skip-test

import org.checkerframework.common.util.report.qual.*;
import org.checkerframework.common.util.count.report.qual.*;

public class Interface {
interface A {
Expand Down
2 changes: 1 addition & 1 deletion framework/tests/report/Overrides.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import org.checkerframework.common.util.report.qual.*;
import org.checkerframework.common.util.count.report.qual.*;

public class Overrides {
class A {
Expand Down
2 changes: 1 addition & 1 deletion framework/tests/report/reporttest.astub
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import org.checkerframework.common.util.report.qual.*;
import org.checkerframework.common.util.count.report.qual.*;

package java.lang;

Expand Down

0 comments on commit 8b53131

Please sign in to comment.