Merge remote-tracking branch 'origin/master'

This commit is contained in:
Konstantin Bulenkov
2015-09-24 20:23:35 +02:00
43 changed files with 344 additions and 190 deletions
-1
View File
@@ -312,4 +312,3 @@ jetbrainsLibrary("Maven Embedder")
jetbrainsLibrary("tcServiceMessages")
jetbrainsLibrary("optimizedFileManager.jar")
jetbrainsLibrary("KotlinJavaRuntime")
jetbrainsLibrary("testDiscoveryInstrumenter.jar")
@@ -416,6 +416,7 @@ public class DebugProcessEvents extends DebugProcessImpl {
final int nextStepDepth = hint.getNextStepDepth(suspendContext);
if (nextStepDepth == RequestHint.RESUME) {
getSession().resetIgnoreStepFiltersFlag();
getSession().clearSteppingThrough();
shouldResume = true;
}
else if (nextStepDepth != RequestHint.STOP) {
@@ -40,6 +40,7 @@ import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vfs.VirtualFile;
@@ -106,7 +107,7 @@ public class JavaDebugProcess extends XDebugProcess {
|| event == DebuggerSession.Event.REFRESH
&& myJavaSession.isPaused()) {
final SuspendContextImpl newSuspendContext = newContext.getSuspendContext();
if (newSuspendContext != null && newSuspendContext != getSession().getSuspendContext()) {
if (newSuspendContext != null && shouldApplyContext(newContext)) {
process.getManagerThread().schedule(new SuspendContextCommandImpl(newSuspendContext) {
@Override
public void contextAction() throws Exception {
@@ -119,10 +120,12 @@ public class JavaDebugProcess extends XDebugProcess {
XBreakpoint xBreakpoint = breakpoint.getXBreakpoint();
if (xBreakpoint != null) {
((XDebugSessionImpl)getSession()).breakpointReachedNoProcessing(xBreakpoint, newSuspendContext);
unsetPausedIfNeeded(newContext);
return;
}
}
getSession().positionReached(newSuspendContext);
unsetPausedIfNeeded(newContext);
}
});
}
@@ -181,6 +184,21 @@ public class JavaDebugProcess extends XDebugProcess {
});
}
private void unsetPausedIfNeeded(DebuggerContextImpl context) {
SuspendContextImpl suspendContext = context.getSuspendContext();
if (suspendContext != null && context.getThreadProxy() != suspendContext.getThread()) {
((XDebugSessionImpl)getSession()).unsetPaused();
}
}
private boolean shouldApplyContext(DebuggerContextImpl context) {
SuspendContextImpl suspendContext = context.getSuspendContext();
SuspendContextImpl currentContext = (SuspendContextImpl)getSession().getSuspendContext();
if (suspendContext != null && !suspendContext.equals(currentContext)) return true;
JavaExecutionStack currentExecutionStack = currentContext != null ? currentContext.getActiveExecutionStack() : null;
return currentExecutionStack == null || !Comparing.equal(context.getThreadProxy(), currentExecutionStack.getThreadProxy());
}
public void saveNodeHistory() {
saveNodeHistory(getDebuggerStateManager().getContext().getFrameProxy());
}
@@ -48,14 +48,11 @@ public class JavaExecutionStack extends XExecutionStack {
super(calcRepresentation(threadProxy), calcIcon(threadProxy, current));
myThreadProxy = threadProxy;
myDebugProcess = debugProcess;
if (current) {
initTopFrame();
}
}
private static Icon calcIcon(ThreadReferenceProxyImpl threadProxy, boolean current) {
if (current) {
return AllIcons.Debugger.ThreadCurrent;
return threadProxy.isSuspended() ? AllIcons.Debugger.ThreadCurrent : AllIcons.Debugger.ThreadRunning;
}
else if (threadProxy.isAtBreakpoint()) {
return AllIcons.Debugger.ThreadAtBreakpoint;
@@ -217,4 +214,9 @@ public class JavaExecutionStack extends XExecutionStack {
public int hashCode() {
return myThreadProxy.hashCode();
}
@Override
public String toString() {
return getDisplayName();
}
}
@@ -138,7 +138,7 @@ public class JavaStackFrame extends XStackFrame {
xFrame.computeChildren(node);
return;
}
myDebugProcess.getManagerThread().schedule(new DebuggerContextCommandImpl(myDebugProcess.getDebuggerContext()) {
myDebugProcess.getManagerThread().schedule(new DebuggerContextCommandImpl(myDebugProcess.getDebuggerContext(), myDescriptor.getFrameProxy().threadProxy()) {
@Override
public Priority getPriority() {
return Priority.NORMAL;
@@ -26,7 +26,6 @@ import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Comparing;
import com.intellij.util.containers.HashSet;
import com.intellij.xdebugger.frame.XExecutionStack;
import com.intellij.xdebugger.frame.XSuspendContext;
import com.sun.jdi.ObjectReference;
import com.sun.jdi.ThreadReference;
@@ -229,15 +228,18 @@ public abstract class SuspendContextImpl extends XSuspendContext implements Susp
@Nullable
@Override
public XExecutionStack getActiveExecutionStack() {
public JavaExecutionStack getActiveExecutionStack() {
return myActiveExecutionStack;
}
public void initExecutionStacks(ThreadReferenceProxyImpl newThread) {
public void initExecutionStacks(ThreadReferenceProxyImpl activeThread) {
DebuggerManagerThreadImpl.assertIsManagerThread();
myThread = newThread;
if (newThread != null) {
myActiveExecutionStack = new JavaExecutionStack(newThread, myDebugProcess, true);
if (myThread == null) {
myThread = activeThread;
}
if (activeThread != null) {
myActiveExecutionStack = new JavaExecutionStack(activeThread, myDebugProcess, myThread == activeThread);
myActiveExecutionStack.initTopFrame();
}
}
@@ -115,13 +115,6 @@ public class SuspendManagerImpl implements SuspendManager {
return suspendContext;
}
public SuspendContextImpl createDummyContext(@MagicConstant(flagsFromClass = EventRequest.class) int suspendPolicy) {
return new SuspendContextImpl(myDebugProcess, suspendPolicy, 0, null) {
@Override
protected void resumeImpl() {}
};
}
@Override
public SuspendContextImpl pushSuspendContext(final EventSet set) {
SuspendContextImpl suspendContext = new SuspendContextImpl(myDebugProcess, set.suspendPolicy(), set.size(), set) {
@@ -360,7 +353,7 @@ public class SuspendManagerImpl implements SuspendManager {
processVote(suspendContext);
}
LinkedList<SuspendContextImpl> getPausedContexts() {
public List<SuspendContextImpl> getPausedContexts() {
return myPausedContexts;
}
}
@@ -151,7 +151,6 @@ public final class DebuggerContextImpl implements DebuggerContext {
ThreadReferenceProxyImpl threadProxy,
StackFrameProxyImpl frameProxy) {
LOG.assertTrue(frameProxy == null || threadProxy == null || threadProxy == frameProxy.threadProxy());
LOG.assertTrue(session == null || session.getProcess() != null);
return new DebuggerContextImpl(session, session != null ? session.getProcess() : null, context, threadProxy, frameProxy, null, null, context == null);
}
@@ -111,7 +111,7 @@ public class DebuggerSession implements AbstractDebuggerSession {
mySteppingThroughThread.set(threadProxy);
}
void clearSteppingThrough() {
public void clearSteppingThrough() {
mySteppingThroughThread.set(null);
}
@@ -469,6 +469,8 @@ public class DebuggerSession implements AbstractDebuggerSession {
LOG.debug("paused");
}
ThreadReferenceProxyImpl currentThread = suspendContext.getThread();
if (!shouldSetAsActiveContext(suspendContext)) {
DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() {
@Override
@@ -476,7 +478,7 @@ public class DebuggerSession implements AbstractDebuggerSession {
getContextManager().fireStateChanged(getContextManager().getContext(), Event.THREADS_REFRESH);
}
});
final ThreadReferenceProxyImpl thread = suspendContext.getThread();
ThreadReferenceProxyImpl thread = suspendContext.getThread();
if (thread != null) {
List<Pair<Breakpoint, com.sun.jdi.event.Event>> descriptors = DebuggerUtilsEx.getEventDescriptors(suspendContext);
if (!descriptors.isEmpty()) {
@@ -492,7 +494,7 @@ public class DebuggerSession implements AbstractDebuggerSession {
@Override
public void contextAction() throws Exception {
final DebuggerContextImpl debuggerContext =
DebuggerContextImpl.createDebuggerContext(DebuggerSession.this, suspendContext, thread, null);
DebuggerContextUtil.createDebuggerContext(DebuggerSession.this, suspendContext);
DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() {
@Override
@@ -507,12 +509,17 @@ public class DebuggerSession implements AbstractDebuggerSession {
}).notify(getProject());
}
}
return;
if (((SuspendManagerImpl)myDebugProcess.getSuspendManager()).getPausedContexts().size() > 1) {
return;
}
else {
currentThread = mySteppingThroughThread.get();
}
}
else {
setSteppingThrough(currentThread);
}
setSteppingThrough(suspendContext.getThread());
ThreadReferenceProxyImpl currentThread = suspendContext.getThread();
final StackFrameContext positionContext;
if (currentThread == null) {
@@ -626,7 +633,7 @@ public class DebuggerSession implements AbstractDebuggerSession {
DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() {
@Override
public void run() {
getContextManager().setState(debuggerContext, State.PAUSED, Event.PAUSE, null);
getContextManager().setState(debuggerContext, State.PAUSED, Event.PAUSE, getDescription(debuggerContext));
}
});
}
@@ -650,25 +657,28 @@ public class DebuggerSession implements AbstractDebuggerSession {
@Override
public void resumed(SuspendContextImpl suspendContext) {
SuspendManager suspendManager = getProcess().getSuspendManager();
SuspendContextImpl context = suspendManager.getPausedContext();
SuspendContextImpl context = getProcess().getSuspendManager().getPausedContext();
ThreadReferenceProxyImpl steppingThread = null;
// single thread stepping
if (suspendContext != null
if (context != null
&& suspendContext != null
&& suspendContext.getSuspendPolicy() == EventRequest.SUSPEND_EVENT_THREAD
&& isSteppingThrough(suspendContext.getThread())) {
ThreadReferenceProxyImpl thread = suspendContext.getThread();
if (context == null || !Comparing.equal(context.getThread(), thread)) {
context = ((SuspendManagerImpl)suspendManager).createDummyContext(suspendContext.getSuspendPolicy());
context.setThread(thread.getThreadReference());
}
steppingThread = suspendContext.getThread();
}
final SuspendContextImpl currentContext = context;
final DebuggerContextImpl debuggerContext =
context != null ?
DebuggerContextImpl.createDebuggerContext(DebuggerSession.this,
context,
steppingThread != null ? steppingThread : context.getThread(),
null)
: null;
DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() {
@Override
public void run() {
if (currentContext != null) {
getContextManager().setState(DebuggerContextUtil.createDebuggerContext(DebuggerSession.this, currentContext),
State.PAUSED, Event.CONTEXT, null);
if (debuggerContext != null) {
getContextManager().setState(debuggerContext, State.PAUSED, Event.CONTEXT, getDescription(debuggerContext));
}
else {
getContextManager().setState(SESSION_EMPTY_CONTEXT, State.RUNNING, Event.CONTEXT, null);
@@ -756,6 +766,14 @@ public class DebuggerSession implements AbstractDebuggerSession {
}
}
private static String getDescription(DebuggerContextImpl debuggerContext) {
SuspendContextImpl suspendContext = debuggerContext.getSuspendContext();
if (suspendContext != null && debuggerContext.getThreadProxy() != suspendContext.getThread()) {
return DebuggerBundle.message("status.paused.in.another.thread");
}
return null;
}
private class MyEvaluationListener implements EvaluationListener {
@Override
public void evaluationStarted(SuspendContextImpl context) {
@@ -176,7 +176,7 @@ class ReloadClassesWorker {
SuspendContextImpl suspendContext = context.getSuspendContext();
if (suspendContext != null) {
XExecutionStack stack = suspendContext.getActiveExecutionStack();
if (stack instanceof JavaExecutionStack) {
if (stack != null) {
((JavaExecutionStack)stack).initTopFrame();
}
}
@@ -193,6 +193,7 @@ public class StackFrameProxyImpl extends JdiProxy implements StackFrameProxy {
throw new EvaluateException(error.getMessage(), error);
}
@NotNull
@Override
public ThreadReferenceProxyImpl threadProxy() {
return myThreadProxy;
@@ -493,6 +493,12 @@ public class RefJavaManagerImpl extends RefJavaManager {
public void visitVariable(PsiVariable variable) {
super.visitVariable(variable);
myRefUtil.addTypeReference(variable, variable.getType(), myRefManager);
if (variable instanceof PsiParameter) {
final RefElement reference = myRefManager.getReference(variable);
if (reference instanceof RefParameterImpl) {
((RefParameterImpl)reference).buildReferences();
}
}
}
@Override
@@ -102,6 +102,15 @@ public class RefParameterImpl extends RefJavaElementImpl implements RefParameter
return myIndex;
}
@Override
public void buildReferences() {
final RefJavaUtil refUtil = RefJavaUtil.getInstance();
final PsiParameter parameter = getElement();
if (parameter != null) {
refUtil.addReferences(parameter, this, parameter.getModifierList());
}
}
public void updateTemplateValue(PsiExpression expression) {
if (myActualValueTemplate == null) return;
@@ -95,7 +95,7 @@ public class JavaLineMarkerProvider implements LineMarkerProvider {
}
if (isMember && !(element1 instanceof PsiAnonymousClass || element1.getParent() instanceof PsiAnonymousClass)) {
PsiFile file = element1.getContainingFile();
Document document = file == null ? null : PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
Document document = file == null ? null : PsiDocumentManager.getInstance(file.getProject()).getLastCommittedDocument(file);
boolean drawSeparator = false;
if (document != null) {
@@ -57,19 +57,21 @@ public class CreateConstructorParameterFromFieldFix implements IntentionAction {
private final SmartPsiElementPointer<PsiField> myField;
private final PsiClass myClass;
private int myConstructorsLength;
public CreateConstructorParameterFromFieldFix(@NotNull PsiField field) {
myClass = field.getContainingClass();
myField = SmartPointerManager.getInstance(field.getProject()).createSmartPsiElementPointer(field);
if (myClass != null) {
getFieldsToFix().add(myField);
myConstructorsLength = myClass.getConstructors().length;
}
}
@Override
@NotNull
public String getText() {
if (getFieldsToFix().size() > 1 && myClass.getConstructors().length <= 1) return "Add constructor parameters";
if (getFieldsToFix().size() > 1 && myConstructorsLength <= 1) return "Add constructor parameters";
return QuickFixBundle.message("add.constructor.parameter.name");
}
@@ -81,7 +83,7 @@ public class CreateConstructorParameterFromFieldFix implements IntentionAction {
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
return isAvailable(getField());
return (myClass == null || myClass.isValid()) && isAvailable(getField());
}
private static boolean isAvailable(PsiField field) {
@@ -272,11 +272,19 @@ public class MethodReferenceResolver implements ResolveCache.PolyVariantContextR
private boolean resolveConflicts(List<CandidateInfo> firstCandidates, List<CandidateInfo> secondCandidates, int applicabilityLevel) {
checkApplicability(firstCandidates);
final int firstApplicability = checkApplicability(firstCandidates);
checkSpecifics(firstCandidates, applicabilityLevel, myLanguageLevel);
checkApplicability(secondCandidates);
final int secondApplicability = checkApplicability(secondCandidates);
checkSpecifics(secondCandidates, applicabilityLevel, myLanguageLevel);
if (firstApplicability < secondApplicability) {
return secondCandidates.size() == 1;
}
if (secondApplicability < firstApplicability) {
return firstCandidates.size() == 1;
}
return firstCandidates.size() + secondCandidates.size() == 1;
}
@@ -0,0 +1,23 @@
import java.util.function.BiConsumer;
class MyTest<T> {
{
BiConsumer<Builder<T>, T> builderTBiConsumer = Builder::add;
BiConsumer<Builder<T>, T> builderTBiConsumer1 = Builder<T>::add;
System.out.println(builderTBiConsumer);
System.out.println(builderTBiConsumer1);
}
public static class Builder<E> {
public Builder<E> add(E element) {
return this;
}
public Builder<E> add(E... elements) {
return this;
}
}
}
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems/>
@@ -0,0 +1,4 @@
import junit.framework.TestCase;
public class MyTest {
public static void main(@TestCase String[] args) {}
}
@@ -146,6 +146,10 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testIgnoreCandidatesWithLowerApplicabilityLevel() throws Exception {
doTest();
}
private void doTest() {
doTest(true);
}
@@ -65,4 +65,5 @@ public class UnusedLibraryInspectionTest extends InspectionTestCase {
public void testSimple() throws Exception { doTest(); }
public void testUsedJunit() throws Exception { doTest(); }
public void testUsedJunitFromField() throws Exception { doTest(); }
public void testUsedInParameterAnnotation() throws Exception { doTest(); }
}
-1
View File
@@ -66,7 +66,6 @@ snappy-in-java-0.3.1.jar
swingx-core-1.6.2.jar
slf4j-api-1.7.10.jar
slf4j-log4j12-1.7.10.jar
testDiscoveryInstrumenter.jar
trove4j.jar
velocity.jar
winp-1.23.jar
Binary file not shown.
@@ -266,7 +266,7 @@ public class FileReferenceSet {
if (curSep >= 0 && decoded.length() == wsHead + sepLen + wsTail) {
// add extra reference for the only & leading "/"
TextRange r = TextRange.create(startInElement, offset(curSep + Math.max(0, sepLen - 1), escaper, valueRange) + 1);
referencesList.add(createFileReference(r, 0, decoded.subSequence(curSep, curSep + sepLen).toString()));
referencesList.add(createFileReference(r, index ++, decoded.subSequence(curSep, curSep + sepLen).toString()));
}
curSep = curSep == wsHead ? curSep + sepLen : wsHead; // reset offsets & start again for simplicity
sepLen = 0;
@@ -186,15 +186,32 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
FileElement treeElement = createFileElement(viewProvider.getContents());
treeElement.setPsi(this);
final StubTree stub = derefStub();
List<Pair<StubBasedPsiElementBase, CompositeElement>> bindings = calcStubAstBindings(treeElement, cachedDocument, stub);
while (true) {
StubTree stub = derefStub();
List<Pair<StubBasedPsiElementBase, CompositeElement>> bindings = calcStubAstBindings(treeElement, cachedDocument, stub);
FileElement savedTree = ensureTreeElement(viewProvider, treeElement, stub, bindings);
if (savedTree != null) {
return savedTree;
}
}
}
@Nullable
private FileElement ensureTreeElement(@NotNull FileViewProvider viewProvider,
@NotNull FileElement treeElement,
@Nullable StubTree stub,
@NotNull List<Pair<StubBasedPsiElementBase, CompositeElement>> bindings) {
synchronized (PsiLock.LOCK) {
FileElement existing = derefTreeElement();
if (existing != null) {
return existing;
}
if (stub != derefStub()) {
return null; // stub has been just loaded by another thread, it needs to be bound to AST
}
if (stub != null) {
treeElement.putUserData(STUB_TREE_IN_PARSED_TREE, new SoftReference<StubTree>(stub));
putUserData(ObjectStubTree.LAST_STUB_TREE_HASH, stub.hashCode());
@@ -318,6 +318,12 @@ class ProjectViewDropTarget implements DnDNativeTarget {
final Module module = getModule(targetNode);
final DataContext dataContext = DataManager.getInstance().getDataContext(myTree);
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
if (!targetElement.isValid()) return;
for (PsiElement sourceElement : sourceElements) {
if (!sourceElement.isValid()) return;
}
getActionHandler().invoke(myProject, sourceElements, new DataContext() {
@Override
@Nullable
@@ -24,6 +24,7 @@ import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiNamedElement;
import com.intellij.psi.SyntheticElement;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.rename.PsiElementRenameHandler;
import com.intellij.refactoring.rename.RenameHandlerRegistry;
import org.jetbrains.annotations.NotNull;
@@ -43,7 +44,9 @@ public class RenameElementAction extends BaseRefactoringAction {
if (elements.length != 1) return false;
PsiElement element = elements[0];
return element instanceof PsiNamedElement && !(element instanceof SyntheticElement);
return element instanceof PsiNamedElement &&
!(element instanceof SyntheticElement) &&
!PsiElementRenameHandler.isVetoed(element);
}
@Override
@@ -108,7 +108,7 @@ public final class TabInfo implements Queryable, PlaceProvider<String> {
public TabInfo setText(String text) {
List<SimpleTextAttributes> attributes = myText.getAttributes();
TextAttributes textAttributes = attributes.isEmpty() ? null : attributes.get(0).toTextAttributes();
TextAttributes textAttributes = attributes.size() == 1 ? attributes.get(0).toTextAttributes() : null;
TextAttributes defaultAttributes = getDefaultAttributes().toTextAttributes();
if (!myText.toString().equals(text) || !Comparing.equal(textAttributes, defaultAttributes)) {
clearText(false);
@@ -1,3 +1,4 @@
# suppress inspection "UnusedProperty" for whole file
darcula.selectionBackground=2F65CA
Menu.arrowIcon=AllIcons.Mac.Tree_white_right_arrow
Menu.arrowIcon=AllIcons.Mac.Tree_white_right_arrow
MenuItem.acceleratorSelectionForeground=ffffff
@@ -329,18 +329,18 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
hasFocus = false;
checkFocus();
final Graphics2D g = (Graphics2D)g2;
final Graphics2D g = (Graphics2D)g2.create();
final Rectangle arrowButtonBounds = arrowButton.getBounds();
final int xxx = arrowButtonBounds.x - JBUI.scale(5);
final int H = height - JBUI.scale(2);
final int W = width - JBUI.scale(2);
final GraphicsConfig config = new GraphicsConfig(g);
final Shape clip = g.getClip();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
final int R = JBUI.scale(5);
if (hasFocus) {
g.setClip(JBUI.scale(2), JBUI.scale(2), comboBox.getWidth()- JBUI.scale(4), comboBox.getHeight() - JBUI.scale(4));
g.clipRect(JBUI.scale(2), JBUI.scale(2), comboBox.getWidth()- JBUI.scale(4), comboBox.getHeight() - JBUI.scale(4));
}
if (editor != null && comboBox.isEditable()) {
((JComponent)editor).setBorder(null);
@@ -368,7 +368,7 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
paintCurrentValue(g, r, false);
if (hasFocus) {
g.setClip(0, 0, comboBox.getWidth(), comboBox.getHeight());
g.setClip(clip);
DarculaUIUtil.paintFocusRing(g, JBUI.scale(2), JBUI.scale(2), width - JBUI.scale(4), height - JBUI.scale(4));
}
else {
@@ -376,14 +376,12 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
g.drawRoundRect(JBUI.scale(1), JBUI.scale(1), width - JBUI.scale(2), height - JBUI.scale(2), R, R);
if (!UIUtil.isUnderDarcula() && comboBox.isEnabled()) {
g.setColor(getArrowButtonFillColor(getBorderColor()));
final Shape clip = g.getClip();
final int offX = xxx + JBUI.scale(5);
g.setClip(offX, y, width - offX, height);
g.clipRect(offX, y, width - offX, height);
g.drawRoundRect(JBUI.scale(1), JBUI.scale(1), width - JBUI.scale(2), height - JBUI.scale(2), R, R);
g.setClip(clip);
}
}
config.restore();
g.dispose();
}
private void checkFocus() {
@@ -53,7 +53,7 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme
/**
* State corresponding to the most recent file is the last
*/
private final List<HistoryEntry> myEntriesList = Collections.synchronizedList(new ArrayList<HistoryEntry>());
private final List<HistoryEntry> myEntriesList = new ArrayList<HistoryEntry>();
/**
* Invoked by reflection
@@ -81,7 +81,7 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme
//noinspection unchecked
for (final Element e : (Iterable<Element>)children) {
try {
myEntriesList.add(new HistoryEntry(myProject, e));
addEntry(new HistoryEntry(EditorHistoryManager.this.myProject, e));
}
catch (InvalidDataException e1) {
// OK here
@@ -100,6 +100,14 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme
);
}
private synchronized void addEntry(HistoryEntry entry) {
myEntriesList.add(entry);
}
private synchronized void removeEntry(HistoryEntry entry) {
myEntriesList.remove(entry);
}
@Override
@NotNull
public String getComponentName(){
@@ -145,8 +153,8 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme
final HistoryEntry entry = getEntry(file);
if(entry != null){
myEntriesList.remove(entry);
myEntriesList.add(entry);
removeEntry(entry);
addEntry(entry);
}
else {
final FileEditorState[] states=new FileEditorState[editors.length];
@@ -157,7 +165,7 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme
providers[i] = provider;
states[i] = editors[i].getState(FileEditorStateLevel.FULL);
}
myEntriesList.add(new HistoryEntry(file, providers, states, providers[selectedProviderIndex]));
addEntry(new HistoryEntry(file, providers, states, providers[selectedProviderIndex]));
trimToSize();
}
}
@@ -222,8 +230,8 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme
LOG.assertTrue(entry.mySelectedProvider != null);
if(changeEntryOrderOnly){
myEntriesList.remove(entry);
myEntriesList.add(entry);
removeEntry(entry);
addEntry(entry);
}
}
}
@@ -231,7 +239,7 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme
/**
* Removes all entries that correspond to invalid files
*/
private void validateEntries(){
private synchronized void validateEntries(){
for(int i=myEntriesList.size()-1; i>=0; i--){
final HistoryEntry entry = myEntriesList.get(i);
if(!entry.myFile.isValid()){
@@ -243,7 +251,7 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme
/**
* @return array of valid files that are in the history, oldest first. May contain duplicates.
*/
public VirtualFile[] getFiles(){
public synchronized VirtualFile[] getFiles(){
validateEntries();
final VirtualFile[] result = new VirtualFile[myEntriesList.size()];
for(int i=myEntriesList.size()-1; i>=0 ;i--){
@@ -265,7 +273,7 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme
return result;
}
public boolean hasBeenOpen(@NotNull VirtualFile f) {
public synchronized boolean hasBeenOpen(@NotNull VirtualFile f) {
for (HistoryEntry each : myEntriesList) {
if (Comparing.equal(each.myFile, f)) return true;
}
@@ -276,13 +284,13 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme
* Removes specified <code>file</code> from history. The method does
* nothing if <code>file</code> is not in the history.
*
* @exception java.lang.IllegalArgumentException if <code>file</code>
* @exception IllegalArgumentException if <code>file</code>
* is <code>null</code>
*/
public void removeFile(@NotNull final VirtualFile file){
public synchronized void removeFile(@NotNull final VirtualFile file){
final HistoryEntry entry = getEntry(file);
if(entry != null){
myEntriesList.remove(entry);
removeEntry(entry);
}
}
@@ -301,7 +309,7 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme
return entry != null ? entry.mySelectedProvider : null;
}
private HistoryEntry getEntry(@NotNull VirtualFile file){
private synchronized HistoryEntry getEntry(@NotNull VirtualFile file){
validateEntries();
for (int i = myEntriesList.size() - 1; i >= 0; i--) {
final HistoryEntry entry = myEntriesList.get(i);
@@ -316,7 +324,7 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme
* If total number of files in history more then <code>UISettings.RECENT_FILES_LIMIT</code>
* then removes the oldest ones to fit the history to new size.
*/
private void trimToSize(){
private synchronized void trimToSize(){
final int limit = UISettings.getInstance().RECENT_FILES_LIMIT + 1;
while(myEntriesList.size()>limit){
myEntriesList.remove(0);
@@ -332,7 +340,7 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme
}
@Override
public void writeExternal(final Element element){
public synchronized void writeExternal(final Element element){
// update history before saving
final VirtualFile[] openFiles = FileEditorManager.getInstance(myProject).getOpenFiles();
for (int i = openFiles.length - 1; i >= 0; i--) {
@@ -15,6 +15,7 @@
*/
package com.intellij.application;
import com.intellij.concurrency.JobSchedulerImpl;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.Application;
@@ -52,6 +53,7 @@ public class ApplicationImplTest extends PlatformTestCase {
protected void setUp() throws Exception {
super.setUp();
exception = null;
timeOut = System.currentTimeMillis() + 2*60*1000;
}
private volatile Throwable exception;
@@ -105,8 +107,8 @@ public class ApplicationImplTest extends PlatformTestCase {
}
public void testReadWriteLockPerformance() throws InterruptedException {
int iterations = Timings.adjustAccordingToMySpeed(300000, true);
public void testRead50Write50LockPerformance() throws InterruptedException {
int iterations = Timings.adjustAccordingToMySpeed(400000, true);
System.out.println("iterations = " + iterations);
final int readIterations = iterations;
final int writeIterations = iterations;
@@ -114,8 +116,8 @@ public class ApplicationImplTest extends PlatformTestCase {
runReadWrites(readIterations, writeIterations, 2000);
}
public void testReadLockPerformance() throws InterruptedException {
int iterations = Timings.adjustAccordingToMySpeed(300000, true);
public void testRead100Write0LockPerformance() throws InterruptedException {
int iterations = Timings.adjustAccordingToMySpeed(400000, true);
System.out.println("iterations = " + iterations);
final int readIterations = iterations;
final int writeIterations = 0;
@@ -129,7 +131,7 @@ public class ApplicationImplTest extends PlatformTestCase {
application.disableEventsUntil(disposable);
try {
final int numOfThreads = 10;
final int numOfThreads = JobSchedulerImpl.CORES_COUNT;
PlatformTestUtil.startPerformanceTest("lock performance", expectedMs, () -> {
final CountDownLatch reads = new CountDownLatch(numOfThreads);
for (int i = 0; i < numOfThreads; i++) {
@@ -155,7 +157,7 @@ public class ApplicationImplTest extends PlatformTestCase {
System.out.println("write end");
}
reads.await();
}).assertTiming();
}).cpuBound().assertTiming();
}
finally {
Disposer.dispose(disposable);
@@ -186,7 +188,7 @@ public class ApplicationImplTest extends PlatformTestCase {
try {
System.out.println("read lock1 acquired");
read1Acquired.set(true);
while (holdRead1.get());
while (holdRead1.get() && ok());
}
finally {
lock.unlockRead(stamp);
@@ -194,20 +196,20 @@ public class ApplicationImplTest extends PlatformTestCase {
System.out.println("read lock1 released");
}
}
catch (Exception e) {
catch (Throwable e) {
exception = e;
throw e;
throw new RuntimeException(e);
}
}, "read lock1");
readAction1.start();
while (!read1Acquired.get());
while (!read1Acquired.get() && ok());
AtomicBoolean aboutToAcquireWrite = new AtomicBoolean();
// readActions2 should try to acquire read action when write action is pending
Thread readActions2 = new Thread(() -> {
try {
assertFalse(ApplicationManager.getApplication().isDispatchThread());
while (!aboutToAcquireWrite.get());
while (!aboutToAcquireWrite.get() && ok());
TimeoutUtil.sleep(2000); // make sure it called writelock
long stamp = lock.readLock();
try {
@@ -220,9 +222,9 @@ public class ApplicationImplTest extends PlatformTestCase {
System.out.println("read lock2 released");
}
}
catch (Exception e) {
catch (Throwable e) {
exception = e;
throw e;
throw new RuntimeException(e);
}
}, "read lock2");
readActions2.start();
@@ -230,12 +232,12 @@ public class ApplicationImplTest extends PlatformTestCase {
Thread checkThread = new Thread(()->{
try {
assertFalse(ApplicationManager.getApplication().isDispatchThread());
while (!aboutToAcquireWrite.get());
while (!read1Acquired.get());
while (!aboutToAcquireWrite.get() && ok());
while (!read1Acquired.get() && ok());
TimeoutUtil.sleep(2000); // make sure it called writelock
long timeout = System.currentTimeMillis() + 10000;
while (System.currentTimeMillis() < timeout) {
while (System.currentTimeMillis() < timeout && ok()) {
assertTrue(aboutToAcquireWrite.get());
assertTrue(read1Acquired.get());
assertFalse(read1Released.get());
@@ -249,10 +251,10 @@ public class ApplicationImplTest extends PlatformTestCase {
}
holdRead1.set(false);
while (!writeAcquired.get());
while (!writeAcquired.get() && ok());
timeout = System.currentTimeMillis() + 10000;
while (System.currentTimeMillis() < timeout) {
while (System.currentTimeMillis() < timeout && ok()) {
assertTrue(aboutToAcquireWrite.get());
assertTrue(read1Acquired.get());
assertTrue(read1Released.get());
@@ -266,11 +268,11 @@ public class ApplicationImplTest extends PlatformTestCase {
holdWrite.set(false);
while (!read2Acquired.get());
while (!read2Acquired.get() && ok());
TimeoutUtil.sleep(1000); // wait for immediate release of read lock2
timeout = System.currentTimeMillis() + 10000;
while (System.currentTimeMillis() < timeout) {
while (System.currentTimeMillis() < timeout && ok()) {
assertTrue(aboutToAcquireWrite.get());
assertTrue(read1Acquired.get());
assertTrue(read1Released.get());
@@ -280,9 +282,9 @@ public class ApplicationImplTest extends PlatformTestCase {
assertTrue(writeReleased.get());
}
}
catch (Exception e) {
catch (Throwable e) {
exception = e;
throw e;
throw new RuntimeException(e);
}
}, "check");
checkThread.start();
@@ -292,7 +294,7 @@ public class ApplicationImplTest extends PlatformTestCase {
try {
System.out.println("write lock acquired");
writeAcquired.set(true);
while (holdWrite.get() && exception == null);
while (holdWrite.get() && ok());
}
finally {
lock.unlockWrite(stamp);
@@ -306,6 +308,12 @@ public class ApplicationImplTest extends PlatformTestCase {
if (exception != null) throw exception;
}
private static long timeOut;
private boolean ok() throws Throwable {
if (exception != null) throw exception;
return System.currentTimeMillis() < timeOut;
}
public void testAppLockReadWritePreference() throws Throwable {
// take read lock1.
// try to take write lock - must wait (because of taken read lock)
@@ -329,7 +337,7 @@ public class ApplicationImplTest extends PlatformTestCase {
try {
System.out.println("read lock1 acquired");
read1Acquired.set(true);
while (holdRead1.get());
while (holdRead1.get() && ok());
}
finally {
stamp.finish();
@@ -337,20 +345,20 @@ public class ApplicationImplTest extends PlatformTestCase {
System.out.println("read lock1 released");
}
}
catch (Exception e) {
catch (Throwable e) {
exception = e;
throw e;
throw new RuntimeException(e);
}
}, "read lock1");
readAction1.start();
while (!read1Acquired.get());
while (!read1Acquired.get() && ok());
AtomicBoolean aboutToAcquireWrite = new AtomicBoolean();
// readActions2 should try to acquire read action when write action is pending
Thread readActions2 = new Thread(() -> {
try {
assertFalse(ApplicationManager.getApplication().isDispatchThread());
while (!aboutToAcquireWrite.get());
while (!aboutToAcquireWrite.get() && ok());
TimeoutUtil.sleep(2000); // make sure it called writelock
AccessToken stamp = application.acquireReadActionLock();
try {
@@ -363,9 +371,9 @@ public class ApplicationImplTest extends PlatformTestCase {
System.out.println("read lock2 released");
}
}
catch (Exception e) {
catch (Throwable e) {
exception = e;
throw e;
throw new RuntimeException(e);
}
}, "read lock2");
readActions2.start();
@@ -373,12 +381,12 @@ public class ApplicationImplTest extends PlatformTestCase {
Thread checkThread = new Thread(()->{
try {
assertFalse(ApplicationManager.getApplication().isDispatchThread());
while (!aboutToAcquireWrite.get());
while (!read1Acquired.get());
while (!aboutToAcquireWrite.get() && ok());
while (!read1Acquired.get() && ok());
TimeoutUtil.sleep(2000); // make sure it called writelock
long timeout = System.currentTimeMillis() + 10000;
while (System.currentTimeMillis() < timeout) {
while (System.currentTimeMillis() < timeout && ok()) {
assertTrue(aboutToAcquireWrite.get());
assertTrue(read1Acquired.get());
assertFalse(read1Released.get());
@@ -391,10 +399,10 @@ public class ApplicationImplTest extends PlatformTestCase {
}
holdRead1.set(false);
while (!writeAcquired.get());
while (!writeAcquired.get() && ok());
timeout = System.currentTimeMillis() + 10000;
while (System.currentTimeMillis() < timeout) {
while (System.currentTimeMillis() < timeout && ok()) {
assertTrue(aboutToAcquireWrite.get());
assertTrue(read1Acquired.get());
assertTrue(read1Released.get());
@@ -408,11 +416,11 @@ public class ApplicationImplTest extends PlatformTestCase {
holdWrite.set(false);
while (!read2Acquired.get());
while (!read2Acquired.get() && ok());
TimeoutUtil.sleep(1000); // wait for immediate release of read lock2
timeout = System.currentTimeMillis() + 10000;
while (System.currentTimeMillis() < timeout) {
while (System.currentTimeMillis() < timeout && ok()) {
assertTrue(aboutToAcquireWrite.get());
assertTrue(read1Acquired.get());
assertTrue(read1Released.get());
@@ -422,9 +430,9 @@ public class ApplicationImplTest extends PlatformTestCase {
assertTrue(writeReleased.get());
}
}
catch (Exception e) {
catch (Throwable e) {
exception = e;
throw e;
throw new RuntimeException(e);
}
}, "check");
checkThread.start();
@@ -434,7 +442,7 @@ public class ApplicationImplTest extends PlatformTestCase {
try {
System.out.println("write lock acquired");
writeAcquired.set(true);
while (holdWrite.get() && exception == null);
while (holdWrite.get() && ok());
}
finally {
stamp.finish();
@@ -461,10 +469,10 @@ public class ApplicationImplTest extends PlatformTestCase {
final StringBuffer LOG = new StringBuffer();
new Thread(() -> {
try {
ApplicationManager.getApplication().runReadAction(() -> {
ApplicationManager.getApplication().runReadAction((ThrowableComputable<Object, Throwable>)() -> {
LOG.append("inside read action\n");
readStarted = true;
while (!tryingToStartWriteAction);
while (!tryingToStartWriteAction && ok());
TimeoutUtil.sleep(100);
for (int i = 0; i < anotherReadActionStarted.length; i++) {
@@ -489,7 +497,7 @@ public class ApplicationImplTest extends PlatformTestCase {
}
for (AtomicBoolean threadStarted : anotherThreadStarted) {
while (!threadStarted.get()) ;
while (!threadStarted.get() && ok()) ;
}
// now the other threads try to get read lock. we should not let them
for (int i=0; i<10; i++) {
@@ -499,6 +507,7 @@ public class ApplicationImplTest extends PlatformTestCase {
TimeoutUtil.sleep(20);
}
LOG.append("\nfinished read action");
return null;
});
}
catch (Throwable e) {
@@ -507,7 +516,7 @@ public class ApplicationImplTest extends PlatformTestCase {
}, "read").start();
while (!readStarted);
while (!readStarted && ok());
tryingToStartWriteAction = true;
LOG.append("\nwrite about to start");
ApplicationManager.getApplication().runWriteAction(() -> {
@@ -332,6 +332,7 @@ public class GeneralToSMTRunnerEventsConvertor extends GeneralTestEventsProcesso
if (mySuite != null) {
mySuite.setFinished();
myCurrentChildren.clear();
myGetChildren = true;
//fire events
fireOnSuiteFinished(mySuite);
@@ -520,6 +521,7 @@ public class GeneralToSMTRunnerEventsConvertor extends GeneralTestEventsProcesso
// current suite shouldn't be null otherwise test runner isn't correct
// or may be we are in debug mode
logProblem("Current suite is undefined. Root suite will be used.");
myGetChildren = true;
return myTestsRootNode;
}
@@ -22,6 +22,7 @@ import com.intellij.util.concurrency.Semaphore;
import gnu.trove.Equality;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.TestOnly;
import javax.swing.*;
import java.util.Collection;
@@ -160,6 +161,8 @@ public class TransferToEDTQueue<T> {
}
}
@TestOnly
@NotNull
public Collection<T> dump() {
synchronized (myQueue) {
return myQueue.toList();
@@ -169,11 +172,9 @@ public class TransferToEDTQueue<T> {
// process all queue in current thread
public void drain() {
int processed = 0;
long start = System.currentTimeMillis();
while (processNext()) {
processed++;
}
long finish = System.currentTimeMillis();
}
// blocks until all elements in the queue are processed
@@ -814,6 +814,10 @@ public class XDebugSessionImpl implements XDebugSession {
});
}
public void unsetPaused() {
myPaused.set(false);
}
@Override
public void positionReached(@NotNull final XSuspendContext suspendContext) {
enableBreakpoints();
@@ -251,19 +251,19 @@ public class GitHandlerUtil {
/**
* a progress manager to use
*/
private final ProgressIndicator myProgressIndicator;
@Nullable private final ProgressIndicator myProgressIndicator;
/**
* A constructor
*
* @param manager the project manager
* @param indicator the project manager
* @param handler a handler instance
* @param operationName an operation name
* @param showErrors if true, the errors are shown when process is terminated
*/
public GitLineHandlerListenerProgress(final ProgressIndicator manager, GitHandler handler, String operationName, boolean showErrors) {
public GitLineHandlerListenerProgress(@Nullable ProgressIndicator indicator, GitHandler handler, String operationName, boolean showErrors) {
super(handler, operationName, showErrors); //To change body of overridden methods use File | Settings | File Templates.
myProgressIndicator = manager;
myProgressIndicator = indicator;
}
/**
@@ -15,13 +15,22 @@
*/
package git4idea.push;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.ThrowableComputable;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.ui.components.JBLabel;
import com.intellij.util.ui.GridBag;
import com.intellij.util.ui.UIUtil;
import git4idea.commands.Git;
import git4idea.commands.GitCommandResult;
import git4idea.repo.GitRemote;
import git4idea.repo.GitRepository;
import git4idea.validators.GitRefNameValidator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -30,11 +39,18 @@ import java.awt.*;
class GitDefineRemoteDialog extends DialogWrapper {
private static final Logger LOG = Logger.getInstance(GitDefineRemoteDialog.class);
@NotNull private final GitRepository myRepository;
@NotNull private final Git myGit;
@NotNull private final JTextField myRemoteName;
@NotNull private final JTextField myRemoteUrl;
GitDefineRemoteDialog(@NotNull Project project) {
super(project);
GitDefineRemoteDialog(@NotNull GitRepository repository, @NotNull Git git) {
super(repository.getProject());
myRepository = repository;
myGit = git;
myRemoteName = new JTextField(GitRemote.ORIGIN_NAME, 20);
myRemoteUrl = new JTextField(20);
setTitle("Define Remote");
@@ -71,4 +87,42 @@ class GitDefineRemoteDialog extends DialogWrapper {
public JComponent getPreferredFocusedComponent() {
return myRemoteUrl;
}
@Override
protected void doOKAction() {
try {
String name = getRemoteName();
String url = getRemoteUrl();
String error = validateRemoteUnderModal(name, url);
if (error != null) {
LOG.warn(String.format("Invalid remote. Name: [%s], URL: [%s], error: %s", name, url, error));
Messages.showErrorDialog(myRepository.getProject(), error, "Invalid Remote URL");
}
else {
super.doOKAction();
}
}
catch (ProcessCanceledException pce) {
// let the dialog stay open
}
}
@Nullable
private String validateRemoteUnderModal(final String name, final String url) {
if (url.isEmpty()) {
return "URL can't be empty";
}
if (!GitRefNameValidator.getInstance().checkInput(name)) {
return "Remote name is invalid";
}
return ProgressManager.getInstance().runProcessWithProgressSynchronously(new ThrowableComputable<String, ProcessCanceledException>() {
@Override
public String compute() throws ProcessCanceledException {
final GitCommandResult result = myGit.lsRemote(myRepository.getProject(), VfsUtilCore.virtualToIoFile(myRepository.getRoot()), url);
return !result.success() ? "Remote URL is invalid: " + result.getErrorOutputAsHtmlString() : null;
}
}, "Checking URL...", true, myRepository.getProject());
}
}
@@ -31,8 +31,6 @@ import com.intellij.openapi.ui.ValidationInfo;
import com.intellij.openapi.ui.popup.ListPopup;
import com.intellij.openapi.ui.popup.PopupStep;
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.ui.ColoredTreeCellRenderer;
import com.intellij.ui.SimpleTextAttributes;
@@ -47,7 +45,6 @@ import git4idea.commands.Git;
import git4idea.commands.GitCommandResult;
import git4idea.repo.GitRemote;
import git4idea.repo.GitRepository;
import git4idea.validators.GitRefNameValidator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -162,44 +159,12 @@ public class GitPushTargetPanel extends PushTargetPanel<GitPushTarget> {
}
private void showDefineRemoteDialog() {
GitDefineRemoteDialog dialog = new GitDefineRemoteDialog(myRepository.getProject());
GitDefineRemoteDialog dialog = new GitDefineRemoteDialog(myRepository, myGit);
if (dialog.showAndGet()) {
String name = dialog.getRemoteName();
String url = dialog.getRemoteUrl();
String error = validateRemoteUnderModal(name, url);
if (error != null) {
LOG.warn(String.format("Invalid remote. Name: [%s], URL: [%s], error: %s", name, url, error));
Messages.showErrorDialog(myRepository.getProject(), error, "Invalid Remote URL");
}
else {
addRemoteUnderModal(name, url);
}
addRemoteUnderModal(dialog.getRemoteName(), dialog.getRemoteUrl());
}
}
@Nullable
private String validateRemoteUnderModal(final String name, final String url) {
if (url.isEmpty()) {
return "URL can't be empty";
}
if (!GitRefNameValidator.getInstance().checkInput(name)) {
return "Remote name is invalid";
}
final Ref<String> error = Ref.create();
ProgressManager.getInstance().run(new Task.Modal(myRepository.getProject(), "Checking URL...", true) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
indicator.setIndeterminate(true);
final GitCommandResult result = myGit.lsRemote(myRepository.getProject(), VfsUtilCore.virtualToIoFile(myRepository.getRoot()), url);
if (!result.success()) {
error.set("Remote URL is invalid: " + result.getErrorOutputAsHtmlString());
}
}
});
return error.get();
}
private void addRemoteUnderModal(@NotNull final String remoteName, @NotNull final String remoteUrl) {
ProgressManager.getInstance().run(new Task.Modal(myRepository.getProject(), "Adding remote...", true) {
private GitCommandResult myResult;
@@ -361,21 +361,17 @@ public class GitUnstashDialog extends DialogWrapper {
AccessToken token = DvcsUtil.workingTreeChangeStarted(myProject);
try {
final Ref<GitCommandResult> result = Ref.create();
final Ref<Boolean> cancelled = Ref.create();
ProgressManager.getInstance().run(new Task.Modal(h.project(), GitBundle.getString("unstash.unstashing"), true) {
final ProgressManager progressManager = ProgressManager.getInstance();
boolean completed = progressManager.runProcessWithProgressSynchronously(new Runnable() {
@Override
public void run(@NotNull final ProgressIndicator indicator) {
indicator.setIndeterminate(true);
h.addLineListener(new GitHandlerUtil.GitLineHandlerListenerProgress(indicator, h, "stash", false));
public void run() {
h.addLineListener(new GitHandlerUtil.GitLineHandlerListenerProgress(progressManager.getProgressIndicator(), h, "stash", false));
Git git = ServiceManager.getService(Git.class);
result.set(git.runCommand(new Computable.PredefinedValueComputable<GitLineHandler>(h)));
}
@Override
public void onCancel() {
cancelled.set(true);
}
});
if (cancelled.get()) return;
}, GitBundle.getString("unstash.unstashing"), true, myProject);
if (!completed) return;
ServiceManager.getService(myProject, GitPlatformFacade.class).hardRefresh(root);
GitCommandResult res = result.get();
@@ -116,7 +116,7 @@ public class GroovyLineMarkerProvider implements LineMarkerProvider {
}
if (isMember && !(element1 instanceof PsiAnonymousClass || element1.getParent() instanceof PsiAnonymousClass)) {
PsiFile file = element1.getContainingFile();
Document document = file == null ? null : PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
Document document = file == null ? null : PsiDocumentManager.getInstance(file.getProject()).getLastCommittedDocument(file);
boolean drawSeparator = false;
if (document != null) {
CharSequence documentChars = document.getCharsSequence();
@@ -24,7 +24,6 @@ import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NonNls;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -138,10 +137,5 @@ public class PropertiesGroupingStructureViewComponent extends StructureViewCompo
}
}
}
@NonNls
public String getHelpID() {
return "editing.propertyFile.bundleEditor";
}
}
@@ -29,12 +29,9 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.ide.CopyPasteManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.pom.PomTargetPsiElement;
import com.intellij.pom.references.PomService;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiNamedElement;
import com.intellij.psi.PsiTarget;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.refactoring.safeDelete.SafeDeleteHandler;
import com.intellij.ui.PopupHandler;
@@ -43,6 +40,7 @@ import com.intellij.usages.UsageView;
import com.intellij.util.ArrayFactory;
import com.intellij.util.NullableFunction;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -235,5 +233,10 @@ public class ResourceBundleStructureViewComponent extends PropertiesGroupingStru
return true;
}
}
@NonNls
public String getHelpID() {
return "editing.propertyFile.bundleEditor";
}
}
@@ -91,6 +91,7 @@ status.step.into=Stepping into
status.step.over=Stepping over
status.run.to.cursor=Run to cursor
status.process.resumed=Process resumed
status.paused.in.another.thread=Paused in another thread
error.pop.bottom.stackframe=Cannot pop bottom frame
error.pop.stackframe=An error occurred while popping stack frame: {0}
error.class.not.loaded=Class not loaded : {0}