private void validateImportPackage(IProgressMonitor monitor) {
        IHeader header = getHeader(Constants.IMPORT_PACKAGE);
        if (header == null)
            return;
        BundleDescription desc = fModel.getBundleDescription();
        if (desc == null) {
            ManifestElement[] elements = header.getElements();
            for (int i = 0; i < elements.length; i++) {
                validateSpecificationVersionAttribute(header, elements[i]);
                validateImportPackageVersion(header, elements[i]);
            }
            return;
        }
        boolean hasUnresolved = false;
        VersionConstraint[] constraints = desc.getContainingState().getStateHelper().getUnsatisfiedConstraints(desc);
        for (int i = 0; i < constraints.length; i++) {
            if (constraints[i] instanceof ImportPackageSpecification) {
                hasUnresolved = true;
                break;
            }
        }
        HashMap<String, ExportPackageDescription> exported = getAvailableExportedPackages(desc.getContainingState());
        ImportPackageSpecification[] imports = desc.getImportPackages();
        if (desc.hasDynamicImports()) {
            List<ImportPackageSpecification> staticImportsList = new ArrayList();
            for (int i = 0; i < imports.length; ++i) {
                if (!imports[i].getDirective(Constants.RESOLUTION_DIRECTIVE).equals(ImportPackageSpecification.RESOLUTION_DYNAMIC))
                    staticImportsList.add(imports[i]);
            }
            imports = staticImportsList.toArray(new ImportPackageSpecification[staticImportsList.size()]);
        }
        ManifestElement[] elements = header.getElements();
        int index = 0;
        for (int i = 0; i < elements.length; i++) {
            checkCanceled(monitor);
            validateSpecificationVersionAttribute(header, elements[i]);
            validateResolutionDirective(header, elements[i]);
            // TODO we should only validate versions that we have a match
            validateImportPackageVersion(header, elements[i]);
            if (!hasUnresolved)
                continue;
            int length = elements[i].getValueComponents().length;
            for (int j = 0; j < length; j++) {
                ImportPackageSpecification importSpec = imports[index++];
                String name = importSpec.getName();
                if (//$NON-NLS-1$ //$NON-NLS-2$
                name.equals("java") || name.startsWith("java.")) {
                    IHeader jreHeader = getHeader(ICoreConstants.ECLIPSE_JREBUNDLE);
                    if (jreHeader == null || !"true".equals(//$NON-NLS-1$
                    jreHeader.getValue())) {
                        report(PDECoreMessages.BundleErrorReporter_importNoJRE, getPackageLine(header, elements[i]), CompilerFlags.ERROR, PDEMarkerFactory.M_JAVA_PACKAGE__PORTED, PDEMarkerFactory.CAT_FATAL);
                        continue;
                    }
                }
                if (importSpec.isResolved() || !isCheckUnresolvedImports())
                    continue;
                boolean optional = isOptional(elements[i]);
                int severity = getRequireBundleSeverity(elements[i], optional);
                ExportPackageDescription export = exported.get(name);
                if (export != null) {
                    if (export.getSupplier().isResolved()) {
                        Version version = export.getVersion();
                        org.eclipse.osgi.service.resolver.VersionRange range = importSpec.getVersionRange();
                        if (range != null && !range.isIncluded(version)) {
                            report(NLS.bind(PDECoreMessages.BundleErrorReporter_unsatisfiedConstraint, importSpec.toString()), getPackageLine(header, elements[i]), severity, PDEMarkerFactory.CAT_FATAL);
                        }
                    } else {
                        report(NLS.bind(PDECoreMessages.BundleErrorReporter_unresolvedExporter, new String[] { export.getSupplier().getSymbolicName(), name }), getPackageLine(header, elements[i]), severity, PDEMarkerFactory.CAT_OTHER);
                    }
                } else {
                    IMarker marker = report(NLS.bind(PDECoreMessages.BundleErrorReporter_PackageNotExported, name), getPackageLine(header, elements[i]), severity, PDEMarkerFactory.M_IMPORT_PKG_NOT_AVAILABLE, PDEMarkerFactory.CAT_FATAL);
                    try {
                        if (marker != null) {
                            //$NON-NLS-1$
                            marker.setAttribute(//$NON-NLS-1$
                            "packageName", //$NON-NLS-1$
                            name);
                            if (optional)
                                //$NON-NLS-1$
                                marker.setAttribute(//$NON-NLS-1$
                                "optional", //$NON-NLS-1$
                                true);
                        }
                    } catch (CoreException e) {
                    }
                }
            }
        }
    }
