@NotNull @Override public Collection<PsiFile> getVariants(ConvertContext context) { List<PsiFile> result = new ArrayList<PsiFile>(); PsiFile currentFile = context.getFile().getOriginalFile(); for (DomFileElement<MavenDomProjectModel> each : MavenDomUtil.collectProjectModels(context.getFile().getProject())) { PsiFile file = each.getOriginalFile(); if (file == currentFile) continue; result.add(file); } return result; }
@Override public String toString(@Nullable PsiFile f, ConvertContext context) { if (f == null) return null; VirtualFile currentFile = context.getFile().getOriginalFile().getVirtualFile(); if (currentFile == null) return null; return MavenDomUtil.calcRelativePath(currentFile.getParent(), f.getVirtualFile()); }
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { GenericDomValue el = (GenericDomValue) myContext.getInvocationElement(); MavenId id = MavenArtifactCoordinatesHelper.getId(myContext); MavenProjectsManager manager = MavenProjectsManager.getInstance(project); MavenProject parentFile = manager.findProject(id); if (parentFile != null) { VirtualFile currentFile = myContext.getFile().getVirtualFile(); el.setStringValue( MavenDomUtil.calcRelativePath(currentFile.getParent(), parentFile.getFile())); } }
@Override public PsiFile fromString(@Nullable @NonNls String s, ConvertContext context) { if (StringUtil.isEmptyOrSpaces(s)) return null; VirtualFile contextFile = context.getFile().getVirtualFile(); if (contextFile == null) return null; VirtualFile f = contextFile.getParent().findFileByRelativePath(s); if (f == null) return null; if (f.isDirectory()) f = f.findFileByRelativePath(MavenConstants.POM_XML); if (f == null) return null; return context.getPsiManager().findFile(f); }