Merge remote-tracking branch 'origin/master'

This commit is contained in:
Ilya.Kazakevich
2014-08-26 21:48:43 +04:00
23 changed files with 196 additions and 121 deletions
@@ -151,7 +151,7 @@ public class FSOperations {
}
}
public static void processFilesToRecompile(CompileContext context, ModuleBuildTarget target, FileProcessor<JavaSourceRootDescriptor, ModuleBuildTarget> processor) throws IOException {
public static void processFilesToRecompile(CompileContext context, @NotNull ModuleBuildTarget target, FileProcessor<JavaSourceRootDescriptor, ModuleBuildTarget> processor) throws IOException {
context.getProjectDescriptor().fsState.processFilesToRecompile(context, target, processor);
}
@@ -145,13 +145,17 @@ public class BuildFSState extends FSState {
setRoundDelta(CURRENT_ROUND_DELTA_KEY, context, new FilesDelta());
}
public <R extends BuildRootDescriptor, T extends BuildTarget<R>> boolean processFilesToRecompile(CompileContext context, final T target, final FileProcessor<R, T> processor) throws IOException {
public <R extends BuildRootDescriptor, T extends BuildTarget<R>> boolean processFilesToRecompile(CompileContext context, final @NotNull T target, final FileProcessor<R, T> processor) throws IOException {
final Map<BuildRootDescriptor, Set<File>> data = getSourcesToRecompile(context, target);
final CompileScope scope = context.getScope();
synchronized (data) {
for (Map.Entry<BuildRootDescriptor, Set<File>> entry : data.entrySet()) {
//noinspection unchecked
R root = (R)entry.getKey();
if (!target.equals(root.getTarget())) {
// the data can contain roots from other targets (e.g. when compiling module cycles)
continue;
}
for (File file : entry.getValue()) {
if (!scope.isAffected(target, file)) {
continue;
@@ -23,7 +23,6 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.AsyncResult;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowAnchor;
@@ -35,6 +34,7 @@ import com.intellij.psi.PsiFile;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.psi.util.PsiUtilBase;
import com.intellij.ui.content.*;
import com.intellij.util.Consumer;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.update.Activatable;
import com.intellij.util.ui.update.UiNotifyConnector;
@@ -193,12 +193,16 @@ public abstract class DockablePopupManager<T extends JComponent & Disposable> {
public void updateComponent() {
if (myProject.isDisposed()) return;
AsyncResult<DataContext> asyncResult = DataManager.getInstance().getDataContextFromFocus();
DataContext dataContext = asyncResult.getResult();
if (dataContext == null) {
return;
}
DataManager.getInstance().getDataContextFromFocus().doWhenDone(new Consumer<DataContext>() {
@Override
public void consume(@NotNull DataContext dataContext) {
if (!myProject.isOpen()) return;
updateComponentInner(dataContext);
}
});
}
private void updateComponentInner(@NotNull DataContext dataContext) {
if (CommonDataKeys.PROJECT.getData(dataContext) != myProject) {
return;
}
@@ -36,6 +36,7 @@ import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ex.ActionManagerEx;
import com.intellij.openapi.actionSystem.ex.AnActionListener;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
@@ -59,7 +60,6 @@ import com.intellij.psi.util.PsiUtilCore;
import com.intellij.ui.ListScrollingUtil;
import com.intellij.ui.content.Content;
import com.intellij.ui.popup.AbstractPopup;
import com.intellij.ui.popup.NotLookupOrSearchCondition;
import com.intellij.ui.popup.PopupPositionManager;
import com.intellij.ui.popup.PopupUpdateProcessor;
import com.intellij.util.Alarm;
@@ -141,12 +141,7 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
IdeFocusManager.getInstance(myProject).requestFocus(myPreviouslyFocused, true);
}
super.restorePopupBehavior();
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
updateComponent();
}
});
updateComponent();
}
/**
@@ -272,12 +267,12 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
@Override
public void updatePopup(Object lookupItemObject) {
if (lookupItemObject instanceof PsiElement) {
doShowJavaDocInfo((PsiElement)lookupItemObject, false, this, original, null, false);
doShowJavaDocInfo((PsiElement)lookupItemObject, false, this, original, null);
}
}
};
doShowJavaDocInfo(element, false, updateProcessor, original, closeCallback, true);
doShowJavaDocInfo(element, false, updateProcessor, original, closeCallback);
}
public void showJavaDocInfo(final Editor editor, @Nullable final PsiFile file, boolean requestFocus) {
@@ -337,7 +332,7 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
return;
}
if (lookupIteObject instanceof PsiElement) {
doShowJavaDocInfo((PsiElement)lookupIteObject, false, this, originalElement, closeCallback, false);
doShowJavaDocInfo((PsiElement)lookupIteObject, false, this, originalElement, closeCallback);
return;
}
@@ -360,12 +355,12 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
}
}
else {
doShowJavaDocInfo(element, false, this, originalElement, closeCallback, false);
doShowJavaDocInfo(element, false, this, originalElement, closeCallback);
}
}
};
doShowJavaDocInfo(element, requestFocus, updateProcessor, originalElement, closeCallback, false);
doShowJavaDocInfo(element, requestFocus, updateProcessor, originalElement, closeCallback);
}
public PsiElement findTargetElement(Editor editor, PsiFile file) {
@@ -380,25 +375,25 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
boolean requestFocus,
PopupUpdateProcessor updateProcessor,
final PsiElement originalElement,
@Nullable final Runnable closeCallback,
boolean fromUserAction)
{
@Nullable final Runnable closeCallback) {
Project project = getProject(element);
storeOriginalElement(project, originalElement, element);
myPreviouslyFocused = WindowManagerEx.getInstanceEx().getFocusedComponent(project);
JBPopup _oldHint = getDocInfoHint();
if (myToolWindow == null && PropertiesComponent.getInstance().isTrueValue(SHOW_DOCUMENTATION_IN_TOOL_WINDOW)) {
createToolWindow(element, originalElement);
return;
}
else if (myToolWindow != null) {
final Content content = myToolWindow.getContentManager().getSelectedContent();
Content content = myToolWindow.getContentManager().getSelectedContent();
if (content != null) {
final DocumentationComponent component = (DocumentationComponent)content.getComponent();
if (element.getManager().areElementsEquivalent(component.getElement(), element) && (requestFocus || fromUserAction)) {
DocumentationComponent component = (DocumentationComponent)content.getComponent();
if (element.getManager().areElementsEquivalent(component.getElement(), element)) {
JComponent preferredFocusableComponent = content.getPreferredFocusableComponent();
if (preferredFocusableComponent != null) {
// focus toolwindow on the second actionPerformed
boolean focus = requestFocus || CommandProcessor.getInstance().getCurrentCommand() != null;
if (preferredFocusableComponent != null && focus) {
IdeFocusManager.getInstance(myProject).requestFocus(preferredFocusableComponent, true);
}
}
@@ -411,16 +406,21 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
if (!myToolWindow.isVisible()) {
myToolWindow.show(null);
}
return;
}
final JBPopup _oldHint = getDocInfoHint();
if (_oldHint != null && _oldHint.isVisible() && _oldHint instanceof AbstractPopup) {
final DocumentationComponent oldComponent = (DocumentationComponent)((AbstractPopup)_oldHint).getComponent();
else if (_oldHint != null && _oldHint.isVisible() && _oldHint instanceof AbstractPopup) {
DocumentationComponent oldComponent = (DocumentationComponent)((AbstractPopup)_oldHint).getComponent();
fetchDocInfo(getDefaultCollector(element, originalElement), oldComponent);
return;
}
else {
showInPopup(element, requestFocus, updateProcessor, originalElement, closeCallback);
}
}
private void showInPopup(@NotNull final PsiElement element,
boolean requestFocus,
PopupUpdateProcessor updateProcessor,
final PsiElement originalElement,
@Nullable final Runnable closeCallback) {
final DocumentationComponent component = new DocumentationComponent(this);
component.setNavigateCallback(new Consumer<PsiElement>() {
@Override
@@ -455,8 +455,7 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
boolean hasLookup = LookupManager.getActiveLookup(myEditor) != null;
final JBPopup hint = JBPopupFactory.getInstance().createComponentPopupBuilder(component, component)
.setRequestFocusCondition(project, NotLookupOrSearchCondition.INSTANCE)
.setProject(project)
.setProject(element.getProject())
.addListener(updateProcessor)
.addUserData(updateProcessor)
.setKeyboardActions(actions)
@@ -501,20 +500,6 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
})
.createPopup();
AbstractPopup oldHint = (AbstractPopup)getDocInfoHint();
if (oldHint != null) {
DocumentationComponent oldComponent = (DocumentationComponent)oldHint.getComponent();
PsiElement element1 = oldComponent.getElement();
if (Comparing.equal(element, element1)) {
if (requestFocus) {
component.getComponent().requestFocus();
}
return;
}
oldHint.cancel();
}
component.setHint(hint);
if (myEditor == null) {
@@ -37,7 +37,6 @@ import com.intellij.openapi.progress.impl.BackgroundableProcessIndicator;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.ui.popup.LightweightWindowEvent;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.vfs.VirtualFile;
@@ -48,7 +47,6 @@ import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.reference.SoftReference;
import com.intellij.ui.popup.AbstractPopup;
import com.intellij.ui.popup.NotLookupOrSearchCondition;
import com.intellij.ui.popup.PopupPositionManager;
import com.intellij.ui.popup.PopupUpdateProcessor;
import com.intellij.usages.UsageView;
@@ -274,7 +272,6 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
};
popup = JBPopupFactory.getInstance().createComponentPopupBuilder(component, component.getPreferredFocusableComponent())
.setRequestFocusCondition(project, NotLookupOrSearchCondition.INSTANCE)
.setProject(project)
.addListener(updateProcessor)
.addUserData(updateProcessor)
@@ -39,7 +39,6 @@ import com.intellij.ui.*;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.components.JBList;
import com.intellij.ui.components.JBScrollPane;
import com.intellij.ui.popup.NotLookupOrSearchCondition;
import com.intellij.ui.treeStructure.Tree;
import com.intellij.util.Function;
import com.intellij.util.NotNullFunction;
@@ -232,7 +231,6 @@ public class ImageDuplicateResultsDialog extends DialogWrapper {
final JBPopup popup =
JBPopupFactory.getInstance().createComponentPopupBuilder(viewComponent, viewComponent.getPreferredFocusableComponent())
.setRequestFocusCondition(myProject, NotLookupOrSearchCondition.INSTANCE)
.setProject(myProject)
.setDimensionServiceKey(myProject, DocumentationManager.JAVADOC_LOCATION_AND_SIZE, false)
.setResizable(true)
@@ -91,8 +91,6 @@ public class SearchDialog extends DialogWrapper implements ConfigurationCreator
private boolean useLastConfiguration;
private static boolean ourOpenInNewTab;
@NonNls private FileType ourFtSearchVariant = StructuralSearchUtil.getDefaultFileType();
private static Language ourDialect = null;
private static String ourContext = null;
@@ -499,7 +497,7 @@ public class SearchDialog extends DialogWrapper implements ConfigurationCreator
final UsageViewContext context = createUsageViewContext(config);
final UsageViewPresentation presentation = new UsageViewPresentation();
presentation.setOpenInNewTab(openInNewTab.isSelected());
presentation.setOpenInNewTab(FindSettings.getInstance().isShowResultsInSeparateView());
presentation.setScopeText(config.getMatchOptions().getScope().getDisplayName());
context.configure(presentation);
@@ -636,7 +634,7 @@ public class SearchDialog extends DialogWrapper implements ConfigurationCreator
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0));
openInNewTab = new JCheckBox(FindBundle.message("find.open.in.new.tab.checkbox"));
openInNewTab.setSelected(ourOpenInNewTab);
openInNewTab.setSelected(FindSettings.getInstance().isShowResultsInSeparateView());
ToolWindow findWindow = ToolWindowManager.getInstance(searchContext.getProject()).getToolWindow(ToolWindowId.FIND);
openInNewTab.setEnabled(findWindow != null && findWindow.isAvailable());
panel.add(openInNewTab, BorderLayout.EAST);
@@ -869,8 +867,9 @@ public class SearchDialog extends DialogWrapper implements ConfigurationCreator
super.doOKAction();
if (!myRunFindActionOnClose) return;
FindSettings.getInstance().setDefaultScopeName(selectedScope.getDisplayName());
ourOpenInNewTab = openInNewTab.isSelected();
final FindSettings findSettings = FindSettings.getInstance();
findSettings.setDefaultScopeName(selectedScope.getDisplayName());
findSettings.setShowResultsInSeparateView(openInNewTab.isSelected());
try {
if (model.getShadowConfig() != null) {
@@ -52,6 +52,10 @@ public abstract class TestTreeView extends Tree implements DataProvider, CopyPro
public abstract AbstractTestProxy getSelectedTest(@NotNull TreePath selectionPath);
protected TestFrameworkRunningModel getTestFrameworkRunningModel() {
return myModel;
}
@Nullable
public AbstractTestProxy getSelectedTest() {
TreePath[] paths = getSelectionPaths();
@@ -41,7 +41,6 @@ import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.psi.util.PsiUtilBase;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.popup.NotLookupOrSearchCondition;
import com.intellij.util.Processor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -138,7 +137,6 @@ public class ShowByteCodeAction extends AnAction {
};
final JBPopup popup = JBPopupFactory.getInstance().createComponentPopupBuilder(component, null)
.setRequestFocusCondition(project, NotLookupOrSearchCondition.INSTANCE)
.setProject(project)
.setDimensionServiceKey(project, DocumentationManager.JAVADOC_LOCATION_AND_SIZE, false)
.setResizable(true)
@@ -21,7 +21,6 @@ import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.searches.OverridingMethodsSearch;
import com.intellij.util.Query;
import com.siyeh.InspectionGadgetsBundle;
@@ -64,9 +63,9 @@ public class TypeMayBeWeakenedInspection extends BaseInspection {
@NonNls final StringBuilder builder = new StringBuilder();
final Iterator<PsiClass> iterator = weakerClasses.iterator();
if (iterator.hasNext()) {
builder.append('\'').append(iterator.next().getQualifiedName()).append('\'');
builder.append('\'').append(getClassName(iterator.next())).append('\'');
while (iterator.hasNext()) {
builder.append(", '").append(iterator.next().getQualifiedName()).append('\'');
builder.append(", '").append(getClassName(iterator.next())).append('\'');
}
}
final Object info = infos[0];
@@ -85,6 +84,14 @@ public class TypeMayBeWeakenedInspection extends BaseInspection {
return InspectionGadgetsBundle.message("type.may.be.weakened.problem.descriptor", builder.toString());
}
private static String getClassName(PsiClass aClass) {
final String qualifiedName = aClass.getQualifiedName();
if (qualifiedName == null) {
return aClass.getName();
}
return qualifiedName;
}
@Override
@Nullable
public JComponent createOptionsPanel() {
@@ -106,11 +113,11 @@ public class TypeMayBeWeakenedInspection extends BaseInspection {
final Iterable<PsiClass> weakerClasses = (Iterable<PsiClass>)infos[1];
final Collection<InspectionGadgetsFix> fixes = new ArrayList();
for (PsiClass weakestClass : weakerClasses) {
final String qualifiedName = weakestClass.getQualifiedName();
if (qualifiedName == null) {
final String className = getClassName(weakestClass);
if (className == null) {
continue;
}
fixes.add(new TypeMayBeWeakenedFix(qualifiedName));
fixes.add(new TypeMayBeWeakenedFix(className));
}
return fixes.toArray(new InspectionGadgetsFix[fixes.size()]);
}
@@ -162,31 +169,30 @@ public class TypeMayBeWeakenedInspection extends BaseInspection {
if (!(oldType instanceof PsiClassType)) {
return;
}
final PsiClassType classType = (PsiClassType)oldType;
final PsiType[] parameterTypes = classType.getParameters();
final GlobalSearchScope scope = element.getResolveScope();
final PsiClassType oldClassType = (PsiClassType)oldType;
final PsiType[] parameterTypes = oldClassType.getParameters();
final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
final PsiClass aClass = facade.findClass(fqClassName, scope);
if (aClass == null) {
final PsiElementFactory factory = facade.getElementFactory();
final PsiType type = factory.createTypeFromText(fqClassName, element);
if (!(type instanceof PsiClassType)) {
return;
}
final PsiTypeParameter[] typeParameters = aClass.getTypeParameters();
final PsiElementFactory factory = facade.getElementFactory();
final PsiClassType type;
if (typeParameters.length != 0 && typeParameters.length == parameterTypes.length) {
final Map<PsiTypeParameter, PsiType> typeParameterMap = new HashMap();
for (int i = 0; i < typeParameters.length; i++) {
final PsiTypeParameter typeParameter = typeParameters[i];
final PsiType parameterType = parameterTypes[i];
typeParameterMap.put(typeParameter, parameterType);
PsiClassType classType = (PsiClassType)type;
final PsiClass aClass = classType.resolve();
if (aClass != null) {
final PsiTypeParameter[] typeParameters = aClass.getTypeParameters();
if (typeParameters.length != 0 && typeParameters.length == parameterTypes.length) {
final Map<PsiTypeParameter, PsiType> typeParameterMap = new HashMap();
for (int i = 0; i < typeParameters.length; i++) {
final PsiTypeParameter typeParameter = typeParameters[i];
final PsiType parameterType = parameterTypes[i];
typeParameterMap.put(typeParameter, parameterType);
}
final PsiSubstitutor substitutor = factory.createSubstitutor(typeParameterMap);
classType = factory.createType(aClass, substitutor);
}
final PsiSubstitutor substitutor = factory.createSubstitutor(typeParameterMap);
type = factory.createType(aClass, substitutor);
}
else {
type = factory.createTypeByFQClassName(fqClassName, scope);
}
final PsiJavaCodeReferenceElement referenceElement = factory.createReferenceElementByType(type);
final PsiJavaCodeReferenceElement referenceElement = factory.createReferenceElementByType(classType);
final PsiElement replacement = componentReferenceElement.replace(referenceElement);
final JavaCodeStyleManager javaCodeStyleManager = JavaCodeStyleManager.getInstance(project);
javaCodeStyleManager.shortenClassReferences(replacement);
@@ -64,6 +64,9 @@ public class EqualsWithItselfInspection extends BaseInspection {
}
final PsiExpressionList argumentList = expression.getArgumentList();
final PsiExpression[] arguments = argumentList.getExpressions();
if (arguments.length != 1) {
return;
}
final PsiExpression argument = arguments[0];
if (!EquivalenceChecker.expressionsAreEquivalent(qualifier, argument) ||
SideEffectChecker.mayHaveSideEffects(qualifier)) {
@@ -0,0 +1,11 @@
class LocalClass {
void foo() {
class A<T> {
void foo() {}
}
class B<T> extends A<T> {}
A<String> bb = new B();
bb.foo();
}
}
@@ -0,0 +1,11 @@
class LocalClass {
void foo() {
class A<T> {
void foo() {}
}
class B<T> extends A<T> {}
B<String> b<caret>b = new B();
bb.foo();
}
}
@@ -162,4 +162,15 @@ class Test implements Foo2 {
interface Foo {
void bar();
}
interface Foo2 extends Foo {}
interface Foo2 extends Foo {}
class Helper {
void foo() {
class A<T> {
void foo() {}
}
class B<T> extends A<T> {}
B<String> <warning descr="Type of variable 'b' may be weakened to 'A'">b</warning> = new B();
b.foo();
}
}
@@ -12,10 +12,13 @@ public class TypeMayBeWeakenedFixTest extends IGQuickFixesTestCase {
@Override
public void setUp() throws Exception {
super.setUp();
myFixture.enableInspections(new TypeMayBeWeakenedInspection());
final TypeMayBeWeakenedInspection inspection = new TypeMayBeWeakenedInspection();
inspection.onlyWeakentoInterface = false;
myFixture.enableInspections(inspection);
myRelativePath = "abstraction/type_may_be_weakened";
}
public void testShorten() { doTest(InspectionGadgetsBundle.message("type.may.be.weakened.quickfix", "java.util.Collection")); }
public void testLocalClass() { doTest(InspectionGadgetsBundle.message("type.may.be.weakened.quickfix", "A")); }
}
@@ -18,8 +18,11 @@ package com.theoryinpractice.testng.inspection;
import com.intellij.codeInsight.AnnotationUtil;
import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.containers.ContainerUtil;
import com.theoryinpractice.testng.util.TestNGUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -35,7 +38,7 @@ import java.util.regex.Pattern;
public class DependsOnMethodInspection extends BaseJavaLocalInspectionTool
{
private static final Logger LOGGER = Logger.getInstance("TestNG Runner");
private static final Pattern PATTERN = Pattern.compile("\"([a-zA-Z1-9_\\(\\)]*)\"");
private static final Pattern PATTERN = Pattern.compile("\"([a-zA-Z1-9_\\(\\)\\*]*)\"");
@NotNull
@Override
@@ -107,7 +110,19 @@ public class DependsOnMethodInspection extends BaseJavaLocalInspectionTool
} else {
final String configAnnotation = TestNGUtil.getConfigAnnotation(PsiTreeUtil.getParentOfType(value, PsiMethod.class));
PsiMethod[] foundMethods = psiClass.findMethodsByName(methodName, true);
final PsiMethod[] foundMethods;
if (methodName.endsWith("*")) {
final String methodNameMask = StringUtil.trimEnd(methodName, "*");
final List<PsiMethod> methods = ContainerUtil.filter(psiClass.getMethods(), new Condition<PsiMethod>() {
@Override
public boolean value(PsiMethod method) {
return method.getName().startsWith(methodNameMask);
}
});
foundMethods = methods.toArray(new PsiMethod[methods.size()]);
} else {
foundMethods = psiClass.findMethodsByName(methodName, true);
}
if (foundMethods.length == 0) {
LOGGER.debug("dependsOnMethods method doesn't exist:" + methodName);
ProblemDescriptor descriptor = manager.createProblemDescriptor(value,
@@ -16,6 +16,7 @@
package com.theoryinpractice.testng.ui;
import com.intellij.execution.testframework.PoolOfTestIcons;
import com.intellij.execution.testframework.TestFrameworkRunningModel;
import com.intellij.icons.AllIcons;
import com.intellij.ui.ColoredTreeCellRenderer;
import com.intellij.ui.SimpleTextAttributes;
@@ -34,10 +35,11 @@ import javax.swing.tree.DefaultMutableTreeNode;
*/
public class ResultTreeRenderer extends ColoredTreeCellRenderer
{
private final TestNGConsoleProperties consoleProperties;
public ResultTreeRenderer(TestNGConsoleProperties consoleProperties) {
this.consoleProperties = consoleProperties;
private TestFrameworkRunningModel model;
public ResultTreeRenderer(TestFrameworkRunningModel model) {
this.model = model;
}
@Override
@@ -47,7 +49,7 @@ public class ResultTreeRenderer extends ColoredTreeCellRenderer
TestProxy proxy = ((TestNodeDescriptor) node.getUserObject()).getElement();
if (node == tree.getModel().getRoot()) {
TreeRootNode root = (TreeRootNode) proxy;
if (node.getChildCount() == 0) {
if (node.getChildCount() == 0 && !((TestNGResults)model).hasFinishedTests()) {
if ((root.isStarted() && root.isInProgress()) || (root.isInProgress() && !root.isStarted())) {
setIcon(PoolOfTestIcons.NOT_RAN);
append("Instantiating tests... ", SimpleTextAttributes.REGULAR_ATTRIBUTES);
@@ -64,13 +66,13 @@ public class ResultTreeRenderer extends ColoredTreeCellRenderer
append(root.isInProgress() ? "Running tests..." : "Test Results", SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
if (consoleProperties.isPaused()) {
if (model.getProperties().isPaused()) {
setIcon(AllIcons.RunConfigurations.TestPaused);
}
} else {
if (proxy.getResultMessage() != null) {
final TestResultMessage result = proxy.getResultMessage();
final String name = TestProxy.toDisplayText(result, consoleProperties.getProject());
final String name = TestProxy.toDisplayText(result, model.getProperties().getProject());
append(name, SimpleTextAttributes.REGULAR_ATTRIBUTES);
} else {
append(proxy.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
@@ -466,6 +466,10 @@ public class TestNGResults extends TestResultsPanel implements TestFrameworkRunn
this.failedToStart = failedToStart;
}
public boolean hasFinishedTests() {
return count > 0;
}
private class OpenSourceSelectionListener implements TreeSelectionListener {
public void valueChanged(TreeSelectionEvent e) {
@@ -33,7 +33,7 @@ import javax.swing.tree.TreeSelectionModel;
public class TestNGTestTreeView extends TestTreeView {
protected TreeCellRenderer getRenderer(final TestConsoleProperties properties) {
return new ResultTreeRenderer((TestNGConsoleProperties)properties);
return new ResultTreeRenderer(getTestFrameworkRunningModel());
}
public TestProxy getSelectedTest(@NotNull TreePath treepath) {
@@ -8,25 +8,26 @@ import com.intellij.execution.actions.JavaRerunFailedTestsAction;
import com.intellij.execution.configurations.RunProfileState;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.testframework.AbstractTestProxy;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComponentContainer;
import com.intellij.openapi.util.Computable;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiModifier;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.util.containers.ContainerUtil;
import com.theoryinpractice.testng.configuration.SearchingForTestsTask;
import com.theoryinpractice.testng.configuration.TestNGConfiguration;
import com.theoryinpractice.testng.configuration.TestNGRunnableState;
import com.theoryinpractice.testng.util.TestNGUtil;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.net.ServerSocket;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.*;
public class RerunFailedTestsAction extends JavaRerunFailedTestsAction {
@@ -53,6 +54,19 @@ public class RerunFailedTestsAction extends JavaRerunFailedTestsAction {
return new SearchingForTestsTask(serverSocket, config, tempFile, client) {
@Override
protected void fillTestObjects(final Map<PsiClass, Collection<PsiMethod>> classes) throws CantRunException {
final HashMap<PsiClass, Collection<PsiMethod>> fullClassList = ContainerUtil.newHashMap();
super.fillTestObjects(fullClassList);
for (final PsiClass aClass : fullClassList.keySet()) {
if (!ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
return TestNGUtil.hasTest(aClass);
}
})) {
classes.put(aClass, fullClassList.get(aClass));
}
}
final GlobalSearchScope scope = config.getConfigurationModule().getSearchScope();
final Project project = config.getProject();
for (AbstractTestProxy proxy : failedTests) {
@@ -113,25 +113,27 @@ public class TestNGUtil {
private static final String SUITE_TAG_NAME = "suite";
public static boolean hasConfig(PsiModifierListOwner element) {
PsiMethod[] methods;
if (element instanceof PsiClass) {
methods = ((PsiClass) element).getMethods();
for (PsiMethod method : ((PsiClass)element).getAllMethods()) {
if (isConfigMethod(method)) return true;
}
} else {
if (!(element instanceof PsiMethod)) return false;
methods = new PsiMethod[] {(PsiMethod) element};
return isConfigMethod((PsiMethod)element);
}
return false;
}
private static boolean isConfigMethod(PsiMethod method) {
for (String fqn : CONFIG_ANNOTATIONS_FQN) {
if (AnnotationUtil.isAnnotated(method, fqn, false)) return true;
}
for (PsiMethod method : methods) {
for (String fqn : CONFIG_ANNOTATIONS_FQN) {
if (AnnotationUtil.isAnnotated(method, fqn, false)) return true;
}
if (hasDocTagsSupport) {
final PsiDocComment comment = method.getDocComment();
if (comment != null) {
for (String javadocTag : CONFIG_JAVADOC_TAGS) {
if (comment.findTagByName(javadocTag) != null) return true;
}
if (hasDocTagsSupport) {
final PsiDocComment comment = method.getDocComment();
if (comment != null) {
for (String javadocTag : CONFIG_JAVADOC_TAGS) {
if (comment.findTagByName(javadocTag) != null) return true;
}
}
}
@@ -14,6 +14,12 @@ import org.testng.annotations.*;
@BeforeMethod(dependsOnMethods = <warning descr="Method 'afterSuiteMethod' is not annotated with @org.testng.annotations.BeforeMethod">"afterSuiteMethod"</warning>)
public final void beforeMethod() throws Throwable {
}
}
@Test(dependsOnMethods = <warning descr="Method 'foo*' unknown.">"foo*"</warning>)
public void testBar2() {}
@Test(dependsOnMethods = "testBa*")
public void testBar1() {}
}
@@ -33,7 +33,6 @@ import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.popup.NotLookupOrSearchCondition;
import java.awt.*;
@@ -101,7 +100,6 @@ public class ShowJavadoc extends AnAction implements IPropertyTableAction {
public void run() {
JBPopup hint =
JBPopupFactory.getInstance().createComponentPopupBuilder(component, component)
.setRequestFocusCondition(project, NotLookupOrSearchCondition.INSTANCE)
.setProject(project)
.setDimensionServiceKey(project, DocumentationManager.JAVADOC_LOCATION_AND_SIZE, false)
.setResizable(true)