From 678320017838b4e86040356be3e120eedd635296 Mon Sep 17 00:00:00 2001 From: Manu Sridharan Date: Tue, 8 Oct 2024 11:38:11 -0700 Subject: [PATCH] Switch to Spotless for formatting (#249) We were using another plugin for formatting before, but Spotless is maintained. Also we update to latest GJF version, which tweaks the formatting a bit. No need to merge this immediately if it causes lots of conflicts in outstanding PRs. We can always do it later and re-run the formatting pass. Fixes #248 --- annotator-core/build.gradle | 7 ++--- .../java/edu/ucr/cs/riple/core/Annotator.java | 3 +++ .../java/edu/ucr/cs/riple/core/Config.java | 26 +++++++++++++++++++ .../java/edu/ucr/cs/riple/core/Context.java | 6 +++++ .../java/edu/ucr/cs/riple/core/Report.java | 7 +++++ .../edu/ucr/cs/riple/core/ReportCache.java | 1 + .../edu/ucr/cs/riple/core/cache/Impact.java | 2 ++ .../riple/core/checkers/CheckerBaseClass.java | 1 + .../core/checkers/nullaway/NullAway.java | 1 + .../core/checkers/nullaway/NullAwayError.java | 1 + .../core/evaluators/AbstractEvaluator.java | 4 +++ .../core/evaluators/graph/ConflictGraph.java | 1 + .../cs/riple/core/evaluators/graph/Node.java | 8 ++++++ .../AbstractConflictGraphProcessor.java | 5 ++++ .../suppliers/AbstractSupplier.java | 4 +++ .../riple/core/injectors/VirtualInjector.java | 3 +++ .../java/edu/ucr/cs/riple/core/log/Log.java | 4 +++ .../core/module/ModuleConfiguration.java | 3 +++ .../ucr/cs/riple/core/module/ModuleInfo.java | 5 ++++ .../registries/field/ClassFieldRecord.java | 4 +++ .../field/FieldInitializationNode.java | 1 + .../field/FieldInitializationStore.java | 3 +++ .../core/registries/field/FieldRegistry.java | 1 + .../cs/riple/core/registries/index/Error.java | 4 +++ .../core/registries/index/ErrorStore.java | 3 +++ .../cs/riple/core/registries/index/Index.java | 2 ++ .../riple/core/registries/index/Result.java | 1 + .../core/registries/method/MethodRecord.java | 7 +++++ .../registries/method/MethodRegistry.java | 2 ++ .../region/CompoundRegionRegistry.java | 2 ++ .../region/ParameterRegionRegistry.java | 1 + .../riple/core/registries/region/Region.java | 2 ++ .../core/registries/region/RegionRecord.java | 1 + .../cs/riple/core/AnnotatorBaseCoreTest.java | 4 +++ .../riple/core/OffsetChangeHandlingTest.java | 4 +++ .../cs/riple/core/tools/CoreTestHelper.java | 14 ++++++++++ .../edu/ucr/cs/riple/core/tools/Module.java | 2 ++ .../cs/riple/core/tools/ProjectBuilder.java | 2 ++ annotator-scanner/build.gradle | 1 - .../scanner/ErrorProneCLIFlagsConfig.java | 4 +++ .../cs/riple/scanner/ScannerConfigWriter.java | 2 ++ .../ucr/cs/riple/scanner/ScannerContext.java | 2 ++ .../edu/ucr/cs/riple/scanner/Serializer.java | 9 +++++++ .../location/AbstractSymbolLocation.java | 2 ++ .../location/MethodParameterLocation.java | 2 ++ .../ucr/cs/riple/scanner/out/ClassRecord.java | 1 + .../cs/riple/scanner/out/ImpactedRegion.java | 3 +++ .../cs/riple/scanner/out/MethodRecord.java | 7 +++++ build.gradle | 8 ++++++ checks/ban-mutable-static/build.gradle | 1 - injector/build.gradle | 18 +++++-------- .../edu/ucr/cs/riple/injector/Printer.java | 2 ++ .../cs/riple/injector/SignatureMatcher.java | 1 + .../injector/changes/AnnotationChange.java | 1 + .../ucr/cs/riple/injector/changes/Name.java | 1 + .../cs/riple/injector/location/Location.java | 3 +++ .../injector/location/OnLocalVariable.java | 1 + .../cs/riple/injector/location/OnMethod.java | 1 + .../riple/injector/location/OnParameter.java | 1 + .../SinglePositionModification.java | 1 + .../injector/offsets/FileOffsetStore.java | 2 ++ .../riple/injector/offsets/OffsetChange.java | 1 + library-model-loader/build.gradle | 1 - 63 files changed, 211 insertions(+), 17 deletions(-) diff --git a/annotator-core/build.gradle b/annotator-core/build.gradle index 7562fbdf9..70320a712 100644 --- a/annotator-core/build.gradle +++ b/annotator-core/build.gradle @@ -25,7 +25,6 @@ import com.vanniktech.maven.publish.SonatypeHost plugins { - id 'com.github.sherter.google-java-format' version '0.9' id 'com.github.johnrengelman.shadow' version '7.1.2' id 'maven-publish' id 'application' @@ -52,8 +51,10 @@ dependencies { } // Exclude formatting files under resources -googleJavaFormat { - exclude 'src/test/resources/**/*.java' +spotless { + java { + targetExclude 'src/test/resources/**/*.java' + } } // Should be the latest supporting version of NullAway. diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/Annotator.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/Annotator.java index 29c15e2a8..0b0ccd63e 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/Annotator.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/Annotator.java @@ -51,10 +51,13 @@ public class Annotator { /** Injector instance. */ private final AnnotationInjector injector; + /** Annotator context. */ public final Context context; + /** Reports cache. */ public final ReportCache cache; + /** Annotator configuration. */ public final Config config; diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/Config.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/Config.java index bd1cc62f1..d9c85babc 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/Config.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/Config.java @@ -68,74 +68,97 @@ public class Config { * zero or less. */ public final boolean bailout; + /** If activated, impact of fixes will be computed in parallel. */ public final boolean useParallelGraphProcessor; + /** If activated, impact of fixes will be cached. */ public final boolean useImpactCache; + /** * If activated, all suggested fixes from the checker will be applied to the source code * regardless of their effectiveness. */ public final boolean exhaustiveSearch; + /** * If activated, all containing fixes in the fix tree will be applied to the source code, * otherwise only the root fix will be applied. */ public final boolean chain; + /** * If enabled, at each iteration fixes with effectiveness will be tagged to exclude them in * further iterations. */ public final boolean useCache; + /** If true, build outputs will be redirected to STD Err. */ public final boolean redirectBuildOutputToStdErr; + /** If activated, it will disable the outer loop. */ public final boolean disableOuterLoop; + /** Info of target module. */ public final ModuleConfiguration target; + /** Path to directory where all outputs of checker and scanner checker is located. */ public final Path globalDir; + /** Command to build the target module. */ public final String buildCommand; + /** Fully qualified name of the {@code nullable} annotation. */ public final String nullableAnnot; + /** Fully qualified name of the {@code initializer} annotation. */ public final String initializerAnnot; + /** If enabled, effects of public API on downstream dependencies will be considered. */ public final boolean downStreamDependenciesAnalysisActivated; + /** Sets of context path information for all downstream dependencies. */ public final ImmutableSet downstreamConfigurations; + /** * Path to NullAway library model loader resource directory, which enables the communication * between annotator and NullAway when processing downstream dependencies. Annotator will write * annotation on files in this directory and the using Library Model Loader reads them. */ public final Path nullawayLibraryModelLoaderPath; + /** Command to build the all downstream dependencies at once. */ public final String downstreamDependenciesBuildCommand; + /** * Analysis mode. Will impact inference decisions when downstream dependency analysis is * activated. */ public final AnalysisMode mode; + /** Global counter for assigning unique id for each instance. */ private int moduleCounterID; + /** * If activated, Annotator will try to suppress all remaining errors. The logic is specific to the * checker suppression mechanism. Annotator will simply call {@link * edu.ucr.cs.riple.core.checkers.Checker#suppressRemainingErrors} methods. */ public final boolean suppressRemainingErrors; + /** Fully qualified NullUnmarked annotation. */ public final String nullUnMarkedAnnotation; + /** * Set of {@code @Nonnull} annotations to be acknowledged by Annotator. If an element is annotated * with these annotations along any other annotation ending with {@code "nonnull"}, Annotator will * acknowledge the annotation and will not add any {@code @Nullable} annotation to the element. */ public final ImmutableSet nonnullAnnotations; + /** Depth of the analysis. Default to 5 if not set by the user */ public final int depth; + /** * Activates inference to add {@code @Nullable} qualifiers. * @@ -143,11 +166,13 @@ public class Config { * {@code true} in production. */ public final boolean inferenceActivated; + /** * Generated code detectors. Responsible for detecting regions that are not present in the source * code and are generated by a processor. */ public final ImmutableSet generatedCodeDetectors; + /** * Checker name to retrieve the {@link edu.ucr.cs.riple.core.checkers.Checker} specific instance. */ @@ -685,6 +710,7 @@ public static class Builder { public String initializerAnnotation; public String nullableAnnotation; public String outputDir; + /** * List of modules, did not use {@link java.util.Set} to preserve order. First project is the * target project. diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/Context.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/Context.java index 8cb74cffe..51c93f579 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/Context.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/Context.java @@ -47,19 +47,25 @@ public class Context { /** Annotator configuration. */ public final Config config; + /** Log instance. Responsible for logging all the information about the build time and count. */ public final Log log; + /** Handler for computing the original offset of reported errors with existing changes. */ public final OffsetHandler offsetHandler; + /** The moduleInfo of target module. */ public final ModuleInfo targetModuleInfo; + /** * Configuration of the target module, required for building the target module and collecting * checkers output. */ public final ModuleConfiguration targetConfiguration; + /** Sets of context path information for all downstream dependencies. */ public final ImmutableSet downstreamConfigurations; + /** Checker instance. Used to execute checker specific tasks. */ public final Checker checker; diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/Report.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/Report.java index edcdd4d91..15e793c18 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/Report.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/Report.java @@ -43,27 +43,34 @@ public class Report { /** Effect on target module. */ public int localEffect; + /** Root of fix tree associated to this report instance. */ public Fix root; + /** Fix tree associated to this report instance. */ public Set tree; + /** * Set of errors that will be triggered in target module if fix tree is applied to the source * code. */ public ImmutableSet triggeredErrors; + /** * Set of triggered fixes on target module that will be triggered if fix tree is applied due to * errors in downstream dependencies. */ public ImmutableSet triggeredFixesFromDownstreamErrors; + /** If true, this report's tree has been processed for at least one iteration */ public boolean hasBeenProcessedOnce; + /** * Lower bound of number of errors in downstream dependencies if fix tree is applied to the target * module. */ private int lowerBoundEffectOnDownstreamDependencies; + /** * Upper bound of number of errors in downstream dependencies if fix tree is applied to the target * module. diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/ReportCache.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/ReportCache.java index 36887fc4f..aebad4126 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/ReportCache.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/ReportCache.java @@ -38,6 +38,7 @@ public class ReportCache { * efficiently. */ private final Map store; + /** Cache activation switch. */ private boolean enabled; diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/cache/Impact.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/cache/Impact.java index 363336030..863255d0c 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/cache/Impact.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/cache/Impact.java @@ -36,8 +36,10 @@ public class Impact { /** Target fix. */ public final Fix fix; + /** Set of triggered errors, if this fix is applied to source code. */ protected ImmutableSet triggeredErrors; + /** * Set of triggered fixes on the target module from downstream dependencies errors if containing * fix is applied. diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/checkers/CheckerBaseClass.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/checkers/CheckerBaseClass.java index 5fbfb5202..bf20fbf6c 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/checkers/CheckerBaseClass.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/checkers/CheckerBaseClass.java @@ -37,6 +37,7 @@ public abstract class CheckerBaseClass implements Checker { /** Annotator config. */ protected final Config config; + /** Annotator context. */ protected final Context context; diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/checkers/nullaway/NullAway.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/checkers/nullaway/NullAway.java index 3d004a987..a97e6ae40 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/checkers/nullaway/NullAway.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/checkers/nullaway/NullAway.java @@ -60,6 +60,7 @@ public class NullAway extends CheckerBaseClass { * The name of the checker. To select this checker, this name must be used in the configurations. */ public static final String NAME = "NULLAWAY"; + /** Supported version of NullAway serialization. */ public static final int VERSION = 3; diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/checkers/nullaway/NullAwayError.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/checkers/nullaway/NullAwayError.java index d6ac5758e..49f7a2d49 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/checkers/nullaway/NullAwayError.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/checkers/nullaway/NullAwayError.java @@ -37,6 +37,7 @@ public class NullAwayError extends Error { /** Error type for method initialization errors from NullAway in {@code String}. */ public static final String METHOD_INITIALIZER_ERROR = "METHOD_NO_INIT"; + /** Error type for field initialization errors from NullAway in {@code String}. */ public static final String FIELD_INITIALIZER_ERROR = "FIELD_NO_INIT"; diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/evaluators/AbstractEvaluator.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/evaluators/AbstractEvaluator.java index 236f4c35b..bc4112de9 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/evaluators/AbstractEvaluator.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/evaluators/AbstractEvaluator.java @@ -48,12 +48,16 @@ public abstract class AbstractEvaluator implements Evaluator { /** Annotator context. */ protected final Context context; + /** Conflict graph to storing unprocessed fixes. */ protected final ConflictGraph graph; + /** Depth of analysis. */ protected final int depth; + /** Graph processor to process the graph. */ protected ConflictGraphProcessor processor; + /** Supplier used for initialization. */ protected final Supplier supplier; diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/evaluators/graph/ConflictGraph.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/evaluators/graph/ConflictGraph.java index 1e64ffcdc..114edbdea 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/evaluators/graph/ConflictGraph.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/evaluators/graph/ConflictGraph.java @@ -45,6 +45,7 @@ public class ConflictGraph { /** Nodes in this graph */ public final Multimap nodes; + /** * Groups in this graph, nodes which does not have any conflict in regions will in the same group. * Please note that this is a graph coloring problem, set of groups is calculated using a greedy diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/evaluators/graph/Node.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/evaluators/graph/Node.java index f94b31ddc..5fda2c1f5 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/evaluators/graph/Node.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/evaluators/graph/Node.java @@ -49,23 +49,31 @@ public class Node { /** Root fix of the tree. */ public final Fix root; + /** Set of all fixes in tree. */ public final Set tree; + /** Set of potentially impacted by any node in tree. */ public final Set regions; + /** Set of triggered errors if tree is applied on target module. */ public ImmutableSet triggeredErrors; + /** * Set of triggered fixes on target module that will be triggered if fix tree is applied due to * errors in downstream dependencies. */ public ImmutableSet triggeredFixesFromDownstreamErrors; + /** Unique id of Node across all nodes. */ public int id; + /** Effect of applying containing change */ public int effect; + /** Corresponding report of processing root. */ public Report report; + /** Regions where original errors reported and NullAway suggested root for that. */ private ImmutableSet origins; diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/evaluators/graph/processors/AbstractConflictGraphProcessor.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/evaluators/graph/processors/AbstractConflictGraphProcessor.java index 86df296d4..ac290c88b 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/evaluators/graph/processors/AbstractConflictGraphProcessor.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/evaluators/graph/processors/AbstractConflictGraphProcessor.java @@ -42,14 +42,19 @@ public abstract class AbstractConflictGraphProcessor implements ConflictGraphPro /** Injector used in the processor to inject / remove fixes. */ protected final AnnotationInjector injector; + /** Error store instance to store state of fixes before and after of injections. */ protected final ErrorStore errorStore; + /** Downstream impact cache to retrieve impacts of fixes globally. */ protected final DownstreamImpactCache downstreamImpactCache; + /** Annotator context. */ protected final Context context; + /** Handler to re-run compiler. */ protected final CompilerRunner compilerRunner; + /** ModuleInfo of the input module which the impact of fixes are computed on. */ protected final ModuleInfo moduleInfo; diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/evaluators/suppliers/AbstractSupplier.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/evaluators/suppliers/AbstractSupplier.java index afdf6e058..262a5a74a 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/evaluators/suppliers/AbstractSupplier.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/evaluators/suppliers/AbstractSupplier.java @@ -35,12 +35,16 @@ public abstract class AbstractSupplier implements Supplier { /** Error Store instance. */ protected final ErrorStore errorStore; + /** Injector instance. */ protected final AnnotationInjector injector; + /** ModuleInfo of the module which the impact of fixes are computed on. */ protected final ModuleInfo moduleInfo; + /** Depth of analysis. */ protected final int depth; + /** Annotator context. */ protected final Context context; diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/injectors/VirtualInjector.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/injectors/VirtualInjector.java index 2fc98e21a..b8b46a181 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/injectors/VirtualInjector.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/injectors/VirtualInjector.java @@ -48,13 +48,16 @@ public class VirtualInjector extends AnnotationInjector { /** Path to library model loader resources directory */ private final Path libraryModelResourcesDirectoryPath; + /** * Annotator configuration, required to check if downstream dependencies analysis is activated or * retrieve the path to library model loader. */ private final Config config; + /** Name of the resource file in library model loader which contains list of nullable methods. */ public static final String NULLABLE_METHOD_LIST_FILE_NAME = "nullable-methods.tsv"; + /** Name of the resource file in library model loader which contains list of nullable fields. */ public static final String NULLABLE_FIELD_LIST_FILE_NAME = "nullable-fields.tsv"; diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/log/Log.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/log/Log.java index 6d5168395..5aec78953 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/log/Log.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/log/Log.java @@ -35,12 +35,16 @@ public class Log { /** Sum of number of nodes constructed in each {@link ConflictGraph}. */ private long nodes; + /** Number of build requests. */ private long requested; + /** Total time spent for annotator from start to finish. */ private long totalTime; + /** Total time spent in building targets. */ private long buildTime = 0; + /** * Set of approved and injected annotations. These annotations are evaluated and approved and will * not get removed from the source code. diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/module/ModuleConfiguration.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/module/ModuleConfiguration.java index ac4c1f1b5..a96052032 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/module/ModuleConfiguration.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/module/ModuleConfiguration.java @@ -36,10 +36,13 @@ public class ModuleConfiguration { /** Path to checker config. */ public final Path checkerConfig; + /** Path to scanner config. */ public final Path scannerConfig; + /** Directory where all serialized data from checkers are located. */ public final Path dir; + /** * Global unique ID for this module. 0 is for the target module, and the i-th module is for the * i-th downstream dependency. diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/module/ModuleInfo.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/module/ModuleInfo.java index bf3c7577e..c2c478bd8 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/module/ModuleInfo.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/module/ModuleInfo.java @@ -45,17 +45,22 @@ public class ModuleInfo { /** This field is used to store the information about the fields in the module. */ private final FieldRegistry fieldRegistry; + /** This field is used to store the information about the methods in the module. */ private final MethodRegistry methodRegistry; + /** This field is used to store the information about the nonnull annotations in the module. */ private final NonnullStore nonnullStore; + /** The set of modules this moduleInfo is created for. */ private final ImmutableSet configurations; + /** * Region registry that contains information about the regions that can potentially be impacted by * a fix. */ private final CompoundRegionRegistry regionRegistry; + /** * The set of annotation processor handlers that are used to process the generated code in this * module. diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/field/ClassFieldRecord.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/field/ClassFieldRecord.java index 5f26df46e..d1e2db077 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/field/ClassFieldRecord.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/field/ClassFieldRecord.java @@ -38,8 +38,10 @@ public class ClassFieldRecord { /** Set of al fields declared within one statement. */ public final Set fields; + /** Flat name of the containing class. */ public final String clazz; + /** Path to source file containing this class. */ public final Path pathToSourceFile; @@ -119,8 +121,10 @@ public static class FieldDeclarationRecord { /** Name of all fields declared within the same statement. */ public final ImmutableSet names; + /** True if the field declaration is of primitive type, false otherwise. */ public final boolean isPrimitiveType; + /** True if the field declaration is public, false otherwise. */ public final boolean isPublic; diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/field/FieldInitializationNode.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/field/FieldInitializationNode.java index 8e03f80a5..251872749 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/field/FieldInitializationNode.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/field/FieldInitializationNode.java @@ -37,6 +37,7 @@ public class FieldInitializationNode { /** Location of the initializer method. */ private final OnMethod initializerLocation; + /** Initialized field by the {@link FieldInitializationNode#initializerLocation}. */ private final String field; diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/field/FieldInitializationStore.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/field/FieldInitializationStore.java index c98b6fe8e..6e0f6b100 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/field/FieldInitializationStore.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/field/FieldInitializationStore.java @@ -120,8 +120,10 @@ private static class Class { * signature. */ private final HashMap initializers; + /** Fully qualified name of the class. */ private final String clazz; + /** Path to file where the class exists. */ private final Path path; @@ -205,6 +207,7 @@ private OnMethod findInitializer() { private static class InitializerMethod { /** Methods signature. */ private final String signature; + /** Initialized field. */ private final Set fields; diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/field/FieldRegistry.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/field/FieldRegistry.java index 6f403c625..66062c16a 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/field/FieldRegistry.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/field/FieldRegistry.java @@ -64,6 +64,7 @@ public class FieldRegistry extends Registry { * initialized at declaration. */ private Multimap uninitializedFields; + /** * Constructor for {@link FieldRegistry}. * diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/index/Error.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/index/Error.java index a1ebd16bd..a2e71d8ce 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/index/Error.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/index/Error.java @@ -40,12 +40,16 @@ public abstract class Error { /** Error Type. */ public final String messageType; + /** Error message. */ public final String message; + /** The fixes which can resolve this error (possibly empty). */ protected final ImmutableSet resolvingFixes; + /** Offset of program point in original version where error is reported. */ protected final int offset; + /** Containing region. */ protected final Region region; diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/index/ErrorStore.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/index/ErrorStore.java index b067e4de7..9c1095e28 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/index/ErrorStore.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/index/ErrorStore.java @@ -41,10 +41,13 @@ public class ErrorStore { /** Initial state indexed by enclosing class and method. */ private final Index root; + /** Current state indexed by enclosing class and method. */ private Index current; + /** ModuleInfo of the module which indexed errors are reported on. */ private final ModuleInfo moduleInfo; + /** Annotator context. */ private final Context context; diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/index/Index.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/index/Index.java index 6f96d73f9..1b3402ff0 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/index/Index.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/index/Index.java @@ -43,8 +43,10 @@ public class Index { /** Contents of the index. */ private final Multimap items; + /** ModuleInfo of the module which indexed errors are reported on. */ private final ModuleInfo moduleInfo; + /** Annotator context. */ private final Context context; diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/index/Result.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/index/Result.java index f37386932..3b01fa7f2 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/index/Result.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/index/Result.java @@ -31,6 +31,7 @@ public class Result { /** Difference in number of elements in collection A and B. */ public final int size; + /** Items that are present in A, but not B. */ public final Collection dif; diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/method/MethodRecord.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/method/MethodRecord.java index ead102d08..d2a44352d 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/method/MethodRecord.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/method/MethodRecord.java @@ -36,18 +36,25 @@ public class MethodRecord { /** Set of children's id. */ public Set children; + /** Parent's node id. */ public Integer parent; + /** A unique id for method across all methods. */ public Integer id; + /** Location of the containing method. */ public OnMethod location; + /** Set of annotations on the method return type or the method itself */ public ImmutableSet annotations; + /** Visibility of the method. */ public Visibility visibility; + /** Is true if the method has non-primitive return. */ public boolean hasNonPrimitiveReturn; + /** Is true if the method is a constructor. */ public boolean isConstructor; diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/method/MethodRegistry.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/method/MethodRegistry.java index 338c3bc68..e73641d67 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/method/MethodRegistry.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/method/MethodRegistry.java @@ -50,8 +50,10 @@ public class MethodRegistry extends Registry { /** Each method has a unique id across all methods. This hashmap, maps ids to nodes. */ private HashMap nodes; + /** A map from class flat name to its declared constructors */ private Multimap classConstructorMap; + /** Set of all classes flat name declared in module. */ private Set declaredClasses; diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/region/CompoundRegionRegistry.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/region/CompoundRegionRegistry.java index 4185aa250..96c136078 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/region/CompoundRegionRegistry.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/region/CompoundRegionRegistry.java @@ -38,8 +38,10 @@ public class CompoundRegionRegistry implements RegionRegistry { /** List of all region registries. */ private final ImmutableSet registries; + /** Module where this registry belongs to. */ private final ModuleInfo moduleInfo; + /** * Method region registry. This registry is used by other registries to identify impacted regions * specifically {@link AnnotationProcessorHandler}. To avoid recreating this instance, it is diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/region/ParameterRegionRegistry.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/region/ParameterRegionRegistry.java index 645c46a6c..bf24fa8c7 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/region/ParameterRegionRegistry.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/region/ParameterRegionRegistry.java @@ -38,6 +38,7 @@ public class ParameterRegionRegistry implements RegionRegistry { /** ModuleInfo of the module which usage of parameters are stored. */ private final ModuleInfo moduleInfo; + /** {@link MethodRegionRegistry} instance, used to retrieve all sites. */ private final MethodRegionRegistry methodRegionRegistry; diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/region/Region.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/region/Region.java index 444ac6835..54970eaa7 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/region/Region.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/region/Region.java @@ -39,8 +39,10 @@ public class Region { * value will be String of {@code "null"} not {@code null}. */ public final String member; + /** Fully qualified name of the enclosing class of the region. */ public final String clazz; + /** * Type of region. If region exists in source code, this value is {@code "SOURCE"}, otherwise it * will be the name of the processor created this region. (e.g. {"LOMBOK"}). diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/region/RegionRecord.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/region/RegionRecord.java index 14cc36578..d6fc7d424 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/region/RegionRecord.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/region/RegionRecord.java @@ -33,6 +33,7 @@ public class RegionRecord { public final Region region; public final String calleeMember; + /** Fully qualified name of the enclosing class of callee. */ public final String calleeClass; diff --git a/annotator-core/src/test/java/edu/ucr/cs/riple/core/AnnotatorBaseCoreTest.java b/annotator-core/src/test/java/edu/ucr/cs/riple/core/AnnotatorBaseCoreTest.java index 0869f905c..8e2ad5ff6 100644 --- a/annotator-core/src/test/java/edu/ucr/cs/riple/core/AnnotatorBaseCoreTest.java +++ b/annotator-core/src/test/java/edu/ucr/cs/riple/core/AnnotatorBaseCoreTest.java @@ -42,12 +42,16 @@ public abstract class AnnotatorBaseCoreTest { /** Temporary folder for each test. */ @Rule public final TemporaryFolder temporaryFolder = new TemporaryFolder(); + /** Name of the used project template */ protected final String projectTemplate; + /** Path to the unit test project */ protected Path unitTestProjectPath; + /** Path to the output directory */ protected Path outDirPath; + /** Helper class for core tests */ protected CoreTestHelper coreTestHelper; diff --git a/annotator-core/src/test/java/edu/ucr/cs/riple/core/OffsetChangeHandlingTest.java b/annotator-core/src/test/java/edu/ucr/cs/riple/core/OffsetChangeHandlingTest.java index bffa148c0..d106d1a1a 100644 --- a/annotator-core/src/test/java/edu/ucr/cs/riple/core/OffsetChangeHandlingTest.java +++ b/annotator-core/src/test/java/edu/ucr/cs/riple/core/OffsetChangeHandlingTest.java @@ -55,12 +55,16 @@ public class OffsetChangeHandlingTest { @Rule public final TemporaryFolder temporaryFolder = new TemporaryFolder(); + /** Map of field name to original field location offset. */ private final ImmutableMap originalFieldOffsetMap; + /** Map of field to enclosing flat name. */ private final ImmutableMap fieldClassMap; + /** Root of tests. */ private Path root; + /** Path to input in resources directory. */ private final Path inputPath; diff --git a/annotator-core/src/test/java/edu/ucr/cs/riple/core/tools/CoreTestHelper.java b/annotator-core/src/test/java/edu/ucr/cs/riple/core/tools/CoreTestHelper.java index f24b51fdc..63f626e90 100644 --- a/annotator-core/src/test/java/edu/ucr/cs/riple/core/tools/CoreTestHelper.java +++ b/annotator-core/src/test/java/edu/ucr/cs/riple/core/tools/CoreTestHelper.java @@ -56,37 +56,51 @@ public class CoreTestHelper { /** The expected reports which gets compared with computed reports when process is finished. */ private final Set expectedReports; + /** Path to the project. */ private final Path projectPath; + /** Path to root directory where all output exists including the project. */ private final Path outDirPath; + /** * Predicate to be used for comparing reports. If not set by the user, {@link DEFAULT_PREDICATE} * will be used. */ private BiPredicate predicate; + /** Depth of the analysis. */ private int depth = 1; + /** Outer loop activation. Deactivated by default */ private boolean outerLoopActivated = false; + /** Bailout activation. Deactivated by default */ private boolean disableBailout = false; + /** Suppress remaining errors mode activation. Deactivated by default */ private boolean suppressRemainingErrors = false; + /** Downstream dependency analysis activation. Deactivated by default */ private boolean downstreamDependencyAnalysisActivated = false; + /** Inference activation. Activated by default */ private boolean deactivateInference = false; + /** Analysis mode. */ private AnalysisMode mode = AnalysisMode.LOCAL; + /** Annotator config. */ private Config config; + /** * Path to the expected output directory. If null, changes on source files will not be checked. */ private Path expectedOutputPath; + /** Project builder. */ private final ProjectBuilder projectBuilder; + /** Annotator log instance after the test execution. */ private Log log; diff --git a/annotator-core/src/test/java/edu/ucr/cs/riple/core/tools/Module.java b/annotator-core/src/test/java/edu/ucr/cs/riple/core/tools/Module.java index c7a10f821..5c3e346d1 100644 --- a/annotator-core/src/test/java/edu/ucr/cs/riple/core/tools/Module.java +++ b/annotator-core/src/test/java/edu/ucr/cs/riple/core/tools/Module.java @@ -14,10 +14,12 @@ public class Module { /** Name of the module. */ final String name; + /** * Path to the source directory of the module. All classes must be under test package directory. */ final Path srcSet; + /** * Reference to {@link ProjectBuilder} to preserve a builder pattern and return to the control * back to it. diff --git a/annotator-core/src/test/java/edu/ucr/cs/riple/core/tools/ProjectBuilder.java b/annotator-core/src/test/java/edu/ucr/cs/riple/core/tools/ProjectBuilder.java index 10be97570..44565dcc4 100644 --- a/annotator-core/src/test/java/edu/ucr/cs/riple/core/tools/ProjectBuilder.java +++ b/annotator-core/src/test/java/edu/ucr/cs/riple/core/tools/ProjectBuilder.java @@ -38,8 +38,10 @@ public class ProjectBuilder { /** Set of modules in the project. */ private final List modules; + /** Path to the project. */ private final Path pathToProject; + /** * Reference to {@link CoreTestHelper} to preserve a builder pattern and return to the control * back to it. diff --git a/annotator-scanner/build.gradle b/annotator-scanner/build.gradle index c2c2652c5..b190bee42 100644 --- a/annotator-scanner/build.gradle +++ b/annotator-scanner/build.gradle @@ -37,7 +37,6 @@ buildscript { plugins { id "net.ltgt.errorprone" version "2.0.1" apply false - id 'com.github.sherter.google-java-format' version '0.9' id 'maven-publish' id "com.vanniktech.maven.publish" } diff --git a/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/ErrorProneCLIFlagsConfig.java b/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/ErrorProneCLIFlagsConfig.java index 170e98fac..0dba847df 100644 --- a/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/ErrorProneCLIFlagsConfig.java +++ b/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/ErrorProneCLIFlagsConfig.java @@ -48,12 +48,16 @@ public class ErrorProneCLIFlagsConfig implements Config { /** Path to output dir. */ @Nonnull private final Path outputDirectory; + /** Controls serialization services activation. */ private final boolean serializationIsActive; + /** Serializing instance for writing outputs at the desired paths. */ private final Serializer serializer; + /** Source type resolver for serialized regions. */ private final SymbolSourceResolver symbolSourceResolver; + /** Immutable set of fully qualified name of {@code @Nonnull} annotations. */ private final ImmutableSet nonnullAnnotations; diff --git a/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/ScannerConfigWriter.java b/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/ScannerConfigWriter.java index 9c54b9577..61d9b5547 100644 --- a/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/ScannerConfigWriter.java +++ b/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/ScannerConfigWriter.java @@ -49,8 +49,10 @@ public class ScannerConfigWriter { /** Path to output directory. */ private Path outputDirectory; + /** Controls serialization services activation. */ private boolean serializationActivation; + /** Set of activated generated code detectors. */ private final Set activatedGeneratedCodeDetectors; diff --git a/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/ScannerContext.java b/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/ScannerContext.java index c7e7220ee..a99725c92 100644 --- a/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/ScannerContext.java +++ b/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/ScannerContext.java @@ -43,11 +43,13 @@ public class ScannerContext { * hash value. */ private final Multimap visitedMethods; + /** * Last given id to the most recent newly visited method. Used to assign unique ids for each * method. */ private int methodId; + /** Type Annotator Scanner config. */ private final Config config; diff --git a/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/Serializer.java b/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/Serializer.java index 1e9236186..7e77106a0 100644 --- a/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/Serializer.java +++ b/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/Serializer.java @@ -51,22 +51,31 @@ public class Serializer { /** Path to write impacted regions for changes on fields. */ private final Path fieldImpactedRegionPath; + /** Path to write impacted regions for changes on methods */ private final Path methodImpactedRegionPath; + /** Path to write method records. */ private final Path methodRecordPath; + /** Path to write class info data. */ private final Path classRecordsPath; + /** Path to write location of elements with explicit {@code @Nonnull} annotation. */ private final Path nonnullElementsPath; + /** File name where all field usage data has been stored. */ public static final String FIELD_IMPACTED_REGION_FILE_NAME = "field_impacted_region_map.tsv"; + /** File name where all impacted regions for changes on methods are serialized. */ public static final String METHOD_IMPACTED_REGION_FILE_NAME = "method_impacted_region_map.tsv"; + /** File name where all method data has been stored. */ public static final String METHOD_RECORD_FILE_NAME = "method_records.tsv"; + /** File name where all class data has been stored. */ public static final String CLASS_RECORD_FILE_NAME = "class_records.tsv"; + /** File name where location of elements explicitly annotated as {@code @Nonnull}. */ public static final String NON_NULL_ELEMENTS_FILE_NAME = "nonnull_elements.tsv"; diff --git a/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/location/AbstractSymbolLocation.java b/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/location/AbstractSymbolLocation.java index f49abaa5a..5eefec360 100644 --- a/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/location/AbstractSymbolLocation.java +++ b/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/location/AbstractSymbolLocation.java @@ -39,8 +39,10 @@ public abstract class AbstractSymbolLocation implements SymbolLocation { /** Element kind of the targeted symbol */ protected final ElementKind type; + /** Path of the file containing the symbol, if available. */ @Nullable protected final Path path; + /** Enclosing class of the symbol. */ protected final Symbol.ClassSymbol enclosingClass; diff --git a/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/location/MethodParameterLocation.java b/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/location/MethodParameterLocation.java index 096edfe4a..c5721ca42 100644 --- a/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/location/MethodParameterLocation.java +++ b/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/location/MethodParameterLocation.java @@ -35,8 +35,10 @@ public class MethodParameterLocation extends AbstractSymbolLocation { /** Symbol of the targeted method. */ private final Symbol.MethodSymbol enclosingMethod; + /** Symbol of the targeted method parameter. */ private final Symbol.VarSymbol paramSymbol; + /** Index of the method parameter in the containing method's argument list. */ private final int index; diff --git a/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/out/ClassRecord.java b/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/out/ClassRecord.java index 2f079d157..805453512 100644 --- a/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/out/ClassRecord.java +++ b/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/out/ClassRecord.java @@ -34,6 +34,7 @@ public class ClassRecord { /** Containing class symbol. */ public final Symbol.ClassSymbol clazz; + /** Path to url containing this class. */ @Nullable public final Path path; diff --git a/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/out/ImpactedRegion.java b/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/out/ImpactedRegion.java index 632441178..6f71a00ce 100644 --- a/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/out/ImpactedRegion.java +++ b/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/out/ImpactedRegion.java @@ -39,10 +39,13 @@ public class ImpactedRegion { /** Symbol of the member. */ private final Symbol memberSymbol; + /** Symbol of the enclosing class of the impacted region. */ @Nullable private final Symbol.ClassSymbol regionClass; + /** Symbol of the impacted region. */ @Nullable private final Symbol regionMember; + /** Source type of the impacted region. */ private final SourceType source; diff --git a/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/out/MethodRecord.java b/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/out/MethodRecord.java index 4a9c7d771..d846523f4 100644 --- a/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/out/MethodRecord.java +++ b/annotator-scanner/src/main/java/edu/ucr/cs/riple/scanner/out/MethodRecord.java @@ -49,24 +49,31 @@ public class MethodRecord { /** Symbol of containing method. */ private final Symbol.MethodSymbol symbol; + /** Symbol of the enclosing class for the method. */ private final Symbol.ClassSymbol clazz; + /** Path to file containing the source file. */ private URI uri; + /** Unique id assigned to this method across all visited methods. */ private final int id; + /** * Set of annotations on the method return type or the method itself. If the method has no * annotations, then this field will be empty and not {@code null}. */ private ImmutableSet annotations; + /** * Flag value for parameters annotations. If {@code annotFlags[j]} is {@code true} then the * parameter at index {@code j} has a {@code @Nullable} annotation. */ private Boolean[] parameterAnnotationFlags; + /** ID of the closest super method. */ private int parentID; + /** Delimiter used to separate annotations in the serialized output. */ public static final String ANNOTATION_DELIMITER = ","; diff --git a/build.gradle b/build.gradle index 89a23e362..2c0a25872 100644 --- a/build.gradle +++ b/build.gradle @@ -24,6 +24,7 @@ import net.ltgt.gradle.errorprone.CheckSeverity plugins{ id "net.ltgt.errorprone" version "2.0.1" apply false id "com.vanniktech.maven.publish" version "0.22.0" apply false + id("com.diffplug.gradle.spotless") version "6.25.0" apply false } allprojects { @@ -44,6 +45,7 @@ subprojects { proj -> proj.apply plugin: "java" proj.apply plugin: "net.ltgt.errorprone" + proj.apply plugin: "com.diffplug.spotless" proj.dependencies { errorprone deps.build.errorProneCore @@ -77,4 +79,10 @@ subprojects { proj -> sourceCompatibility = 1.11 targetCompatibility = 1.11 + + spotless { + java { + googleJavaFormat('1.24.0') + } + } } diff --git a/checks/ban-mutable-static/build.gradle b/checks/ban-mutable-static/build.gradle index 3171024fd..dc25dac33 100644 --- a/checks/ban-mutable-static/build.gradle +++ b/checks/ban-mutable-static/build.gradle @@ -24,7 +24,6 @@ plugins { id "net.ltgt.errorprone" version "2.0.1" apply false - id 'com.github.sherter.google-java-format' version '0.9' } dependencies { diff --git a/injector/build.gradle b/injector/build.gradle index 24378e1ee..d0924f314 100644 --- a/injector/build.gradle +++ b/injector/build.gradle @@ -22,10 +22,6 @@ * THE SOFTWARE. */ -plugins { - id 'com.github.sherter.google-java-format' version '0.9' -} - dependencies { implementation deps.build.guava @@ -39,11 +35,11 @@ dependencies { testImplementation deps.build.commonsio } -compileJava.mustRunAfter verifyGoogleJavaFormat - -googleJavaFormat { - // don't enforce formatting for generated Java code under buildSrc - exclude 'tests/**/*.java' - // tests expected output does not conform to google java format rules. - exclude '**/test/resources/**/*.java' +spotless { + java { + // don't enforce formatting for generated Java code under buildSrc + targetExclude 'tests/**/*.java' + // tests expected output does not conform to google java format rules. + targetExclude '**/test/resources/**/*.java' + } } diff --git a/injector/src/main/java/edu/ucr/cs/riple/injector/Printer.java b/injector/src/main/java/edu/ucr/cs/riple/injector/Printer.java index 9bdfe1a6d..f24fff7ae 100644 --- a/injector/src/main/java/edu/ucr/cs/riple/injector/Printer.java +++ b/injector/src/main/java/edu/ucr/cs/riple/injector/Printer.java @@ -47,8 +47,10 @@ public class Printer { /** Path to source file. */ private final Path path; + /** Lines of source file. */ private final List lines; + /** Offset store for recording changes in source code. */ private final FileOffsetStore offsetStore; diff --git a/injector/src/main/java/edu/ucr/cs/riple/injector/SignatureMatcher.java b/injector/src/main/java/edu/ucr/cs/riple/injector/SignatureMatcher.java index 0cf46a062..79e4160ba 100644 --- a/injector/src/main/java/edu/ucr/cs/riple/injector/SignatureMatcher.java +++ b/injector/src/main/java/edu/ucr/cs/riple/injector/SignatureMatcher.java @@ -34,6 +34,7 @@ public class SignatureMatcher { /** Simple name of the callable. */ private final String callableName; + /** List of parameters detected from signature in string. */ private final List parameterTypes; diff --git a/injector/src/main/java/edu/ucr/cs/riple/injector/changes/AnnotationChange.java b/injector/src/main/java/edu/ucr/cs/riple/injector/changes/AnnotationChange.java index 418f5ac9c..5aaeb84a1 100644 --- a/injector/src/main/java/edu/ucr/cs/riple/injector/changes/AnnotationChange.java +++ b/injector/src/main/java/edu/ucr/cs/riple/injector/changes/AnnotationChange.java @@ -30,6 +30,7 @@ public abstract class AnnotationChange implements ASTChange { /** Location of the element which its annotations should be changed. */ public final Location location; + /** Annotation name. */ public final Name annotationName; diff --git a/injector/src/main/java/edu/ucr/cs/riple/injector/changes/Name.java b/injector/src/main/java/edu/ucr/cs/riple/injector/changes/Name.java index 095bc2331..0bc199431 100644 --- a/injector/src/main/java/edu/ucr/cs/riple/injector/changes/Name.java +++ b/injector/src/main/java/edu/ucr/cs/riple/injector/changes/Name.java @@ -30,6 +30,7 @@ public class Name { /** The simple name of the name, i.e., the last identifier. */ public final String simpleName; + /** The full name of the name, i.e., all identifiers. */ public final String fullName; diff --git a/injector/src/main/java/edu/ucr/cs/riple/injector/location/Location.java b/injector/src/main/java/edu/ucr/cs/riple/injector/location/Location.java index 96552fa28..8cf19b143 100644 --- a/injector/src/main/java/edu/ucr/cs/riple/injector/location/Location.java +++ b/injector/src/main/java/edu/ucr/cs/riple/injector/location/Location.java @@ -38,8 +38,10 @@ public abstract class Location { /** The kind of the element. */ public final LocationKind kind; + /** The flat name of enclosing class of the element. */ public final String clazz; + /** The path to the file containing the element. */ public Path path; @@ -111,6 +113,7 @@ public void ifMethod(Consumer consumer) {} * @param consumer The consumer to be called. */ public void ifParameter(Consumer consumer) {} + /** * If this location is of kind {@link LocationKind#FIELD}, calls the consumer on the location. * diff --git a/injector/src/main/java/edu/ucr/cs/riple/injector/location/OnLocalVariable.java b/injector/src/main/java/edu/ucr/cs/riple/injector/location/OnLocalVariable.java index 8de77c97f..41be02d9e 100644 --- a/injector/src/main/java/edu/ucr/cs/riple/injector/location/OnLocalVariable.java +++ b/injector/src/main/java/edu/ucr/cs/riple/injector/location/OnLocalVariable.java @@ -38,6 +38,7 @@ public class OnLocalVariable extends Location { /** Enclosing method of the target local variable. */ public final OnMethod encMethod; + /** Name of the local variable. */ public final String varName; diff --git a/injector/src/main/java/edu/ucr/cs/riple/injector/location/OnMethod.java b/injector/src/main/java/edu/ucr/cs/riple/injector/location/OnMethod.java index f3c2c1cfc..5cb129417 100644 --- a/injector/src/main/java/edu/ucr/cs/riple/injector/location/OnMethod.java +++ b/injector/src/main/java/edu/ucr/cs/riple/injector/location/OnMethod.java @@ -36,6 +36,7 @@ public class OnMethod extends Location { /** Method signature of the target element. */ public final String method; + /** * Matcher for the method signature. Method signature is given as a string, this matcher is used * to match the target. diff --git a/injector/src/main/java/edu/ucr/cs/riple/injector/location/OnParameter.java b/injector/src/main/java/edu/ucr/cs/riple/injector/location/OnParameter.java index 4719c12a0..ae1a991df 100644 --- a/injector/src/main/java/edu/ucr/cs/riple/injector/location/OnParameter.java +++ b/injector/src/main/java/edu/ucr/cs/riple/injector/location/OnParameter.java @@ -37,6 +37,7 @@ public class OnParameter extends Location { /** Enclosing Method location of the parameter. */ public final OnMethod enclosingMethod; + /** Index of the parameter in the method signature. */ public final int index; diff --git a/injector/src/main/java/edu/ucr/cs/riple/injector/modifications/SinglePositionModification.java b/injector/src/main/java/edu/ucr/cs/riple/injector/modifications/SinglePositionModification.java index 18e5a0932..81dbff110 100644 --- a/injector/src/main/java/edu/ucr/cs/riple/injector/modifications/SinglePositionModification.java +++ b/injector/src/main/java/edu/ucr/cs/riple/injector/modifications/SinglePositionModification.java @@ -35,6 +35,7 @@ public abstract class SinglePositionModification implements Modification { /** Starting position where the modification should be applied in the source file. */ public final Position startPosition; + /** Content of modification. */ public final String content; diff --git a/injector/src/main/java/edu/ucr/cs/riple/injector/offsets/FileOffsetStore.java b/injector/src/main/java/edu/ucr/cs/riple/injector/offsets/FileOffsetStore.java index d266b6b84..0d80e500d 100644 --- a/injector/src/main/java/edu/ucr/cs/riple/injector/offsets/FileOffsetStore.java +++ b/injector/src/main/java/edu/ucr/cs/riple/injector/offsets/FileOffsetStore.java @@ -41,8 +41,10 @@ public class FileOffsetStore { /** Path to file. */ private final Path path; + /** List of existing offset changes. */ private SortedSet offsetChanges; + /** Contents of file. */ private final ImmutableList lines; diff --git a/injector/src/main/java/edu/ucr/cs/riple/injector/offsets/OffsetChange.java b/injector/src/main/java/edu/ucr/cs/riple/injector/offsets/OffsetChange.java index 1760824e0..95298c218 100644 --- a/injector/src/main/java/edu/ucr/cs/riple/injector/offsets/OffsetChange.java +++ b/injector/src/main/java/edu/ucr/cs/riple/injector/offsets/OffsetChange.java @@ -35,6 +35,7 @@ public class OffsetChange implements Comparable { /** Index of addition / deletion. */ public final int position; + /** Number of characters added / removed. */ public final int numChars; diff --git a/library-model-loader/build.gradle b/library-model-loader/build.gradle index b0b55b9b6..f0d95dcd7 100644 --- a/library-model-loader/build.gradle +++ b/library-model-loader/build.gradle @@ -22,7 +22,6 @@ plugins { id "java-library" - id 'com.github.sherter.google-java-format' version '0.9' } version=""