@NotNull private static File getIndexDirectory(@NotNull ID<?, ?> indexName, boolean forVersion, String relativePath) { final String dirName = indexName.toString().toLowerCase(Locale.US); File indexDir; if (indexName instanceof StubIndexKey) { // store StubIndices under StubUpdating index' root to ensure they are deleted // when StubUpdatingIndex version is changed indexDir = new File(getIndexDirectory(StubUpdatingIndex.INDEX_ID, false, relativePath), forVersion ? STUB_VERSIONS : dirName); } else { if (relativePath.length() > 0) relativePath = File.separator + relativePath; indexDir = new File(PathManager.getIndexRoot() + relativePath, dirName); } indexDir.mkdirs(); return indexDir; }
@Nonnull private static File getIndexDirectory(@Nonnull ID<?, ?> indexName, boolean forVersion, String relativePath) { final String dirName = indexName.toString().toLowerCase(Locale.US); File indexDir; if (indexName instanceof StubIndexKey) { // store StubIndices under StubUpdating index' root to ensure they are deleted // when StubUpdatingIndex version is changed indexDir = new File(getIndexDirectory(StubUpdatingIndex.INDEX_ID, false, relativePath), forVersion ? STUB_VERSIONS : dirName); } else { if (relativePath.length() > 0) relativePath = File.separator + relativePath; indexDir = new File(PathManager.getIndexRoot() + relativePath, dirName); } indexDir.mkdirs(); return indexDir; }
public void testLargeFile() throws Exception { char[] text = new char[FileUtilRt.LARGE_FOR_CONTENT_LOADING + 42]; final String clazz = "class Foo { String bar; }"; for (int i = 0; i < text.length; i++) { text[i] = i < clazz.length() ? clazz.charAt(i) : ' '; } final LightVirtualFile file = new LightVirtualFile("Foo.java", new CharArrayCharSequence(text)); assertFalse(((FileBasedIndexImpl)FileBasedIndex.getInstance()).isIndexingCandidate(file, StubUpdatingIndex.INDEX_ID)); }
private void addImplicitResolveResults(String referencedName, ResolveResultList ret) { final Project project = myElement.getProject(); final GlobalSearchScope scope = PyProjectScopeBuilder.excludeSdkTestsScope(project); final Collection functions = PyFunctionNameIndex.find(referencedName, project, scope); final PsiFile containingFile = myElement.getContainingFile(); final List<QualifiedName> imports; if (containingFile instanceof PyFile) { imports = collectImports((PyFile)containingFile); } else { imports = Collections.emptyList(); } for (Object function : functions) { if (!(function instanceof PyFunction)) { FileBasedIndex.getInstance().scheduleRebuild(StubUpdatingIndex.INDEX_ID, new Throwable("found non-function object " + function + " in function list")); break; } PyFunction pyFunction = (PyFunction)function; if (pyFunction.getContainingClass() != null) { ret.add(new ImplicitResolveResult(pyFunction, getImplicitResultRate(pyFunction, imports))); } } final Collection attributes = PyInstanceAttributeIndex.find(referencedName, project, scope); for (Object attribute : attributes) { if (!(attribute instanceof PyTargetExpression)) { FileBasedIndex.getInstance().scheduleRebuild(StubUpdatingIndex.INDEX_ID, new Throwable( "found non-target expression object " + attribute + " in target expression list")); break; } ret.add(new ImplicitResolveResult((PyTargetExpression)attribute, getImplicitResultRate((PyTargetExpression)attribute, imports))); } }
public static Sdk create(final String version, @NotNull final VirtualFile ... additionalRoots) { final String mock_path = PythonTestUtil.getTestDataPath() + "/MockSdk" + version + "/"; String sdkHome = new File(mock_path, "bin/python"+version).getPath(); SdkType sdkType = PythonSdkType.getInstance(); final Sdk sdk = new ProjectJdkImpl(MOCK_SDK_NAME + " " + version, sdkType) { @Override public String getVersionString() { return "Python " + version + " Mock SDK"; } }; final SdkModificator sdkModificator = sdk.getSdkModificator(); sdkModificator.setHomePath(sdkHome); File libPath = new File(mock_path, "Lib"); if (libPath.exists()) { sdkModificator.addRoot(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(libPath), OrderRootType.CLASSES); } PyUserSkeletonsUtil.addUserSkeletonsRoot(PySdkUpdater.fromSdkModificator(sdk, sdkModificator)); String mock_stubs_path = mock_path + PythonSdkType.SKELETON_DIR_NAME; sdkModificator.addRoot(LocalFileSystem.getInstance().refreshAndFindFileByPath(mock_stubs_path), PythonSdkType.BUILTIN_ROOT_TYPE); for (final VirtualFile root : additionalRoots) { sdkModificator.addRoot(root, OrderRootType.CLASSES); } sdkModificator.commitChanges(); final FileBasedIndex index = FileBasedIndex.getInstance(); index.requestRebuild(StubUpdatingIndex.INDEX_ID); index.requestRebuild(PyModuleNameIndex.NAME); return sdk; }
private static File getIndexDirectory(ID<?, ?> indexName, boolean forVersion) { final String dirName = indexName.toString().toLowerCase(Locale.US); // store StubIndices under StubUpdating index' root to ensure they are deleted // when StubUpdatingIndex version is changed final File indexDir = indexName instanceof StubIndexKey ? new File(getIndexRootDir(StubUpdatingIndex.INDEX_ID), forVersion ? STUB_VERSIONS : dirName) : new File(PathManager.getIndexRoot(), dirName); indexDir.mkdirs(); return indexDir; }
public static ID getStubId(ID<?, ?> indexName, FileType fileType) { if (StubUpdatingIndex.INDEX_ID.equals(indexName)) { String name = fileType.getName(); ID id = ID.findByName(name); if (id != null) { return id; } else { return StubIndexKey.createIndexKey(name); } } else { return indexName; } }
public static void ensureIndexesUpToDate(@NotNull Project project) { if (!DumbService.isDumb(project)) { FileBasedIndex.getInstance().ensureUpToDate(StubUpdatingIndex.INDEX_ID, project, null); FileBasedIndex.getInstance().ensureUpToDate(TodoIndex.NAME, project, null); } }
public static void ensureIndexesUpToDate(Project project) { if (!DumbService.isDumb(project)) { FileBasedIndex.getInstance().ensureUpToDate(StubUpdatingIndex.INDEX_ID, project, null); FileBasedIndex.getInstance().ensureUpToDate(TodoIndex.NAME, project, null); } }