Skip to content

PDE should not warn if resource URI of unknown scheme cannot be found#2032

Merged
HannesWell merged 1 commit intoeclipse-pde:masterfrom
Dani-Hub:#2031-PDE_should_not_warn_if_resource_URI_of_unknown_scheme_cannot_be_found
Nov 11, 2025
Merged

PDE should not warn if resource URI of unknown scheme cannot be found#2032
HannesWell merged 1 commit intoeclipse-pde:masterfrom
Dani-Hub:#2031-PDE_should_not_warn_if_resource_URI_of_unknown_scheme_cannot_be_found

Conversation

@Dani-Hub
Copy link
Contributor

Fixes #2031

@Dani-Hub
Copy link
Contributor Author

Could someone help my try to understand the test failures? I would like to see the test details for judgment on whether it is possibly caused by my changes or not - Thanks!

@github-actions
Copy link

github-actions bot commented Oct 19, 2025

Test Results

   771 files  ±0     771 suites  ±0   54m 49s ⏱️ + 3m 10s
 3 637 tests ±0   3 583 ✅ ±0   54 💤 ±0  0 ❌ ±0 
10 845 runs  ±0  10 682 ✅ ±0  163 💤 ±0  0 ❌ ±0 

Results for commit e7f3431. ± Comparison against base commit b00ef59.

♻️ This comment has been updated with latest results.

@Dani-Hub
Copy link
Contributor Author

Any help would be appreciated.

@HannesWell HannesWell force-pushed the #2031-PDE_should_not_warn_if_resource_URI_of_unknown_scheme_cannot_be_found branch from cfd0eec to dd902cc Compare October 23, 2025 20:01
Copy link
Member

@HannesWell HannesWell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late reply, the past few days have been busy.
I have added a few general comments, altough I think we should revisite the proposed solution as discussed in #2031 (comment) ff.

But still I think this is a good enhancement if we find a suitable solution that fits all cases.

Comment on lines 606 to 610
if (bundleJar == null && isValidUriOfUnknownProtocol(location)) {
return true;
}

return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be more compact, as if true then return true is a bit cumbersome.

Suggested change
if (bundleJar == null && isValidUriOfUnknownProtocol(location)) {
return true;
}
return false;
return bundleJar == null && isValidUriOfUnknownProtocol(location);

