ISourceContainer[] getSourceContainers(String location, String id) throws CoreException { ISourceContainer[] containers = (ISourceContainer[]) fSourceContainerMap.get(location); if (containers != null) { return containers; } ArrayList result = new ArrayList(); ModelEntry entry = MonitorRegistry.findEntry(id); boolean match = false; IMonitorModelBase[] models = entry.getWorkspaceModels(); for (int i = 0; i < models.length; i++) { if (isPerfectMatch(models[i], new Path(location))) { IResource resource = models[i].getUnderlyingResource(); // if the plug-in matches a workspace model, // add the project and any libraries not coming via a container // to the list of source containers, in that order if (resource != null) { addProjectSourceContainers(resource.getProject(), result); } match = true; break; } } if (!match) { File file = new File(location); if (file.isFile()) { // in case of linked plug-in projects that map to an external JARd plug-in, // use source container that maps to the library in the linked project. ISourceContainer container = getArchiveSourceContainer(location); if (container != null) { containers = new ISourceContainer[] {container}; fSourceContainerMap.put(location, containers); return containers; } } models = entry.getExternalModels(); for (int i = 0; i < models.length; i++) { if (isPerfectMatch(models[i], new Path(location))) { // try all source zips found in the source code locations IClasspathEntry[] entries = MDEClasspathContainer.getExternalEntries(models[i]); for (int j = 0; j < entries.length; j++) { IRuntimeClasspathEntry rte = convertClasspathEntry(entries[j]); if (rte != null) result.add(rte); } break; } } } IRuntimeClasspathEntry[] entries = (IRuntimeClasspathEntry[]) result.toArray(new IRuntimeClasspathEntry[result.size()]); containers = JavaRuntime.getSourceContainers(entries); fSourceContainerMap.put(location, containers); return containers; }
/** * Validates that the version of the given plug-in is available in the registry. Adds a warning if * the plug-in could not be found. * * @param plugin xml element describing the plug-in to look for in the registry * @param attr set of element attributes */ private void validateVersion(Element plugin, Attr attr) { String id = plugin.getAttribute("id"); // $NON-NLS-1$ String version = plugin.getAttribute("version"); // $NON-NLS-1$ if (id.trim().length() == 0 || version.trim().length() == 0 || version.equals("0.0.0")) // $NON-NLS-1$ return; ModelEntry entry = MonitorRegistry.findEntry(id); if (entry != null) { IMonitorModelBase[] allModels = entry.getActiveModels(); for (int i = 0; i < allModels.length; i++) { IMonitorModelBase availablePlugin = allModels[i]; if (id.equals(availablePlugin.getMonitorBase().getId())) { if (version.equals(availablePlugin.getMonitorBase().getVersion())) { return; } } } } report( NLS.bind( MDECoreMessages.Builders_Feature_mismatchPluginVersion, new String[] {version, id}), getLine(plugin, attr.getName()), CompilerFlags.WARNING, MDEMarkerFactory.CAT_OTHER); }