Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions src/share/classes/jdk/codetools/apidiff/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ public String toString() {
Boolean compareDocComments;
Boolean compareApiDescriptions;
Boolean compareApiDescriptionsAsText;
Boolean showUnchanged;
String jdkDocs;

// output options
Expand All @@ -181,7 +182,6 @@ public String toString() {
Path mainStylesheet;
List<Path> extraStylesheets;
List<Path> resourceFiles;
boolean showEqual;

/**
* The position of additional text to be included in the report.
Expand Down Expand Up @@ -336,6 +336,16 @@ void process(String opt, String arg, Options options) throws BadOption {
}
},

/**
* {@code --show-unchanged} <var>boolean-value</var>
*/
SHOW_UNCHANGED("--show-unchanged", "opt.arg.boolean") {
@Override
void process(String opt, String arg, Options options) throws BadOption {
options.showUnchanged = asBoolean(arg);
}
},

/**
* {@code --enable-preview}.
*
Expand Down Expand Up @@ -909,6 +919,15 @@ public boolean compareApiDescriptionsAsText() {
return compareApiDescriptionsAsText;
}

/**
* Returns whether unchanged API elements should be unconditionally shown.
*
* @return {@code true} if unchanged API elements should be unconditionally shown
*/
public boolean showUnchanged() {
return showUnchanged;
}

/**
* Returns whether documentation comments should be compared.
*
Expand Down Expand Up @@ -981,10 +1000,6 @@ public List<Path> getResourceFiles() {
return (resourceFiles == null) ? Collections.emptyList() : resourceFiles;
}

public boolean showEqual() {
return showEqual;
}

/**
* Returns the value of a "hidden" option, set by {@code -XD<name>} or
* {@code -XD<name>=<value>}.
Expand Down Expand Up @@ -1082,6 +1097,10 @@ void validate() {
compareDocComments = !compareApiDescriptions;
}

if (showUnchanged == null) {
showUnchanged = false;
}

if (resourceFiles != null) {
for (var resFile : resourceFiles) {
if (resFile.isAbsolute() && !Files.exists(resFile)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ protected Content buildNav(InfoTextKind kind) {
}
List<Content> infoBox = new ArrayList<>();
infoBox.add(new RawHtml(infoText));
if (kind == InfoTextKind.HEADER) {
if (kind == InfoTextKind.HEADER && !parent.options.showUnchanged()) {
String showUnchangedCheckbox =
"""
<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ opt.desc.release=\
opt.desc.resource-files=\
Specifies resource files to be copied from an API directory

opt.desc.show-unchanged=\
Unchanged elements should be unconditionally shown in the resulting diff

opt.desc.source=\
Specifies the version of the platform for an API.

Expand Down
5 changes: 5 additions & 0 deletions src/share/doc/apidiff.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ to repeat these options for each API to be compared.
<p class="note">This option may be useful when comparing HTML documentation that
depend on some non-HTML resource files.</p>

<a id="option-show-unchanged">`--show-unchanged` *boolean*</a>
: If true, unchanged elements will be show unconditionally. When false or
missing, the user viewing the diff will have an option to show or hide the
unchanged elements.

### Other Options

<a id="option-help">`--help`, `-help`, `-h`, `-?`</a>
Expand Down
Loading