FUS: migrate java.find.usages to new API

GitOrigin-RevId: 8c4ea6bc5d25b055121d9bb334d64955b2545e75
This commit is contained in:
Anastasia Ivanova
2022-05-04 14:02:28 +02:00
committed by intellij-monorepo-bot
parent de3b37779a
commit a3cfa64537
9 changed files with 181 additions and 120 deletions

View File

@@ -65,7 +65,7 @@
<orderEntry type="module" module-name="intellij.platform.util.jdom" />
<orderEntry type="module" module-name="intellij.copyright" />
<orderEntry type="library" name="StreamEx" level="project" />
<orderEntry type="module" module-name="intellij.platform.statistics" />
<orderEntry type="module" module-name="intellij.platform.statistics" exported="" />
<orderEntry type="module" module-name="intellij.platform.inspect" />
<orderEntry type="library" name="fastutil-min" level="project" />
<orderEntry type="module" module-name="intellij.platform.core.ui" />

View File

@@ -452,7 +452,7 @@
<projectService serviceInterface="com.intellij.debugger.ui.HotSwapUI" serviceImplementation="com.intellij.debugger.ui.HotSwapUIImpl"/>
<projectService serviceInterface="com.intellij.debugger.DebuggerManager" serviceImplementation="com.intellij.debugger.impl.DebuggerManagerImpl"/>
<statistics.counterUsagesCollector groupId="java.find.usages" version="2"/>
<statistics.counterUsagesCollector implementationClass="com.intellij.find.findUsages.JavaFindUsagesCollector"/>
<statistics.counterUsagesCollector groupId="java.extract.method" version="2"/>
<statistics.counterUsagesCollector implementationClass="com.intellij.refactoring.extractMethod.newImpl.inplace.InplaceExtractMethodCollector"/>
<statistics.counterUsagesCollector implementationClass="com.intellij.debugger.actions.JavaDebuggerActionsCollector"/>

View File

