diff --git a/java/compiler/impl/src/com/intellij/compiler/OutputParser.java b/java/compiler/impl/src/com/intellij/compiler/OutputParser.java index 4f5c325155ee..37f688263173 100644 --- a/java/compiler/impl/src/com/intellij/compiler/OutputParser.java +++ b/java/compiler/impl/src/com/intellij/compiler/OutputParser.java @@ -15,9 +15,9 @@ */ package com.intellij.compiler; +import com.intellij.compiler.impl.javaCompiler.FileObject; import com.intellij.openapi.compiler.CompilerMessageCategory; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.compiler.impl.javaCompiler.FileObject; import org.jetbrains.annotations.NonNls; import java.util.ArrayList; @@ -29,6 +29,7 @@ public abstract class OutputParser { public interface Callback { @NonNls String getNextLine(); @NonNls String getCurrentLine(); + void pushBack(String line); void setProgressText(String text); void fileProcessed(@NonNls String path); void fileGenerated(@NonNls FileObject path); diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/CompilerParsingThread.java b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/CompilerParsingThread.java index 58e74794bec9..e440d1d8666f 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/CompilerParsingThread.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/CompilerParsingThread.java @@ -44,6 +44,7 @@ public class CompilerParsingThread implements Runnable, OutputParser.Callback { private final boolean myIsUnitTestMode; private FileObject myClassFileToProcess = null; private String myLastReadLine = null; + private String myPushBackLine = null; private volatile boolean myProcessExited = false; private final CompileContext myContext; @@ -104,6 +105,12 @@ public class CompilerParsingThread implements Runnable, OutputParser.Callback { } public final String getNextLine() { + final String pushBack = myPushBackLine; + if (pushBack != null) { + myPushBackLine = null; + myLastReadLine = pushBack; + return pushBack; + } final String line = readLine(myCompilerOutStreamReader); if (LOG.isDebugEnabled()) { LOG.debug("LIne read: #" + line + "#"); @@ -120,6 +127,12 @@ public class CompilerParsingThread implements Runnable, OutputParser.Callback { return myLastReadLine; } + @Override + public void pushBack(String line) { + myLastReadLine = null; + myPushBackLine = line; + } + public final void fileGenerated(FileObject path) { // javac first logs file generated, then starts to write the file to disk, // so this thread sometimes can stumble on not yet existing file, diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/javac/JavacOutputParser.java b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/javac/JavacOutputParser.java index b1c2e5c5e428..f5d106e3494f 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/javac/JavacOutputParser.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/javac/JavacOutputParser.java @@ -127,6 +127,14 @@ public class JavacOutputParser extends OutputParser { final CharSequence chars = prevLine == null ? line : prevLine; final int offset = Math.max(0, Math.min(chars.length(), nextLine.indexOf('^'))); colNum = EditorUtil.calcColumnNumber(null, chars,0, offset, myTabSize); + String messageEnd = callback.getNextLine(); + while (isMessageEnd(messageEnd)) { + messages.add(messageEnd.trim()); + messageEnd = callback.getNextLine(); + } + if (messageEnd != null) { + callback.pushBack(messageEnd); + } break; } if (prevLine != null) { @@ -168,6 +176,10 @@ public class JavacOutputParser extends OutputParser { return true; } + private static boolean isMessageEnd(String line) { + return line != null && line.length() > 0 && Character.isWhitespace(line.charAt(0)); + } + private static List convertMessages(List messages) { if(messages.size() <= 1) { diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/impl/LibraryUsageCollector.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/impl/LibraryUsageCollector.java index fdff8b12dd91..dad76bc77c8b 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/impl/LibraryUsageCollector.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraries/impl/LibraryUsageCollector.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.roots.ui.configuration.libraries.impl; +import com.intellij.internal.statistic.AbstractApplicationUsagesCollector; import com.intellij.internal.statistic.UsagesCollector; import com.intellij.internal.statistic.beans.GroupDescriptor; import com.intellij.internal.statistic.beans.UsageDescriptor; @@ -34,12 +35,13 @@ import java.util.*; /** * @author nik */ -public class LibraryUsageCollector extends UsagesCollector { +public class LibraryUsageCollector extends AbstractApplicationUsagesCollector { + @NonNls private static final String GROUP_ID = "libraries"; @NotNull @Override - public Set getUsages(@Nullable Project project) { + public Set getProjectUsages(@Nullable Project project) { if (project == null) return Collections.emptySet(); final Set> usedKinds = new HashSet>(); @@ -56,15 +58,13 @@ public class LibraryUsageCollector extends UsagesCollector { final HashSet usageDescriptors = new HashSet(); for (LibraryKind kind : usedKinds) { - final GroupDescriptor group = GroupDescriptor.create(GROUP_ID); - usageDescriptors.add(new UsageDescriptor(group, kind.getKindId(), 1)); + usageDescriptors.add(new UsageDescriptor(kind.getKindId(), 1)); } return usageDescriptors; } @NotNull @Override - public String getGroupId() { - return GROUP_ID; - } + public GroupDescriptor getGroupId() { + return GroupDescriptor.create(GROUP_ID); } } diff --git a/platform/lang-impl/src/com/intellij/facet/impl/statistics/FrameworkStatisticsPersistence.java b/platform/lang-impl/src/com/intellij/facet/impl/statistics/FrameworkStatisticsPersistence.java deleted file mode 100644 index b1d9a0894c75..000000000000 --- a/platform/lang-impl/src/com/intellij/facet/impl/statistics/FrameworkStatisticsPersistence.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2000-2010 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.intellij.facet.impl.statistics; - -import com.intellij.openapi.project.Project; -import com.intellij.internal.statistic.beans.UsageDescriptor; -import com.intellij.util.containers.HashMap; -import org.jetbrains.annotations.NotNull; - -import java.util.Map; -import java.util.Set; - -public abstract class FrameworkStatisticsPersistence { - private Map> myFrameworks = new HashMap>(); - - public FrameworkStatisticsPersistence() { - } - - public void persistFrameworks(@NotNull Project project, @NotNull Set frameworks) { - myFrameworks.put(project.getName(), frameworks); - } - - @NotNull - public Map> getFrameworks() { - return myFrameworks; - } - -} diff --git a/platform/lang-impl/src/com/intellij/facet/impl/statistics/FrameworkStatisticsPersistenceComponent.java b/platform/lang-impl/src/com/intellij/facet/impl/statistics/FrameworkStatisticsPersistenceComponent.java deleted file mode 100644 index 717dabff6e15..000000000000 --- a/platform/lang-impl/src/com/intellij/facet/impl/statistics/FrameworkStatisticsPersistenceComponent.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright 2000-2010 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.intellij.facet.impl.statistics; - -import com.intellij.internal.statistic.beans.UsageDescriptor; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.PathManager; -import com.intellij.openapi.components.ApplicationComponent; -import com.intellij.openapi.components.PersistentStateComponent; -import com.intellij.openapi.components.State; -import com.intellij.openapi.components.Storage; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ProjectManager; -import com.intellij.openapi.project.ProjectManagerListener; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.util.Function; -import com.intellij.util.containers.HashSet; -import org.jdom.Element; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; - -import java.io.File; -import java.util.List; -import java.util.Map; -import java.util.Set; - -@State( - name = "FrameworkUsages", - storages = { - @Storage( - id = "frameworks", - file = "$APP_CONFIG$/framework.usages.xml" - )} -) -public class FrameworkStatisticsPersistenceComponent extends FrameworkStatisticsPersistence - implements ApplicationComponent, PersistentStateComponent { - private static final String TOKENIZER = ","; - - @NonNls private static final String PROJECT_TAG = "project"; - @NonNls private static final String PROJECT_ID_ATTR = "id"; - @NonNls private static final String FRAMEWORKS_ATTR = "frameworks"; - - public FrameworkStatisticsPersistenceComponent() { - } - - public static FrameworkStatisticsPersistenceComponent getInstance() { - return ApplicationManager.getApplication().getComponent(FrameworkStatisticsPersistenceComponent.class); - } - - public void loadState(final Element element) { - List projectsList = element.getChildren(PROJECT_TAG); - for (Object project : projectsList) { - Element projectElement = (Element)project; - String projectId = projectElement.getAttributeValue(PROJECT_ID_ATTR); - String frameworks = projectElement.getAttributeValue(FRAMEWORKS_ATTR); - if (!StringUtil.isEmptyOrSpaces(projectId) && !StringUtil.isEmptyOrSpaces(frameworks)) { - Set frameworkDescriptors = new HashSet(); - for (String key : StringUtil.split(frameworks, TOKENIZER)) { - frameworkDescriptors.add(new UsageDescriptor(FrameworkUsagesCollector.getGroupDescriptor(), key, 1)); - } - getFrameworks().put(projectId, frameworkDescriptors); - } - } - } - - public Element getState() { - Element element = new Element("state"); - - for (Map.Entry> frameworks : getFrameworks().entrySet()) { - Element projectElement = new Element(PROJECT_TAG); - projectElement.setAttribute(PROJECT_ID_ATTR, frameworks.getKey()); - projectElement.setAttribute(FRAMEWORKS_ATTR, joinUsages(frameworks.getValue())); - - element.addContent(projectElement); - } - - return element; - } - - private static String joinUsages(@NotNull Set usages) { - return StringUtil.join(usages, new Function() { - @Override - public String fun(UsageDescriptor usageDescriptor) { - return usageDescriptor.getKey(); - } - }, TOKENIZER); - } - - @NotNull - @NonNls - public File[] getExportFiles() { - return new File[]{PathManager.getOptionsFile("framework.usages")}; - } - - @NotNull - public String getPresentableName() { - return "Framework Usages"; - } - - @NonNls - @NotNull - public String getComponentName() { - return "FrameworkStatisticsPersistenceComponent"; - } - - public void initComponent() { - ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerListener() { - @Override - public void projectOpened(Project project) { - } - - @Override - public boolean canCloseProject(Project project) { - return true; - } - - @Override - public void projectClosed(Project project) { - } - - @Override - public void projectClosing(Project project) { - if (project != null) { - FrameworkUsagesCollector.persistProjectUsages(project); - } - } - }); - } - - public void disposeComponent() { - } -} diff --git a/platform/lang-impl/src/com/intellij/facet/impl/statistics/FrameworkUsagesCollector.java b/platform/lang-impl/src/com/intellij/facet/impl/statistics/FrameworkUsagesCollector.java index abad35157269..30e78582fb7d 100644 --- a/platform/lang-impl/src/com/intellij/facet/impl/statistics/FrameworkUsagesCollector.java +++ b/platform/lang-impl/src/com/intellij/facet/impl/statistics/FrameworkUsagesCollector.java @@ -17,84 +17,31 @@ package com.intellij.facet.impl.statistics; import com.intellij.facet.Facet; import com.intellij.facet.FacetManager; +import com.intellij.internal.statistic.AbstractApplicationUsagesCollector; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.project.Project; -import com.intellij.internal.statistic.UsagesCollector; import com.intellij.internal.statistic.beans.GroupDescriptor; import com.intellij.internal.statistic.beans.UsageDescriptor; import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.HashSet; -import com.intellij.util.containers.hash.HashMap; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import java.util.Map; import java.util.Set; -public class FrameworkUsagesCollector extends UsagesCollector { +public class FrameworkUsagesCollector extends AbstractApplicationUsagesCollector { public static final String GROUP_ID = "frameworks"; - public static void persistProjectUsages(@NotNull Project project) { - persistProjectUsages(project, getProjectUsages(project)); - } - - public static void persistProjectUsages(@NotNull Project project, @NotNull Set usages) { - persistProjectUsages(project, usages, FrameworkStatisticsPersistenceComponent.getInstance()); - } - - public static void persistProjectUsages(@NotNull Project project, - @NotNull Set usages, - @NotNull FrameworkStatisticsPersistence persistence) { - persistence.persistFrameworks(project, usages); - } - - @NotNull - public Set getApplicationUsages() { - return getApplicationUsages(FrameworkStatisticsPersistenceComponent.getInstance()); - } - - @NotNull - public Set getApplicationUsages(@NotNull final FrameworkStatisticsPersistence persistence) { - final Map facets = new HashMap(); - - for (Set frameworks : persistence.getFrameworks().values()) { - for (UsageDescriptor framework : frameworks) { - final String key = framework.getKey(); - final Integer count = facets.get(key); - facets.put(key, count == null ? 1 : count.intValue() + 1); - } - } - - return ContainerUtil.map2Set(facets.entrySet(), new Function, UsageDescriptor>() { - @Override - public UsageDescriptor fun(Map.Entry facet) { - return new UsageDescriptor(getGroupDescriptor(), facet.getKey(), facet.getValue()); - } - }); - } - @NotNull @Override - public String getGroupId() { - return GROUP_ID; - } - - public static GroupDescriptor getGroupDescriptor() { + public GroupDescriptor getGroupId() { return GroupDescriptor.create(GROUP_ID, GroupDescriptor.HIGHER_PRIORITY); } + @NotNull - public Set getUsages(@Nullable Project project) { - if (project != null) { - persistProjectUsages(project, getProjectUsages(project)); - } - - return getApplicationUsages(); - } - - public static Set getProjectUsages(@NotNull Project project) { + public Set getProjectUsages(@NotNull Project project) { final Set facets = new HashSet(); for (Module module : ModuleManager.getInstance(project).getModules()) { for (Facet facet : FacetManager.getInstance(module).getAllFacets()) { @@ -105,7 +52,7 @@ public class FrameworkUsagesCollector extends UsagesCollector { return ContainerUtil.map2Set(facets, new Function() { @Override public UsageDescriptor fun(String facet) { - return new UsageDescriptor(getGroupDescriptor(), facet, 1); + return new UsageDescriptor(facet, 1); } }); } diff --git a/platform/platform-impl/src/com/intellij/featureStatistics/FeaturesUsageCollector.java b/platform/platform-impl/src/com/intellij/featureStatistics/FeaturesUsageCollector.java index b983a6d9adc1..44bec87c2dd1 100644 --- a/platform/platform-impl/src/com/intellij/featureStatistics/FeaturesUsageCollector.java +++ b/platform/platform-impl/src/com/intellij/featureStatistics/FeaturesUsageCollector.java @@ -29,8 +29,8 @@ public class FeaturesUsageCollector extends UsagesCollector { @NotNull @Override - public String getGroupId() { - return "productivity"; + public GroupDescriptor getGroupId() { + return GroupDescriptor.create("productivity", GroupDescriptor.LOWER_PRIORITY); } @NotNull @@ -44,8 +44,7 @@ public class FeaturesUsageCollector extends UsagesCollector { for (String featureId : registry.getFeatureIds()) { final FeatureDescriptor featureDescriptor = registry.getFeatureDescriptor(featureId); if (featureDescriptor != null) { - usages.add(new UsageDescriptor( - GroupDescriptor.create(getGroupId(), GroupDescriptor.LOWER_PRIORITY), featureId, featureDescriptor.getUsageCount())); + usages.add(new UsageDescriptor(featureId, featureDescriptor.getUsageCount())); } } diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginsUsagesCollector.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginsUsagesCollector.java index 006b58967ada..c4fc51be1450 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginsUsagesCollector.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginsUsagesCollector.java @@ -30,8 +30,8 @@ public class PluginsUsagesCollector extends UsagesCollector { private static final String GROUP_ID = "disabled-plugins"; @NotNull - public String getGroupId() { - return GROUP_ID; + public GroupDescriptor getGroupId() { + return GroupDescriptor.create(GROUP_ID, GroupDescriptor.HIGHER_PRIORITY); } @NotNull @@ -39,7 +39,7 @@ public class PluginsUsagesCollector extends UsagesCollector { return ContainerUtil.map2Set(PluginManager.getDisabledPlugins(), new Function() { @Override public UsageDescriptor fun(String descriptor) { - return new UsageDescriptor(GroupDescriptor.create(getGroupId(), GroupDescriptor.HIGHER_PRIORITY), descriptor, 1); + return new UsageDescriptor(descriptor, 1); } }); } diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/AbstractApplicationUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/AbstractApplicationUsagesCollector.java new file mode 100644 index 000000000000..f7173bc60d65 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/AbstractApplicationUsagesCollector.java @@ -0,0 +1,82 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.internal.statistic; + +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.persistence.ApplicationStatisticsPersistence; +import com.intellij.internal.statistic.persistence.ApplicationStatisticsPersistenceComponent; +import com.intellij.openapi.project.Project; +import com.intellij.util.Function; +import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.containers.hash.HashMap; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Map; +import java.util.Set; + +public abstract class AbstractApplicationUsagesCollector extends UsagesCollector { + public void persistProjectUsages(@NotNull Project project) { + persistProjectUsages(project, getProjectUsages(project)); + } + + public void persistProjectUsages(@NotNull Project project, @NotNull Set usages) { + persistProjectUsages(project, usages, ApplicationStatisticsPersistenceComponent.getInstance()); + } + + public void persistProjectUsages(@NotNull Project project, + @NotNull Set usages, + @NotNull ApplicationStatisticsPersistence persistence) { + persistence.persistFrameworks(getGroupId(), project, usages); + } + + @NotNull + public Set getApplicationUsages() { + return getApplicationUsages(ApplicationStatisticsPersistenceComponent.getInstance()); + } + + @NotNull + public Set getApplicationUsages(@NotNull final ApplicationStatisticsPersistence persistence) { + final Map facets = new HashMap(); + + for (Set frameworks : persistence.getApplicationData(getGroupId()).values()) { + for (UsageDescriptor framework : frameworks) { + final String key = framework.getKey(); + final Integer count = facets.get(key); + facets.put(key, count == null ? 1 : count.intValue() + 1); + } + } + + return ContainerUtil.map2Set(facets.entrySet(), new Function, UsageDescriptor>() { + @Override + public UsageDescriptor fun(Map.Entry facet) { + return new UsageDescriptor(facet.getKey(), facet.getValue()); + } + }); + } + + @NotNull + public Set getUsages(@Nullable Project project) { + if (project != null) { + persistProjectUsages(project, getProjectUsages(project)); + } + + return getApplicationUsages(); + } + + @NotNull + public abstract Set getProjectUsages(@NotNull Project project); +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/StatisticsUploadAssistant.java b/platform/platform-impl/src/com/intellij/internal/statistic/StatisticsUploadAssistant.java index b6a2105b5064..ac676de86be8 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/StatisticsUploadAssistant.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/StatisticsUploadAssistant.java @@ -30,7 +30,7 @@ import com.intellij.openapi.util.Pair; import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.HashSet; -import com.intellij.util.text.DateFormatUtil; +import com.intellij.util.containers.hash.HashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -38,173 +38,204 @@ import java.util.*; public class StatisticsUploadAssistant { - public String getData() { - return getData(Collections.emptySet()); - } + public String getData() { + return getData(Collections.emptySet()); + } - public static boolean showNotification() { - return UsageStatisticsPersistenceComponent.getInstance().isShowNotification(); - } + public static boolean showNotification() { + return UsageStatisticsPersistenceComponent.getInstance().isShowNotification(); + } - public static boolean isTimeToSend() { - if (ApplicationManagerEx.getApplicationEx().isInternal()) return true; // todo remove + public static boolean isTimeToSend() { + if (ApplicationManagerEx.getApplicationEx().isInternal()) return true; // todo remove - return isTimeToSend(UsageStatisticsPersistenceComponent.getInstance()); - } + return isTimeToSend(UsageStatisticsPersistenceComponent.getInstance()); + } - public static boolean isTimeToSend(UsageStatisticsPersistenceComponent settings) { - final long timeDelta = System.currentTimeMillis() - settings.getLastTimeSent(); + public static boolean isTimeToSend(UsageStatisticsPersistenceComponent settings) { + final long timeDelta = System.currentTimeMillis() - settings.getLastTimeSent(); - return Math.abs(timeDelta) > settings.getPeriod().getMillis(); - } + return Math.abs(timeDelta) > settings.getPeriod().getMillis(); + } - public static boolean isSendAllowed() { - if (ApplicationManagerEx.getApplicationEx().isInternal()) return true; // todo remove + public static boolean isSendAllowed() { + if (ApplicationManagerEx.getApplicationEx().isInternal()) return true; // todo remove - return isSendAllowed(UsageStatisticsPersistenceComponent.getInstance()); - } + return isSendAllowed(UsageStatisticsPersistenceComponent.getInstance()); + } - public static boolean isSendAllowed(final SentUsagesPersistence settings) { - return settings != null && settings.isAllowed(); - } + public static boolean isSendAllowed(final SentUsagesPersistence settings) { + return settings != null && settings.isAllowed(); + } - public static String getData(@NotNull Set disabledGroups) { - return getStringPatch(disabledGroups, ProjectManager.getInstance().getOpenProjects()); - } + public static String getData(@NotNull Set disabledGroups) { + return getStringPatch(disabledGroups, ProjectManager.getInstance().getOpenProjects()); + } - public static void persistSentPatch(@NotNull String patchStr) { - persistSentPatch(patchStr, UsageStatisticsPersistenceComponent.getInstance()); - } + public static void persistSentPatch(@NotNull String patchStr) { + persistSentPatch(patchStr, UsageStatisticsPersistenceComponent.getInstance()); + } - public static void persistSentPatch(@NotNull String patchStr, @NotNull SentUsagesPersistence persistenceComponent) { - Set patchedUsages = - ContainerUtil.map2Set(ConvertUsagesUtil.convertString(patchStr), new Function() { - @Override - public PatchedUsage fun(UsageDescriptor usageDescriptor) { - return new PatchedUsage(usageDescriptor); + public static void persistSentPatch(@NotNull String patchStr, @NotNull SentUsagesPersistence persistenceComponent) { + Map> patchedUsages = mapToPatchedUsagesMap(ConvertUsagesUtil.convertString(patchStr)); + + if (patchedUsages.size() > 0) persistenceComponent.persistPatch(patchedUsages); + } + + @NotNull + public static String getStringPatch(@NotNull Set disabledGroups, Project... project) { + return getStringPatch(disabledGroups, project, UsageStatisticsPersistenceComponent.getInstance(), 0); + } + + @NotNull + public static String getStringPatch(@NotNull Set disabledGroups, + @NotNull Project[] projects, + @NotNull SentUsagesPersistence usagesPersistence, + int maxSize) { + final Map> patchedUsages = getPatchedUsages(disabledGroups, projects, usagesPersistence); + + return getStringPatch(patchedUsages, maxSize); + } + + public static String getStringPatch(@NotNull Map> patchedUsages, int maxSize) { + if (patchedUsages.size() == 0) return ""; + + String patchStr = ConvertUsagesUtil.convertUsages(patchedUsages); + if (maxSize > 0 && patchStr.getBytes().length > maxSize) { + patchStr = ConvertUsagesUtil.cutPatchString(patchStr, maxSize); } - }); - if (patchedUsages.size() > 0) persistenceComponent.persistPatch(patchedUsages); - } - - @NotNull - public static String getStringPatch(@NotNull Set disabledGroups, Project... project) { - return getStringPatch(disabledGroups, project, UsageStatisticsPersistenceComponent.getInstance(), 0); - } - - @NotNull - public static String getStringPatch(@NotNull Set disabledGroups, - @NotNull Project[] projects, - @NotNull SentUsagesPersistence usagesPersistence, - int maxSize) { - final Set patchedUsages = getPatchedUsages(disabledGroups, projects, usagesPersistence); - - return getStringPatch(patchedUsages, maxSize); - } - - public static String getStringPatch(@NotNull Set patchedUsages, int maxSize) { - if (patchedUsages.size() == 0) return ""; - - String patchStr = ConvertUsagesUtil.convertUsages(patchedUsages); - if (maxSize > 0 && patchStr.getBytes().length > maxSize) { - patchStr = ConvertUsagesUtil.cutPatchString(patchStr, maxSize); + return patchStr; } - return patchStr; - } + @NotNull + public static Map> getPatchedUsages(@NotNull Set disabledGroups, + @NotNull Project[] projects, + @NotNull SentUsagesPersistence usagesPersistence) { + Map> usages = new HashMap>(); - @NotNull - public static Set getPatchedUsages(@NotNull Set disabledGroups, - @NotNull Project[] projects, - @NotNull SentUsagesPersistence usagesPersistence) { - Set usages = new HashSet(); + for (Project project : projects) { + final Map> allUsages = getAllUsages(project, disabledGroups); + final Map> sentUsages = filterDisabled(disabledGroups, usagesPersistence.getSentUsages()); - for (Project project : projects) { - final Set allUsages = getAllUsages(project, disabledGroups); - final Set sentUsages = filterDisabled(disabledGroups, usagesPersistence.getSentUsages()); - - usages.addAll(getPatchedUsages(allUsages, sentUsages)); - } - return usages; - } - - private static Set filterDisabled(@NotNull Set disabledGroups, @NotNull Set usages) { - Set filtered = new HashSet(); - - for (UsageDescriptor usage : usages) { - if (!disabledGroups.contains(usage.getGroup().getId())) { - filtered.add(usage); - } - } - return filtered; - } - - @NotNull - public static Set getPatchedUsages(@NotNull final Set allUsages, - @NotNull SentUsagesPersistence usagesPersistence) { - return getPatchedUsages(allUsages, usagesPersistence.getSentUsages()); - } - - @NotNull - public static Set getPatchedUsages(@NotNull final Set allUsages, final Set sentUsages) { - final Set patchedUsages = ContainerUtil.map2Set(allUsages, new Function() { - @Override - public PatchedUsage fun(UsageDescriptor usageDescriptor) { - return new PatchedUsage(usageDescriptor); - } - }); - - for (UsageDescriptor sentUsage : sentUsages) { - final PatchedUsage descriptor = findDescriptor(patchedUsages, Pair.create(sentUsage.getGroup(), sentUsage.getKey())); - if (descriptor == null) { - patchedUsages.add(new PatchedUsage(sentUsage.getGroup(), sentUsage.getKey(), -sentUsage.getValue())); - } - else { - descriptor.subValue(sentUsage.getValue()); - } + usages.putAll(getPatchedUsages(allUsages, sentUsages)); + } + return usages; } - return packCollection(patchedUsages, new Condition() { - @Override - public boolean value(PatchedUsage patchedUsage) { - return patchedUsage.getDelta() != 0; - } - }); - } + @NotNull + private static Map> filterDisabled(@NotNull Set disabledGroups, @NotNull Map> usages) { + Map> filtered = new HashMap>(); - @NotNull - private static Set packCollection(@NotNull Collection set, @NotNull Condition condition) { - final Set result = new LinkedHashSet(); - for (T t : set) { - if (condition.value(t)) { - result.add(t); - } + for (Map.Entry> usage : usages.entrySet()) { + if (!disabledGroups.contains(usage.getKey().getId())) { + filtered.put(usage.getKey(), usage.getValue()); + } + } + return filtered; } - return result; - } - - @Nullable - public static T findDescriptor(@NotNull Set descriptors, - @NotNull final Pair id) { - return ContainerUtil.find(descriptors, new Condition() { - @Override - public boolean value(T t) { - return id.getFirst().equals(t.getGroup()) && id.getSecond().equals(t.getKey()); - } - }); - } - - @NotNull - public static Set getAllUsages(@Nullable Project project, @NotNull Set disabledGroups) { - final Set usageDescriptors = new TreeSet(); - - for (UsagesCollector usagesCollector : Extensions.getExtensions(UsagesCollector.EP_NAME)) { - if (!disabledGroups.contains(usagesCollector.getGroupId())) { - usageDescriptors.addAll(usagesCollector.getUsages(project)); - } + + @NotNull + public static Map> getPatchedUsages(@NotNull final Map> allUsages, + @NotNull SentUsagesPersistence usagesPersistence) { + return getPatchedUsages(allUsages, usagesPersistence.getSentUsages()); + } + + @NotNull + public static Map> getPatchedUsages(@NotNull final Map> allUsages, final Map> sentUsageMap) { + Map> patchedUsages = mapToPatchedUsagesMap(allUsages); + + for (Map.Entry> sentUsageEntry : sentUsageMap.entrySet()) { + final GroupDescriptor sentUsageGroupDescriptor = sentUsageEntry.getKey(); + + final Set sentUsages = sentUsageEntry.getValue(); + + for (UsageDescriptor sentUsage : sentUsages) { + final PatchedUsage descriptor = findDescriptor(patchedUsages, Pair.create(sentUsageGroupDescriptor, sentUsage.getKey())); + if (descriptor == null) { + if (!patchedUsages.containsKey(sentUsageGroupDescriptor)) { + patchedUsages.put(sentUsageGroupDescriptor, new HashSet()); + } + patchedUsages.get(sentUsageGroupDescriptor).add(new PatchedUsage(sentUsage.getKey(), -sentUsage.getValue())); + } else { + descriptor.subValue(sentUsage.getValue()); + } + } + + } + + return packCollection(patchedUsages, new Condition() { + @Override + public boolean value(PatchedUsage patchedUsage) { + return patchedUsage.getDelta() != 0; + } + }); + } + + private static Map> mapToPatchedUsagesMap(Map> allUsages) { + Map> patchedUsages = new HashMap>(); + for (Map.Entry> entry : allUsages.entrySet()) { + patchedUsages.put(entry.getKey(), ContainerUtil.map2Set(entry.getValue(), new Function() { + @Override + public PatchedUsage fun(UsageDescriptor usageDescriptor) { + return new PatchedUsage(usageDescriptor); + } + })); + } + return patchedUsages; + } + + @NotNull + private static Map> packCollection(@NotNull Map> patchedUsages, Condition condition) { + Map> result = new HashMap>(); + for (GroupDescriptor descriptor : patchedUsages.keySet()) { + final Set usages = packCollection(patchedUsages.get(descriptor), condition); + if (usages.size() > 0) { + result.put(descriptor, usages); + } + } + + return result; + } + + @NotNull + private static Set packCollection(@NotNull Collection set, @NotNull Condition condition) { + final Set result = new LinkedHashSet(); + for (T t : set) { + if (condition.value(t)) { + result.add(t); + } + } + return result; + } + + @Nullable + public static T findDescriptor(@NotNull Map> descriptors, + @NotNull final Pair id) { + final Set usages = descriptors.get(id.getFirst()); + if (usages == null) return null; + + return ContainerUtil.find(usages, new Condition() { + @Override + public boolean value(T t) { + return id.getSecond().equals(t.getKey()); + } + }); + } + + @NotNull + public static Map> getAllUsages(@Nullable Project project, @NotNull Set disabledGroups) { + Map> usageDescriptors = new HashMap>(); + + for (UsagesCollector usagesCollector : Extensions.getExtensions(UsagesCollector.EP_NAME)) { + final GroupDescriptor groupDescriptor = usagesCollector.getGroupId(); + + if (!disabledGroups.contains(groupDescriptor.getId())) { + usageDescriptors.put(groupDescriptor, usagesCollector.getUsages(project)); + } + } + + return usageDescriptors; } - return usageDescriptors; - } } diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/UsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/UsagesCollector.java index e07246e0556a..46e03564bf5d 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/UsagesCollector.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/UsagesCollector.java @@ -15,6 +15,7 @@ */ package com.intellij.internal.statistic; +import com.intellij.internal.statistic.beans.GroupDescriptor; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.project.Project; import com.intellij.internal.statistic.beans.UsageDescriptor; @@ -28,5 +29,5 @@ public abstract class UsagesCollector { public abstract @NotNull Set getUsages(@Nullable Project project); - public abstract @NotNull String getGroupId(); + public abstract @NotNull GroupDescriptor getGroupId(); } diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/beans/ConvertUsagesUtil.java b/platform/platform-impl/src/com/intellij/internal/statistic/beans/ConvertUsagesUtil.java index 8fd58411e437..e8f2c6e8acd8 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/beans/ConvertUsagesUtil.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/beans/ConvertUsagesUtil.java @@ -16,6 +16,8 @@ package com.intellij.internal.statistic.beans; +import com.intellij.util.containers.hash.HashMap; + import java.util.*; public class ConvertUsagesUtil { @@ -26,19 +28,14 @@ public class ConvertUsagesUtil { private ConvertUsagesUtil() { } - // @NotNull - public static String convertUsages(Set descriptors) { - assert descriptors != null; - final Map> descriptorGroups = groupDescriptors(descriptors); - - return convertUsages(descriptorGroups); - } // @NotNull - public static String convertUsages(Map> map) { + public static String convertUsages(Map> map) { assert map != null; + final Map> sortedMap = sortDescriptorsByPriority(map); + StringBuffer buffer = new StringBuffer(); - for (Map.Entry> entry : map.entrySet()) { + for (Map.Entry> entry : sortedMap.entrySet()) { buffer.append(entry.getKey().getId()); buffer.append(GROUP_SEPARATOR); buffer.append(convertValueMap(entry.getValue())); @@ -49,7 +46,7 @@ public class ConvertUsagesUtil { } //@NotNull - public static String convertValueMap(Set descriptors) { + public static String convertValueMap(Set descriptors) { assert descriptors != null; final StringBuffer buffer = new StringBuffer(); for (UsageDescriptor usageDescriptor : descriptors) { @@ -76,14 +73,14 @@ public class ConvertUsagesUtil { } //@NotNull - public static Set convertString(String usages) { + public static Map> convertString(String usages) { assert usages != null; - Set descriptors = new LinkedHashSet(); + Map> descriptors = new HashMap>(); for (String groupStr : usages.split(GROUPS_SEPARATOR.toString())) { if (!isEmptyOrSpaces(groupStr)) { final StringPair group = getPair(groupStr, GROUP_SEPARATOR.toString()); if (group != null) { - descriptors.addAll(convertValueString(GroupDescriptor.create(group.first), group.second)); + descriptors.putAll(convertValueString(GroupDescriptor.create(group.first), group.second)); } } } @@ -91,9 +88,9 @@ public class ConvertUsagesUtil { } //@NotNull - public static Set convertValueString(GroupDescriptor groupId, String valueData) { + public static Map> convertValueString(GroupDescriptor groupId, String valueData) { assert groupId != null; - final Set descriptors = new LinkedHashSet(); + final Map> descriptors = new HashMap>(); for (String value : valueData.split(GROUP_VALUE_SEPARATOR.toString())) { if (!isEmptyOrSpaces(value)) { final StringPair pair = getPair(value, "="); @@ -102,7 +99,10 @@ public class ConvertUsagesUtil { if (!isEmptyOrSpaces(count)) { try { final int i = Integer.parseInt(count); - descriptors.add(new UsageDescriptor(groupId, pair.first, i)); + if (!descriptors.containsKey(groupId)) { + descriptors.put(groupId, new LinkedHashSet()); + } + descriptors.get(groupId).add(new UsageDescriptor(pair.first, i)); } catch (NumberFormatException ignored) { } } @@ -129,22 +129,17 @@ public class ConvertUsagesUtil { } //@NotNull - public static Map> groupDescriptors(Set descriptors) { + public static Map> sortDescriptorsByPriority(Map> descriptors) { assert descriptors != null; - final SortedMap> map = new TreeMap>(new Comparator() { + final SortedMap> map = new TreeMap>(new Comparator() { public int compare(GroupDescriptor g1, GroupDescriptor g2) { final int priority = (int) (g2.getPriority() - g1.getPriority()); return priority == 0 ? g1.getId().compareTo(g2.getId()) : priority; } }); - for (UsageDescriptor descriptor : descriptors) { - final GroupDescriptor group = descriptor.getGroup(); - if (!map.containsKey(group)) { - map.put(group, new HashSet()); - } - map.get(group).add(descriptor); - } + map.putAll(descriptors); + return map; } @@ -158,7 +153,7 @@ public class ConvertUsagesUtil { } } - public static boolean isEmptyOrSpaces(final String s) { - return s == null || s.trim().length() == 0; - } + public static boolean isEmptyOrSpaces(final String s) { + return s == null || s.trim().length() == 0; + } } diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/beans/PatchedUsage.java b/platform/platform-impl/src/com/intellij/internal/statistic/beans/PatchedUsage.java index f91433e4b6bb..f300bd74362f 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/beans/PatchedUsage.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/beans/PatchedUsage.java @@ -18,11 +18,11 @@ package com.intellij.internal.statistic.beans; public class PatchedUsage extends UsageDescriptor { public PatchedUsage(UsageDescriptor descriptor) { - super(descriptor.getGroup(), descriptor.getKey(), descriptor.getValue()); + super(descriptor.getKey(), descriptor.getValue()); } - public PatchedUsage(GroupDescriptor group, String key, int value) { - super(group, key, value); + public PatchedUsage(String key, int value) { + super(key, value); } public int getDelta() { diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/beans/UsageDescriptor.java b/platform/platform-impl/src/com/intellij/internal/statistic/beans/UsageDescriptor.java index 2ec188afa17d..4b5a4c9c66d6 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/beans/UsageDescriptor.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/beans/UsageDescriptor.java @@ -16,15 +16,12 @@ package com.intellij.internal.statistic.beans; public class UsageDescriptor implements Comparable { - private final GroupDescriptor myGroup; private final String myKey; private int myValue; - public UsageDescriptor(GroupDescriptor group, String key, int value) { - assert group != null; - assert key != null; + public UsageDescriptor(String key, int value) { + assert key != null; - myGroup = group; myKey = key; myValue = value; } @@ -33,10 +30,6 @@ public class UsageDescriptor implements Comparable { return myKey; } - public GroupDescriptor getGroup() { - return myGroup; - } - public int getValue() { return myValue; } @@ -45,29 +38,15 @@ public class UsageDescriptor implements Comparable { myValue = i; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof UsageDescriptor)) return false; - - UsageDescriptor that = (UsageDescriptor) o; - - if (!myGroup.equals(that.myGroup)) return false; - if (!myKey.equals(that.myKey)) return false; - - return true; + public int getMyValue() { + return myValue; } - @Override - public int hashCode() { - int result = myGroup.hashCode(); - result = 31 * result + myKey.hashCode(); - return result; + public void setMyValue(int myValue) { + this.myValue = myValue; } public int compareTo(UsageDescriptor ud) { - final int byGroup = this.getGroup().compareTo(ud.getGroup()); - - return byGroup == 0 ? this.getKey().compareTo(ud.myKey) : byGroup; + return this.getKey().compareTo(ud.myKey); } } diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/configurable/StatisticsConfigurable.java b/platform/platform-impl/src/com/intellij/internal/statistic/configurable/StatisticsConfigurable.java index 9af6117dbd03..c7ff27d0a279 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/configurable/StatisticsConfigurable.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/configurable/StatisticsConfigurable.java @@ -29,7 +29,18 @@ import javax.swing.*; public class StatisticsConfigurable implements SearchableConfigurable { - private StatisticsConfigurationComponent myConfig; + private boolean modifiedByDefault; + + public StatisticsConfigurable() { + this(false); + } + + public StatisticsConfigurable(boolean isModifiedByDefault) { + modifiedByDefault = isModifiedByDefault; + } + + + private StatisticsConfigurationComponent myConfig; @Nls public String getDisplayName() { @@ -56,7 +67,7 @@ public class StatisticsConfigurable implements SearchableConfigurable { final UsageStatisticsPersistenceComponent persistenceComponent = UsageStatisticsPersistenceComponent.getInstance(); return myConfig.isAllowed() != persistenceComponent.isAllowed() || myConfig.getPeriod() != persistenceComponent.getPeriod() || - persistenceComponent.isShowNotification(); + modifiedByDefault; } public void apply() throws ConfigurationException { @@ -65,6 +76,7 @@ public class StatisticsConfigurable implements SearchableConfigurable { persistenceComponent.setPeriod(myConfig.getPeriod()); persistenceComponent.setAllowed(myConfig.isAllowed()); persistenceComponent.setShowNotification(false); + modifiedByDefault = false; } public void reset() { diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/persistence/ApplicationStatisticsPersistence.java b/platform/platform-impl/src/com/intellij/internal/statistic/persistence/ApplicationStatisticsPersistence.java new file mode 100644 index 000000000000..b5021df47287 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/persistence/ApplicationStatisticsPersistence.java @@ -0,0 +1,37 @@ +package com.intellij.internal.statistic.persistence; + +import com.intellij.internal.statistic.beans.GroupDescriptor; +import com.intellij.openapi.project.Project; +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.util.containers.HashMap; +import org.jetbrains.annotations.NotNull; + +import java.util.Map; +import java.util.Set; + +public abstract class ApplicationStatisticsPersistence { + private Map>> myApplicationData = new HashMap>>(); + + public ApplicationStatisticsPersistence() { + } + + public void persistFrameworks(@NotNull GroupDescriptor groupDescriptor, @NotNull Project project, @NotNull Set frameworks) { + if (!myApplicationData.containsKey(groupDescriptor)) { + myApplicationData.put(groupDescriptor, new HashMap>()); + } + myApplicationData.get(groupDescriptor).put(project.getName(), frameworks); + } + + @NotNull + public Map> getApplicationData(@NotNull GroupDescriptor groupDescriptor) { + final Map> map = myApplicationData.get(groupDescriptor); + + return map == null ? new HashMap>(): map; + } + + @NotNull + public Map>> getApplicationData() { + return myApplicationData; + } + +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/persistence/ApplicationStatisticsPersistenceComponent.java b/platform/platform-impl/src/com/intellij/internal/statistic/persistence/ApplicationStatisticsPersistenceComponent.java new file mode 100644 index 000000000000..fb8d0fd6bffe --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/persistence/ApplicationStatisticsPersistenceComponent.java @@ -0,0 +1,184 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.intellij.internal.statistic.persistence; + +import com.intellij.internal.statistic.AbstractApplicationUsagesCollector; +import com.intellij.internal.statistic.UsagesCollector; +import com.intellij.internal.statistic.beans.GroupDescriptor; +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.PathManager; +import com.intellij.openapi.components.ApplicationComponent; +import com.intellij.openapi.components.PersistentStateComponent; +import com.intellij.openapi.components.State; +import com.intellij.openapi.components.Storage; +import com.intellij.openapi.extensions.Extensions; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.project.ProjectManager; +import com.intellij.openapi.project.ProjectManagerListener; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.util.Function; +import com.intellij.util.containers.HashSet; +import org.jdom.Element; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; + +import java.io.File; +import java.util.List; +import java.util.Map; +import java.util.Set; + +@State( + name = "StatisticsApplicationUsages", + storages = { + @Storage( + id = "statistics.application.usages", + file = "$APP_CONFIG$/statistics.application.usages.xml" + )} +) +public class ApplicationStatisticsPersistenceComponent extends ApplicationStatisticsPersistence + implements ApplicationComponent, PersistentStateComponent { + private static final String TOKENIZER = ","; + + @NonNls + private static final String GROUP_TAG = "group"; + @NonNls + private static final String GROUP_NAME_ATTR = "name"; + + @NonNls + private static final String PROJECT_TAG = "project"; + @NonNls + private static final String PROJECT_ID_ATTR = "id"; + @NonNls + private static final String VALUES_ATTR = "values"; + + public ApplicationStatisticsPersistenceComponent() { + } + + public static ApplicationStatisticsPersistenceComponent getInstance() { + return ApplicationManager.getApplication().getComponent(ApplicationStatisticsPersistenceComponent.class); + } + + public void loadState(final Element element) { + List groups = element.getChildren(GROUP_TAG); + + for (Object group : groups) { + Element groupElement = (Element) group; + String groupName = groupElement.getAttributeValue(GROUP_NAME_ATTR); + + final GroupDescriptor groupDescriptor = GroupDescriptor.create(groupName); + + List projectsList = groupElement.getChildren(PROJECT_TAG); + for (Object project : projectsList) { + Element projectElement = (Element) project; + String projectId = projectElement.getAttributeValue(PROJECT_ID_ATTR); + String frameworks = projectElement.getAttributeValue(VALUES_ATTR); + if (!StringUtil.isEmptyOrSpaces(projectId) && !StringUtil.isEmptyOrSpaces(frameworks)) { + Set frameworkDescriptors = new HashSet(); + for (String key : StringUtil.split(frameworks, TOKENIZER)) { + frameworkDescriptors.add(new UsageDescriptor(key, 1)); + } + getApplicationData(groupDescriptor).put(projectId, frameworkDescriptors); + } + } + } + } + + public Element getState() { + Element element = new Element("state"); + + for (Map.Entry>> appData : getApplicationData().entrySet()) { + Element groupElement = new Element(GROUP_TAG); + groupElement.setAttribute(GROUP_NAME_ATTR, appData.getKey().getId()); + boolean isEmptyGroup = true; + + for (Map.Entry> projectData : appData.getValue().entrySet()) { + Element projectElement = new Element(PROJECT_TAG); + projectElement.setAttribute(PROJECT_ID_ATTR, projectData.getKey()); + final Set projectDataValue = projectData.getValue(); + if (!projectDataValue.isEmpty()) { + projectElement.setAttribute(VALUES_ATTR, joinUsages(projectDataValue)); + groupElement.addContent(projectElement); + isEmptyGroup = false; + } + } + + if (!isEmptyGroup) { + element.addContent(groupElement); + } + } + + return element; + } + + private static String joinUsages(@NotNull Set usages) { + return StringUtil.join(usages, new Function() { + @Override + public String fun(UsageDescriptor usageDescriptor) { + return usageDescriptor.getKey(); + } + }, TOKENIZER); + } + + @NotNull + @NonNls + public File[] getExportFiles() { + return new File[]{PathManager.getOptionsFile("framework.usages")}; + } + + @NotNull + public String getPresentableName() { + return "Application Usages Statistics"; + } + + @NonNls + @NotNull + public String getComponentName() { + return "ApplicationStatisticsPersistenceComponent"; + } + + public void initComponent() { + ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerListener() { + @Override + public void projectOpened(Project project) { + } + + @Override + public boolean canCloseProject(Project project) { + return true; + } + + @Override + public void projectClosed(Project project) { + } + + @Override + public void projectClosing(Project project) { + if (project != null) { + for (UsagesCollector usagesCollector : Extensions.getExtensions(UsagesCollector.EP_NAME)) { + if (usagesCollector instanceof AbstractApplicationUsagesCollector) { + ((AbstractApplicationUsagesCollector) usagesCollector).persistProjectUsages(project); + } + } + } + } + }); + } + + public void disposeComponent() { + } +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/persistence/BasicSentUsagesPersistenceComponent.java b/platform/platform-impl/src/com/intellij/internal/statistic/persistence/BasicSentUsagesPersistenceComponent.java index 9f4ab0c910c3..b77ea2367816 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/persistence/BasicSentUsagesPersistenceComponent.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/persistence/BasicSentUsagesPersistenceComponent.java @@ -17,58 +17,69 @@ package com.intellij.internal.statistic.persistence; import com.intellij.internal.statistic.StatisticsUploadAssistant; +import com.intellij.internal.statistic.beans.GroupDescriptor; import com.intellij.internal.statistic.beans.PatchedUsage; import com.intellij.internal.statistic.beans.UsageDescriptor; import com.intellij.openapi.util.Pair; import com.intellij.util.containers.HashSet; +import com.intellij.util.containers.hash.HashMap; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import java.util.Map; import java.util.Set; public class BasicSentUsagesPersistenceComponent extends SentUsagesPersistence { - public BasicSentUsagesPersistenceComponent() { - } + public BasicSentUsagesPersistenceComponent() { + } - protected Set mySentDescriptors = new HashSet(); - @NonNls private long mySentTime = 0; + protected Map> mySentDescriptors = new HashMap>(); + @NonNls + private long mySentTime = 0; - @Override - public boolean isAllowed() { - return true; - } + @Override + public boolean isAllowed() { + return true; + } - @Override - public boolean isShowNotification() { - return false; - } + @Override + public boolean isShowNotification() { + return false; + } - @Override - public long getLastTimeSent() { - return mySentTime; - } + @Override + public long getLastTimeSent() { + return mySentTime; + } - public void setSentTime(long time) { - mySentTime = time; - } + public void setSentTime(long time) { + mySentTime = time; + } - public void persistPatch(@NotNull Set patchedDescriptors) { - for (PatchedUsage patchedUsage : patchedDescriptors) { - UsageDescriptor usageDescriptor = StatisticsUploadAssistant.findDescriptor(mySentDescriptors, Pair.create(patchedUsage.getGroup(), patchedUsage.getKey())); - if (usageDescriptor != null) { - usageDescriptor.setValue(usageDescriptor.getValue() + patchedUsage.getDelta()); - } - else { - mySentDescriptors.add(new UsageDescriptor(patchedUsage.getGroup(), patchedUsage.getKey(), patchedUsage.getValue())); - } + public void persistPatch(@NotNull Map> patchedDescriptorMap) { + for (Map.Entry> entry : patchedDescriptorMap.entrySet()) { + final GroupDescriptor groupDescriptor = entry.getKey(); + for (PatchedUsage patchedUsage : entry.getValue()) { + UsageDescriptor usageDescriptor = StatisticsUploadAssistant.findDescriptor(mySentDescriptors, Pair.create(groupDescriptor, patchedUsage.getKey())); + if (usageDescriptor != null) { + usageDescriptor.setValue(usageDescriptor.getValue() + patchedUsage.getDelta()); + } else { + if (!mySentDescriptors.containsKey(groupDescriptor)) { + mySentDescriptors.put(groupDescriptor, new HashSet()); + } + mySentDescriptors.get(groupDescriptor).add(new UsageDescriptor(patchedUsage.getKey(), patchedUsage.getValue())); + } + } + } + + setSentTime(System.currentTimeMillis()); } - setSentTime(System.currentTimeMillis()); - } - @NotNull - public Set getSentUsages() { - return mySentDescriptors; - } + @NotNull + public Map> getSentUsages + () { + return mySentDescriptors; + } } diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/persistence/SentUsagesPersistence.java b/platform/platform-impl/src/com/intellij/internal/statistic/persistence/SentUsagesPersistence.java index ca271e3a1cd7..cffc0edec7ba 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/persistence/SentUsagesPersistence.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/persistence/SentUsagesPersistence.java @@ -16,18 +16,20 @@ package com.intellij.internal.statistic.persistence; +import com.intellij.internal.statistic.beans.GroupDescriptor; import com.intellij.internal.statistic.beans.PatchedUsage; import com.intellij.internal.statistic.beans.UsageDescriptor; import org.jetbrains.annotations.NotNull; +import java.util.Map; import java.util.Set; public abstract class SentUsagesPersistence { - public abstract void persistPatch(@NotNull Set patchedDescriptors); + public abstract void persistPatch(@NotNull Map> patchedDescriptors); @NotNull - public abstract Set getSentUsages(); + public abstract Map> getSentUsages(); public abstract boolean isAllowed(); diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/persistence/UsageStatisticsPersistenceComponent.java b/platform/platform-impl/src/com/intellij/internal/statistic/persistence/UsageStatisticsPersistenceComponent.java index 1262fa18c79d..9140f257eac3 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/persistence/UsageStatisticsPersistenceComponent.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/persistence/UsageStatisticsPersistenceComponent.java @@ -76,7 +76,7 @@ public class UsageStatisticsPersistenceComponent extends BasicSentUsagesPersiste String valueData = groupElement.getAttributeValue(DATA_ATTR); if (!StringUtil.isEmptyOrSpaces(groupId) && !StringUtil.isEmptyOrSpaces(valueData)) { - getSentUsages().addAll(ConvertUsagesUtil.convertValueString(GroupDescriptor.create(groupId, groupPriority), valueData)); + getSentUsages().putAll(ConvertUsagesUtil.convertValueString(GroupDescriptor.create(groupId, groupPriority), valueData)); } } @@ -99,7 +99,7 @@ public class UsageStatisticsPersistenceComponent extends BasicSentUsagesPersiste public Element getState() { Element element = new Element("state"); - for (Map.Entry> entry : ConvertUsagesUtil.groupDescriptors(getSentUsages()) + for (Map.Entry> entry : ConvertUsagesUtil.sortDescriptorsByPriority(getSentUsages()) .entrySet()) { Element projectElement = new Element(GROUP_TAG); projectElement.setAttribute(GROUP_ID_ATTR, entry.getKey().getId()); diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/updater/StatisticsNotificationManager.java b/platform/platform-impl/src/com/intellij/internal/statistic/updater/StatisticsNotificationManager.java index 4fef4c3f2521..43ab15bfc3ce 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/updater/StatisticsNotificationManager.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/updater/StatisticsNotificationManager.java @@ -72,7 +72,7 @@ public class StatisticsNotificationManager { else if ("settings".equals(description)) { final ShowSettingsUtil util = ShowSettingsUtil.getInstance(); IdeFrame ideFrame = WindowManagerEx.getInstanceEx().findFrameFor(null); - util.editConfigurable((JFrame)ideFrame, new StatisticsConfigurable()); + util.editConfigurable((JFrame)ideFrame, new StatisticsConfigurable(true)); notification.expire(); } } diff --git a/platform/platform-resources/src/componentSets/Platform.xml b/platform/platform-resources/src/componentSets/Platform.xml index b41fe5ed2b1e..fa0f63758036 100644 --- a/platform/platform-resources/src/componentSets/Platform.xml +++ b/platform/platform-resources/src/componentSets/Platform.xml @@ -118,20 +118,16 @@ com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent + + com.intellij.internal.statistic.persistence.ApplicationStatisticsPersistenceComponent + com.intellij.internal.statistic.persistence.ApplicationStatisticsPersistenceComponent + + com.intellij.openapi.util.FoundationLoader - - com.intellij.facet.impl.statistics.FrameworkStatisticsPersistenceComponent - com.intellij.facet.impl.statistics.FrameworkStatisticsPersistenceComponent - - - - com.intellij.openapi.vcs.statistics.VcsStatisticsPersistenceComponent - com.intellij.openapi.vcs.statistics.VcsStatisticsPersistenceComponent - diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java index 4198baf3233f..0517740f2f0c 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java @@ -79,7 +79,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec private FileHolderComposite myComposite; - private final ChangeListWorker myWorker; + private ChangeListWorker myWorker; private VcsException myUpdateException = null; @SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"}) @@ -117,7 +117,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec myChangesViewManager = myProject.isDefault() ? new DummyChangesView(myProject) : ChangesViewManager.getInstance(myProject); myFileStatusManager = FileStatusManager.getInstance(myProject); myComposite = new FileHolderComposite(project); - myIgnoredIdeaLevel = new IgnoredFilesComponent(myProject); + myIgnoredIdeaLevel = new IgnoredFilesComponent(myProject, true); myUpdater = new UpdateRequestsQueue(myProject, ourUpdateAlarm, new ActualUpdater()); myWorker = new ChangeListWorker(myProject, new MyChangesDeltaForwarder(myProject, ourUpdateAlarm)); @@ -421,10 +421,8 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec myModifier.clearQueue(); // update member from copy if (takeChanges) { - myWorker.takeData(dataHolder.getChangeListWorker()); - } - - if (takeChanges) { + myWorker = dataHolder.getChangeListWorker(); + myModifier.setWorker(myWorker); if (LOG.isDebugEnabled()) { LOG.debug("refresh procedure finished, size: " + dataHolder.getComposite().getVFHolder(FileHolder.HolderType.UNVERSIONED).getSize()); } @@ -996,8 +994,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec final IgnoredFilesComponent ignoredFilesComponent; final ChangeListWorker worker; synchronized (myDataLock) { - ignoredFilesComponent = new IgnoredFilesComponent(myProject); - ignoredFilesComponent.add(myIgnoredIdeaLevel.getFilesToIgnore()); + ignoredFilesComponent = new IgnoredFilesComponent(myIgnoredIdeaLevel); worker = myWorker.copy(); } new ChangeListManagerSerialization(ignoredFilesComponent, worker).writeExternal(element); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListsIndexes.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListsIndexes.java index 96cdbe14625a..7fde7a2827a3 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListsIndexes.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListsIndexes.java @@ -24,10 +24,7 @@ import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.Nullable; import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; public class ChangeListsIndexes { private final Map myFileToStatus; @@ -107,6 +104,22 @@ public class ChangeListsIndexes { } } + public void getDelta(final ChangeListsIndexes newIndexes, final Set> toRemove, Set> toAdd) { + // this is old + final Set oldKeySet = myFileToVcs.keySet(); + final Set toRemoveSet = new HashSet(oldKeySet); + final Set newKeySet = newIndexes.myFileToVcs.keySet(); + final Set toAddSet = new HashSet(newKeySet); + toRemoveSet.removeAll(newKeySet); + toAddSet.removeAll(oldKeySet); + for (String s : toRemoveSet) { + toRemove.add(new Pair(s, myFileToVcs.get(s))); + } + for (String s : toAddSet) { + toAdd.add(new Pair(s, newIndexes.myFileToVcs.get(s))); + } + } + public List> getAffectedFilesUnderVcs() { final ArrayList> result = new ArrayList>(); for (Map.Entry entry : myFileToVcs.entrySet()) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesDelta.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesDelta.java index be5e4611f6de..fcb32c5f88d6 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesDelta.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesDelta.java @@ -23,6 +23,7 @@ import com.intellij.openapi.vcs.VcsKey; import com.intellij.openapi.vcs.impl.CollectionsDelta; import java.util.Collection; +import java.util.HashSet; import java.util.List; import java.util.Set; @@ -44,18 +45,16 @@ public class ChangesDelta { myInitialized = true; return true; //+- } - final List> becameAffected = became.getAffectedFilesUnderVcs(); - final Set> toRemove = CollectionsDelta.notInSecond(wasAffected, becameAffected); - final Set> toAdd = CollectionsDelta.notInSecond(becameAffected, wasAffected); + final Set> toRemove = new HashSet>(); + final Set> toAdd = new HashSet>(); + was.getDelta(became, toRemove, toAdd); - if (toRemove != null) { - for (Pair pair : toRemove) { - myDeltaListener.minus(convertPair(pair)); - } + for (Pair pair : toRemove) { + myDeltaListener.minus(convertPair(pair)); } sendPlus(toAdd); - return toRemove != null || toAdd != null; + return ! toRemove.isEmpty() || ! toAdd.isEmpty(); } private void sendPlus(final Collection> toAdd) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/IgnoredFilesComponent.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/IgnoredFilesComponent.java index 63737b88891b..91336c7589cd 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/IgnoredFilesComponent.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/IgnoredFilesComponent.java @@ -28,20 +28,24 @@ import java.util.List; import java.util.Set; public class IgnoredFilesComponent { - private final Project myProject; private final Set myFilesToIgnore; - public IgnoredFilesComponent(final Project project) { - myProject = project; + public IgnoredFilesComponent(final Project project, final boolean registerListener) { myFilesToIgnore = new LinkedHashSet(); - project.getMessageBus().connect().subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener() { - public void before(List events) {} + if (registerListener) { + project.getMessageBus().connect(project).subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener() { + public void before(List events) {} - public void after(List events) { - resetCaches(); - } - }); + public void after(List events) { + resetCaches(); + } + }); + } + } + + public IgnoredFilesComponent(final IgnoredFilesComponent other) { + myFilesToIgnore = new LinkedHashSet(other.myFilesToIgnore); } public void add(final IgnoredFileBean... filesToIgnore) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/Modifier.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/Modifier.java index a3317e39667d..431f8c399ba7 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/Modifier.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/Modifier.java @@ -27,7 +27,7 @@ import java.util.List; * (after update is done) */ public class Modifier implements ChangeListsWriteOperations { - private final ChangeListWorker myWorker; + private ChangeListWorker myWorker; private boolean myInsideUpdate; private final List myCommandQueue; private final DelayedNotificator myNotificator; @@ -113,4 +113,8 @@ public class Modifier implements ChangeListsWriteOperations { myNotificator.callNotify(command); } } + + public void setWorker(ChangeListWorker worker) { + myWorker = worker; + } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsStatisticsPersistence.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsStatisticsPersistence.java deleted file mode 100644 index 968e52aae1a8..000000000000 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsStatisticsPersistence.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2000-2010 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.intellij.openapi.vcs.statistics; - -import com.intellij.openapi.project.Project; -import com.intellij.internal.statistic.beans.UsageDescriptor; -import com.intellij.util.containers.HashMap; -import org.jetbrains.annotations.NotNull; - -import java.util.Map; -import java.util.Set; - -public abstract class VcsStatisticsPersistence { - private Map> myVcsUsagesMap = new HashMap>(); - - public VcsStatisticsPersistence() { - } - - public void persist(@NotNull Project project, @NotNull Set vcs) { - myVcsUsagesMap.put(project.getName(), vcs); - } - - @NotNull - public Map> getVcsUsageMap() { - return myVcsUsagesMap; - } - -} diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsStatisticsPersistenceComponent.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsStatisticsPersistenceComponent.java deleted file mode 100644 index 96a7cf527c12..000000000000 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsStatisticsPersistenceComponent.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright 2000-2010 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.intellij.openapi.vcs.statistics; - -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.PathManager; -import com.intellij.openapi.components.ApplicationComponent; -import com.intellij.openapi.components.PersistentStateComponent; -import com.intellij.openapi.components.State; -import com.intellij.openapi.components.Storage; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ProjectManager; -import com.intellij.openapi.project.ProjectManagerListener; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.internal.statistic.beans.UsageDescriptor; -import com.intellij.util.Function; -import com.intellij.util.containers.HashSet; -import org.jdom.Element; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; - -import java.io.File; -import java.util.List; -import java.util.Map; -import java.util.Set; - -@State( - name = "VcsUsages", - storages = { - @Storage( - id = "vcs", - file = "$APP_CONFIG$/vcs.usages.xml" - )} -) -public class VcsStatisticsPersistenceComponent extends VcsStatisticsPersistence - implements ApplicationComponent, PersistentStateComponent { - private static final String TOKENIZER = ","; - - @NonNls private static final String PROJECT_TAG = "project"; - @NonNls private static final String PROJECT_ID_ATTR = "id"; - @NonNls private static final String USAGES_ATTR = "usages"; - - public VcsStatisticsPersistenceComponent() { - } - - public static VcsStatisticsPersistenceComponent getInstance() { - return ApplicationManager.getApplication().getComponent(VcsStatisticsPersistenceComponent.class); - } - - public void loadState(final Element element) { - List projectsList = element.getChildren(PROJECT_TAG); - for (Object project : projectsList) { - Element projectElement = (Element)project; - String projectId = projectElement.getAttributeValue(PROJECT_ID_ATTR); - String vcs = projectElement.getAttributeValue(USAGES_ATTR); - if (!StringUtil.isEmptyOrSpaces(projectId) && !StringUtil.isEmptyOrSpaces(vcs)) { - Set vcsDescriptors = new HashSet(); - for (String key : StringUtil.split(vcs, TOKENIZER)) { - vcsDescriptors.add(new UsageDescriptor(VcsUsagesCollector.createGroupDescriptor(), key, 1)); - } - getVcsUsageMap().put(projectId, vcsDescriptors); - } - } - } - - public Element getState() { - Element element = new Element("state"); - - for (Map.Entry> vcsUsageEntry : getVcsUsageMap().entrySet()) { - Element projectElement = new Element(PROJECT_TAG); - projectElement.setAttribute(PROJECT_ID_ATTR, vcsUsageEntry.getKey()); - projectElement.setAttribute(USAGES_ATTR, joinUsages(vcsUsageEntry.getValue())); - - element.addContent(projectElement); - } - - return element; - } - - private static String joinUsages(@NotNull Set usages) { - return StringUtil.join(usages, new Function() { - @Override - public String fun(UsageDescriptor usageDescriptor) { - return usageDescriptor.getKey(); - } - }, TOKENIZER); - } - - @NotNull - @NonNls - public File[] getExportFiles() { - return new File[]{PathManager.getOptionsFile("vcs.usages")}; - } - - @NotNull - public String getPresentableName() { - return "Vcs Usages"; - } - - @NonNls - @NotNull - public String getComponentName() { - return "VcsStatisticsPersistenceComponent"; - } - - public void initComponent() { - ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerListener() { - @Override - public void projectOpened(Project project) { - } - - @Override - public boolean canCloseProject(Project project) { - return true; - } - - @Override - public void projectClosed(Project project) { - } - - @Override - public void projectClosing(Project project) { - if (project != null) { - VcsUsagesCollector.persistProjectUsages(project); - } - } - }); - } - - public void disposeComponent() { - } -} diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsUsagesCollector.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsUsagesCollector.java index ffbbc803b855..0c027b0f8d6e 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsUsagesCollector.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsUsagesCollector.java @@ -15,10 +15,10 @@ */ package com.intellij.openapi.vcs.statistics; +import com.intellij.internal.statistic.AbstractApplicationUsagesCollector; import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.AbstractVcs; import com.intellij.openapi.vcs.ProjectLevelVcsManager; -import com.intellij.openapi.vcs.impl.VcsDescriptor; import com.intellij.internal.statistic.UsagesCollector; import com.intellij.internal.statistic.beans.GroupDescriptor; import com.intellij.internal.statistic.beans.UsageDescriptor; @@ -28,77 +28,25 @@ import com.intellij.util.containers.hash.HashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Arrays; import java.util.Map; import java.util.Set; -public class VcsUsagesCollector extends UsagesCollector { - private static final String GROUP_ID = "vcs"; +public class VcsUsagesCollector extends AbstractApplicationUsagesCollector { + private static final String GROUP_ID = "vcs"; - public static void persistProjectUsages(@NotNull Project project) { - persistProjectUsages(project, getProjectUsages(project)); - } - - public static void persistProjectUsages(@NotNull Project project, @NotNull Set usages) { - persistProjectUsages(project, usages, VcsStatisticsPersistenceComponent.getInstance()); - } - - public static void persistProjectUsages(@NotNull Project project, - @NotNull Set usages, - @NotNull VcsStatisticsPersistenceComponent persistence) { - persistence.persist(project, usages); - } - - @NotNull - public static Set getApplicationUsages() { - return getApplicationUsages(VcsStatisticsPersistenceComponent.getInstance()); - } - - @NotNull - public static Set getApplicationUsages(@NotNull final VcsStatisticsPersistenceComponent persistence) { - final Map vcsUsagesMap = new HashMap(); - - for (Set descriptors : persistence.getVcsUsageMap().values()) { - for (UsageDescriptor descriptor : descriptors) { - final String key = descriptor.getKey(); - final Integer count = vcsUsagesMap.get(key); - vcsUsagesMap.put(key, count == null ? 1 : count.intValue() + 1); - } + @NotNull + public GroupDescriptor getGroupId() { + return GroupDescriptor.create(GROUP_ID, GroupDescriptor.HIGHER_PRIORITY); } - return ContainerUtil.map2Set(vcsUsagesMap.entrySet(), new Function, UsageDescriptor>() { - @Override - public UsageDescriptor fun(Map.Entry vcsUsage) { - return new UsageDescriptor(createGroupDescriptor(), vcsUsage.getKey(), vcsUsage.getValue()); - } - }); - } - - @NotNull - public String getGroupId() { - return GROUP_ID; - } - - @NotNull - public Set getUsages(@Nullable Project project) { - if (project != null) { - persistProjectUsages(project, getProjectUsages(project)); + @NotNull + public Set getProjectUsages(@NotNull Project project) { + return ContainerUtil.map2Set(ProjectLevelVcsManager.getInstance(project).getAllActiveVcss(), new Function() { + @Override + public UsageDescriptor fun(AbstractVcs vcs) { + return new UsageDescriptor(vcs.getName(), 1); + } + }); } - - return getApplicationUsages(); - } - - public static Set getProjectUsages(@NotNull Project project) { - return ContainerUtil.map2Set(ProjectLevelVcsManager.getInstance(project).getAllActiveVcss(), new Function() { - @Override - public UsageDescriptor fun(AbstractVcs vcs) { - return new UsageDescriptor(createGroupDescriptor(), vcs.getName(), 1); - } - }); - } - - public static GroupDescriptor createGroupDescriptor() { - return GroupDescriptor.create(GROUP_ID, GroupDescriptor.HIGHER_PRIORITY); - } } diff --git a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties index 5734a1f02ef7..0a9522cf8c9c 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties +++ b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties @@ -268,7 +268,7 @@ instance.variable.may.not.be.initialized.display.name=Instance field may not be instance.variable.may.not.be.initialized.problem.descriptor=Instance field #ref may not be initialized during object construction #loc instance.Variable.may.not.be.initialized.problem.descriptor.junit=Instance field #ref may not be initialized during object construction or 'setUp()' call #loc primitive.fields.ignore.option=Ignore primitive fields -instance.variable.used.before.initialized.display.name=Instance field used before initialized +instance.variable.used.before.initialized.display.name=Instance field used before initialization instance.variable.used.before.initialized.problem.descriptor=Instance field #ref used before initialized #loc non.final.static.variable.initialization.display.name=Non-final static field is used during class initialization non.final.static.variable.initialization.problem.descriptor=Non-final static field #ref used during class initialization #loc @@ -1841,4 +1841,6 @@ package.dot.html.may.be.package.info.problem.descriptor=package.html -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableHasSerialVersionUIDFieldInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableHasSerialVersionUIDFieldInspection.java index 2bec2c00829f..0d1a8ebd457a 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableHasSerialVersionUIDFieldInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableHasSerialVersionUIDFieldInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,11 +22,13 @@ import com.siyeh.ig.BaseInspectionVisitor; import com.siyeh.ig.InspectionGadgetsFix; import com.siyeh.ig.fixes.AddSerialVersionUIDFix; import com.siyeh.ig.psiutils.SerializationUtils; +import org.intellij.lang.annotations.Pattern; import org.jetbrains.annotations.NotNull; public class SerializableHasSerialVersionUIDFieldInspection extends SerializableInspection { + @Pattern("[a-zA-Z_0-9.-]+") @Override @NotNull public String getID() { @@ -70,6 +72,10 @@ public class SerializableHasSerialVersionUIDFieldInspection aClass instanceof PsiEnumConstantInitializer) { return; } + if (ignoreAnonymousInnerClasses && + aClass instanceof PsiAnonymousClass) { + return; + } final PsiField serialVersionUIDField = aClass.findFieldByName( HardcodedMethodConstants.SERIAL_VERSION_UID, false); if (serialVersionUIDField != null) { diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableHasSerializationMethodsInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableHasSerializationMethodsInspection.java index fd39f8b830ba..fa3ed0d17fc9 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableHasSerializationMethodsInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableHasSerializationMethodsInspection.java @@ -15,6 +15,7 @@ */ package com.siyeh.ig.serialization; +import com.intellij.psi.PsiAnonymousClass; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiEnumConstantInitializer; import com.intellij.psi.PsiTypeParameter; @@ -26,12 +27,14 @@ import org.jetbrains.annotations.NotNull; public class SerializableHasSerializationMethodsInspection extends SerializableInspection { + @Override @NotNull public String getDisplayName() { return InspectionGadgetsBundle.message( "serializable.has.serialization.methods.display.name"); } + @Override @NotNull public String buildErrorString(Object... infos) { final boolean hasReadObject = ((Boolean)infos[0]).booleanValue(); @@ -48,6 +51,7 @@ public class SerializableHasSerializationMethodsInspection } } + @Override public BaseInspectionVisitor buildVisitor() { return new SerializableHasSerializationMethodsVisitor(); } @@ -65,6 +69,10 @@ public class SerializableHasSerializationMethodsInspection aClass instanceof PsiEnumConstantInitializer) { return; } + if (ignoreAnonymousInnerClasses && + aClass instanceof PsiAnonymousClass) { + return; + } if (!SerializationUtils.isSerializable(aClass)) { return; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableInnerClassHasSerialVersionUIDFieldVisitor.java b/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableInnerClassHasSerialVersionUIDFieldVisitor.java index d1e758bafc86..a7d26d7aa874 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableInnerClassHasSerialVersionUIDFieldVisitor.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableInnerClassHasSerialVersionUIDFieldVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ package com.siyeh.ig.serialization; +import com.intellij.psi.PsiAnonymousClass; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiField; import com.intellij.psi.PsiModifier; @@ -28,7 +29,8 @@ class SerializableInnerClassHasSerialVersionUIDFieldVisitor private final SerializableInspection inspection; - public SerializableInnerClassHasSerialVersionUIDFieldVisitor(SerializableInspection inspection) { + public SerializableInnerClassHasSerialVersionUIDFieldVisitor( + SerializableInspection inspection) { this.inspection = inspection; } @@ -38,6 +40,10 @@ class SerializableInnerClassHasSerialVersionUIDFieldVisitor aClass.isEnum()) { return; } + if (inspection.ignoreAnonymousInnerClasses && + aClass instanceof PsiAnonymousClass) { + return; + } if (hasSerialVersionUIDField(aClass)) { return; } @@ -57,7 +63,7 @@ class SerializableInnerClassHasSerialVersionUIDFieldVisitor registerClassError(aClass); } - private boolean hasSerialVersionUIDField(PsiClass aClass) { + private static boolean hasSerialVersionUIDField(PsiClass aClass) { final PsiField[] fields = aClass.getFields(); boolean hasSerialVersionUID = false; for (PsiField field : fields) { diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableInnerClassWithNonSerializableOuterClassVisitor.java b/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableInnerClassWithNonSerializableOuterClassVisitor.java index c404b45afb58..b9accba4ab2e 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableInnerClassWithNonSerializableOuterClassVisitor.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableInnerClassWithNonSerializableOuterClassVisitor.java @@ -15,6 +15,7 @@ */ package com.siyeh.ig.serialization; +import com.intellij.psi.PsiAnonymousClass; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiModifier; import com.siyeh.ig.BaseInspectionVisitor; @@ -24,10 +25,10 @@ import org.jetbrains.annotations.NotNull; class SerializableInnerClassWithNonSerializableOuterClassVisitor extends BaseInspectionVisitor { - private final SerializableInnerClassWithNonSerializableOuterClassInspection inspection; + private final SerializableInspection inspection; public SerializableInnerClassWithNonSerializableOuterClassVisitor( - SerializableInnerClassWithNonSerializableOuterClassInspection inspection) { + SerializableInspection inspection) { this.inspection = inspection; } @@ -36,6 +37,10 @@ class SerializableInnerClassWithNonSerializableOuterClassVisitor aClass.isEnum()) { return; } + if (inspection.ignoreAnonymousInnerClasses && + aClass instanceof PsiAnonymousClass) { + return; + } final PsiClass containingClass = aClass.getContainingClass(); if (containingClass == null) { return; diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableInspection.java index dfecdac65843..cea1a5826af0 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/serialization/SerializableInspection.java @@ -19,22 +19,29 @@ import com.intellij.codeInspection.ui.AddAction; import com.intellij.codeInspection.ui.ListTable; import com.intellij.codeInspection.ui.ListWrappingTableModel; import com.intellij.codeInspection.ui.RemoveAction; +import com.intellij.openapi.actionSystem.ActionToolbar; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; import com.intellij.psi.PsiClass; import com.intellij.psi.util.InheritanceUtil; +import com.intellij.ui.ScrollPaneFactory; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; import com.siyeh.ig.psiutils.SerializationUtils; +import com.siyeh.ig.ui.CheckBox; +import com.siyeh.ig.ui.UiUtils; import org.jdom.Element; import javax.swing.*; +import java.awt.*; import java.util.ArrayList; import java.util.List; public abstract class SerializableInspection extends BaseInspection { - /** @noinspection PublicField */ + @SuppressWarnings({"PublicField"}) + public boolean ignoreAnonymousInnerClasses = false; + @SuppressWarnings({"PublicField"}) public String superClassString = "java.awt.Component"; protected List superClassList = new ArrayList(); @@ -44,8 +51,41 @@ public abstract class SerializableInspection extends BaseInspection { @Override public JComponent createOptionsPanel() { - final Form form = new Form(); - return form.getContentPanel(); + final JComponent panel = new JPanel(new GridBagLayout()); + + final ListTable table = new ListTable(new ListWrappingTableModel( + superClassList, InspectionGadgetsBundle.message( + "ignore.classes.in.hierarchy.column.name"))); + final JScrollPane scrollPane = + ScrollPaneFactory.createScrollPane(table); + final ActionToolbar toolbar = + UiUtils.createAddRemoveTreeAnnotationChooserToolbar(table, + InspectionGadgetsBundle.message( + "choose.super.class.to.ignore")); + final CheckBox checkBox = new CheckBox(InspectionGadgetsBundle.message( + "ignore.anonymous.inner.classes"), this, + "ignoreAnonymousInnerClasses"); + + final GridBagConstraints constraints = new GridBagConstraints(); + constraints.gridx = 0; + constraints.gridy = 0; + constraints.insets.left = 4; + constraints.insets.right = 4; + constraints.fill = GridBagConstraints.HORIZONTAL; + panel.add(toolbar.getComponent(), constraints); + + constraints.gridy = 1; + constraints.weightx = 1.0; + constraints.weighty = 1.0; + constraints.fill = GridBagConstraints.BOTH; + panel.add(scrollPane, constraints); + + constraints.gridy = 2; + constraints.weighty = 0.0; + constraints.fill = GridBagConstraints.HORIZONTAL; + panel.add(checkBox, constraints); + + return panel; } @Override @@ -71,27 +111,4 @@ public abstract class SerializableInspection extends BaseInspection { } return false; } - - private class Form { - - private JPanel contentPanel; - private ListTable table; - private JButton addButton; - private JButton removeButton; - - Form() { - addButton.setAction(new AddAction(table)); - removeButton.setAction(new RemoveAction(table)); - } - - private void createUIComponents() { - table = new ListTable(new ListWrappingTableModel(superClassList, - InspectionGadgetsBundle.message( - "ignore.classes.in.hierarchy.column.name"))); - } - - public JPanel getContentPanel() { - return contentPanel; - } - } } \ No newline at end of file diff --git a/plugins/ant/src/com/intellij/lang/ant/config/execution/OutputParser.java b/plugins/ant/src/com/intellij/lang/ant/config/execution/OutputParser.java index a739bf0167c9..3c5b1ca1cc10 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/execution/OutputParser.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/execution/OutputParser.java @@ -15,9 +15,9 @@ */ package com.intellij.lang.ant.config.execution; +import com.intellij.compiler.impl.javaCompiler.FileObject; import com.intellij.compiler.impl.javaCompiler.javac.JavacOutputParser; import com.intellij.compiler.impl.javaCompiler.jikes.JikesOutputParser; -import com.intellij.compiler.impl.javaCompiler.FileObject; import com.intellij.execution.process.OSProcessHandler; import com.intellij.lang.ant.AntBundle; import com.intellij.openapi.application.ApplicationManager; @@ -240,7 +240,7 @@ public class OutputParser{ } com.intellij.compiler.OutputParser.Callback callback = new com.intellij.compiler.OutputParser.Callback() { - private int myIndex = 0; + private int myIndex = -1; @Nullable public String getCurrentLine() { @@ -251,7 +251,16 @@ public class OutputParser{ } public String getNextLine() { - return javacMessages.get(myIndex++); + final int next = myIndex + 1; + if (next >= javacMessages.size()) { + return null; + } + return javacMessages.get(myIndex = next); + } + + @Override + public void pushBack(String line) { + myIndex--; } public void message(final CompilerMessageCategory category, diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationManager.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationManager.java index 0542feabb651..f07993844566 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationManager.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationManager.java @@ -40,10 +40,7 @@ import org.tmatesoft.svn.core.SVNErrorMessage; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNProperties; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.auth.ISVNAuthenticationProvider; -import org.tmatesoft.svn.core.auth.ISVNProxyManager; -import org.tmatesoft.svn.core.auth.SVNAuthentication; -import org.tmatesoft.svn.core.auth.SVNSSLAuthentication; +import org.tmatesoft.svn.core.auth.*; import org.tmatesoft.svn.core.internal.wc.*; import org.tmatesoft.svn.core.io.SVNRepository; @@ -568,8 +565,9 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im } @Override - public boolean promptForSSLPlaintextPassphraseSaving(SVNURL url, String realm, File certificateFile) { - final int answer = Messages.showYesNoDialog(myProject, String.format("Your passphrase for client certificate:\n%s\ncan only be stored to disk unencrypted. Would you like to store it in plaintext?", + public boolean promptForSSLPlaintextPassphraseSaving(SVNURL url, String realm, File certificateFile, String certificateName) { + final int answer = Messages.showYesNoDialog(myProject, + String.format("Your passphrase for " + certificateName + ":\n%s\ncan only be stored to disk unencrypted. Would you like to store it in plaintext?", certificateFile.getPath()), "Store the passphrase in plaintext?", Messages.getQuestionIcon()); return answer == 0; @@ -655,8 +653,19 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im promptAndSaveWhenWeLackEncryption(realm, auth, new Getter() { @Override public Boolean get() { + File file = null; + String certificateName = null; + if (auth instanceof SVNSSLAuthentication) { + file = ((SVNSSLAuthentication) auth).getCertificateFile(); + certificateName = "client certificate"; + } else if (auth instanceof SVNSSHAuthentication) { + file = ((SVNSSHAuthentication) auth).getPrivateKeyFile(); + certificateName = "private key file"; + } else { + assert false; + } return myInteraction.promptForSSLPlaintextPassphraseSaving(myUrl, realm, - ((SVNSSLAuthentication) auth).getCertificateFile()); + file, certificateName); } }); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/auth/SvnAuthenticationInteraction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/auth/SvnAuthenticationInteraction.java index a43f6fad829d..a256435d0b7c 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/auth/SvnAuthenticationInteraction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/auth/SvnAuthenticationInteraction.java @@ -23,7 +23,7 @@ public interface SvnAuthenticationInteraction { void warnOnAuthStorageDisabled(final SVNURL url); void warnOnPasswordStorageDisabled(final SVNURL url); void warnOnSSLPassphraseStorageDisabled(final SVNURL url); - boolean promptForSSLPlaintextPassphraseSaving(final SVNURL url, String realm, File certificateFile); + boolean promptForSSLPlaintextPassphraseSaving(final SVNURL url, String realm, File certificateFile, String certificateName); boolean promptForPlaintextPasswordSaving(final SVNURL url, String realm); boolean promptInAwt(); } diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnAuthenticationTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnAuthenticationTest.java index 50247afa3b93..a0c44d748bb2 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnAuthenticationTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnAuthenticationTest.java @@ -1248,7 +1248,7 @@ public class SvnAuthenticationTest extends PlatformTestCase { } @Override - public boolean promptForSSLPlaintextPassphraseSaving(SVNURL url, String realm, File certificateFile) { + public boolean promptForSSLPlaintextPassphraseSaving(SVNURL url, String realm, File certificateFile, String certificateName) { ++ myNumSSLPlaintextPrompt; return mySSLPlaintextAnswer; }