@Override public void resolveEntryPoints(@NotNull final RefManager manager) { if (!myResolved) { myResolved = true; cleanup(); validateEntryPoints(); ApplicationManager.getApplication() .runReadAction( () -> { for (SmartRefElementPointer entryPoint : myPersistentEntryPoints.values()) { if (entryPoint.resolve(manager)) { RefEntity refElement = entryPoint.getRefElement(); ((RefElementImpl) refElement).setEntry(true); ((RefElementImpl) refElement).setPermanentEntry(entryPoint.isPersistent()); } } for (ClassPattern pattern : myPatterns) { final RefEntity refClass = manager.getReference(RefJavaManager.CLASS, pattern.pattern); if (refClass != null) { for (RefMethod constructor : ((RefClass) refClass).getConstructors()) { ((RefMethodImpl) constructor).setEntry(true); ((RefMethodImpl) constructor).setPermanentEntry(true); } } } }); } }
public void cleanup() { purgeTemporaryEntryPoints(); Collection<SmartRefElementPointer> entries = myPersistentEntryPoints.values(); for (SmartRefElementPointer entry : entries) { entry.freeReference(); } }
@Override @Nullable public QuickFixAction[] extractActiveFixes( @NotNull RefEntity[] refElements, @NotNull Map<RefEntity, Set<QuickFix>> actions) { Map<Class, QuickFixAction> result = new com.intellij.util.containers.HashMap<Class, QuickFixAction>(); for (RefEntity refElement : refElements) { final Set<QuickFix> localQuickFixes = actions.get(refElement); if (localQuickFixes == null) continue; for (QuickFix fix : localQuickFixes) { if (fix == null) continue; final Class klass = fix instanceof ActionClassHolder ? ((ActionClassHolder) fix).getActionClass() : fix.getClass(); final QuickFixAction quickFixAction = result.get(klass); if (quickFixAction != null) { try { String familyName = fix.getFamilyName(); familyName = !familyName.isEmpty() ? "\'" + familyName + "\'" : familyName; ((LocalQuickFixWrapper) quickFixAction) .setText( InspectionsBundle.message( "inspection.descriptor.provider.apply.fix", familyName)); } catch (AbstractMethodError e) { // for plugin compatibility ((LocalQuickFixWrapper) quickFixAction) .setText(InspectionsBundle.message("inspection.descriptor.provider.apply.fix", "")); } } else { LocalQuickFixWrapper quickFixWrapper = new LocalQuickFixWrapper(fix, myToolWrapper); result.put(klass, quickFixWrapper); } } } return result.values().isEmpty() ? null : result.values().toArray(new QuickFixAction[result.size()]); }
public RefElement[] getEntryPoints() { validateEntryPoints(); List<RefElement> entries = new ArrayList<RefElement>(); Collection<SmartRefElementPointer> collection = myPersistentEntryPoints.values(); for (SmartRefElementPointer refElementPointer : collection) { final RefEntity elt = refElementPointer.getRefElement(); if (elt instanceof RefElement) { entries.add((RefElement) elt); } } entries.addAll(myTemporaryEntryPoints); return entries.toArray(new RefElement[entries.size()]); }
@SuppressWarnings({"HardCodedStringLiteral"}) public static void writeExternal( final Element element, final Map<String, SmartRefElementPointer> persistentEntryPoints, final JDOMExternalizableStringList additional_annotations) { Element entryPointsElement = new Element("entry_points"); entryPointsElement.setAttribute(VERSION_ATTR, VERSION); for (SmartRefElementPointer entryPoint : persistentEntryPoints.values()) { assert entryPoint.isPersistent(); entryPoint.writeExternal(entryPointsElement); } element.addContent(entryPointsElement); if (!additional_annotations.isEmpty()) { additional_annotations.writeExternal(element); } }
@Override @NotNull public FileStatus getProblemStatus(@NotNull final CommonProblemDescriptor descriptor) { final GlobalInspectionContextImpl context = getContext(); if (!isDisposed() && context.getUIOptions().SHOW_DIFF_WITH_PREVIOUS_RUN) { if (myOldProblemElements != null) { final Set<CommonProblemDescriptor> allAvailable = new HashSet<CommonProblemDescriptor>(); for (CommonProblemDescriptor[] descriptors : myOldProblemElements.values()) { if (descriptors != null) { ContainerUtil.addAll(allAvailable, descriptors); } } final boolean old = containsDescriptor(descriptor, allAvailable); final boolean current = containsDescriptor(descriptor, getProblemToElements().keySet()); return calcStatus(old, current); } } return FileStatus.NOT_CHANGED; }
private void validateEntryPoints() { long count = PsiManager.getInstance(myProject).getModificationTracker().getModificationCount(); if (count != myLastModificationCount) { myLastModificationCount = count; Collection<SmartRefElementPointer> collection = myPersistentEntryPoints.values(); SmartRefElementPointer[] entries = collection.toArray(new SmartRefElementPointer[collection.size()]); for (SmartRefElementPointer entry : entries) { RefElement refElement = (RefElement) entry.getRefElement(); if (refElement != null && !refElement.isValid()) { myPersistentEntryPoints.remove(entry.getFQName()); } } final Iterator<RefElement> it = myTemporaryEntryPoints.iterator(); while (it.hasNext()) { RefElement refElement = it.next(); if (!refElement.isValid()) { it.remove(); } } } }