private void validateImportPackage(IProgressMonitor monitor) {
        IHeader header = getHeader(Constants.IMPORT_PACKAGE);
        if (header == null)
            return;
        BundleDescription desc = fModel.getBundleDescription();
        if (desc == null) {
            ManifestElement[] elements = header.getElements();
            for (int i = 0; i < elements.length; i++) {
                validateSpecificationVersionAttribute(header, elements[i]);
                validateImportPackageVersion(header, elements[i]);
            }
            return;
        }
        boolean hasUnresolved = false;
        VersionConstraint[] constraints = desc.getContainingState().getStateHelper().getUnsatisfiedConstraints(desc);
        for (int i = 0; i < constraints.length; i++) {
            if (constraints[i] instanceof ImportPackageSpecification) {
                hasUnresolved = true;
                break;
            }
        }
        HashMap<String, ExportPackageDescription> exported = getAvailableExportedPackages(desc.getContainingState());
        ImportPackageSpecification[] imports = desc.getImportPackages();
        if (desc.hasDynamicImports()) {
            List<ImportPackageSpecification> staticImportsList = new ArrayList();
            for (int i = 0; i < imports.length; ++i) {
                if (!imports[i].getDirective(Constants.RESOLUTION_DIRECTIVE).equals(ImportPackageSpecification.RESOLUTION_DYNAMIC))
                    staticImportsList.add(imports[i]);
            }
            imports = staticImportsList.toArray(new ImportPackageSpecification[staticImportsList.size()]);
        }
        ManifestElement[] elements = header.getElements();
        int index = 0;
        for (int i = 0; i < elements.length; i++) {
            checkCanceled(monitor);
            validateSpecificationVersionAttribute(header, elements[i]);
            validateResolutionDirective(header, elements[i]);
           
            validateImportPackageVersion(header, elements[i]);
            if (!hasUnresolved)
                continue;
            int length = elements[i].getValueComponents().length;
            for (int j = 0; j < length; j++) {
                ImportPackageSpecification importSpec = imports[index++];
                String name = importSpec.getName();
                if 
                name.equals("java") || name.startsWith("java.")) {
                    IHeader jreHeader = getHeader(ICoreConstants.ECLIPSE_JREBUNDLE);
                    if (jreHeader == null || !"true".equals
                    jreHeader.getValue())) {
                        report(PDECoreMessages.BundleErrorReporter_importNoJRE, getPackageLine(header, elements[i]), CompilerFlags.ERROR, PDEMarkerFactory.M_JAVA_PACKAGE__PORTED, PDEMarkerFactory.CAT_FATAL);
                        continue;
                    }
                }
                if (importSpec.isResolved() || !isCheckUnresolvedImports())
                    continue;
                boolean optional = isOptional(elements[i]);
                int severity = getRequireBundleSeverity(elements[i], optional);
                ExportPackageDescription export = exported.get(name);
                if (export != null) {
                    if (export.getSupplier().isResolved()) {
                        Version version = export.getVersion();
                        org.eclipse.osgi.service.resolver.VersionRange range = importSpec.getVersionRange();
                        if (range != null && !range.isIncluded(version)) {
                            report(NLS.bind(PDECoreMessages.BundleErrorReporter_unsatisfiedConstraint, importSpec.toString()), getPackageLine(header, elements[i]), severity, PDEMarkerFactory.CAT_FATAL);
                        }
                    } else {
                        report(NLS.bind(PDECoreMessages.BundleErrorReporter_unresolvedExporter, new String[] { export.getSupplier().getSymbolicName(), name }), getPackageLine(header, elements[i]), severity, PDEMarkerFactory.CAT_OTHER);
                    }
                } else {
                    IMarker marker = report(NLS.bind(PDECoreMessages.BundleErrorReporter_PackageNotExported, name), getPackageLine(header, elements[i]), severity, PDEMarkerFactory.M_IMPORT_PKG_NOT_AVAILABLE, PDEMarkerFactory.CAT_FATAL);
                    try {
                        if (marker != null) {
                           
                            marker.setAttribute
                            "packageName",
                            name);
                            if (optional)
                               
                                marker.setAttribute
                                "optional",
                                true);
                        }
                    } catch (CoreException e) {
                    }
                }
            }
        }
    }
