public static JavaIndex getIndex(Nd nd) { return new JavaIndex(nd, Database.DATA_AREA_OFFSET); }
private NdTypeId createTypeIdFromFieldDescriptor(char[] typeName) { if (typeName == null) { return null; } return this.index.createTypeId(typeName); }
public static JavaIndex getIndex() { return getIndex(getGlobalNd()); }
/** * Reads the given binary type. If the type can be found in the index with a fingerprint that exactly matches * the file on disk, the type is read from the index. Otherwise the type is read from disk. Returns null if * no such type exists. * @throws ClassFormatException */ public static IBinaryType readType(BinaryTypeDescriptor descriptor, IProgressMonitor monitor) throws JavaModelException, ClassFormatException { if (JavaIndex.isEnabled()) { try { return readFromIndex(JavaIndex.getIndex(), descriptor, monitor); } catch (NotInIndexException e) { // fall back to reading the zip file, below } } return rawReadType(descriptor, true); }
public void verifyArchiveContent(IPath path) throws CoreException { // TODO: we haven't finalized what path the JRT is represented by. Don't attempt to validate it. if (isJrt(path)) { return; } throwExceptionIfArchiveInvalid(path); // Check if we can determine the archive's validity by examining the index if (JavaIndex.isEnabled()) { JavaIndex index = JavaIndex.getIndex(); String location = JavaModelManager.getLocalFile(path).getAbsolutePath(); try (IReader reader = index.getNd().acquireReadLock()) { NdResourceFile resourceFile = index.getResourceFile(location.toCharArray()); if (index.isUpToDate(resourceFile)) { // We have this file in the index and the index is up-to-date, so we can determine the file's // validity without touching the filesystem. if (resourceFile.isCorruptedZipFile()) { throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.status_IOException, new ZipException())); } return; } } } ZipFile file = getZipFile(path); closeZipFile(file); }
private static void newSearchAllPossibleSubTypes(IType type, IJavaSearchScope scope2, Map binariesFromIndexMatches2, IPathRequestor pathRequestor, int waitingPolicy, IProgressMonitor progressMonitor) { SubMonitor subMonitor = SubMonitor.convert(progressMonitor, 2); JavaIndex index = JavaIndex.getIndex(); Nd nd = index.getNd(); char[] fieldDefinition = JavaNames.fullyQualifiedNameToFieldDescriptor(type.getFullyQualifiedName().toCharArray()); NdTypeId foundType = index.findType(fieldDefinition);
JavaIndex index = JavaIndex.getIndex(); Nd nd = index.getNd(); try (IReader lock = nd.acquireReadLock()) { return !index.visitFieldDescriptorsStartingWith(fieldDescriptorPrefix, new FieldSearchIndex.Visitor<NdTypeId>() { @Override
JavaIndex javaIndex = JavaIndex.getIndex(this.nd); 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.setFingerprint(fingerprint); allResourcesWithThisPath = javaIndex.findResourcesWithPath(pathString);
@Override public NdType get() { NdTypeId typeId = JavaIndex.getIndex(TypeRef.this.ref.getNd()).findType(TypeRef.this.fieldDescriptor); if (typeId == null) { return null; } List<NdType> implementations = typeId.getTypes(); for (NdType next : implementations) { NdResourceFile nextResourceFile = next.getResourceFile(); if (nextResourceFile.getLocation().compare(TypeRef.this.fileName, false) == 0) { if (nextResourceFile.isDoneIndexing()) { return next; } } } return null; } }
private void updateResourceMappings(Map<IPath, List<IJavaElement>> pathsToUpdate, IProgressMonitor monitor) { SubMonitor subMonitor = SubMonitor.convert(monitor, pathsToUpdate.keySet().size()); JavaIndex index = JavaIndex.getIndex(this.nd); for (Entry<IPath, List<IJavaElement>> entry : pathsToUpdate.entrySet()) { SubMonitor iterationMonitor = subMonitor.split(1).setWorkRemaining(10); this.nd.acquireWriteLock(iterationMonitor.split(1)); try { NdResourceFile resourceFile = index.getResourceFile(entry.getKey().toString().toCharArray()); if (resourceFile == null) { continue; } attachWorkspaceFilesToResource(entry.getValue(), resourceFile); } finally { this.nd.releaseWriteLock(); } } }
JavaIndex index = JavaIndex.getIndex(this.nd); List<NdResourceFile> resourceFiles = index.getAllResourceFiles();
public static Nd createNd(File databaseFile, ChunkCache chunkCache) { return new Nd(databaseFile, chunkCache, createTypeRegistry(), MIN_SUPPORTED_VERSION, MAX_SUPPORTED_VERSION, CURRENT_VERSION); }
public ClassFileToIndexConverter(NdResourceFile resourceFile) { this.resource = resourceFile; this.index = JavaIndex.getIndex(resourceFile.getNd()); }
public static Indexer getInstance() { synchronized (mutex) { if (indexer == null) { indexer = new Indexer(JavaIndex.getGlobalNd(), ResourcesPlugin.getWorkspace().getRoot()); IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(JavaCore.PLUGIN_ID); preferences.addPreferenceChangeListener(listener); } return indexer; } }
/** * Returns a type ID or creates a new one if it does not exist. The caller must * attach a reference to it after calling this method or it may leak. */ public NdTypeId createTypeId(char[] fieldDescriptor) { NdTypeId existingType = findType(fieldDescriptor); if (existingType != null) { return existingType; } if (fieldDescriptor.length > 1) { if (fieldDescriptor[0] == 'L') { if (fieldDescriptor[fieldDescriptor.length - 1] != ';') { throw new IllegalStateException(new String(fieldDescriptor) + " is not a valid field descriptor"); //$NON-NLS-1$ } } } NdTypeId result = new NdTypeId(this.nd, fieldDescriptor); if (!CharArrayUtils.equals(result.getFieldDescriptor().getChars(), fieldDescriptor)) { throw new IllegalStateException("Field descriptor didn't match"); //$NON-NLS-1$ } return result; }
public void verifyArchiveContent(IPath path) throws CoreException { // TODO: we haven't finalized what path the JRT is represented by. Don't attempt to validate it. if (isJrt(path)) { return; } throwExceptionIfArchiveInvalid(path); // Check if we can determine the archive's validity by examining the index if (JavaIndex.isEnabled()) { JavaIndex index = JavaIndex.getIndex(); String location = JavaModelManager.getLocalFile(path).getAbsolutePath(); try (IReader reader = index.getNd().acquireReadLock()) { NdResourceFile resourceFile = index.getResourceFile(location.toCharArray()); if (index.isUpToDate(resourceFile)) { // We have this file in the index and the index is up-to-date, so we can determine the file's // validity without touching the filesystem. if (resourceFile.isCorruptedZipFile()) { throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.status_IOException, new ZipException())); } return; } } } ZipFile file = getZipFile(path); closeZipFile(file); }
private static void newSearchAllPossibleSubTypes(IType type, IJavaSearchScope scope2, Map binariesFromIndexMatches2, IPathRequestor pathRequestor, int waitingPolicy, IProgressMonitor progressMonitor) { SubMonitor subMonitor = SubMonitor.convert(progressMonitor, 2); JavaIndex index = JavaIndex.getIndex(); Nd nd = index.getNd(); char[] fieldDefinition = JavaNames.fullyQualifiedNameToFieldDescriptor(type.getFullyQualifiedName().toCharArray()); NdTypeId foundType = index.findType(fieldDefinition);
JavaIndex index = JavaIndex.getIndex(); Nd nd = index.getNd(); try (IReader lock = nd.acquireReadLock()) { return !index.visitFieldDescriptorsStartingWith(fieldDescriptorPrefix, new FieldSearchIndex.Visitor<NdTypeId>() { @Override
JavaIndex javaIndex = JavaIndex.getIndex(this.nd); 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.setFingerprint(fingerprint); allResourcesWithThisPath = javaIndex.findResourcesWithPath(pathString);