Implement "Find usages" using UsagesSearch (classes, functions, properties)
This commit is contained in:
@@ -272,6 +272,10 @@ super.methods.action.key.find.usages=find usages of
|
|||||||
|
|
||||||
find.what.implementing.methods.checkbox=&Implementing functions
|
find.what.implementing.methods.checkbox=&Implementing functions
|
||||||
find.what.overriding.methods.checkbox=Over&riding functions
|
find.what.overriding.methods.checkbox=Over&riding functions
|
||||||
|
find.what.implementing.properties.checkbox=&Implementing properties
|
||||||
|
find.what.overriding.properties.checkbox=Over&riding properties
|
||||||
|
find.what.property.readers.checkbox=Readers
|
||||||
|
find.what.property.writers.checkbox=Writers
|
||||||
find.options.include.overloaded.methods.checkbox=Include o&verloaded functions and extensions
|
find.options.include.overloaded.methods.checkbox=Include o&verloaded functions and extensions
|
||||||
find.what.functions.usages.checkbox=Usages of &functions
|
find.what.functions.usages.checkbox=Usages of &functions
|
||||||
find.what.properties.usages.checkbox=Usages of &properties
|
find.what.properties.usages.checkbox=Usages of &properties
|
||||||
|
|||||||
@@ -24,30 +24,35 @@ import org.jetbrains.jet.lang.psi.JetClass
|
|||||||
import org.jetbrains.jet.lang.psi.JetDeclaration
|
import org.jetbrains.jet.lang.psi.JetDeclaration
|
||||||
import org.jetbrains.jet.lang.psi.JetNamedFunction
|
import org.jetbrains.jet.lang.psi.JetNamedFunction
|
||||||
import org.jetbrains.jet.plugin.findUsages.handlers.KotlinFindClassUsagesHandler
|
import org.jetbrains.jet.plugin.findUsages.handlers.KotlinFindClassUsagesHandler
|
||||||
import org.jetbrains.jet.plugin.findUsages.handlers.KotlinFindFunctionUsagesHandler
|
import org.jetbrains.jet.plugin.findUsages.handlers.KotlinFindCallableUsagesHandler
|
||||||
import org.jetbrains.jet.plugin.refactoring.JetRefactoringUtil
|
import org.jetbrains.jet.plugin.refactoring.JetRefactoringUtil
|
||||||
|
import org.jetbrains.jet.lang.psi.JetProperty
|
||||||
|
import org.jetbrains.jet.lang.psi.JetCallableDeclaration
|
||||||
|
|
||||||
public class KotlinFindUsagesHandlerFactory(project: Project) : FindUsagesHandlerFactory() {
|
public class KotlinFindUsagesHandlerFactory(project: Project) : FindUsagesHandlerFactory() {
|
||||||
val findMethodOptions = KotlinMethodFindUsagesOptions(project)
|
val findFunctionOptions = KotlinFunctionFindUsagesOptions(project)
|
||||||
|
val findPropertyOptions = KotlinPropertyFindUsagesOptions(project)
|
||||||
val findClassOptions = KotlinClassFindUsagesOptions(project)
|
val findClassOptions = KotlinClassFindUsagesOptions(project)
|
||||||
|
|
||||||
public override fun canFindUsages(element: PsiElement): Boolean =
|
public override fun canFindUsages(element: PsiElement): Boolean =
|
||||||
element is JetClass || element is JetNamedFunction
|
element is JetClass || element is JetNamedFunction || element is JetProperty
|
||||||
|
|
||||||
public override fun createFindUsagesHandler(element: PsiElement, forHighlightUsages: Boolean): FindUsagesHandler {
|
public override fun createFindUsagesHandler(element: PsiElement, forHighlightUsages: Boolean): FindUsagesHandler {
|
||||||
when(element) {
|
when(element) {
|
||||||
is JetClass ->
|
is JetClass ->
|
||||||
return KotlinFindClassUsagesHandler(element, this)
|
return KotlinFindClassUsagesHandler(element, this)
|
||||||
|
|
||||||
is JetNamedFunction -> {
|
is JetNamedFunction, is JetProperty -> {
|
||||||
return if (forHighlightUsages) KotlinFindFunctionUsagesHandler(element, this)
|
val declaration = element as JetCallableDeclaration
|
||||||
else JetRefactoringUtil.checkSuperMethods(element, null, "super.methods.action.key.find.usages")?.let { methods ->
|
|
||||||
when (methods.size()) {
|
return if (forHighlightUsages) KotlinFindCallableUsagesHandler.getInstance(declaration, this)
|
||||||
|
else JetRefactoringUtil.checkSuperMethods(declaration, null, "super.methods.action.key.find.usages")?.let { callables ->
|
||||||
|
when (callables.size()) {
|
||||||
0 -> null
|
0 -> null
|
||||||
1 ->
|
1 ->
|
||||||
KotlinFindFunctionUsagesHandler(methods.get(0) as JetNamedFunction, this)
|
KotlinFindCallableUsagesHandler.getInstance(callables.get(0) as JetCallableDeclaration, this)
|
||||||
else ->
|
else ->
|
||||||
KotlinFindFunctionUsagesHandler(element as JetNamedFunction, methods, this)
|
KotlinFindCallableUsagesHandler.getInstance(declaration, callables, this)
|
||||||
}
|
}
|
||||||
} ?: FindUsagesHandler.NULL_HANDLER
|
} ?: FindUsagesHandler.NULL_HANDLER
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-6
@@ -8,17 +8,18 @@ import com.intellij.openapi.project.Project;
|
|||||||
import com.intellij.psi.PsiMethod;
|
import com.intellij.psi.PsiMethod;
|
||||||
import com.intellij.ui.SimpleColoredComponent;
|
import com.intellij.ui.SimpleColoredComponent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
||||||
import org.jetbrains.jet.plugin.JetBundle;
|
import org.jetbrains.jet.plugin.JetBundle;
|
||||||
import org.jetbrains.jet.plugin.findUsages.KotlinMethodFindUsagesOptions;
|
import org.jetbrains.jet.plugin.findUsages.KotlinFunctionFindUsagesOptions;
|
||||||
import org.jetbrains.jet.plugin.refactoring.JetRefactoringUtil;
|
import org.jetbrains.jet.plugin.refactoring.JetRefactoringUtil;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
public class KotlinFindMethodUsagesDialog extends FindMethodUsagesDialog {
|
public class KotlinFindFunctionUsagesDialog extends FindMethodUsagesDialog {
|
||||||
public KotlinFindMethodUsagesDialog(
|
public KotlinFindFunctionUsagesDialog(
|
||||||
PsiMethod method,
|
PsiMethod method,
|
||||||
Project project,
|
Project project,
|
||||||
KotlinMethodFindUsagesOptions findUsagesOptions,
|
KotlinFunctionFindUsagesOptions findUsagesOptions,
|
||||||
boolean toShowInNewTab,
|
boolean toShowInNewTab,
|
||||||
boolean mustOpenInNewTab,
|
boolean mustOpenInNewTab,
|
||||||
boolean isSingleFile,
|
boolean isSingleFile,
|
||||||
@@ -28,8 +29,8 @@ public class KotlinFindMethodUsagesDialog extends FindMethodUsagesDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected KotlinMethodFindUsagesOptions getFindUsagesOptions() {
|
protected KotlinFunctionFindUsagesOptions getFindUsagesOptions() {
|
||||||
return (KotlinMethodFindUsagesOptions) super.getFindUsagesOptions();
|
return (KotlinFunctionFindUsagesOptions) myFindUsagesOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -40,6 +41,7 @@ public class KotlinFindMethodUsagesDialog extends FindMethodUsagesDialog {
|
|||||||
@Override
|
@Override
|
||||||
protected JPanel createFindWhatPanel() {
|
protected JPanel createFindWhatPanel() {
|
||||||
JPanel findWhatPanel = super.createFindWhatPanel();
|
JPanel findWhatPanel = super.createFindWhatPanel();
|
||||||
|
|
||||||
if (findWhatPanel != null) {
|
if (findWhatPanel != null) {
|
||||||
Utils.renameCheckbox(
|
Utils.renameCheckbox(
|
||||||
findWhatPanel,
|
findWhatPanel,
|
||||||
+113
@@ -0,0 +1,113 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2013 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 org.jetbrains.jet.plugin.findUsages.dialogs;
|
||||||
|
|
||||||
|
import com.intellij.find.FindBundle;
|
||||||
|
import com.intellij.find.FindSettings;
|
||||||
|
import com.intellij.find.findUsages.FindUsagesHandler;
|
||||||
|
import com.intellij.find.findUsages.JavaFindUsagesDialog;
|
||||||
|
import com.intellij.openapi.project.Project;
|
||||||
|
import com.intellij.psi.PsiElement;
|
||||||
|
import com.intellij.ui.IdeBorderFactory;
|
||||||
|
import com.intellij.ui.StateRestoringCheckBox;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetProperty;
|
||||||
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
|
import org.jetbrains.jet.plugin.JetBundle;
|
||||||
|
import org.jetbrains.jet.plugin.findUsages.KotlinPropertyFindUsagesOptions;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class KotlinFindPropertyUsagesDialog extends JavaFindUsagesDialog<KotlinPropertyFindUsagesOptions> {
|
||||||
|
public KotlinFindPropertyUsagesDialog(
|
||||||
|
PsiElement element,
|
||||||
|
Project project,
|
||||||
|
KotlinPropertyFindUsagesOptions findUsagesOptions,
|
||||||
|
boolean toShowInNewTab,
|
||||||
|
boolean mustOpenInNewTab,
|
||||||
|
boolean isSingleFile,
|
||||||
|
FindUsagesHandler handler
|
||||||
|
) {
|
||||||
|
super(element, project, findUsagesOptions, toShowInNewTab, mustOpenInNewTab, isSingleFile, handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
private StateRestoringCheckBox cbReaders;
|
||||||
|
private StateRestoringCheckBox cbWriters;
|
||||||
|
private StateRestoringCheckBox cbOverrides;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected KotlinPropertyFindUsagesOptions getFindUsagesOptions() {
|
||||||
|
return (KotlinPropertyFindUsagesOptions) myFindUsagesOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JComponent getPreferredFocusedControl() {
|
||||||
|
return myCbToSkipResultsWhenOneUsage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void calcFindUsagesOptions(KotlinPropertyFindUsagesOptions options) {
|
||||||
|
super.calcFindUsagesOptions(options);
|
||||||
|
|
||||||
|
options.isReadAccess = isSelected(cbReaders);
|
||||||
|
options.isWriteAccess = isSelected(cbWriters);
|
||||||
|
options.setSearchOverrides(isSelected(cbOverrides));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JPanel createFindWhatPanel() {
|
||||||
|
JPanel findWhatPanel = new JPanel();
|
||||||
|
findWhatPanel.setBorder(IdeBorderFactory.createTitledBorder(FindBundle.message("find.what.group"), true));
|
||||||
|
findWhatPanel.setLayout(new BoxLayout(findWhatPanel, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
|
KotlinPropertyFindUsagesOptions options = getFindUsagesOptions();
|
||||||
|
|
||||||
|
cbReaders = addCheckboxToPanel(
|
||||||
|
JetBundle.message("find.what.property.readers.checkbox"),
|
||||||
|
options.isReadAccess,
|
||||||
|
findWhatPanel,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
cbWriters = addCheckboxToPanel(
|
||||||
|
JetBundle.message("find.what.property.writers.checkbox"),
|
||||||
|
options.isWriteAccess,
|
||||||
|
findWhatPanel,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
return findWhatPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addUsagesOptions(JPanel optionsPanel) {
|
||||||
|
super.addUsagesOptions(optionsPanel);
|
||||||
|
|
||||||
|
boolean isAbstract = ((JetProperty) getPsiElement()).hasModifier(JetTokens.ABSTRACT_KEYWORD);
|
||||||
|
cbOverrides = addCheckboxToPanel(
|
||||||
|
isAbstract
|
||||||
|
? JetBundle.message("find.what.implementing.properties.checkbox")
|
||||||
|
: JetBundle.message("find.what.overriding.properties.checkbox"),
|
||||||
|
FindSettings.getInstance().isSearchOverloadedMethods(),
|
||||||
|
optionsPanel,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void update() {
|
||||||
|
setOKActionEnabled(isSelected(cbReaders) || isSelected(cbWriters));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,17 +19,101 @@ package org.jetbrains.jet.plugin.findUsages
|
|||||||
import com.intellij.find.findUsages.JavaMethodFindUsagesOptions
|
import com.intellij.find.findUsages.JavaMethodFindUsagesOptions
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.find.findUsages.JavaClassFindUsagesOptions
|
import com.intellij.find.findUsages.JavaClassFindUsagesOptions
|
||||||
|
import org.jetbrains.jet.plugin.search.usagesSearch.ClassUsagesSearchHelper
|
||||||
|
import org.jetbrains.jet.plugin.search.usagesSearch.UsagesSearchTarget
|
||||||
|
import com.intellij.psi.PsiNamedElement
|
||||||
|
import org.jetbrains.jet.plugin.search.usagesSearch.UsagesSearchLocation
|
||||||
|
import com.intellij.find.findUsages.FindUsagesOptions
|
||||||
|
import org.jetbrains.jet.plugin.search.usagesSearch.PropertyUsagesSearchHelper
|
||||||
|
import com.intellij.find.findUsages.JavaFindUsagesOptions
|
||||||
|
import org.jetbrains.jet.plugin.search.usagesSearch.DeclarationUsagesSearchHelper
|
||||||
|
import com.intellij.psi.search.GlobalSearchScope
|
||||||
|
import org.jetbrains.jet.plugin.search.usagesSearch.ClassDeclarationsUsagesSearchHelper
|
||||||
|
import org.jetbrains.jet.plugin.search.usagesSearch.FunctionUsagesSearchHelper
|
||||||
|
import org.jetbrains.jet.plugin.search.usagesSearch.UsagesSearchHelper
|
||||||
|
import kotlin.test.fail
|
||||||
|
import com.intellij.find.findUsages.JavaVariableFindUsagesOptions
|
||||||
|
|
||||||
public class KotlinMethodFindUsagesOptions(project: Project) : JavaMethodFindUsagesOptions(project)
|
public class KotlinClassFindUsagesOptions(project: Project) : JavaClassFindUsagesOptions(project) {
|
||||||
|
public var searchConstructorUsages: Boolean = true
|
||||||
|
|
||||||
public class KotlinClassFindUsagesOptions(project : Project) : JavaClassFindUsagesOptions(project) {
|
public override fun equals(o: Any?): Boolean {
|
||||||
public var searchConstructorUsages : Boolean = true
|
|
||||||
|
|
||||||
public override fun equals(o : Any?) : Boolean {
|
|
||||||
return super.equals(o) && o is KotlinClassFindUsagesOptions && o.searchConstructorUsages == searchConstructorUsages
|
return super.equals(o) && o is KotlinClassFindUsagesOptions && o.searchConstructorUsages == searchConstructorUsages
|
||||||
}
|
}
|
||||||
|
|
||||||
public override fun hashCode() : Int {
|
public override fun hashCode(): Int {
|
||||||
return 31 * super.hashCode() + if (searchConstructorUsages) 1 else 0
|
return 31 * super.hashCode() + if (searchConstructorUsages) 1 else 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public trait KotlinCallableFindUsagesOptions {
|
||||||
|
public var searchOverrides: Boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
public class KotlinFunctionFindUsagesOptions(project: Project): KotlinCallableFindUsagesOptions, JavaMethodFindUsagesOptions(project) {
|
||||||
|
override var searchOverrides: Boolean
|
||||||
|
get() = isOverridingMethods
|
||||||
|
set(value: Boolean) {
|
||||||
|
isOverridingMethods = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class KotlinPropertyFindUsagesOptions(project: Project): KotlinCallableFindUsagesOptions, JavaVariableFindUsagesOptions(project) {
|
||||||
|
override var searchOverrides: Boolean = false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun KotlinClassFindUsagesOptions.toClassHelper(): ClassUsagesSearchHelper =
|
||||||
|
ClassUsagesSearchHelper().let { builder ->
|
||||||
|
builder.constructorUsages = searchConstructorUsages
|
||||||
|
builder.nonConstructorUsages = isUsages
|
||||||
|
builder.skipImports = isSkipImportStatements
|
||||||
|
|
||||||
|
builder
|
||||||
|
}
|
||||||
|
|
||||||
|
fun KotlinClassFindUsagesOptions.toClassDeclarationsHelper(): ClassDeclarationsUsagesSearchHelper =
|
||||||
|
ClassDeclarationsUsagesSearchHelper().let { builder ->
|
||||||
|
builder.functionUsages = isMethodsUsages
|
||||||
|
builder.propertyUsages = isFieldsUsages
|
||||||
|
builder.skipImports = isSkipImportStatements
|
||||||
|
|
||||||
|
builder
|
||||||
|
}
|
||||||
|
|
||||||
|
fun KotlinFunctionFindUsagesOptions.toHelper(): FunctionUsagesSearchHelper =
|
||||||
|
FunctionUsagesSearchHelper().let { builder ->
|
||||||
|
builder.selfUsages = isUsages
|
||||||
|
builder.overrideUsages = isUsages
|
||||||
|
builder.overloadUsages = isIncludeOverloadUsages
|
||||||
|
builder.extensionUsages = isIncludeOverloadUsages
|
||||||
|
builder.skipImports = isSkipImportStatements
|
||||||
|
|
||||||
|
builder
|
||||||
|
}
|
||||||
|
|
||||||
|
fun KotlinPropertyFindUsagesOptions.toHelper(): PropertyUsagesSearchHelper =
|
||||||
|
PropertyUsagesSearchHelper().let { builder ->
|
||||||
|
builder.selfUsages = isUsages
|
||||||
|
builder.overrideUsages = isUsages
|
||||||
|
builder.readUsages = isReadAccess
|
||||||
|
builder.writeUsages = isWriteAccess
|
||||||
|
builder.skipImports = isSkipImportStatements
|
||||||
|
|
||||||
|
builder
|
||||||
|
}
|
||||||
|
|
||||||
|
fun JavaFindUsagesOptions.toHelper(): DeclarationUsagesSearchHelper<PsiNamedElement> =
|
||||||
|
DeclarationUsagesSearchHelper<PsiNamedElement>().let { builder ->
|
||||||
|
builder.skipImports = isSkipImportStatements
|
||||||
|
|
||||||
|
builder
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T : PsiNamedElement> FindUsagesOptions.toSearchTarget(element: T, restrictByTarget: Boolean): UsagesSearchTarget<T> {
|
||||||
|
val location = if (isSearchForTextOccurrences && searchScope is GlobalSearchScope)
|
||||||
|
UsagesSearchLocation.EVERYWHERE
|
||||||
|
else
|
||||||
|
UsagesSearchLocation.DEFAULT
|
||||||
|
|
||||||
|
return UsagesSearchTarget(element, searchScope ?: element.getUseScope(), location, restrictByTarget)
|
||||||
|
}
|
||||||
|
|||||||
+203
@@ -0,0 +1,203 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2013 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 org.jetbrains.jet.plugin.findUsages.handlers;
|
||||||
|
|
||||||
|
import com.intellij.find.findUsages.AbstractFindUsagesDialog;
|
||||||
|
import com.intellij.find.findUsages.FindUsagesOptions;
|
||||||
|
import com.intellij.openapi.actionSystem.DataContext;
|
||||||
|
import com.intellij.openapi.application.ApplicationManager;
|
||||||
|
import com.intellij.openapi.util.Computable;
|
||||||
|
import com.intellij.psi.PsiElement;
|
||||||
|
import com.intellij.psi.PsiMethod;
|
||||||
|
import com.intellij.psi.PsiReference;
|
||||||
|
import com.intellij.psi.search.PsiElementProcessor;
|
||||||
|
import com.intellij.psi.search.PsiElementProcessorAdapter;
|
||||||
|
import com.intellij.psi.search.searches.OverridingMethodsSearch;
|
||||||
|
import com.intellij.usageView.UsageInfo;
|
||||||
|
import com.intellij.util.Processor;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jetbrains.jet.asJava.LightClassUtil;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetCallableDeclaration;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetProperty;
|
||||||
|
import org.jetbrains.jet.plugin.findUsages.*;
|
||||||
|
import org.jetbrains.jet.plugin.findUsages.dialogs.KotlinFindFunctionUsagesDialog;
|
||||||
|
import org.jetbrains.jet.plugin.findUsages.dialogs.KotlinFindPropertyUsagesDialog;
|
||||||
|
import org.jetbrains.jet.plugin.search.usagesSearch.UsagesSearch;
|
||||||
|
import org.jetbrains.jet.plugin.search.usagesSearch.UsagesSearchHelper;
|
||||||
|
import org.jetbrains.jet.plugin.search.usagesSearch.UsagesSearchRequest;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
public abstract class KotlinFindCallableUsagesHandler<T extends JetCallableDeclaration> extends KotlinFindUsagesHandler<T> {
|
||||||
|
private static class Function extends KotlinFindCallableUsagesHandler<JetNamedFunction> {
|
||||||
|
public Function(
|
||||||
|
@NotNull JetNamedFunction declaration,
|
||||||
|
@NotNull Collection<? extends PsiElement> elementsToSearch,
|
||||||
|
@NotNull KotlinFindUsagesHandlerFactory factory
|
||||||
|
) {
|
||||||
|
super(declaration, elementsToSearch, factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected UsagesSearchHelper<JetNamedFunction> getSearchHelper(KotlinCallableFindUsagesOptions options) {
|
||||||
|
return FindUsagesPackage.toHelper((KotlinFunctionFindUsagesOptions) options);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public FindUsagesOptions getFindUsagesOptions(@Nullable DataContext dataContext) {
|
||||||
|
return getFactory().getFindFunctionOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public AbstractFindUsagesDialog getFindUsagesDialog(boolean isSingleFile, boolean toShowInNewTab, boolean mustOpenInNewTab) {
|
||||||
|
KotlinFunctionFindUsagesOptions options = getFactory().getFindFunctionOptions();
|
||||||
|
Iterator<PsiMethod> lightMethods = getLightMethods(getElement()).iterator();
|
||||||
|
if (lightMethods.hasNext()) {
|
||||||
|
return new KotlinFindFunctionUsagesDialog(
|
||||||
|
lightMethods.next(), getProject(), options, toShowInNewTab, mustOpenInNewTab, isSingleFile, this
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getFindUsagesDialog(isSingleFile, toShowInNewTab, mustOpenInNewTab);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Property extends KotlinFindCallableUsagesHandler<JetProperty> {
|
||||||
|
public Property(
|
||||||
|
@NotNull JetProperty declaration,
|
||||||
|
@NotNull Collection<? extends PsiElement> elementsToSearch,
|
||||||
|
@NotNull KotlinFindUsagesHandlerFactory factory
|
||||||
|
) {
|
||||||
|
super(declaration, elementsToSearch, factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected UsagesSearchHelper<JetProperty> getSearchHelper(KotlinCallableFindUsagesOptions options) {
|
||||||
|
return FindUsagesPackage.toHelper((KotlinPropertyFindUsagesOptions) options);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public FindUsagesOptions getFindUsagesOptions(@Nullable DataContext dataContext) {
|
||||||
|
return getFactory().getFindPropertyOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public AbstractFindUsagesDialog getFindUsagesDialog(boolean isSingleFile, boolean toShowInNewTab, boolean mustOpenInNewTab) {
|
||||||
|
KotlinPropertyFindUsagesOptions options = getFactory().getFindPropertyOptions();
|
||||||
|
Iterator<PsiMethod> lightMethods = getLightMethods(getElement()).iterator();
|
||||||
|
if (lightMethods.hasNext()) {
|
||||||
|
return new KotlinFindPropertyUsagesDialog(
|
||||||
|
getElement(), getProject(), options, toShowInNewTab, mustOpenInNewTab, isSingleFile, this
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getFindUsagesDialog(isSingleFile, toShowInNewTab, mustOpenInNewTab);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected KotlinFindCallableUsagesHandler(
|
||||||
|
@NotNull T declaration,
|
||||||
|
@NotNull Collection<? extends PsiElement> elementsToSearch,
|
||||||
|
@NotNull KotlinFindUsagesHandlerFactory factory
|
||||||
|
) {
|
||||||
|
super(declaration, elementsToSearch, factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract UsagesSearchHelper<T> getSearchHelper(KotlinCallableFindUsagesOptions options);
|
||||||
|
|
||||||
|
private static Iterable<PsiMethod> getLightMethods(JetCallableDeclaration element) {
|
||||||
|
if (element instanceof JetNamedFunction) {
|
||||||
|
PsiMethod method = LightClassUtil.getLightClassMethod((JetNamedFunction) element);
|
||||||
|
return method != null ? Collections.singletonList(method) : Collections.<PsiMethod>emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (element instanceof JetProperty) {
|
||||||
|
return LightClassUtil.getLightClassPropertyMethods((JetProperty) element);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean searchReferences(
|
||||||
|
@NotNull final PsiElement element, @NotNull final Processor<UsageInfo> processor, @NotNull FindUsagesOptions options
|
||||||
|
) {
|
||||||
|
KotlinCallableFindUsagesOptions kotlinOptions = (KotlinCallableFindUsagesOptions) options;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
UsagesSearchRequest request =
|
||||||
|
getSearchHelper(kotlinOptions).newRequest(FindUsagesPackage.toSearchTarget(options, (T) element, true));
|
||||||
|
|
||||||
|
for (PsiReference ref : UsagesSearch.instance$.search(request)) {
|
||||||
|
processUsage(processor, ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator<PsiMethod> lightMethods = ApplicationManager.getApplication().runReadAction(new Computable<Iterator<PsiMethod>>() {
|
||||||
|
@Override
|
||||||
|
public Iterator<PsiMethod> compute() {
|
||||||
|
return getLightMethods((JetCallableDeclaration) element).iterator();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (kotlinOptions.getSearchOverrides()) {
|
||||||
|
while (lightMethods.hasNext()) {
|
||||||
|
OverridingMethodsSearch.search(lightMethods.next(), options.searchScope, true).forEach(
|
||||||
|
new PsiElementProcessorAdapter<PsiMethod>(
|
||||||
|
new PsiElementProcessor<PsiMethod>() {
|
||||||
|
@Override
|
||||||
|
public boolean execute(@NotNull PsiMethod element) {
|
||||||
|
return processUsage(processor, element.getNavigationElement());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isSearchForTextOccurencesAvailable(@NotNull PsiElement psiElement, boolean isSingleFile) {
|
||||||
|
return !isSingleFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static KotlinFindCallableUsagesHandler<? extends JetCallableDeclaration> getInstance(
|
||||||
|
@NotNull JetCallableDeclaration declaration,
|
||||||
|
@NotNull Collection<? extends PsiElement> elementsToSearch,
|
||||||
|
@NotNull KotlinFindUsagesHandlerFactory factory) {
|
||||||
|
return declaration instanceof JetNamedFunction
|
||||||
|
? new Function((JetNamedFunction) declaration, elementsToSearch, factory)
|
||||||
|
: new Property((JetProperty) declaration, elementsToSearch, factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static KotlinFindCallableUsagesHandler<? extends JetCallableDeclaration> getInstance(
|
||||||
|
@NotNull JetCallableDeclaration declaration,
|
||||||
|
@NotNull KotlinFindUsagesHandlerFactory factory) {
|
||||||
|
return getInstance(declaration, Collections.<PsiElement>emptyList(), factory);
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
-46
@@ -18,10 +18,8 @@ package org.jetbrains.jet.plugin.findUsages.handlers;
|
|||||||
|
|
||||||
import com.intellij.find.findUsages.AbstractFindUsagesDialog;
|
import com.intellij.find.findUsages.AbstractFindUsagesDialog;
|
||||||
import com.intellij.find.findUsages.FindUsagesOptions;
|
import com.intellij.find.findUsages.FindUsagesOptions;
|
||||||
import com.intellij.find.findUsages.JavaClassFindUsagesOptions;
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
import com.intellij.openapi.actionSystem.DataContext;
|
||||||
import com.intellij.openapi.application.ApplicationManager;
|
import com.intellij.openapi.application.ApplicationManager;
|
||||||
import com.intellij.openapi.application.ReadActionProcessor;
|
|
||||||
import com.intellij.openapi.util.Computable;
|
import com.intellij.openapi.util.Computable;
|
||||||
import com.intellij.openapi.util.Condition;
|
import com.intellij.openapi.util.Condition;
|
||||||
import com.intellij.psi.PsiClass;
|
import com.intellij.psi.PsiClass;
|
||||||
@@ -30,22 +28,20 @@ import com.intellij.psi.PsiReference;
|
|||||||
import com.intellij.psi.search.PsiElementProcessor;
|
import com.intellij.psi.search.PsiElementProcessor;
|
||||||
import com.intellij.psi.search.PsiElementProcessorAdapter;
|
import com.intellij.psi.search.PsiElementProcessorAdapter;
|
||||||
import com.intellij.psi.search.searches.ClassInheritorsSearch;
|
import com.intellij.psi.search.searches.ClassInheritorsSearch;
|
||||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
|
||||||
import com.intellij.usageView.UsageInfo;
|
import com.intellij.usageView.UsageInfo;
|
||||||
import com.intellij.util.Processor;
|
import com.intellij.util.Processor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.asJava.LightClassUtil;
|
import org.jetbrains.jet.asJava.LightClassUtil;
|
||||||
import org.jetbrains.jet.lang.psi.JetClass;
|
import org.jetbrains.jet.lang.psi.JetClass;
|
||||||
import org.jetbrains.jet.lang.psi.JetDeclaration;
|
import org.jetbrains.jet.lang.psi.JetClassOrObject;
|
||||||
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
|
||||||
import org.jetbrains.jet.lang.psi.JetProperty;
|
|
||||||
import org.jetbrains.jet.plugin.findUsages.FindUsagesPackage;
|
import org.jetbrains.jet.plugin.findUsages.FindUsagesPackage;
|
||||||
|
import org.jetbrains.jet.plugin.findUsages.KotlinClassFindUsagesOptions;
|
||||||
import org.jetbrains.jet.plugin.findUsages.KotlinFindUsagesHandlerFactory;
|
import org.jetbrains.jet.plugin.findUsages.KotlinFindUsagesHandlerFactory;
|
||||||
import org.jetbrains.jet.plugin.findUsages.dialogs.KotlinFindClassUsagesDialog;
|
import org.jetbrains.jet.plugin.findUsages.dialogs.KotlinFindClassUsagesDialog;
|
||||||
import org.jetbrains.jet.plugin.findUsages.KotlinClassFindUsagesOptions;
|
import org.jetbrains.jet.plugin.search.usagesSearch.UsagesSearch;
|
||||||
|
import org.jetbrains.jet.plugin.search.usagesSearch.UsagesSearchRequest;
|
||||||
import java.util.Collection;
|
import org.jetbrains.jet.plugin.search.usagesSearch.UsagesSearchTarget;
|
||||||
|
|
||||||
public class KotlinFindClassUsagesHandler extends KotlinFindUsagesHandler<JetClass> {
|
public class KotlinFindClassUsagesHandler extends KotlinFindUsagesHandler<JetClass> {
|
||||||
public KotlinFindClassUsagesHandler(@NotNull JetClass jetClass, @NotNull KotlinFindUsagesHandlerFactory factory) {
|
public KotlinFindClassUsagesHandler(@NotNull JetClass jetClass, @NotNull KotlinFindUsagesHandlerFactory factory) {
|
||||||
@@ -72,26 +68,26 @@ public class KotlinFindClassUsagesHandler extends KotlinFindUsagesHandler<JetCla
|
|||||||
new Computable<Boolean>() {
|
new Computable<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean compute() {
|
public Boolean compute() {
|
||||||
KotlinClassFindUsagesOptions kotlinOptions = (KotlinClassFindUsagesOptions)options;
|
KotlinClassFindUsagesOptions kotlinOptions = (KotlinClassFindUsagesOptions) options;
|
||||||
JetClass jetClass = (JetClass) element;
|
JetClassOrObject classOrObject = (JetClassOrObject) element;
|
||||||
|
|
||||||
if (kotlinOptions.isUsages || kotlinOptions.getSearchConstructorUsages()) {
|
UsagesSearchTarget<JetClassOrObject> target =
|
||||||
Collection<PsiReference> references = ReferencesSearch.search(
|
FindUsagesPackage.toSearchTarget(kotlinOptions, classOrObject, true);
|
||||||
new ReferencesSearch.SearchParameters(jetClass, kotlinOptions.searchScope, false)
|
UsagesSearchRequest classRequest =
|
||||||
).findAll();
|
FindUsagesPackage.toClassHelper(kotlinOptions).newRequest(target);
|
||||||
for (PsiReference ref : references) {
|
UsagesSearchRequest declarationsRequest =
|
||||||
boolean constructorUsage = FindUsagesPackage.isConstructorUsage(ref.getElement(), jetClass);
|
FindUsagesPackage.toClassDeclarationsHelper(kotlinOptions).newRequest(target);
|
||||||
if ((constructorUsage && !kotlinOptions.getSearchConstructorUsages())
|
|
||||||
|| (!constructorUsage && !kotlinOptions.isUsages)) continue;
|
|
||||||
|
|
||||||
processUsage(processor, ref, kotlinOptions);
|
for (PsiReference ref : UsagesSearch.instance$.search(classRequest)) {
|
||||||
}
|
processUsage(processor, ref);
|
||||||
|
}
|
||||||
|
for (PsiReference ref : UsagesSearch.instance$.search(declarationsRequest)) {
|
||||||
|
processUsage(processor, ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
PsiClass lightClass = LightClassUtil.getPsiClass(getElement());
|
PsiClass lightClass = LightClassUtil.getPsiClass(classOrObject);
|
||||||
if (lightClass == null) return true;
|
if (lightClass == null) return true;
|
||||||
|
|
||||||
if (!processDeclarationsUsages(jetClass, processor, kotlinOptions)) return false;
|
|
||||||
if (!processInheritors(lightClass, processor, kotlinOptions)) return false;
|
if (!processInheritors(lightClass, processor, kotlinOptions)) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -100,27 +96,6 @@ public class KotlinFindClassUsagesHandler extends KotlinFindUsagesHandler<JetCla
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean processDeclarationsUsages(
|
|
||||||
@NotNull JetClass klass,
|
|
||||||
@NotNull final Processor<UsageInfo> processor,
|
|
||||||
@NotNull final JavaClassFindUsagesOptions options
|
|
||||||
) {
|
|
||||||
for (JetDeclaration declaration : klass.getDeclarations()) {
|
|
||||||
if (declaration instanceof JetNamedFunction && options.isMethodsUsages
|
|
||||||
|| declaration instanceof JetProperty && options.isFieldsUsages) {
|
|
||||||
if (!ReferencesSearch.search(new ReferencesSearch.SearchParameters(declaration, options.searchScope, false)).forEach(
|
|
||||||
new ReadActionProcessor<PsiReference>() {
|
|
||||||
@Override
|
|
||||||
public boolean processInReadAction(PsiReference ref) {
|
|
||||||
return processUsage(processor, ref, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)) return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final ClassInheritorsSearch.InheritanceChecker INHERITANCE_CHECKER = new ClassInheritorsSearch.InheritanceChecker() {
|
private static final ClassInheritorsSearch.InheritanceChecker INHERITANCE_CHECKER = new ClassInheritorsSearch.InheritanceChecker() {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkInheritance(@NotNull PsiClass subClass, @NotNull PsiClass parentClass) {
|
public boolean checkInheritance(@NotNull PsiClass subClass, @NotNull PsiClass parentClass) {
|
||||||
@@ -144,7 +119,7 @@ public class KotlinFindClassUsagesHandler extends KotlinFindUsagesHandler<JetCla
|
|||||||
public boolean execute(@NotNull PsiClass element) {
|
public boolean execute(@NotNull PsiClass element) {
|
||||||
if ((element.isInterface() && options.isDerivedInterfaces)
|
if ((element.isInterface() && options.isDerivedInterfaces)
|
||||||
|| (!element.isInterface() && options.isDerivedClasses)) {
|
|| (!element.isInterface() && options.isDerivedClasses)) {
|
||||||
return processUsage(processor, element, options);
|
return processUsage(processor, element);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -164,4 +139,4 @@ public class KotlinFindClassUsagesHandler extends KotlinFindUsagesHandler<JetCla
|
|||||||
public FindUsagesOptions getFindUsagesOptions(@Nullable DataContext dataContext) {
|
public FindUsagesOptions getFindUsagesOptions(@Nullable DataContext dataContext) {
|
||||||
return getFactory().getFindClassOptions();
|
return getFactory().getFindClassOptions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
-202
@@ -1,202 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2013 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 org.jetbrains.jet.plugin.findUsages.handlers;
|
|
||||||
|
|
||||||
import com.intellij.find.findUsages.AbstractFindUsagesDialog;
|
|
||||||
import com.intellij.find.findUsages.FindUsagesOptions;
|
|
||||||
import com.intellij.openapi.actionSystem.DataContext;
|
|
||||||
import com.intellij.openapi.application.ApplicationManager;
|
|
||||||
import com.intellij.openapi.application.ReadActionProcessor;
|
|
||||||
import com.intellij.openapi.util.Computable;
|
|
||||||
import com.intellij.psi.*;
|
|
||||||
import com.intellij.psi.search.PsiElementProcessor;
|
|
||||||
import com.intellij.psi.search.PsiElementProcessorAdapter;
|
|
||||||
import com.intellij.psi.search.SearchScope;
|
|
||||||
import com.intellij.psi.search.searches.MethodReferencesSearch;
|
|
||||||
import com.intellij.psi.search.searches.OverridingMethodsSearch;
|
|
||||||
import com.intellij.usageView.UsageInfo;
|
|
||||||
import com.intellij.util.Processor;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jetbrains.jet.asJava.LightClassUtil;
|
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
|
||||||
import org.jetbrains.jet.plugin.findUsages.KotlinFindUsagesHandlerFactory;
|
|
||||||
import org.jetbrains.jet.plugin.findUsages.dialogs.KotlinFindMethodUsagesDialog;
|
|
||||||
import org.jetbrains.jet.plugin.findUsages.KotlinMethodFindUsagesOptions;
|
|
||||||
import org.jetbrains.jet.plugin.hierarchy.calls.CalleeReferenceVisitorBase;
|
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
|
||||||
import org.jetbrains.jet.plugin.search.KotlinExtensionSearch;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class KotlinFindFunctionUsagesHandler extends KotlinFindUsagesHandler<JetNamedFunction> {
|
|
||||||
public KotlinFindFunctionUsagesHandler(
|
|
||||||
@NotNull JetNamedFunction function,
|
|
||||||
@NotNull Collection<? extends PsiElement> elementsToSearch,
|
|
||||||
@NotNull KotlinFindUsagesHandlerFactory factory
|
|
||||||
) {
|
|
||||||
super(function, elementsToSearch, factory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public KotlinFindFunctionUsagesHandler(@NotNull JetNamedFunction function, @NotNull KotlinFindUsagesHandlerFactory factory) {
|
|
||||||
super(function, factory);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public AbstractFindUsagesDialog getFindUsagesDialog(boolean isSingleFile, boolean toShowInNewTab, boolean mustOpenInNewTab) {
|
|
||||||
PsiMethod lightMethod = LightClassUtil.getLightClassMethod(getElement());
|
|
||||||
if (lightMethod != null) {
|
|
||||||
return new KotlinFindMethodUsagesDialog(
|
|
||||||
lightMethod, getProject(), getFactory().getFindMethodOptions(), toShowInNewTab, mustOpenInNewTab, isSingleFile, this
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.getFindUsagesDialog(isSingleFile, toShowInNewTab, mustOpenInNewTab);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean searchReferences(
|
|
||||||
@NotNull PsiElement element,
|
|
||||||
@NotNull final Processor<UsageInfo> processor,
|
|
||||||
@NotNull FindUsagesOptions options
|
|
||||||
) {
|
|
||||||
JetNamedFunction function = (JetNamedFunction) element;
|
|
||||||
|
|
||||||
final KotlinMethodFindUsagesOptions kotlinOptions = (KotlinMethodFindUsagesOptions) options;
|
|
||||||
SearchScope searchScope = kotlinOptions.searchScope;
|
|
||||||
|
|
||||||
JetElement blockForLocalDeclaration = JetPsiUtil.getEnclosingBlockForLocalDeclaration(function);
|
|
||||||
if (blockForLocalDeclaration != null && kotlinOptions.isUsages) {
|
|
||||||
return searchLocalFunction(element, processor, function, kotlinOptions, blockForLocalDeclaration);
|
|
||||||
}
|
|
||||||
|
|
||||||
final PsiMethod lightMethod = ApplicationManager.getApplication().runReadAction(new Computable<PsiMethod>() {
|
|
||||||
@Override
|
|
||||||
public PsiMethod compute() {
|
|
||||||
return LightClassUtil.getLightClassMethod(getElement());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (lightMethod == null) return true;
|
|
||||||
|
|
||||||
if (kotlinOptions.isUsages) {
|
|
||||||
boolean strictSignatureSearch = !kotlinOptions.isIncludeOverloadUsages;
|
|
||||||
if (!MethodReferencesSearch
|
|
||||||
.search(
|
|
||||||
new MethodReferencesSearch.SearchParameters(
|
|
||||||
lightMethod, searchScope, strictSignatureSearch, kotlinOptions.fastTrack
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.forEach(
|
|
||||||
new ReadActionProcessor<PsiReference>() {
|
|
||||||
@Override
|
|
||||||
public boolean processInReadAction(PsiReference ref) {
|
|
||||||
return processUsage(processor, ref, kotlinOptions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isAbstract = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
|
|
||||||
@Override
|
|
||||||
public Boolean compute() {
|
|
||||||
return lightMethod.hasModifierProperty(PsiModifier.ABSTRACT);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (isAbstract && kotlinOptions.isImplementingMethods || kotlinOptions.isOverridingMethods) {
|
|
||||||
OverridingMethodsSearch.search(lightMethod, options.searchScope, kotlinOptions.isCheckDeepInheritance).forEach(
|
|
||||||
new PsiElementProcessorAdapter<PsiMethod>(
|
|
||||||
new PsiElementProcessor<PsiMethod>() {
|
|
||||||
@Override
|
|
||||||
public boolean execute(@NotNull PsiMethod element) {
|
|
||||||
return processUsage(processor, element.getNavigationElement(), kotlinOptions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (kotlinOptions.isIncludeOverloadUsages) {
|
|
||||||
String name = ((PsiNamedElement) element).getName();
|
|
||||||
if (name == null) return true;
|
|
||||||
|
|
||||||
for (PsiReference ref : KotlinExtensionSearch.search(lightMethod, searchScope).findAll()) {
|
|
||||||
processUsage(processor, ref, kotlinOptions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean searchLocalFunction(
|
|
||||||
final PsiElement element,
|
|
||||||
Processor<UsageInfo> processor,
|
|
||||||
final JetNamedFunction function,
|
|
||||||
final KotlinMethodFindUsagesOptions kotlinOptions,
|
|
||||||
JetElement blockForLocalDeclaration
|
|
||||||
) {
|
|
||||||
BindingContext bindingContext =
|
|
||||||
AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) element.getContainingFile()).getBindingContext();
|
|
||||||
|
|
||||||
final List<PsiReference> result = new ArrayList<PsiReference>();
|
|
||||||
CalleeReferenceVisitorBase visitor = new CalleeReferenceVisitorBase(bindingContext, true) {
|
|
||||||
private boolean isAcceptable(PsiElement declaration) {
|
|
||||||
if (kotlinOptions.isIncludeOverloadUsages) {
|
|
||||||
//noinspection ConstantConditions
|
|
||||||
return declaration instanceof JetNamedFunction &&
|
|
||||||
function.getName()
|
|
||||||
.equals(((JetNamedFunction) declaration).getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
return declaration.equals(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void processDeclaration(JetReferenceExpression reference, PsiElement declaration) {
|
|
||||||
if (isAcceptable(declaration)) {
|
|
||||||
result.add(reference.getReference());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
blockForLocalDeclaration.accept(visitor);
|
|
||||||
|
|
||||||
for (PsiReference ref : result) {
|
|
||||||
if (!processUsage(processor, ref, kotlinOptions)) return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean isSearchForTextOccurencesAvailable(@NotNull PsiElement psiElement, boolean isSingleFile) {
|
|
||||||
if (isSingleFile) return false;
|
|
||||||
return psiElement instanceof JetNamedFunction;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public FindUsagesOptions getFindUsagesOptions(@Nullable DataContext dataContext) {
|
|
||||||
return getFactory().getFindMethodOptions();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+14
-46
@@ -19,19 +19,20 @@ package org.jetbrains.jet.plugin.findUsages.handlers;
|
|||||||
import com.intellij.find.findUsages.FindUsagesHandler;
|
import com.intellij.find.findUsages.FindUsagesHandler;
|
||||||
import com.intellij.find.findUsages.FindUsagesOptions;
|
import com.intellij.find.findUsages.FindUsagesOptions;
|
||||||
import com.intellij.find.findUsages.JavaFindUsagesOptions;
|
import com.intellij.find.findUsages.JavaFindUsagesOptions;
|
||||||
import com.intellij.openapi.application.ReadActionProcessor;
|
|
||||||
import com.intellij.openapi.util.TextRange;
|
import com.intellij.openapi.util.TextRange;
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
|
import com.intellij.psi.PsiNamedElement;
|
||||||
import com.intellij.psi.PsiReference;
|
import com.intellij.psi.PsiReference;
|
||||||
import com.intellij.psi.search.GlobalSearchScope;
|
import com.intellij.psi.search.GlobalSearchScope;
|
||||||
import com.intellij.psi.search.SearchScope;
|
import com.intellij.psi.search.SearchScope;
|
||||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
|
||||||
import com.intellij.psi.util.PsiTreeUtil;
|
|
||||||
import com.intellij.usageView.UsageInfo;
|
import com.intellij.usageView.UsageInfo;
|
||||||
import com.intellij.util.Processor;
|
import com.intellij.util.Processor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.psi.JetImportDirective;
|
import org.jetbrains.jet.plugin.findUsages.FindUsagesPackage;
|
||||||
import org.jetbrains.jet.plugin.findUsages.KotlinFindUsagesHandlerFactory;
|
import org.jetbrains.jet.plugin.findUsages.KotlinFindUsagesHandlerFactory;
|
||||||
|
import org.jetbrains.jet.plugin.search.usagesSearch.DeclarationUsagesSearchHelper;
|
||||||
|
import org.jetbrains.jet.plugin.search.usagesSearch.UsagesSearch;
|
||||||
|
import org.jetbrains.jet.plugin.search.usagesSearch.UsagesSearchTarget;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -64,28 +65,13 @@ public abstract class KotlinFindUsagesHandler<T extends PsiElement> extends Find
|
|||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static boolean filterUsage(@NotNull PsiElement usage, @NotNull FindUsagesOptions options) {
|
protected static boolean processUsage(Processor<UsageInfo> processor, PsiReference ref) {
|
||||||
if (options instanceof JavaFindUsagesOptions && ((JavaFindUsagesOptions) options).isSkipImportStatements) {
|
TextRange rangeInElement = ref.getRangeInElement();
|
||||||
if (PsiTreeUtil.getParentOfType(usage, JetImportDirective.class) != null) return false;
|
return processor.process(new UsageInfo(ref.getElement(), rangeInElement.getStartOffset(), rangeInElement.getEndOffset(), false));
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static boolean processUsage(Processor<UsageInfo> processor, PsiReference ref, FindUsagesOptions options) {
|
protected static boolean processUsage(@NotNull Processor<UsageInfo> processor, @NotNull PsiElement element) {
|
||||||
if (filterUsage(ref.getElement(), options)){
|
return processor.process(new UsageInfo(element));
|
||||||
TextRange rangeInElement = ref.getRangeInElement();
|
|
||||||
return processor.process(new UsageInfo(ref.getElement(), rangeInElement.getStartOffset(), rangeInElement.getEndOffset(), false));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static boolean processUsage(
|
|
||||||
@NotNull Processor<UsageInfo> processor,
|
|
||||||
@NotNull PsiElement element,
|
|
||||||
@NotNull FindUsagesOptions options
|
|
||||||
) {
|
|
||||||
return !filterUsage(element, options) || processor.process(new UsageInfo(element));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -96,28 +82,6 @@ public abstract class KotlinFindUsagesHandler<T extends PsiElement> extends Find
|
|||||||
: elementsToSearch.toArray(new PsiElement[elementsToSearch.size()]);
|
: elementsToSearch.toArray(new PsiElement[elementsToSearch.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean searchReferences(
|
|
||||||
@NotNull PsiElement element,
|
|
||||||
@NotNull final Processor<UsageInfo> processor,
|
|
||||||
@NotNull FindUsagesOptions options
|
|
||||||
) {
|
|
||||||
if (options.isUsages) {
|
|
||||||
boolean success = ReferencesSearch.search(
|
|
||||||
new ReferencesSearch.SearchParameters(element, options.searchScope, false, options.fastTrack)
|
|
||||||
).forEach(new ReadActionProcessor<PsiReference>() {
|
|
||||||
@Override
|
|
||||||
public boolean processInReadAction(PsiReference ref) {
|
|
||||||
TextRange rangeInElement = ref.getRangeInElement();
|
|
||||||
return processor.process(
|
|
||||||
new UsageInfo(ref.getElement(), rangeInElement.getStartOffset(), rangeInElement.getEndOffset(), false)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (!success) return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean searchTextOccurrences(
|
protected boolean searchTextOccurrences(
|
||||||
@NotNull final PsiElement element,
|
@NotNull final PsiElement element,
|
||||||
@NotNull final Processor<UsageInfo> processor,
|
@NotNull final Processor<UsageInfo> processor,
|
||||||
@@ -151,4 +115,8 @@ public abstract class KotlinFindUsagesHandler<T extends PsiElement> extends Find
|
|||||||
) {
|
) {
|
||||||
return searchReferences(element, processor, options) && searchTextOccurrences(element, processor, options);
|
return searchReferences(element, processor, options) && searchTextOccurrences(element, processor, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract boolean searchReferences(
|
||||||
|
@NotNull PsiElement element, @NotNull Processor<UsageInfo> processor, @NotNull FindUsagesOptions options
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.asJava.LightClassUtil;
|
import org.jetbrains.jet.asJava.LightClassUtil;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.impl.LocalVariableDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||||
@@ -169,6 +170,10 @@ public class JetRefactoringUtil {
|
|||||||
AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) declaration.getContainingFile()).getBindingContext();
|
AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) declaration.getContainingFile()).getBindingContext();
|
||||||
|
|
||||||
DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration);
|
DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration);
|
||||||
|
|
||||||
|
if (declarationDescriptor instanceof LocalVariableDescriptor) {
|
||||||
|
return Collections.singletonList(declaration);
|
||||||
|
}
|
||||||
if (!(declarationDescriptor instanceof CallableMemberDescriptor)) return null;
|
if (!(declarationDescriptor instanceof CallableMemberDescriptor)) return null;
|
||||||
|
|
||||||
CallableMemberDescriptor callableDescriptor = (CallableMemberDescriptor) declarationDescriptor;
|
CallableMemberDescriptor callableDescriptor = (CallableMemberDescriptor) declarationDescriptor;
|
||||||
|
|||||||
@@ -1,151 +0,0 @@
|
|||||||
package org.jetbrains.jet.plugin.search;
|
|
||||||
|
|
||||||
import com.intellij.openapi.application.ApplicationManager;
|
|
||||||
import com.intellij.openapi.application.QueryExecutorBase;
|
|
||||||
import com.intellij.psi.*;
|
|
||||||
import com.intellij.psi.search.*;
|
|
||||||
import com.intellij.psi.search.searches.ReferenceDescriptor;
|
|
||||||
import com.intellij.util.*;
|
|
||||||
import com.intellij.util.containers.ContainerUtil;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
|
||||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression;
|
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.jetAsJava.JetClsMethod;
|
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class KotlinExtensionSearch extends QueryFactory<PsiReference, KotlinExtensionSearch.SearchParameters> {
|
|
||||||
public static final KotlinExtensionSearch INSTANCE = new KotlinExtensionSearch();
|
|
||||||
|
|
||||||
public static class SearchParameters {
|
|
||||||
private final PsiMethod method;
|
|
||||||
private final SearchScope searchScope;
|
|
||||||
private final SearchRequestCollector optimizer = new SearchRequestCollector(new SearchSession());
|
|
||||||
|
|
||||||
public SearchParameters(@NotNull PsiMethod method, @NotNull SearchScope searchScope) {
|
|
||||||
this.searchScope = searchScope;
|
|
||||||
this.method = method;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PsiMethod getMethod() {
|
|
||||||
return method;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SearchScope getSearchScope() {
|
|
||||||
return searchScope;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SearchRequestCollector getOptimizer() {
|
|
||||||
return optimizer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ExtensionTextOccurenceProcessor extends RequestResultProcessor {
|
|
||||||
private final SearchParameters parameters;
|
|
||||||
|
|
||||||
private ExtensionTextOccurenceProcessor(SearchParameters parameters, @NotNull Object... equality) {
|
|
||||||
super(equality);
|
|
||||||
this.parameters = parameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processElement(
|
|
||||||
@NotNull PsiReference ref,
|
|
||||||
@Nullable PsiElement refTarget,
|
|
||||||
@NotNull Processor<PsiReference> consumer
|
|
||||||
) {
|
|
||||||
if (!(refTarget instanceof JetSimpleNameExpression)) return;
|
|
||||||
|
|
||||||
BindingContext bindingContext =
|
|
||||||
AnalyzerFacadeWithCache.analyzeFileWithCache((JetFile) refTarget.getContainingFile()).getBindingContext();
|
|
||||||
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, (JetSimpleNameExpression) refTarget);
|
|
||||||
|
|
||||||
if (!(descriptor instanceof FunctionDescriptor)) return;
|
|
||||||
|
|
||||||
FunctionDescriptor functionDescriptor = (FunctionDescriptor) descriptor;
|
|
||||||
ReceiverParameterDescriptor receiverParameterDescriptor = functionDescriptor.getReceiverParameter();
|
|
||||||
|
|
||||||
if (receiverParameterDescriptor == null) return;
|
|
||||||
JetType receiverType = receiverParameterDescriptor.getType();
|
|
||||||
|
|
||||||
ClassifierDescriptor receiverDescriptor = receiverType.getConstructor().getDeclarationDescriptor();
|
|
||||||
if (!(receiverDescriptor instanceof ClassDescriptor)) return;
|
|
||||||
|
|
||||||
PsiElement originalMethod = parameters.getMethod();
|
|
||||||
if (originalMethod instanceof JetClsMethod) {
|
|
||||||
originalMethod = ((JetClsMethod) originalMethod).getOrigin();
|
|
||||||
}
|
|
||||||
|
|
||||||
DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, originalMethod);
|
|
||||||
if (declarationDescriptor == null) return;
|
|
||||||
|
|
||||||
DeclarationDescriptor containingDescriptor = declarationDescriptor.getContainingDeclaration();
|
|
||||||
if (!(containingDescriptor instanceof ClassDescriptor)) return;
|
|
||||||
|
|
||||||
if (DescriptorUtils.isSubclass((ClassDescriptor) containingDescriptor, (ClassDescriptor) receiverDescriptor)) {
|
|
||||||
consumer.process(ref);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean processTextOccurrence(
|
|
||||||
@NotNull PsiElement element,
|
|
||||||
int offsetInElement,
|
|
||||||
@NotNull Processor<PsiReference> consumer
|
|
||||||
) {
|
|
||||||
List<PsiReference> references = PsiReferenceService.getService().getReferences(
|
|
||||||
element, PsiReferenceService.Hints.NO_HINTS
|
|
||||||
);
|
|
||||||
for (PsiReference ref : references) {
|
|
||||||
if (ReferenceRange.containsOffsetInElement(ref, offsetInElement)) {
|
|
||||||
processElement(ref, ref.getElement(), consumer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private KotlinExtensionSearch() {
|
|
||||||
registerExecutor(
|
|
||||||
new QueryExecutorBase<PsiReference, SearchParameters>() {
|
|
||||||
@Override
|
|
||||||
public void processQuery(@NotNull final SearchParameters p, @NotNull Processor<PsiReference> consumer) {
|
|
||||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
p.getOptimizer().searchWord(
|
|
||||||
p.getMethod().getName(),
|
|
||||||
p.getSearchScope(),
|
|
||||||
UsageSearchContext.IN_CODE,
|
|
||||||
true,
|
|
||||||
new ExtensionTextOccurenceProcessor(p)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Query<PsiReference> search(@NotNull PsiMethod method, @NotNull SearchScope scope) {
|
|
||||||
return search(new SearchParameters(method, scope));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Query<PsiReference> search(SearchParameters parameters) {
|
|
||||||
Query<PsiReference> result = INSTANCE.createQuery(parameters);
|
|
||||||
SearchRequestCollector requests = parameters.getOptimizer();
|
|
||||||
return uniqueResults(new MergeQuery<PsiReference>(result, new SearchRequestQuery(parameters.getMethod().getProject(), requests)));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static UniqueResultsQuery<PsiReference, ReferenceDescriptor> uniqueResults(@NotNull Query<PsiReference> composite) {
|
|
||||||
return new UniqueResultsQuery<PsiReference, ReferenceDescriptor>(
|
|
||||||
composite, ContainerUtil.<ReferenceDescriptor>canonicalStrategy(), ReferenceDescriptor.MAPPER
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetProperty
|
||||||
|
// OPTIONS: overrides
|
||||||
|
open class A<T> {
|
||||||
|
open var <caret>foo: T
|
||||||
|
}
|
||||||
|
|
||||||
|
open class B: A<String>() {
|
||||||
|
override var foo: String
|
||||||
|
get() {
|
||||||
|
println("get")
|
||||||
|
return super<A>.foo
|
||||||
|
}
|
||||||
|
set(value: String) {
|
||||||
|
println("set:" + value)
|
||||||
|
super<A>.foo = value
|
||||||
|
}
|
||||||
|
|
||||||
|
fun baz(a: A<String>) {
|
||||||
|
a.foo = ""
|
||||||
|
println(a.foo)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
class C extends A<String> {
|
||||||
|
@Override
|
||||||
|
public String getFoo() {
|
||||||
|
return super.getFoo();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFoo(String s) {
|
||||||
|
super.setFoo(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
Unclassified usage (13: 9) set(value: String) {
|
||||||
|
Unclassified usage (3: 19) public String getFoo() {
|
||||||
|
Unclassified usage (8: 17) public void setFoo(String s) {
|
||||||
|
Unclassified usage (9: 9) get() {
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetProperty
|
||||||
|
// OPTIONS: usages, skipWrite
|
||||||
|
package server;
|
||||||
|
|
||||||
|
open class A<T>(t: T) {
|
||||||
|
open var <caret>foo: T = t
|
||||||
|
}
|
||||||
|
|
||||||
|
open class B: A<String>("") {
|
||||||
|
override var foo: String
|
||||||
|
get() {
|
||||||
|
println("get")
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
set(value: String) {
|
||||||
|
println("set:" + value)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package client;
|
||||||
|
|
||||||
|
import server.*
|
||||||
|
|
||||||
|
class Client {
|
||||||
|
fun fooBar() {
|
||||||
|
A<String> a = new A<String>("");
|
||||||
|
a.setFoo("a");
|
||||||
|
println("a.foo = " + a.getFoo());
|
||||||
|
|
||||||
|
B b = new B();
|
||||||
|
b.setFoo("b");
|
||||||
|
println("b.foo = " + b.getFoo());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
Unclassified usage (13: 32) println("b.foo = " + b.getFoo());
|
||||||
|
Unclassified usage (9: 32) println("a.foo = " + a.getFoo());
|
||||||
@@ -1,7 +1,18 @@
|
|||||||
// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetProperty
|
// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetProperty
|
||||||
|
// OPTIONS: usages
|
||||||
package server;
|
package server;
|
||||||
|
|
||||||
object O {
|
open class A<T>(t: T) {
|
||||||
var <caret>foo: String = "foo"
|
open var <caret>foo: T = t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open class B: A<String>("") {
|
||||||
|
override var foo: String
|
||||||
|
get() {
|
||||||
|
println("get")
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
set(value: String) {
|
||||||
|
println("set:" + value)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,15 @@
|
|||||||
package client;
|
package client;
|
||||||
|
|
||||||
import server.O
|
import server.*
|
||||||
|
|
||||||
class Client {
|
class Client {
|
||||||
fun fooBar() {
|
fun fooBar() {
|
||||||
println("foo = " + O.instance$.getFoo())
|
A<String> a = new A<String>("");
|
||||||
|
a.setFoo("a");
|
||||||
|
println("a.foo = " + a.getFoo());
|
||||||
|
|
||||||
|
B b = new B();
|
||||||
|
b.setFoo("b");
|
||||||
|
println("b.foo = " + b.getFoo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1 +1,4 @@
|
|||||||
Unclassified usage (7: 40) println("foo = " + O.instance$.getFoo())
|
Unclassified usage (12: 11) b.setFoo("b");
|
||||||
|
Unclassified usage (13: 32) println("b.foo = " + b.getFoo());
|
||||||
|
Unclassified usage (8: 11) a.setFoo("a");
|
||||||
|
Unclassified usage (9: 32) println("a.foo = " + a.getFoo());
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetProperty
|
||||||
|
// OPTIONS: usages, skipRead
|
||||||
|
package server;
|
||||||
|
|
||||||
|
open class A<T>(t: T) {
|
||||||
|
open var <caret>foo: T = t
|
||||||
|
}
|
||||||
|
|
||||||
|
open class B: A<String>("") {
|
||||||
|
override var foo: String
|
||||||
|
get() {
|
||||||
|
println("get")
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
set(value: String) {
|
||||||
|
println("set:" + value)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package client;
|
||||||
|
|
||||||
|
import server.*
|
||||||
|
|
||||||
|
class Client {
|
||||||
|
fun fooBar() {
|
||||||
|
A<String> a = new A<String>("");
|
||||||
|
a.setFoo("a");
|
||||||
|
println("a.foo = " + a.getFoo());
|
||||||
|
|
||||||
|
B b = new B();
|
||||||
|
b.setFoo("b");
|
||||||
|
println("b.foo = " + b.getFoo());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
Unclassified usage (12: 11) b.setFoo("b");
|
||||||
|
Unclassified usage (8: 11) a.setFoo("a");
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetProperty
|
||||||
|
// OPTIONS: usages, skipWrite
|
||||||
|
package server;
|
||||||
|
|
||||||
|
open class A<T> {
|
||||||
|
open var <caret>foo: T
|
||||||
|
}
|
||||||
|
|
||||||
|
open class B: A<String>() {
|
||||||
|
open var foo: String
|
||||||
|
get() {
|
||||||
|
println("get")
|
||||||
|
return super<A>.foo
|
||||||
|
}
|
||||||
|
set(value: String) {
|
||||||
|
println("set:" + value)
|
||||||
|
super<A>.foo = value
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import server.*;
|
||||||
|
|
||||||
|
class Client {
|
||||||
|
public fun foo() {
|
||||||
|
val a = A<String>()
|
||||||
|
a.foo = "a"
|
||||||
|
println("a.foo = ${a.foo}")
|
||||||
|
|
||||||
|
val b = B()
|
||||||
|
b.foo = "b"
|
||||||
|
println("b.foo = ${b.foo}")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
Value read (11: 30) println("b.foo = ${b.foo}")
|
||||||
|
Value read (13: 29) return super<A>.foo
|
||||||
|
Value read (7: 30) println("a.foo = ${a.foo}")
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetProperty
|
||||||
|
// OPTIONS: usages
|
||||||
|
package server;
|
||||||
|
|
||||||
|
open class A<T> {
|
||||||
|
open var <caret>foo: T
|
||||||
|
}
|
||||||
|
|
||||||
|
open class B: A<String>() {
|
||||||
|
open var foo: String
|
||||||
|
get() {
|
||||||
|
println("get")
|
||||||
|
return super<A>.foo
|
||||||
|
}
|
||||||
|
set(value: String) {
|
||||||
|
println("set:" + value)
|
||||||
|
super<A>.foo = value
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import server.*;
|
||||||
|
|
||||||
|
class Client {
|
||||||
|
public fun foo() {
|
||||||
|
val a = A<String>()
|
||||||
|
a.foo = "a"
|
||||||
|
println("a.foo = ${a.foo}")
|
||||||
|
|
||||||
|
val b = B()
|
||||||
|
b.foo = "b"
|
||||||
|
println("b.foo = ${b.foo}")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
Value read (11: 30) println("b.foo = ${b.foo}")
|
||||||
|
Value read (13: 29) return super<A>.foo
|
||||||
|
Value read (7: 30) println("a.foo = ${a.foo}")
|
||||||
|
Value write (10: 11) b.foo = "b"
|
||||||
|
Value write (17: 22) super<A>.foo = value
|
||||||
|
Value write (6: 11) a.foo = "a"
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetProperty
|
||||||
|
// OPTIONS: usages, skipRead
|
||||||
|
package server;
|
||||||
|
|
||||||
|
open class A<T> {
|
||||||
|
open var <caret>foo: T
|
||||||
|
}
|
||||||
|
|
||||||
|
open class B: A<String>() {
|
||||||
|
open var foo: String
|
||||||
|
get() {
|
||||||
|
println("get")
|
||||||
|
return super<A>.foo
|
||||||
|
}
|
||||||
|
set(value: String) {
|
||||||
|
println("set:" + value)
|
||||||
|
super<A>.foo = value
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import server.*;
|
||||||
|
|
||||||
|
class Client {
|
||||||
|
public fun foo() {
|
||||||
|
val a = A<String>()
|
||||||
|
a.foo = "a"
|
||||||
|
println("a.foo = ${a.foo}")
|
||||||
|
|
||||||
|
val b = B()
|
||||||
|
b.foo = "b"
|
||||||
|
println("b.foo = ${b.foo}")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
Value write (10: 11) b.foo = "b"
|
||||||
|
Value write (17: 22) super<A>.foo = value
|
||||||
|
Value write (6: 11) a.foo = "a"
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetProperty
|
// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetProperty
|
||||||
|
// OPTIONS: usages
|
||||||
package server;
|
package server;
|
||||||
|
|
||||||
var <caret>foo: String = "foo"
|
var <caret>foo: String = "foo"
|
||||||
|
|||||||
@@ -47,10 +47,12 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.jetbrains.jet.InTextDirectivesUtils;
|
import org.jetbrains.jet.InTextDirectivesUtils;
|
||||||
import org.jetbrains.jet.lang.psi.JetClass;
|
import org.jetbrains.jet.lang.psi.JetClass;
|
||||||
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetProperty;
|
||||||
import org.jetbrains.jet.plugin.JetLightProjectDescriptor;
|
import org.jetbrains.jet.plugin.JetLightProjectDescriptor;
|
||||||
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
||||||
import org.jetbrains.jet.plugin.findUsages.KotlinClassFindUsagesOptions;
|
import org.jetbrains.jet.plugin.findUsages.KotlinClassFindUsagesOptions;
|
||||||
import org.jetbrains.jet.plugin.findUsages.KotlinMethodFindUsagesOptions;
|
import org.jetbrains.jet.plugin.findUsages.KotlinFunctionFindUsagesOptions;
|
||||||
|
import org.jetbrains.jet.plugin.findUsages.KotlinPropertyFindUsagesOptions;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
@@ -92,11 +94,11 @@ public abstract class AbstractJetFindUsagesTest extends LightCodeInsightFixtureT
|
|||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
METHOD {
|
FUNCTION {
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public FindUsagesOptions parse(@NotNull String text, @NotNull Project project) {
|
public FindUsagesOptions parse(@NotNull String text, @NotNull Project project) {
|
||||||
KotlinMethodFindUsagesOptions options = new KotlinMethodFindUsagesOptions(project);
|
KotlinFunctionFindUsagesOptions options = new KotlinFunctionFindUsagesOptions(project);
|
||||||
options.isUsages = false;
|
options.isUsages = false;
|
||||||
for (String s : InTextDirectivesUtils.findListWithPrefixes(text, "// OPTIONS: ")) {
|
for (String s : InTextDirectivesUtils.findListWithPrefixes(text, "// OPTIONS: ")) {
|
||||||
if (parseCommonOptions(options, s)) continue;
|
if (parseCommonOptions(options, s)) continue;
|
||||||
@@ -112,6 +114,30 @@ public abstract class AbstractJetFindUsagesTest extends LightCodeInsightFixtureT
|
|||||||
else fail("Invalid option: " + s);
|
else fail("Invalid option: " + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
PROPERTY {
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public FindUsagesOptions parse(@NotNull String text, @NotNull Project project) {
|
||||||
|
KotlinPropertyFindUsagesOptions options = new KotlinPropertyFindUsagesOptions(project);
|
||||||
|
options.isUsages = false;
|
||||||
|
for (String s : InTextDirectivesUtils.findListWithPrefixes(text, "// OPTIONS: ")) {
|
||||||
|
if (parseCommonOptions(options, s)) continue;
|
||||||
|
|
||||||
|
if (s.equals("overrides")) {
|
||||||
|
options.setSearchOverrides(true);
|
||||||
|
}
|
||||||
|
else if (s.equals("skipRead")) {
|
||||||
|
options.isReadAccess = false;
|
||||||
|
}
|
||||||
|
else if (s.equals("skipWrite")) {
|
||||||
|
options.isWriteAccess = false;
|
||||||
|
}
|
||||||
|
else fail("Invalid option: " + s);
|
||||||
|
}
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -136,7 +162,10 @@ public abstract class AbstractJetFindUsagesTest extends LightCodeInsightFixtureT
|
|||||||
@Nullable
|
@Nullable
|
||||||
public static OptionsParser getParserByPsiElementClass(@NotNull Class<? extends PsiElement> klass) {
|
public static OptionsParser getParserByPsiElementClass(@NotNull Class<? extends PsiElement> klass) {
|
||||||
if (klass == JetNamedFunction.class) {
|
if (klass == JetNamedFunction.class) {
|
||||||
return METHOD;
|
return FUNCTION;
|
||||||
|
}
|
||||||
|
if (klass == JetProperty.class) {
|
||||||
|
return PROPERTY;
|
||||||
}
|
}
|
||||||
if (klass == JetClass.class) {
|
if (klass == JetClass.class) {
|
||||||
return CLASS;
|
return CLASS;
|
||||||
@@ -217,7 +246,7 @@ public abstract class AbstractJetFindUsagesTest extends LightCodeInsightFixtureT
|
|||||||
};
|
};
|
||||||
|
|
||||||
Collection<String> finalUsages = Ordering.natural().sortedCopy(Collections2.transform(filteredUsages, convertToString));
|
Collection<String> finalUsages = Ordering.natural().sortedCopy(Collections2.transform(filteredUsages, convertToString));
|
||||||
String expectedText = FileUtil.loadFile(new File(rootPath + prefix + "results.txt"), true);
|
String expectedText = FileUtil.loadFile(new File(rootPath, prefix + "results.txt"), true);
|
||||||
assertOrderedEquals(finalUsages, Ordering.natural().sortedCopy(StringUtil.split(expectedText, "\n")));
|
assertOrderedEquals(finalUsages, Ordering.natural().sortedCopy(StringUtil.split(expectedText, "\n")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import org.jetbrains.jet.findUsages.AbstractJetFindUsagesTest;
|
|||||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
|
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
@TestMetadata("idea/testData/findUsages")
|
@TestMetadata("idea/testData/findUsages")
|
||||||
@InnerTestClasses({JetFindUsagesTest.FindClassUsages.class, JetFindUsagesTest.FindMethodUsages.class, JetFindUsagesTest.FindObjectUsages.class, JetFindUsagesTest.FindPropertyUsages.class, JetFindUsagesTest.FindWithFilteringImports.class, JetFindUsagesTest.UnresolvedAnnotation.class})
|
@InnerTestClasses({JetFindUsagesTest.FindClassUsages.class, JetFindUsagesTest.FindFunctionUsages.class, JetFindUsagesTest.FindObjectUsages.class, JetFindUsagesTest.FindPropertyUsages.class, JetFindUsagesTest.FindWithFilteringImports.class, JetFindUsagesTest.UnresolvedAnnotation.class})
|
||||||
public class JetFindUsagesTest extends AbstractJetFindUsagesTest {
|
public class JetFindUsagesTest extends AbstractJetFindUsagesTest {
|
||||||
public void testAllFilesPresentInFindUsages() throws Exception {
|
public void testAllFilesPresentInFindUsages() throws Exception {
|
||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/findUsages"), Pattern.compile("^(.+)\\.0\\.kt$"), true);
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/findUsages"), Pattern.compile("^(.+)\\.0\\.kt$"), true);
|
||||||
@@ -185,55 +185,55 @@ public class JetFindUsagesTest extends AbstractJetFindUsagesTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("idea/testData/findUsages/findMethodUsages")
|
@TestMetadata("idea/testData/findUsages/findFunctionUsages")
|
||||||
public static class FindMethodUsages extends AbstractJetFindUsagesTest {
|
public static class FindFunctionUsages extends AbstractJetFindUsagesTest {
|
||||||
public void testAllFilesPresentInFindMethodUsages() throws Exception {
|
public void testAllFilesPresentInFindFunctionUsages() throws Exception {
|
||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/findUsages/findMethodUsages"), Pattern.compile("^(.+)\\.0\\.kt$"), true);
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/findUsages/findFunctionUsages"), Pattern.compile("^(.+)\\.0\\.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("javaAndKotlinOverrides.0.kt")
|
@TestMetadata("javaAndKotlinOverrides.0.kt")
|
||||||
public void testJavaAndKotlinOverrides() throws Exception {
|
public void testJavaAndKotlinOverrides() throws Exception {
|
||||||
doTest("idea/testData/findUsages/findMethodUsages/javaAndKotlinOverrides.0.kt");
|
doTest("idea/testData/findUsages/findFunctionUsages/javaAndKotlinOverrides.0.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("javaMethodUsages.0.kt")
|
@TestMetadata("javaMethodUsages.0.kt")
|
||||||
public void testJavaMethodUsages() throws Exception {
|
public void testJavaMethodUsages() throws Exception {
|
||||||
doTest("idea/testData/findUsages/findMethodUsages/javaMethodUsages.0.kt");
|
doTest("idea/testData/findUsages/findFunctionUsages/javaMethodUsages.0.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("kotlinLocalMethodUsages1.0.kt")
|
@TestMetadata("kotlinLocalMethodUsages1.0.kt")
|
||||||
public void testKotlinLocalMethodUsages1() throws Exception {
|
public void testKotlinLocalMethodUsages1() throws Exception {
|
||||||
doTest("idea/testData/findUsages/findMethodUsages/kotlinLocalMethodUsages1.0.kt");
|
doTest("idea/testData/findUsages/findFunctionUsages/kotlinLocalMethodUsages1.0.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("kotlinLocalMethodUsages2.0.kt")
|
@TestMetadata("kotlinLocalMethodUsages2.0.kt")
|
||||||
public void testKotlinLocalMethodUsages2() throws Exception {
|
public void testKotlinLocalMethodUsages2() throws Exception {
|
||||||
doTest("idea/testData/findUsages/findMethodUsages/kotlinLocalMethodUsages2.0.kt");
|
doTest("idea/testData/findUsages/findFunctionUsages/kotlinLocalMethodUsages2.0.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("kotlinMethodUsages.0.kt")
|
@TestMetadata("kotlinMethodUsages.0.kt")
|
||||||
public void testKotlinMethodUsages() throws Exception {
|
public void testKotlinMethodUsages() throws Exception {
|
||||||
doTest("idea/testData/findUsages/findMethodUsages/kotlinMethodUsages.0.kt");
|
doTest("idea/testData/findUsages/findFunctionUsages/kotlinMethodUsages.0.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("kotlinOverloadAndExtensionUsages.0.kt")
|
@TestMetadata("kotlinOverloadAndExtensionUsages.0.kt")
|
||||||
public void testKotlinOverloadAndExtensionUsages() throws Exception {
|
public void testKotlinOverloadAndExtensionUsages() throws Exception {
|
||||||
doTest("idea/testData/findUsages/findMethodUsages/kotlinOverloadAndExtensionUsages.0.kt");
|
doTest("idea/testData/findUsages/findFunctionUsages/kotlinOverloadAndExtensionUsages.0.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("kotlinPrivateMethodUsages.0.kt")
|
@TestMetadata("kotlinPrivateMethodUsages.0.kt")
|
||||||
public void testKotlinPrivateMethodUsages() throws Exception {
|
public void testKotlinPrivateMethodUsages() throws Exception {
|
||||||
doTest("idea/testData/findUsages/findMethodUsages/kotlinPrivateMethodUsages.0.kt");
|
doTest("idea/testData/findUsages/findFunctionUsages/kotlinPrivateMethodUsages.0.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("kotlinTopLevelMethodUsages.0.kt")
|
@TestMetadata("kotlinTopLevelMethodUsages.0.kt")
|
||||||
public void testKotlinTopLevelMethodUsages() throws Exception {
|
public void testKotlinTopLevelMethodUsages() throws Exception {
|
||||||
doTest("idea/testData/findUsages/findMethodUsages/kotlinTopLevelMethodUsages.0.kt");
|
doTest("idea/testData/findUsages/findFunctionUsages/kotlinTopLevelMethodUsages.0.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("kotlinTopLevelMethodUsagesNoImport.0.kt")
|
@TestMetadata("kotlinTopLevelMethodUsagesNoImport.0.kt")
|
||||||
public void testKotlinTopLevelMethodUsagesNoImport() throws Exception {
|
public void testKotlinTopLevelMethodUsagesNoImport() throws Exception {
|
||||||
doTest("idea/testData/findUsages/findMethodUsages/kotlinTopLevelMethodUsagesNoImport.0.kt");
|
doTest("idea/testData/findUsages/findFunctionUsages/kotlinTopLevelMethodUsagesNoImport.0.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -277,11 +277,26 @@ public class JetFindUsagesTest extends AbstractJetFindUsagesTest {
|
|||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/findUsages/findPropertyUsages"), Pattern.compile("^(.+)\\.0\\.kt$"), true);
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/findUsages/findPropertyUsages"), Pattern.compile("^(.+)\\.0\\.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("javaAndKotlinOverrides.0.kt")
|
||||||
|
public void testJavaAndKotlinOverrides() throws Exception {
|
||||||
|
doTest("idea/testData/findUsages/findPropertyUsages/javaAndKotlinOverrides.0.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("javaPropertyReadUsages.0.kt")
|
||||||
|
public void testJavaPropertyReadUsages() throws Exception {
|
||||||
|
doTest("idea/testData/findUsages/findPropertyUsages/javaPropertyReadUsages.0.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("javaPropertyUsages.0.kt")
|
@TestMetadata("javaPropertyUsages.0.kt")
|
||||||
public void testJavaPropertyUsages() throws Exception {
|
public void testJavaPropertyUsages() throws Exception {
|
||||||
doTest("idea/testData/findUsages/findPropertyUsages/javaPropertyUsages.0.kt");
|
doTest("idea/testData/findUsages/findPropertyUsages/javaPropertyUsages.0.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("javaPropertyWriteUsages.0.kt")
|
||||||
|
public void testJavaPropertyWriteUsages() throws Exception {
|
||||||
|
doTest("idea/testData/findUsages/findPropertyUsages/javaPropertyWriteUsages.0.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kotlinLocalPropertyUsages1.0.kt")
|
@TestMetadata("kotlinLocalPropertyUsages1.0.kt")
|
||||||
public void testKotlinLocalPropertyUsages1() throws Exception {
|
public void testKotlinLocalPropertyUsages1() throws Exception {
|
||||||
doTest("idea/testData/findUsages/findPropertyUsages/kotlinLocalPropertyUsages1.0.kt");
|
doTest("idea/testData/findUsages/findPropertyUsages/kotlinLocalPropertyUsages1.0.kt");
|
||||||
@@ -297,6 +312,21 @@ public class JetFindUsagesTest extends AbstractJetFindUsagesTest {
|
|||||||
doTest("idea/testData/findUsages/findPropertyUsages/kotlinPrivatePropertyUsages.0.kt");
|
doTest("idea/testData/findUsages/findPropertyUsages/kotlinPrivatePropertyUsages.0.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kotlinPropertyReadUsages.0.kt")
|
||||||
|
public void testKotlinPropertyReadUsages() throws Exception {
|
||||||
|
doTest("idea/testData/findUsages/findPropertyUsages/kotlinPropertyReadUsages.0.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kotlinPropertyUsages.0.kt")
|
||||||
|
public void testKotlinPropertyUsages() throws Exception {
|
||||||
|
doTest("idea/testData/findUsages/findPropertyUsages/kotlinPropertyUsages.0.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kotlinPropertyWriteUsages.0.kt")
|
||||||
|
public void testKotlinPropertyWriteUsages() throws Exception {
|
||||||
|
doTest("idea/testData/findUsages/findPropertyUsages/kotlinPropertyWriteUsages.0.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kotlinTopLevelPropertyUsages.0.kt")
|
@TestMetadata("kotlinTopLevelPropertyUsages.0.kt")
|
||||||
public void testKotlinTopLevelPropertyUsages() throws Exception {
|
public void testKotlinTopLevelPropertyUsages() throws Exception {
|
||||||
doTest("idea/testData/findUsages/findPropertyUsages/kotlinTopLevelPropertyUsages.0.kt");
|
doTest("idea/testData/findUsages/findPropertyUsages/kotlinTopLevelPropertyUsages.0.kt");
|
||||||
@@ -334,7 +364,7 @@ public class JetFindUsagesTest extends AbstractJetFindUsagesTest {
|
|||||||
TestSuite suite = new TestSuite("JetFindUsagesTest");
|
TestSuite suite = new TestSuite("JetFindUsagesTest");
|
||||||
suite.addTestSuite(JetFindUsagesTest.class);
|
suite.addTestSuite(JetFindUsagesTest.class);
|
||||||
suite.addTestSuite(FindClassUsages.class);
|
suite.addTestSuite(FindClassUsages.class);
|
||||||
suite.addTestSuite(FindMethodUsages.class);
|
suite.addTestSuite(FindFunctionUsages.class);
|
||||||
suite.addTestSuite(FindObjectUsages.class);
|
suite.addTestSuite(FindObjectUsages.class);
|
||||||
suite.addTestSuite(FindPropertyUsages.class);
|
suite.addTestSuite(FindPropertyUsages.class);
|
||||||
suite.addTestSuite(FindWithFilteringImports.class);
|
suite.addTestSuite(FindWithFilteringImports.class);
|
||||||
|
|||||||
Reference in New Issue
Block a user