boolean (@NotNull final PsiElement psiElement, int offset, String text, @NotNull List<? super PsiReference> references, boolean soft) { FileReferenceSet set = new FileReferenceSet(text, psiElement, offset, null, true, true, new FileType[]{XmlFileType.INSTANCE}) { private final Condition<PsiFileSystemItem> PLUGIN_XML_CONDITION = item -> !item.isDirectory() && !item.equals(getContainingFile()) && (item instanceof XmlFile && DescriptorUtil.isPluginXml((PsiFile)item)) && !isAlreadyUsed((XmlFile)item); private boolean isAlreadyUsed(final XmlFile xmlFile) { final PsiFile file = getContainingFile(); if (!(file instanceof XmlFile)) return false; final IdeaPlugin ideaPlugin = DescriptorUtil.getIdeaPlugin((XmlFile)file); if (ideaPlugin == null) return false; return !ContainerUtil.process(ideaPlugin.getDepends(), dependency -> { final GenericAttributeValue<PathReference> configFileAttribute = dependency.getConfigFile(); if (!DomUtil.hasXml(configFileAttribute)) return true; final PathReference pathReference = configFileAttribute.getValue(); if (pathReference == null) return true; return !xmlFile.equals(pathReference.resolve()); }); } @NotNull @Override public Collection<PsiFileSystemItem> computeDefaultContexts() { final PsiFile containingFile = getContainingFile(); if (containingFile == null) { return Collections.emptyList(); } final Module module = ModuleUtilCore.findModuleForPsiElement(getElement()); if (module == null) { return Collections.emptyList(); } final Set<VirtualFile> roots = new HashSet<>(); final VirtualFile parent = containingFile.getVirtualFile().getParent(); roots.add(parent); for (VirtualFile sourceRoot : ModuleRootManager.getInstance(module).getSourceRoots(JavaModuleSourceRootTypes.PRODUCTION)) { roots.add(sourceRoot.findChild("META-INF")); } return toFileSystemItems(roots); } @Override protected boolean isSoft() { return true; } @Override protected Condition<PsiFileSystemItem> getReferenceCompletionFilter() { return PLUGIN_XML_CONDITION; } }; Collections.addAll(references, set.getAllReferences()); return true; }