@NotNull @Override public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) { if (JNomadInspection.jnomad == null) { setupJNomad(); } List<EnvFileFullReport> fileFullReports; VirtualFile virtualFile = holder.getFile().getVirtualFile(); if (virtualFile.getPath().endsWith("java") && virtualFile instanceof VirtualFileImpl) { CharSequence contents = holder.getFile().getViewProvider().getContents(); fileFullReports = getFileFullReports(contents); return new JNomadQueryVisitor(holder, holder.getFile().getVirtualFile(), fileFullReports.toArray(new EnvFileFullReport[0])); } return new JNomadQueryVisitor(holder, holder.getFile().getVirtualFile(), null); }
public PerlRunProfileState(ExecutionEnvironment executionEnvironment) { this.executionEnvironment = executionEnvironment; this.project = executionEnvironment.getProject(); String file = ""; Object vFile = executionEnvironment.getDataContext().getData("virtualFile"); if(vFile != null && vFile instanceof VirtualFileImpl && ((VirtualFileImpl) vFile).getExtension().equals("pl")) { //get file path from context file = ((VirtualFileImpl) vFile).getPath(); }else{ //get file from selected text editor file = FileDocumentManager.getInstance().getFile(FileEditorManager.getInstance(executionEnvironment.getProject()).getSelectedTextEditor().getDocument()).toString(); } if(file.endsWith("pl")) { PerlCli.runFile(executionEnvironment.getProject(), file); } }
public static List<String> getAllFilesInDirectory(VirtualFile directory, String target, String replacement) { List<String> files = new ArrayList<String>(); VirtualFile[] children = directory.getChildren(); for (VirtualFile child : children) { if (child instanceof VirtualDirectoryImpl) { files.addAll(getAllFilesInDirectory(child, target, replacement)); } else if (child instanceof VirtualFileImpl) { files.add(child.getPath().replace(target, replacement)); } } return files; }