Skip to content

Commit e3d5fea

Browse files
committed
PDE should not warn if resource URI of unknown scheme cannot be found
Fixes #2031 Signed-off-by: Daniel Krügler <[email protected]>
1 parent 7caca2d commit e3d5fea

File tree

5 files changed

+56
-1
lines changed

5 files changed

+56
-1
lines changed

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/CompilerFlags.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* Contributors:
1212
* IBM Corporation - initial API and implementation
1313
* Code 9 Corporation - on going enhancements and maintenance
14+
* Daniel Kruegler - #2031 - PDE should not warn if resource URI of unknown scheme cannot be found
1415
*******************************************************************************/
1516
package org.eclipse.pde.internal.core.builders;
1617

@@ -55,6 +56,7 @@ public class CompilerFlags {
5556
public static final String P_UNKNOWN_ATTRIBUTE = "compilers.p.unknown-attribute"; //$NON-NLS-1$
5657
public static final String P_UNKNOWN_CLASS = "compilers.p.unknown-class"; //$NON-NLS-1$
5758
public static final String P_UNKNOWN_RESOURCE = "compilers.p.unknown-resource"; //$NON-NLS-1$
59+
public static final String P_IGNORED_RESOURCE_PROTOCOLS = "compilers.p.ignored-resource-protocols"; //$NON-NLS-1$
5860
public static final String P_UNKNOWN_IDENTIFIER = "compilers.p.unknown-identifier"; //$NON-NLS-1$
5961
public static final String P_DISCOURAGED_CLASS = "compilers.p.discouraged-class"; //$NON-NLS-1$
6062
public static final String P_NO_REQUIRED_ATT = "compilers.p.no-required-att"; //$NON-NLS-1$

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ExtensionsErrorReporter.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@
1111
* Contributors:
1212
* IBM Corporation - initial API and implementation
1313
* Martin Karpisek <[email protected]> - Bug 526283
14+
* Daniel Kruegler - #2031 - PDE should not warn if resource URI of unknown scheme cannot be found
1415
*******************************************************************************/
1516
package org.eclipse.pde.internal.core.builders;
1617

1718
import java.io.File;
19+
import java.net.URI;
20+
import java.net.URISyntaxException;
1821
import java.util.ArrayList;
1922
import java.util.HashSet;
2023
import java.util.Iterator;
@@ -597,6 +600,37 @@ private boolean resourceExists(String location) {
597600
}
598601
}
599602

