From eb60abccc3caa5075c828018f0ec813f5ef2845b Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 1 Oct 2014 15:58:30 +0200 Subject: [PATCH] cleanup --- .../openapi/project/impl/ProjectImpl.java | 82 +++++++++---------- 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java index 3012334644ae..e29b4ed788a2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java @@ -477,55 +477,53 @@ public class ProjectImpl extends PlatformComponentManagerImpl implements Project @Override public void checkUnknownMacros(final boolean showDialog) { final IProjectStore stateStore = getStateStore(); - - final TrackingPathMacroSubstitutor[] substitutors = stateStore.getSubstitutors(); - final Set unknownMacros = new HashSet(); - for (final TrackingPathMacroSubstitutor substitutor : substitutors) { + TrackingPathMacroSubstitutor[] substitutors = stateStore.getSubstitutors(); + Set unknownMacros = new THashSet(); + for (TrackingPathMacroSubstitutor substitutor : substitutors) { unknownMacros.addAll(substitutor.getUnknownMacros(null)); } - if (!unknownMacros.isEmpty()) { - if (!showDialog || ProjectMacrosUtil.checkMacros(this, new HashSet(unknownMacros))) { - final PathMacros pathMacros = PathMacros.getInstance(); - final Set macros2invalidate = new HashSet(unknownMacros); - for (Iterator it = macros2invalidate.iterator(); it.hasNext();) { - final String macro = (String)it.next(); - final String value = pathMacros.getValue(macro); - if ((value == null || value.trim().isEmpty()) && !pathMacros.isIgnoredMacroName(macro)) { - it.remove(); + if (unknownMacros.isEmpty() || (showDialog && !ProjectMacrosUtil.checkMacros(this, new THashSet(unknownMacros)))) { + return; + } + + final PathMacros pathMacros = PathMacros.getInstance(); + final Set macrosToInvalidate = new THashSet(unknownMacros); + for (Iterator it = macrosToInvalidate.iterator(); it.hasNext(); ) { + String macro = it.next(); + if (StringUtil.isEmptyOrSpaces(pathMacros.getValue(macro)) && !pathMacros.isIgnoredMacroName(macro)) { + it.remove(); + } + } + + if (!macrosToInvalidate.isEmpty()) { + final Set components = new THashSet(); + for (TrackingPathMacroSubstitutor substitutor : substitutors) { + components.addAll(substitutor.getComponents(macrosToInvalidate)); + } + + if (stateStore.isReloadPossible(components)) { + for (TrackingPathMacroSubstitutor substitutor : substitutors) { + substitutor.invalidateUnknownMacros(macrosToInvalidate); + } + + for (UnknownMacroNotification notification : NotificationsManager.getNotificationsManager().getNotificationsOfType(UnknownMacroNotification.class, this)) { + if (macrosToInvalidate.containsAll(notification.getMacros())) { + notification.expire(); } } - if (!macros2invalidate.isEmpty()) { - final Set components = new THashSet(); - for (TrackingPathMacroSubstitutor substitutor : substitutors) { - components.addAll(substitutor.getComponents(macros2invalidate)); - } - - if (stateStore.isReloadPossible(components)) { - for (final TrackingPathMacroSubstitutor substitutor : substitutors) { - substitutor.invalidateUnknownMacros(macros2invalidate); - } - - final UnknownMacroNotification[] notifications = - NotificationsManager.getNotificationsManager().getNotificationsOfType(UnknownMacroNotification.class, this); - for (final UnknownMacroNotification notification : notifications) { - if (macros2invalidate.containsAll(notification.getMacros())) notification.expire(); - } - - ApplicationManager.getApplication().runWriteAction(new Runnable() { - @Override - public void run() { - stateStore.reinitComponents(components, true); - } - }); - } - else { - if (Messages.showYesNoDialog(this, "Component could not be reloaded. Reload project?", "Configuration Changed", - Messages.getQuestionIcon()) == Messages.YES) { - ProjectManagerEx.getInstanceEx().reloadProject(this); - } + ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override + public void run() { + stateStore.reinitComponents(components, true); } + }); + } + else { + if (Messages.showYesNoDialog(this, "Component could not be reloaded. Reload project?", "Configuration Changed", + Messages.getQuestionIcon()) == Messages.YES) { + ProjectManagerEx.getInstanceEx().reloadProject(this); } } }