Comment on lines 618 to 626
boolean isKnownProtocol = false;
// Exclude those URI forms where we have already special
// handling for or where we are sure that they are known URLs:
for (String knownScheme : KNOWN_URI_SCHEMES) {
if (knownScheme.equalsIgnoreCase(scheme)) {
isKnownProtocol = true;
break;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know large parts of the PDE code-base are still in an old Java style, but that shouldn't prevent us from using newer, more readable styles in new or modified parts of the code:

Suggested change
boolean isKnownProtocol = false;
// Exclude those URI forms where we have already special
// handling for or where we are sure that they are known URLs:
for (String knownScheme : KNOWN_URI_SCHEMES) {
if (knownScheme.equalsIgnoreCase(scheme)) {
isKnownProtocol = true;
break;
}
}
boolean isKnownProtocol = KNOWN_URI_SCHEMES.stream().anyMatch(scheme::equalsIgnoreCase);

@Dani-Hub
Copy link
Contributor Author

I don't understand how I got this merge mess. Any suggestions?

@iloveeclipse
Copy link
Member

I don't understand how I got this merge mess. Any suggestions?

Don't merge but rebase your commit on top of master.

@merks
Copy link
Contributor

merks commented Oct 26, 2025

And, once you have PR started, use amend and force push for any subsequent changes.

Sometimes when I get into this state, I rename the branch to which I pushed my PR changes. check out master, do a pull, create a new branch with exactly the same name as the one I was using, apply the changes, then commit and force push by my fork. This will overwrite all the commits in that branch in your force and will update this existing PR.

@Dani-Hub
Copy link
Contributor Author

Actually I did ammend, but somehow a previous PULL must have happened. I follow now Ed's approach, thank you!

@Dani-Hub Dani-Hub force-pushed the #2031-PDE_should_not_warn_if_resource_URI_of_unknown_scheme_cannot_be_found branch from e94873d to e3d5fea Compare October 26, 2025 13:06
@Dani-Hub
Copy link
Contributor Author

@HannesWell : A friendly reminder for a second review - Thanks!

@HannesWell
Copy link
Member

A friendly reminder for a second review - Thanks!

I plan to have a look at it this evening.

Copy link
Member

@HannesWell HannesWell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the update and your patience (Sorry last week was busy).

Generally this looks already quite good, but the new preference page don't look nice at the moment and the method that performs the actual check can be simpler.
Please see my comments below.

Comment on lines 268 to 279
private static Key[] fgAllKeys = {KEY_F_UNRESOLVED_FEATURES, KEY_F_UNRESOLVED_PLUGINS, KEY_P_BUILD, KEY_P_BUILD_MISSING_OUTPUT, KEY_P_BUILD_SOURCE_LIBRARY, KEY_P_BUILD_OUTPUT_LIBRARY, KEY_P_BUILD_SRC_INCLUDES, KEY_P_BUILD_BIN_INCLUDES, KEY_P_BUILD_JAVA_COMPLIANCE, KEY_P_BUILD_JAVA_COMPILER, KEY_P_BUILD_ENCODINGS, KEY_P_INTERNAL, KEY_P_SERVICE_COMP_WITHOUT_LAZY, KEY_P_NO_AUTOMATIC_MODULE_NAME, KEY_P_DEPRECATED, KEY_P_DISCOURAGED_CLASS, KEY_P_INCOMPATIBLE_ENV, KEY_P_MISSING_EXPORT_PKGS, KEY_P_NO_REQUIRED_ATT, KEY_P_NOT_EXTERNALIZED, KEY_P_UNKNOWN_ATTRIBUTE, KEY_P_UNKNOWN_CLASS, KEY_P_UNKNOWN_ELEMENT, KEY_P_UNKNOWN_IDENTIFIER, KEY_P_UNKNOWN_RESOURCE, KEY_P_UNRESOLVED_EX_POINTS, KEY_P_UNRESOLVED_IMPORTS, KEY_P_VERSION_EXP_PKG, KEY_P_VERSION_IMP_PKG, KEY_P_VERSION_REQ_BUNDLE, KEY_P_VERSION_EXEC_ENV_TOO_LOW, KEY_S_CREATE_DOCS, KEY_S_DOC_FOLDER, KEY_S_OPEN_TAGS };
private static Key[] fgAllKeys = { KEY_F_UNRESOLVED_FEATURES, KEY_F_UNRESOLVED_PLUGINS, KEY_P_BUILD,
KEY_P_BUILD_MISSING_OUTPUT, KEY_P_BUILD_SOURCE_LIBRARY, KEY_P_BUILD_OUTPUT_LIBRARY,
KEY_P_BUILD_SRC_INCLUDES, KEY_P_BUILD_BIN_INCLUDES, KEY_P_BUILD_JAVA_COMPLIANCE,
KEY_P_BUILD_JAVA_COMPILER, KEY_P_BUILD_ENCODINGS, KEY_P_INTERNAL, KEY_P_SERVICE_COMP_WITHOUT_LAZY,
KEY_P_NO_AUTOMATIC_MODULE_NAME, KEY_P_DEPRECATED, KEY_P_DISCOURAGED_CLASS, KEY_P_INCOMPATIBLE_ENV,
KEY_P_MISSING_EXPORT_PKGS, KEY_P_NO_REQUIRED_ATT, KEY_P_NOT_EXTERNALIZED, KEY_P_UNKNOWN_ATTRIBUTE,
KEY_P_UNKNOWN_CLASS, KEY_P_UNKNOWN_ELEMENT, KEY_P_UNKNOWN_IDENTIFIER, KEY_P_UNKNOWN_RESOURCE,
KEY_P_IGNORED_RESOURCE_PROTOCOLS, KEY_P_UNRESOLVED_EX_POINTS, KEY_P_UNRESOLVED_IMPORTS,
KEY_P_VERSION_EXP_PKG, KEY_P_VERSION_IMP_PKG, KEY_P_VERSION_REQ_BUNDLE,
KEY_P_VERSION_EXEC_ENV_TOO_LOW, KEY_S_CREATE_DOCS, KEY_S_DOC_FOLDER, KEY_S_OPEN_TAGS };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't indent this field so deep.
I know this is result of just formatting the fields lines, but this is just because the previous field isn't properly formatted (and somehow this confuses the formattter).
This can be avoided if you format the field above too.
If you want to you can also include a 'formatting'-fix of the previous field in this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the hint how to solve this - done.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great 👍🏽
Since you've modified this and the field above already, you could make it final too.

Comment on lines 578 to 581
Composite comp = SWTFactory.createComposite(client, 2, 2, GridData.FILL_HORIZONTAL, 0, 0);
createTextControl(comp, PDEUIMessages.compilers_p_ignored_uri_protocols,
KEY_P_IGNORED_RESOURCE_PROTOCOLS, CompilerFlags.PLUGIN_FLAGS);
SWTFactory.createLabel(comp, PDEUIMessages.compilers_p_ignored_uri_protocols_details, 2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Windows-11 this doesn't look good:

The label shouldn't be in bold case and I think the details shouldn't be in a separate line. Instead I think you should provide the details as a tool-tip. It could be set after returning the created Text from the createTextControl() method.

I cannot tell immediately why the label is bold, but maybe it's related to how the previous elements are created (cascaded into each other).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I'll need to look deeper into that - tomorrow.

Copy link
Contributor Author

@Dani-Hub Dani-Hub Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand now where the bold font is coming from: It is caused by the usage of the SWTFactory methods which all have in common to set the font of the created widget based on the font of its parent. But the parent in this case is the one created from createExpansibleComposite, which sets a bold font. This explains why the existing methods in PDECompilersConfigurationBlock such as createComboControl do not use the SWTFactory methods for label and combo creation. My current approach to fix this is to create my intermediate Composite manually without SWTFactory being involved and intentionally do not set the parent font. Is this an acceptable approach (See my last commit) or what would you suggest as an alternative here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good investigation. Now this looks nice. :)

Comment on lines 607 to 634
final var ignoredProtocols = CompilerFlags.getString(fProject, CompilerFlags.P_IGNORED_RESOURCE_PROTOCOLS);
final var st = new StringTokenizer(ignoredProtocols, ","); //$NON-NLS-1$
if (!st.hasMoreTokens()) {
return false;
}
try {
final var uri = new URI(location);
if (uri.isAbsolute()) {
// Exclude syntactically valid file paths that are also
// syntactically valid URIs, such as "C:/somePath" where
// "C" would be interpreted as URI protocol:
try {
java.nio.file.Path.of(location);
} catch (java.nio.file.InvalidPathException e) {
// OK, location does not match a file path
final var scheme = uri.getScheme();
while (st.hasMoreElements()) {
String protocol = st.nextToken().trim();
if (scheme.equalsIgnoreCase(protocol)) {
return true;
}
}
}
}
} catch (URISyntaxException e) {
// location is not a valid URI
}
return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As RFC 2396 specifies that the scheme must be followed by a colon (for absolute URIs) I think this entire method can be simplified to just

Suggested change
final var ignoredProtocols = CompilerFlags.getString(fProject, CompilerFlags.P_IGNORED_RESOURCE_PROTOCOLS);
final var st = new StringTokenizer(ignoredProtocols, ","); //$NON-NLS-1$
if (!st.hasMoreTokens()) {
return false;
}
try {
final var uri = new URI(location);
if (uri.isAbsolute()) {
// Exclude syntactically valid file paths that are also
// syntactically valid URIs, such as "C:/somePath" where
// "C" would be interpreted as URI protocol:
try {
java.nio.file.Path.of(location);
} catch (java.nio.file.InvalidPathException e) {
// OK, location does not match a file path
final var scheme = uri.getScheme();
while (st.hasMoreElements()) {
String protocol = st.nextToken().trim();
if (scheme.equalsIgnoreCase(protocol)) {
return true;
}
}
}
}
} catch (URISyntaxException e) {
// location is not a valid URI
}
return false;
String ignoredProtocols = CompilerFlags.getString(fProject, CompilerFlags.P_IGNORED_RESOURCE_PROTOCOLS);
if (ignoredProtocols.isEmpty()) {
return false;
}
return Arrays.stream(ignoredProtocols.split(",")).map(p -> p + ":").anyMatch(location::startsWith); //$NON-NLS-1$ //$NON-NLS-2$

I.e. it just checks if the location starts with any protocol plus a colon.

Copy link
Contributor Author

@Dani-Hub Dani-Hub Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two issues with this alternative solution: (1) It doesn't trim any leading or trailing spaces (and this seems to be done everywhere else) and (2) it doesn't do a case-insensitive match (protocol comparison is defined to be case-insensitive). So I'm working on a modified approach now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's both correct.
But your modifications to refine this approach look good. :)

@Dani-Hub Dani-Hub force-pushed the #2031-PDE_should_not_warn_if_resource_URI_of_unknown_scheme_cannot_be_found branch 5 times, most recently from 15f65d5 to e67db37 Compare November 4, 2025 19:13
@Dani-Hub
Copy link
Contributor Author

Dani-Hub commented Nov 6, 2025

@HannesWell Could you please proceed with the review?

Copy link
Member

@HannesWell HannesWell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the update.
The UI looks better now, but it still has to be improved further. Please see my remarks below.

Do you also have a simple example at hand to try out the possibly ignored URI protocols, i.e. a corresponding plugin.xml snippet?

Composite comp = createComposite(client, 2, 2, GridData.FILL_HORIZONTAL, 0, 0);
createTextControl(comp, PDEUIMessages.compilers_p_ignored_uri_protocols,
KEY_P_IGNORED_RESOURCE_PROTOCOLS, CompilerFlags.PLUGIN_FLAGS);
SWTFactory.createLabel(comp, PDEUIMessages.compilers_p_ignored_uri_protocols_details, 2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This label should be a tool-tip of the text field instead.
Not having an extra description field makes the UI cleaner.

And it maybe makes the code even simpler as you can maybe even skip the extra container/Composite. But I'm not sure about the latter and it would have to be investigated/tried out.

You can get the text-field by returning it from the createTextControl() method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This label should be a tool-tip of the text field instead. Not having an extra description field makes the UI cleaner.

All existing comparable text fields in the Eclipse wizards providing comma-separated lists use an extra label to explain the usage. See for example:

grafik grafik

In the File Search dialog we have a comparable pattern:
grafik

In the rarer case were no such a label is provided the Eclipse UI does not show a tool tip. I would like to point these out before we change the design. So, given this additional information, do we still want to user your alternative approach?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This label should be a tool-tip of the text field instead. Not having an extra description field makes the UI cleaner.

All existing comparable text fields in the Eclipse wizards providing comma-separated lists use an extra label to explain the usage. See for example:

grafik grafik

In the File Search dialog we have a comparable pattern:
grafik

In the rarer case were no such a label is provided the Eclipse UI does not show a tool tip. I would like to point these out before we change the design. So, given this additional information, do we still want to user your alternative approach?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the rarer case were no such a label is provided the Eclipse UI does not show a tool tip. I would like to point these out before we change the design. So, given this additional information, do we still want to user your alternative approach?

Thanks for the analysis and comparison.
I would argue that wizards are also a bit different preferences and I have to admit it looked a bit strange to me at this point respectively it stand out from the rest, which I think shouldn't be the case. If you really prefer to have the description as a label, maybe it's better to have it above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm personally completely open to any direction. I just pointed out the seemingly existing practice so that we have a complete picture to argue about and I will apply any preferred UI approach that you reviewers would like to see.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have now moved the explanatory label before the text field in my last ammendment. Does this look better to you? (It doesn't to me but again, please decide yourself)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just pointed out the seemingly existing practice so that we have a complete picture to argue about and I will apply any preferred UI approach that you reviewers would like to see.

I have looked through the other pages in the PDE section and not found a fully comparable case and I still have the impression that a separate label text 'breaks the pattern' on this page compared to the other entries (which admittedly are all similar but different to this one):

With my proposal to use a tool tip, I still think this fits best into the existing page, even though this is handled differently in some other wizards:

@Dani-Hub
Copy link
Contributor Author

Dani-Hub commented Nov 7, 2025

@HannesWell Could you please proceed with the review?

Thank you for the update. The UI looks better now, but it still has to be improved further. Please see my remarks below.

Do you also have a simple example at hand to try out the possibly ignored URI protocols, i.e. a corresponding plugin.xml snippet?

Yes, in the original example is a complete example project, here is a link to it.

@Dani-Hub Dani-Hub force-pushed the #2031-PDE_should_not_warn_if_resource_URI_of_unknown_scheme_cannot_be_found branch 2 times, most recently from e0a569c to d86589b Compare November 10, 2025 03:17
@HannesWell HannesWell force-pushed the #2031-PDE_should_not_warn_if_resource_URI_of_unknown_scheme_cannot_be_found branch from d86589b to 13c3829 Compare November 10, 2025 22:37
@HannesWell HannesWell force-pushed the #2031-PDE_should_not_warn_if_resource_URI_of_unknown_scheme_cannot_be_found branch from 13c3829 to e7f3431 Compare November 10, 2025 22:38
Copy link
Member

@HannesWell HannesWell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dani-Hub I have now pushed an update to your branch that uses the a tool-tip to add the explanation to the preference, as per other thread in this PR.

Furthermore I added a default value initialization which was missing and broke the restore of defaults for the PDE preference page that hosts the new option.

Also thank you for providing your example, that showed that this works as intended.

With all that the current state is ready for submission from my POV.
Unless you'd like to have things differently I'll submit this tomorrow evening.

If you want to push further updates to this PR, please make sure to fetch the latest state from your fork first.

@Dani-Hub
Copy link
Contributor Author

@Dani-Hub I have now pushed an update to your branch that uses the a tool-tip to add the explanation to the preference, as per other thread in this PR.

Looks good to me!

Furthermore I added a default value initialization which was missing and broke the restore of defaults for the PDE preference page that hosts the new option.

Thanks for that fix!

Also thank you for providing your example, that showed that this works as intended.

With all that the current state is ready for submission from my POV. Unless you'd like to have things differently I'll submit this tomorrow evening.

If you want to push further updates to this PR, please make sure to fetch the latest state from your fork first.

No, I have nothing to change, thanks for your help!

@HannesWell
Copy link
Member

Great, submitting it then.
Thank you for this contribution.

@HannesWell HannesWell merged commit 08a144c into eclipse-pde:master Nov 11, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PDE should not warn if resource URI of unknown scheme cannot be found

4 participants