603+
return isIgnoredResourceUri(location);
604+
}
605+
606+
private boolean isIgnoredResourceUri(String location) {
607+
final var ignoredProtocols = CompilerFlags.getString(fProject, CompilerFlags.P_IGNORED_RESOURCE_PROTOCOLS);
608+
final var st = new StringTokenizer(ignoredProtocols, ","); //$NON-NLS-1$
609+
if (!st.hasMoreTokens()) {
610+
return false;
611+
}
612+
try {
613+
final var uri = new URI(location);
614+
if (uri.isAbsolute()) {
615+
// Exclude syntactically valid file paths that are also
616+
// syntactically valid URIs, such as "C:/somePath" where
617+
// "C" would be interpreted as URI protocol:
618+
try {
619+
java.nio.file.Path.of(location);
620+
} catch (java.nio.file.InvalidPathException e) {
621+
// OK, location does not match a file path
622+
final var scheme = uri.getScheme();
623+
while (st.hasMoreElements()) {
624+
String protocol = st.nextToken().trim();
625+
if (scheme.equalsIgnoreCase(protocol)) {
626+
return true;
627+
}
628+
}
629+
}
630+
}
631+
} catch (URISyntaxException e) {
632+
// location is not a valid URI
633+
}
600634
return false;
601635
}
602636

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,6 +1890,8 @@ public class PDEUIMessages extends NLS {
18901890
public static String compilers_s_doc_folder;
18911891
public static String compilers_s_open_tags;
18921892
public static String compilers_p_exec_env_too_low;
1893+
public static String compilers_p_ignored_uri_protocols;
1894+
public static String compilers_p_ignored_uri_protocols_details;
18931895

18941896
public static String compilers_p_exported_pkgs;
18951897

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,6 +1634,8 @@ compilers_p_exported_pkgs = Unexported pac&kage:
16341634
compilers_p_missing_exp_pkg = Missing versions on exported packages:
16351635
compilers_p_missing_imp_pkg = Missing versions on imported packages:
16361636
compilers_p_missing_require_bundle = Missing versions on required bundles:
1637+
compilers_p_ignored_uri_protocols = Filtered resource protocols:
1638+
compilers_p_ignored_uri_protocols_details = Filtered protocols of unknown resource URIs are ignored. List is comma separated.
16371639

16381640
compilers_s_create_docs = &Generate reference documentation from schemas
16391641
compilers_s_doc_folder = Do&cumentation folder:

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/PDECompilersConfigurationBlock.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* IBM Corporation - initial API and implementation
1313
* Code 9 Corporation - on going enhancements and maintenance
1414
* Johannes Ahlers <[email protected]> - bug 477677
15+
* Daniel Kruegler - #2031 - PDE should not warn if resource URI of unknown scheme cannot be found
1516
*******************************************************************************/
1617
package org.eclipse.pde.internal.ui.preferences;
1718

@@ -227,6 +228,7 @@ protected final static Key getPDEPrefKey(String key) {
227228
private static final Key KEY_P_UNKNOWN_CLASS = getPDEPrefKey(CompilerFlags.P_UNKNOWN_CLASS);
228229
private static final Key KEY_P_UNKNOWN_RESOURCE = getPDEPrefKey(CompilerFlags.P_UNKNOWN_RESOURCE);
229230
private static final Key KEY_P_UNKNOWN_IDENTIFIER = getPDEPrefKey(CompilerFlags.P_UNKNOWN_IDENTIFIER);
231+
private static final Key KEY_P_IGNORED_RESOURCE_PROTOCOLS = getPDEPrefKey(CompilerFlags.P_IGNORED_RESOURCE_PROTOCOLS);
230232

231233
//general
232234
private static final Key KEY_P_DISCOURAGED_CLASS = getPDEPrefKey(CompilerFlags.P_DISCOURAGED_CLASS);
@@ -265,7 +267,16 @@ protected final static Key getPDEPrefKey(String key) {
265267
PDEUIMessages.PDECompilersConfigurationBlock_ignore
266268
};
267269

268-
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 };
270+
private static Key[] fgAllKeys = { KEY_F_UNRESOLVED_FEATURES, KEY_F_UNRESOLVED_PLUGINS, KEY_P_BUILD,
271+
KEY_P_BUILD_MISSING_OUTPUT, KEY_P_BUILD_SOURCE_LIBRARY, KEY_P_BUILD_OUTPUT_LIBRARY,
272+
KEY_P_BUILD_SRC_INCLUDES, KEY_P_BUILD_BIN_INCLUDES, KEY_P_BUILD_JAVA_COMPLIANCE,
273+
KEY_P_BUILD_JAVA_COMPILER, KEY_P_BUILD_ENCODINGS, KEY_P_INTERNAL, KEY_P_SERVICE_COMP_WITHOUT_LAZY,
274+
KEY_P_NO_AUTOMATIC_MODULE_NAME, KEY_P_DEPRECATED, KEY_P_DISCOURAGED_CLASS, KEY_P_INCOMPATIBLE_ENV,
275+
KEY_P_MISSING_EXPORT_PKGS, KEY_P_NO_REQUIRED_ATT, KEY_P_NOT_EXTERNALIZED, KEY_P_UNKNOWN_ATTRIBUTE,
276+
KEY_P_UNKNOWN_CLASS, KEY_P_UNKNOWN_ELEMENT, KEY_P_UNKNOWN_IDENTIFIER, KEY_P_UNKNOWN_RESOURCE,
277+
KEY_P_IGNORED_RESOURCE_PROTOCOLS, KEY_P_UNRESOLVED_EX_POINTS, KEY_P_UNRESOLVED_IMPORTS,
278+
KEY_P_VERSION_EXP_PKG, KEY_P_VERSION_IMP_PKG, KEY_P_VERSION_REQ_BUNDLE,
279+
KEY_P_VERSION_EXEC_ENV_TOO_LOW, KEY_S_CREATE_DOCS, KEY_S_DOC_FOLDER, KEY_S_OPEN_TAGS };
269280

270281
/**
271282
* Constant representing the {@link IDialogSettings} section for this block
@@ -564,6 +575,10 @@ private Composite createPage(int kind, Composite folder, String name, String des
564575
// References
565576
client = createExpansibleComposite(sbody, PDEUIMessages.PDECompilersConfigurationBlock_references);
566577
initializeComboControls(client, new String[] {PDEUIMessages.compilers_p_unknown_element, PDEUIMessages.compilers_p_unknown_attribute, PDEUIMessages.compilers_p_unknown_class, PDEUIMessages.compilers_p_discouraged_class, PDEUIMessages.compilers_p_unknown_resource, PDEUIMessages.compilers_p_unknown_identifier}, new Key[] {KEY_P_UNKNOWN_ELEMENT, KEY_P_UNKNOWN_ATTRIBUTE, KEY_P_UNKNOWN_CLASS, KEY_P_DISCOURAGED_CLASS, KEY_P_UNKNOWN_RESOURCE, KEY_P_UNKNOWN_IDENTIFIER,}, CompilerFlags.PLUGIN_FLAGS);
578+
Composite comp = SWTFactory.createComposite(client, 2, 2, GridData.FILL_HORIZONTAL, 0, 0);
579+
createTextControl(comp, PDEUIMessages.compilers_p_ignored_uri_protocols,
580+
KEY_P_IGNORED_RESOURCE_PROTOCOLS, CompilerFlags.PLUGIN_FLAGS);
581+
SWTFactory.createLabel(comp, PDEUIMessages.compilers_p_ignored_uri_protocols_details, 2);
567582

568583
break;
569584
}

0 commit comments

Comments
 (0)