@Nullable private static Sdk projectSdk(@NotNull Project project) { return sdk(ProjectRootManager.getInstance(project).getProjectSdk()); }
private boolean isAContentRoot(@Nullable PsiDirectory directory) { if (directory == null) { return false; } VirtualFile[] contentRoots = ProjectRootManager.getInstance(directory.getProject()).getContentRoots(); for (VirtualFile contentRoot : contentRoots) { if (contentRoot.equals(directory.getVirtualFile())) { return true; } } return false; } }
@Nullable private static String getBallerinaSdk(Project project) { Sdk projectSdk = ProjectRootManager.getInstance(project).getProjectSdk(); if (projectSdk == null) { return null; } String sdkPath = projectSdk.getHomePath(); return (isBallerinaSdkHome(sdkPath)) ? sdkPath : null; }
@Override protected void addCompletionVariants(@NotNull String text, int offset, @NotNull String prefix, @NotNull CompletionResultSet result) { Module module = myModuleProducer.produce(); if (module != null) { Project project = module.getProject(); VirtualFile[] contentRoots = ProjectRootManager.getInstance(project).getContentRoots(); for (VirtualFile contentRoot : contentRoots) { addDirectories(result, contentRoot.getPath(), contentRoot); } } }
@NotNull public static synchronized List<BallerinaAnnotationDefinition> suggestBuiltInAnnotations(@NotNull PsiElement element) { return CachedValuesManager.getCachedValue(element, () -> CachedValueProvider.Result.create(getBuiltInAnnotations(element), ProjectRootManager.getInstance(element.getProject()))); }
@Nullable public static PsiElement getCachedType(@NotNull BallerinaNameReference ballerinaNameReference) { return CachedValuesManager.getCachedValue(ballerinaNameReference, () -> CachedValueProvider.Result.create(getType(ballerinaNameReference), ProjectRootManager.getInstance(ballerinaNameReference.getProject()))); }
@NotNull public static synchronized List<BallerinaTypeDefinition> suggestBuiltInTypes(@NotNull PsiElement element) { return CachedValuesManager.getCachedValue(element, () -> CachedValueProvider.Result.create(getBuiltInTypes(element), ProjectRootManager.getInstance(element.getProject()))); }
/** * Used to retrieve the type from a {@link BallerinaVariableReference}. * * @param ballerinaVariableReference a {@link BallerinaVariableReference} object. * @return Type of the definition. */ @Nullable public static PsiElement getType(@NotNull BallerinaVariableReference ballerinaVariableReference) { return CachedValuesManager.getCachedValue(ballerinaVariableReference, () -> CachedValueProvider.Result.create(getBallerinaTypeFromVariableReference (ballerinaVariableReference), ProjectRootManager.getInstance(ballerinaVariableReference.getProject()))); }
/** * Initializes {@link #cacheMap} and {@link VirtualFileManager}. * * @param project current project */ protected FilesIndexCacheProjectComponent(@NotNull final Project project) { super(project); cacheMap = ContainerUtil.newConcurrentMap(); virtualFileManager = VirtualFileManager.getInstance(); projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex(); }
@Nullable public static String getSdkPath(@NotNull final Project project) { Sdk sdk = ProjectRootManager.getInstance(project).getProjectSdk(); return sdk != null && sdk.getSdkType() == getInstance() ? sdk.getHomePath() : null; }
private Sdk getGoSdk(@Nullable Module module) { if (module != null) { Sdk sdk = ModuleRootManager.getInstance(module).getSdk(); if (sdk != null && sdk.getSdkType() instanceof GoSdkType) { return sdk; } } Sdk sdk = ProjectRootManager.getInstance(myProject).getProjectSdk(); return sdk != null && sdk.getSdkType() instanceof GoSdkType ? sdk : null; } }
@NotNull public static synchronized List<BallerinaFunctionDefinition> suggestBuiltInFunctions(@NotNull PsiElement type) { if (!hasBuiltInDefinitions(type)) { return new LinkedList<>(); } String key = type.getText(); return CachedValuesManager.getCachedValue(type, () -> CachedValueProvider.Result.create(getBuiltInFunctions(key, type), ProjectRootManager.getInstance(type.getProject()))); }
private static IdFilter createIdFilter(@NotNull Project project, @NotNull Key<CachedValue<IdFilter>> cacheKey, @NotNull Condition<VirtualFile> filterCondition) { return CachedValuesManager.getManager(project).getCachedValue(project, cacheKey, () -> { BitSet bitSet = new BitSet(); ContentIterator iterator = fileOrDir -> { if (filterCondition.value(fileOrDir)) { addToBitSet(bitSet, fileOrDir); } ProgressManager.checkCanceled(); return true; }; FileBasedIndex.getInstance().iterateIndexableFiles(iterator, project, null); return CachedValueProvider.Result.create(new GoIdFilter(bitSet), ProjectRootManager.getInstance(project), VirtualFileManager.VFS_STRUCTURE_MODIFICATIONS); }, false); }
private Sdk getBallerinaSdk(@Nullable Module module) { if (module != null) { Sdk sdk = ModuleRootManager.getInstance(module).getSdk(); if (sdk != null && sdk.getSdkType() instanceof BallerinaSdkType) { return sdk; } } Sdk sdk = ProjectRootManager.getInstance(myProject).getProjectSdk(); return sdk != null && sdk.getSdkType() instanceof BallerinaSdkType ? sdk : null; }
@Nullable VirtualFile findFile(@NotNull String filename, @NotNull Project project) { VirtualFile found = null; if (filename.length() > 2 && filename.charAt(0) == '~' && filename.charAt(1) == File.separatorChar) { String homefile = filename.substring(2); String dir = System.getProperty("user.home"); if (logger.isDebugEnabled()) { logger.debug("home dir file"); logger.debug("looking for " + homefile + " in " + dir); } found = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(dir, homefile)); } else { ProjectRootManager prm = ProjectRootManager.getInstance(project); VirtualFile[] roots = prm.getContentRoots(); for (int i = 0; i < roots.length; i++) { if (logger.isDebugEnabled()) { logger.debug("root[" + i + "] = " + roots[i].getPath()); } found = findFile(roots[i], filename); if (found != null) { break; } } if (found == null) { found = LocalFileSystem.getInstance().findFileByIoFile(new File(filename)); } } return found; }
@Nullable @Override protected Runnable createRenewRequest(@NotNull CoverageSuitesBundle bundle, @NotNull CoverageDataManager manager) { GoCoverageProjectData data = new GoCoverageProjectData(); for (CoverageSuite suite : bundle.getSuites()) { ProjectData toMerge = suite.getCoverageData(manager); if (toMerge != null) { data.merge(toMerge); } } return () -> { annotateAllFiles(data, manager.doInReadActionIfProjectOpen(() -> ProjectRootManager.getInstance(getProject()).getContentRoots())); manager.triggerPresentationUpdate(); }; }
synchronized (myLastHandledGoPathSourcesRoots) { Collection<VirtualFile> goPathSourcesRoots = GoSdkUtil.getGoPathSources(project, myModule); Set<VirtualFile> excludeRoots = ContainerUtil.newHashSet(ProjectRootManager.getInstance(project).getContentRoots()); ProgressIndicatorProvider.checkCanceled(); if (!myLastHandledGoPathSourcesRoots.equals(goPathSourcesRoots) || !myLastHandledExclusions.equals(excludeRoots)) {
public static String getSdkHome(Project project, Module module) { // Get the module SDK. Sdk moduleSdk = ModuleRootManager.getInstance(module).getSdk(); // If the SDK is Ballerina SDK, return the home path. if (moduleSdk != null && moduleSdk.getSdkType() == BallerinaSdkType.getInstance()) { return moduleSdk.getHomePath(); } // Ge the project SDK. Sdk projectSdk = ProjectRootManager.getInstance(project).getProjectSdk(); // If the SDK is Ballerina SDK, return the home path. if (projectSdk != null && projectSdk.getSdkType() == BallerinaSdkType.getInstance()) { return projectSdk.getHomePath(); } return ""; }
private void setUpProjectSdk() { ApplicationManager.getApplication().runWriteAction(() -> { Sdk sdk = getProjectDescriptor().getSdk(); ProjectJdkTable.getInstance().addJdk(sdk); ProjectRootManager.getInstance(myFixture.getProject()).setProjectSdk(sdk); }); }
protected void setUpProjectSdk() { ApplicationManager.getApplication().runWriteAction(() -> { Sdk sdk = getProjectDescriptor().getSdk(); ProjectJdkTable.getInstance().addJdk(sdk); ProjectRootManager.getInstance(myFixture.getProject()).setProjectSdk(sdk); }); }