)() -> XDebuggerManager.getInstance(myProject).getBreakpointManager().addBreakpoint((XBreakpointType)type, type.createProperties()));
+ return WriteAction.compute(() -> XDebuggerManager.getInstance(myProject).getBreakpointManager().addBreakpoint((XBreakpointType)type, type.createProperties()));
}
private > XLineBreakpoint createXLineBreakpoint(Class extends XBreakpointType> typeCls,
@@ -479,7 +479,7 @@ public class BreakpointManager {
if (breakpoint == null) {
return;
}
- ApplicationManager.getApplication().runWriteAction(() -> getXBreakpointManager().removeBreakpoint(breakpoint.myXBreakpoint));
+ WriteAction.run(() -> getXBreakpointManager().removeBreakpoint(breakpoint.myXBreakpoint));
}
public void writeExternal(@NotNull final Element parentNode) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java
index 8ccee6bf428a..075239a3991c 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java
@@ -25,11 +25,11 @@ import com.intellij.debugger.engine.requests.RequestManagerImpl;
import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.vfs.VirtualFile;
@@ -184,12 +184,7 @@ public abstract class BreakpointWithHighlighter() {
- @Override
- public Boolean compute() {
- return sourcePosition != null && sourcePosition.getFile().isValid();
- }
- }).booleanValue();
+ return ReadAction.compute(() -> sourcePosition != null && sourcePosition.getFile().isValid()).booleanValue();
}
@Nullable
@@ -344,13 +339,7 @@ public abstract class BreakpointWithHighlighter
() {
- @Nullable
- @Override
- public PsiClass compute() {
- return JVMNameUtil.getClassAt(sourcePosition);
- }
- });
+ return ReadAction.compute(() -> JVMNameUtil.getClassAt(sourcePosition));
}
@Override
@@ -403,13 +392,8 @@ public abstract class BreakpointWithHighlighter
() {
- @Override
- public String compute() {
- return CommonXmlStrings.HTML_START + CommonXmlStrings.BODY_START
- + getDescription()
- + CommonXmlStrings.BODY_END + CommonXmlStrings.HTML_END;
- }
- });
+ return ReadAction.compute(() -> CommonXmlStrings.HTML_START + CommonXmlStrings.BODY_START
+ + getDescription()
+ + CommonXmlStrings.BODY_END + CommonXmlStrings.HTML_END);
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpoint.java
index 956630d0c763..6db976eb4446 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpoint.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/ExceptionBreakpoint.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2016 JetBrains s.r.o.
+ * Copyright 2000-2017 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.
@@ -29,11 +29,9 @@ import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
import com.intellij.debugger.engine.requests.RequestManagerImpl;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.icons.AllIcons;
-import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.JDOMExternalizerUtil;
import com.intellij.openapi.util.Key;
@@ -122,12 +120,9 @@ public class ExceptionBreakpoint extends Breakpoint() {
- public SourcePosition compute() {
- PsiClass psiClass = DebuggerUtils.findClass(getQualifiedName(), myProject, debugProcess.getSearchScope());
-
- return psiClass != null ? SourcePosition.createFromElement(psiClass) : null;
- }
+ SourcePosition classPosition = ReadAction.compute(() -> {
+ PsiClass psiClass = DebuggerUtils.findClass(getQualifiedName(), myProject, debugProcess.getSearchScope());
+ return psiClass != null ? SourcePosition.createFromElement(psiClass) : null;
});
if(classPosition == null) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaExceptionBreakpointType.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaExceptionBreakpointType.java
index b4883e10f48a..3af57ecf8035 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaExceptionBreakpointType.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaExceptionBreakpointType.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2015 JetBrains s.r.o.
+ * Copyright 2000-2017 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.
@@ -21,9 +21,8 @@ import com.intellij.debugger.engine.JVMNameUtil;
import com.intellij.icons.AllIcons;
import com.intellij.ide.util.TreeClassChooser;
import com.intellij.ide.util.TreeClassChooserFactory;
-import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Computable;
import com.intellij.psi.CommonClassNames;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiClass;
@@ -128,13 +127,8 @@ public class JavaExceptionBreakpointType extends JavaBreakpointTypeBase 0) {
- return ApplicationManager.getApplication().runWriteAction(new Computable>() {
- @Override
- public XBreakpoint compute() {
- return XDebuggerManager.getInstance(project).getBreakpointManager().addBreakpoint(
- JavaExceptionBreakpointType.this, new JavaExceptionBreakpointProperties(qName, ((PsiClassOwner)selectedClass.getContainingFile()).getPackageName()));
- }
- });
+ return WriteAction.compute(() -> XDebuggerManager.getInstance(project).getBreakpointManager()
+ .addBreakpoint(this, new JavaExceptionBreakpointProperties(qName, ((PsiClassOwner)selectedClass.getContainingFile()).getPackageName())));
}
return null;
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaFieldBreakpointType.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaFieldBreakpointType.java
index d40bc8023c8c..410a8221b751 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaFieldBreakpointType.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaFieldBreakpointType.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2015 JetBrains s.r.o.
+ * Copyright 2000-2017 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.
@@ -19,7 +19,7 @@ import com.intellij.CommonBundle;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.HelpID;
import com.intellij.icons.AllIcons;
-import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
@@ -146,7 +146,7 @@ public class JavaFieldBreakpointType extends JavaLineBreakpointTypeBase {
+ WriteAction.run(() -> {
XLineBreakpoint fieldBreakpoint = XDebuggerManager.getInstance(project).getBreakpointManager()
.addLineBreakpoint(JavaFieldBreakpointType.this, psiFile.getVirtualFile().getUrl(), line, new JavaFieldBreakpointProperties(fieldName, className));
result.set(fieldBreakpoint);
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaWildcardMethodBreakpointType.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaWildcardMethodBreakpointType.java
index 990850708e55..ecab88d344bd 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaWildcardMethodBreakpointType.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/JavaWildcardMethodBreakpointType.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2016 JetBrains s.r.o.
+ * Copyright 2000-2017 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.
@@ -18,9 +18,8 @@ package com.intellij.debugger.ui.breakpoints;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.HelpID;
import com.intellij.icons.AllIcons;
-import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.xdebugger.XDebuggerManager;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
@@ -104,7 +103,7 @@ public class JavaWildcardMethodBreakpointType extends JavaBreakpointTypeBase>)() -> {
+ return WriteAction.compute(() -> {
JavaMethodBreakpointProperties properties = new JavaMethodBreakpointProperties(dialog.getClassPattern(), dialog.getMethodName());
if (Registry.is("debugger.emulate.method.breakpoints")) {
properties.EMULATED = true; // create all new emulated
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpoint.java
index 052ac43562f8..e28d980600bf 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpoint.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpoint.java
@@ -31,7 +31,6 @@ import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.debugger.jdi.StackFrameProxyImpl;
import com.intellij.icons.AllIcons;
-import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
@@ -39,7 +38,6 @@ import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.roots.ProjectRootManager;
-import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.vfs.VirtualFile;
@@ -269,46 +267,42 @@ public class LineBreakpoint extends Breakpoi
private Collection findClassCandidatesInSourceContent(final String className, final GlobalSearchScope scope, final ProjectFileIndex fileIndex) {
final int dollarIndex = className.indexOf("$");
final String topLevelClassName = dollarIndex >= 0? className.substring(0, dollarIndex) : className;
- return ApplicationManager.getApplication().runReadAction(new Computable>() {
- @Override
- @Nullable
- public Collection compute() {
- final PsiClass[] classes = JavaPsiFacade.getInstance(myProject).findClasses(topLevelClassName, scope);
+ return ReadAction.compute(() -> {
+ final PsiClass[] classes = JavaPsiFacade.getInstance(myProject).findClasses(topLevelClassName, scope);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Found "+ classes.length + " classes " + topLevelClassName + " in scope "+scope);
+ }
+ if (classes.length == 0) {
+ return null;
+ }
+ final List list = new ArrayList<>(classes.length);
+ for (PsiClass aClass : classes) {
+ final PsiFile psiFile = aClass.getContainingFile();
+
if (LOG.isDebugEnabled()) {
- LOG.debug("Found "+ classes.length + " classes " + topLevelClassName + " in scope "+scope);
+ final StringBuilder msg = new StringBuilder();
+ msg.append("Checking class ").append(aClass.getQualifiedName());
+ msg.append("\n\t").append("PsiFile=").append(psiFile);
+ if (psiFile != null) {
+ final VirtualFile vFile = psiFile.getVirtualFile();
+ msg.append("\n\t").append("VirtualFile=").append(vFile);
+ if (vFile != null) {
+ msg.append("\n\t").append("isInSourceContent=").append(fileIndex.isUnderSourceRootOfType(vFile, JavaModuleSourceRootTypes.SOURCES));
+ }
+ }
+ LOG.debug(msg.toString());
}
- if (classes.length == 0) {
+
+ if (psiFile == null) {
return null;
}
- final List list = new ArrayList<>(classes.length);
- for (PsiClass aClass : classes) {
- final PsiFile psiFile = aClass.getContainingFile();
-
- if (LOG.isDebugEnabled()) {
- final StringBuilder msg = new StringBuilder();
- msg.append("Checking class ").append(aClass.getQualifiedName());
- msg.append("\n\t").append("PsiFile=").append(psiFile);
- if (psiFile != null) {
- final VirtualFile vFile = psiFile.getVirtualFile();
- msg.append("\n\t").append("VirtualFile=").append(vFile);
- if (vFile != null) {
- msg.append("\n\t").append("isInSourceContent=").append(fileIndex.isUnderSourceRootOfType(vFile, JavaModuleSourceRootTypes.SOURCES));
- }
- }
- LOG.debug(msg.toString());
- }
-
- if (psiFile == null) {
- return null;
- }
- final VirtualFile vFile = psiFile.getVirtualFile();
- if (vFile == null || !fileIndex.isUnderSourceRootOfType(vFile, JavaModuleSourceRootTypes.SOURCES)) {
- return null; // this will switch off the check if at least one class is from libraries
- }
- list.add(vFile);
+ final VirtualFile vFile = psiFile.getVirtualFile();
+ if (vFile == null || !fileIndex.isUnderSourceRootOfType(vFile, JavaModuleSourceRootTypes.SOURCES)) {
+ return null; // this will switch off the check if at least one class is from libraries
}
- return list;
+ list.add(vFile);
}
+ return list;
});
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java
index 4c9e8cb5a2d4..6ab93c6116af 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java
@@ -36,6 +36,7 @@ import com.intellij.debugger.jdi.MethodBytecodeUtil;
import com.intellij.debugger.requests.Requestor;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.progress.ProgressIndicator;
@@ -43,7 +44,10 @@ import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.util.ProgressWindow;
import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.*;
+import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.util.InvalidDataException;
+import com.intellij.openapi.util.JDOMExternalizerUtil;
+import com.intellij.openapi.util.Key;
import com.intellij.psi.*;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.util.containers.ContainerUtil;
@@ -441,37 +445,34 @@ public class MethodBreakpoint extends BreakpointWithHighlighter() {
// conflicts with readAction on initial breakpoints creation
- final MethodDescriptor descriptor = ApplicationManager.getApplication().runReadAction(new Computable() {
- @Nullable
- public MethodDescriptor compute() {
- //PsiMethod method = DebuggerUtilsEx.findPsiMethod(psiJavaFile, endOffset);
- PsiMethod method = PositionUtil.getPsiElementAt(project, PsiMethod.class, sourcePosition);
- if (method == null) {
- return null;
- }
- final int methodOffset = method.getTextOffset();
- if (methodOffset < 0) {
- return null;
- }
- if (document.getLineNumber(methodOffset) < sourcePosition.getLine()) {
- return null;
- }
-
- final PsiIdentifier identifier = method.getNameIdentifier();
- int methodNameOffset = identifier != null? identifier.getTextOffset() : methodOffset;
- final MethodDescriptor descriptor =
- new MethodDescriptor();
- descriptor.methodName = JVMNameUtil.getJVMMethodName(method);
- try {
- descriptor.methodSignature = JVMNameUtil.getJVMSignature(method);
- descriptor.isStatic = method.hasModifierProperty(PsiModifier.STATIC);
- }
- catch (IndexNotReadyException ignored) {
- return null;
- }
- descriptor.methodLine = document.getLineNumber(methodNameOffset);
- return descriptor;
+ final MethodDescriptor descriptor = ReadAction.compute(() -> {
+ //PsiMethod method = DebuggerUtilsEx.findPsiMethod(psiJavaFile, endOffset);
+ PsiMethod method = PositionUtil.getPsiElementAt(project, PsiMethod.class, sourcePosition);
+ if (method == null) {
+ return null;
}
+ final int methodOffset = method.getTextOffset();
+ if (methodOffset < 0) {
+ return null;
+ }
+ if (document.getLineNumber(methodOffset) < sourcePosition.getLine()) {
+ return null;
+ }
+
+ final PsiIdentifier identifier = method.getNameIdentifier();
+ int methodNameOffset = identifier != null? identifier.getTextOffset() : methodOffset;
+ final MethodDescriptor res =
+ new MethodDescriptor();
+ res.methodName = JVMNameUtil.getJVMMethodName(method);
+ try {
+ res.methodSignature = JVMNameUtil.getJVMSignature(method);
+ res.isStatic = method.hasModifierProperty(PsiModifier.STATIC);
+ }
+ catch (IndexNotReadyException ignored) {
+ return null;
+ }
+ res.methodLine = document.getLineNumber(methodNameOffset);
+ return res;
});
if (descriptor == null || descriptor.methodName == null || descriptor.methodSignature == null) {
return null;
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeRenderer.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeRenderer.java
index fb8a715d3a88..944e32e0c436 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeRenderer.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreeRenderer.java
@@ -19,6 +19,7 @@ import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.debugger.ui.impl.watch.*;
+import com.intellij.debugger.ui.tree.NodeDescriptor;
import com.intellij.debugger.ui.tree.ValueDescriptor;
import com.intellij.debugger.ui.tree.render.EnumerationChildrenRenderer;
import com.intellij.icons.AllIcons;
@@ -62,7 +63,7 @@ public class DebuggerTreeRenderer extends ColoredTreeCellRenderer {
}
@Nullable
- public static Icon getDescriptorIcon(NodeDescriptorImpl descriptor) {
+ public static Icon getDescriptorIcon(NodeDescriptor descriptor) {
Icon nodeIcon = null;
if (descriptor instanceof ThreadGroupDescriptorImpl) {
nodeIcon = (((ThreadGroupDescriptorImpl)descriptor).isCurrent() ? AllIcons.Debugger.ThreadGroupCurrent : AllIcons.Debugger.ThreadGroup);
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ArrayRenderer.java b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ArrayRenderer.java
index 599eabc1d9c6..da962f223050 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ArrayRenderer.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ArrayRenderer.java
@@ -22,7 +22,6 @@ import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluationContext;
import com.intellij.debugger.settings.ViewsGeneralSettings;
import com.intellij.debugger.ui.impl.watch.ArrayElementDescriptorImpl;
-import com.intellij.debugger.ui.impl.watch.MessageDescriptor;
import com.intellij.debugger.ui.impl.watch.NodeManagerImpl;
import com.intellij.debugger.ui.tree.DebuggerTreeNode;
import com.intellij.debugger.ui.tree.NodeDescriptor;
@@ -37,6 +36,7 @@ import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiElementFactory;
import com.intellij.psi.PsiExpression;
+import com.intellij.ui.SimpleTextAttributes;
import com.intellij.util.IncorrectOperationException;
import com.sun.jdi.ArrayReference;
import com.sun.jdi.ArrayType;
@@ -45,8 +45,7 @@ import com.sun.jdi.Value;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Collections;
/**
* User: lex
@@ -58,11 +57,6 @@ public class ArrayRenderer extends NodeRendererImpl{
public static final @NonNls String UNIQUE_ID = "ArrayRenderer";
- public static final MessageDescriptor ALL_ELEMENTS_IN_RANGE_ARE_NULL =
- new MessageDescriptor(DebuggerBundle.message("message.node.all.elements.null"));
- public static final MessageDescriptor HIDDEN_NULL_ELEMENTS =
- new MessageDescriptor(DebuggerBundle.message("message.node.elements.null.hidden"));
-
public int START_INDEX = 0;
public int END_INDEX = 100;
public int ENTRIES_LIMIT = 101;
@@ -99,7 +93,6 @@ public class ArrayRenderer extends NodeRendererImpl{
public void buildChildren(Value value, ChildrenBuilder builder, EvaluationContext evaluationContext) {
DebuggerManagerThreadImpl.assertIsManagerThread();
- List children = new ArrayList<>();
NodeManagerImpl nodeManager = (NodeManagerImpl)builder.getNodeManager();
NodeDescriptorFactory descriptorFactory = builder.getDescriptorManager();
@@ -133,7 +126,7 @@ public class ArrayRenderer extends NodeRendererImpl{
continue;
}
- children.add(arrayItemNode);
+ builder.addChildren(Collections.singletonList(arrayItemNode), false);
added++;
if (added > ENTRIES_LIMIT) {
break;
@@ -141,24 +134,26 @@ public class ArrayRenderer extends NodeRendererImpl{
}
}
+ builder.addChildren(Collections.emptyList(), true);
+
if (added == 0) {
if (START_INDEX == 0 && array.length() - 1 <= END_INDEX) {
- children.add(nodeManager.createMessageNode(ALL_ELEMENTS_IN_RANGE_ARE_NULL));
+ builder.setMessage(DebuggerBundle.message("message.node.all.elements.null"), null, SimpleTextAttributes.REGULAR_ATTRIBUTES, null);
}
else {
- children.add(nodeManager.createMessageNode(DebuggerBundle.message("message.node.all.array.elements.null", START_INDEX, END_INDEX)));
+ builder.setMessage(DebuggerBundle.message("message.node.all.array.elements.null", START_INDEX, END_INDEX), null,
+ SimpleTextAttributes.REGULAR_ATTRIBUTES, null);
}
}
else {
if (hiddenNulls) {
- children.add(0, nodeManager.createMessageNode(HIDDEN_NULL_ELEMENTS));
+ builder.setMessage(DebuggerBundle.message("message.node.elements.null.hidden"), null, SimpleTextAttributes.REGULAR_ATTRIBUTES, null);
}
if (!myForced && END_INDEX < array.length() - 1) {
builder.setRemaining(array.length() - 1 - END_INDEX);
}
}
}
- builder.setChildren(children);
}
private static boolean elementIsNull(ArrayReference arrayReference, int index) {
@@ -200,6 +195,6 @@ public class ArrayRenderer extends NodeRendererImpl{
}
public boolean isApplicable(Type type) {
- return (type instanceof ArrayType);
+ return type instanceof ArrayType;
}
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ChildrenBuilder.java b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ChildrenBuilder.java
index e98867a81496..416089ed0de7 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ChildrenBuilder.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ChildrenBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2017 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.
@@ -16,7 +16,12 @@
package com.intellij.debugger.ui.tree.render;
import com.intellij.debugger.ui.tree.*;
+import com.intellij.ui.SimpleTextAttributes;
+import com.intellij.xdebugger.frame.XDebuggerTreeNodeHyperlink;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import javax.swing.*;
import java.util.List;
public interface ChildrenBuilder {
@@ -28,6 +33,16 @@ public interface ChildrenBuilder {
void setChildren(List children);
+ default void addChildren(List children, boolean last) {
+ setChildren(children);
+ }
+
+ default void setMessage(@NotNull String message,
+ @Nullable Icon icon,
+ @NotNull SimpleTextAttributes attributes,
+ @Nullable XDebuggerTreeNodeHyperlink link) {
+ }
+
void setRemaining(int remaining);
void initChildrenArrayRenderer(ArrayRenderer renderer);
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/UnboxableTypeRenderer.java b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/UnboxableTypeRenderer.java
new file mode 100644
index 000000000000..a76516600258
--- /dev/null
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/UnboxableTypeRenderer.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2000-2017 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.debugger.ui.tree.render;
+
+import com.intellij.debugger.engine.DebuggerUtils;
+import com.intellij.debugger.engine.evaluation.EvaluateException;
+import com.intellij.debugger.engine.evaluation.EvaluationContext;
+import com.intellij.debugger.engine.evaluation.expression.UnBoxingEvaluator;
+import com.intellij.debugger.settings.NodeRendererSettings;
+import com.intellij.debugger.ui.tree.ValueDescriptor;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.CommonClassNames;
+import com.sun.jdi.ObjectReference;
+import com.sun.jdi.ReferenceType;
+import com.sun.jdi.Type;
+
+/**
+ * @author egor
+ */
+public abstract class UnboxableTypeRenderer extends CompoundReferenceRenderer {
+ public UnboxableTypeRenderer(String className, NodeRendererSettings rendererSettings) {
+ super(rendererSettings, StringUtil.getShortName(className), new LabelRenderer() {
+ @Override
+ public String calcLabel(ValueDescriptor descriptor, EvaluationContext evaluationContext, DescriptorLabelListener labelListener)
+ throws EvaluateException {
+ return DebuggerUtils.getValueAsString(evaluationContext, UnBoxingEvaluator.getInnerPrimitiveValue((ObjectReference)descriptor.getValue()));
+ }
+ }, null);
+ LOG.assertTrue(UnBoxingEvaluator.isTypeUnboxable(className));
+ setClassName(className);
+ setEnabled(true);
+ }
+
+ @Override
+ public boolean isApplicable(Type type) {
+ return type instanceof ReferenceType && StringUtil.equals(type.name(), getClassName());
+ }
+
+ public static class BooleanRenderer extends UnboxableTypeRenderer {
+ public BooleanRenderer(NodeRendererSettings rendererSettings) {
+ super(CommonClassNames.JAVA_LANG_BOOLEAN, rendererSettings);
+ }
+ }
+
+ public static class ByteRenderer extends UnboxableTypeRenderer {
+ public ByteRenderer(NodeRendererSettings rendererSettings) {
+ super(CommonClassNames.JAVA_LANG_BYTE, rendererSettings);
+ }
+ }
+
+ public static class CharacterRenderer extends UnboxableTypeRenderer {
+ public CharacterRenderer(NodeRendererSettings rendererSettings) {
+ super(CommonClassNames.JAVA_LANG_CHARACTER, rendererSettings);
+ }
+ }
+
+ public static class ShortRenderer extends UnboxableTypeRenderer {
+ public ShortRenderer(NodeRendererSettings rendererSettings) {
+ super(CommonClassNames.JAVA_LANG_SHORT, rendererSettings);
+ }
+ }
+
+ public static class IntegerRenderer extends UnboxableTypeRenderer {
+ public IntegerRenderer(NodeRendererSettings rendererSettings) {
+ super(CommonClassNames.JAVA_LANG_INTEGER, rendererSettings);
+ }
+ }
+
+ public static class LongRenderer extends UnboxableTypeRenderer {
+ public LongRenderer(NodeRendererSettings rendererSettings) {
+ super(CommonClassNames.JAVA_LANG_LONG, rendererSettings);
+ }
+ }
+
+ public static class FloatRenderer extends UnboxableTypeRenderer {
+ public FloatRenderer(NodeRendererSettings rendererSettings) {
+ super(CommonClassNames.JAVA_LANG_FLOAT, rendererSettings);
+ }
+ }
+
+ public static class DoubleRenderer extends UnboxableTypeRenderer {
+ public DoubleRenderer(NodeRendererSettings rendererSettings) {
+ super(CommonClassNames.JAVA_LANG_DOUBLE, rendererSettings);
+ }
+ }
+}
diff --git a/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java b/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java
index ef55ee92e099..a48a908d6c4c 100644
--- a/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java
+++ b/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java
@@ -72,20 +72,19 @@ public abstract class DebuggerUtils {
return ((StringReference)value).value();
}
if (isInteger(value)) {
- long v = ((PrimitiveValue)value).longValue();
- return String.valueOf(v);
+ return String.valueOf(((PrimitiveValue)value).longValue());
}
- if (isNumeric(value)) {
- double v = ((PrimitiveValue)value).doubleValue();
- return String.valueOf(v);
+ if (value instanceof FloatValue) {
+ return String.valueOf(((FloatValue)value).floatValue());
+ }
+ if (value instanceof DoubleValue) {
+ return String.valueOf(((DoubleValue)value).doubleValue());
}
if (value instanceof BooleanValue) {
- boolean v = ((PrimitiveValue)value).booleanValue();
- return String.valueOf(v);
+ return String.valueOf(((PrimitiveValue)value).booleanValue());
}
if (value instanceof CharValue) {
- char v = ((PrimitiveValue)value).charValue();
- return String.valueOf(v);
+ return String.valueOf(((PrimitiveValue)value).charValue());
}
if (value instanceof ObjectReference) {
if (value instanceof ArrayReference) {
diff --git a/java/debugger/openapi/src/com/intellij/debugger/engine/jdi/VirtualMachineProxy.java b/java/debugger/openapi/src/com/intellij/debugger/engine/jdi/VirtualMachineProxy.java
index ab116c9e2fc5..2c3f6bd3c8a1 100644
--- a/java/debugger/openapi/src/com/intellij/debugger/engine/jdi/VirtualMachineProxy.java
+++ b/java/debugger/openapi/src/com/intellij/debugger/engine/jdi/VirtualMachineProxy.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2017 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.
@@ -17,6 +17,7 @@ package com.intellij.debugger.engine.jdi;
import com.intellij.debugger.engine.DebugProcess;
import com.sun.jdi.ReferenceType;
+import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -40,5 +41,5 @@ public interface VirtualMachineProxy {
List nestedTypes(ReferenceType refType);
- List classesByName(String s);
+ List classesByName(@NotNull String s);
}
diff --git a/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java b/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java
index a9039bc4a830..86b394f2c5d9 100644
--- a/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java
+++ b/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java
@@ -246,12 +246,17 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration envs = getEnvs();
+ //if (!envs.isEmpty()) {
+ EnvironmentVariablesComponent.writeExternal(element, envs);
+ //}
}
public static class JavaApplicationCommandLineState extends BaseJavaApplicationCommandLineState {
@@ -297,15 +302,13 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration JavaModuleGraphUtil.findDescriptorByElement(module.findClass(params.getMainClass())));
+ if (mainModule != null) {
+ params.setModuleName(mainModule.getName());
+ PathsList classPath = params.getClassPath(), modulePath = params.getModulePath();
+ modulePath.addAll(classPath.getPathList());
+ classPath.clear();
}
}
}
diff --git a/java/execution/impl/src/com/intellij/execution/junit/JUnitUtil.java b/java/execution/impl/src/com/intellij/execution/junit/JUnitUtil.java
index 2fa79311b8c6..91bcef935b00 100644
--- a/java/execution/impl/src/com/intellij/execution/junit/JUnitUtil.java
+++ b/java/execution/impl/src/com/intellij/execution/junit/JUnitUtil.java
@@ -219,7 +219,7 @@ public class JUnitUtil {
return false;
}
- public static boolean isJUnit5TestClass(final PsiClass psiClass, boolean checkAbstract) {
+ public static boolean isJUnit5TestClass(@NotNull final PsiClass psiClass, boolean checkAbstract) {
final PsiModifierList modifierList = psiClass.getModifierList();
if (modifierList == null) return false;
diff --git a/java/execution/impl/src/com/intellij/execution/testframework/SearchForTestsTask.java b/java/execution/impl/src/com/intellij/execution/testframework/SearchForTestsTask.java
index 74a9f465a87c..6df268e6c6d2 100644
--- a/java/execution/impl/src/com/intellij/execution/testframework/SearchForTestsTask.java
+++ b/java/execution/impl/src/com/intellij/execution/testframework/SearchForTestsTask.java
@@ -15,6 +15,7 @@
*/
package com.intellij.execution.testframework;
+import com.intellij.concurrency.SensitiveProgressWrapper;
import com.intellij.execution.ExecutionBundle;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.process.OSProcessHandler;
@@ -27,6 +28,7 @@ import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.progress.impl.BackgroundableProcessIndicator;
+import com.intellij.openapi.progress.util.ProgressIndicatorUtils;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
@@ -36,6 +38,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
+import java.util.concurrent.atomic.AtomicBoolean;
public abstract class SearchForTestsTask extends Task.Backgroundable {
@@ -101,14 +104,16 @@ public abstract class SearchForTestsTask extends Task.Backgroundable {
try {
mySocket = myServerSocket.accept();
final ExecutionException[] ex = new ExecutionException[1];
- DumbService.getInstance(getProject()).repeatUntilPassesInSmartMode(() -> {
+ Runnable runnable = () -> {
try {
search();
}
catch (ExecutionException e) {
ex[0] = e;
}
- });
+ };
+ //noinspection StatementWithEmptyBody
+ while (!runSmartModeReadActionWithWritePriority(runnable, new SensitiveProgressWrapper(indicator)));
if (ex[0] != null) {
logCantRunException(ex[0]);
}
@@ -124,6 +129,35 @@ public abstract class SearchForTestsTask extends Task.Backgroundable {
}
}
+ /**
+ * @return true if runnable has been executed with no write action interference and in "smart" mode
+ */
+ private boolean runSmartModeReadActionWithWritePriority(@NotNull Runnable runnable, ProgressIndicator indicator) {
+ DumbService dumbService = DumbService.getInstance(myProject);
+
+ indicator.checkCanceled();
+ dumbService.waitForSmartMode();
+
+ AtomicBoolean dumb = new AtomicBoolean();
+ boolean success = ProgressIndicatorUtils.runInReadActionWithWriteActionPriority(() -> {
+ if (myProject.isDisposed()) return;
+
+ if (dumbService.isDumb()) {
+ dumb.set(true);
+ return;
+ }
+
+ runnable.run();
+ }, indicator);
+ if (dumb.get()) {
+ return false;
+ }
+ if (!success) {
+ ProgressIndicatorUtils.yieldToPendingWriteActions();
+ }
+ return success;
+ }
+
protected void logCantRunException(ExecutionException e) throws ExecutionException {
throw e;
}
diff --git a/java/execution/impl/src/com/intellij/testIntegration/RecentTestsListProvider.java b/java/execution/impl/src/com/intellij/testIntegration/RecentTestsListProvider.java
index 102fc8ae0334..752ead10a177 100644
--- a/java/execution/impl/src/com/intellij/testIntegration/RecentTestsListProvider.java
+++ b/java/execution/impl/src/com/intellij/testIntegration/RecentTestsListProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2016 JetBrains s.r.o.
+ * Copyright 2000-2017 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.
@@ -51,9 +51,7 @@ class RunConfigurationByRecordProvider implements ConfigurationByRecordProvider
private void initRunConfigurationsMap() {
RunManagerEx manager = RunManagerEx.getInstanceEx(myProject);
- ConfigurationType[] types = manager.getConfigurationFactories();
-
- for (ConfigurationType type : types) {
+ for (ConfigurationType type : manager.getConfigurationFactories()) {
Map> structure = manager.getStructure(type);
for (Map.Entry> e : structure.entrySet()) {
for (RunnerAndConfigurationSettings settings : e.getValue()) {
@@ -62,7 +60,6 @@ class RunConfigurationByRecordProvider implements ConfigurationByRecordProvider
}
}
}
-
}
diff --git a/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java b/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java
index 62184dfc35d6..fb5ce69d4001 100644
--- a/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java
+++ b/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java
@@ -92,6 +92,7 @@ public class NewProjectUtil {
}
final ProjectBuilder projectBuilder = dialog.getProjectBuilder();
+ LOG.debug("builder " + projectBuilder);
try {
File projectDir = new File(projectFilePath).getParentFile();
diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java
index f7a0ffccbf5b..d6d35f6ee017 100644
--- a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java
+++ b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java
@@ -45,6 +45,7 @@ import com.intellij.platform.ProjectTemplate;
import com.intellij.platform.ProjectTemplateEP;
import com.intellij.platform.ProjectTemplatesFactory;
import com.intellij.platform.templates.*;
+import com.intellij.psi.impl.DebugUtil;
import com.intellij.ui.CollectionListModel;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.ListSpeedSearch;
@@ -123,6 +124,7 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D
myTemplatesMap = new ConcurrentMultiMap<>();
final List groups = fillTemplatesMap(context);
+ LOG.debug("groups=" + groups);
myProjectTypeList.setModel(new CollectionListModel<>(groups));
myProjectTypeList.setSelectionModel(new SingleSelectionModel());
@@ -232,6 +234,7 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D
}
final String groupId = PropertiesComponent.getInstance().getValue(PROJECT_WIZARD_GROUP);
+ LOG.debug("saved groupId=" + groupId);
if (groupId != null) {
TemplatesGroup group = ContainerUtil.find(groups, group1 -> groupId.equals(group1.getId()));
if (group != null) {
@@ -374,6 +377,9 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D
if (group == null || group == myLastSelectedGroup) return;
myLastSelectedGroup = group;
PropertiesComponent.getInstance().setValue(PROJECT_WIZARD_GROUP, group.getId() );
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("projectTypeChanged: " + group.getId() + " " + DebugUtil.currentStackTrace());
+ }
ModuleBuilder groupModuleBuilder = group.getModuleBuilder();
mySettingsStep = null;
@@ -644,6 +650,8 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D
}
ModuleBuilder builder = getSelectedBuilder();
+ LOG.debug("builder=" + builder + "; template=" + template + "; group=" + getSelectedGroup() + "; groupIndex=" + myProjectTypeList.getMinSelectionIndex());
+
myContext.setProjectBuilder(builder);
if (builder != null) {
myWizard.getSequence().setType(builder.getBuilderId());
diff --git a/java/idea-ui/src/com/intellij/jarRepository/JarRepositoryManager.java b/java/idea-ui/src/com/intellij/jarRepository/JarRepositoryManager.java
index 1ee2fe74f79e..55e5fbbb9487 100644
--- a/java/idea-ui/src/com/intellij/jarRepository/JarRepositoryManager.java
+++ b/java/idea-ui/src/com/intellij/jarRepository/JarRepositoryManager.java
@@ -42,7 +42,6 @@ import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
-import com.intellij.util.PairProcessor;
import com.intellij.util.Processor;
import com.intellij.util.concurrency.SequentialTaskExecutor;
import gnu.trove.THashMap;
@@ -67,7 +66,6 @@ import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -96,13 +94,14 @@ public class JarRepositoryManager {
return null;
}
- final List repositories = dialog.getRepositories();
final String coord = dialog.getCoordinateText();
final boolean attachSources = dialog.getAttachSources();
final boolean attachJavaDoc = dialog.getAttachJavaDoc();
final String copyTo = dialog.getDirectoryPath();
- final NewLibraryConfiguration config = resolveAndDownload(project, coord, attachSources, attachJavaDoc, copyTo, repositories);
+ final NewLibraryConfiguration config = resolveAndDownload(
+ project, coord, attachSources, attachJavaDoc, copyTo, RemoteRepositoryDescription.DEFAULT_REPOSITORIES
+ );
if (config == null) {
Messages.showErrorDialog(parentComponent, "No files were downloaded for " + coord, CommonBundle.getErrorTitle());
}
@@ -277,7 +276,7 @@ public class JarRepositoryManager {
Notifications.Bus.notify(new Notification("Repository", title, sb.toString(), NotificationType.INFORMATION), project);
}
- public static void searchArtifacts(final Project project, String coord, final PairProcessor>, Boolean> resultProcessor) {
+ public static void searchArtifacts(final Project project, String coord, final Consumer>> resultProcessor) {
if (coord == null || coord.length() == 0) {
return;
}
@@ -291,30 +290,18 @@ public class JarRepositoryManager {
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Maven", false) {
public void run(@NotNull ProgressIndicator indicator) {
- String[] urls = MavenRepositoryServicesManager.getServiceUrls();
- boolean tooManyResults = false;
- final AtomicBoolean proceedFlag = new AtomicBoolean(true);
-
- for (int i = 0, length = urls.length; i < length; i++) {
- if (!proceedFlag.get()) break;
- final List> resultList = new ArrayList<>();
- try {
- String serviceUrl = urls[i];
- final List artifacts = MavenRepositoryServicesManager.findArtifacts(template, serviceUrl);
- if (!artifacts.isEmpty()) {
- if (!proceedFlag.get()) {
- break;
- }
- final List repositories = MavenRepositoryServicesManager.getRepositories(serviceUrl);
- Map map = new THashMap<>();
- for (RemoteRepositoryDescription repository : repositories) {
- map.put(repository.getId(), repository);
- }
- for (RepositoryArtifactDescription artifact : artifacts) {
- if (artifact == null) {
- tooManyResults = true;
+ final List> resultList = new ArrayList<>();
+ try {
+ for (String serviceUrl : MavenRepositoryServicesManager.getServiceUrls()) {
+ try {
+ final List artifacts = MavenRepositoryServicesManager.findArtifacts(template, serviceUrl);
+ if (!artifacts.isEmpty()) {
+ final List repositories = MavenRepositoryServicesManager.getRepositories(serviceUrl);
+ final Map map = new THashMap<>();
+ for (RemoteRepositoryDescription repository : repositories) {
+ map.put(repository.getId(), repository);
}
- else {
+ for (RepositoryArtifactDescription artifact : artifacts) {
final RemoteRepositoryDescription repository = map.get(artifact.getRepositoryId());
// if the artifact is provided by an unsupported repository just skip it
// because it won't be resolved anyway
@@ -324,38 +311,32 @@ public class JarRepositoryManager {
}
}
}
- }
- catch (Exception e) {
- LOG.error(e);
- }
- finally {
- if (!proceedFlag.get()) {
- break;
+ catch (Exception e) {
+ LOG.error(e);
}
- final Boolean aBoolean = i == length - 1 ? tooManyResults : null;
- ApplicationManager.getApplication().invokeLater(
- () -> proceedFlag.set(resultProcessor.process(resultList, aBoolean)), o -> !proceedFlag.get()
- );
}
}
+ finally {
+ ApplicationManager.getApplication().invokeLater(() -> resultProcessor.accept(resultList));
+ }
}
});
}
- public static void searchRepositories(final Project project, final Collection nexusUrls, final Processor> resultProcessor) {
+ public static void searchRepositories(final Project project, final Collection serviceUrls, final Processor> resultProcessor) {
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Maven", false) {
public void run(@NotNull ProgressIndicator indicator) {
final Ref> result = Ref.create(Collections.emptyList());
try {
final ArrayList repoList = new ArrayList<>();
- for (String nexusUrl : nexusUrls) {
+ for (String url : serviceUrls) {
final List repositories;
try {
- repositories = MavenRepositoryServicesManager.getRepositories(nexusUrl);
+ repositories = MavenRepositoryServicesManager.getRepositories(url);
}
catch (Exception ex) {
- LOG.warn("Accessing Service at: " + nexusUrl, ex);
+ LOG.warn("Accessing Service at: " + url, ex);
continue;
}
repoList.addAll(repositories);
diff --git a/java/idea-ui/src/com/intellij/jarRepository/RepositoryAddLibraryAction.java b/java/idea-ui/src/com/intellij/jarRepository/RepositoryAddLibraryAction.java
index ef1812cd53ac..49a33579308e 100644
--- a/java/idea-ui/src/com/intellij/jarRepository/RepositoryAddLibraryAction.java
+++ b/java/idea-ui/src/com/intellij/jarRepository/RepositoryAddLibraryAction.java
@@ -16,7 +16,7 @@
package com.intellij.jarRepository;
import com.intellij.codeInspection.IntentionAndQuickFixAction;
-import com.intellij.jarRepository.propertiesEditor.RepositoryLibraryPropertiesDialog;
+import com.intellij.jarRepository.settings.RepositoryLibraryPropertiesDialog;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.module.Module;
diff --git a/java/idea-ui/src/com/intellij/jarRepository/RepositoryAttachDialog.java b/java/idea-ui/src/com/intellij/jarRepository/RepositoryAttachDialog.java
index e9ae84194e41..7065d88883c4 100644
--- a/java/idea-ui/src/com/intellij/jarRepository/RepositoryAttachDialog.java
+++ b/java/idea-ui/src/com/intellij/jarRepository/RepositoryAttachDialog.java
@@ -27,7 +27,6 @@ import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.ui.ValidationInfo;
import com.intellij.openapi.util.Comparing;
-import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
@@ -56,8 +55,10 @@ import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import java.util.Map;
public class RepositoryAttachDialog extends DialogWrapper {
@NonNls private static final String PROPERTY_DOWNLOAD_TO_PATH = "Downloaded.Files.Path";
@@ -79,8 +80,7 @@ public class RepositoryAttachDialog extends DialogWrapper {
private final JComboBox myCombobox;
- private final Map> myCoordinates = ContainerUtil.newTroveMap();
- private final Map myRepositories = new TreeMap<>();
+ private final Map myCoordinates = ContainerUtil.newTroveMap();
private final List myShownItems = ContainerUtil.newArrayList();
private final String myDefaultDownloadFolder;
@@ -203,7 +203,9 @@ public class RepositoryAttachDialog extends DialogWrapper {
main:
for (String coordinate : myCoordinates.keySet()) {
for (String part : parts) {
- if (!StringUtil.containsIgnoreCase(coordinate, part)) continue main;
+ if (!StringUtil.containsIgnoreCase(coordinate, part)) {
+ continue main;
+ }
}
myShownItems.add(coordinate);
}
@@ -267,41 +269,22 @@ public class RepositoryAttachDialog extends DialogWrapper {
private boolean performSearch() {
final String text = getCoordinateText();
- if (StringUtil.isEmptyOrSpaces(text)) return false;
- if (myCoordinates.containsKey(text)) return false;
- if (myProgressIcon.isRunning()) return false;
+ if (myProgressIcon.isRunning() || StringUtil.isEmptyOrSpaces(text) || myCoordinates.containsKey(text)) {
+ return false;
+ }
myProgressIcon.resume();
- JarRepositoryManager.searchArtifacts(myProject, text, (artifacts, tooMany) -> {
+ JarRepositoryManager.searchArtifacts(myProject, text, (pairs) -> {
if (myProgressIcon.isDisposed()) {
- return false;
- }
- if (tooMany != null) {
- myProgressIcon.suspend(); // finished
+ return;
}
+ myProgressIcon.suspend(); // finished
final int prevSize = myCoordinates.size();
- for (Pair each : artifacts) {
- myCoordinates.put(each.first.getGroupId() + ":" + each.first.getArtifactId() + ":" + each.first.getVersion(), each);
- String url = each.second != null? each.second.getUrl() : null;
- if (StringUtil.isNotEmpty(url) && !myRepositories.containsKey(url)) {
- myRepositories.put(url, each.second);
- }
- }
- String title = getTitle();
- String tooManyMessage = ": too many results found";
- if (tooMany != null) {
- boolean alreadyThere = title.endsWith(tooManyMessage);
- if (tooMany.booleanValue() && !alreadyThere) {
- setTitle(title + tooManyMessage);
- }
- else if (!tooMany.booleanValue() && alreadyThere) {
- setTitle(title.substring(0, title.length() - tooManyMessage.length()));
- }
+ for (Pair pair : pairs) {
+ final RepositoryArtifactDescription artifact = pair.first;
+ myCoordinates.put(artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion(), artifact);
}
updateComboboxSelection(prevSize != myCoordinates.size());
- // tooMany != null on last call, so enable OK action to let
- // local maven repo a chance even if all remote services failed
- setOKActionEnabled(!myRepositories.isEmpty() || tooMany != null);
- return true;
+ setOKActionEnabled(true);
});
return true;
}
@@ -352,13 +335,6 @@ public class RepositoryAttachDialog extends DialogWrapper {
return RepositoryAttachDialog.class.getName();
}
- @NotNull
- public List getRepositories() {
- final Pair artifactAndRepo = myCoordinates.get(getCoordinateText());
- final RemoteRepositoryDescription repository = artifactAndRepo == null ? null : artifactAndRepo.second;
- return repository != null ? Collections.singletonList(repository) : ContainerUtil.findAll(myRepositories.values(), Condition.NOT_NULL);
- }
-
private boolean isValidCoordinateSelected() {
final String text = getCoordinateText();
return text.split(":").length == 3;
diff --git a/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibrarySupportInModuleConfigurable.java b/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibrarySupportInModuleConfigurable.java
index bf6f57a1a1f4..b4a66448c248 100644
--- a/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibrarySupportInModuleConfigurable.java
+++ b/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibrarySupportInModuleConfigurable.java
@@ -16,7 +16,7 @@
package com.intellij.jarRepository;
import com.intellij.framework.addSupport.FrameworkSupportInModuleConfigurable;
-import com.intellij.jarRepository.propertiesEditor.RepositoryLibraryPropertiesEditor;
+import com.intellij.jarRepository.settings.RepositoryLibraryPropertiesEditor;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ModifiableModelsProvider;
diff --git a/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibraryWithDescriptionEditor.java b/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibraryWithDescriptionEditor.java
index ffee1c12e1a1..5c99fdc7928f 100644
--- a/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibraryWithDescriptionEditor.java
+++ b/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibraryWithDescriptionEditor.java
@@ -15,7 +15,7 @@
*/
package com.intellij.jarRepository;
-import com.intellij.jarRepository.propertiesEditor.RepositoryLibraryPropertiesDialog;
+import com.intellij.jarRepository.settings.RepositoryLibraryPropertiesDialog;
import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.roots.libraries.ui.LibraryEditorComponent;
import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor;
diff --git a/java/idea-ui/src/com/intellij/jarRepository/propertiesEditor/RepositoryLibraryPropertiesEditor.form b/java/idea-ui/src/com/intellij/jarRepository/propertiesEditor/RepositoryLibraryPropertiesEditor.form
deleted file mode 100644
index 12d569c4dc71..000000000000
--- a/java/idea-ui/src/com/intellij/jarRepository/propertiesEditor/RepositoryLibraryPropertiesEditor.form
+++ /dev/null
@@ -1,193 +0,0 @@
-
-
diff --git a/java/idea-ui/src/com/intellij/jarRepository/propertiesEditor/RepositoryLibraryPropertiesDialog.java b/java/idea-ui/src/com/intellij/jarRepository/settings/RepositoryLibraryPropertiesDialog.java
similarity index 97%
rename from java/idea-ui/src/com/intellij/jarRepository/propertiesEditor/RepositoryLibraryPropertiesDialog.java
rename to java/idea-ui/src/com/intellij/jarRepository/settings/RepositoryLibraryPropertiesDialog.java
index d2d966ce58ef..601024874e7f 100644
--- a/java/idea-ui/src/com/intellij/jarRepository/propertiesEditor/RepositoryLibraryPropertiesDialog.java
+++ b/java/idea-ui/src/com/intellij/jarRepository/settings/RepositoryLibraryPropertiesDialog.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.intellij.jarRepository.propertiesEditor;
+package com.intellij.jarRepository.settings;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/propertiesEditor/RepositoryLibraryPropertiesEditor.form b/java/idea-ui/src/com/intellij/jarRepository/settings/RepositoryLibraryPropertiesEditor.form
similarity index 97%
rename from plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/propertiesEditor/RepositoryLibraryPropertiesEditor.form
rename to java/idea-ui/src/com/intellij/jarRepository/settings/RepositoryLibraryPropertiesEditor.form
index 5903bd9cafd7..cb1f7a895be3 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/propertiesEditor/RepositoryLibraryPropertiesEditor.form
+++ b/java/idea-ui/src/com/intellij/jarRepository/settings/RepositoryLibraryPropertiesEditor.form
@@ -1,5 +1,5 @@
-