@Override public void apply() throws ConfigurationException { try { PropertiesComponent.getInstance().setValue(KEY_RULES_PATH, rulesPath.getText()); if (!TextUtils.isEmpty(rulesPath.getText())) { load(rulesPath.getText()); DirectiveLint.prepare(); } else { DirectiveLint.reset(); } } catch (Exception e) { ProjectUtil.guessCurrentProject(select).getMessageBus().syncPublisher(Notifications.TOPIC).notify( new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "Weex language support - bad rules", e.toString(), NotificationType.ERROR)); } savePaths(); }
/** * @deprecated to be removed after IDEA 15. Use {@link VfsUtil#saveText(VirtualFile, String)} instead. */ public static void setFileText(@Nullable Project project, final VirtualFile virtualFile, final String text) throws IOException { if (project == null) { project = ProjectUtil.guessProjectForFile(virtualFile); } if (project != null) { final PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile); final PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project); final Document document = psiFile == null? null : psiDocumentManager.getDocument(psiFile); if (document != null) { document.setText(text != null ? text : ""); psiDocumentManager.commitDocument(document); FileDocumentManager.getInstance().saveDocument(document); return; } } VfsUtil.saveText(virtualFile, text != null ? text : ""); virtualFile.refresh(false, false); }
private void applyLanguageSettings(Language lang) { final Project currProject = ProjectUtil.guessCurrentProject(getPanel()); CodeStyleSettings rootSettings = CodeStyleSettingsManager.getSettings(currProject); CommonCodeStyleSettings sourceSettings = rootSettings.getCommonSettings(lang); CommonCodeStyleSettings targetSettings = getSettings().getCommonSettings(getDefaultLanguage()); if (sourceSettings == null || targetSettings == null) return; if (!(targetSettings instanceof CodeStyleSettings)) { CommonCodeStyleSettingsManager.copy(sourceSettings, targetSettings); } else { Language targetLang = getDefaultLanguage(); LOG.error((targetLang != null ? targetLang.getDisplayName() : "Unknown") + " language plug-in either uses an outdated API or does not initialize" + " its own code style settings in LanguageCodeStyleSettingsProvider.getDefaultSettings()." + " The operation can not be applied in this case."); } reset(getSettings()); onSomethingChanged(); }
private void updateEditor(boolean useDefaultSample) { if (!myShouldUpdatePreview || (!ApplicationManager.getApplication().isUnitTestMode() && !myEditor.getComponent().isShowing())) { return; } if (myLastDocumentModificationStamp != myEditor.getDocument().getModificationStamp()) { myTextToReformat = myEditor.getDocument().getText(); } else if (useDefaultSample || myTextToReformat == null) { myTextToReformat = getPreviewText(); } int currOffs = myEditor.getScrollingModel().getVerticalScrollOffset(); final Project finalProject = ProjectUtil.guessCurrentProject(getPanel()); CommandProcessor.getInstance().executeCommand(finalProject, new Runnable() { @Override public void run() { replaceText(finalProject); } }, null, null); myEditor.getSettings().setRightMargin(getAdjustedRightMargin()); myLastDocumentModificationStamp = myEditor.getDocument().getModificationStamp(); myEditor.getScrollingModel().scrollVertically(currOffs); }
public static boolean isIpythonNewFormat(@NotNull final VirtualFile virtualFile) { final Project project = ProjectUtil.guessProjectForFile(virtualFile); if (project != null) { final Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(virtualFile); if (module != null) { final Sdk sdk = PythonSdkType.findPythonSdk(module); if (sdk != null) { try { final PyPackage ipython = PyPackageManager.getInstance(sdk).findPackage("ipython", true); if (ipython != null && VersionComparatorUtil.compare(ipython.getVersion(), "3.0") <= 0) { return false; } } catch (ExecutionException ignored) { } } } } return true; }
@NotNull @Override public Object[] getVariants() { final Project project = myElement.getProject(); PropertiesReferenceManager referenceManager = PropertiesReferenceManager.getInstance(project); final List<LookupElement> variants = new ArrayList<LookupElement>(); referenceManager.processPropertiesFiles(GlobalSearchScopesCore.projectProductionScope(project), new PropertiesFileProcessor() { public boolean process(String baseName, PropertiesFile propertiesFile) { final Icon icon = propertiesFile.getContainingFile().getIcon(Iconable.ICON_FLAG_READ_STATUS); final String relativePath = ProjectUtil.calcRelativeToProjectPath(propertiesFile.getVirtualFile(), project); variants.add(LookupElementBuilder.create(propertiesFile, baseName) .withIcon(icon) .withTailText(" (" + relativePath + ")", true)); return true; } }, this); return variants.toArray(new LookupElement[variants.size()]); }
@Nullable @Override public JComponent createComponent() { myProject = ProjectUtil.guessCurrentProject(myPanel); myConfig = JSRequireConfig.getInstanceForProject(myProject); mainJSRootDirTextField.setText(myConfig.getMainJSDirString()); nodeModulesDirField.setText(myConfig.getNodeModulesDirString()); deepIncludeNodeModulesField.setText(myConfig.getDeepIncludeModulesDirString()); useRelativePathsCheckBox.setSelected(myConfig.getUseRelativePathsForMain()); shouldIgnoreCase.setSelected(myConfig.getShouldIgnoreCase()); useDoubleQuotesField.setSelected(myConfig.getShouldUseDoubleQuotes()); return myPanel; }
public static void setFileText(@Nullable Project project, final VirtualFile virtualFile, final String text) throws IOException { if (project == null) { project = ProjectUtil.guessProjectForFile(virtualFile); } if (project != null) { final PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile); final PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project); final Document document = psiFile == null? null : psiDocumentManager.getDocument(psiFile); if (document != null) { document.setText(text != null ? text : ""); psiDocumentManager.commitDocument(document); FileDocumentManager.getInstance().saveDocument(document); return; } } VfsUtil.saveText(virtualFile, text != null ? text : ""); virtualFile.refresh(false, false); }
public static JButton createConfigureAnnotationsButton() { final JButton configureAnnotations = new JButton("Configure annotations..."); configureAnnotations.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getInstance(ProjectUtil.guessCurrentProject(configureAnnotations)).configureAnnotations(); } }); return configureAnnotations; }
private static void navigate(@Nullable Project project, @NotNull VirtualFile file, @NotNull OpenFileRequest request) { if (project == null) { project = getLastFocusedOrOpenedProject(); if (project == null) { project = ProjectManager.getInstance().getDefaultProject(); } } // OpenFileDescriptor line and column number are 0-based. new OpenFileDescriptor(project, file, Math.max(request.line - 1, 0), Math.max(request.column - 1, 0)).navigate(true); if (request.focused) { com.intellij.ide.impl.ProjectUtil.focusProjectWindow(project, true); } }
@NotNull private static Promise<Void> openAbsolutePath(@NotNull final File file, @NotNull final OpenFileRequest request) { if (!file.exists()) { return Promise.reject(NOT_FOUND); } final AsyncPromise<Void> promise = new AsyncPromise<Void>(); ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { try { VirtualFile virtualFile; AccessToken token = WriteAction.start(); try { virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file); } finally { token.finish(); } if (virtualFile == null) { promise.setError(NOT_FOUND); } else { navigate(ProjectUtil.guessProjectForContentFile(virtualFile), virtualFile, request); promise.setResult(null); } } catch (Throwable e) { promise.setError(e); } } }); return promise; }
@NotNull private static Component getAnchor(@NotNull JRootPane pane) { Component tabWrapper = UIUtil.findComponentOfType(pane, TabbedPaneWrapper.TabWrapper.class); if (tabWrapper != null) return tabWrapper; Component splitters = UIUtil.findComponentOfType(pane, EditorsSplitters.class); if (splitters != null) return splitters; FileEditorManagerEx ex = FileEditorManagerEx.getInstanceEx(ProjectUtil.guessCurrentProject(pane)); return ex == null ? pane : ex.getSplitters(); }
@Override @Nullable protected EditorHighlighter createHighlighter(final EditorColorsScheme scheme) { FileType fileType = getFileType(); return FileTypeEditorHighlighterProviders.INSTANCE.forFileType(fileType).getEditorHighlighter( ProjectUtil.guessCurrentProject(getPanel()), fileType, null, scheme); }
@Override public void processElementsWithName(@NotNull String name, @NotNull final Processor<NavigationItem> _processor, @NotNull FindSymbolParameters parameters) { final boolean globalSearch = parameters.getSearchScope().isSearchInLibraries(); final Processor<PsiFileSystemItem> processor = new Processor<PsiFileSystemItem>() { @Override public boolean process(PsiFileSystemItem item) { if (!globalSearch && ProjectUtil.isProjectOrWorkspaceFile(item.getVirtualFile())) { return true; } return _processor.process(item); } }; String completePattern = parameters.getCompletePattern(); final boolean includeDirs = completePattern.endsWith("/") || completePattern.endsWith("\\") || completePattern.startsWith("/") || completePattern.startsWith("\\"); boolean result = FilenameIndex.processFilesByName( name, includeDirs, processor, parameters.getSearchScope(), parameters.getProject(), parameters.getIdFilter() ); if (!result && includeDirs) { FilenameIndex.processFilesByName( name, false, processor, parameters.getSearchScope(), parameters.getProject(), parameters.getIdFilter() ); } }
public String getRelativeToProjectPath() { if (myRelativeToProjectPath == null) { final PsiDirectory directory = getDirectory(); final VirtualFile virtualFile = directory != null ? directory.getVirtualFile() : null; myRelativeToProjectPath = virtualFile != null ? ProjectUtil.calcRelativeToProjectPath(virtualFile, directory.getProject(), true, false, true) : getPresentableUrl(); } return myRelativeToProjectPath; }
@NotNull private List<UsageInfo> findAllStyleApplications() { Collection<PsiFile> psiFilesToProcess = collectFilesToProcess(); if (psiFilesToProcess.size() == 0) { return Collections.emptyList(); } final int n = psiFilesToProcess.size(); int i = 0; final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); if (indicator != null) { indicator.setText("Searching for style applications"); } final List<UsageInfo> usages = new ArrayList<UsageInfo>(); for (PsiFile psiFile : psiFilesToProcess) { ProgressManager.checkCanceled(); final VirtualFile vFile = psiFile.getVirtualFile(); if (vFile == null) { continue; } if (indicator != null) { indicator.setFraction((double)i / n); indicator.setText2(ProjectUtil.calcRelativeToProjectPath(vFile, myProject)); } findAllStyleApplications(vFile, usages); } return usages; }
private static Map<Module, PsiFile> findModulesInScope(@NotNull final Project project, @NotNull final AnalysisScope scope, @NotNull final int[] fileCount) { final ProgressManager progressManager = ProgressManager.getInstance(); final Map<Module, PsiFile> modules = new HashMap<Module, PsiFile>(); boolean completed = progressManager.runProcessWithProgressSynchronously(new Runnable() { @Override public void run() { scope.accept(new PsiElementVisitor() { @Override public void visitFile(PsiFile file) { fileCount[0]++; final ProgressIndicator progressIndicator = progressManager.getProgressIndicator(); if (progressIndicator != null) { final VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile != null) { progressIndicator.setText2(ProjectUtil.calcRelativeToProjectPath(virtualFile, project)); } progressIndicator.setText(AnalysisScopeBundle.message("scanning.scope.progress.title")); } final Module module = ModuleUtilCore.findModuleForPsiElement(file); if (module != null && !modules.containsKey(module)) { modules.put(module, file); } } }); } }, "Check applicability...", true, project); return completed ? modules : null; }
public OptionsPanel() { myCheckLocalVariablesCheckBox.setSelected(LOCAL_VARIABLE); myCheckClassesCheckBox.setSelected(CLASS); myCheckFieldsCheckBox.setSelected(FIELD); myCheckMethodsCheckBox.setSelected(METHOD); myCheckParametersCheckBox.setSelected(PARAMETER); myReportUnusedParametersInPublics.setSelected(REPORT_PARAMETER_FOR_PUBLIC_METHODS); myReportUnusedParametersInPublics.setEnabled(PARAMETER); final ActionListener listener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { LOCAL_VARIABLE = myCheckLocalVariablesCheckBox.isSelected(); CLASS = myCheckClassesCheckBox.isSelected(); FIELD = myCheckFieldsCheckBox.isSelected(); METHOD = myCheckMethodsCheckBox.isSelected(); PARAMETER = myCheckParametersCheckBox.isSelected(); REPORT_PARAMETER_FOR_PUBLIC_METHODS = PARAMETER && myReportUnusedParametersInPublics.isSelected(); myReportUnusedParametersInPublics.setEnabled(PARAMETER); } }; myCheckLocalVariablesCheckBox.addActionListener(listener); myCheckFieldsCheckBox.addActionListener(listener); myCheckMethodsCheckBox.addActionListener(listener); myCheckClassesCheckBox.addActionListener(listener); myCheckParametersCheckBox.addActionListener(listener); myReportUnusedParametersInPublics.addActionListener(listener); Project project = ProjectUtil.guessCurrentProject(myPanel); myAnnos.add(EntryPointsManager.getInstance(project).createConfigureAnnotationsBtn(), new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0)); }
@Override public JComponent createOptionsPanel() { final JPanel panel = new JPanel(new GridBagLayout()); Project project = ProjectUtil.guessCurrentProject(panel); panel.add(EntryPointsManager.getInstance(project).createConfigureAnnotationsBtn(), new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); return panel; }
@Nonnull private static Component getAnchor(@Nonnull JRootPane pane) { Component tabWrapper = UIUtil.findComponentOfType(pane, TabbedPaneWrapper.TabWrapper.class); if (tabWrapper != null && tabWrapper.isShowing()) return tabWrapper; DesktopEditorsSplitters splitters = UIUtil.findComponentOfType(pane, DesktopEditorsSplitters.class); if (splitters != null) { return splitters.isShowing() ? splitters : pane; } FileEditorManagerEx ex = FileEditorManagerEx.getInstanceEx(ProjectUtil.guessCurrentProject(pane)); if (ex == null) return pane; splitters = (DesktopEditorsSplitters)ex.getSplitters(); return splitters.isShowing() ? splitters : pane; }
@Nullable private static Project getProject(@Nonnull Document document, @Nullable Editor editor) { if (editor != null) return editor.getProject(); VirtualFile file = FileDocumentManager.getInstance().getFile(document); if (file != null) { return ProjectUtil.guessProjectForFile(file); } return null; }
private void updateEditor(boolean useDefaultSample) { if (!myShouldUpdatePreview || (!ApplicationManager.getApplication().isUnitTestMode() && !myEditor.getComponent().isShowing())) { return; } if (myLastDocumentModificationStamp != myEditor.getDocument().getModificationStamp()) { myTextToReformat = myEditor.getDocument().getText(); } else if (useDefaultSample || myTextToReformat == null) { myTextToReformat = getPreviewText(); } int currOffs = myEditor.getScrollingModel().getVerticalScrollOffset(); final Project finalProject = ProjectUtil.guessCurrentProject(getPanel()); CommandProcessor.getInstance().executeCommand(finalProject, new Runnable() { @Override @RequiredDispatchThread public void run() { replaceText(finalProject); } }, null, null); myEditor.getSettings().setRightMargin(getAdjustedRightMargin()); myLastDocumentModificationStamp = myEditor.getDocument().getModificationStamp(); myEditor.getScrollingModel().scrollVertically(currOffs); }
@NotNull public static JButton createConfigureAnnotationsButton() { final JButton configureAnnotations = new JButton("Configure annotations..."); configureAnnotations.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getInstance(ProjectUtil.guessCurrentProject(configureAnnotations)).configureAnnotations(); } }); return configureAnnotations; }
@Override protected void analyze(@NotNull final Project project, @NotNull final AnalysisScope scope) { PropertiesComponent.getInstance().setValue(ANNOTATE_LOCAL_VARIABLES, myAnnotateLocalVariablesCb.isSelected()); final ProgressManager progressManager = ProgressManager.getInstance(); final Set<Module> modulesWithoutAnnotations = new HashSet<Module>(); final Set<Module> modulesWithLL = new HashSet<Module>(); final JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(project); final String defaultNullable = NullableNotNullManager.getInstance(project).getDefaultNullable(); final int[] fileCount = new int[] {0}; if (!progressManager.runProcessWithProgressSynchronously(new Runnable() { @Override public void run() { scope.accept(new PsiElementVisitor() { final private Set<Module> processed = new HashSet<Module>(); @Override public void visitFile(PsiFile file) { fileCount[0]++; final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator(); if (progressIndicator != null) { final VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile != null) { progressIndicator.setText2(ProjectUtil.calcRelativeToProjectPath(virtualFile, project)); } progressIndicator.setText(AnalysisScopeBundle.message("scanning.scope.progress.title")); } final Module module = ModuleUtilCore.findModuleForPsiElement(file); if (module != null && processed.add(module)) { if (PsiUtil.getLanguageLevel(file).compareTo(LanguageLevel.JDK_1_5) < 0) { modulesWithLL.add(module); } else if (javaPsiFacade.findClass(defaultNullable, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module)) == null) { modulesWithoutAnnotations.add(module); } } } }); } }, "Check Applicability...", true, project)) { return; } if (!modulesWithLL.isEmpty()) { Messages.showErrorDialog(project, "Infer Nullity Annotations requires the project language level be set to 1.5 or greater.", INFER_NULLITY_ANNOTATIONS); return; } if (!modulesWithoutAnnotations.isEmpty()) { if (addAnnotationsDependency(project, modulesWithoutAnnotations, defaultNullable, INFER_NULLITY_ANNOTATIONS)) { restartAnalysis(project, scope); } return; } PsiDocumentManager.getInstance(project).commitAllDocuments(); final UsageInfo[] usageInfos = findUsages(project, scope, fileCount[0]); if (usageInfos == null) return; if (usageInfos.length < 5) { SwingUtilities.invokeLater(applyRunnable(project, new Computable<UsageInfo[]>() { @Override public UsageInfo[] compute() { return usageInfos; } })); } else { showUsageView(project, usageInfos, scope); } }
private UsageInfo[] findUsages(@NotNull final Project project, @NotNull final AnalysisScope scope, final int fileCount) { final NullityInferrer inferrer = new NullityInferrer(myAnnotateLocalVariablesCb.isSelected(), project); final PsiManager psiManager = PsiManager.getInstance(project); final Runnable searchForUsages = new Runnable() { @Override public void run() { scope.accept(new PsiElementVisitor() { int myFileCount = 0; @Override public void visitFile(final PsiFile file) { myFileCount++; final VirtualFile virtualFile = file.getVirtualFile(); final FileViewProvider viewProvider = psiManager.findViewProvider(virtualFile); final Document document = viewProvider == null ? null : viewProvider.getDocument(); if (document == null || virtualFile.getFileType().isBinary()) return; //do not inspect binary files final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator(); if (progressIndicator != null) { progressIndicator.setText2(ProjectUtil.calcRelativeToProjectPath(virtualFile, project)); progressIndicator.setFraction(((double)myFileCount) / fileCount); } if (file instanceof PsiJavaFile) { inferrer.collect(file); } } }); } }; if (ApplicationManager.getApplication().isDispatchThread()) { if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(searchForUsages, INFER_NULLITY_ANNOTATIONS, true, project)) { return null; } } else { searchForUsages.run(); } final List<UsageInfo> usages = new ArrayList<UsageInfo>(); inferrer.collect(usages); return usages.toArray(new UsageInfo[usages.size()]); }
private static boolean isIgnoredByBuild(VirtualFile file) { return FileTypeManager.getInstance().isFileIgnored(file) || ProjectUtil.isProjectOrWorkspaceFile(file) || FileUtil.isAncestor(PathManager.getConfigPath(), file.getPath(), false); // is config file }
public ChangelistConflictTracker(@NotNull Project project, @NotNull ChangeListManager changeListManager, @NotNull FileStatusManager fileStatusManager, @NotNull EditorNotifications editorNotifications) { myProject = project; myChangeListManager = changeListManager; myEditorNotifications = editorNotifications; myDocumentManager = FileDocumentManager.getInstance(); myFileStatusManager = fileStatusManager; myCheckSetLock = new Object(); myCheckSet = new HashSet<VirtualFile>(); final Application application = ApplicationManager.getApplication(); final ZipperUpdater zipperUpdater = new ZipperUpdater(300, myProject); final Runnable runnable = new Runnable() { @Override public void run() { if (application.runReadAction(new Computable<Boolean>() { @Override public Boolean compute() { return application.isDisposed() || myProject.isDisposed() || !myProject.isOpen(); } })) { return; } final Set<VirtualFile> localSet; synchronized (myCheckSetLock) { localSet = new HashSet<VirtualFile>(); localSet.addAll(myCheckSet); myCheckSet.clear(); } checkFiles(localSet); } }; myDocumentListener = new DocumentAdapter() { @Override public void documentChanged(DocumentEvent e) { if (!myOptions.TRACKING_ENABLED) { return; } Document document = e.getDocument(); VirtualFile file = myDocumentManager.getFile(document); if (ProjectUtil.guessProjectForFile(file) == myProject) { synchronized (myCheckSetLock) { myCheckSet.add(file); } zipperUpdater.queue(runnable); } } }; myChangeListListener = new ChangeListAdapter() { @Override public void changeListChanged(ChangeList list) { if (myChangeListManager.isDefaultChangeList(list)) { clearChanges(list.getChanges()); } } @Override public void changesMoved(Collection<Change> changes, ChangeList fromList, ChangeList toList) { if (myChangeListManager.isDefaultChangeList(toList)) { clearChanges(changes); } } @Override public void changesRemoved(Collection<Change> changes, ChangeList fromList) { clearChanges(changes); } @Override public void defaultListChanged(ChangeList oldDefaultList, ChangeList newDefaultList) { clearChanges(newDefaultList.getChanges()); } }; }
private int getAdjustedRightMargin() { int result = getRightMargin(); return result > 0 ? result : CodeStyleFacade.getInstance(ProjectUtil.guessCurrentProject(getPanel())).getRightMargin(getDefaultLanguage()); }
public final void applyPredefinedSettings(@NotNull PredefinedCodeStyle codeStyle) { CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(ProjectUtil.guessCurrentProject(getPanel())).clone(); codeStyle.apply(settings); reset(settings); onSomethingChanged(); }
private static UsageInfo[] findUsages(@NotNull final Project project, @NotNull final AnalysisScope scope, final int fileCount) { final NullityInferrer inferrer = new NullityInferrer(false, project); final PsiManager psiManager = PsiManager.getInstance(project); final Runnable searchForUsages = new Runnable() { @Override public void run() { scope.accept(new PsiElementVisitor() { int myFileCount = 0; @Override public void visitFile(final PsiFile file) { myFileCount++; final VirtualFile virtualFile = file.getVirtualFile(); final FileViewProvider viewProvider = psiManager.findViewProvider(virtualFile); final Document document = viewProvider == null ? null : viewProvider.getDocument(); if (document == null || virtualFile.getFileType().isBinary()) return; //do not inspect binary files final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator(); if (progressIndicator != null) { progressIndicator.setText2(ProjectUtil.calcRelativeToProjectPath(virtualFile, project)); progressIndicator.setFraction(((double)myFileCount) / fileCount); } if (file instanceof PsiJavaFile) { inferrer.collect(file); } } }); } }; if (ApplicationManager.getApplication().isDispatchThread()) { if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(searchForUsages, INFER_NULLITY_ANNOTATIONS, true, project)) { return null; } } else { searchForUsages.run(); } final List<UsageInfo> usages = new ArrayList<UsageInfo>(); inferrer.collect(usages); return usages.toArray(new UsageInfo[usages.size()]); }
@NotNull private ListItemWrapper<VirtualFile> createSourceRootItemWrapper(@NotNull VirtualFile candidateRoot) { String relativePath = ProjectUtil.calcRelativeToProjectPath(candidateRoot, dataSource.getProject(), true, false, true); return new ListItemWrapper<>(candidateRoot, relativePath, getSourceRootIcon(candidateRoot)); }