private void validateimportpackage(iprogressmonitor monitor) { iheader header = getheader(constants.import_package); if (header == null) return; bundledescription desc = fmodel.getbundledescription(); if (desc == null) { manifestelement[] elements = header.getelements(); for (int i = 0; i < elements.length; i++) { validatespecificationversionattribute(header, elements[i]); validateimportpackageversion(header, elements[i]); } return; } boolean hasunresolved = false; versionconstraint[] constraints = desc.getcontainingstate().getstatehelper().getunsatisfiedconstraints(desc); for (int i = 0; i < constraints.length; i++) { if (constraints[i] instanceof importpackagespecification) { hasunresolved = true; break; } } hashmap<string, exportpackagedescription> exported = getavailableexportedpackages(desc.getcontainingstate()); importpackagespecification[] imports = desc.getimportpackages(); if (desc.hasdynamicimports()) { list<importpackagespecification> staticimportslist = new arraylist(); for (int i = 0; i < imports.length; ++i) { if (!imports[i].getdirective(constants.resolution_directive).equals(importpackagespecification.resolution_dynamic)) staticimportslist.add(imports[i]); } imports = staticimportslist.toarray(new importpackagespecification[staticimportslist.size()]); } manifestelement[] elements = header.getelements(); int index = 0; for (int i = 0; i < elements.length; i++) { checkcanceled(monitor); validatespecificationversionattribute(header, elements[i]); validateresolutiondirective(header, elements[i]); validateimportpackageversion(header, elements[i]); if (!hasunresolved) continue; int length = elements[i].getvaluecomponents().length; for (int j = 0; j < length; j++) { importpackagespecification importspec = imports[index++]; string name = importspec.getname(); if name.equals("java") || name.startswith("java.")) { iheader jreheader = getheader(icoreconstants.eclipse_jrebundle); if (jreheader == null || !"true".equals jreheader.getvalue())) { report(pdecoremessages.bundleerrorreporter_importnojre, getpackageline(header, elements[i]), compilerflags.error, pdemarkerfactory.m_java_package__ported, pdemarkerfactory.cat_fatal); continue; } } if (importspec.isresolved() || !ischeckunresolvedimports()) continue; boolean optional = isoptional(elements[i]); int severity = getrequirebundleseverity(elements[i], optional); exportpackagedescription export = exported.get(name); if (export != null) { if (export.getsupplier().isresolved()) { version version = export.getversion(); org.eclipse.osgi.service.resolver.versionrange range = importspec.getversionrange(); if (range != null && !range.isincluded(version)) { report(nls.bind(pdecoremessages.bundleerrorreporter_unsatisfiedconstraint, importspec.tostring()), getpackageline(header, elements[i]), severity, pdemarkerfactory.cat_fatal); } } else { report(nls.bind(pdecoremessages.bundleerrorreporter_unresolvedexporter, new string[] { export.getsupplier().getsymbolicname(), name }), getpackageline(header, elements[i]), severity, pdemarkerfactory.cat_other); } } else { imarker marker = report(nls.bind(pdecoremessages.bundleerrorreporter_packagenotexported, name), getpackageline(header, elements[i]), severity, pdemarkerfactory.m_import_pkg_not_available, pdemarkerfactory.cat_fatal); try { if (marker != null) { marker.setattribute "packagename", name); if (optional) marker.setattribute "optional", true); } } catch (coreexception e) { } } } } }