Skip to content

Commit e0a569c

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 e0a569c

File tree

5 files changed

+47
-6
lines changed

5 files changed

+47
-6
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: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +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;
1819
import java.util.ArrayList;
20+
import java.util.Arrays;
1921
import java.util.HashSet;
2022
import java.util.Iterator;
2123
import java.util.Map;
@@ -597,7 +599,13 @@ private boolean resourceExists(String location) {
597599
}
598600
}
599601

600-
return false;
602+
return isIgnoredResourceUri(location);
603+
}
604+
605+
private boolean isIgnoredResourceUri(String location) {
606+
final var ignoredProtocols = CompilerFlags.getString(fProject, CompilerFlags.P_IGNORED_RESOURCE_PROTOCOLS);
607+
return Arrays.stream(ignoredProtocols.split(",")).map(p -> p.trim() + ":"). //$NON-NLS-1$ //$NON-NLS-2$
608+
anyMatch(s -> location.regionMatches(true, 0, s, 0, s.length()));
601609
}
602610

603611
protected void validateJavaAttribute(Element element, Attr attr) {

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: 32 additions & 5 deletions
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

@@ -45,6 +46,8 @@
4546
import org.eclipse.core.runtime.preferences.InstanceScope;
4647
import org.eclipse.jface.dialogs.IDialogSettings;
4748
import org.eclipse.jface.dialogs.MessageDialog;
49+
import org.eclipse.jface.layout.GridDataFactory;
50+
import org.eclipse.jface.layout.GridLayoutFactory;
4851
import org.eclipse.jface.resource.JFaceResources;
4952
import org.eclipse.jface.util.Util;
5053
import org.eclipse.jface.window.Window;
@@ -227,6 +230,7 @@ protected final static Key getPDEPrefKey(String key) {
227230
private static final Key KEY_P_UNKNOWN_CLASS = getPDEPrefKey(CompilerFlags.P_UNKNOWN_CLASS);
228231
private static final Key KEY_P_UNKNOWN_RESOURCE = getPDEPrefKey(CompilerFlags.P_UNKNOWN_RESOURCE);
229232
private static final Key KEY_P_UNKNOWN_IDENTIFIER = getPDEPrefKey(CompilerFlags.P_UNKNOWN_IDENTIFIER);
233+
private static final Key KEY_P_IGNORED_RESOURCE_PROTOCOLS = getPDEPrefKey(CompilerFlags.P_IGNORED_RESOURCE_PROTOCOLS);
230234

231235
//general
232236
private static final Key KEY_P_DISCOURAGED_CLASS = getPDEPrefKey(CompilerFlags.P_DISCOURAGED_CLASS);
@@ -260,12 +264,20 @@ protected final static Key getPDEPrefKey(String key) {
260264
private static final Key KEY_S_DOC_FOLDER = getPDEPrefKey(CompilerFlags.S_DOC_FOLDER);
261265
private static final Key KEY_S_OPEN_TAGS = getPDEPrefKey(CompilerFlags.S_OPEN_TAGS);
262266

263-
private static String[] SEVERITIES = {PDEUIMessages.PDECompilersConfigurationBlock_error,
267+
private static final String[] SEVERITIES = { PDEUIMessages.PDECompilersConfigurationBlock_error,
264268
PDEUIMessages.PDECompilersConfigurationBlock_warning, PDEUIMessages.PDECompilersConfigurationBlock_info,
265-
PDEUIMessages.PDECompilersConfigurationBlock_ignore
266-
};
267-
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 };
269+
PDEUIMessages.PDECompilersConfigurationBlock_ignore };
270+
271+
private static final Key[] fgAllKeys = { KEY_F_UNRESOLVED_FEATURES, KEY_F_UNRESOLVED_PLUGINS, KEY_P_BUILD,
272+
KEY_P_BUILD_MISSING_OUTPUT, KEY_P_BUILD_SOURCE_LIBRARY, KEY_P_BUILD_OUTPUT_LIBRARY,
273+
KEY_P_BUILD_SRC_INCLUDES, KEY_P_BUILD_BIN_INCLUDES, KEY_P_BUILD_JAVA_COMPLIANCE, KEY_P_BUILD_JAVA_COMPILER,
274+
KEY_P_BUILD_ENCODINGS, KEY_P_INTERNAL, KEY_P_SERVICE_COMP_WITHOUT_LAZY, KEY_P_NO_AUTOMATIC_MODULE_NAME,
275+
KEY_P_DEPRECATED, KEY_P_DISCOURAGED_CLASS, KEY_P_INCOMPATIBLE_ENV, KEY_P_MISSING_EXPORT_PKGS,
276+
KEY_P_NO_REQUIRED_ATT, KEY_P_NOT_EXTERNALIZED, KEY_P_UNKNOWN_ATTRIBUTE, KEY_P_UNKNOWN_CLASS,
277+
KEY_P_UNKNOWN_ELEMENT, KEY_P_UNKNOWN_IDENTIFIER, KEY_P_UNKNOWN_RESOURCE, KEY_P_IGNORED_RESOURCE_PROTOCOLS,
278+
KEY_P_UNRESOLVED_EX_POINTS, KEY_P_UNRESOLVED_IMPORTS, KEY_P_VERSION_EXP_PKG, KEY_P_VERSION_IMP_PKG,
279+
KEY_P_VERSION_REQ_BUNDLE, KEY_P_VERSION_EXEC_ENV_TOO_LOW, KEY_S_CREATE_DOCS, KEY_S_DOC_FOLDER,
280+
KEY_S_OPEN_TAGS };
269281

270282
/**
271283
* Constant representing the {@link IDialogSettings} section for this block
@@ -564,6 +576,10 @@ private Composite createPage(int kind, Composite folder, String name, String des
564576
// References
565577
client = createExpansibleComposite(sbody, PDEUIMessages.PDECompilersConfigurationBlock_references);
566578
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);
579+
Composite comp = createComposite(client, 2, 2, GridData.FILL_HORIZONTAL, 0, 0);
580+
createTextControl(comp, PDEUIMessages.compilers_p_ignored_uri_protocols,
581+
KEY_P_IGNORED_RESOURCE_PROTOCOLS, CompilerFlags.PLUGIN_FLAGS);
582+
SWTFactory.createLabel(comp, PDEUIMessages.compilers_p_ignored_uri_protocols_details, 2);
567583

568584
break;
569585
}
@@ -592,6 +608,17 @@ private void initializeComboControls(Composite composite, String[] labels, Key[]
592608
}
593609
}
594610

611+
/**
612+
* Creates a composite without inheriting the font from its parent.
613+
*/
614+
private static Composite createComposite(Composite parent, int columns, int hspan, int fill, int marginwidth,
615+
int marginheight) {
616+
Composite composite = new Composite(parent, SWT.NONE);
617+
GridLayoutFactory.swtDefaults().numColumns(columns).margins(marginwidth, marginheight).applyTo(composite);
618+
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(hspan, 1).applyTo(composite);
619+
return composite;
620+
}
621+
595622
/**
596623
* Creates a checkbox button control in the parent
597624
*/

0 commit comments

Comments
 (0)