diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/CompoundPositionManager.java b/java/debugger/impl/src/com/intellij/debugger/engine/CompoundPositionManager.java index aabdc0fcb175..a9982cd41b14 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/CompoundPositionManager.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/CompoundPositionManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -24,6 +24,7 @@ import com.intellij.debugger.jdi.StackFrameProxyImpl; import com.intellij.debugger.requests.ClassPrepareRequestor; import com.intellij.execution.filters.LineNumbersMapping; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ThreeState; import com.intellij.xdebugger.frame.XStackFrame; @@ -59,62 +60,55 @@ public class CompoundPositionManager extends PositionManagerEx implements MultiR private Cache mySourcePositionCache = new Cache(); + private interface Processor { + T process(PositionManager positionManager) throws NoDataException; + } + + private T iterate(Processor processor, T defaultValue) { + for (PositionManager positionManager : myPositionManagers) { + try { + return processor.process(positionManager); + } + catch (NoDataException ignored) {} + catch (VMDisconnectedException e) {throw e;} + catch (InternalException ignored) {} + catch (ProcessCanceledException ignored) {} + catch (Exception e) {LOG.error(e);} + catch (AssertionError e) {LOG.error(e);} + } + return defaultValue; + } + @Override - public SourcePosition getSourcePosition(Location location) { + public SourcePosition getSourcePosition(final Location location) { if (location == null) return null; SourcePosition res = mySourcePositionCache.get(location); if (res != null) return res; - for (PositionManager positionManager : myPositionManagers) { - try { - res = positionManager.getSourcePosition(location); + return iterate(new Processor() { + @Override + public SourcePosition process(PositionManager positionManager) throws NoDataException { + SourcePosition res = positionManager.getSourcePosition(location); mySourcePositionCache.put(location, res); return res; } - catch (NoDataException ignored) { - } - catch (VMDisconnectedException e) { - throw e; - } - catch (InternalException ignored) { - } - catch (Exception e) { - LOG.error(e); - } - catch (AssertionError e) { - LOG.error(e); - } - } - return null; + }, null); } @Override @NotNull - public List getAllClasses(@NotNull SourcePosition classPosition) { - for (PositionManager positionManager : myPositionManagers) { - try { + public List getAllClasses(@NotNull final SourcePosition classPosition) { + return iterate(new Processor>() { + @Override + public List process(PositionManager positionManager) throws NoDataException { return positionManager.getAllClasses(classPosition); } - catch (NoDataException ignored) { - } - catch (VMDisconnectedException e) { - throw e; - } - catch (InternalException ignored) { - } - catch (Exception e) { - LOG.error(e); - } - catch (AssertionError e) { - LOG.error(e); - } - } - return Collections.emptyList(); + }, Collections.emptyList()); } @Override @NotNull - public List locationsOfLine(@NotNull ReferenceType type, @NotNull SourcePosition position) { + public List locationsOfLine(@NotNull final ReferenceType type, @NotNull SourcePosition position) { VirtualFile file = position.getFile().getVirtualFile(); if (file != null) { LineNumbersMapping mapping = file.getUserData(LineNumbersMapping.LINE_NUMBERS_MAPPING_KEY); @@ -126,54 +120,31 @@ public class CompoundPositionManager extends PositionManagerEx implements MultiR } } - for (PositionManager positionManager : myPositionManagers) { - try { - return positionManager.locationsOfLine(type, position); + final SourcePosition finalPosition = position; + return iterate(new Processor>() { + @Override + public List process(PositionManager positionManager) throws NoDataException { + return positionManager.locationsOfLine(type, finalPosition); } - catch (NoDataException ignored) { - } - catch (VMDisconnectedException e) { - throw e; - } - catch (InternalException ignored) { - } - catch (Exception e) { - LOG.error(e); - } - catch (AssertionError e) { - LOG.error(e); - } - } - return Collections.emptyList(); + }, Collections.emptyList()); } @Override - public ClassPrepareRequest createPrepareRequest(@NotNull ClassPrepareRequestor requestor, @NotNull SourcePosition position) { - for (PositionManager positionManager : myPositionManagers) { - try { + public ClassPrepareRequest createPrepareRequest(@NotNull final ClassPrepareRequestor requestor, @NotNull final SourcePosition position) { + return iterate(new Processor() { + @Override + public ClassPrepareRequest process(PositionManager positionManager) throws NoDataException { return positionManager.createPrepareRequest(requestor, position); } - catch (NoDataException ignored) { - } - catch (VMDisconnectedException e) { - throw e; - } - catch (Exception e) { - LOG.error(e); - } - catch (AssertionError e) { - LOG.error(e); - } - } - - return null; + }, null); } @NotNull @Override - public List createPrepareRequests(@NotNull ClassPrepareRequestor requestor, @NotNull SourcePosition position) { - for (PositionManager positionManager : myPositionManagers) { - try { + public List createPrepareRequests(@NotNull final ClassPrepareRequestor requestor, @NotNull final SourcePosition position) { + return iterate(new Processor>() { + @Override + public List process(PositionManager positionManager) throws NoDataException { if (positionManager instanceof MultiRequestPositionManager) { return ((MultiRequestPositionManager)positionManager).createPrepareRequests(requestor, position); } @@ -185,20 +156,7 @@ public class CompoundPositionManager extends PositionManagerEx implements MultiR return Collections.singletonList(prepareRequest); } } - catch (NoDataException ignored) { - } - catch (VMDisconnectedException e) { - throw e; - } - catch (Exception e) { - LOG.error(e); - } - catch (AssertionError e) { - LOG.error(e); - } - } - - return Collections.emptyList(); + }, Collections.emptyList()); } @Nullable diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/AssignmentEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/AssignmentEvaluator.java index 05104e250ef1..d4866f56fca9 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/AssignmentEvaluator.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/AssignmentEvaluator.java @@ -20,6 +20,7 @@ import com.intellij.debugger.engine.evaluation.EvaluateException; import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil; import com.intellij.debugger.engine.evaluation.EvaluationContextImpl; import com.sun.jdi.*; +import org.jetbrains.annotations.NotNull; /** * @author lex @@ -28,7 +29,7 @@ public class AssignmentEvaluator implements Evaluator{ private final Evaluator myLeftEvaluator; private final Evaluator myRightEvaluator; - public AssignmentEvaluator(Evaluator leftEvaluator, Evaluator rightEvaluator) { + public AssignmentEvaluator(@NotNull Evaluator leftEvaluator, @NotNull Evaluator rightEvaluator) { myLeftEvaluator = leftEvaluator; myRightEvaluator = new DisableGC(rightEvaluator); } diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/BinaryExpressionEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/BinaryExpressionEvaluator.java index 14d46e7f361b..6970859ec25c 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/BinaryExpressionEvaluator.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/BinaryExpressionEvaluator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -31,6 +31,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.psi.JavaTokenType; import com.intellij.psi.tree.IElementType; import com.sun.jdi.*; +import org.jetbrains.annotations.NotNull; class BinaryExpressionEvaluator implements Evaluator { private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.engine.evaluation.expression.BinaryExpressionEvaluator"); @@ -39,7 +40,10 @@ class BinaryExpressionEvaluator implements Evaluator { private final IElementType myOpType; private final String myExpectedType; // a result of PsiType.getCanonicalText() - public BinaryExpressionEvaluator(Evaluator leftOperand, Evaluator rightOperand, IElementType opType, String expectedType) { + public BinaryExpressionEvaluator(@NotNull Evaluator leftOperand, + @NotNull Evaluator rightOperand, + @NotNull IElementType opType, + String expectedType) { myLeftOperand = new DisableGC(leftOperand); myRightOperand = new DisableGC(rightOperand); myOpType = opType; diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/InvokeThread.java b/java/debugger/impl/src/com/intellij/debugger/impl/InvokeThread.java index 2d83c119a9bf..8c98f4f5a5e4 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/InvokeThread.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/InvokeThread.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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.impl; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; import com.sun.jdi.VMDisconnectedException; @@ -157,6 +158,7 @@ public abstract class InvokeThread { catch (EventQueueClosedException ignored) { break; } + catch (ProcessCanceledException ignored) {} catch (RuntimeException e) { if(e.getCause() instanceof InterruptedException) { break; diff --git a/java/idea-ui/src/com/intellij/ide/util/projectWizard/SdkSettingsStep.java b/java/idea-ui/src/com/intellij/ide/util/projectWizard/SdkSettingsStep.java index b497b144540c..9e92b8b8ee0f 100644 --- a/java/idea-ui/src/com/intellij/ide/util/projectWizard/SdkSettingsStep.java +++ b/java/idea-ui/src/com/intellij/ide/util/projectWizard/SdkSettingsStep.java @@ -81,33 +81,12 @@ public class SdkSettingsStep extends ModuleWizardStep { if (jdk != null) { component.setValue(selectedJdkProperty, jdk.getName()); } - OnSdkSelected(jdk); + onSdkSelected(jdk); } }); - if (project != null) { - Sdk sdk = ProjectRootManager.getInstance(project).getProjectSdk(); - if (sdk != null && moduleBuilder.isSuitableSdkType(sdk.getSdkType())) { - // use project SDK - return; - } - } - else { - // set default project SDK - Project defaultProject = ProjectManager.getInstance().getDefaultProject(); - Sdk sdk = ProjectRootManager.getInstance(defaultProject).getProjectSdk(); - if (sdk != null && sdkFilter.value(sdk.getSdkType())) { - myJdkComboBox.setSelectedJdk(sdk); - } - } - - String value = component.getValue(selectedJdkProperty); - if (value != null) { - Sdk jdk = ProjectJdkTable.getInstance().findJdk(value); - if (jdk != null) { - myJdkComboBox.setSelectedJdk(jdk); - } - } + Sdk sdk = getPreselectedSdk(project, component.getValue(selectedJdkProperty), sdkFilter); + myJdkComboBox.setSelectedJdk(sdk); JButton button = new JButton("Ne\u001Bw..."); myJdkComboBox.setSetupButton(button, project, myModel, @@ -119,7 +98,32 @@ public class SdkSettingsStep extends ModuleWizardStep { myJdkPanel.add(myJdkComboBox.getSetUpButton(), BorderLayout.EAST); } - protected void OnSdkSelected(Sdk sdk) {} + private Sdk getPreselectedSdk(Project project, String lastUsedSdk, Condition sdkFilter) { + if (project != null) { + Sdk sdk = ProjectRootManager.getInstance(project).getProjectSdk(); + if (sdk != null && myModuleBuilder.isSuitableSdkType(sdk.getSdkType())) { + // use project SDK + //noinspection unchecked + myJdkComboBox.insertItemAt(new JdkComboBox.ProjectJdkComboBoxItem(), 0); + return null; + } + } + if (lastUsedSdk != null) { + Sdk sdk = ProjectJdkTable.getInstance().findJdk(lastUsedSdk); + if (sdk != null && myModuleBuilder.isSuitableSdkType(sdk.getSdkType())) { + return sdk; + } + } + // set default project SDK + Project defaultProject = ProjectManager.getInstance().getDefaultProject(); + Sdk selected = ProjectRootManager.getInstance(defaultProject).getProjectSdk(); + if (selected != null && sdkFilter.value(selected.getSdkType())) { + return selected; + } + return null; + } + + protected void onSdkSelected(Sdk sdk) {} public boolean isEmpty() { return myJdkPanel.getComponentCount() == 0; @@ -130,10 +134,6 @@ public class SdkSettingsStep extends ModuleWizardStep { return (project == null ? "Project" : "Module") + " \u001BSDK:"; } - public JdkComboBox getJdkComboBox() { - return myJdkComboBox; - } - @Override public JComponent getComponent() { return myJdkPanel; @@ -156,7 +156,7 @@ public class SdkSettingsStep extends ModuleWizardStep { @Override public boolean validate() throws ConfigurationException { - if (myJdkComboBox.getSelectedJdk() == null) { + if (myJdkComboBox.getSelectedJdk() == null && !myJdkComboBox.isProjectJdkSelected()) { if (Messages.showDialog(getNoSdkMessage(), IdeBundle.message("title.no.jdk.specified"), new String[]{CommonBundle.getYesButtonText(), CommonBundle.getNoButtonText()}, 1, Messages.getWarningIcon()) != Messages.YES) { diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JdkComboBox.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JdkComboBox.java index 43344ae2d023..41899d69db0b 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JdkComboBox.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JdkComboBox.java @@ -213,10 +213,14 @@ public class JdkComboBox extends ComboBoxWithWidePopup { @Nullable public Sdk getSelectedJdk() { - final JdkComboBoxItem selectedItem = (JdkComboBoxItem)super.getSelectedItem(); + final JdkComboBoxItem selectedItem = getSelectedItem(); return selectedItem != null? selectedItem.getJdk() : null; } + public boolean isProjectJdkSelected() { + return getSelectedItem() instanceof ProjectJdkComboBoxItem; + } + public void setSelectedJdk(Sdk jdk) { final int index = indexOf(jdk); if (index >= 0) { diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleJdkConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleJdkConfigurable.java index 66931e49de15..4a3a3c2d8a8c 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleJdkConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleJdkConfigurable.java @@ -44,7 +44,6 @@ import java.awt.event.ActionListener; */ public abstract class ModuleJdkConfigurable implements Disposable { private JdkComboBox myCbModuleJdk; - private Sdk mySelectedModuleJdk = null; private JPanel myJdkPanel; private ClasspathEditor myModuleEditor; private final ProjectSdksModel myJdksModel; @@ -78,18 +77,6 @@ public abstract class ModuleJdkConfigurable implements Disposable { init(); } - /** - * @return null if JDK should be inherited - */ - @Nullable - public Sdk getSelectedModuleJdk() { - return myJdksModel.findSdk(mySelectedModuleJdk); - } - - public boolean isInheritJdk() { - return myCbModuleJdk.getSelectedItem()instanceof JdkComboBox.ProjectJdkComboBoxItem; - } - public JComponent createComponent() { return myJdkPanel; } @@ -171,9 +158,9 @@ public abstract class ModuleJdkConfigurable implements Disposable { myFreeze = true; final String jdkName = getRootModel().getSdkName(); if (jdkName != null && !getRootModel().isSdkInherited()) { - mySelectedModuleJdk = myJdksModel.findSdk(jdkName); - if (mySelectedModuleJdk != null) { - myCbModuleJdk.setSelectedJdk(mySelectedModuleJdk); + Sdk selectedModuleJdk = myJdksModel.findSdk(jdkName); + if (selectedModuleJdk != null) { + myCbModuleJdk.setSelectedJdk(selectedModuleJdk); } else { myCbModuleJdk.setInvalidJdk(jdkName); clearCaches(); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/CheckedExceptionCompatibilityConstraint.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/CheckedExceptionCompatibilityConstraint.java index e51369e1d6cd..f03a796350d8 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/CheckedExceptionCompatibilityConstraint.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/CheckedExceptionCompatibilityConstraint.java @@ -103,51 +103,24 @@ public class CheckedExceptionCompatibilityConstraint extends InputOutputConstrai } final List thrownTypes = new ArrayList(); - if (myExpression instanceof PsiLambdaExpression) { - final PsiElement body = ((PsiLambdaExpression)myExpression).getBody(); - if (body != null) { - final List exceptions = ExceptionUtil.ourThrowsGuard.doPreventingRecursion(myExpression, false, new Computable>() { + final PsiElement body = myExpression instanceof PsiLambdaExpression ? ((PsiLambdaExpression)myExpression).getBody() : myExpression; + if (body != null) { + final List exceptions = ExceptionUtil.ourThrowsGuard.doPreventingRecursion(myExpression, false, new Computable>() { + @Override + public List compute() { + return ExceptionUtil.getUnhandledExceptions(new PsiElement[] {body}); + } + }); + if (exceptions != null) { + thrownTypes.addAll(ContainerUtil.filter(exceptions, new Condition() { @Override - public List compute() { - return ExceptionUtil.getUnhandledExceptions(new PsiElement[] {body}); + public boolean value(PsiClassType type) { + return !ExceptionUtil.isUncheckedException(type); } - }); - if (exceptions != null) { - thrownTypes.addAll(ContainerUtil.filter(exceptions, new Condition() { - @Override - public boolean value(PsiClassType type) { - return !ExceptionUtil.isUncheckedException(type); - } - })); - } - } - } else { - - final PsiMethodReferenceUtil.QualifierResolveResult qualifierResolveResult = PsiMethodReferenceUtil.getQualifierResolveResult((PsiMethodReferenceExpression)myExpression); - final PsiSubstitutor psiSubstitutor = qualifierResolveResult.getSubstitutor(); - final PsiMethod method; - if (((PsiMethodReferenceExpression)myExpression).isExact()) { - final PsiElement resolve = ((PsiMethodReferenceExpression)myExpression).getPotentiallyApplicableMember(); - if (resolve instanceof PsiMethod) { - method = (PsiMethod)resolve; - } else { - method = null; - } - } - else { - method = interfaceMethod; - } - - if (method != null) { - for (PsiType type : method.getThrowsList().getReferencedTypes()) { - type = psiSubstitutor.substitute(type); - if (type instanceof PsiClassType && !ExceptionUtil.isUncheckedException((PsiClassType)type)) { - thrownTypes.add(substitutor.substitute(type)); - } - } + })); } } - + if (expectedNonProperThrownTypes.isEmpty()) { for (PsiType thrownType : thrownTypes) { if (!isAddressed(expectedThrownTypes, thrownType)) return false; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/SkipCheckedExceptionsHandledByInterfaceMethod.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/SkipCheckedExceptionsHandledByInterfaceMethod.java new file mode 100644 index 000000000000..e25dc6bd867c --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/SkipCheckedExceptionsHandledByInterfaceMethod.java @@ -0,0 +1,14 @@ +import java.io.IOException; + +class MethodReferenceErrorHighlight { + { + match(String.class, this::foo); + } + +

void match(final Class

type, UnitApply

apply) {} + void foo(String s) throws IOException { throw new IOException(); } +} + +interface UnitApply { + void apply(I i) throws Exception; +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/regression/IDEA137795.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/regression/IDEA137795.java new file mode 100644 index 000000000000..86d58076d115 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/regression/IDEA137795.java @@ -0,0 +1,10 @@ + +import java.util.function.Function; + +class Example { + void test() { + Function firstFunction = null; + Function secondFunction = null; + Function function = firstFunction.andThen(secondFunction); + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Java8RegressionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Java8RegressionTest.java index 75776f0c78d6..976806753231 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Java8RegressionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Java8RegressionTest.java @@ -55,6 +55,10 @@ public class Java8RegressionTest extends LightDaemonAnalyzerTestCase { doTest(); } + public void testIDEA137795() throws Exception { + doTest(); + } + private void doTest() { doTest(false); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java index f400763aabf4..f8d298225533 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java @@ -394,6 +394,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(); } + public void testSkipCheckedExceptionsHandledByInterfaceMethod() throws Exception { + doTest(); + } + private void doTest() { doTest(false); } diff --git a/platform/diff-impl/src/com/intellij/diff/util/DiffDividerDrawUtil.java b/platform/diff-impl/src/com/intellij/diff/util/DiffDividerDrawUtil.java index 4b4e150d312a..64a8ba473a46 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/DiffDividerDrawUtil.java +++ b/platform/diff-impl/src/com/intellij/diff/util/DiffDividerDrawUtil.java @@ -20,7 +20,6 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.LogicalPosition; import com.intellij.openapi.ui.GraphicsConfig; import com.intellij.util.ui.GraphicsUtil; -import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -233,13 +232,20 @@ public class DiffDividerDrawUtil { } private void paint(Graphics2D g, int width, boolean paintBorder, boolean curve) { - Color borderColor = paintBorder ? DiffDrawUtil.getFramingColor(myColor) : myColor; // we need this shift, because editor background highlight is painted in range "Y(line) - 1 .. Y(line + 1) - 1" + int startY1 = myStart1 - 1; + int endY1 = myEnd1 - 1; + int startY2 = myStart2 - 1; + int endY2 = myEnd2 - 1; + + if (endY1 - startY1 < 2) endY1 = startY1 + 1; + if (endY2 - startY2 < 2) endY2 = startY2 + 1; + if (curve) { - DiffDrawUtil.drawCurveTrapezium(g, 0, width, myStart1 - 1, myEnd1 - 1, myStart2 - 1, myEnd2 - 1, myColor, borderColor); + DiffDrawUtil.drawCurveTrapezium(g, 0, width, startY1, endY1, startY2, endY2, myColor, null); } else { - DiffDrawUtil.drawTrapezium(g, 0, width, myStart1 - 1, myEnd1 - 1, myStart2 - 1, myEnd2 - 1, myColor, borderColor); + DiffDrawUtil.drawTrapezium(g, 0, width, startY1, endY1, startY2, endY2, myColor, null); } } @@ -255,12 +261,11 @@ public class DiffDividerDrawUtil { if (height > 2) { g.fillRect(startX, startY, width, height); - Color framingColor = DiffDrawUtil.getFramingColor(myColor); - UIUtil.drawLine(g, startX, startY, endX, startY, null, framingColor); - UIUtil.drawLine(g, startX, endY, endX, endY, null, framingColor); + DiffDrawUtil.drawChunkBorderLine(g, startX, endX, startY, myColor); + DiffDrawUtil.drawChunkBorderLine(g, startX, endX, endY, myColor); } else { - DiffDrawUtil.drawDoubleShadowedLine(g, startX, endX, startY, myColor); + DiffDrawUtil.drawDoubleChunkBorderLine(g, startX, endX, startY, myColor); } } diff --git a/platform/diff-impl/src/com/intellij/diff/util/DiffDrawUtil.java b/platform/diff-impl/src/com/intellij/diff/util/DiffDrawUtil.java index 75e4c2a69845..d763e54ce2f0 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/DiffDrawUtil.java +++ b/platform/diff-impl/src/com/intellij/diff/util/DiffDrawUtil.java @@ -57,13 +57,13 @@ public class DiffDrawUtil { DiffLineSeparatorRenderer.drawConnectorLine(g, x1, x2, start1, end1, start2, end2); } - public static void drawDoubleShadowedLine(@NotNull Graphics2D g, int x1, int x2, int y, @NotNull Color color) { - UIUtil.drawLine(g, x1, y, x2, y, null, getFramingColor(color)); + public static void drawDoubleChunkBorderLine(@NotNull Graphics2D g, int x1, int x2, int y, @NotNull Color color) { + UIUtil.drawLine(g, x1, y, x2, y, null, color); UIUtil.drawLine(g, x1, y + 1, x2, y + 1, null, color); } - public static void drawShadowedLine(@NotNull Graphics2D g, int x1, int x2, int y, @NotNull Color color) { - UIUtil.drawLine(g, x1, y, x2, y, null, getFramingColor(color)); + public static void drawChunkBorderLine(@NotNull Graphics2D g, int x1, int x2, int y, @NotNull Color color) { + UIUtil.drawLine(g, x1, y, x2, y, null, color); } public static void drawTrapezium(@NotNull Graphics2D g, @@ -71,7 +71,7 @@ public class DiffDrawUtil { int start1, int end1, int start2, int end2, @NotNull Color color) { - drawTrapezium(g, x1, x2, start1, end1, start2, end2, color, getFramingColor(color)); + drawTrapezium(g, x1, x2, start1, end1, start2, end2, color, null); } public static void drawTrapezium(@NotNull Graphics2D g, @@ -80,10 +80,10 @@ public class DiffDrawUtil { int start2, int end2, @Nullable Color fillColor, @Nullable Color borderColor) { - final int[] xPoints = new int[]{x1, x2, x2, x1}; - final int[] yPoints = new int[]{start1, start2, end2, end1}; - if (fillColor != null) { + final int[] xPoints = new int[]{x1, x2, x2, x1}; + final int[] yPoints = new int[]{start1, start2, end2 + 1, end1 + 1}; + g.setColor(fillColor); g.fillPolygon(xPoints, yPoints, xPoints.length); } @@ -100,7 +100,7 @@ public class DiffDrawUtil { int start1, int end1, int start2, int end2, @NotNull Color color) { - drawCurveTrapezium(g, x1, x2, start1, end1, start2, end2, color, getFramingColor(color)); + drawCurveTrapezium(g, x1, x2, start1, end1, start2, end2, color, null); } public static void drawCurveTrapezium(@NotNull Graphics2D g, @@ -108,23 +108,24 @@ public class DiffDrawUtil { int start1, int end1, int start2, int end2, @Nullable Color fillColor, - @Nullable Color frameColor) { + @Nullable Color borderColor) { Shape upperCurve = makeCurve(x1, x2, start1, start2, true); - Shape lowerCurve = makeCurve(x1, x2, end1, end2, false); - - Path2D path = new Path2D.Double(); - path.append(upperCurve, true); - path.append(lowerCurve, true); + Shape lowerCurve = makeCurve(x1, x2, end1 + 1, end2 + 1, false); + Shape lowerCurveBorder = makeCurve(x1, x2, end1, end2, false); if (fillColor != null) { + Path2D path = new Path2D.Double(); + path.append(upperCurve, true); + path.append(lowerCurve, true); + g.setColor(fillColor); g.fill(path); } - if (frameColor != null) { - g.setColor(frameColor); + if (borderColor != null) { + g.setColor(borderColor); g.draw(upperCurve); - g.draw(lowerCurve); + g.draw(lowerCurveBorder); } } @@ -150,11 +151,6 @@ public class DiffDrawUtil { // Colors // - @NotNull - public static Color getFramingColor(@NotNull Color backgroundColor) { - return backgroundColor.darker(); - } - @NotNull public static TextAttributes getTextAttributes(@NotNull final TextDiffType type, @Nullable final Editor editor, @@ -257,10 +253,10 @@ public class DiffDrawUtil { Rectangle clip = g.getClipBounds(); x2 = clip.x + clip.width; if (doubleLine) { - drawDoubleShadowedLine((Graphics2D)g, x1, x2, y, type.getColor(editor)); + drawDoubleChunkBorderLine((Graphics2D)g, x1, x2, y, type.getColor(editor)); } else { - drawShadowedLine((Graphics2D)g, x1, x2, y, type.getColor(editor)); + drawChunkBorderLine((Graphics2D)g, x1, x2, y, type.getColor(editor)); } } }; diff --git a/platform/diff-impl/src/com/intellij/diff/util/DiffLineMarkerRenderer.java b/platform/diff-impl/src/com/intellij/diff/util/DiffLineMarkerRenderer.java index b14f925d7bea..09f8da940e7b 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/DiffLineMarkerRenderer.java +++ b/platform/diff-impl/src/com/intellij/diff/util/DiffLineMarkerRenderer.java @@ -44,13 +44,13 @@ public class DiffLineMarkerRenderer implements LineMarkerRenderer { if (height > 2) { g.setColor(color); g.fillRect(x, y, width, height); - DiffDrawUtil.drawShadowedLine(g2, x, x + width, y - 1, color); - DiffDrawUtil.drawShadowedLine(g2, x, x + width, y + height - 1, color); + DiffDrawUtil.drawChunkBorderLine(g2, x, x + width, y - 1, color); + DiffDrawUtil.drawChunkBorderLine(g2, x, x + width, y + height - 1, color); } else { // range is empty - insertion or deletion // Draw 2 pixel line in that case - DiffDrawUtil.drawDoubleShadowedLine(g2, x, x + width, y - 1, color); + DiffDrawUtil.drawDoubleChunkBorderLine(g2, x, x + width, y - 1, color); } } } diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java index 4c8b86b75fef..d8b492b5630f 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java @@ -48,6 +48,8 @@ import javax.swing.event.*; import javax.swing.tree.*; import java.awt.*; import java.awt.event.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import java.util.Collection; import java.util.Collections; import java.util.EventObject; @@ -258,13 +260,24 @@ public class PushLog extends JPanel implements DataProvider { linkLabel.setListener(new LinkListener() { @Override public void linkSelected(LinkLabel aSource, String aLinkData) { - mySyncStrategy = true; - DefaultMutableTreeNode nodeToEdit = getFirstNodeToEdit(); - if (nodeToEdit != null) { - myTree.startEditingAtPath(TreeUtil.getPathFromRoot(nodeToEdit)); + if (linkLabel.isEnabled()) { + mySyncStrategy = true; + DefaultMutableTreeNode nodeToEdit = getFirstNodeToEdit(); + if (nodeToEdit != null) { + myTree.startEditingAtPath(TreeUtil.getPathFromRoot(nodeToEdit)); + } } } }, null); + myTree.addPropertyChangeListener(PushLogTreeUtil.EDIT_MODE_PROP, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + Boolean editMode = (Boolean)evt.getNewValue(); + linkLabel.setEnabled(!editMode); + linkLabel.setPaintUnderline(!editMode); + linkLabel.repaint(); + } + }); labelPanel.add(linkLabel, BorderLayout.EAST); return labelPanel; } diff --git a/platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.java b/platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.java index 1932622b8996..1d8166ffe8b0 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.java +++ b/platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.java @@ -86,7 +86,7 @@ public class UISettings extends SimpleModificationTracker implements PersistentS public boolean ALWAYS_SHOW_WINDOW_BUTTONS = false; public boolean CYCLE_SCROLLING = true; public boolean SCROLL_TAB_LAYOUT_IN_EDITOR = true; - public boolean HIDE_TABS_IF_NEED = false; + public boolean HIDE_TABS_IF_NEED = true; public boolean SHOW_CLOSE_BUTTON = true; public int EDITOR_TAB_PLACEMENT = 1; public boolean HIDE_KNOWN_EXTENSION_IN_TABS = false; diff --git a/platform/lang-api/src/com/intellij/ide/util/projectWizard/SettingsStep.java b/platform/lang-api/src/com/intellij/ide/util/projectWizard/SettingsStep.java index a8941d34d436..0d435fefefdc 100644 --- a/platform/lang-api/src/com/intellij/ide/util/projectWizard/SettingsStep.java +++ b/platform/lang-api/src/com/intellij/ide/util/projectWizard/SettingsStep.java @@ -26,7 +26,6 @@ import javax.swing.*; */ public interface SettingsStep { - @Nullable WizardContext getContext(); void addSettingsField(@NotNull String label, @NotNull JComponent field); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/ImplementationViewComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/ImplementationViewComponent.java index 1dfff7e75cff..4c6af43a5027 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hint/ImplementationViewComponent.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/ImplementationViewComponent.java @@ -24,8 +24,6 @@ import com.intellij.navigation.NavigationItem; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.*; -import com.intellij.openapi.editor.colors.EditorColors; -import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.editor.highlighter.EditorHighlighter; import com.intellij.openapi.fileEditor.FileEditor; @@ -143,8 +141,7 @@ public class ImplementationViewComponent extends JPanel { Document doc = factory.createDocument(""); doc.setReadOnly(true); myEditor = factory.createEditor(doc, project); - - setBackgroundColor(myEditor); + ((EditorEx)myEditor).setBackgroundColor(EditorFragmentComponent.getBackgroundColor(myEditor)); final EditorSettings settings = myEditor.getSettings(); settings.setAdditionalLinesCount(1); @@ -247,15 +244,6 @@ public class ImplementationViewComponent extends JPanel { }); } - private static void setBackgroundColor(Editor editor) { - EditorColorsScheme colorsScheme = editor.getColorsScheme(); - Color color = colorsScheme.getColor(EditorColors.CARET_ROW_COLOR); - if (color == null) { - color = colorsScheme.getDefaultBackground(); - } - ((EditorEx)editor).setBackgroundColor(color); - } - private void updateRenderer(final Project project) { myFileChooser.setRenderer(new ListCellRendererWrapper() { @Override diff --git a/platform/lang-impl/src/com/intellij/internal/DumpScreenConfigurationAction.java b/platform/lang-impl/src/com/intellij/internal/DumpScreenConfigurationAction.java index 79d9461f2eda..4b47f7485577 100644 --- a/platform/lang-impl/src/com/intellij/internal/DumpScreenConfigurationAction.java +++ b/platform/lang-impl/src/com/intellij/internal/DumpScreenConfigurationAction.java @@ -230,12 +230,13 @@ public class DumpScreenConfigurationAction extends DumbAwareAction { g.fillRect(x, y, bounds.width, bounds.height); String id = String.valueOf(i + 1); + int size = Math.min(bounds.width << 1, bounds.height); g.setColor(JBColor.WHITE); - g.setFont(new Font("Monospaced", Font.BOLD, Math.min(bounds.width, bounds.height))); + g.setFont(new Font("Monospaced", Font.BOLD, size)); FontMetrics fm = g.getFontMetrics(); x += (bounds.width - fm.stringWidth(id)) / 2; y += (bounds.height - fm.getHeight()) / 2; - g.drawString(id, x, y + bounds.height); + g.drawString(id, x, y + size); } g.dispose(); } diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java index 21f02bf10972..5e6c1ad6685a 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java @@ -2512,6 +2512,12 @@ public class FileBasedIndexImpl extends FileBasedIndex { IndexingStamp.flushCaches(); myIndexableSets.remove(set); myIndexableSetToProjectMap.remove(set); + + for (VirtualFile file : myChangedFilesCollector.getAllFilesToUpdate()) { + if (getIndexableSetForFile(file) == null) { + myChangedFilesCollector.myFilesToUpdate.remove(file); + } + } } @Override diff --git a/platform/platform-api/src/com/intellij/openapi/ui/ThreeComponentsSplitter.java b/platform/platform-api/src/com/intellij/openapi/ui/ThreeComponentsSplitter.java index 8d3bf33f3fc2..51850b175ea5 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/ThreeComponentsSplitter.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/ThreeComponentsSplitter.java @@ -19,6 +19,7 @@ import com.intellij.icons.AllIcons; import com.intellij.openapi.Disposable; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Weighted; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.wm.IdeGlassPane; import com.intellij.openapi.wm.IdeGlassPaneUtil; import com.intellij.ui.ClickListener; @@ -86,9 +87,9 @@ public class ThreeComponentsSplitter extends JPanel implements Disposable { public ThreeComponentsSplitter(boolean vertical, boolean onePixelDividers) { myVerticalSplit = vertical; myShowDividerControls = false; - myFirstDivider = new Divider(true); + myFirstDivider = new Divider(true, onePixelDividers); Disposer.register(this, myFirstDivider); - myLastDivider = new Divider(false); + myLastDivider = new Divider(false, onePixelDividers); Disposer.register(this, myLastDivider); myDividerWidth = onePixelDividers ? 1 : 7; @@ -457,10 +458,16 @@ public class ThreeComponentsSplitter extends JPanel implements Disposable { } private class Divider extends JPanel implements Disposable { + private final boolean myIsOnePixel; protected boolean myDragging; protected Point myPoint; private final boolean myIsFirst; + @Override + public void paint(Graphics g) { + super.paint(g); + } + private IdeGlassPane myGlassPane; private class MyMouseAdapter extends MouseAdapter implements Weighted { @@ -523,8 +530,9 @@ public class ThreeComponentsSplitter extends JPanel implements Disposable { private boolean myWasPressedOnMe; - public Divider(boolean isFirst) { + public Divider(boolean isFirst, boolean isOnePixel) { super(new GridBagLayout()); + myIsOnePixel = isOnePixel; setFocusable(false); enableEvents(MouseEvent.MOUSE_EVENT_MASK | MouseEvent.MOUSE_MOTION_EVENT_MASK); myIsFirst = isFirst; @@ -541,10 +549,11 @@ public class ThreeComponentsSplitter extends JPanel implements Disposable { private boolean isInside(Point p) { if (!isVisible()) return false; + int dndOff = myIsOnePixel ? Registry.intValue("ide.splitter.mouseZone") : 0; if (myVerticalSplit) { if (p.x >= 0 && p.x < getWidth()) { if (getHeight() > 0) { - return p.y >= 0 && p.y < getHeight(); + return p.y >= -dndOff && p.y < getHeight() + dndOff; } else { return p.y >= -myDividerZone / 2 && p.y <= myDividerZone / 2; @@ -554,7 +563,7 @@ public class ThreeComponentsSplitter extends JPanel implements Disposable { else { if (p.y >= 0 && p.y < getHeight()) { if (getWidth() > 0) { - return p.x >= 0 && p.x < getWidth(); + return p.x >= -dndOff && p.x < getWidth() + dndOff; } else { return p.x >= -myDividerZone / 2 && p.x <= myDividerZone / 2; diff --git a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.java b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.java index d0a875598203..8baa090b2af2 100644 --- a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.java +++ b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.java @@ -96,6 +96,9 @@ public abstract class ToolWindowManager { @NotNull public abstract ToolWindow registerToolWindow(@NotNull String id, boolean canCloseContent, @NotNull ToolWindowAnchor anchor, Disposable parentDisposable, boolean canWorkInDumbMode); + @NotNull + public abstract ToolWindow registerToolWindow(@NotNull String id, boolean canCloseContent, @NotNull ToolWindowAnchor anchor, Disposable parentDisposable, boolean canWorkInDumbMode, boolean secondary); + @NotNull public ToolWindow registerToolWindow(@NotNull final String id, final boolean canCloseContent, diff --git a/platform/platform-impl/src/com/intellij/codeInsight/hint/EditorFragmentComponent.java b/platform/platform-impl/src/com/intellij/codeInsight/hint/EditorFragmentComponent.java index d038d7aade6f..2d8be80bc861 100644 --- a/platform/platform-impl/src/com/intellij/codeInsight/hint/EditorFragmentComponent.java +++ b/platform/platform-impl/src/com/intellij/codeInsight/hint/EditorFragmentComponent.java @@ -22,6 +22,7 @@ import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.LogicalPosition; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.editor.ex.FoldingModelEx; import com.intellij.openapi.util.TextRange; @@ -62,9 +63,6 @@ public class EditorFragmentComponent extends JPanel { if (!showFolding) { foldingModel.setFoldingEnabled(false); } - - boolean isCaretRowShown = editor.getSettings().isCaretRowShown(); - editor.getSettings().setCaretRowShown(false); Point p1 = editor.logicalPositionToXY(new LogicalPosition(startLine, 0)); Point p2 = editor.logicalPositionToXY(new LogicalPosition(Math.max(endLine, startLine + 1), 0)); @@ -113,8 +111,6 @@ public class EditorFragmentComponent extends JPanel { if (wasVisible) { editor.setCaretVisible(true); } - - editor.getSettings().setCaretRowShown(isCaretRowShown); if (!showFolding) { foldingModel.setFoldingEnabled(isFoldingEnabled); @@ -148,7 +144,7 @@ public class EditorFragmentComponent extends JPanel { final Color borderColor = editor.getColorsScheme().getColor(EditorColors.SELECTED_TEARLINE_COLOR); Border outsideBorder = BorderFactory.createLineBorder(borderColor, 1); - Border insideBorder = BorderFactory.createEmptyBorder(2, 0, 2, 2); + Border insideBorder = BorderFactory.createEmptyBorder(2, 2, 2, 2); setBorder(BorderFactory.createCompoundBorder(outsideBorder, insideBorder)); } @@ -163,6 +159,21 @@ public class EditorFragmentComponent extends JPanel { boolean showUpward, boolean showFolding, boolean hideByAnyKey) { + return showEditorFragmentHintAt(editor, range, y, showUpward, showFolding, hideByAnyKey, true); + } + + /** + * @param y y coordinate in layered pane coordinate system. + * @param hideByAnyKey + */ + @Nullable + public static LightweightHint showEditorFragmentHintAt(Editor editor, + TextRange range, + int y, + boolean showUpward, + boolean showFolding, + boolean hideByAnyKey, + boolean useCaretRowBackground) { if (ApplicationManager.getApplication().isUnitTestMode()) return null; Document document = editor.getDocument(); @@ -190,8 +201,8 @@ public class EditorFragmentComponent extends JPanel { if (startLine >= endLine) return null; - EditorFragmentComponent fragmentComponent = createEditorFragmentComponent(editor, startLine, endLine, showFolding, true); - + EditorFragmentComponent fragmentComponent = createEditorFragmentComponent(editor, startLine, endLine, showFolding, true, + useCaretRowBackground); if (showUpward) { y -= fragmentComponent.getPreferredSize().height; @@ -199,7 +210,7 @@ public class EditorFragmentComponent extends JPanel { } final JComponent c = editor.getComponent(); - int x = SwingUtilities.convertPoint(c, new Point(-1, 0), UIUtil.getRootPane(c)).x; //IDEA-68016 + int x = SwingUtilities.convertPoint(c, new Point(-3,0), UIUtil.getRootPane(c)).x; //IDEA-68016 Point p = new Point(x, y); LightweightHint hint = new MyComponentHint(fragmentComponent); @@ -213,8 +224,23 @@ public class EditorFragmentComponent extends JPanel { int startLine, int endLine, boolean showFolding, boolean showGutter) { - EditorFragmentComponent fragmentComponent = new EditorFragmentComponent((EditorEx)editor, startLine, endLine, showFolding, showGutter); - fragmentComponent.setBackground(getBackgroundColor(editor)); + return createEditorFragmentComponent(editor, startLine, endLine, showFolding, showGutter, true); + } + + public static EditorFragmentComponent createEditorFragmentComponent(Editor editor, + int startLine, + int endLine, + boolean showFolding, boolean showGutter, + boolean useCaretRowBackground) { + final EditorEx editorEx = (EditorEx)editor; + final Color old = editorEx.getBackgroundColor(); + Color backColor = getBackgroundColor(editor, useCaretRowBackground); + editorEx.setBackgroundColor(backColor); + EditorFragmentComponent fragmentComponent = new EditorFragmentComponent(editorEx, startLine, endLine, + showFolding, showGutter); + fragmentComponent.setBackground(backColor); + + editorEx.setBackgroundColor(old); return fragmentComponent; } @@ -226,11 +252,20 @@ public class EditorFragmentComponent extends JPanel { if (rootPane == null) return null; JLayeredPane layeredPane = rootPane.getLayeredPane(); Point point = SwingUtilities.convertPoint(editorComponent, -2, 0, layeredPane); - return showEditorFragmentHintAt(editor, range, point.y, true, showFolding, hideByAnyKey); + return showEditorFragmentHintAt(editor, range, point.y, true, showFolding, hideByAnyKey, false); } public static Color getBackgroundColor(Editor editor){ - return editor.getColorsScheme().getDefaultBackground(); + return getBackgroundColor(editor, true); + } + + public static Color getBackgroundColor(Editor editor, boolean useCaretRowBackground){ + EditorColorsScheme colorsScheme = editor.getColorsScheme(); + Color color = colorsScheme.getColor(EditorColors.CARET_ROW_COLOR); + if (!useCaretRowBackground || color == null){ + color = colorsScheme.getDefaultBackground(); + } + return color; } private static class MyComponentHint extends LightweightHint { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/SettingsImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/SettingsImpl.java index 975257f8011e..ed14e128a804 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/SettingsImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/SettingsImpl.java @@ -429,9 +429,7 @@ public class SettingsImpl implements EditorSettings { final Boolean newValue = val ? Boolean.TRUE : Boolean.FALSE; if (newValue.equals(myCaretRowShown)) return; myCaretRowShown = newValue; - if (myEditor instanceof EditorImpl) { - ((EditorImpl)myEditor).getCaretModel().reinitSettings(); - } + fireEditorRefresh(); } @Override diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java index b97e14b495e4..2701e7ea5404 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/FSRecords.java @@ -518,7 +518,8 @@ public class FSRecords implements Forceable { private static RuntimeException handleError(final Throwable e) { if (!ourIsDisposed) { // No need to forcibly mark VFS corrupted if it is already shut down - if (!myCorrupted) { + if (!myCorrupted && w.tryLock()) { // avoid deadlock if r lock is occupied by current thread + w.unlock(); createBrokenMarkerFile(e); myCorrupted = true; force(); diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeadlessManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeadlessManagerImpl.java index b4d20378fc06..a8d83ebac235 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeadlessManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeadlessManagerImpl.java @@ -143,6 +143,17 @@ public class ToolWindowHeadlessManagerImpl extends ToolWindowManagerEx { return doRegisterToolWindow(id, parentDisposable); } + @NotNull + @Override + public ToolWindow registerToolWindow(@NotNull String id, + boolean canCloseContent, + @NotNull ToolWindowAnchor anchor, + Disposable parentDisposable, + boolean canWorkInDumbMode, + boolean secondary) { + return doRegisterToolWindow(id, parentDisposable); + } + @Override public void unregisterToolWindow(@NotNull String id) { myToolWindows.remove(id); diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java index 46f66ed21dfb..e7240a66a5b2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java @@ -1146,7 +1146,18 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements @NotNull final ToolWindowAnchor anchor, @NotNull final Disposable parentDisposable, final boolean canWorkInDumbMode) { - ToolWindow window = registerToolWindow(id, null, anchor, false, canCloseContent, canWorkInDumbMode); + return registerToolWindow(id, canCloseContent, anchor, parentDisposable, canWorkInDumbMode, false); + } + + @NotNull + @Override + public ToolWindow registerToolWindow(@NotNull String id, + boolean canCloseContent, + @NotNull ToolWindowAnchor anchor, + Disposable parentDisposable, + boolean canWorkInDumbMode, + boolean secondary) { + ToolWindow window = registerToolWindow(id, null, anchor, secondary, canCloseContent, canWorkInDumbMode); return registerDisposable(id, parentDisposable, window); } @@ -1824,8 +1835,10 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements private void appendUpdateToolWindowsPaneCmd(final List commandsList) { final JRootPane rootPane = myFrame.getRootPane(); - final FinalizableCommand command = new UpdateRootPaneCmd(rootPane, myWindowManager.getCommandProcessor()); - commandsList.add(command); + if (rootPane != null) { + final FinalizableCommand command = new UpdateRootPaneCmd(rootPane, myWindowManager.getCommandProcessor()); + commandsList.add(command); + } } private EditorsSplitters getSplittersToFocus() { diff --git a/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java b/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java index 02e6bd11ad7c..ac13621f7a9a 100644 --- a/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java +++ b/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java @@ -16,6 +16,8 @@ package org.jetbrains.io; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.util.Condition; +import com.intellij.openapi.util.Conditions; import com.intellij.util.SystemProperties; import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.BootstrapUtil; @@ -95,8 +97,13 @@ public final class NettyUtil { @Nullable public static Channel connect(@NotNull Bootstrap bootstrap, @NotNull InetSocketAddress remoteAddress, @Nullable AsyncPromise promise, int maxAttemptCount) { + return connect(bootstrap, remoteAddress, promise, maxAttemptCount, null); + } + + @Nullable + public static Channel connect(@NotNull Bootstrap bootstrap, @NotNull InetSocketAddress remoteAddress, @Nullable AsyncPromise promise, int maxAttemptCount, @Nullable Condition stopCondition) { try { - return doConnect(bootstrap, remoteAddress, promise, maxAttemptCount); + return doConnect(bootstrap, remoteAddress, promise, maxAttemptCount, stopCondition == null ? Conditions.alwaysFalse() : stopCondition); } catch (Throwable e) { if (promise != null) { @@ -107,7 +114,11 @@ public final class NettyUtil { } @Nullable - private static Channel doConnect(@NotNull Bootstrap bootstrap, @NotNull InetSocketAddress remoteAddress, @Nullable AsyncPromise promise, int maxAttemptCount) throws Throwable { + private static Channel doConnect(@NotNull Bootstrap bootstrap, + @NotNull InetSocketAddress remoteAddress, + @Nullable AsyncPromise promise, + int maxAttemptCount, + @NotNull Condition stopCondition) throws Throwable { int attemptCount = 0; if (bootstrap.group() instanceof NioEventLoopGroup) { @@ -116,6 +127,9 @@ public final class NettyUtil { if (future.isSuccess()) { return future.channel(); } + else if (stopCondition.value(null) || (promise != null && promise.getState() == Promise.State.REJECTED)) { + return null; + } else if (maxAttemptCount == -1) { //noinspection BusyWait Thread.sleep(300); @@ -145,7 +159,10 @@ public final class NettyUtil { break; } catch (IOException e) { - if (maxAttemptCount == -1) { + if (stopCondition.value(null) || (promise != null && promise.getState() == Promise.State.REJECTED)) { + return null; + } + else if (maxAttemptCount == -1) { //noinspection BusyWait Thread.sleep(300); attemptCount++; diff --git a/platform/platform-resources/src/DefaultColorSchemesManager.xml b/platform/platform-resources/src/DefaultColorSchemesManager.xml index 95b4c8ca5065..10f717aa29d8 100644 --- a/platform/platform-resources/src/DefaultColorSchemesManager.xml +++ b/platform/platform-resources/src/DefaultColorSchemesManager.xml @@ -385,7 +385,7 @@