@SuppressWarnings("OverlyBroadCatchBlock") private void multiCast(@NotNull Method method, Object[] args) { try { method.invoke(myBus.syncPublisher(AppTopics.FILE_DOCUMENT_SYNC), args); } catch (ClassCastException e) { LOG.error("Arguments: " + Arrays.toString(args), e); } catch (Exception e) { LOG.error(e); } // Allows pre-save document modification for (FileDocumentManagerListener listener : getListeners()) { try { method.invoke(listener, args); } catch (Exception e) { LOG.error(e); } } // stripping trailing spaces try { method.invoke(myTrailingSpacesStripper, args); } catch (Exception e) { LOG.error(e); } }
@NotNull protected final PsiElement[] invokeDialog(final Project project, final PsiDirectory directory) { log.debug("invokeDialog"); final MyInputValidator validator = new MyInputValidator(project, directory); Messages.showInputDialog( project, getDialogPrompt(), getDialogTitle(), Messages.getQuestionIcon(), "", validator); final PsiElement[] elements = validator.getCreatedElements(); log.debug("Result: " + Arrays.toString(elements)); return elements; }
@NotNull public VirtualFile[] getOpenFiles() { final ArrayListSet<VirtualFile> files = new ArrayListSet<VirtualFile>(); for (final EditorWindow myWindow : myWindows) { final EditorWithProviderComposite[] editors = myWindow.getEditors(); for (final EditorWithProviderComposite editor : editors) { final VirtualFile file = editor.getFile(); LOG.assertTrue(file.isValid(), Arrays.toString(editor.getProviders())); files.add(file); } } return VfsUtil.toVirtualFileArray(files); }
public static void attachJdkAnnotations(@NotNull SdkModificator modificator) { LocalFileSystem lfs = LocalFileSystem.getInstance(); List<String> pathsChecked = new ArrayList<>(); // community idea under idea String path = FileUtil.toSystemIndependentName(PathManager.getHomePath()) + "/java/jdkAnnotations"; VirtualFile root = lfs.findFileByPath(path); pathsChecked.add(path); if (root == null) { // idea under idea path = FileUtil.toSystemIndependentName(PathManager.getHomePath()) + "/community/java/jdkAnnotations"; root = lfs.findFileByPath(path); pathsChecked.add(path); } if (root == null) { // build String url = "jar://" + FileUtil.toSystemIndependentName(PathManager.getHomePath()) + "/lib/jdkAnnotations.jar!/"; root = VirtualFileManager.getInstance().findFileByUrl(url); pathsChecked.add( FileUtil.toSystemIndependentName(PathManager.getHomePath()) + "/lib/jdkAnnotations.jar"); } if (root == null) { String msg = "Paths checked:\n"; for (String p : pathsChecked) { File file = new File(p); msg += "Path: '" + p + "' " + (file.exists() ? "Found" : "Not found") + "; directory children: " + Arrays.toString(file.getParentFile().listFiles()) + "\n"; } LOG.error("JDK annotations not found", msg); return; } OrderRootType annoType = AnnotationOrderRootType.getInstance(); modificator.removeRoot(root, annoType); modificator.addRoot(root, annoType); }