diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 0c9d86e..6fe0ecd 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -16,6 +16,8 @@ jobs:
steps:
- uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 5f66da6..b7c6b90 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -8,6 +8,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
- name: Set up Java for publishing to Maven Central Repository
uses: actions/setup-java@v3
with:
diff --git a/README.md b/README.md
index 5ca530a..575fc79 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,7 @@ EvalEx - Java Expression Evaluator
[](https://sonarcloud.io/summary/new_code?id=ezylang_EvalEx)
[](https://sonarcloud.io/summary/new_code?id=ezylang_EvalEx)
[](https://sonarcloud.io/summary/new_code?id=ezylang_EvalEx)
+[](https://search.maven.org/search?q=a:%22EvalEx%22)
| :warning: Version 3 of EvalEx is a complete rewrite of the popular expression evaluator. See [the new documentation area](https://ezylang.github.io/EvalEx/concepts/changes.html) for an overview of the changes. |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
@@ -41,6 +42,13 @@ on [GitHub Pages](https://ezylang.github.io/EvalEx/)
For announcements, questions and ideas visit
the [Discussions area](https://github.com/ezylang/EvalEx/discussions).
+## Download / Including
+
+You can download the binaries, source code and JavaDoc jars from
+[Maven Central](https://search.maven.org/search?q=a:%22EvalEx%22).\
+You will find there also copy/paste templates for including EvalEx in your project with build
+systems like Maven or Gradle.
+
## Examples
### A simple example, that shows how it works in general:
diff --git a/src/main/java/com/ezylang/evalex/Expression.java b/src/main/java/com/ezylang/evalex/Expression.java
index 5b53736..5f88735 100644
--- a/src/main/java/com/ezylang/evalex/Expression.java
+++ b/src/main/java/com/ezylang/evalex/Expression.java
@@ -332,10 +332,10 @@ public class Expression {
}
/**
- * Returns all variables or constants that are used i the expression, excluding the standard
- * constants like e.g. PI or TRUE and FALSE.
+ * Returns all variables that are used i the expression, excluding the constants like e.g.
+ * PI or TRUE and FALSE.
*
- * @return All used variables and constants less the standard constants.
+ * @return All used variables excluding constants.
* @throws ParseException If there were problems while parsing the expression.
*/
public Set getUsedVariables() throws ParseException {
@@ -350,4 +350,20 @@ public class Expression {
return variables;
}
+
+ /**
+ * Returns all variables that are used in the expression, but have no value assigned.
+ *
+ * @return All variables that have no value assigned.
+ * @throws ParseException If there were problems while parsing the expression.
+ */
+ public Set getUndefinedVariables() throws ParseException {
+ Set variables = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
+ for (String variable : getUsedVariables()) {
+ if (getDataAccessor().getData(variable) == null) {
+ variables.add(variable);
+ }
+ }
+ return variables;
+ }
}
diff --git a/src/test/java/com/ezylang/evalex/ExpressionTest.java b/src/test/java/com/ezylang/evalex/ExpressionTest.java
index e0ffad5..ba9cf0b 100644
--- a/src/test/java/com/ezylang/evalex/ExpressionTest.java
+++ b/src/test/java/com/ezylang/evalex/ExpressionTest.java
@@ -145,4 +145,10 @@ class ExpressionTest {
Expression expression = new Expression("a+B*b-A/PI*(1/2)*pi+e-E+a");
assertThat(expression.getUsedVariables()).containsExactlyInAnyOrder("a", "b");
}
+
+ @Test
+ void testGetUndefinedVariables() throws ParseException {
+ Expression expression = new Expression("a+A+b+B+c+C+E+e+PI+x").with("x", 1);
+ assertThat(expression.getUndefinedVariables()).containsExactlyInAnyOrder("a", "b", "c");
+ }
}