Merge remote-tracking branch 'origin/master'
|
Before Width: | Height: | Size: 342 B After Width: | Height: | Size: 1.0 KiB |
@@ -3,7 +3,7 @@
|
||||
<company name="JetBrains s.r.o." url="http://www.jetbrains.com/?fromIDE"/>
|
||||
<build number="__BUILD_NUMBER__" date="__BUILD_DATE__"/>
|
||||
<install-over minbuild="129.1" maxbuild="135.9999" version="13.1"/>
|
||||
<logo url="/idea_community_logo.png" textcolor="444444" progressColor="ffaa16" progressY="222" progressTailIcon="/community_progress_tail.png"/>
|
||||
<logo url="/idea_community_logo.png" textcolor="aaaaaa" progressColor="B0C6B0" progressY="230" progressTailIcon="/community_progress_tail.png"/>
|
||||
<about url="/idea_community_about.png" foreground="444444" linkColor="000099" logoX="300" logoY="265" logoW="75" logoH="30"/>
|
||||
<icon size32="/icon_CE.png" size16="/icon_CEsmall.png" size32opaque="/icon_CEwhite.png" size12="/toolwindows/toolWindowProject.png" size128="/icon_CE_128.png" ico="idea_CE.ico"/>
|
||||
<package code="__PACKAGE_CODE__"/>
|
||||
|
||||
|
Before Width: | Height: | Size: 129 KiB After Width: | Height: | Size: 132 KiB |
|
Before Width: | Height: | Size: 374 KiB After Width: | Height: | Size: 423 KiB |
@@ -23,8 +23,6 @@ import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ex.ProjectManagerEx;
|
||||
import com.intellij.openapi.roots.impl.DirectoryIndex;
|
||||
import com.intellij.openapi.roots.impl.DirectoryIndexImpl;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
@@ -81,9 +79,6 @@ public class GenerateAntApplication {
|
||||
logMessage(0, "Loading project...");
|
||||
myProject = ProjectManagerEx.getInstanceEx().loadProject(myProjectPath);
|
||||
|
||||
DirectoryIndexImpl dirIndex = (DirectoryIndexImpl)DirectoryIndex.getInstance(myProject);
|
||||
dirIndex.initialize();
|
||||
|
||||
logMessageLn(0, " done");
|
||||
|
||||
GenerateAntBuildAction.generateSingleFileBuild(myProject,
|
||||
|
||||
@@ -24,10 +24,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ui.util.CompositeAppearance;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiModifier;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.presentation.java.ClassPresentationUtil;
|
||||
import com.intellij.ui.LayeredIcon;
|
||||
import com.intellij.ui.RowIcon;
|
||||
@@ -41,13 +38,12 @@ public final class MethodHierarchyNodeDescriptor extends HierarchyNodeDescriptor
|
||||
private Icon myStateIcon;
|
||||
private MethodHierarchyTreeStructure myTreeStructure;
|
||||
|
||||
public MethodHierarchyNodeDescriptor(
|
||||
final Project project,
|
||||
final HierarchyNodeDescriptor parentDescriptor,
|
||||
final PsiClass aClass,
|
||||
final boolean isBase,
|
||||
final MethodHierarchyTreeStructure treeStructure
|
||||
){
|
||||
public MethodHierarchyNodeDescriptor(final Project project,
|
||||
final HierarchyNodeDescriptor parentDescriptor,
|
||||
final PsiElement aClass,
|
||||
final boolean isBase,
|
||||
final MethodHierarchyTreeStructure treeStructure
|
||||
) {
|
||||
super(project, parentDescriptor, aClass, isBase);
|
||||
myTreeStructure = treeStructure;
|
||||
}
|
||||
@@ -60,24 +56,26 @@ public final class MethodHierarchyNodeDescriptor extends HierarchyNodeDescriptor
|
||||
return MethodHierarchyUtil.findBaseMethodInClass(myTreeStructure.getBaseMethod(), aClass, checkBases);
|
||||
}
|
||||
|
||||
public final PsiClass getPsiClass() {
|
||||
return (PsiClass)myElement;
|
||||
public final PsiElement getPsiClass() {
|
||||
return myElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Element for OpenFileDescriptor
|
||||
*/
|
||||
public final PsiElement getTargetElement() {
|
||||
final PsiClass aClass = getPsiClass();
|
||||
if (aClass == null || !aClass.isValid()) return null;
|
||||
final PsiElement element = getPsiClass();
|
||||
if (!(element instanceof PsiClass)) return element;
|
||||
final PsiClass aClass = (PsiClass)getPsiClass();
|
||||
if (!aClass.isValid()) return null;
|
||||
final PsiMethod method = getMethod(aClass, false);
|
||||
if (method != null) return method;
|
||||
return aClass;
|
||||
}
|
||||
|
||||
public final boolean isValid() {
|
||||
final PsiClass aClass = getPsiClass();
|
||||
return aClass != null && aClass.isValid();
|
||||
final PsiElement psiElement = getPsiClass();
|
||||
return psiElement != null && psiElement.isValid();
|
||||
}
|
||||
|
||||
public final boolean update() {
|
||||
@@ -88,7 +86,7 @@ public final class MethodHierarchyNodeDescriptor extends HierarchyNodeDescriptor
|
||||
|
||||
boolean changes = super.update();
|
||||
|
||||
final PsiClass psiClass = getPsiClass();
|
||||
final PsiElement psiClass = getPsiClass();
|
||||
|
||||
if (psiClass == null){
|
||||
final String invalidPrefix = IdeBundle.message("node.hierarchy.invalid");
|
||||
@@ -99,7 +97,7 @@ public final class MethodHierarchyNodeDescriptor extends HierarchyNodeDescriptor
|
||||
}
|
||||
|
||||
final Icon newRawIcon = psiClass.getIcon(flags);
|
||||
final Icon newStateIcon = calculateState(psiClass);
|
||||
final Icon newStateIcon = psiClass instanceof PsiClass ? calculateState((PsiClass)psiClass) : AllIcons.Hierarchy.MethodDefined;
|
||||
|
||||
if (changes || newRawIcon != myRawIcon || newStateIcon != myStateIcon) {
|
||||
changes = true;
|
||||
@@ -133,8 +131,12 @@ public final class MethodHierarchyNodeDescriptor extends HierarchyNodeDescriptor
|
||||
if (myColor != null) {
|
||||
classNameAttributes = new TextAttributes(myColor, null, null, null, Font.PLAIN);
|
||||
}
|
||||
myHighlightedText.getEnding().addText(ClassPresentationUtil.getNameForClass(psiClass, false), classNameAttributes);
|
||||
myHighlightedText.getEnding().addText(" (" + JavaHierarchyUtil.getPackageName(psiClass) + ")", HierarchyNodeDescriptor.getPackageNameAttributes());
|
||||
if (psiClass instanceof PsiClass) {
|
||||
myHighlightedText.getEnding().addText(ClassPresentationUtil.getNameForClass((PsiClass)psiClass, false), classNameAttributes);
|
||||
myHighlightedText.getEnding().addText(" (" + JavaHierarchyUtil.getPackageName((PsiClass)psiClass) + ")", HierarchyNodeDescriptor.getPackageNameAttributes());
|
||||
} else if (psiClass instanceof PsiFunctionalExpression) {
|
||||
myHighlightedText.getEnding().addText(ClassPresentationUtil.getFunctionalExpressionPresentation((PsiFunctionalExpression)psiClass, false));
|
||||
}
|
||||
myName = myHighlightedText.getText();
|
||||
|
||||
if (!Comparing.equal(myHighlightedText, oldText)) {
|
||||
|
||||
@@ -21,6 +21,9 @@ import com.intellij.ide.hierarchy.HierarchyTreeStructure;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.searches.ClassInheritorsSearch;
|
||||
import com.intellij.psi.search.searches.FunctionalExpressionSearch;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Processor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -152,11 +155,12 @@ public final class MethodHierarchyTreeStructure extends HierarchyTreeStructure {
|
||||
@NotNull
|
||||
@Override
|
||||
protected final Object[] buildChildren(@NotNull final HierarchyNodeDescriptor descriptor) {
|
||||
final PsiClass psiClass = ((MethodHierarchyNodeDescriptor)descriptor).getPsiClass();
|
||||
|
||||
final PsiElement psiElement = ((MethodHierarchyNodeDescriptor)descriptor).getPsiClass();
|
||||
if (!(psiElement instanceof PsiClass)) return ArrayUtil.EMPTY_OBJECT_ARRAY;
|
||||
final PsiClass psiClass = (PsiClass)psiElement;
|
||||
final Collection<PsiClass> subclasses = getSubclasses(psiClass);
|
||||
|
||||
List<HierarchyNodeDescriptor> descriptors = new ArrayList<HierarchyNodeDescriptor>(subclasses.size());
|
||||
final List<HierarchyNodeDescriptor> descriptors = new ArrayList<HierarchyNodeDescriptor>(subclasses.size());
|
||||
for (final PsiClass aClass : subclasses) {
|
||||
if (HierarchyBrowserManager.getInstance(myProject).getState().HIDE_CLASSES_WHERE_METHOD_NOT_IMPLEMENTED) {
|
||||
if (shouldHideClass(aClass)) {
|
||||
@@ -167,6 +171,15 @@ public final class MethodHierarchyTreeStructure extends HierarchyTreeStructure {
|
||||
final MethodHierarchyNodeDescriptor d = new MethodHierarchyNodeDescriptor(myProject, descriptor, aClass, false, this);
|
||||
descriptors.add(d);
|
||||
}
|
||||
|
||||
FunctionalExpressionSearch.search(psiClass).forEach(new Processor<PsiFunctionalExpression>() {
|
||||
@Override
|
||||
public boolean process(PsiFunctionalExpression expression) {
|
||||
descriptors.add(new MethodHierarchyNodeDescriptor(myProject, descriptor, expression, false, MethodHierarchyTreeStructure.this));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
return descriptors.toArray(new HierarchyNodeDescriptor[descriptors.size()]);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,10 @@ abstract class OverrideImplementMethodAction extends AnAction {
|
||||
final ReadonlyStatusHandler.OperationStatus status = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(VfsUtil.toVirtualFileArray(files));
|
||||
if (!status.hasReadonlyFiles()) {
|
||||
for (HierarchyNodeDescriptor selectedDescriptor : selectedDescriptors) {
|
||||
OverrideImplementUtil.overrideOrImplement(((MethodHierarchyNodeDescriptor)selectedDescriptor).getPsiClass(), methodHierarchyBrowser.getBaseMethod());
|
||||
final PsiElement aClass = ((MethodHierarchyNodeDescriptor)selectedDescriptor).getPsiClass();
|
||||
if (aClass instanceof PsiClass) {
|
||||
OverrideImplementUtil.overrideOrImplement((PsiClass)aClass, methodHierarchyBrowser.getBaseMethod());
|
||||
}
|
||||
}
|
||||
ToolWindowManager.getInstance(project).activateEditorComponent();
|
||||
}
|
||||
@@ -146,8 +149,10 @@ abstract class OverrideImplementMethodAction extends AnAction {
|
||||
protected abstract void update(Presentation presentation, int toImplement, int toOverride);
|
||||
|
||||
private static boolean canImplementOverride(final MethodHierarchyNodeDescriptor descriptor, final MethodHierarchyBrowser methodHierarchyBrowser, final boolean toImplement) {
|
||||
final PsiClass psiClass = descriptor.getPsiClass();
|
||||
if (psiClass == null || psiClass instanceof PsiSyntheticClass) return false;
|
||||
final PsiElement psiElement = descriptor.getPsiClass();
|
||||
if (!(psiElement instanceof PsiClass)) return false;
|
||||
final PsiClass psiClass = (PsiClass)psiElement;
|
||||
if (psiClass instanceof PsiSyntheticClass) return false;
|
||||
final PsiMethod baseMethod = methodHierarchyBrowser.getBaseMethod();
|
||||
if (baseMethod == null) return false;
|
||||
final MethodSignature signature = baseMethod.getSignature(PsiSubstitutor.EMPTY);
|
||||
|
||||
@@ -19,12 +19,12 @@ import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.hierarchy.HierarchyNodeDescriptor;
|
||||
import com.intellij.ide.hierarchy.HierarchyTreeStructure;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.psi.PsiAnonymousClass;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiModifier;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.psi.search.searches.ClassInheritorsSearch;
|
||||
import com.intellij.psi.search.searches.FunctionalExpressionSearch;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Processor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -45,17 +45,27 @@ public class SubtypesHierarchyTreeStructure extends HierarchyTreeStructure {
|
||||
|
||||
@NotNull
|
||||
protected final Object[] buildChildren(@NotNull final HierarchyNodeDescriptor descriptor) {
|
||||
final PsiClass psiClass = ((TypeHierarchyNodeDescriptor)descriptor).getPsiClass();
|
||||
final Object element = ((TypeHierarchyNodeDescriptor)descriptor).getPsiClass();
|
||||
if (!(element instanceof PsiClass)) return ArrayUtil.EMPTY_OBJECT_ARRAY;
|
||||
final PsiClass psiClass = (PsiClass)element;
|
||||
if (CommonClassNames.JAVA_LANG_OBJECT.equals(psiClass.getQualifiedName())) {
|
||||
return new Object[]{IdeBundle.message("node.hierarchy.java.lang.object")};
|
||||
}
|
||||
if (psiClass instanceof PsiAnonymousClass) return ArrayUtil.EMPTY_OBJECT_ARRAY;
|
||||
if (psiClass.hasModifierProperty(PsiModifier.FINAL)) return ArrayUtil.EMPTY_OBJECT_ARRAY;
|
||||
final List<PsiClass> classes = new ArrayList<PsiClass>(ClassInheritorsSearch.search(psiClass, psiClass.getUseScope().intersectWith(getSearchScope(myCurrentScopeType, psiClass)), false).findAll());
|
||||
final HierarchyNodeDescriptor[] descriptors = new HierarchyNodeDescriptor[classes.size()];
|
||||
for (int i = 0; i < classes.size(); i++) {
|
||||
descriptors[i] = new TypeHierarchyNodeDescriptor(myProject, descriptor, classes.get(i), false);
|
||||
final SearchScope searchScope = psiClass.getUseScope().intersectWith(getSearchScope(myCurrentScopeType, psiClass));
|
||||
final List<PsiClass> classes = new ArrayList<PsiClass>(ClassInheritorsSearch.search(psiClass, searchScope, false).findAll());
|
||||
final List<HierarchyNodeDescriptor> descriptors = new ArrayList<HierarchyNodeDescriptor>(classes.size());
|
||||
for (PsiClass aClass : classes) {
|
||||
descriptors.add(new TypeHierarchyNodeDescriptor(myProject, descriptor, aClass, false));
|
||||
}
|
||||
return descriptors;
|
||||
FunctionalExpressionSearch.search(psiClass, searchScope).forEach(new Processor<PsiFunctionalExpression>() {
|
||||
@Override
|
||||
public boolean process(PsiFunctionalExpression expression) {
|
||||
descriptors.add(new TypeHierarchyNodeDescriptor(myProject, descriptor, expression, false));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return descriptors.toArray(new HierarchyNodeDescriptor[descriptors.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ package com.intellij.ide.hierarchy.type;
|
||||
import com.intellij.ide.hierarchy.HierarchyNodeDescriptor;
|
||||
import com.intellij.ide.hierarchy.HierarchyTreeStructure;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -34,15 +34,24 @@ public final class SupertypesHierarchyTreeStructure extends HierarchyTreeStructu
|
||||
|
||||
@NotNull
|
||||
protected final Object[] buildChildren(@NotNull final HierarchyNodeDescriptor descriptor) {
|
||||
final PsiClass psiClass = ((TypeHierarchyNodeDescriptor)descriptor).getPsiClass();
|
||||
final PsiClass[] supers = psiClass.getSupers();
|
||||
final List<HierarchyNodeDescriptor> descriptors = new ArrayList<HierarchyNodeDescriptor>();
|
||||
PsiClass objectClass = JavaPsiFacade.getInstance(myProject).findClass(CommonClassNames.JAVA_LANG_OBJECT, psiClass.getResolveScope());
|
||||
for (PsiClass aSuper : supers) {
|
||||
if (!psiClass.isInterface() || !aSuper.equals(objectClass)) {
|
||||
descriptors.add(new TypeHierarchyNodeDescriptor(myProject, descriptor, aSuper, false));
|
||||
final Object element = ((TypeHierarchyNodeDescriptor)descriptor).getPsiClass();
|
||||
if (element instanceof PsiClass) {
|
||||
final PsiClass psiClass = (PsiClass)element;
|
||||
final PsiClass[] supers = psiClass.getSupers();
|
||||
final List<HierarchyNodeDescriptor> descriptors = new ArrayList<HierarchyNodeDescriptor>();
|
||||
final PsiClass objectClass = JavaPsiFacade.getInstance(myProject).findClass(CommonClassNames.JAVA_LANG_OBJECT, psiClass.getResolveScope());
|
||||
for (PsiClass aSuper : supers) {
|
||||
if (!psiClass.isInterface() || !aSuper.equals(objectClass)) {
|
||||
descriptors.add(new TypeHierarchyNodeDescriptor(myProject, descriptor, aSuper, false));
|
||||
}
|
||||
}
|
||||
return descriptors.toArray(new HierarchyNodeDescriptor[descriptors.size()]);
|
||||
} else if (element instanceof PsiFunctionalExpression) {
|
||||
final PsiClass functionalInterfaceClass = PsiUtil.resolveClassInType(((PsiFunctionalExpression)element).getFunctionalInterfaceType());
|
||||
if (functionalInterfaceClass != null) {
|
||||
return new HierarchyNodeDescriptor[] {new TypeHierarchyNodeDescriptor(myProject, descriptor, functionalInterfaceClass, false)};
|
||||
}
|
||||
}
|
||||
return descriptors.toArray(new HierarchyNodeDescriptor[descriptors.size()]);
|
||||
return ArrayUtil.EMPTY_OBJECT_ARRAY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,23 +24,25 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ui.util.CompositeAppearance;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFunctionalExpression;
|
||||
import com.intellij.psi.presentation.java.ClassPresentationUtil;
|
||||
import com.intellij.ui.LayeredIcon;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public final class TypeHierarchyNodeDescriptor extends HierarchyNodeDescriptor {
|
||||
public TypeHierarchyNodeDescriptor(final Project project, final HierarchyNodeDescriptor parentDescriptor, final PsiClass psiClass, final boolean isBase) {
|
||||
super(project, parentDescriptor, psiClass, isBase);
|
||||
public TypeHierarchyNodeDescriptor(final Project project, final HierarchyNodeDescriptor parentDescriptor, final PsiElement classOrFunctionalExpression, final boolean isBase) {
|
||||
super(project, parentDescriptor, classOrFunctionalExpression, isBase);
|
||||
}
|
||||
|
||||
public final PsiClass getPsiClass() {
|
||||
return (PsiClass)myElement;
|
||||
public final PsiElement getPsiClass() {
|
||||
return myElement;
|
||||
}
|
||||
|
||||
public final boolean isValid() {
|
||||
final PsiClass aClass = getPsiClass();
|
||||
return aClass != null && aClass.isValid();
|
||||
final PsiElement psiElement = getPsiClass();
|
||||
return psiElement != null && psiElement.isValid();
|
||||
}
|
||||
|
||||
public final boolean update() {
|
||||
@@ -61,7 +63,7 @@ public final class TypeHierarchyNodeDescriptor extends HierarchyNodeDescriptor {
|
||||
setIcon(icon);
|
||||
}
|
||||
|
||||
final PsiClass psiClass = getPsiClass();
|
||||
final PsiElement psiElement = getPsiClass();
|
||||
|
||||
final CompositeAppearance oldText = myHighlightedText;
|
||||
|
||||
@@ -71,8 +73,12 @@ public final class TypeHierarchyNodeDescriptor extends HierarchyNodeDescriptor {
|
||||
if (myColor != null) {
|
||||
classNameAttributes = new TextAttributes(myColor, null, null, null, Font.PLAIN);
|
||||
}
|
||||
myHighlightedText.getEnding().addText(ClassPresentationUtil.getNameForClass(psiClass, false), classNameAttributes);
|
||||
myHighlightedText.getEnding().addText(" (" + JavaHierarchyUtil.getPackageName(psiClass) + ")", HierarchyNodeDescriptor.getPackageNameAttributes());
|
||||
if (psiElement instanceof PsiClass) {
|
||||
myHighlightedText.getEnding().addText(ClassPresentationUtil.getNameForClass((PsiClass)psiElement, false), classNameAttributes);
|
||||
myHighlightedText.getEnding().addText(" (" + JavaHierarchyUtil.getPackageName((PsiClass)psiElement) + ")", HierarchyNodeDescriptor.getPackageNameAttributes());
|
||||
} else if (psiElement instanceof PsiFunctionalExpression) {
|
||||
myHighlightedText.getEnding().addText(ClassPresentationUtil.getFunctionalExpressionPresentation(((PsiFunctionalExpression)psiElement), false));
|
||||
}
|
||||
myName = myHighlightedText.getText();
|
||||
|
||||
if (!Comparing.equal(myHighlightedText, oldText)) {
|
||||
|
||||
@@ -26,11 +26,14 @@ import com.intellij.ide.util.TreeClassChooserFactory;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFunctionalExpression;
|
||||
import com.intellij.psi.presentation.java.ClassPresentationUtil;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.psi.search.searches.ClassInheritorsSearch;
|
||||
import com.intellij.psi.search.searches.FunctionalExpressionSearch;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.Processor;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.LinkedList;
|
||||
@@ -59,11 +62,19 @@ public class ClassHierarchyScopeDescriptor extends ScopeDescriptor {
|
||||
PsiClass aClass = chooser.getSelected();
|
||||
if (aClass == null) return null;
|
||||
|
||||
List<PsiElement> classesToSearch = new LinkedList<PsiElement>();
|
||||
final List<PsiElement> classesToSearch = new LinkedList<PsiElement>();
|
||||
classesToSearch.add(aClass);
|
||||
|
||||
classesToSearch.addAll(ClassInheritorsSearch.search(aClass, true).findAll());
|
||||
|
||||
FunctionalExpressionSearch.search(aClass).forEach(new Processor<PsiFunctionalExpression>() {
|
||||
@Override
|
||||
public boolean process(PsiFunctionalExpression expression) {
|
||||
classesToSearch.add(expression);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
myCachedScope = new LocalSearchScope(PsiUtilCore.toPsiElementArray(classesToSearch),
|
||||
IdeBundle.message("scope.hierarchy", ClassPresentationUtil.getNameForClass(aClass, true)));
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
import com.intellij.psi.javadoc.PsiDocTag;
|
||||
import com.intellij.psi.search.searches.FunctionalExpressionSearch;
|
||||
import com.intellij.psi.search.searches.OverridingMethodsSearch;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.util.MethodSignatureUtil;
|
||||
@@ -48,6 +49,7 @@ import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
@@ -456,6 +458,8 @@ public class JavaSafeDeleteProcessor extends SafeDeleteProcessorDelegateBase {
|
||||
removeDeletedMethods(OverridingMethodsSearch.search(psiMethod, true).toArray(PsiMethod.EMPTY_ARRAY),
|
||||
allElementsToDelete);
|
||||
|
||||
findFunctionalExpressions(usages, ArrayUtil.prepend(psiMethod, overridingMethods));
|
||||
|
||||
final HashMap<PsiMethod, Collection<PsiReference>> methodToReferences = new HashMap<PsiMethod, Collection<PsiReference>>();
|
||||
for (PsiMethod overridingMethod : overridingMethods) {
|
||||
final Collection<PsiReference> overridingReferences = ReferencesSearch.search(overridingMethod).findAll();
|
||||
@@ -478,6 +482,19 @@ public class JavaSafeDeleteProcessor extends SafeDeleteProcessorDelegateBase {
|
||||
};
|
||||
}
|
||||
|
||||
private static void findFunctionalExpressions(final List<UsageInfo> usages, PsiMethod... methods) {
|
||||
for (PsiMethod method : methods) {
|
||||
final PsiClass containingClass = method.getContainingClass();
|
||||
FunctionalExpressionSearch.search(containingClass).forEach(new Processor<PsiFunctionalExpression>() {
|
||||
@Override
|
||||
public boolean process(PsiFunctionalExpression expression) {
|
||||
usages.add(new SafeDeleteFunctionalExpressionUsageInfo(expression, containingClass));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static PsiMethod[] removeDeletedMethods(PsiMethod[] methods, final PsiElement[] allElementsToDelete) {
|
||||
ArrayList<PsiMethod> list = new ArrayList<PsiMethod>();
|
||||
for (PsiMethod method : methods) {
|
||||
@@ -730,6 +747,8 @@ public class JavaSafeDeleteProcessor extends SafeDeleteProcessorDelegateBase {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
findFunctionalExpressions(usages, method);
|
||||
}
|
||||
|
||||
|
||||
@@ -760,4 +779,13 @@ public class JavaSafeDeleteProcessor extends SafeDeleteProcessorDelegateBase {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class SafeDeleteFunctionalExpressionUsageInfo extends SafeDeleteReferenceUsageInfo {
|
||||
public SafeDeleteFunctionalExpressionUsageInfo(@NotNull PsiElement element, PsiElement referencedElement) {
|
||||
super(element, referencedElement, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteElement() throws IncorrectOperationException {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.infos.MethodCandidateInfo;
|
||||
import com.intellij.psi.util.*;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -35,7 +34,6 @@ import java.util.*;
|
||||
public class LambdaUtil {
|
||||
public static ThreadLocal<Map<PsiElement, PsiType>> ourFunctionTypes = new ThreadLocal<Map<PsiElement, PsiType>>();
|
||||
private static final Logger LOG = Logger.getInstance("#" + LambdaUtil.class.getName());
|
||||
@NonNls public static final String JAVA_LANG_FUNCTIONAL_INTERFACE = "java.lang.FunctionalInterface";
|
||||
|
||||
@Nullable
|
||||
public static PsiType getFunctionalInterfaceReturnType(PsiLambdaExpression expr) {
|
||||
@@ -434,7 +432,7 @@ public class LambdaUtil {
|
||||
|
||||
@Nullable
|
||||
public static String checkFunctionalInterface(@NotNull PsiAnnotation annotation, @NotNull LanguageLevel languageLevel) {
|
||||
if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8) && Comparing.strEqual(annotation.getQualifiedName(), JAVA_LANG_FUNCTIONAL_INTERFACE)) {
|
||||
if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8) && Comparing.strEqual(annotation.getQualifiedName(), CommonClassNames.JAVA_LANG_FUNCTIONAL_INTERFACE)) {
|
||||
final PsiAnnotationOwner owner = annotation.getOwner();
|
||||
if (owner instanceof PsiModifierList) {
|
||||
final PsiElement parent = ((PsiModifierList)owner).getParent();
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface PsiFunctionalExpression extends PsiExpression {
|
||||
public interface PsiFunctionalExpression extends PsiExpression, Iconable {
|
||||
/**
|
||||
* @return SAM type the lambda expression corresponds to
|
||||
* null when no SAM type could be found
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.source.tree.java;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
@@ -33,6 +34,8 @@ import com.intellij.util.containers.IntArrayList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements PsiLambdaExpression {
|
||||
|
||||
public PsiLambdaExpressionImpl() {
|
||||
@@ -218,4 +221,10 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
|
||||
}
|
||||
return paramType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Icon getIcon(int flags) {
|
||||
return AllIcons.Nodes.AnonymousClass;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.source.tree.java;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
@@ -41,6 +42,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Map;
|
||||
|
||||
public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase implements PsiMethodReferenceExpression {
|
||||
@@ -469,4 +471,10 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Icon getIcon(int flags) {
|
||||
return AllIcons.Nodes.AnonymousClass;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ClassPresentationUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static String getContextName(@NotNull PsiElement element, boolean qualified) {
|
||||
public static String getContextName(@NotNull PsiElement element, boolean qualified) {
|
||||
PsiElement parent = PsiTreeUtil.getParentOfType(element, PsiMember.class, PsiFile.class);
|
||||
while(true){
|
||||
if (parent == null) return null;
|
||||
@@ -72,4 +72,8 @@ public class ClassPresentationUtil {
|
||||
parent = parent.getParent();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getFunctionalExpressionPresentation(PsiFunctionalExpression functionalExpression, boolean qualified) {
|
||||
return "Functional expression in " + getContextName(functionalExpression, qualified);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
interface SAM {
|
||||
void fo<caret>o(int i);
|
||||
}
|
||||
|
||||
class Test {
|
||||
|
||||
{
|
||||
SAM sam = (i) -> {};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
interface SAM {
|
||||
void foo(int <caret>i);
|
||||
}
|
||||
|
||||
class Test {
|
||||
|
||||
{
|
||||
SAM sam = (i) -> {};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -134,6 +134,30 @@ public class SafeDeleteTest extends MultiFileTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testParameterFromFunctionalInterface() throws Exception {
|
||||
try {
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_8);
|
||||
doSingleFileTest();
|
||||
fail("Conflict was not detected");
|
||||
}
|
||||
catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
|
||||
String message = e.getMessage();
|
||||
assertEquals("class <b><code>SAM</code></b> has 1 usage that is not safe to delete.", message);
|
||||
}
|
||||
}
|
||||
|
||||
public void testFunctionalInterfaceMethod() throws Exception {
|
||||
try {
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_8);
|
||||
doSingleFileTest();
|
||||
fail("Conflict was not detected");
|
||||
}
|
||||
catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
|
||||
String message = e.getMessage();
|
||||
assertEquals("class <b><code>SAM</code></b> has 1 usage that is not safe to delete.", message);
|
||||
}
|
||||
}
|
||||
|
||||
public void testMethodDeepHierarchy() throws Exception {
|
||||
doTest("Super");
|
||||
}
|
||||
|
||||
@@ -100,4 +100,5 @@ public interface CommonClassNames {
|
||||
@NonNls String JAVA_LANG_INVOKE_MH_POLYMORPHIC = "java.lang.invoke.MethodHandle.PolymorphicSignature";
|
||||
|
||||
@NonNls String CLASS_FILE_EXTENSION = ".class";
|
||||
@NonNls String JAVA_LANG_FUNCTIONAL_INTERFACE = "java.lang.FunctionalInterface";
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 647 B |
|
After Width: | Height: | Size: 4.6 KiB |
@@ -23,7 +23,6 @@ import com.intellij.openapi.components.AbstractProjectComponent;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModuleRootAdapter;
|
||||
import com.intellij.openapi.roots.ModuleRootEvent;
|
||||
import com.intellij.openapi.roots.impl.DirectoryIndex;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.problems.WolfTheProblemSolver;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
@@ -47,7 +46,7 @@ public class VcsEventWatcher extends AbstractProjectComponent {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (myProject.isDisposed() || !DirectoryIndex.getInstance(myProject).isInitialized()) return;
|
||||
if (myProject.isDisposed()) return;
|
||||
VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
|
||||
}
|
||||
}, ModalityState.NON_MODAL);
|
||||
|
||||
@@ -67,7 +67,7 @@ public class CodeAnalysisBeforeCheckinHandler extends CheckinHandler {
|
||||
public JComponent getComponent() {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.add(checkBox);
|
||||
refreshEnable(checkBox);
|
||||
TodoCheckinHandler.disableWhenDumb(myProject, checkBox, "Code analysis is impossible until indices are up-to-date");
|
||||
return panel;
|
||||
}
|
||||
|
||||
@@ -87,16 +87,6 @@ public class CodeAnalysisBeforeCheckinHandler extends CheckinHandler {
|
||||
};
|
||||
}
|
||||
|
||||
private void refreshEnable(JCheckBox checkBox) {
|
||||
if (DumbService.getInstance(myProject).isDumb()) {
|
||||
checkBox.setEnabled(false);
|
||||
checkBox.setToolTipText("Code analysis is impossible until indices are up-to-date");
|
||||
} else {
|
||||
checkBox.setEnabled(true);
|
||||
checkBox.setToolTipText("");
|
||||
}
|
||||
}
|
||||
|
||||
private VcsConfiguration getSettings() {
|
||||
return VcsConfiguration.getInstance(myProject);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.intellij.openapi.vcs.checkin;
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.actions.OptimizeImportsProcessor;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.CheckinProjectPanel;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
@@ -47,7 +48,7 @@ public class OptimizeImportsBeforeCheckinHandler extends CheckinHandler implemen
|
||||
@Nullable
|
||||
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
|
||||
final JCheckBox optimizeBox = new JCheckBox(VcsBundle.message("checkbox.checkin.options.optimize.imports"));
|
||||
|
||||
TodoCheckinHandler.disableWhenDumb(myProject, optimizeBox, "Impossible until indices are up-to-date");
|
||||
return new RefreshableOnComponent() {
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
@@ -90,7 +91,7 @@ public class OptimizeImportsBeforeCheckinHandler extends CheckinHandler implemen
|
||||
}
|
||||
};
|
||||
|
||||
if (configuration.OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT) {
|
||||
if (configuration.OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT && !DumbService.isDumb(myProject)) {
|
||||
new OptimizeImportsProcessor(myProject, BeforeCheckinHandlerUtil.getPsiFiles(myProject, files), COMMAND_NAME, performCheckoutAction).run();
|
||||
} else {
|
||||
finishAction.run();
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.openapi.vcs.checkin;
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.actions.RearrangeCodeProcessor;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.CheckinProjectPanel;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
@@ -44,7 +45,7 @@ public class RearrangeBeforeCheckinHandler extends CheckinHandler implements Che
|
||||
@Nullable
|
||||
public RefreshableOnComponent getBeforeCheckinConfigurationPanel() {
|
||||
final JCheckBox rearrangeBox = new JCheckBox(VcsBundle.message("checkbox.checkin.options.rearrange.code"));
|
||||
|
||||
TodoCheckinHandler.disableWhenDumb(myProject, rearrangeBox, "Impossible until indices are up-to-date");
|
||||
return new RefreshableOnComponent() {
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
@@ -83,7 +84,7 @@ public class RearrangeBeforeCheckinHandler extends CheckinHandler implements Che
|
||||
}
|
||||
};
|
||||
|
||||
if (VcsConfiguration.getInstance(myProject).REARRANGE_BEFORE_PROJECT_COMMIT) {
|
||||
if (VcsConfiguration.getInstance(myProject).REARRANGE_BEFORE_PROJECT_COMMIT && !DumbService.isDumb(myProject)) {
|
||||
new RearrangeCodeProcessor(
|
||||
myProject, BeforeCheckinHandlerUtil.getPsiFiles(myProject, myPanel.getVirtualFiles()), COMMAND_NAME, performCheckoutAction
|
||||
).run();
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -47,6 +46,7 @@ import com.intellij.util.Consumer;
|
||||
import com.intellij.util.PairConsumer;
|
||||
import com.intellij.util.text.DateFormatUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -64,7 +64,6 @@ public class TodoCheckinHandler extends CheckinHandler {
|
||||
private final CheckinProjectPanel myCheckinProjectPanel;
|
||||
private final VcsConfiguration myConfiguration;
|
||||
private TodoFilter myTodoFilter;
|
||||
private final static Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.checkin.TodoCheckinHandler");
|
||||
|
||||
public TodoCheckinHandler(CheckinProjectPanel checkinProjectPanel) {
|
||||
myProject = checkinProjectPanel.getProject();
|
||||
@@ -105,7 +104,7 @@ public class TodoCheckinHandler extends CheckinHandler {
|
||||
}, null);
|
||||
panel.add(linkLabel, BorderLayout.CENTER);
|
||||
|
||||
refreshEnable(checkBox);
|
||||
disableWhenDumb(myProject, checkBox, "TODO check is impossible until indices are up-to-date");
|
||||
return panel;
|
||||
}
|
||||
|
||||
@@ -133,14 +132,10 @@ public class TodoCheckinHandler extends CheckinHandler {
|
||||
};
|
||||
}
|
||||
|
||||
private void refreshEnable(JCheckBox checkBox) {
|
||||
if (DumbService.getInstance(myProject).isDumb()) {
|
||||
checkBox.setEnabled(false);
|
||||
checkBox.setToolTipText("TODO check is impossible until indices are up-to-date");
|
||||
} else {
|
||||
checkBox.setEnabled(true);
|
||||
checkBox.setToolTipText("");
|
||||
}
|
||||
static void disableWhenDumb(@NotNull Project project, @NotNull JCheckBox checkBox, @NotNull String tooltip) {
|
||||
boolean dumb = DumbService.isDumb(project);
|
||||
checkBox.setEnabled(!dumb);
|
||||
checkBox.setToolTipText(dumb ? tooltip : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,7 +27,10 @@ import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.ui.StripeTable;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.components.JBScrollPane;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.ui.ColorIcon;
|
||||
import com.intellij.util.ui.PlatformColors;
|
||||
@@ -166,7 +169,7 @@ public class UiInspectorAction extends ToggleAction implements DumbAware {
|
||||
splitPane.setDividerLocation(0.5);
|
||||
splitPane.setRightComponent(myWrapperPanel);
|
||||
|
||||
JScrollPane pane = new JScrollPane(myHierarchyTree);
|
||||
JScrollPane pane = new JBScrollPane(myHierarchyTree);
|
||||
splitPane.setLeftComponent(pane);
|
||||
add(splitPane, BorderLayout.CENTER);
|
||||
|
||||
@@ -225,7 +228,7 @@ public class UiInspectorAction extends ToggleAction implements DumbAware {
|
||||
glassPane.repaint();
|
||||
}
|
||||
} else {
|
||||
myHighlightComponent = new HighlightComponent(Color.GREEN);
|
||||
myHighlightComponent = new HighlightComponent(JBColor.GREEN);
|
||||
|
||||
final Point pt = SwingUtilities.convertPoint(c, new Point(0, 0), rootPane);
|
||||
myHighlightComponent.setBounds(pt.x, pt.y, c.getWidth(), c.getHeight());
|
||||
@@ -270,18 +273,20 @@ public class UiInspectorAction extends ToggleAction implements DumbAware {
|
||||
name = component.getClass().getSuperclass().getSimpleName();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!selected) {
|
||||
if (!component.isVisible()) {
|
||||
foreground = Color.GRAY;
|
||||
} else if (component.getWidth() == 0 || component.getHeight() == 0) {
|
||||
foreground = JBColor.GRAY;
|
||||
}
|
||||
else if (component.getWidth() == 0 || component.getHeight() == 0) {
|
||||
foreground = new Color(128, 10, 0);
|
||||
} else if (component.getPreferredSize() != null &&
|
||||
(component.getSize().width < component.getPreferredSize().width
|
||||
|| component.getSize().height < component.getPreferredSize().height)) {
|
||||
}
|
||||
else if (component.getPreferredSize() != null &&
|
||||
(component.getSize().width < component.getPreferredSize().width
|
||||
|| component.getSize().height < component.getPreferredSize().height)) {
|
||||
foreground = PlatformColors.BLUE;
|
||||
}
|
||||
|
||||
|
||||
if (componentNode.getToSelect() == componentNode.getOwnComponent()) {
|
||||
background = new Color(31, 128, 8, 58);
|
||||
}
|
||||
@@ -467,7 +472,7 @@ public class UiInspectorAction extends ToggleAction implements DumbAware {
|
||||
private DimensionsComponent(@NotNull final Component component) {
|
||||
myComponent = component;
|
||||
setOpaque(true);
|
||||
setBackground(Color.WHITE);
|
||||
setBackground(JBColor.WHITE);
|
||||
setBorder(new EmptyBorder(5, 0, 5, 0));
|
||||
|
||||
setFont(new JLabel().getFont().deriveFont(Font.PLAIN, 9));
|
||||
@@ -503,7 +508,7 @@ public class UiInspectorAction extends ToggleAction implements DumbAware {
|
||||
|
||||
g2d.drawString(sizeString, bounds.width / 2 - sizeWidth / 2, bounds.height / 2 + fontHeight / 2);
|
||||
|
||||
g2d.setColor(Color.GRAY);
|
||||
g2d.setColor(JBColor.GRAY);
|
||||
|
||||
int innerX = bounds.width / 2 - sizeWidth / 2 - 20;
|
||||
int innerY = bounds.height / 2 - fontHeight / 2 - 5;
|
||||
@@ -522,10 +527,10 @@ public class UiInspectorAction extends ToggleAction implements DumbAware {
|
||||
}
|
||||
|
||||
private static void drawInsets(Graphics2D g2d, FontMetrics fm, String name, Insets insets, int offset, int fontHeight, int innerX, int innerY, int innerWidth, int innerHeight) {
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.setColor(JBColor.BLACK);
|
||||
g2d.drawString(name, innerX - offset + 5, innerY - offset + fontHeight);
|
||||
|
||||
g2d.setColor(Color.GRAY);
|
||||
g2d.setColor(JBColor.GRAY);
|
||||
int dashWidth = fm.stringWidth("-");
|
||||
|
||||
if (insets != null) {
|
||||
@@ -558,7 +563,7 @@ public class UiInspectorAction extends ToggleAction implements DumbAware {
|
||||
}
|
||||
|
||||
private static class ValueCellRenderer implements TableCellRenderer {
|
||||
private static final Map<Class, Renderer> RENDERERS = new HashMap<Class, Renderer>();
|
||||
private static final Map<Class, Renderer> RENDERERS = ContainerUtil.newHashMap();
|
||||
|
||||
static {
|
||||
RENDERERS.put(Point.class, new PointRenderer());
|
||||
@@ -571,45 +576,45 @@ public class UiInspectorAction extends ToggleAction implements DumbAware {
|
||||
RENDERERS.put(Icon.class, new IconRenderer());
|
||||
}
|
||||
|
||||
private static final Renderer DEFAULT_RENDERER = new ObjectRenderer();
|
||||
private static final Renderer<Object> DEFAULT_RENDERER = new ObjectRenderer();
|
||||
|
||||
private static final JLabel NULL_RENDERER = new JLabel("-");
|
||||
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
if (value == null) {
|
||||
NULL_RENDERER.setOpaque(false);
|
||||
NULL_RENDERER.setOpaque(isSelected);
|
||||
NULL_RENDERER.setForeground(isSelected ? table.getSelectionForeground() : table.getForeground());
|
||||
NULL_RENDERER.setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());
|
||||
return NULL_RENDERER;
|
||||
}
|
||||
|
||||
Renderer renderer = getRenderer(value.getClass());
|
||||
if (renderer == null)
|
||||
renderer = DEFAULT_RENDERER;
|
||||
Renderer<Object> renderer = ObjectUtils.notNull(getRenderer(value.getClass()), DEFAULT_RENDERER);
|
||||
|
||||
JComponent result = renderer.setValue(value);
|
||||
result.setOpaque(false);
|
||||
result.setOpaque(isSelected);
|
||||
result.setForeground(isSelected ? table.getSelectionForeground() : table.getForeground());
|
||||
result.setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Renderer getRenderer(Class clazz) {
|
||||
if (clazz == null)
|
||||
return null;
|
||||
Renderer renderer = RENDERERS.get(clazz);
|
||||
if (renderer != null)
|
||||
return renderer;
|
||||
private static Renderer<Object> getRenderer(Class clazz) {
|
||||
if (clazz == null) return null;
|
||||
|
||||
Renderer<Object> renderer = (Renderer<Object>)RENDERERS.get(clazz);
|
||||
if (renderer != null) return renderer;
|
||||
|
||||
Class[] interfaces = clazz.getInterfaces();
|
||||
for (Class aClass : interfaces) {
|
||||
renderer = getRenderer(aClass);
|
||||
if (renderer != null)
|
||||
if (renderer != null) {
|
||||
return renderer;
|
||||
}
|
||||
}
|
||||
clazz = clazz.getSuperclass();
|
||||
if (clazz != null)
|
||||
if (clazz != null) {
|
||||
return getRenderer(clazz);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -676,8 +681,11 @@ public class UiInspectorAction extends ToggleAction implements DumbAware {
|
||||
}
|
||||
|
||||
private static class ObjectRenderer extends JLabel implements Renderer<Object> {
|
||||
{
|
||||
putClientProperty("html.disable", Boolean.TRUE);
|
||||
}
|
||||
public JComponent setValue(@NotNull final Object value) {
|
||||
setText(value.toString());
|
||||
setText(String.valueOf(value).replace('\n', ' '));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -697,10 +705,15 @@ public class UiInspectorAction extends ToggleAction implements DumbAware {
|
||||
private static class InspectorTableModel extends AbstractTableModel {
|
||||
|
||||
private static final String[] JCOMPONENT_METHODS = new String[] {
|
||||
"getLocation", "getLocationOnScreen", "getMinimumSize", "getMaximumSize", "getPreferredSize", "getSize",
|
||||
"getAlignmentX", "getAlignmentY", "getTooltipText", "getVisibleRect", "getLayout",
|
||||
"getForeground", "getBackground", "getFont", "isOpaque", "isFocusCycleRoot", "isValid", "isDisplayable",
|
||||
"isShowing", "isEnabled", "isLightweight", "isFocusable", "isFocusOwner", "getToolTipText", "getText", "isEditable", "getIcon"
|
||||
"getLocation", "getLocationOnScreen",
|
||||
"getSize", "isOpaque", "getBorder",
|
||||
"getForeground", "getBackground", "getFont",
|
||||
"getMinimumSize", "getMaximumSize", "getPreferredSize",
|
||||
"getAlignmentX", "getAlignmentY",
|
||||
"getText", "isEditable", "getIcon",
|
||||
"getTooltipText", "getToolTipText",
|
||||
"getVisibleRect", "getLayout",
|
||||
"isFocusCycleRoot", "isValid", "isDisplayable", "isShowing", "isEnabled", "isLightweight", "isFocusable", "isFocusOwner"
|
||||
};
|
||||
|
||||
private Component myComponent;
|
||||
|
||||
@@ -283,7 +283,7 @@ public class DumbServiceImpl extends DumbService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showDumbModeNotification(final String message) {
|
||||
public void showDumbModeNotification(@NotNull final String message) {
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -341,14 +341,9 @@ public class DumbServiceImpl extends DumbService {
|
||||
|
||||
private class IndexUpdateRunnable implements Runnable {
|
||||
private final CacheUpdateRunner myAction;
|
||||
private double myProcessedItems;
|
||||
private volatile int myTotalItems;
|
||||
private double myCurrentBaseTotal;
|
||||
|
||||
public IndexUpdateRunnable(@NotNull CacheUpdateRunner action) {
|
||||
myAction = action;
|
||||
myTotalItems = 0;
|
||||
myCurrentBaseTotal = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -389,12 +384,7 @@ public class DumbServiceImpl extends DumbService {
|
||||
});
|
||||
}
|
||||
|
||||
final ProgressIndicator proxy = new DelegatingProgressIndicator(indicator) {
|
||||
@Override
|
||||
public void setFraction(double fraction) {
|
||||
super.setFraction((myProcessedItems + fraction * myCurrentBaseTotal) / myTotalItems);
|
||||
}
|
||||
};
|
||||
final ProgressIndicator proxy = new DelegatingProgressIndicator(indicator);
|
||||
|
||||
final ShutDownTracker shutdownTracker = ShutDownTracker.getInstance();
|
||||
final Thread self = Thread.currentThread();
|
||||
@@ -421,16 +411,12 @@ public class DumbServiceImpl extends DumbService {
|
||||
indicator.setText(IdeBundle.message("progress.indexing.scanning"));
|
||||
int count = updateRunner.queryNeededFiles(indicator);
|
||||
|
||||
myCurrentBaseTotal = count;
|
||||
myTotalItems += count;
|
||||
|
||||
indicator.setIndeterminate(false);
|
||||
indicator.setText(IdeBundle.message("progress.indexing.updating"));
|
||||
if (count > 0) {
|
||||
updateRunner.processFiles(indicator, true);
|
||||
}
|
||||
updateRunner.updatingDone();
|
||||
myProcessedItems += count;
|
||||
}
|
||||
catch (ProcessCanceledException ignored) {
|
||||
}
|
||||
|
||||
@@ -152,9 +152,7 @@ public class JarFileSystemImpl extends JarFileSystem implements ApplicationCompo
|
||||
|
||||
@Override
|
||||
public JarFile getJarFile(@NotNull VirtualFile entryVFile) throws IOException {
|
||||
JarHandler handler = getHandler(entryVFile);
|
||||
|
||||
return handler.getJar();
|
||||
return getHandler(entryVFile).getJar();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -160,9 +160,9 @@ public class Splash extends JDialog implements StartupProgress {
|
||||
g.setColor(textColor);
|
||||
final String licensedToMessage = provider.getLicensedToMessage();
|
||||
final List<String> licenseRestrictionsMessages = provider.getLicenseRestrictionsMessages();
|
||||
g.drawString(licensedToMessage, x + 21, y + height - 49);
|
||||
g.drawString(licensedToMessage, x + 15, y + height - 30);
|
||||
if (licenseRestrictionsMessages.size() > 0) {
|
||||
g.drawString(licenseRestrictionsMessages.get(0), x + 21, y + height - 33);
|
||||
g.drawString(licenseRestrictionsMessages.get(0), x + 15, y + height - 14);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -275,11 +275,6 @@ dump.threads.on.empty.lookup.description=Whether IDEA should issue a thread dump
|
||||
|
||||
file.structure.tree.mode=true
|
||||
|
||||
directory.index.use.root.index=true
|
||||
directory.index.use.root.index.description=Requires restart
|
||||
directory.index.compare.implementations=false
|
||||
directory.index.compare.implementations.description=Will make the IDE slow. Requires restart
|
||||
|
||||
disable.toolwindow.overlay=true
|
||||
# suppress inspection "UnusedProperty"
|
||||
disable.toolwindow.overlay.description=Disable transparent toolwindow stripes.
|
||||
@@ -382,4 +377,4 @@ editor.injected.highlighting.enabled.description=Disables injected fragments hig
|
||||
|
||||
run.processes.with.pty=false
|
||||
|
||||
ide.certificate.manager=true
|
||||
ide.certificate.manager=true
|
||||
|
||||
@@ -49,5 +49,9 @@ public abstract class DirectoryIndex {
|
||||
@Nullable
|
||||
public abstract String getPackageName(@NotNull VirtualFile dir);
|
||||
|
||||
/**
|
||||
* @return true
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract boolean isInitialized();
|
||||
}
|
||||
|
||||
@@ -22,8 +22,6 @@ import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.RootPolicy;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ArrayFactory;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.BitUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -192,7 +190,7 @@ public class DirectoryInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(OrderEntry o) {
|
||||
public int compareTo(@NotNull OrderEntry o) {
|
||||
throw new IncorrectOperationException();
|
||||
}
|
||||
|
||||
@@ -203,55 +201,6 @@ public class DirectoryInfo {
|
||||
};
|
||||
}
|
||||
|
||||
// orderEntries must be sorted BY_OWNER_MODULE
|
||||
OrderEntry[] calcNewOrderEntries(@NotNull OrderEntry[] orderEntries, @Nullable DirectoryInfo parentInfo, @Nullable OrderEntry[] oldParentEntries) {
|
||||
OrderEntry[] newOrderEntries;
|
||||
if (orderEntries.length == 0) {
|
||||
newOrderEntries = null;
|
||||
}
|
||||
else if (this.orderEntries == null) {
|
||||
newOrderEntries = orderEntries;
|
||||
}
|
||||
else if (parentInfo != null && oldParentEntries == this.orderEntries) {
|
||||
newOrderEntries = parentInfo.orderEntries;
|
||||
}
|
||||
else {
|
||||
newOrderEntries = mergeWith(orderEntries);
|
||||
}
|
||||
return newOrderEntries;
|
||||
}
|
||||
|
||||
// entries must be sorted BY_OWNER_MODULE
|
||||
@NotNull
|
||||
private OrderEntry[] mergeWith(@NotNull OrderEntry[] entries) {
|
||||
OrderEntry[] orderEntries = this.orderEntries;
|
||||
OrderEntry[] result = new OrderEntry[orderEntries.length + entries.length];
|
||||
int i=0;
|
||||
int j=0;
|
||||
// remove equals entries in the process
|
||||
int o = 0;
|
||||
while (i != orderEntries.length || j != entries.length) {
|
||||
OrderEntry m = i != orderEntries.length && (j == entries.length || BY_OWNER_MODULE.compare(orderEntries[i], entries[j]) < 0)
|
||||
? orderEntries[i++]
|
||||
: entries[j++];
|
||||
if (o==0 || !m.equals(result[o - 1])) {
|
||||
result[o++] = m;
|
||||
}
|
||||
}
|
||||
if (o != result.length) {
|
||||
result = ArrayUtil.realloc(result, o, ORDER_ENTRY_ARRAY_FACTORY);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static final ArrayFactory<OrderEntry> ORDER_ENTRY_ARRAY_FACTORY = new ArrayFactory<OrderEntry>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public OrderEntry[] create(int count) {
|
||||
return count == 0 ? OrderEntry.EMPTY_ARRAY : new OrderEntry[count];
|
||||
}
|
||||
};
|
||||
|
||||
public static final Comparator<OrderEntry> BY_OWNER_MODULE = new Comparator<OrderEntry>() {
|
||||
@Override
|
||||
public int compare(OrderEntry o1, OrderEntry o2) {
|
||||
@@ -291,27 +240,6 @@ public class DirectoryInfo {
|
||||
return module;
|
||||
}
|
||||
|
||||
private static <T> T iff(T value, T defaultValue) {
|
||||
return value == null ? defaultValue : value;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public DirectoryInfo with(Module module,
|
||||
VirtualFile contentRoot,
|
||||
VirtualFile sourceRoot,
|
||||
VirtualFile libraryClassRoot,
|
||||
int sourceRootTypeData,
|
||||
OrderEntry[] orderEntries) {
|
||||
return new DirectoryInfo(iff(module, this.module), iff(contentRoot, this.contentRoot), iff(sourceRoot, this.sourceRoot),
|
||||
iff(libraryClassRoot, this.libraryClassRoot), sourceRootTypeData == 0 ? this.sourceRootTypeData : (byte)sourceRootTypeData,
|
||||
iff(orderEntries, this.orderEntries));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public DirectoryInfo withInternedEntries(@NotNull OrderEntry[] orderEntries) {
|
||||
return new DirectoryInfo(module, contentRoot, sourceRoot, libraryClassRoot, sourceRootTypeData, orderEntries);
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
void assertConsistency() {
|
||||
OrderEntry[] entries = getOrderEntries();
|
||||
|
||||
@@ -560,8 +560,6 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
|
||||
if (manager instanceof FileDocumentManagerImpl) {
|
||||
((FileDocumentManagerImpl)manager).dropAllUnsavedDocuments();
|
||||
}
|
||||
|
||||
((DirectoryIndexImpl)DirectoryIndex.getInstance(project)).assertAncestorConsistent();
|
||||
}
|
||||
}.execute().throwException();
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.intellij.testFramework.fixtures;
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionType;
|
||||
import com.intellij.codeInsight.daemon.GutterMark;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInsight.lookup.Lookup;
|
||||
@@ -32,7 +33,6 @@ import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.codeInsight.daemon.GutterMark;
|
||||
import com.intellij.openapi.editor.markup.RangeHighlighter;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -53,11 +53,9 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @see IdeaTestFixtureFactory#createCodeInsightFixture(IdeaProjectTestFixture)
|
||||
* @link http://confluence.jetbrains.net/display/IDEADEV/Testing+IntelliJ+IDEA+Plugins
|
||||
*
|
||||
* @author Dmitry Avdeev
|
||||
* @link http://confluence.jetbrains.net/display/IDEADEV/Testing+IntelliJ+IDEA+Plugins
|
||||
* @see IdeaTestFixtureFactory#createCodeInsightFixture(IdeaProjectTestFixture)
|
||||
*/
|
||||
public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
|
||||
|
||||
@@ -104,7 +102,7 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
|
||||
* Copies a file from the testdata directory to the specified path in the test project directory.
|
||||
*
|
||||
* @param sourceFilePath path to the source file, relative to the testdata path.
|
||||
* @param targetPath path to the destination, relative to the source root of the test project.
|
||||
* @param targetPath path to the destination, relative to the source root of the test project.
|
||||
* @return the VirtualFile for the copied file in the test project directory.
|
||||
*/
|
||||
VirtualFile copyFileToProject(@TestDataFile @NonNls String sourceFilePath, @NonNls String targetPath);
|
||||
@@ -113,7 +111,7 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
|
||||
* Copies a directory from the testdata directory to the specified path in the test project directory.
|
||||
*
|
||||
* @param sourceFilePath path to the source directory, relative to the testdata path.
|
||||
* @param targetPath path to the destination, relative to the source root of the test project.
|
||||
* @param targetPath path to the destination, relative to the source root of the test project.
|
||||
* @return the VirtualFile for the copied directory in the test project directory.
|
||||
*/
|
||||
VirtualFile copyDirectoryToProject(@NonNls String sourceFilePath, @NonNls String targetPath);
|
||||
@@ -148,7 +146,7 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
|
||||
* editor.
|
||||
*
|
||||
* @param fileType the file type according to which which the text is interpreted.
|
||||
* @param text the text to load into the in-memory editor.
|
||||
* @param text the text to load into the in-memory editor.
|
||||
* @return the PSI file created from the specified text.
|
||||
*/
|
||||
PsiFile configureByText(FileType fileType, @NonNls String text);
|
||||
@@ -158,7 +156,7 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
|
||||
* editor.
|
||||
*
|
||||
* @param fileName the name of the file (which is used to determine the file type based on the registered filename patterns).
|
||||
* @param text the text to load into the in-memory editor.
|
||||
* @param text the text to load into the in-memory editor.
|
||||
* @return the PSI file created from the specified text.
|
||||
*/
|
||||
PsiFile configureByText(String fileName, @NonNls String text);
|
||||
@@ -182,8 +180,7 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
|
||||
* Creates a file with the specified path and contents in the test project directory.
|
||||
*
|
||||
* @param relativePath the path for the file to create, relative to the test project source root.
|
||||
* @param fileText the text to put into the created file.
|
||||
*
|
||||
* @param fileText the text to put into the created file.
|
||||
* @return the PSI file for the created file.
|
||||
*/
|
||||
PsiFile addFileToProject(@NonNls String relativePath, @NonNls String fileText);
|
||||
@@ -199,7 +196,7 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
|
||||
/**
|
||||
* Compares the contents of the in-memory editor with the specified file, optionally ignoring trailing whitespaces.
|
||||
*
|
||||
* @param expectedFile path to file to check against, relative to the testdata path.
|
||||
* @param expectedFile path to file to check against, relative to the testdata path.
|
||||
* @param ignoreTrailingWhitespaces whether trailing whitespaces should be ignored by the comparison.
|
||||
*/
|
||||
void checkResultByFile(@TestDataFile @NonNls String expectedFile, boolean ignoreTrailingWhitespaces);
|
||||
@@ -207,11 +204,13 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
|
||||
/**
|
||||
* Compares a file in the test project with a file in the testdata directory.
|
||||
*
|
||||
* @param filePath path to file to be checked, relative to the source root of the test project.
|
||||
* @param expectedFile path to file to check against, relative to the testdata path.
|
||||
* @param filePath path to file to be checked, relative to the source root of the test project.
|
||||
* @param expectedFile path to file to check against, relative to the testdata path.
|
||||
* @param ignoreTrailingWhitespaces whether trailing whitespaces should be ignored by the comparison.
|
||||
*/
|
||||
void checkResultByFile(@NonNls String filePath, @TestDataFile @NonNls String expectedFile, boolean ignoreTrailingWhitespaces);
|
||||
void checkResultByFile(@TestDataFile @NonNls String filePath,
|
||||
@TestDataFile @NonNls String expectedFile,
|
||||
boolean ignoreTrailingWhitespaces);
|
||||
|
||||
/**
|
||||
* Enables inspections for highlighting tests.
|
||||
@@ -240,21 +239,27 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
|
||||
* Runs highlighting test for the given files.
|
||||
* Checks for {@link #ERROR_MARKER} markers by default.
|
||||
*
|
||||
* @param checkWarnings enables {@link #WARNING_MARKER} support.
|
||||
* @param checkInfos enables {@link #INFO_MARKER} support.
|
||||
* @param checkWarnings enables {@link #WARNING_MARKER} support.
|
||||
* @param checkInfos enables {@link #INFO_MARKER} support.
|
||||
* @param checkWeakWarnings enables {@link #INFORMATION_MARKER} support.
|
||||
* @param filePaths the first file is tested only; the others are just copied along the first.
|
||||
*
|
||||
* @param filePaths the first file is tested only; the others are just copied along the first.
|
||||
* @return highlighting duration in milliseconds.
|
||||
*/
|
||||
long testHighlighting(boolean checkWarnings, boolean checkInfos, boolean checkWeakWarnings, @TestDataFile @NonNls String... filePaths);
|
||||
|
||||
long testHighlightingAllFiles(boolean checkWarnings, boolean checkInfos, boolean checkWeakWarnings, @TestDataFile @NonNls String... filePaths);
|
||||
long testHighlightingAllFiles(boolean checkWarnings,
|
||||
boolean checkInfos,
|
||||
boolean checkWeakWarnings,
|
||||
@TestDataFile @NonNls String... filePaths);
|
||||
|
||||
long testHighlightingAllFiles(boolean checkWarnings, boolean checkInfos, boolean checkWeakWarnings, @TestDataFile @NonNls VirtualFile... files);
|
||||
long testHighlightingAllFiles(boolean checkWarnings,
|
||||
boolean checkInfos,
|
||||
boolean checkWeakWarnings,
|
||||
@TestDataFile @NonNls VirtualFile... files);
|
||||
|
||||
/**
|
||||
* Check highlighting of file already loaded by configure* methods
|
||||
*
|
||||
* @return duration
|
||||
*/
|
||||
long checkHighlighting(boolean checkWarnings, boolean checkInfos, boolean checkWeakWarnings);
|
||||
@@ -266,12 +271,12 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
|
||||
* The same as {@link #testHighlighting(boolean, boolean, boolean, String...)} with all options set.
|
||||
*
|
||||
* @param filePaths the first file is tested only; the others are just copied along with the first.
|
||||
*
|
||||
* @return highlighting duration in milliseconds
|
||||
*/
|
||||
long testHighlighting(@TestDataFile @NonNls String... filePaths);
|
||||
|
||||
long testHighlighting(boolean checkWarnings, boolean checkInfos, boolean checkWeakWarnings, VirtualFile file);
|
||||
|
||||
HighlightTestInfo testFile(@NonNls @NotNull String... filePath);
|
||||
|
||||
void testInspection(@NotNull String testDir, @NotNull InspectionToolWrapper toolWrapper);
|
||||
@@ -289,7 +294,6 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
|
||||
* Finds the reference in position marked by {@link #CARET_MARKER}.
|
||||
*
|
||||
* @return null if no reference found.
|
||||
*
|
||||
* @see #getReferenceAtCaretPositionWithAssertion(String...)
|
||||
*/
|
||||
@Nullable
|
||||
@@ -300,7 +304,6 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
|
||||
* Asserts that the reference exists.
|
||||
*
|
||||
* @return founded reference
|
||||
*
|
||||
* @see #getReferenceAtCaretPosition(String...)
|
||||
*/
|
||||
@NotNull
|
||||
@@ -314,10 +317,10 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
|
||||
* @see #CARET_MARKER
|
||||
*/
|
||||
@NotNull
|
||||
List<IntentionAction> getAvailableIntentions(@NonNls String... filePaths);
|
||||
List<IntentionAction> getAvailableIntentions(@NonNls @TestDataFile String... filePaths);
|
||||
|
||||
@NotNull
|
||||
List<IntentionAction> getAllQuickFixes(@NonNls String... filePaths);
|
||||
List<IntentionAction> getAllQuickFixes(@NonNls @TestDataFile String... filePaths);
|
||||
|
||||
@NotNull
|
||||
List<IntentionAction> getAvailableIntentions();
|
||||
@@ -344,11 +347,11 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
|
||||
* in the in-memory editor and returns an intention action or quickfix with the name exactly matching the specified text.
|
||||
*
|
||||
* @param intentionName the text that the intention text should be equal to.
|
||||
* @param filePaths the list of file path to copy to the test project directory.
|
||||
* @param filePaths the list of file path to copy to the test project directory.
|
||||
* @return the first found intention or quickfix, or null if no matching intention actions are found.
|
||||
*/
|
||||
@Nullable
|
||||
IntentionAction getAvailableIntention(final String intentionName, final String... filePaths);
|
||||
IntentionAction getAvailableIntention(final String intentionName, @TestDataFile final String... filePaths);
|
||||
|
||||
/**
|
||||
* Launches the given action. Use {@link #checkResultByFile(String)} to check the result.
|
||||
@@ -367,11 +370,15 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
|
||||
*/
|
||||
void testCompletion(@TestDataFile @NonNls String fileBefore, @TestDataFile @NonNls String fileAfter, final String... additionalFiles);
|
||||
|
||||
void testCompletionTyping(@TestDataFile @NonNls String fileBefore, String toType, @TestDataFile @NonNls String fileAfter, final String... additionalFiles);
|
||||
void testCompletionTyping(@TestDataFile @NonNls String fileBefore,
|
||||
String toType,
|
||||
@TestDataFile @NonNls String fileAfter,
|
||||
final String... additionalFiles);
|
||||
|
||||
/**
|
||||
* Runs basic completion in caret position in fileBefore.
|
||||
* Checks that lookup is shown and it contains items with given lookup strings
|
||||
*
|
||||
* @param items most probably will contain > 1 items
|
||||
*/
|
||||
void testCompletionVariants(@TestDataFile @NonNls String fileBefore, @NonNls String... items);
|
||||
@@ -380,22 +387,22 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
|
||||
* Launches renaming refactoring and checks the result.
|
||||
*
|
||||
* @param fileBefore original file path. Use {@link #CARET_MARKER} to mark the element to rename.
|
||||
* @param fileAfter result file to be checked against.
|
||||
* @param newName new name for the element.
|
||||
* @param fileAfter result file to be checked against.
|
||||
* @param newName new name for the element.
|
||||
* @see #testRename(String, String)
|
||||
*/
|
||||
void testRename(@TestDataFile @NonNls String fileBefore,
|
||||
@TestDataFile @NonNls String fileAfter, @NonNls String newName, final String... additionalFiles);
|
||||
|
||||
void testRename(String fileAfter, String newName);
|
||||
void testRename(@TestDataFile String fileAfter, String newName);
|
||||
|
||||
Collection<UsageInfo> testFindUsages(@TestDataFile @NonNls String... fileNames);
|
||||
|
||||
Collection<UsageInfo> findUsages(final PsiElement to);
|
||||
|
||||
RangeHighlighter[] testHighlightUsages(String... files);
|
||||
RangeHighlighter[] testHighlightUsages(@TestDataFile String... files);
|
||||
|
||||
void moveFile(@NonNls String filePath, @NonNls String to, final String... additionalFiles);
|
||||
void moveFile(@NonNls @TestDataFile String filePath, @NonNls String to, final String... additionalFiles);
|
||||
|
||||
/**
|
||||
* Returns gutter renderer at the caret position.
|
||||
@@ -431,7 +438,7 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
|
||||
Document getDocument(PsiFile file);
|
||||
|
||||
@NotNull
|
||||
Collection<GutterMark> findAllGutters(String filePath);
|
||||
Collection<GutterMark> findAllGutters(@TestDataFile String filePath);
|
||||
|
||||
void type(final char c);
|
||||
|
||||
@@ -441,13 +448,14 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
|
||||
|
||||
/**
|
||||
* If the action is visible and enabled, perform it
|
||||
*
|
||||
* @param action
|
||||
* @return updated action's presentation
|
||||
*/
|
||||
Presentation testAction(AnAction action);
|
||||
|
||||
@Nullable
|
||||
List<String> getCompletionVariants(String... filesBefore);
|
||||
List<String> getCompletionVariants(@TestDataFile String... filesBefore);
|
||||
|
||||
/**
|
||||
* @return null if the only item was auto-completed
|
||||
@@ -476,13 +484,14 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
|
||||
void allowTreeAccessForAllFiles();
|
||||
|
||||
void renameElement(PsiElement element,
|
||||
String newName,
|
||||
boolean searchInComments,
|
||||
boolean searchTextOccurrences);
|
||||
String newName,
|
||||
boolean searchInComments,
|
||||
boolean searchTextOccurrences);
|
||||
|
||||
<T extends PsiElement> T findElementByText(String text, Class<T> elementClass);
|
||||
|
||||
void testFolding(String fileName);
|
||||
|
||||
void testFoldingWithCollapseStatus(String fileName);
|
||||
|
||||
void assertPreferredCompletionItems(int selected, @NonNls String... expected);
|
||||
|
||||
@@ -115,7 +115,6 @@ class HeavyIdeaTestFixtureImpl extends BaseFixture implements HeavyIdeaTestFixtu
|
||||
for (ModuleFixtureBuilder moduleFixtureBuilder : myModuleFixtureBuilders) {
|
||||
moduleFixtureBuilder.getFixture().tearDown();
|
||||
}
|
||||
((DirectoryIndexImpl)DirectoryIndex.getInstance(getProject())).assertAncestorConsistent();
|
||||
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
|
||||
@@ -22,8 +22,6 @@ import com.intellij.idea.IdeaTestApplication;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.impl.DirectoryIndex;
|
||||
import com.intellij.openapi.roots.impl.DirectoryIndexImpl;
|
||||
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSchemes;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
@@ -72,7 +70,6 @@ public class LightIdeaTestFixtureImpl extends BaseFixture implements LightIdeaTe
|
||||
super.tearDown();
|
||||
InjectedLanguageManagerImpl.checkInjectorsAreDisposed(project);
|
||||
PersistentFS.getInstance().clearIdCache();
|
||||
((DirectoryIndexImpl)DirectoryIndex.getInstance(project)).assertAncestorConsistent();
|
||||
damage.throwIfNotEmpty();
|
||||
}
|
||||
|
||||
|
||||
@@ -167,6 +167,7 @@ public class AllIcons {
|
||||
public static final Icon Import = IconLoader.getIcon("/css/import.png"); // 16x16
|
||||
public static final Icon Property = IconLoader.getIcon("/css/property.png"); // 16x16
|
||||
public static final Icon Pseudo_element = IconLoader.getIcon("/css/pseudo-element.png"); // 16x16
|
||||
public static final Icon Toolwindow = IconLoader.getIcon("/css/toolwindow.png"); // 13x13
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -88,51 +88,51 @@ public class ConcurrencyUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ThreadPoolExecutor newSingleThreadExecutor(@NotNull @NonNls final String threadFactoryName) {
|
||||
return newSingleThreadExecutor(threadFactoryName, Thread.NORM_PRIORITY);
|
||||
public static ThreadPoolExecutor newSingleThreadExecutor(@NotNull @NonNls String name) {
|
||||
return newSingleThreadExecutor(name, Thread.NORM_PRIORITY);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ThreadPoolExecutor newSingleThreadExecutor(@NonNls @NotNull final String threadFactoryName, final int threadPriority) {
|
||||
return new ThreadPoolExecutor(1, 1,
|
||||
0L, TimeUnit.MILLISECONDS,
|
||||
new LinkedBlockingQueue<Runnable>(), newNamedThreadFactory(threadFactoryName, true, threadPriority));
|
||||
public static ThreadPoolExecutor newSingleThreadExecutor(@NonNls @NotNull String name, int priority) {
|
||||
return new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS,
|
||||
new LinkedBlockingQueue<Runnable>(), newNamedThreadFactory(name, true, priority));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ScheduledThreadPoolExecutor newSingleScheduledThreadExecutor(@NotNull @NonNls final String threadFactoryName) {
|
||||
return newSingleScheduledThreadExecutor(threadFactoryName, Thread.NORM_PRIORITY);
|
||||
public static ScheduledThreadPoolExecutor newSingleScheduledThreadExecutor(@NotNull @NonNls String name) {
|
||||
return newSingleScheduledThreadExecutor(name, Thread.NORM_PRIORITY);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ScheduledThreadPoolExecutor newSingleScheduledThreadExecutor(@NonNls @NotNull final String threadFactoryName, final int threadPriority) {
|
||||
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1, newNamedThreadFactory(threadFactoryName, true, threadPriority));
|
||||
public static ScheduledThreadPoolExecutor newSingleScheduledThreadExecutor(@NonNls @NotNull String name, int priority) {
|
||||
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1, newNamedThreadFactory(name, true, priority));
|
||||
executor.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
|
||||
executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
|
||||
return executor;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ThreadFactory newNamedThreadFactory(@NonNls @NotNull final String threadName, final boolean isDaemon, final int threadPriority) {
|
||||
public static ThreadFactory newNamedThreadFactory(@NonNls @NotNull final String name, final boolean isDaemon, final int priority) {
|
||||
return new ThreadFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Thread newThread(@NotNull final Runnable r) {
|
||||
final Thread thread = new Thread(r, threadName);
|
||||
thread.setDaemon(isDaemon);
|
||||
thread.setPriority(threadPriority);
|
||||
return thread;
|
||||
}
|
||||
};
|
||||
@NotNull
|
||||
@Override
|
||||
public Thread newThread(@NotNull Runnable r) {
|
||||
Thread thread = new Thread(r, name);
|
||||
thread.setDaemon(isDaemon);
|
||||
thread.setPriority(priority);
|
||||
return thread;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ThreadFactory newNamedThreadFactory(@NonNls @NotNull final String threadName) {
|
||||
public static ThreadFactory newNamedThreadFactory(@NonNls @NotNull final String name) {
|
||||
return new ThreadFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Thread newThread(@NotNull final Runnable r) {
|
||||
return new Thread(r, threadName);
|
||||
}
|
||||
};
|
||||
@NotNull
|
||||
@Override
|
||||
public Thread newThread(@NotNull final Runnable r) {
|
||||
return new Thread(r, name);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,7 @@ package com.siyeh.ig.classlayout;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.codeInsight.intention.AddAnnotationPsiFix;
|
||||
import com.intellij.psi.LambdaHighlightingUtil;
|
||||
import com.intellij.psi.LambdaUtil;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiNameValuePair;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.MethodSignature;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
@@ -55,7 +52,7 @@ public class InterfaceMayBeAnnotatedFunctionalInspection extends BaseInspection
|
||||
@Override
|
||||
protected InspectionGadgetsFix buildFix(Object... infos) {
|
||||
final PsiClass aClass = (PsiClass)infos[0];
|
||||
return new DelegatingFix(new AddAnnotationPsiFix(LambdaUtil.JAVA_LANG_FUNCTIONAL_INTERFACE, aClass, PsiNameValuePair.EMPTY_ARRAY));
|
||||
return new DelegatingFix(new AddAnnotationPsiFix(CommonClassNames.JAVA_LANG_FUNCTIONAL_INTERFACE, aClass, PsiNameValuePair.EMPTY_ARRAY));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,10 @@ import com.intellij.psi.PsiTypeParameter;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.psi.search.searches.ClassInheritorsSearch;
|
||||
import com.intellij.psi.search.searches.FunctionalExpressionSearch;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.Query;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@@ -75,8 +77,9 @@ public class InheritanceUtil {
|
||||
return result[0];
|
||||
}
|
||||
|
||||
public static boolean hasImplementation(PsiClass aClass) {
|
||||
public static boolean hasImplementation(@NotNull PsiClass aClass) {
|
||||
final SearchScope scope = GlobalSearchScope.projectScope(aClass.getProject());
|
||||
if (aClass.isInterface() && FunctionalExpressionSearch.search(aClass, scope).findFirst() != null) return true;
|
||||
final Query<PsiClass> search = ClassInheritorsSearch.search(aClass, scope, true, true);
|
||||
return !search.forEach(new Processor<PsiClass>() {
|
||||
@Override
|
||||
|
||||
@@ -5,4 +5,14 @@ interface InterfaceWithOnlyOneDirectInheritor {}
|
||||
class Inheritor implements InterfaceWithOnlyOneDirectInheritor {}
|
||||
interface InterfaceWithTwoInheritors {}
|
||||
class Inheritor1 implements InterfaceWithTwoInheritors {}
|
||||
class Inheritor2 implements InterfaceWithTwoInheritors {}
|
||||
class Inheritor2 implements InterfaceWithTwoInheritors {}
|
||||
|
||||
interface SAM {
|
||||
void foo();
|
||||
}
|
||||
|
||||
class LambdaCall {
|
||||
{
|
||||
SAM sam = () -> {};
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,29 @@
|
||||
package com.siyeh.ig.inheritance;
|
||||
|
||||
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.siyeh.ig.IGInspectionTestCase;
|
||||
|
||||
public class InterfaceNeverImplementedInspectionTest extends IGInspectionTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doTest("com/siyeh/igtest/inheritance/interface_never_implemented", new InterfaceNeverImplementedInspection());
|
||||
final LanguageLevelProjectExtension levelProjectExtension = LanguageLevelProjectExtension.getInstance(getProject());
|
||||
final LanguageLevel level = levelProjectExtension.getLanguageLevel();
|
||||
try {
|
||||
levelProjectExtension.setLanguageLevel(LanguageLevel.JDK_1_8);
|
||||
doTest("com/siyeh/igtest/inheritance/interface_never_implemented",
|
||||
new LocalInspectionToolWrapper(new InterfaceNeverImplementedInspection()), "java 1.8");
|
||||
}
|
||||
finally {
|
||||
levelProjectExtension.setLanguageLevel(level);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getTestProjectSdk() {
|
||||
return IdeaTestUtil.getMockJdk18();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,16 @@
|
||||
package com.siyeh.ipp.interfacetoclass;
|
||||
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.presentation.java.ClassPresentationUtil;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.psi.search.searches.ClassInheritorsSearch;
|
||||
import com.intellij.psi.search.searches.FunctionalExpressionSearch;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.refactoring.BaseRefactoringProcessor;
|
||||
import com.intellij.refactoring.ui.ConflictsDialog;
|
||||
import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.intellij.refactoring.util.RefactoringUIUtil;
|
||||
@@ -123,10 +127,20 @@ public class ConvertInterfaceToClassIntention extends Intention {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final PsiFunctionalExpression functionalExpression = FunctionalExpressionSearch.search(anInterface, searchScope).findFirst();
|
||||
if (functionalExpression != null) {
|
||||
final String conflictMessage = ClassPresentationUtil.getFunctionalExpressionPresentation(functionalExpression, true) +
|
||||
" will not compile after converting " + RefactoringUIUtil.getDescription(anInterface, false) + " to a class";
|
||||
conflicts.putValue(functionalExpression, conflictMessage);
|
||||
}
|
||||
final boolean conflictsDialogOK;
|
||||
if (conflicts.isEmpty()) {
|
||||
conflictsDialogOK = true;
|
||||
} else {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
throw new BaseRefactoringProcessor.ConflictsInTestsException(conflicts.values());
|
||||
}
|
||||
final ConflictsDialog conflictsDialog = new ConflictsDialog(anInterface.getProject(), conflicts, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.siyeh.ipp.interfacetoclass;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
@@ -45,6 +47,6 @@ class ConvertInterfaceToClassPredicate implements PsiElementPredicate {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return !AnnotationUtil.isAnnotated(aClass, CommonClassNames.JAVA_LANG_FUNCTIONAL_INTERFACE, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
interface <caret>FunctionalExpressions {
|
||||
void foo();
|
||||
}
|
||||
|
||||
class Test {
|
||||
{
|
||||
FunctionalExpressions fe = () -> {};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
@FunctionalInterface
|
||||
interface <caret>FunctionalExpressions {
|
||||
void foo();
|
||||
}
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.siyeh.ipp.interfacetoclass;
|
||||
|
||||
import com.intellij.refactoring.BaseRefactoringProcessor;
|
||||
import com.siyeh.IntentionPowerPackBundle;
|
||||
import com.siyeh.ipp.IPPTestCase;
|
||||
|
||||
@@ -23,6 +24,19 @@ public class ConvertInterfaceToClassTest extends IPPTestCase {
|
||||
public void testExtensionMethods() { doTest(); }
|
||||
public void testInnerInterface() { doTest(); }
|
||||
public void testStaticMethods() { doTest(); }
|
||||
public void testFunctionalExpressions() {
|
||||
try {
|
||||
doTest();
|
||||
fail("Conflict not detected");
|
||||
}
|
||||
catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
|
||||
assertEquals("Functional expression in Test will not compile after converting class <b><code>FunctionalExpressions</code></b> to a class", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void testFunctionalInterface() throws Exception {
|
||||
assertIntentionNotAvailable();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRelativePath() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import static Util.*
|
||||
import static Util.doSomething
|
||||
|
||||
class Util {
|
||||
static doSomething(){}
|
||||
@@ -10,4 +10,4 @@ def doSomethingElse(a){}
|
||||
|
||||
doSomething()
|
||||
doSomething(2)
|
||||
Util.doSomethingElse(2)
|
||||
doSomethingElse(2)
|
||||
@@ -1,5 +1,5 @@
|
||||
print(new java.lang.Runnable() {
|
||||
public void run(java.lang.Object it) {print("foo}");}
|
||||
public void run(java.lang.Object it) {org.codehaus.groovy.runtime.DefaultGroovyMethods.print(anonymousFromMap.this, "foo}");}
|
||||
public void run() {
|
||||
this.run(null);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
java.util.ArrayList<java.lang.Integer> list = new java.util.ArrayList<java.lang.Integer>(java.util.Arrays.asList(1, 2, 3));
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.each(list, new groovy.lang.Closure<java.lang.Object>(this, this) {
|
||||
public void doCall(java.lang.Integer it) {
|
||||
print(it);
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.print(closure.this, it);
|
||||
}
|
||||
|
||||
public void doCall() {
|
||||
|
||||
@@ -13,7 +13,7 @@ public void foo(int x) {final groovy.lang.Reference<java.lang.Integer> i = new g
|
||||
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.each(new java.util.ArrayList<java.lang.Integer>(java.util.Arrays.asList(1, 2, 3)), new groovy.lang.Closure<java.lang.Integer>(this, this) {
|
||||
public java.lang.Integer doCall(java.lang.Integer it) {
|
||||
print(i.get());
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.print(methodParamInClosureImplicitReturn.this, i.get());
|
||||
return setGroovyRef(i, i.get() + 1);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ return doCall(null);
|
||||
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.each(new java.util.ArrayList<java.lang.Integer>(java.util.Arrays.asList(1, 2, 3)), new groovy.lang.Closure<java.lang.Integer>(this, this) {
|
||||
public java.lang.Integer doCall(java.lang.Integer it) {
|
||||
print(i.get());
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.print(methodParamInClosureImplicitReturn.this, i.get());
|
||||
i.set(i.get()++);
|
||||
return i.get();
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ foo.set(foo.get()++);
|
||||
foo.set(foo.get() + 2);
|
||||
foo.set(foo.get() - 1);
|
||||
foo.set(4);
|
||||
print(foo.get());
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.print(refInClosureInScript.this, foo.get());
|
||||
}
|
||||
|
||||
public void doCall() {
|
||||
|
||||
@@ -25,7 +25,9 @@ import org.jetbrains.idea.maven.dom.MavenDomUtil;
|
||||
import org.jetbrains.idea.maven.dom.MavenPropertyResolver;
|
||||
import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel;
|
||||
import org.jetbrains.idea.maven.project.MavenProject;
|
||||
import org.jetbrains.idea.maven.project.MavenProjectSettings;
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsManager;
|
||||
import org.jetbrains.idea.maven.project.MavenTestRunningSettings;
|
||||
import org.jetbrains.idea.maven.utils.MavenJDOMUtil;
|
||||
|
||||
import java.util.List;
|
||||
@@ -45,6 +47,8 @@ public class MavenJUnitPatcher extends JUnitPatcher {
|
||||
Element config = mavenProject.getPluginConfiguration("org.apache.maven.plugins", "maven-surefire-plugin");
|
||||
if (config == null) return;
|
||||
|
||||
MavenTestRunningSettings testRunningSettings = MavenProjectSettings.getInstance(module.getProject()).getTestRunningSettings();
|
||||
|
||||
List<String> paths = MavenJDOMUtil.findChildrenValuesByPath(config, "additionalClasspathElements", "additionalClasspathElement");
|
||||
|
||||
if (paths.size() > 0) {
|
||||
@@ -59,39 +63,45 @@ public class MavenJUnitPatcher extends JUnitPatcher {
|
||||
}
|
||||
}
|
||||
|
||||
Element systemPropertyVariables = config.getChild("systemPropertyVariables");
|
||||
if (systemPropertyVariables != null && isEnabled("systemPropertyVariables")) {
|
||||
for (Element element : systemPropertyVariables.getChildren()) {
|
||||
String propertyName = element.getName();
|
||||
if (testRunningSettings.isPassEnvironmentVariables() && isEnabled("systemPropertyVariables")) {
|
||||
Element systemPropertyVariables = config.getChild("systemPropertyVariables");
|
||||
if (systemPropertyVariables != null) {
|
||||
for (Element element : systemPropertyVariables.getChildren()) {
|
||||
String propertyName = element.getName();
|
||||
|
||||
if (!javaParameters.getVMParametersList().hasProperty(propertyName)) {
|
||||
String value = resolveSurefireProperties(element.getValue());
|
||||
if (isResolved(value)) {
|
||||
javaParameters.getVMParametersList().addProperty(propertyName, value);
|
||||
if (!javaParameters.getVMParametersList().hasProperty(propertyName)) {
|
||||
String value = resolveSurefireProperties(element.getValue());
|
||||
if (isResolved(value)) {
|
||||
javaParameters.getVMParametersList().addProperty(propertyName, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Element environmentVariables = config.getChild("environmentVariables");
|
||||
if (environmentVariables != null && isEnabled("environmentVariables")) {
|
||||
for (Element element : environmentVariables.getChildren()) {
|
||||
String variableName = element.getName();
|
||||
if (testRunningSettings.isPassEnvironmentVariables() && isEnabled("environmentVariables")) {
|
||||
Element environmentVariables = config.getChild("environmentVariables");
|
||||
if (environmentVariables != null) {
|
||||
for (Element element : environmentVariables.getChildren()) {
|
||||
String variableName = element.getName();
|
||||
|
||||
if (javaParameters.getEnv() == null || !javaParameters.getEnv().containsKey(variableName)) {
|
||||
String value = resolveSurefireProperties(element.getValue());
|
||||
if (isResolved(value)) {
|
||||
javaParameters.addEnv(variableName, value);
|
||||
if (javaParameters.getEnv() == null || !javaParameters.getEnv().containsKey(variableName)) {
|
||||
String value = resolveSurefireProperties(element.getValue());
|
||||
if (isResolved(value)) {
|
||||
javaParameters.addEnv(variableName, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Element argLine = config.getChild("argLine");
|
||||
if (argLine != null && isEnabled("argLine")) {
|
||||
String value = resolveSurefireProperties(argLine.getTextTrim());
|
||||
if (StringUtil.isNotEmpty(value) && isResolved(value)) {
|
||||
javaParameters.getVMParametersList().addParametersString(value);
|
||||
if (testRunningSettings.isPassArgLine() && isEnabled("argLine")) {
|
||||
Element argLine = config.getChild("argLine");
|
||||
if (argLine != null) {
|
||||
String value = resolveSurefireProperties(argLine.getTextTrim());
|
||||
if (StringUtil.isNotEmpty(value) && isResolved(value)) {
|
||||
javaParameters.getVMParametersList().addParametersString(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.maven.project;
|
||||
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Sergey Evdokimov
|
||||
*/
|
||||
@State(
|
||||
name = "MavenProjectSettings",
|
||||
storages = {@Storage(
|
||||
file = StoragePathMacros.PROJECT_CONFIG_DIR + "/mavenProjectSettings.xml")})
|
||||
public class MavenProjectSettings implements PersistentStateComponent<MavenProjectSettings> {
|
||||
|
||||
private final Project myProject;
|
||||
|
||||
private MavenTestRunningSettings myTestRunningSettings = new MavenTestRunningSettings();
|
||||
|
||||
public MavenProjectSettings() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public MavenProjectSettings(Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
public static MavenProjectSettings getInstance(@NotNull Project project) {
|
||||
return ServiceManager.getService(project, MavenProjectSettings.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public MavenProjectSettings getState() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public MavenTestRunningSettings getTestRunningSettings() {
|
||||
return myTestRunningSettings;
|
||||
}
|
||||
|
||||
public void setTestRunningSettings(MavenTestRunningSettings testRunningSettings) {
|
||||
myTestRunningSettings = testRunningSettings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(MavenProjectSettings state) {
|
||||
this.myTestRunningSettings = state.myTestRunningSettings;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.idea.maven.project.MavenTestRunningConfigurable">
|
||||
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="5" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="923" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="2c82f" class="com.intellij.ui.components.JBCheckBox" binding="myPassArgLineCB">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="5" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="<html>Pass <i>&argLine</i> plugin parameter to arguments list of JUnit process</html>"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="6ca33">
|
||||
<constraints>
|
||||
<grid row="4" column="4" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="2514a" class="com.intellij.ui.TitledSeparator">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="5" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="<html>Configuration of <b>maven-surefire-plugin</b> that will be used when JUnit run configuration will be executed</html>"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="928c4" class="com.intellij.ui.components.JBCheckBox" binding="myPassSystemPropertiesCB">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="5" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="<html>Pass properties from <i>&systemPropertyVariables</i> plugin parameter to JUnit process</html>"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="4f0b5" class="com.intellij.ui.components.JBCheckBox" binding="myPassEnvironmentVariablesCB">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="5" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="<html>Pass variables from <i>&environmentVariables</i> to environment variables of JUnit process</html>"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.maven.project;
|
||||
|
||||
import com.intellij.openapi.options.BaseConfigurable;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.SearchableConfigurable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author Sergey Evdokimov
|
||||
*/
|
||||
public class MavenTestRunningConfigurable extends BaseConfigurable implements SearchableConfigurable, Configurable.NoScroll {
|
||||
|
||||
private JPanel myMainPanel;
|
||||
|
||||
private JBCheckBox myPassArgLineCB;
|
||||
private JBCheckBox myPassSystemPropertiesCB;
|
||||
private JBCheckBox myPassEnvironmentVariablesCB;
|
||||
|
||||
private final Project myProject;
|
||||
|
||||
public MavenTestRunningConfigurable(Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@Nls
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return ProjectBundle.message("maven.testRunning");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getHelpTopic() {
|
||||
return "reference.settings.project.maven.testRunning";
|
||||
}
|
||||
|
||||
private void getSettingsFromUI(MavenTestRunningSettings settings) {
|
||||
settings.setPassArgLine(myPassArgLineCB.isSelected());
|
||||
settings.setPassSystemProperties(myPassSystemPropertiesCB.isSelected());
|
||||
settings.setPassEnvironmentVariables(myPassEnvironmentVariablesCB.isSelected());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() throws ConfigurationException {
|
||||
getSettingsFromUI(MavenProjectSettings.getInstance(myProject).getTestRunningSettings());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
MavenTestRunningSettings settings = MavenProjectSettings.getInstance(myProject).getTestRunningSettings();
|
||||
|
||||
myPassArgLineCB.setSelected(settings.isPassArgLine());
|
||||
myPassSystemPropertiesCB.setSelected(settings.isPassSystemProperties());
|
||||
myPassEnvironmentVariablesCB.setSelected(settings.isPassEnvironmentVariables());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JComponent createComponent() {
|
||||
return myMainPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
MavenTestRunningSettings uiSettings = new MavenTestRunningSettings();
|
||||
getSettingsFromUI(uiSettings);
|
||||
|
||||
MavenTestRunningSettings projectSettings = MavenProjectSettings.getInstance(myProject).getTestRunningSettings();
|
||||
|
||||
return !projectSettings.equals(uiSettings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeUIResources() {
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getId() {
|
||||
return "reference.settings.project.maven.testRunning";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Runnable enableSearch(String option) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.maven.project;
|
||||
|
||||
/**
|
||||
* @author Sergey Evdokimov
|
||||
*/
|
||||
public class MavenTestRunningSettings {
|
||||
|
||||
private boolean myPassArgLine;
|
||||
private boolean myPassEnvironmentVariables;
|
||||
private boolean myPassSystemProperties;
|
||||
|
||||
public boolean isPassArgLine() {
|
||||
return myPassArgLine;
|
||||
}
|
||||
|
||||
public void setPassArgLine(boolean passArgLine) {
|
||||
myPassArgLine = passArgLine;
|
||||
}
|
||||
|
||||
public boolean isPassEnvironmentVariables() {
|
||||
return myPassEnvironmentVariables;
|
||||
}
|
||||
|
||||
public void setPassEnvironmentVariables(boolean passEnvironmentVariables) {
|
||||
myPassEnvironmentVariables = passEnvironmentVariables;
|
||||
}
|
||||
|
||||
public boolean isPassSystemProperties() {
|
||||
return myPassSystemProperties;
|
||||
}
|
||||
|
||||
public void setPassSystemProperties(boolean passSystemProperties) {
|
||||
myPassSystemProperties = passSystemProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof MavenTestRunningSettings)) return false;
|
||||
|
||||
MavenTestRunningSettings settings = (MavenTestRunningSettings)o;
|
||||
|
||||
if (myPassArgLine != settings.myPassArgLine) return false;
|
||||
if (myPassEnvironmentVariables != settings.myPassEnvironmentVariables) return false;
|
||||
if (myPassSystemProperties != settings.myPassSystemProperties) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = (myPassArgLine ? 1 : 0);
|
||||
result = 31 * result + (myPassEnvironmentVariables ? 1 : 0);
|
||||
result = 31 * result + (myPassSystemProperties ? 1 : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,8 @@ public class MavenSettings implements SearchableConfigurable.Parent {
|
||||
|
||||
myChildren.add(new MyMavenRunnerConfigurable(project));
|
||||
|
||||
myChildren.add(new MavenTestRunningConfigurable(project));
|
||||
|
||||
if (!myProject.isDefault()) {
|
||||
myChildren.add(new MavenRepositoriesConfigurable(myProject));
|
||||
}
|
||||
|
||||
@@ -51,6 +51,9 @@
|
||||
id="reference.settings.project.maven.ignored.files" key="maven.tab.ignored.files" bundle="ProjectBundle"/>
|
||||
<configurable instance="org.jetbrains.idea.maven.utils.MavenSettings$MyMavenRunnerConfigurable"
|
||||
id="reference.settings.project.maven.runner" key="maven.tab.runner" bundle="RunnerBundle"/>
|
||||
<configurable instance="org.jetbrains.idea.maven.project.MavenTestRunningConfigurable"
|
||||
id="reference.settings.project.maven.testRunning" key="maven.testRunning" bundle="ProjectBundle"
|
||||
nonDefaultProject="true"/>
|
||||
<configurable instance="org.jetbrains.idea.maven.indices.MavenRepositoriesConfigurable"
|
||||
id="reference.settings.project.maven.repository.indices" key="maven.repositories.title" bundle="IndicesBundle"
|
||||
nonDefaultProject="true"/>
|
||||
@@ -170,7 +173,7 @@
|
||||
|
||||
<projectService serviceImplementation="org.jetbrains.idea.maven.project.MavenWorkspaceSettingsComponent"/>
|
||||
<projectService serviceImplementation="org.jetbrains.idea.maven.execution.MavenRunner"/>
|
||||
|
||||
<projectService serviceImplementation="org.jetbrains.idea.maven.project.MavenProjectSettings"/>
|
||||
</extensions>
|
||||
|
||||
<extensions defaultExtensionNs="org.jetbrains.idea.maven">
|
||||
|
||||
@@ -59,6 +59,7 @@ maven.download.ondemand=On demand
|
||||
maven.download.always=On import
|
||||
|
||||
maven.tab.ignored.files=Ignored Files
|
||||
maven.testRunning=Running Tests
|
||||
maven.ignore=Ignore Projects
|
||||
maven.unignore=Unignore Projects
|
||||
maven.ingored.no.file=No Maven files
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.patterns;
|
||||
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.util.ProcessingContext;
|
||||
import com.intellij.util.xml.DomElement;
|
||||
import com.intellij.util.xml.DomManager;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
public class DomFilePattern<Self extends DomFilePattern<Self>> extends XmlFilePattern<Self> {
|
||||
public DomFilePattern(final Class<? extends DomElement> aClass) {
|
||||
super(new InitialPatternCondition<XmlFile>(XmlFile.class) {
|
||||
@Override
|
||||
public boolean accepts(@Nullable Object o, ProcessingContext context) {
|
||||
return o instanceof XmlFile && DomManager.getDomManager(((XmlFile)o).getProject()).getFileElement((XmlFile)o, aClass) != null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static class Capture extends DomFilePattern<Capture> {
|
||||
public Capture(Class<? extends DomElement> aClass) {
|
||||
super(aClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,6 +62,10 @@ public class DomPatterns {
|
||||
});
|
||||
}
|
||||
|
||||
public static <T extends DomElement> DomFilePattern.Capture inDomFile(Class<T> rootElementClass) {
|
||||
return new DomFilePattern.Capture(rootElementClass);
|
||||
}
|
||||
|
||||
public static XmlTagPattern.Capture tagWithDom(String tagName, Class<? extends DomElement> aClass) {
|
||||
return tagWithDom(tagName, domElement(aClass));
|
||||
}
|
||||
|
||||