private void validateUnpack(Element parent) { int severity = CompilerFlags.getFlag(fProject, CompilerFlags.F_UNRESOLVED_PLUGINS); if (severity == CompilerFlags.IGNORE) { return; } if (severity == CompilerFlags.ERROR) { // this might not be an error, so max the flag at WARNING level. severity = CompilerFlags.WARNING; } String unpack = parent.getAttribute("unpack"); // $NON-NLS-1$ IMonitorModelBase pModel = MonitorRegistry.findModel(parent.getAttribute("id")); // $NON-NLS-1$ if (pModel == null) { return; } if (pModel instanceof IBundlePluginModel) { IBundlePluginModel bModel = (IBundlePluginModel) pModel; IManifestHeader header = bModel .getBundleModel() .getBundle() .getManifestHeader(ICoreConstants.ECLIPSE_BUNDLE_SHAPE); if (header != null) { String value = header.getValue(); String unpackValue = "true".equals(unpack) ? "jar" : "dir"; // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if (value != null && !value.equalsIgnoreCase(unpackValue)) { String message = NLS.bind( MDECoreMessages.Builders_Feature_mismatchUnpackBundleShape, (new String[] { "unpack=" + unpack, parent.getAttribute("id"), "Eclipse-BundleShape: " + value })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ report(message, getLine(parent), severity, MDEMarkerFactory.CAT_OTHER); } } } if ("true".equals(unpack) && !CoreUtility.guessUnpack(pModel.getBundleDescription())) { // $NON-NLS-1$ String message = NLS.bind( MDECoreMessages.Builders_Feature_missingUnpackFalse, (new String[] { parent.getAttribute("id"), "unpack=\"false\"" })); //$NON-NLS-1$ //$NON-NLS-2$ report(message, getLine(parent), severity, MDEMarkerFactory.CAT_OTHER); } }
protected void validateJavaAttribute(Element element, Attr attr) { String value = attr.getValue(); IJavaProject javaProject = JavaCore.create(fFile.getProject()); // be careful: people have the option to use the format: // fullqualifiedName:staticMethod int index = value.indexOf(":"); // $NON-NLS-1$ if (index != -1) value = value.substring(0, index); // assume we're on the classpath already boolean onClasspath = true; int severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNKNOWN_CLASS); if (severity != CompilerFlags.IGNORE && javaProject.isOpen()) { onClasspath = PDEJavaHelper.isOnClasspath(value, javaProject); if (!onClasspath) { report( NLS.bind( MDECoreMessages.Builders_Manifest_class, (new String[] {value, attr.getName()})), getLine(element, attr.getName()), severity, MDEMarkerFactory.P_UNKNOWN_CLASS, element, attr.getName() + F_ATT_VALUE_PREFIX + attr.getValue(), MDEMarkerFactory.CAT_FATAL); } } severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_DISCOURAGED_CLASS); if (severity != CompilerFlags.IGNORE && javaProject.isOpen()) { BundleDescription desc = fModel.getBundleDescription(); if (desc == null) return; // only check if we're discouraged if there is something on the classpath if (onClasspath && PDEJavaHelper.isDiscouraged(value, javaProject, desc)) { report( NLS.bind( MDECoreMessages.Builders_Manifest_discouragedClass, (new String[] {value, attr.getName()})), getLine(element, attr.getName()), severity, MDEMarkerFactory.M_DISCOURAGED_CLASS, element, attr.getName() + F_ATT_VALUE_PREFIX + attr.getValue(), MDEMarkerFactory.CAT_OTHER); } } }