Skip to content

Commit

Permalink
[java] Add JSpecify annotations to WebElement and SearchContext (Sele…
Browse files Browse the repository at this point in the history
  • Loading branch information
mk868 committed Aug 9, 2024
1 parent a5de377 commit 34197fa
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ maven.install(
"org.bouncycastle:bcpkix-jdk18on:1.78.1",
"org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5",
"org.hsqldb:hsqldb:2.7.3",
"org.jspecify:jspecify:1.0.0",
"org.junit.jupiter:junit-jupiter-api:5.10.3",
"org.junit.jupiter:junit-jupiter-engine:5.10.3",
"org.junit.jupiter:junit-jupiter-params:5.10.3",
Expand Down
16 changes: 14 additions & 2 deletions java/maven_install.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL",
"__INPUT_ARTIFACTS_HASH": 966816920,
"__RESOLVED_ARTIFACTS_HASH": -1502533934,
"__INPUT_ARTIFACTS_HASH": -1798640815,
"__RESOLVED_ARTIFACTS_HASH": 890286156,
"conflict_resolution": {
"com.google.code.gson:gson:2.8.9": "com.google.code.gson:gson:2.11.0",
"com.google.errorprone:error_prone_annotations:2.3.2": "com.google.errorprone:error_prone_annotations:2.27.0",
Expand Down Expand Up @@ -654,6 +654,13 @@
},
"version": "6.2.2"
},
"org.jspecify:jspecify": {
"shasums": {
"jar": "1fad6e6be7557781e4d33729d49ae1cdc8fdda6fe477bb0cc68ce351eafdfbab",
"sources": "adf0898191d55937fb3192ba971826f4f294292c4a960740f3c27310e7b70296"
},
"version": "1.0.0"
},
"org.junit.jupiter:junit-jupiter-api": {
"shasums": {
"jar": "6efe6e01ca1ff79b7bf4c6f1eed0b29292e166c27eaf7b00ac981a14d4de61aa",
Expand Down Expand Up @@ -2620,6 +2627,9 @@
"jodd.typeconverter.impl",
"jodd.util"
],
"org.jspecify:jspecify": [
"org.jspecify.annotations"
],
"org.junit.jupiter:junit-jupiter-api": [
"org.junit.jupiter.api",
"org.junit.jupiter.api.condition",
Expand Down Expand Up @@ -3134,6 +3144,8 @@
"org.htmlunit:htmlunit-core-js:jar:sources",
"org.jodd:jodd-util",
"org.jodd:jodd-util:jar:sources",
"org.jspecify:jspecify",
"org.jspecify:jspecify:jar:sources",
"org.junit.jupiter:junit-jupiter-api",
"org.junit.jupiter:junit-jupiter-api:jar:sources",
"org.junit.jupiter:junit-jupiter-engine",
Expand Down
4 changes: 2 additions & 2 deletions java/src/org/openqa/selenium/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//java:defs.bzl", "java_dist_zip", "java_export", "java_import", "javadoc")
load("//java:defs.bzl", "artifact", "java_dist_zip", "java_export", "java_import", "javadoc")
load("//java:version.bzl", "SE_VERSION")
load("//java/src/org/openqa/selenium/devtools:versions.bzl", "CDP_DEPS")

Expand Down Expand Up @@ -32,8 +32,8 @@ java_export(
pom_template = ":template-pom",
visibility = ["//visibility:public"],
deps = [
# Nothing from third party
":manifest",
artifact("org.jspecify:jspecify"),
],
)

Expand Down
2 changes: 2 additions & 0 deletions java/src/org/openqa/selenium/SearchContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
package org.openqa.selenium;

import java.util.List;
import org.jspecify.annotations.NullMarked;

@NullMarked
public interface SearchContext {
/**
* Find all elements within the current context using the given mechanism.
Expand Down
13 changes: 8 additions & 5 deletions java/src/org/openqa/selenium/WebElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package org.openqa.selenium;

import java.util.List;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

/**
* Represents an HTML element. Generally, all interesting operations to do with interacting with a
Expand All @@ -28,6 +30,7 @@
* fails, then an {@link org.openqa.selenium.StaleElementReferenceException} is thrown, and all
* future calls to this instance will fail.
*/
@NullMarked
public interface WebElement extends SearchContext, TakesScreenshot {
/**
* Click this element. If this causes a new page to load, you should discard all references to
Expand Down Expand Up @@ -98,7 +101,7 @@ public interface WebElement extends SearchContext, TakesScreenshot {
* @param name The name of the property.
* @return The property's current value or null if the value is not set.
*/
default String getDomProperty(String name) {
default @Nullable String getDomProperty(String name) {
throw new UnsupportedOperationException("getDomProperty");
}

Expand All @@ -122,7 +125,7 @@ default String getDomProperty(String name) {
* @param name The name of the attribute.
* @return The attribute's value or null if the value is not set.
*/
default String getDomAttribute(String name) {
default @Nullable String getDomAttribute(String name) {
throw new UnsupportedOperationException("getDomAttribute");
}

Expand Down Expand Up @@ -163,7 +166,7 @@ default String getDomAttribute(String name) {
* @param name The name of the attribute.
* @return The attribute/property's current value or null if the value is not set.
*/
String getAttribute(String name);
@Nullable String getAttribute(String name);

/**
* Gets result of computing the WAI-ARIA role of element.
Expand All @@ -173,7 +176,7 @@ default String getDomAttribute(String name) {
*
* @return the WAI-ARIA role of the element.
*/
default String getAriaRole() {
default @Nullable String getAriaRole() {
throw new UnsupportedOperationException("getAriaRole");
}

Expand All @@ -186,7 +189,7 @@ default String getAriaRole() {
*
* @return the accessible name of the element.
*/
default String getAccessibleName() {
default @Nullable String getAccessibleName() {
throw new UnsupportedOperationException("getAccessibleName");
}

Expand Down

0 comments on commit 34197fa

Please sign in to comment.