From 34989702ef50f1ae3939d7acda3ad3b8dabc56e1 Mon Sep 17 00:00:00 2001 From: Priti Chattopadhyay <35490584+PRITI1999@users.noreply.github.com> Date: Tue, 21 Jul 2020 04:21:42 +0530 Subject: [PATCH] Add -Aversion command-line option; fixes #3381 --- changelog.txt | 2 ++ docs/manual/introduction.tex | 4 ++++ .../framework/source/SourceChecker.java | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/changelog.txt b/changelog.txt index 1b5311437e1..35768a76cb1 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,7 @@ Version 3.6.0, August 3, 2020 +Added a new option `-Aversion` to print the version of the Checker Framework. + The Interning Checker supports method annotations @EqualsMethod and @CompareToMethod. Place them on methods like equals(), compareTo(), and compare() to permit certain uses of == on non-interned values. diff --git a/docs/manual/introduction.tex b/docs/manual/introduction.tex index b01e64043c9..9a2d0327cd2 100644 --- a/docs/manual/introduction.tex +++ b/docs/manual/introduction.tex @@ -788,6 +788,10 @@ \<-AatfCacheSize> Miscellaneous debugging options; see Section~\ref{creating-debugging-options-misc}. +\item + \<-Aversion> +Print the Checker Framework version. + \item \<-AprintGitProperties> Print information about the git repository from which the Checker Framework diff --git a/framework/src/main/java/org/checkerframework/framework/source/SourceChecker.java b/framework/src/main/java/org/checkerframework/framework/source/SourceChecker.java index 1806f7bf62d..2ff0cde379b 100644 --- a/framework/src/main/java/org/checkerframework/framework/source/SourceChecker.java +++ b/framework/src/main/java/org/checkerframework/framework/source/SourceChecker.java @@ -253,6 +253,8 @@ /// Amount of detail in messages + // Print the version of the Checker Framework + "version", // Print info about git repository from which the Checker Framework was compiled "printGitProperties", @@ -781,6 +783,9 @@ public void run() { } }); } + if (hasOption("version")) { + messager.printMessage(Kind.NOTE, "Checker Framework " + getCheckerVersion()); + } } catch (UserError ce) { logUserError(ce); } catch (TypeSystemError ce) { @@ -2530,4 +2535,18 @@ private void printGitProperties() { System.out.println("IOException while reading git.properties: " + e.getMessage()); } } + + /** + * Returns the version of the Checker Framework. + * + * @return Checker Framework version + */ + private String getCheckerVersion() { + Properties gitProperties = getProperties(getClass(), "/git.properties"); + String version = gitProperties.getProperty("git.build.version"); + if (version != null) { + return version; + } + throw new BugInCF("Could not find the version in git.properties"); + } }