FUS-123 Debugger Breakpoints Usage

This commit is contained in:
Egor Ushakov
2018-06-28 18:54:01 +03:00
parent 3273ef6e27
commit ab763848d7
5 changed files with 66 additions and 18 deletions
@@ -50,6 +50,7 @@
<virtualFileSystem key="lazyAttachVfs" implementationClass="com.intellij.xdebugger.attach.fs.LazyAttachVirtualFS"/>
<statistics.projectUsagesCollector implementation="com.intellij.xdebugger.impl.breakpoints.BreakpointsStatisticsCollector"/>
<statistics.projectUsagesCollector implementation="com.intellij.xdebugger.impl.breakpoints.BreakpointsUsageCollector"/>
</extensions>
<actions>
@@ -660,6 +660,13 @@ public class XDebugSessionImpl implements XDebugSession {
presentation.setErrorMessage(errorMessage);
presentation.setIcon(icon);
long timestamp = presentation.getTimestamp();
if (timestamp != 0 && XDebuggerUtilImpl.getVerifiedIcon(breakpoint).equals(icon)) {
long delay = System.currentTimeMillis() - timestamp;
presentation.setTimestamp(0);
BreakpointsUsageCollector.reportUsage(myProject, "verified." + (int)Math.pow(10,(int)Math.log10(delay)) + "+");
}
}
myDebuggerManager.getBreakpointManager().getLineBreakpointManager().queueBreakpointUpdate((XLineBreakpointImpl<?>)breakpoint);
}
@@ -955,8 +962,16 @@ public class XDebugSessionImpl implements XDebugSession {
private final class MyBreakpointListener implements XBreakpointListener<XBreakpoint<?>> {
@Override
public void breakpointAdded(@NotNull final XBreakpoint<?> breakpoint) {
if (!myBreakpointsDisabled) {
processAllHandlers(breakpoint, true);
if (processAdd(breakpoint)) {
CustomizedBreakpointPresentation presentation = getBreakpointPresentation(breakpoint);
if (presentation != null) {
if (XDebuggerUtilImpl.getVerifiedIcon(breakpoint).equals(presentation.getIcon())) {
BreakpointsUsageCollector.reportUsage(myProject, "verified.0");
}
else {
presentation.setTimestamp(System.currentTimeMillis());
}
}
}
}
@@ -972,10 +987,18 @@ public class XDebugSessionImpl implements XDebugSession {
processAllHandlers(breakpoint, false);
}
boolean processAdd(@NotNull final XBreakpoint<?> breakpoint) {
if (!myBreakpointsDisabled) {
processAllHandlers(breakpoint, true);
return true;
}
return false;
}
@Override
public void breakpointChanged(@NotNull final XBreakpoint<?> breakpoint) {
processRemove(breakpoint);
breakpointAdded(breakpoint);
processAdd(breakpoint);
}
}
@@ -0,0 +1,22 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.xdebugger.impl.breakpoints
import com.intellij.internal.statistic.service.fus.collectors.FUSProjectUsageTrigger
import com.intellij.internal.statistic.service.fus.collectors.ProjectUsageTriggerCollector
import com.intellij.internal.statistic.service.fus.collectors.UsageDescriptorKeyValidator
import com.intellij.openapi.project.Project
/**
* @author egor
*/
class BreakpointsUsageCollector : ProjectUsageTriggerCollector() {
override fun getGroupId(): String = "statistics.debugger.breakpoints.usage"
companion object {
@JvmStatic
fun reportUsage(project: Project, featureId: String) {
FUSProjectUsageTrigger.getInstance(project).trigger(BreakpointsUsageCollector::class.java,
UsageDescriptorKeyValidator.ensureProperKey(featureId))
}
}
}
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2009 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.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.xdebugger.impl.breakpoints;
import org.jetbrains.annotations.Nullable;
@@ -25,6 +11,7 @@ import javax.swing.*;
public class CustomizedBreakpointPresentation {
private Icon myIcon;
private String myErrorMessage;
private volatile long myTimestamp; // for statistics
public void setIcon(@Nullable Icon icon) {
myIcon = icon;
@@ -43,4 +30,12 @@ public class CustomizedBreakpointPresentation {
public String getErrorMessage() {
return myErrorMessage;
}
public long getTimestamp() {
return myTimestamp;
}
public void setTimestamp(long timestamp) {
myTimestamp = timestamp;
}
}
@@ -119,6 +119,13 @@ public class XBreakpointManagerImpl implements XBreakpointManager {
}
else {
myBreakpoints.put(type, breakpoint);
if (initUI) {
BreakpointsUsageCollector.reportUsage(myProject, "new.breakpoint");
BreakpointsUsageCollector.reportUsage(myProject, "new." + type.getId());
if (myDebuggerManager.getCurrentSession() != null) {
BreakpointsUsageCollector.reportUsage(myProject, "new.within.session");
}
}
}
myAllBreakpoints.add(breakpoint);
if (breakpoint instanceof XLineBreakpointImpl) {