@@ -1,22 +1,7 @@
/*
* 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-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.find.findUsages;
import com.intellij.internal.statistic.eventLog.FeatureUsageData;
import com.intellij.internal.statistic.service.fus.collectors.FUCounterUsageLogger;
import com.intellij.internal.statistic.eventLog.events.EventPair;
import com.intellij.java.JavaBundle;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiClass;
@@ -25,6 +10,9 @@ import com.intellij.psi.PsiModifier;
import com.intellij.ui.StateRestoringCheckBox;
import javax.swing.*;
import java.util.List;
import static com.intellij.find.findUsages.JavaFindUsagesCollector.*;
public class FindClassUsagesDialog extends JavaFindUsagesDialog<JavaClassFindUsagesOptions> {
private StateRestoringCheckBox myCbUsages;
@@ -71,17 +59,17 @@ public class FindClassUsagesDialog extends JavaFindUsagesDialog<JavaClassFindUsa
options.isCheckDeepInheritance = true;
options.isIncludeInherited = false;
FUCounterUsageLogger.getInstance().logEvent(myPsiElement.getProject(), EVENT_LOG_GROUP, "find.class.started", createFeatureUsageData(options));
FIND_CLASS_STARTED.log(myPsiElement.getProject(), createFeatureUsageData(options));
}
@Override
protected FeatureUsageData createFeatureUsageData(JavaClassFindUsagesOptions options) {
FeatureUsageData data = super.createFeatureUsageData(options);
data.addData("methodUsages", options.isMethodsUsages);
data.addData("fieldUsages", options.isFieldsUsages);
data.addData("derivedUsages", options.isDerivedClasses);
data.addData("implementingClasses", options.isImplementingClasses);
data.addData("derivedInterfaces", options.isDerivedInterfaces);
protected List<EventPair<?>> createFeatureUsageData(JavaClassFindUsagesOptions options) {
List<EventPair<?>> data = super.createFeatureUsageData(options);
data.add(METHOD_USAGES.with(options.isMethodsUsages));
data.add(FIELD_USAGES.with(options.isFieldsUsages));
data.add(DERIVED_USAGES.with(options.isDerivedClasses));
data.add(IMPLEMENTING_CLASSES.with(options.isImplementingClasses));
data.add(DERIVED_INTERFACES.with(options.isDerivedInterfaces));
return data;
}

View File

@@ -1,7 +1,8 @@
// 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.
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.find.findUsages;
import com.intellij.internal.statistic.eventLog.FeatureUsageData;
import com.intellij.internal.statistic.eventLog.events.EventPair;
import com.intellij.internal.statistic.service.fus.collectors.FUCounterUsageLogger;
import com.intellij.java.JavaBundle;
import com.intellij.openapi.project.Project;
@@ -13,6 +14,9 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.util.List;
import static com.intellij.find.findUsages.JavaFindUsagesCollector.*;
public class FindMethodUsagesDialog extends JavaFindUsagesDialog<JavaMethodFindUsagesOptions> {
private StateRestoringCheckBox myCbSearchForBase;
@@ -51,18 +55,19 @@ public class FindMethodUsagesDialog extends JavaFindUsagesDialog<JavaMethodFindU
options.isImplicitToString = isSelected(myCbImplicitToString);
}
options.isCheckDeepInheritance = true;
FUCounterUsageLogger.getInstance().logEvent(myPsiElement.getProject(), EVENT_LOG_GROUP, "find.method.started", createFeatureUsageData(options));
FIND_METHOD_STARTED.log(myPsiElement.getProject(), createFeatureUsageData(options));
}
@Override
protected FeatureUsageData createFeatureUsageData(JavaMethodFindUsagesOptions options) {
FeatureUsageData data = super.createFeatureUsageData(options);
data.addData("searchForBaseMethods", options.isSearchForBaseMethod);
data.addData("overridingMethods", options.isOverridingMethods);
data.addData("implementingMethods", options.isImplementingMethods);
data.addData("includeInherited", options.isIncludeInherited);
data.addData("includeOverload", options.isIncludeOverloadUsages);
data.addData("implicitCalls", options.isImplicitToString);
protected List<EventPair<?>> createFeatureUsageData(JavaMethodFindUsagesOptions options) {
List<EventPair<?>> data = super.createFeatureUsageData(options);
data.add(SEARCH_FOR_BASE_METHODS.with(options.isSearchForBaseMethod));
data.add(OVERRIDING_METHODS.with(options.isOverridingMethods));
data.add(IMPLEMENTING_METHODS.with(options.isImplementingMethods));
data.add(INCLUDE_INHERITED.with(options.isIncludeInherited));
data.add(INCLUDE_OVERLOAD.with(options.isIncludeOverloadUsages));
data.add(IMPLICIT_CALLS.with(options.isImplicitToString));
return data;
}

View File

@@ -1,21 +1,8 @@
/*
* 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-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.find.findUsages;
import com.intellij.internal.statistic.eventLog.FeatureUsageData;
import com.intellij.internal.statistic.eventLog.events.EventPair;
import com.intellij.internal.statistic.service.fus.collectors.FUCounterUsageLogger;
import com.intellij.java.JavaBundle;
import com.intellij.openapi.project.Project;
@@ -23,6 +10,10 @@ import com.intellij.psi.PsiElement;
import com.intellij.ui.StateRestoringCheckBox;
import javax.swing.*;
import java.util.List;
import static com.intellij.find.findUsages.JavaFindUsagesCollector.CLASSES_USAGES;
import static com.intellij.find.findUsages.JavaFindUsagesCollector.FIND_PACKAGE_STARTED;
public class FindPackageUsagesDialog extends JavaFindUsagesDialog<JavaPackageFindUsagesOptions> {
private StateRestoringCheckBox myCbUsages;
@@ -51,13 +42,13 @@ public class FindPackageUsagesDialog extends JavaFindUsagesDialog<JavaPackageFin
}
options.isSkipPackageStatements = false;
options.isSkipImportStatements = false;
FUCounterUsageLogger.getInstance().logEvent(myPsiElement.getProject(), EVENT_LOG_GROUP, "find.package.started", createFeatureUsageData(options));
FIND_PACKAGE_STARTED.log(myPsiElement.getProject(), createFeatureUsageData(options));
}
@Override
protected FeatureUsageData createFeatureUsageData(JavaPackageFindUsagesOptions options) {
FeatureUsageData data = super.createFeatureUsageData(options);
data.addData("classesUsages", options.isClassesUsages);
protected List<EventPair<?>> createFeatureUsageData(JavaPackageFindUsagesOptions options) {
List<EventPair<?>> data = super.createFeatureUsageData(options);
data.add(CLASSES_USAGES.with(options.isClassesUsages));
return data;
}

View File

@@ -1,21 +1,6 @@
/*
* Copyright 2000-2016 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-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.find.findUsages;
import com.intellij.internal.statistic.service.fus.collectors.FUCounterUsageLogger;
import com.intellij.java.JavaBundle;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
@@ -28,6 +13,8 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import static com.intellij.find.findUsages.JavaFindUsagesCollector.FIND_THROW_STARTED;
public class FindThrowUsagesDialog extends JavaFindUsagesDialog<JavaThrowFindUsagesOptions> {
private StateRestoringCheckBox myCbUsages;
private JComboBox myCbExns;
@@ -76,7 +63,7 @@ public class FindThrowUsagesDialog extends JavaFindUsagesDialog<JavaThrowFindUsa
public void calcFindUsagesOptions(final JavaThrowFindUsagesOptions options) {
super.calcFindUsagesOptions(options);
options.isUsages = isSelected(myCbUsages) || !myHasFindWhatPanel;
FUCounterUsageLogger.getInstance().logEvent(myPsiElement.getProject(), EVENT_LOG_GROUP, "find.throw.started", createFeatureUsageData(options));
FIND_THROW_STARTED.log(myPsiElement.getProject(), createFeatureUsageData(options));
}
@Override

View File

@@ -1,22 +1,7 @@
/*
* 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-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.find.findUsages;
import com.intellij.internal.statistic.eventLog.FeatureUsageData;
import com.intellij.internal.statistic.service.fus.collectors.FUCounterUsageLogger;
import com.intellij.internal.statistic.eventLog.events.EventPair;
import com.intellij.java.JavaBundle;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.panel.ComponentPanelBuilder;
@@ -27,6 +12,9 @@ import com.intellij.ui.StateRestoringCheckBox;
import javax.swing.*;
import java.awt.*;
import java.util.List;
import static com.intellij.find.findUsages.JavaFindUsagesCollector.*;
public class FindVariableUsagesDialog extends JavaFindUsagesDialog<JavaVariableFindUsagesOptions> {
private StateRestoringCheckBox myCbSearchForAccessors;
@@ -61,17 +49,17 @@ public class FindVariableUsagesDialog extends JavaFindUsagesDialog<JavaVariableF
options.isSearchForBaseAccessors = isSelected(myCbSearchForBase);
}
FUCounterUsageLogger.getInstance().logEvent(myPsiElement.getProject(), EVENT_LOG_GROUP, "find.variable.started", createFeatureUsageData(options));
FIND_VARIABLE_STARTED.log(myPsiElement.getProject(), createFeatureUsageData(options));
}
@Override
protected FeatureUsageData createFeatureUsageData(JavaVariableFindUsagesOptions options) {
FeatureUsageData data = super.createFeatureUsageData(options);
data.addData("searchForBaseAccessors", options.isSearchForBaseAccessors);
data.addData("searchForAccessors", options.isSearchForAccessors);
data.addData("searchInOverriding", options.isSearchInOverridingMethods);
data.addData("readAccess", options.isReadAccess);
data.addData("writeAccess", options.isWriteAccess);
protected List<EventPair<?>> createFeatureUsageData(JavaVariableFindUsagesOptions options) {
List<EventPair<?>> data = super.createFeatureUsageData(options);
data.add(SEARCH_FOR_BASE_ACCESSOR.with(options.isSearchForBaseAccessors));
data.add(SEARCH_FOR_ACCESSORS.with(options.isSearchForAccessors));
data.add(SEARCH_IN_OVERRIDING.with(options.isSearchInOverridingMethods));
data.add(READ_ACCESS.with(options.isReadAccess));
data.add(WRITE_ACCESS.with(options.isWriteAccess));
return data;
}

View File

@@ -0,0 +1,113 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.find.findUsages
import com.intellij.ide.util.scopeChooser.ScopeIdMapper
import com.intellij.internal.statistic.eventLog.EventLogGroup
import com.intellij.internal.statistic.eventLog.events.EventField
import com.intellij.internal.statistic.eventLog.events.EventFields
import com.intellij.internal.statistic.eventLog.events.VarargEventId
import com.intellij.internal.statistic.service.fus.collectors.CounterUsagesCollector
internal class JavaFindUsagesCollector : CounterUsagesCollector() {
override fun getGroup(): EventLogGroup = GROUP
companion object {
private val GROUP = EventLogGroup("java.find.usages", 3)
@JvmField
val USAGES = EventFields.Boolean("usages")
@JvmField
val TEXT_OCCURRENCES = EventFields.Boolean("textOccurrences")
@JvmField
val SEARCH_SCOPE = EventFields.String("searchScope", ScopeIdMapper.standardNames.toList())
@JvmField
val METHOD_USAGES = EventFields.Boolean("methodUsages")
@JvmField
val FIELD_USAGES = EventFields.Boolean("fieldUsages")
@JvmField
val DERIVED_USAGES = EventFields.Boolean("derivedUsages")
@JvmField
val IMPLEMENTING_CLASSES = EventFields.Boolean("implementingClasses")
@JvmField
val DERIVED_INTERFACES = EventFields.Boolean("derivedInterfaces")
@JvmField
val SEARCH_FOR_BASE_METHODS = EventFields.Boolean("searchForBaseMethods")
@JvmField
val OVERRIDING_METHODS = EventFields.Boolean("overridingMethods")
@JvmField
val IMPLEMENTING_METHODS = EventFields.Boolean("implementingMethods")
@JvmField
val INCLUDE_INHERITED = EventFields.Boolean("includeInherited")
@JvmField
val INCLUDE_OVERLOAD = EventFields.Boolean("includeOverload")
@JvmField
val IMPLICIT_CALLS = EventFields.Boolean("implicitCalls")
@JvmField
val CLASSES_USAGES = EventFields.Boolean("classesUsages")
@JvmField
val SEARCH_FOR_BASE_ACCESSOR = EventFields.Boolean("searchForBaseAccessors")
@JvmField
val SEARCH_FOR_ACCESSORS = EventFields.Boolean("searchForAccessors")
@JvmField
val SEARCH_IN_OVERRIDING = EventFields.Boolean("searchInOverriding")
@JvmField
val READ_ACCESS = EventFields.Boolean("readAccess")
@JvmField
val WRITE_ACCESS = EventFields.Boolean("writeAccess")
@JvmField
val FIND_CLASS_STARTED = registerEvent("find.class.started",
METHOD_USAGES,
FIELD_USAGES,
DERIVED_USAGES,
IMPLEMENTING_CLASSES,
DERIVED_INTERFACES)
@JvmField
val FIND_METHOD_STARTED = registerEvent("find.method.started",
SEARCH_FOR_BASE_METHODS,
OVERRIDING_METHODS,
IMPLEMENTING_METHODS,
INCLUDE_INHERITED,
INCLUDE_OVERLOAD,
IMPLICIT_CALLS)
@JvmField
val FIND_PACKAGE_STARTED = registerEvent("find.package.started", CLASSES_USAGES)
@JvmField
val FIND_THROW_STARTED = registerEvent("find.throw.started")
@JvmField
val FIND_VARIABLE_STARTED = registerEvent("find.variable.started",
SEARCH_FOR_BASE_ACCESSOR,
SEARCH_FOR_ACCESSORS,
SEARCH_IN_OVERRIDING,
READ_ACCESS,
WRITE_ACCESS)
private fun registerEvent(eventId: String, vararg additionalFields: EventField<*>): VarargEventId {
return GROUP.registerVarargEvent(eventId, USAGES, TEXT_OCCURRENCES, SEARCH_SCOPE, *additionalFields)
}
}
}

View File

@@ -1,23 +1,9 @@
/*
* Copyright 2000-2014 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-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.find.findUsages;
import com.intellij.find.FindSettings;
import com.intellij.ide.util.scopeChooser.ScopeIdMapper;
import com.intellij.internal.statistic.eventLog.FeatureUsageData;
import com.intellij.internal.statistic.eventLog.events.EventPair;
import com.intellij.java.JavaBundle;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
@@ -27,11 +13,14 @@ import com.intellij.ui.StateRestoringCheckBox;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
import static com.intellij.find.findUsages.JavaFindUsagesCollector.*;
public abstract class JavaFindUsagesDialog<T extends JavaFindUsagesOptions> extends CommonFindUsagesDialog {
private StateRestoringCheckBox myCbIncludeOverloadedMethods;
private boolean myIncludeOverloadedMethodsAvailable;
protected static final String EVENT_LOG_GROUP = "java.find.usages";
protected JavaFindUsagesDialog(@NotNull PsiElement element,
@NotNull Project project,
@@ -56,14 +45,14 @@ public abstract class JavaFindUsagesDialog<T extends JavaFindUsagesOptions> exte
}
}
protected FeatureUsageData createFeatureUsageData(T options) {
FeatureUsageData data = new FeatureUsageData();
data.addData("usages", options.isUsages);
data.addData("textOccurrences", options.isSearchForTextOccurrences);
protected List<EventPair<?>> createFeatureUsageData(T options) {
List<EventPair<?>> data = new ArrayList<>();
data.add(USAGES.with(options.isUsages));
data.add(TEXT_OCCURRENCES.with(options.isSearchForTextOccurrences));
String serializedName = ScopeIdMapper.getInstance().getScopeSerializationId(options.searchScope.getDisplayName());
if (ScopeIdMapper.getStandardNames().contains(serializedName)) {
data.addData("searchScope", serializedName);
data.add(SEARCH_SCOPE.with(serializedName));
}
return data;