Implement "Find Usages" for value/type parameters
This commit is contained in:
@@ -24,39 +24,48 @@ import org.jetbrains.jet.lang.psi.JetClass
|
||||
import org.jetbrains.jet.lang.psi.JetDeclaration
|
||||
import org.jetbrains.jet.lang.psi.JetNamedFunction
|
||||
import org.jetbrains.jet.plugin.findUsages.handlers.KotlinFindClassUsagesHandler
|
||||
import org.jetbrains.jet.plugin.findUsages.handlers.KotlinFindCallableUsagesHandler
|
||||
import org.jetbrains.jet.plugin.findUsages.handlers.KotlinFindMemberUsagesHandler
|
||||
import org.jetbrains.jet.plugin.refactoring.JetRefactoringUtil
|
||||
import org.jetbrains.jet.lang.psi.JetProperty
|
||||
import org.jetbrains.jet.lang.psi.JetCallableDeclaration
|
||||
import org.jetbrains.jet.lang.psi.JetNamedDeclaration
|
||||
import com.intellij.find.findUsages.FindUsagesOptions
|
||||
import org.jetbrains.jet.lang.psi.JetTypeParameter
|
||||
import org.jetbrains.jet.plugin.findUsages.handlers.KotlinTypeParameterFindUsagesHandler
|
||||
import org.jetbrains.jet.lang.psi.JetParameter
|
||||
import org.jetbrains.jet.lang.psi.JetNamedDeclaration
|
||||
|
||||
public class KotlinFindUsagesHandlerFactory(project: Project) : FindUsagesHandlerFactory() {
|
||||
val findFunctionOptions = KotlinFunctionFindUsagesOptions(project)
|
||||
val findPropertyOptions = KotlinPropertyFindUsagesOptions(project)
|
||||
val findClassOptions = KotlinClassFindUsagesOptions(project)
|
||||
val defaultOptions = FindUsagesOptions(project)
|
||||
|
||||
public override fun canFindUsages(element: PsiElement): Boolean =
|
||||
element is JetClass || element is JetNamedFunction || element is JetProperty
|
||||
element is JetClass || element is JetNamedFunction || element is JetProperty || element is JetParameter || element is JetTypeParameter
|
||||
|
||||
public override fun createFindUsagesHandler(element: PsiElement, forHighlightUsages: Boolean): FindUsagesHandler {
|
||||
when(element) {
|
||||
is JetClass ->
|
||||
return KotlinFindClassUsagesHandler(element, this)
|
||||
|
||||
is JetNamedFunction, is JetProperty -> {
|
||||
val declaration = element as JetCallableDeclaration
|
||||
is JetNamedFunction, is JetProperty, is JetParameter -> {
|
||||
val declaration = element as JetNamedDeclaration
|
||||
|
||||
return if (forHighlightUsages) KotlinFindCallableUsagesHandler.getInstance(declaration, this)
|
||||
return if (forHighlightUsages) KotlinFindMemberUsagesHandler.getInstance(declaration, this)
|
||||
else JetRefactoringUtil.checkSuperMethods(declaration, null, "super.methods.action.key.find.usages")?.let { callables ->
|
||||
when (callables.size()) {
|
||||
0 -> null
|
||||
1 ->
|
||||
KotlinFindCallableUsagesHandler.getInstance(callables.get(0) as JetCallableDeclaration, this)
|
||||
KotlinFindMemberUsagesHandler.getInstance(callables.get(0) as JetNamedDeclaration, this)
|
||||
else ->
|
||||
KotlinFindCallableUsagesHandler.getInstance(declaration, callables, this)
|
||||
KotlinFindMemberUsagesHandler.getInstance(declaration, callables, this)
|
||||
}
|
||||
} ?: FindUsagesHandler.NULL_HANDLER
|
||||
}
|
||||
|
||||
is JetTypeParameter ->
|
||||
return KotlinTypeParameterFindUsagesHandler(element, this)
|
||||
|
||||
else ->
|
||||
throw IllegalArgumentException("unexpected element type: " + element)
|
||||
}
|
||||
|
||||
+9
-2
@@ -23,8 +23,10 @@ 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.SimpleColoredComponent;
|
||||
import com.intellij.ui.StateRestoringCheckBox;
|
||||
import org.jetbrains.jet.lang.psi.JetProperty;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.JetNamedDeclaration;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
import org.jetbrains.jet.plugin.findUsages.KotlinPropertyFindUsagesOptions;
|
||||
@@ -91,11 +93,16 @@ public class KotlinFindPropertyUsagesDialog extends JavaFindUsagesDialog<KotlinP
|
||||
return findWhatPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureLabelComponent(@NotNull SimpleColoredComponent coloredComponent) {
|
||||
Utils.configureLabelComponent(coloredComponent, (JetNamedDeclaration) getPsiElement());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addUsagesOptions(JPanel optionsPanel) {
|
||||
super.addUsagesOptions(optionsPanel);
|
||||
|
||||
JetProperty property = (JetProperty) getPsiElement();
|
||||
JetNamedDeclaration property = (JetNamedDeclaration) getPsiElement();
|
||||
|
||||
boolean isAbstract = property.hasModifier(JetTokens.ABSTRACT_KEYWORD);
|
||||
boolean isOpen = property.hasModifier(JetTokens.OPEN_KEYWORD);
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.findUsages.CommonFindUsagesDialog;
|
||||
import com.intellij.find.findUsages.FindUsagesHandler;
|
||||
import com.intellij.find.findUsages.FindUsagesOptions;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.JetNamedDeclaration;
|
||||
|
||||
public class KotlinTypeParameterFindUsagesDialog<T extends JetNamedDeclaration> extends CommonFindUsagesDialog {
|
||||
public KotlinTypeParameterFindUsagesDialog(
|
||||
T element,
|
||||
Project project,
|
||||
FindUsagesOptions findUsagesOptions,
|
||||
boolean toShowInNewTab,
|
||||
boolean mustOpenInNewTab,
|
||||
boolean isSingleFile,
|
||||
FindUsagesHandler handler
|
||||
) {
|
||||
super(element, project, findUsagesOptions, toShowInNewTab, mustOpenInNewTab, isSingleFile, handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureLabelComponent(@NotNull SimpleColoredComponent coloredComponent) {
|
||||
Utils.configureLabelComponent(coloredComponent, (JetNamedDeclaration) myPsiElement);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
package org.jetbrains.jet.plugin.findUsages.dialogs;
|
||||
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.JetNamedDeclaration;
|
||||
import org.jetbrains.jet.plugin.search.usagesSearch.UsagesSearchPackage;
|
||||
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -9,6 +13,12 @@ class Utils {
|
||||
private Utils() {
|
||||
}
|
||||
|
||||
public static void configureLabelComponent(
|
||||
@NotNull SimpleColoredComponent coloredComponent,
|
||||
@NotNull JetNamedDeclaration declaration) {
|
||||
coloredComponent.append(DescriptorRenderer.COMPACT.render(UsagesSearchPackage.getDescriptor(declaration)));
|
||||
}
|
||||
|
||||
static boolean renameCheckbox(@NotNull JPanel panel, @NotNull String srcText, @NotNull String destText) {
|
||||
for (Component component : panel.getComponents()) {
|
||||
if (component instanceof JCheckBox) {
|
||||
|
||||
+22
-23
@@ -32,8 +32,9 @@ 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.JetNamedDeclaration;
|
||||
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
||||
import org.jetbrains.jet.lang.psi.JetParameter;
|
||||
import org.jetbrains.jet.lang.psi.JetProperty;
|
||||
import org.jetbrains.jet.plugin.findUsages.*;
|
||||
import org.jetbrains.jet.plugin.findUsages.dialogs.KotlinFindFunctionUsagesDialog;
|
||||
@@ -46,8 +47,8 @@ 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 abstract class KotlinFindMemberUsagesHandler<T extends JetNamedDeclaration> extends KotlinFindUsagesHandler<T> {
|
||||
private static class Function extends KotlinFindMemberUsagesHandler<JetNamedFunction> {
|
||||
public Function(
|
||||
@NotNull JetNamedFunction declaration,
|
||||
@NotNull Collection<? extends PsiElement> elementsToSearch,
|
||||
@@ -82,9 +83,9 @@ public abstract class KotlinFindCallableUsagesHandler<T extends JetCallableDecla
|
||||
}
|
||||
}
|
||||
|
||||
private static class Property extends KotlinFindCallableUsagesHandler<JetProperty> {
|
||||
private static class Property extends KotlinFindMemberUsagesHandler<JetNamedDeclaration> {
|
||||
public Property(
|
||||
@NotNull JetProperty declaration,
|
||||
@NotNull JetNamedDeclaration declaration,
|
||||
@NotNull Collection<? extends PsiElement> elementsToSearch,
|
||||
@NotNull KotlinFindUsagesHandlerFactory factory
|
||||
) {
|
||||
@@ -92,7 +93,7 @@ public abstract class KotlinFindCallableUsagesHandler<T extends JetCallableDecla
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UsagesSearchHelper<JetProperty> getSearchHelper(KotlinCallableFindUsagesOptions options) {
|
||||
protected UsagesSearchHelper<JetNamedDeclaration> getSearchHelper(KotlinCallableFindUsagesOptions options) {
|
||||
return FindUsagesPackage.toHelper((KotlinPropertyFindUsagesOptions) options);
|
||||
}
|
||||
|
||||
@@ -105,19 +106,13 @@ public abstract class KotlinFindCallableUsagesHandler<T extends JetCallableDecla
|
||||
@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);
|
||||
return new KotlinFindPropertyUsagesDialog(
|
||||
getElement(), getProject(), getFactory().getFindPropertyOptions(), toShowInNewTab, mustOpenInNewTab, isSingleFile, this
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected KotlinFindCallableUsagesHandler(
|
||||
protected KotlinFindMemberUsagesHandler(
|
||||
@NotNull T declaration,
|
||||
@NotNull Collection<? extends PsiElement> elementsToSearch,
|
||||
@NotNull KotlinFindUsagesHandlerFactory factory
|
||||
@@ -127,7 +122,7 @@ public abstract class KotlinFindCallableUsagesHandler<T extends JetCallableDecla
|
||||
|
||||
protected abstract UsagesSearchHelper<T> getSearchHelper(KotlinCallableFindUsagesOptions options);
|
||||
|
||||
private static Iterable<PsiMethod> getLightMethods(JetCallableDeclaration element) {
|
||||
private static Iterable<PsiMethod> getLightMethods(JetNamedDeclaration element) {
|
||||
if (element instanceof JetNamedFunction) {
|
||||
PsiMethod method = LightClassUtil.getLightClassMethod((JetNamedFunction) element);
|
||||
return method != null ? Collections.singletonList(method) : Collections.<PsiMethod>emptyList();
|
||||
@@ -137,6 +132,10 @@ public abstract class KotlinFindCallableUsagesHandler<T extends JetCallableDecla
|
||||
return LightClassUtil.getLightClassPropertyMethods((JetProperty) element);
|
||||
}
|
||||
|
||||
if (element instanceof JetParameter) {
|
||||
return LightClassUtil.getLightClassPropertyMethods((JetParameter) element);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -157,7 +156,7 @@ public abstract class KotlinFindCallableUsagesHandler<T extends JetCallableDecla
|
||||
Iterator<PsiMethod> lightMethods = ApplicationManager.getApplication().runReadAction(new Computable<Iterator<PsiMethod>>() {
|
||||
@Override
|
||||
public Iterator<PsiMethod> compute() {
|
||||
return getLightMethods((JetCallableDeclaration) element).iterator();
|
||||
return getLightMethods((JetNamedDeclaration) element).iterator();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -185,18 +184,18 @@ public abstract class KotlinFindCallableUsagesHandler<T extends JetCallableDecla
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static KotlinFindCallableUsagesHandler<? extends JetCallableDeclaration> getInstance(
|
||||
@NotNull JetCallableDeclaration declaration,
|
||||
public static KotlinFindMemberUsagesHandler<? extends JetNamedDeclaration> getInstance(
|
||||
@NotNull JetNamedDeclaration 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);
|
||||
: new Property(declaration, elementsToSearch, factory);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static KotlinFindCallableUsagesHandler<? extends JetCallableDeclaration> getInstance(
|
||||
@NotNull JetCallableDeclaration declaration,
|
||||
public static KotlinFindMemberUsagesHandler<? extends JetNamedDeclaration> getInstance(
|
||||
@NotNull JetNamedDeclaration declaration,
|
||||
@NotNull KotlinFindUsagesHandlerFactory factory) {
|
||||
return getInstance(declaration, Collections.<PsiElement>emptyList(), factory);
|
||||
}
|
||||
@@ -18,21 +18,15 @@ package org.jetbrains.jet.plugin.findUsages.handlers;
|
||||
|
||||
import com.intellij.find.findUsages.FindUsagesHandler;
|
||||
import com.intellij.find.findUsages.FindUsagesOptions;
|
||||
import com.intellij.find.findUsages.JavaFindUsagesOptions;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiNamedElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.util.Processor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.plugin.findUsages.FindUsagesPackage;
|
||||
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.Collections;
|
||||
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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.PsiReference;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.util.Processor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.JetNamedDeclaration;
|
||||
import org.jetbrains.jet.plugin.findUsages.FindUsagesPackage;
|
||||
import org.jetbrains.jet.plugin.findUsages.KotlinFindUsagesHandlerFactory;
|
||||
import org.jetbrains.jet.plugin.findUsages.dialogs.KotlinTypeParameterFindUsagesDialog;
|
||||
import org.jetbrains.jet.plugin.search.usagesSearch.DefaultSearchHelper;
|
||||
import org.jetbrains.jet.plugin.search.usagesSearch.UsagesSearch;
|
||||
import org.jetbrains.jet.plugin.search.usagesSearch.UsagesSearchRequest;
|
||||
import org.jetbrains.jet.plugin.search.usagesSearch.UsagesSearchTarget;
|
||||
|
||||
public class KotlinTypeParameterFindUsagesHandler extends KotlinFindUsagesHandler<JetNamedDeclaration> {
|
||||
public KotlinTypeParameterFindUsagesHandler(@NotNull JetNamedDeclaration element, @NotNull KotlinFindUsagesHandlerFactory factory) {
|
||||
super(element, factory);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AbstractFindUsagesDialog getFindUsagesDialog(boolean isSingleFile, boolean toShowInNewTab, boolean mustOpenInNewTab) {
|
||||
return new KotlinTypeParameterFindUsagesDialog<JetNamedDeclaration>(
|
||||
getElement(), getProject(), getFindUsagesOptions(), toShowInNewTab, mustOpenInNewTab, isSingleFile, this
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean searchReferences(
|
||||
@NotNull final PsiElement element, @NotNull final Processor<UsageInfo> processor, @NotNull final FindUsagesOptions options
|
||||
) {
|
||||
return ApplicationManager.getApplication().runReadAction(
|
||||
new Computable<Boolean>() {
|
||||
@Override
|
||||
public Boolean compute() {
|
||||
UsagesSearchTarget<JetNamedDeclaration> target =
|
||||
FindUsagesPackage.toSearchTarget(options, (JetNamedDeclaration) element, true);
|
||||
UsagesSearchRequest request = new DefaultSearchHelper().newRequest(target);
|
||||
|
||||
for (PsiReference ref : UsagesSearch.instance$.search(request)) {
|
||||
if (!processUsage(processor, ref)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public FindUsagesOptions getFindUsagesOptions(@Nullable DataContext dataContext) {
|
||||
return getFactory().getFindClassOptions();
|
||||
}
|
||||
}
|
||||
@@ -136,8 +136,15 @@ public class JetRefactoringUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<? extends PsiElement> getPropertySuperDeclarations(@NotNull JetProperty property) {
|
||||
LightClassUtil.PropertyAccessorsPsiMethods lightMethods = LightClassUtil.getLightClassPropertyMethods(property);
|
||||
private static List<? extends PsiElement> getPropertySuperDeclarations(@NotNull JetDeclaration declaration) {
|
||||
LightClassUtil.PropertyAccessorsPsiMethods lightMethods;
|
||||
if (declaration instanceof JetProperty) {
|
||||
lightMethods = LightClassUtil.getLightClassPropertyMethods((JetProperty) declaration);
|
||||
}
|
||||
else if (declaration instanceof JetParameter) {
|
||||
lightMethods = LightClassUtil.getLightClassPropertyMethods((JetParameter) declaration);
|
||||
}
|
||||
else return Collections.emptyList();
|
||||
|
||||
Collection<PsiMethod> foundMethods = new HashSet<PsiMethod>();
|
||||
if (lightMethods.getGetter() != null) {
|
||||
@@ -158,7 +165,7 @@ public class JetRefactoringUtil {
|
||||
@NotNull
|
||||
private static List<? extends PsiElement> getSuperDeclarations(@NotNull JetDeclaration declaration) {
|
||||
if (declaration instanceof JetNamedFunction) return getFunctionSuperDeclarations((JetNamedFunction) declaration);
|
||||
if (declaration instanceof JetProperty) return getPropertySuperDeclarations((JetProperty) declaration);
|
||||
if (declaration instanceof JetProperty || declaration instanceof JetParameter) return getPropertySuperDeclarations(declaration);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -174,9 +181,6 @@ public class JetRefactoringUtil {
|
||||
if (declarationDescriptor instanceof LocalVariableDescriptor) {
|
||||
return Collections.singletonList(declaration);
|
||||
}
|
||||
if (!(declarationDescriptor instanceof CallableMemberDescriptor)) return null;
|
||||
|
||||
CallableMemberDescriptor callableDescriptor = (CallableMemberDescriptor) declarationDescriptor;
|
||||
|
||||
List<? extends PsiElement> superDeclarations = getSuperDeclarations(declaration);
|
||||
if (ignore != null) {
|
||||
@@ -186,13 +190,13 @@ public class JetRefactoringUtil {
|
||||
if (superDeclarations.isEmpty()) return Collections.singletonList(declaration);
|
||||
|
||||
java.util.List<String> superClasses = getClassDescriptions(bindingContext, superDeclarations);
|
||||
return askUserForMethodsToSearch(declaration, callableDescriptor, superDeclarations, superClasses, actionStringKey);
|
||||
return askUserForMethodsToSearch(declaration, declarationDescriptor, superDeclarations, superClasses, actionStringKey);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<? extends PsiElement> askUserForMethodsToSearch(
|
||||
@NotNull JetDeclaration declaration,
|
||||
@NotNull CallableMemberDescriptor callableDescriptor,
|
||||
@NotNull DeclarationDescriptor declarationDescriptor,
|
||||
@NotNull List<? extends PsiElement> superMethods,
|
||||
@NotNull List<String> superClasses,
|
||||
@NotNull String actionStringKey
|
||||
@@ -200,8 +204,8 @@ public class JetRefactoringUtil {
|
||||
String superClassesStr = "\n" + StringUtil.join(superClasses, "");
|
||||
String message = JetBundle.message(
|
||||
"x.overrides.y.in.class.list",
|
||||
DescriptorRenderer.COMPACT.render(callableDescriptor),
|
||||
DescriptorRenderer.SOURCE_CODE_SHORT_NAMES_IN_TYPES.render(callableDescriptor.getContainingDeclaration()),
|
||||
DescriptorRenderer.COMPACT.render(declarationDescriptor),
|
||||
DescriptorRenderer.SOURCE_CODE_SHORT_NAMES_IN_TYPES.render(declarationDescriptor.getContainingDeclaration()),
|
||||
superClassesStr,
|
||||
JetBundle.message(actionStringKey)
|
||||
);
|
||||
|
||||
@@ -42,6 +42,7 @@ import com.intellij.usages.impl.rules.UsageType
|
||||
import org.jetbrains.jet.asJava.LightClassUtil
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi
|
||||
import org.jetbrains.jet.codegen.PropertyCodegen
|
||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor
|
||||
|
||||
// Navigation element of the resolved reference
|
||||
// For property accessor return enclosing property
|
||||
@@ -54,18 +55,23 @@ val PsiReference.navigationTarget: PsiElement?
|
||||
val JetDeclaration.descriptor: DeclarationDescriptor?
|
||||
get() = AnalyzerFacadeWithCache.getContextForElement(this).get(BindingContext.DECLARATION_TO_DESCRIPTOR, this)
|
||||
|
||||
val JetParameter.propertyDescriptor: PropertyDescriptor?
|
||||
get() = AnalyzerFacadeWithCache.getContextForElement(this).get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, this)
|
||||
|
||||
fun PsiReference.isTargetUsage(target: PsiElement): Boolean {
|
||||
return target.getNavigationElement() == navigationTarget
|
||||
}
|
||||
|
||||
fun PsiReference.checkUsageVsOriginalDescriptor(
|
||||
target: JetDeclaration, checker: (usageDescriptor: DeclarationDescriptor, targetDescriptor: DeclarationDescriptor) -> Boolean
|
||||
target: JetDeclaration,
|
||||
declarationToDescriptor: (JetDeclaration) -> DeclarationDescriptor? = {it.descriptor},
|
||||
checker: (usageDescriptor: DeclarationDescriptor, targetDescriptor: DeclarationDescriptor) -> Boolean
|
||||
): Boolean {
|
||||
val refTarget = navigationTarget
|
||||
if (refTarget !is JetDeclaration) return false
|
||||
|
||||
val usageDescriptor = refTarget.descriptor
|
||||
val targetDescriptor = target.descriptor
|
||||
val usageDescriptor = declarationToDescriptor(refTarget)
|
||||
val targetDescriptor = declarationToDescriptor(target)
|
||||
return usageDescriptor != null && targetDescriptor != null && checker(usageDescriptor, targetDescriptor)
|
||||
}
|
||||
|
||||
@@ -137,22 +143,32 @@ fun PsiReference.isUsageInContainingDeclaration(declaration: JetNamedDeclaration
|
||||
&& usageDescriptor.getContainingDeclaration() == targetDescriptor.getContainingDeclaration()
|
||||
}
|
||||
|
||||
fun PsiReference.isCallableOverrideUsage(declaration: JetCallableDeclaration): Boolean =
|
||||
checkUsageVsOriginalDescriptor(declaration) { (usageDescriptor, targetDescriptor) ->
|
||||
usageDescriptor is CallableDescriptor && targetDescriptor is CallableDescriptor
|
||||
&& OverridingUtil.overrides(usageDescriptor, targetDescriptor)
|
||||
}
|
||||
|
||||
fun PsiReference.isPropertyReadOnlyUsage(): Boolean {
|
||||
if (this is JetPsiReference) {
|
||||
return JetUsageTypeProvider.getUsageType(getElement()) != UsageType.WRITE
|
||||
fun PsiReference.isCallableOverrideUsage(declaration: JetNamedDeclaration): Boolean {
|
||||
val decl2Desc = {(declaration: JetDeclaration) ->
|
||||
if (declaration is JetParameter && declaration.getValOrVarNode() != null) declaration.propertyDescriptor else declaration.descriptor
|
||||
}
|
||||
|
||||
val refTarget = resolve()
|
||||
return checkUsageVsOriginalDescriptor(declaration, decl2Desc) { (usageDescriptor, targetDescriptor) ->
|
||||
usageDescriptor is CallableDescriptor && targetDescriptor is CallableDescriptor
|
||||
&& OverridingUtil.overrides(usageDescriptor, targetDescriptor)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check if reference resolves to property getter
|
||||
// Works for JetProperty and JetParameter
|
||||
fun PsiReference.isPropertyReadOnlyUsage(): Boolean {
|
||||
if (JetUsageTypeProvider.getUsageType(getElement()) == UsageType.READ) return true
|
||||
|
||||
val refTarget = resolve()
|
||||
if (refTarget is JetClsMethod) {
|
||||
val property = refTarget.getOrigin()?.getParentByType(javaClass<JetProperty>())
|
||||
return property != null && refTarget.getName() == PropertyCodegen.getterName(property.getNameAsName())
|
||||
val origin = refTarget.getOrigin()
|
||||
val declaration: JetNamedDeclaration? = when (origin) {
|
||||
is JetPropertyAccessor -> origin.getParentByType(javaClass<JetProperty>())
|
||||
is JetProperty, is JetParameter -> origin as JetNamedDeclaration
|
||||
else -> null
|
||||
}
|
||||
return declaration != null && refTarget.getName() == PropertyCodegen.getterName(declaration.getNameAsName())
|
||||
}
|
||||
|
||||
return false
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetParameter
|
||||
// OPTIONS: usages
|
||||
open class A<T>(<caret>foo: T) {
|
||||
{
|
||||
println(foo)
|
||||
}
|
||||
|
||||
val t: T = foo
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
Value read (5: 17) println(foo)
|
||||
Value read (8: 16) val t: T = foo
|
||||
@@ -0,0 +1,6 @@
|
||||
// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetParameter
|
||||
// OPTIONS: usages
|
||||
fun foo<T>(<caret>t: T): T {
|
||||
println(t)
|
||||
return t
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
Value read (4: 13) println(t)
|
||||
Value read (5: 12) return t
|
||||
@@ -0,0 +1,26 @@
|
||||
// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetParameter
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
|
||||
open class D: A<String>("") {
|
||||
override var foo: String = ""
|
||||
}
|
||||
|
||||
open class E<T>(override var foo: T): A<T>(foo)
|
||||
@@ -0,0 +1,15 @@
|
||||
class C extends A<String> {
|
||||
C(String s) {
|
||||
super(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFoo() {
|
||||
return super.getFoo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFoo(String s) {
|
||||
super.setFoo(s);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
Unclassified usage (11: 9) set(value: String) {
|
||||
Unclassified usage (12: 17) public void setFoo(String s) {
|
||||
Unclassified usage (23: 18) override var foo: String = ""
|
||||
Unclassified usage (23: 18) override var foo: String = ""
|
||||
Unclassified usage (26: 30) open class E<T>(override var foo: T): A<T>(foo)
|
||||
Unclassified usage (26: 30) open class E<T>(override var foo: T): A<T>(foo)
|
||||
Unclassified usage (7: 19) public String getFoo() {
|
||||
Unclassified usage (7: 9) get() {
|
||||
@@ -0,0 +1,16 @@
|
||||
// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetParameter
|
||||
// OPTIONS: usages, skipWrite
|
||||
package server;
|
||||
|
||||
open class A<T>(open var <caret>foo: 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());
|
||||
@@ -0,0 +1,16 @@
|
||||
// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetParameter
|
||||
// OPTIONS: usages
|
||||
package server;
|
||||
|
||||
open class A<T>(open var <caret>foo: 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,4 @@
|
||||
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,16 @@
|
||||
// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetParameter
|
||||
// OPTIONS: usages, skipRead
|
||||
package server;
|
||||
|
||||
open class A<T>(open var <caret>foo: 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());
|
||||
}
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
Unclassified usage (12: 11) b.setFoo("b");
|
||||
Unclassified usage (8: 11) a.setFoo("a");
|
||||
@@ -0,0 +1,12 @@
|
||||
// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetParameter
|
||||
// OPTIONS: usages
|
||||
package server;
|
||||
|
||||
public open class Server(private val <caret>foo: String = "foo") {
|
||||
open fun processRequest() = foo
|
||||
}
|
||||
|
||||
public class ServerEx(): Server() {
|
||||
override fun processRequest() = "foo" + foo
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import server.*;
|
||||
|
||||
class Client {
|
||||
public fun foo() {
|
||||
println(Server().foo)
|
||||
ServerEx().processRequest()
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
Value read (10: 45) override fun processRequest() = "foo" + foo
|
||||
Value read (5: 26) println(Server().foo)
|
||||
Value read (6: 33) open fun processRequest() = foo
|
||||
@@ -0,0 +1,17 @@
|
||||
// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetParameter
|
||||
// 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}")
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
Value read (11: 29) return super<A>.foo
|
||||
Value read (11: 30) println("b.foo = ${b.foo}")
|
||||
Value read (7: 30) println("a.foo = ${a.foo}")
|
||||
@@ -0,0 +1,17 @@
|
||||
// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetParameter
|
||||
// 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: 29) return super<A>.foo
|
||||
Value read (11: 30) println("b.foo = ${b.foo}")
|
||||
Value read (7: 30) println("a.foo = ${a.foo}")
|
||||
Value write (10: 11) b.foo = "b"
|
||||
Value write (15: 22) super<A>.foo = value
|
||||
Value write (6: 11) a.foo = "a"
|
||||
@@ -0,0 +1,17 @@
|
||||
// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetParameter
|
||||
// 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}")
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
Value write (10: 11) b.foo = "b"
|
||||
Value write (15: 22) super<A>.foo = value
|
||||
Value write (6: 11) a.foo = "a"
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetTypeParameter
|
||||
// OPTIONS: usages
|
||||
open class A<<caret>T>(foo: T, list: List<T>) {
|
||||
{
|
||||
fun T.bar() {}
|
||||
|
||||
foo.bar()
|
||||
}
|
||||
|
||||
val t: T = foo
|
||||
fun bar(t: T): T = t
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
Class/object property type (10: 12) val t: T = foo
|
||||
Extension receiver type (5: 13) fun T.bar() {}
|
||||
Function return types (11: 20) fun bar(t: T): T = t
|
||||
Parameter type (11: 16) fun bar(t: T): T = t
|
||||
Parameter type (3: 22) open class A<T>(foo: T, list: List<T>) {
|
||||
Type parameter (3: 36) open class A<T>(foo: T, list: List<T>) {
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetTypeParameter
|
||||
// OPTIONS: usages
|
||||
fun <<caret>T> T.foo(t: T, list: List<T>): T {
|
||||
return t
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
Extension receiver type (3: 9) fun <T> T.foo(t: T, list: List<T>): T {
|
||||
Function return types (3: 37) fun <T> T.foo(t: T, list: List<T>): T {
|
||||
Parameter type (3: 18) fun <T> T.foo(t: T, list: List<T>): T {
|
||||
Type parameter (3: 32) fun <T> T.foo(t: T, list: List<T>): T {
|
||||
@@ -42,9 +42,7 @@ import com.intellij.util.CommonProcessors;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.InTextDirectivesUtils;
|
||||
import org.jetbrains.jet.lang.psi.JetClass;
|
||||
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
||||
import org.jetbrains.jet.lang.psi.JetProperty;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.plugin.JetLightProjectDescriptor;
|
||||
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
||||
import org.jetbrains.jet.plugin.findUsages.KotlinClassFindUsagesOptions;
|
||||
@@ -194,6 +192,13 @@ public abstract class AbstractJetFindUsagesTest extends LightCodeInsightFixtureT
|
||||
public FindUsagesOptions parse(@NotNull String text, @NotNull Project project) {
|
||||
return new JavaVariableFindUsagesOptions(project);
|
||||
}
|
||||
},
|
||||
DEFAULT {
|
||||
@NotNull
|
||||
@Override
|
||||
public FindUsagesOptions parse(@NotNull String text, @NotNull Project project) {
|
||||
return new FindUsagesOptions(project);
|
||||
}
|
||||
};
|
||||
|
||||
protected static boolean parseCommonOptions(JavaFindUsagesOptions options, String s) {
|
||||
@@ -218,7 +223,7 @@ public abstract class AbstractJetFindUsagesTest extends LightCodeInsightFixtureT
|
||||
if (klass == JetNamedFunction.class) {
|
||||
return FUNCTION;
|
||||
}
|
||||
if (klass == JetProperty.class) {
|
||||
if (klass == JetProperty.class || klass == JetParameter.class) {
|
||||
return PROPERTY;
|
||||
}
|
||||
if (klass == JetClass.class) {
|
||||
@@ -233,6 +238,9 @@ public abstract class AbstractJetFindUsagesTest extends LightCodeInsightFixtureT
|
||||
if (klass == PsiField.class) {
|
||||
return JAVA_FIELD;
|
||||
}
|
||||
if (klass == JetTypeParameter.class) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.jetbrains.jet.findUsages.AbstractJetFindUsagesTest;
|
||||
@InnerTestClasses({JetFindUsagesTestGenerated.Kotlin.class, JetFindUsagesTestGenerated.Java.class})
|
||||
public class JetFindUsagesTestGenerated extends AbstractJetFindUsagesTest {
|
||||
@TestMetadata("idea/testData/findUsages/kotlin")
|
||||
@InnerTestClasses({Kotlin.FindClassUsages.class, Kotlin.FindFunctionUsages.class, Kotlin.FindObjectUsages.class, Kotlin.FindPropertyUsages.class, Kotlin.FindWithFilteringImports.class, Kotlin.UnresolvedAnnotation.class})
|
||||
@InnerTestClasses({Kotlin.FindClassUsages.class, Kotlin.FindFunctionUsages.class, Kotlin.FindObjectUsages.class, Kotlin.FindParameterUsages.class, Kotlin.FindPropertyUsages.class, Kotlin.FindTypeParameterUsages.class, Kotlin.FindWithFilteringImports.class, Kotlin.UnresolvedAnnotation.class})
|
||||
public static class Kotlin extends AbstractJetFindUsagesTest {
|
||||
public void testAllFilesPresentInKotlin() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/findUsages/kotlin"), Pattern.compile("^(.+)\\.0\\.kt$"), true);
|
||||
@@ -293,6 +293,24 @@ public class JetFindUsagesTestGenerated extends AbstractJetFindUsagesTest {
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/findUsages/kotlin/findParameterUsages")
|
||||
public static class FindParameterUsages extends AbstractJetFindUsagesTest {
|
||||
public void testAllFilesPresentInFindParameterUsages() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/findUsages/kotlin/findParameterUsages"), Pattern.compile("^(.+)\\.0\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinConstructorParameterUsages.0.kt")
|
||||
public void testKotlinConstructorParameterUsages() throws Exception {
|
||||
doTest("idea/testData/findUsages/kotlin/findParameterUsages/kotlinConstructorParameterUsages.0.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinFunctionParameterUsages.0.kt")
|
||||
public void testKotlinFunctionParameterUsages() throws Exception {
|
||||
doTest("idea/testData/findUsages/kotlin/findParameterUsages/kotlinFunctionParameterUsages.0.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/findUsages/kotlin/findPropertyUsages")
|
||||
public static class FindPropertyUsages extends AbstractJetFindUsagesTest {
|
||||
public void testAllFilesPresentInFindPropertyUsages() throws Exception {
|
||||
@@ -304,21 +322,41 @@ public class JetFindUsagesTestGenerated extends AbstractJetFindUsagesTest {
|
||||
doTest("idea/testData/findUsages/kotlin/findPropertyUsages/javaAndKotlinOverrides.0.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("javaAndKotlinOverrides2.0.kt")
|
||||
public void testJavaAndKotlinOverrides2() throws Exception {
|
||||
doTest("idea/testData/findUsages/kotlin/findPropertyUsages/javaAndKotlinOverrides2.0.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("javaPropertyReadUsages.0.kt")
|
||||
public void testJavaPropertyReadUsages() throws Exception {
|
||||
doTest("idea/testData/findUsages/kotlin/findPropertyUsages/javaPropertyReadUsages.0.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("javaPropertyReadUsages2.0.kt")
|
||||
public void testJavaPropertyReadUsages2() throws Exception {
|
||||
doTest("idea/testData/findUsages/kotlin/findPropertyUsages/javaPropertyReadUsages2.0.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("javaPropertyUsages.0.kt")
|
||||
public void testJavaPropertyUsages() throws Exception {
|
||||
doTest("idea/testData/findUsages/kotlin/findPropertyUsages/javaPropertyUsages.0.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("javaPropertyUsages2.0.kt")
|
||||
public void testJavaPropertyUsages2() throws Exception {
|
||||
doTest("idea/testData/findUsages/kotlin/findPropertyUsages/javaPropertyUsages2.0.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("javaPropertyWriteUsages.0.kt")
|
||||
public void testJavaPropertyWriteUsages() throws Exception {
|
||||
doTest("idea/testData/findUsages/kotlin/findPropertyUsages/javaPropertyWriteUsages.0.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("javaPropertyWriteUsages2.0.kt")
|
||||
public void testJavaPropertyWriteUsages2() throws Exception {
|
||||
doTest("idea/testData/findUsages/kotlin/findPropertyUsages/javaPropertyWriteUsages2.0.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinLocalPropertyUsages1.0.kt")
|
||||
public void testKotlinLocalPropertyUsages1() throws Exception {
|
||||
doTest("idea/testData/findUsages/kotlin/findPropertyUsages/kotlinLocalPropertyUsages1.0.kt");
|
||||
@@ -334,21 +372,41 @@ public class JetFindUsagesTestGenerated extends AbstractJetFindUsagesTest {
|
||||
doTest("idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPrivatePropertyUsages.0.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinPrivatePropertyUsages2.0.kt")
|
||||
public void testKotlinPrivatePropertyUsages2() throws Exception {
|
||||
doTest("idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPrivatePropertyUsages2.0.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinPropertyReadUsages.0.kt")
|
||||
public void testKotlinPropertyReadUsages() throws Exception {
|
||||
doTest("idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPropertyReadUsages.0.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinPropertyReadUsages2.0.kt")
|
||||
public void testKotlinPropertyReadUsages2() throws Exception {
|
||||
doTest("idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPropertyReadUsages2.0.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinPropertyUsages.0.kt")
|
||||
public void testKotlinPropertyUsages() throws Exception {
|
||||
doTest("idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPropertyUsages.0.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinPropertyUsages2.0.kt")
|
||||
public void testKotlinPropertyUsages2() throws Exception {
|
||||
doTest("idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPropertyUsages2.0.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinPropertyWriteUsages.0.kt")
|
||||
public void testKotlinPropertyWriteUsages() throws Exception {
|
||||
doTest("idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPropertyWriteUsages.0.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinPropertyWriteUsages2.0.kt")
|
||||
public void testKotlinPropertyWriteUsages2() throws Exception {
|
||||
doTest("idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPropertyWriteUsages2.0.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinTopLevelPropertyUsages.0.kt")
|
||||
public void testKotlinTopLevelPropertyUsages() throws Exception {
|
||||
doTest("idea/testData/findUsages/kotlin/findPropertyUsages/kotlinTopLevelPropertyUsages.0.kt");
|
||||
@@ -356,6 +414,24 @@ public class JetFindUsagesTestGenerated extends AbstractJetFindUsagesTest {
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/findUsages/kotlin/findTypeParameterUsages")
|
||||
public static class FindTypeParameterUsages extends AbstractJetFindUsagesTest {
|
||||
public void testAllFilesPresentInFindTypeParameterUsages() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/findUsages/kotlin/findTypeParameterUsages"), Pattern.compile("^(.+)\\.0\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinClassTypeParameterUsages.0.kt")
|
||||
public void testKotlinClassTypeParameterUsages() throws Exception {
|
||||
doTest("idea/testData/findUsages/kotlin/findTypeParameterUsages/kotlinClassTypeParameterUsages.0.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinFunctionTypeParameterUsages.0.kt")
|
||||
public void testKotlinFunctionTypeParameterUsages() throws Exception {
|
||||
doTest("idea/testData/findUsages/kotlin/findTypeParameterUsages/kotlinFunctionTypeParameterUsages.0.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/findUsages/kotlin/findWithFilteringImports")
|
||||
public static class FindWithFilteringImports extends AbstractJetFindUsagesTest {
|
||||
public void testAllFilesPresentInFindWithFilteringImports() throws Exception {
|
||||
@@ -388,7 +464,9 @@ public class JetFindUsagesTestGenerated extends AbstractJetFindUsagesTest {
|
||||
suite.addTestSuite(FindClassUsages.class);
|
||||
suite.addTestSuite(FindFunctionUsages.class);
|
||||
suite.addTestSuite(FindObjectUsages.class);
|
||||
suite.addTestSuite(FindParameterUsages.class);
|
||||
suite.addTestSuite(FindPropertyUsages.class);
|
||||
suite.addTestSuite(FindTypeParameterUsages.class);
|
||||
suite.addTestSuite(FindWithFilteringImports.class);
|
||||
suite.addTestSuite(UnresolvedAnnotation.class);
|
||||
return suite;
|
||||
|
||||
Reference in New Issue
Block a user