Skip to content

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

  623 files   -   148    623 suites   - 148   48m 44s ⏱️ - 2m 55s
3 637 tests ±    0  3 582 ✅  -     1   54 💤 ± 0  1 ❌ +1 
8 191 runs   - 2 654  8 051 ✅  - 2 631  139 💤  - 24  1 ❌ +1 

For more details on these failures, see this check.

Results for commit e0a569c. ± 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 580
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?

Comment on lines 612 to 620
private static Composite createComposite(Composite parent, int columns, int hspan, int fill, int marginwidth,
int marginheight) {
Composite g = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(columns, false);
layout.marginWidth = marginwidth;
layout.marginHeight = marginheight;
g.setLayout(layout);
GridData gd = new GridData(fill);
gd.horizontalSpan = hspan;
g.setLayoutData(gd);
return g;
}
Copy link
Member

Choose a reason for hiding this comment

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

I think this could be more compact using something similar to:

Suggested change
private static Composite createComposite(Composite parent, int columns, int hspan, int fill, int marginwidth,
int marginheight) {
Composite g = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(columns, false);
layout.marginWidth = marginwidth;
layout.marginHeight = marginheight;
g.setLayout(layout);
GridData gd = new GridData(fill);
gd.horizontalSpan = hspan;
g.setLayoutData(gd);
return g;
}
private static Composite createComposite(Composite parent, int columns, int hspan, int fill, int marginwidth,
int marginheight) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayoutFactory.swtDefaults().numColumns(columns).margins(marginwidth, marginheight).applyTo(composite);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(hspan, 1).applyTo(composite);
return composite;
}

given this is still necessary.

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 think this could be more compact using something similar to:

Done

@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 from e67db37 to e0a569c Compare November 8, 2025 12:54
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