/** * Stores the content of the JAR's MANIFEST.MF file. This should only be invoked on resources that correspond to JAR * files. */ public void setManifestContent(char[] newContent) { MANIFEST_CONTENT.put(getNd(), getAddress(), newContent); }
/** * Returns a workspace path to this resource if possible and the absolute filesystem location if not. */ public IPath getPath() { IPath workspacePath = getFirstWorkspaceLocation(); if (workspacePath.isEmpty()) { return new Path(getLocation().getString()); } return workspacePath; }
resourceFile = new NdResourceFile(this.nd); resourceFile.setTimeLastUsed(currentTimeMillis); resourceFile.setLocation(pathString); IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot) element .getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); IPath rootPathString = JavaIndex.getLocationForElement(packageFragmentRoot); if (!rootPathString.equals(thePath)) { resourceFile.setPackageFragmentRoot(rootPathString.toString().toCharArray()); if (resourceFile.isInIndex()) { resourceFile.delete(); if (resourceFile.isInIndex()) { resourceFile.setFingerprint(fingerprint); allResourcesWithThisPath = javaIndex.findResourcesWithPath(pathString); this.fileStateCache.remove(resourceFile.getLocation().getString()); if (!next.equals(resourceFile)) { deleteResource(next, deletionMonitor.split(1));
if (toDelete.isInIndex()) { toDelete.markAsInvalid(); this.nd.acquireWriteLock(deletionMonitor.split(1)); try { if (!toDelete.isInIndex()) { break; int numChildren = toDelete.getTypeCount(); deletionMonitor.setWorkRemaining(numChildren + 1); if (numChildren == 0) { NdType nextDeletion = toDelete.getType(numChildren - 1); if (DEBUG_INSERTIONS) { Package.logInfo("Deleting " + nextDeletion.getTypeId().getFieldDescriptor().getString() + " from " //$NON-NLS-1$//$NON-NLS-2$ + toDelete.getLocation().getString() + " " + toDelete.address); //$NON-NLS-1$ if (toDelete.isInIndex()) { toDelete.delete();
resourceFile.allocateZipEntries(zipFile.size()); } finally { this.nd.releaseWriteLock(); this.nd.acquireWriteLock(subMonitor.split(5)); try { if (resourceFile.isInIndex()) { if (DEBUG_INSERTIONS) { Package.logInfo("Inserting non-class file " + fileName + " into " //$NON-NLS-1$//$NON-NLS-2$ + resourceFile.getLocation().getString() + " " + resourceFile.address); //$NON-NLS-1$ resourceFile.addZipEntry(fileName); char[] chars = getInputStreamAsCharArray(inputStream, -1, UTF_8); resourceFile.setManifestContent(chars); if (resourceFile.isInIndex()) { resourceFile.setFlags(NdResourceFile.FLG_CORRUPT_ZIP_FILE);
this.nd.acquireWriteLock(subMonitor.split(5)); try { if (resourceFile.isInIndex()) { if (DEBUG_INSERTIONS) { Package.logInfo("Inserting " + new String(fieldDescriptor) + " into " //$NON-NLS-1$//$NON-NLS-2$ + resourceFile.getLocation().getString() + " " + resourceFile.address); //$NON-NLS-1$ resourceFile.setJdkLevel(binaryType.getVersion()); indexed = true; for (NdType nextType : implementations) { NdResourceFile nextResourceFile = nextType.getResourceFile(); if (nextResourceFile.equals(resourceFile)) { targetType = nextType; break;
/** * Returns true iff the given resource file is up-to-date with the filesystem. Returns false * if the argument is null or there is a possibility it being out-of-date with the file system. * * @param file the index file to look up or null * @throws CoreException */ public boolean isUpToDate(NdResourceFile file) throws CoreException { if (file != null && file.isDoneIndexing()) { String location = file.getLocation().getString(); FileStateCache cache = FileStateCache.getCache(getNd()); Boolean cachedResult = cache.isUpToDate(location); if (cachedResult != null) { return cachedResult; } Path locationPath = new Path(location); boolean result = file.getFingerprint().test(locationPath, null).matches(); cache.put(location, result); return result; } return false; }
fingerprint = resourceFile.getFingerprint(); this.nd.acquireWriteLock(subMonitor.split(10)); try { if (resourceFile.isInIndex()) { if (DEBUG) { Package.logInfo( "Writing updated fingerprint for " + thePath + ": " + result.getNewFingerprint()); //$NON-NLS-1$//$NON-NLS-2$ resourceFile.setFingerprint(result.getNewFingerprint());
/** * Given a NdType, returns its identifier in the form accepted by {@link IJavaSearchScope#encloses(String)} */ public static char[] getIndexPathFor(NdType type, IWorkspaceRoot root) { NdResourceFile resourceFile = type.getResourceFile(); char[] binaryName = type.getTypeId().getBinaryName(); char[] workspaceLocation = null; if (root != null) { workspaceLocation = resourceFile.getAnyOpenWorkspaceLocation(root).toString().toCharArray(); } if (workspaceLocation == null || workspaceLocation.length == 0) { workspaceLocation = resourceFile.getLocation().getChars(); } return CharArrayUtils.concat(workspaceLocation, JAR_FILE_ENTRY_SEPARATOR, binaryNameToResourceRelativePath(binaryName)); }
public boolean hasAllFlags(int flags) { int ourFlags = getFlags(); return (ourFlags & flags) == flags; }
resourceFile = new NdResourceFile(this.nd); resourceFile.setTimeLastUsed(currentTimeMillis); resourceFile.setLocation(pathString); IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot) element .getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); IPath rootPathString = JavaIndex.getLocationForElement(packageFragmentRoot); if (!rootPathString.equals(thePath)) { resourceFile.setPackageFragmentRoot(rootPathString.toString().toCharArray()); if (resourceFile.isInIndex()) { resourceFile.delete(); if (resourceFile.isInIndex()) { resourceFile.setFingerprint(fingerprint); allResourcesWithThisPath = javaIndex.findResourcesWithPath(pathString); this.fileStateCache.remove(resourceFile.getLocation().getString()); if (!next.equals(resourceFile)) { deleteResource(next, deletionMonitor.split(1));
if (toDelete.isInIndex()) { toDelete.markAsInvalid(); this.nd.acquireWriteLock(deletionMonitor.split(1)); try { if (!toDelete.isInIndex()) { break; int numChildren = toDelete.getTypeCount(); deletionMonitor.setWorkRemaining(numChildren + 1); if (numChildren == 0) { NdType nextDeletion = toDelete.getType(numChildren - 1); if (DEBUG_INSERTIONS) { Package.logInfo("Deleting " + nextDeletion.getTypeId().getFieldDescriptor().getString() + " from " //$NON-NLS-1$//$NON-NLS-2$ + new String(toDelete.getLocation().getString()) + " " + toDelete.address); //$NON-NLS-1$ if (toDelete.isInIndex()) { toDelete.delete();
resourceFile.allocateZipEntries(zipFile.size()); } finally { this.nd.releaseWriteLock(); this.nd.acquireWriteLock(subMonitor.split(5)); try { if (resourceFile.isInIndex()) { if (DEBUG_INSERTIONS) { Package.logInfo("Inserting non-class file " + fileName + " into " //$NON-NLS-1$//$NON-NLS-2$ + resourceFile.getLocation().getString() + " " + resourceFile.address); //$NON-NLS-1$ resourceFile.addZipEntry(fileName); char[] chars = getInputStreamAsCharArray(inputStream, -1, UTF_8); resourceFile.setManifestContent(chars); if (resourceFile.isInIndex()) { resourceFile.setFlags(NdResourceFile.FLG_CORRUPT_ZIP_FILE);
this.nd.acquireWriteLock(subMonitor.split(5)); try { if (resourceFile.isInIndex()) { if (DEBUG_INSERTIONS) { Package.logInfo("Inserting " + new String(fieldDescriptor) + " into " //$NON-NLS-1$//$NON-NLS-2$ + resourceFile.getLocation().getString() + " " + resourceFile.address); //$NON-NLS-1$ resourceFile.setJdkLevel(binaryType.getVersion()); indexed = true; for (NdType nextType : implementations) { NdResourceFile nextResourceFile = nextType.getResourceFile(); if (nextResourceFile.equals(resourceFile)) { targetType = nextType; break;
/** * Returns true iff the given resource file is up-to-date with the filesystem. Returns false * if the argument is null or there is a possibility it being out-of-date with the file system. * * @param file the index file to look up or null * @throws CoreException */ public boolean isUpToDate(NdResourceFile file) throws CoreException { if (file != null && file.isDoneIndexing()) { String location = file.getLocation().getString(); FileStateCache cache = FileStateCache.getCache(getNd()); Boolean cachedResult = cache.isUpToDate(location); if (cachedResult != null) { return cachedResult; } Path locationPath = new Path(location); boolean result = file.getFingerprint().test(locationPath, null).matches(); cache.put(location, result); return result; } return false; }
fingerprint = resourceFile.getFingerprint(); this.nd.acquireWriteLock(subMonitor.split(10)); try { if (resourceFile.isInIndex()) { if (DEBUG) { Package.logInfo( "Writing updated fingerprint for " + thePath + ": " + result.getNewFingerprint()); //$NON-NLS-1$//$NON-NLS-2$ resourceFile.setFingerprint(result.getNewFingerprint());
/** * Given a NdType, returns its identifier in the form accepted by {@link IJavaSearchScope#encloses(String)} */ public static char[] getIndexPathFor(NdType type, IWorkspaceRoot root) { NdResourceFile resourceFile = type.getResourceFile(); char[] binaryName = type.getTypeId().getBinaryName(); char[] workspaceLocation = null; if (root != null) { workspaceLocation = resourceFile.getAnyOpenWorkspaceLocation(root).toString().toCharArray(); } if (workspaceLocation == null || workspaceLocation.length == 0) { workspaceLocation = resourceFile.getLocation().getChars(); } return CharArrayUtils.concat(workspaceLocation, JAR_FILE_ENTRY_SEPARATOR, binaryNameToResourceRelativePath(binaryName)); }