/** @since 2.4 */ protected PackageFragmentRootData initializeData(final IPackageFragmentRoot root) { final PackageFragmentRootData data = new PackageFragmentRootData(computeModificationStamp(root)); data.addRoot(root); try { final SourceAttachmentPackageFragmentRootWalker<Void> walker = new SourceAttachmentPackageFragmentRootWalker<Void>() { @Override protected URI getURI( IFile file, org.eclipse.xtext.ui.resource.PackageFragmentRootWalker.TraversalState state) { if (!uriValidator.isPossiblyManaged(file)) return null; return super.getURI(file, state); } @Override protected URI getURI( IJarEntryResource jarEntry, org.eclipse.xtext.ui.resource.PackageFragmentRootWalker.TraversalState state) { if (!uriValidator.isPossiblyManaged(jarEntry)) return null; final URI uri = locator.getURI(root, jarEntry, state); if (!uriValidator.isValid(uri, jarEntry)) return null; return uri; } @Override protected Void handle( URI uri, IStorage storage, org.eclipse.xtext.ui.resource.PackageFragmentRootWalker.TraversalState state) { data.uri2Storage.put(uri, storage); return null; } }; walker.traverse(root, false); if (walker.getBundleSymbolicName() != null) data.uriPrefix = URI.createPlatformResourceURI(walker.getBundleSymbolicName() + "/", true); } catch (RuntimeException e) { log.error(e.getMessage(), e); } catch (JavaModelException e) { log.debug(e.getMessage(), e); } return data; }
private PackageFragmentRootData getCachedData(IPackageFragmentRoot root) { final String path = root.getPath().toString(); synchronized (cachedPackageFragmentRootData) { if (cachedPackageFragmentRootData.containsKey(path)) { final PackageFragmentRootData data = cachedPackageFragmentRootData.get(path); if (isUpToDate(data, root)) { data.addRoot(root); return data; } else { cachedPackageFragmentRootData.remove(path); } } } PackageFragmentRootData data = initializeData(root); synchronized (cachedPackageFragmentRootData) { cachedPackageFragmentRootData.put(path, data); } return data; }