mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
@@ -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<Location, SourcePosition> mySourcePositionCache = new Cache<Location, SourcePosition>();
|
||||
|
||||
private interface Processor<T> {
|
||||
T process(PositionManager positionManager) throws NoDataException;
|
||||
}
|
||||
|
||||
private <T> T iterate(Processor<T> 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<SourcePosition>() {
|
||||
@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<ReferenceType> getAllClasses(@NotNull SourcePosition classPosition) {
|
||||
for (PositionManager positionManager : myPositionManagers) {
|
||||
try {
|
||||
public List<ReferenceType> getAllClasses(@NotNull final SourcePosition classPosition) {
|
||||
return iterate(new Processor<List<ReferenceType>>() {
|
||||
@Override
|
||||
public List<ReferenceType> 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.<ReferenceType>emptyList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<Location> locationsOfLine(@NotNull ReferenceType type, @NotNull SourcePosition position) {
|
||||
public List<Location> 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<List<Location>>() {
|
||||
@Override
|
||||
public List<Location> 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.<Location>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<ClassPrepareRequest>() {
|
||||
@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<ClassPrepareRequest> createPrepareRequests(@NotNull ClassPrepareRequestor requestor, @NotNull SourcePosition position) {
|
||||
for (PositionManager positionManager : myPositionManagers) {
|
||||
try {
|
||||
public List<ClassPrepareRequest> createPrepareRequests(@NotNull final ClassPrepareRequestor requestor, @NotNull final SourcePosition position) {
|
||||
return iterate(new Processor<List<ClassPrepareRequest>>() {
|
||||
@Override
|
||||
public List<ClassPrepareRequest> 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.<ClassPrepareRequest>emptyList());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+2
-1
@@ -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);
|
||||
}
|
||||
|
||||
+6
-2
@@ -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;
|
||||
|
||||
@@ -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<E extends PrioritizedTask> {
|
||||
catch (EventQueueClosedException ignored) {
|
||||
break;
|
||||
}
|
||||
catch (ProcessCanceledException ignored) {}
|
||||
catch (RuntimeException e) {
|
||||
if(e.getCause() instanceof InterruptedException) {
|
||||
break;
|
||||
|
||||
@@ -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<SdkTypeId> 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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+3
-16
@@ -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();
|
||||
|
||||
+14
-41
@@ -103,51 +103,24 @@ public class CheckedExceptionCompatibilityConstraint extends InputOutputConstrai
|
||||
}
|
||||
|
||||
final List<PsiType> thrownTypes = new ArrayList<PsiType>();
|
||||
if (myExpression instanceof PsiLambdaExpression) {
|
||||
final PsiElement body = ((PsiLambdaExpression)myExpression).getBody();
|
||||
if (body != null) {
|
||||
final List<PsiClassType> exceptions = ExceptionUtil.ourThrowsGuard.doPreventingRecursion(myExpression, false, new Computable<List<PsiClassType>>() {
|
||||
final PsiElement body = myExpression instanceof PsiLambdaExpression ? ((PsiLambdaExpression)myExpression).getBody() : myExpression;
|
||||
if (body != null) {
|
||||
final List<PsiClassType> exceptions = ExceptionUtil.ourThrowsGuard.doPreventingRecursion(myExpression, false, new Computable<List<PsiClassType>>() {
|
||||
@Override
|
||||
public List<PsiClassType> compute() {
|
||||
return ExceptionUtil.getUnhandledExceptions(new PsiElement[] {body});
|
||||
}
|
||||
});
|
||||
if (exceptions != null) {
|
||||
thrownTypes.addAll(ContainerUtil.filter(exceptions, new Condition<PsiClassType>() {
|
||||
@Override
|
||||
public List<PsiClassType> 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<PsiClassType>() {
|
||||
@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;
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.io.IOException;
|
||||
|
||||
class MethodReferenceErrorHighlight {
|
||||
{
|
||||
match(String.class, this::foo);
|
||||
}
|
||||
|
||||
<P> void match(final Class<P> type, UnitApply<P> apply) {}
|
||||
void foo(String s) throws IOException { throw new IOException(); }
|
||||
}
|
||||
|
||||
interface UnitApply<I> {
|
||||
void apply(I i) throws Exception;
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
class Example {
|
||||
void test() {
|
||||
Function<? super Integer, Float> firstFunction = null;
|
||||
Function<Float, String> secondFunction = null;
|
||||
Function<? super Integer, String> function = firstFunction.andThen(secondFunction);
|
||||
}
|
||||
}
|
||||
+4
@@ -55,6 +55,10 @@ public class Java8RegressionTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA137795() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
+4
@@ -394,6 +394,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSkipCheckedExceptionsHandledByInterfaceMethod() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<String>() {
|
||||
@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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -26,7 +26,6 @@ import javax.swing.*;
|
||||
*/
|
||||
public interface SettingsStep {
|
||||
|
||||
@Nullable
|
||||
WizardContext getContext();
|
||||
|
||||
void addSettingsField(@NotNull String label, @NotNull JComponent field);
|
||||
|
||||
+1
-13
@@ -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<FileDescriptor>() {
|
||||
@Override
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
+48
-13
@@ -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 <code>y</code> 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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
+2
-1
@@ -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();
|
||||
|
||||
+11
@@ -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);
|
||||
|
||||
@@ -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<FinalizableCommand> 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() {
|
||||
|
||||
@@ -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<Void> stopCondition) {
|
||||
try {
|
||||
return doConnect(bootstrap, remoteAddress, promise, maxAttemptCount);
|
||||
return doConnect(bootstrap, remoteAddress, promise, maxAttemptCount, stopCondition == null ? Conditions.<Void>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<Void> 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++;
|
||||
|
||||
@@ -385,7 +385,7 @@
|
||||
<option name="DIFF_INSERTED">
|
||||
<value>
|
||||
<option name="FOREGROUND"/>
|
||||
<option name="BACKGROUND" value="C8F2C8"/>
|
||||
<option name="BACKGROUND" value="BEE6BE"/>
|
||||
<option name="EFFECT_COLOR"/>
|
||||
<option name="ERROR_STRIPE_COLOR" value="AADEAA"/>
|
||||
</value>
|
||||
|
||||
+19
-3
@@ -1,8 +1,24 @@
|
||||
/*
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.debugger.connection;
|
||||
|
||||
import com.intellij.ide.browsers.WebBrowser;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.util.Consumer;
|
||||
@@ -37,10 +53,10 @@ public abstract class RemoteVmConnection extends VmConnection<Vm> {
|
||||
public abstract Bootstrap createBootstrap(@NotNull InetSocketAddress address, @NotNull AsyncPromise<Vm> promise);
|
||||
|
||||
public void open(@NotNull InetSocketAddress address) {
|
||||
open(address, false);
|
||||
open(address, null);
|
||||
}
|
||||
|
||||
public void open(@NotNull final InetSocketAddress address, final boolean waitForever) {
|
||||
public void open(@NotNull final InetSocketAddress address, final Condition<Void> stopCondition) {
|
||||
setState(ConnectionStatus.WAITING_FOR_CONNECTION, "Connecting to " + address.getHostName() + ":" + address.getPort());
|
||||
final Future<?> future = ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
|
||||
@Override
|
||||
@@ -58,7 +74,7 @@ public abstract class RemoteVmConnection extends VmConnection<Vm> {
|
||||
});
|
||||
|
||||
AsyncPromise<Void> connectionPromise = new AsyncPromise<Void>();
|
||||
NettyUtil.connect(createBootstrap(address, result), address, connectionPromise, waitForever ? -1 : NettyUtil.DEFAULT_CONNECT_ATTEMPT_COUNT);
|
||||
NettyUtil.connect(createBootstrap(address, result), address, connectionPromise, stopCondition == null ? NettyUtil.DEFAULT_CONNECT_ATTEMPT_COUNT : -1, stopCondition);
|
||||
connectionPromise.rejected(new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void consume(Throwable error) {
|
||||
|
||||
@@ -599,6 +599,17 @@ public class Mock {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ToolWindow registerToolWindow(@NotNull String id,
|
||||
boolean canCloseContent,
|
||||
@NotNull ToolWindowAnchor anchor,
|
||||
Disposable parentDisposable,
|
||||
boolean canWorkInDumbMode,
|
||||
boolean secondary) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ToolWindow registerToolWindow(@NotNull final String id, final boolean canCloseContent, @NotNull final ToolWindowAnchor anchor, final boolean secondary) {
|
||||
|
||||
@@ -128,6 +128,7 @@ public abstract class KeymapsTestCase extends PlatformTestCase {
|
||||
{ "shift control UP", "ResizeToolWindowUp", "MoveStatementUp"},
|
||||
{ "shift control alt DOWN", "VcsShowNextChangeMarker", "HtmlTableCellNavigateDown"},
|
||||
{ "shift control alt UP", "VcsShowPrevChangeMarker", "HtmlTableCellNavigateUp"},
|
||||
{ "shift control alt D", "UML.ShowChanges", "Console.TableResult.CloneColumn"},
|
||||
{ "shift control U", "ShelveChanges.UnshelveWithDialog", "EditorToggleCase"},
|
||||
{ "control E", "RecentFiles", "Vcs.ShowMessageHistory"},
|
||||
{ "control alt Z", "Vcs.RollbackChangedLines", "ChangesView.Revert"},
|
||||
|
||||
@@ -278,10 +278,8 @@ public class JBAutoscroller implements ActionListener {
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
if (e.getValueIsAdjusting() || getInstance().isRunningOn(myTable)) return;
|
||||
|
||||
ListSelectionModel rsm = getRowSelectionModel();
|
||||
int row = rsm != null ? rsm.getLeadSelectionIndex() : -1;
|
||||
ListSelectionModel csm = getColumnSelectionModel();
|
||||
int col = csm != null ? csm.getLeadSelectionIndex() : -1;
|
||||
int row = getLeadSelectionIndexIfSelectionIsNotEmpty(getRowSelectionModel());
|
||||
int col = getLeadSelectionIndexIfSelectionIsNotEmpty(getColumnSelectionModel());
|
||||
|
||||
if (row >= 0 && row < myTable.getRowCount() && col >= 0 && col < myTable.getColumnCount()) {
|
||||
myTable.scrollRectToVisible(myTable.getCellRect(row, col, false));
|
||||
@@ -329,5 +327,9 @@ public class JBAutoscroller implements ActionListener {
|
||||
to.addListSelectionListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
private static int getLeadSelectionIndexIfSelectionIsNotEmpty(ListSelectionModel lsm) {
|
||||
return lsm != null && !lsm.isSelectionEmpty() ? lsm.getLeadSelectionIndex() : -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+28
@@ -16,7 +16,11 @@
|
||||
package org.jetbrains.idea.maven.server;
|
||||
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class MavenServerUtil {
|
||||
@@ -52,6 +56,30 @@ public class MavenServerUtil {
|
||||
return mySystemPropertiesCache;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File findMavenBasedir(@NotNull File workingDir) {
|
||||
File baseDir = workingDir;
|
||||
File dir = workingDir;
|
||||
while ((dir = dir.getParentFile()) != null) {
|
||||
if (dir.listFiles(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return ".mvn".equals(name);
|
||||
}
|
||||
}).length > 0) {
|
||||
baseDir = dir;
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
return baseDir.getCanonicalFile();
|
||||
}
|
||||
catch (IOException e) {
|
||||
return baseDir.getAbsoluteFile();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static boolean isMagicalProperty(String key) {
|
||||
return key.startsWith("=");
|
||||
}
|
||||
|
||||
+30
-10
@@ -16,6 +16,7 @@
|
||||
package org.jetbrains.idea.maven.server;
|
||||
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
@@ -50,10 +51,7 @@ import org.apache.maven.project.path.PathTranslator;
|
||||
import org.apache.maven.project.validation.ModelValidationResult;
|
||||
import org.apache.maven.repository.RepositorySystem;
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.apache.maven.settings.building.DefaultSettingsBuildingRequest;
|
||||
import org.apache.maven.settings.building.SettingsBuilder;
|
||||
import org.apache.maven.settings.building.SettingsBuildingException;
|
||||
import org.apache.maven.settings.building.SettingsBuildingRequest;
|
||||
import org.apache.maven.settings.building.*;
|
||||
import org.apache.maven.shared.dependency.tree.DependencyNode;
|
||||
import org.apache.maven.shared.dependency.tree.DependencyTreeResolutionListener;
|
||||
import org.codehaus.plexus.DefaultPlexusContainer;
|
||||
@@ -69,7 +67,6 @@ import org.eclipse.aether.DefaultRepositorySystemSession;
|
||||
import org.eclipse.aether.RepositorySystemSession;
|
||||
import org.eclipse.aether.graph.Dependency;
|
||||
import org.eclipse.aether.repository.LocalRepositoryManager;
|
||||
import org.eclipse.aether.util.graph.transformer.ConflictResolver;
|
||||
import org.eclipse.aether.util.graph.visitor.PreorderNodeListGenerator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -140,12 +137,21 @@ public class Maven32ServerEmbedderImpl extends Maven3ServerEmbedder {
|
||||
}
|
||||
};
|
||||
|
||||
SettingsBuilder settingsBuilder = null;
|
||||
Class cliRequestClass;
|
||||
try {
|
||||
cliRequestClass = MavenCli.class.getClassLoader().loadClass("org.apache.maven.cli.MavenCli$CliRequest");
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException("Class \"org.apache.maven.cli.MavenCli$CliRequest\" not found");
|
||||
try {
|
||||
cliRequestClass = MavenCli.class.getClassLoader().loadClass("org.apache.maven.cli.CliRequest");
|
||||
// initialize maven.multiModuleProjectDirectory property to avoid failure in org.apache.maven.cli.MavenCli#initialize method
|
||||
System.setProperty("maven.multiModuleProjectDirectory", new File("").getPath());
|
||||
settingsBuilder = new DefaultSettingsBuilderFactory().newInstance();
|
||||
}
|
||||
catch (ClassNotFoundException e1) {
|
||||
throw new RuntimeException("unable to find maven CliRequest class");
|
||||
}
|
||||
}
|
||||
|
||||
Object cliRequest;
|
||||
@@ -183,15 +189,18 @@ public class Maven32ServerEmbedderImpl extends Maven3ServerEmbedder {
|
||||
|
||||
myContainer.getLoggerManager().setThreshold(settings.getLoggingLevel());
|
||||
|
||||
mySystemProperties = FieldAccessor.<Properties>get(cliRequestClass, cliRequest, "systemProperties");
|
||||
mySystemProperties = FieldAccessor.get(cliRequestClass, cliRequest, "systemProperties");
|
||||
|
||||
if (settings.getProjectJdk() != null) {
|
||||
mySystemProperties.setProperty("java.home", settings.getProjectJdk());
|
||||
}
|
||||
|
||||
myMavenSettings =
|
||||
buildSettings(FieldAccessor.<SettingsBuilder>get(MavenCli.class, cli, "settingsBuilder"), settings, mySystemProperties,
|
||||
FieldAccessor.<Properties>get(cliRequestClass, cliRequest, "userProperties"));
|
||||
if (settingsBuilder == null) {
|
||||
settingsBuilder = FieldAccessor.get(MavenCli.class, cli, "settingsBuilder");
|
||||
}
|
||||
|
||||
myMavenSettings = buildSettings(settingsBuilder, settings, mySystemProperties,
|
||||
FieldAccessor.<Properties>get(cliRequestClass, cliRequest, "userProperties"));
|
||||
|
||||
myLocalRepository = createLocalRepository();
|
||||
}
|
||||
@@ -619,6 +628,17 @@ public class Maven32ServerEmbedderImpl extends Maven3ServerEmbedder {
|
||||
|
||||
result.setStartTime(myBuildStartTime);
|
||||
|
||||
final Method setMultiModuleProjectDirectoryMethod =
|
||||
ReflectionUtil.findMethod(ReflectionUtil.getClassDeclaredMethods(result.getClass()), "setMultiModuleProjectDirectory", File.class);
|
||||
if (setMultiModuleProjectDirectoryMethod != null) {
|
||||
try {
|
||||
setMultiModuleProjectDirectoryMethod.invoke(result, MavenServerUtil.findMavenBasedir(file));
|
||||
}
|
||||
catch (Exception e) {
|
||||
Maven3ServerGlobals.getLogger().error(e);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (MavenExecutionRequestPopulationException e) {
|
||||
|
||||
+7
-1
@@ -57,6 +57,7 @@ import org.jetbrains.idea.maven.artifactResolver.common.MavenModuleMap;
|
||||
import org.jetbrains.idea.maven.project.MavenGeneralSettings;
|
||||
import org.jetbrains.idea.maven.project.MavenProject;
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsManager;
|
||||
import org.jetbrains.idea.maven.server.MavenServerUtil;
|
||||
import org.jetbrains.idea.maven.utils.MavenSettings;
|
||||
import org.jetbrains.idea.maven.utils.MavenUtil;
|
||||
|
||||
@@ -121,8 +122,13 @@ public class MavenExternalParameters {
|
||||
params.setJdk(getJdk(project, runnerSettings, project != null && MavenRunner.getInstance(project).getState() == runnerSettings));
|
||||
|
||||
final String mavenHome = resolveMavenHome(coreSettings, project, runConfiguration);
|
||||
final String mavenVersion = MavenUtil.getMavenVersion(mavenHome);
|
||||
|
||||
params.getProgramParametersList().add("-Didea.version=" + MavenUtil.getIdeaVersionToPassToMavenProcess());
|
||||
if (StringUtil.compareVersionNumbers(mavenVersion, "3.3") >= 0) {
|
||||
params.getVMParametersList().addProperty("maven.multiModuleProjectDirectory",
|
||||
MavenServerUtil.findMavenBasedir(parameters.getWorkingDirFile()).getPath());
|
||||
}
|
||||
|
||||
addVMParameters(params.getVMParametersList(), mavenHome, runnerSettings);
|
||||
|
||||
@@ -133,7 +139,7 @@ public class MavenExternalParameters {
|
||||
|
||||
if (project != null && parameters.isResolveToWorkspace()) {
|
||||
try {
|
||||
String resolverJar = getArtifactResolverJar(MavenUtil.getMavenVersion(mavenHome));
|
||||
String resolverJar = getArtifactResolverJar(mavenVersion);
|
||||
confFile = patchConfFile(confFile, resolverJar);
|
||||
|
||||
File modulesPathsFile = dumpModulesPaths(project);
|
||||
|
||||
+10
-11
@@ -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.
|
||||
@@ -13,39 +13,38 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.idea.maven.utils;
|
||||
|
||||
import com.intellij.openapi.application.PathMacros;
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class MavenEnvironmentRegistrar implements ApplicationComponent {
|
||||
public class MavenEnvironmentRegistrar extends ApplicationComponent.Adapter {
|
||||
private static final String MAVEN_REPOSITORY = "MAVEN_REPOSITORY";
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getComponentName() {
|
||||
return MavenEnvironmentRegistrar.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
registerPathVariable();
|
||||
}
|
||||
|
||||
private static void registerPathVariable() {
|
||||
File repository = MavenUtil.resolveLocalRepository(null, null, null);
|
||||
String repository = MavenUtil.resolveLocalRepository(null, null, null).getAbsolutePath();
|
||||
PathMacros macros = PathMacros.getInstance();
|
||||
|
||||
for (String each : macros.getAllMacroNames()) {
|
||||
String path = macros.getValue(each);
|
||||
if (path == null) continue;
|
||||
if (new File(path).equals(repository)) return;
|
||||
if (path != null && FileUtil.pathsEqual(repository, path)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
macros.setMacro(MAVEN_REPOSITORY, repository.getPath());
|
||||
}
|
||||
|
||||
public void disposeComponent() {
|
||||
macros.setMacro(MAVEN_REPOSITORY, repository);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class PythonModuleBuilder extends PythonModuleBuilderBase implements Sour
|
||||
}
|
||||
}) {
|
||||
@Override
|
||||
protected void OnSdkSelected(Sdk sdk) {
|
||||
protected void onSdkSelected(Sdk sdk) {
|
||||
setSdk(sdk);
|
||||
}
|
||||
};
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ public class PyDependentModuleMembersCollector extends DependentMembersCollector
|
||||
public void collect(final PsiNamedElement member) {
|
||||
if (member.getContainingFile() == myModule) {
|
||||
final PyResolveContext resolveContext = PyResolveContext.defaultContext();
|
||||
final PsiElement memberBody = PyMoveModuleMemberUtil.expandNamedElementBody(member);
|
||||
final PsiElement memberBody = PyMoveModuleMembersHelper.expandNamedElementBody(member);
|
||||
assert memberBody != null;
|
||||
memberBody.accept(new PyRecursiveElementVisitor() {
|
||||
@Override
|
||||
@@ -46,6 +46,6 @@ public class PyDependentModuleMembersCollector extends DependentMembersCollector
|
||||
}
|
||||
|
||||
private boolean isValidSameModuleDependency(@NotNull PsiElement element) {
|
||||
return PyMoveModuleMemberUtil.isMovableModuleMember(element) && element.getContainingFile() == myModule;
|
||||
return PyMoveModuleMembersHelper.isMovableModuleMember(element) && element.getContainingFile() == myModule;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
package com.jetbrains.python.refactoring.move;
|
||||
|
||||
import com.intellij.refactoring.classMembers.AbstractUsesDependencyMemberInfoModel;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.jetbrains.python.psi.PyElement;
|
||||
import com.jetbrains.python.psi.PyFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Mikhail Golubev
|
||||
*/
|
||||
@@ -30,23 +25,4 @@ class PyModuleMemberInfoModel extends AbstractUsesDependencyMemberInfoModel<PyEl
|
||||
protected int doCheck(@NotNull PyModuleMemberInfo memberInfo, int problem) {
|
||||
return problem == ERROR ? WARNING : problem;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<PyElement> collectTopLevelSymbols() {
|
||||
final List<PyElement> result = new ArrayList<PyElement>();
|
||||
result.addAll(myPyFile.getTopLevelAttributes());
|
||||
result.addAll(myPyFile.getTopLevelClasses());
|
||||
result.addAll(myPyFile.getTopLevelFunctions());
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<PyModuleMemberInfo> collectTopLevelSymbolsInfo() {
|
||||
return ContainerUtil.mapNotNull(collectTopLevelSymbols(), new Function<PyElement, PyModuleMemberInfo>() {
|
||||
@Override
|
||||
public PyModuleMemberInfo fun(PyElement element) {
|
||||
return new PyModuleMemberInfo(element);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,10 @@ import com.google.common.collect.Lists;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.SelectionModel;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
@@ -31,6 +34,8 @@ import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.jetbrains.python.PyBundle;
|
||||
import com.jetbrains.python.psi.PyElement;
|
||||
import com.jetbrains.python.psi.PyFile;
|
||||
import com.jetbrains.python.psi.PyUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -44,7 +49,7 @@ public class PyMoveModuleMembersDelegate extends MoveHandlerDelegate {
|
||||
@Override
|
||||
public boolean canMove(PsiElement[] elements, @Nullable PsiElement targetContainer) {
|
||||
for (PsiElement element : elements) {
|
||||
if (!PyMoveModuleMemberUtil.isMovableModuleMember(element)) {
|
||||
if (!PyMoveModuleMembersHelper.isMovableModuleMember(element)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -58,7 +63,7 @@ public class PyMoveModuleMembersDelegate extends MoveHandlerDelegate {
|
||||
@Nullable MoveCallback callback) {
|
||||
final List<PsiNamedElement> initialElements = Lists.newArrayList();
|
||||
for (PsiElement element : elements) {
|
||||
final PsiNamedElement e = getElementToMove(element);
|
||||
final PsiNamedElement e = PyMoveModuleMembersHelper.extractNamedElement(element);
|
||||
if (e == null) {
|
||||
return;
|
||||
}
|
||||
@@ -93,30 +98,53 @@ public class PyMoveModuleMembersDelegate extends MoveHandlerDelegate {
|
||||
@Nullable DataContext dataContext,
|
||||
@Nullable PsiReference reference,
|
||||
@Nullable Editor editor) {
|
||||
final PsiNamedElement e = getElementToMove(element);
|
||||
if (e != null && PyMoveModuleMemberUtil.isMovableElement(e)) {
|
||||
if (PyUtil.isTopLevel(e)) {
|
||||
PsiElement targetContainer = null;
|
||||
if (editor != null) {
|
||||
final Document document = editor.getDocument();
|
||||
targetContainer = PsiDocumentManager.getInstance(project).getPsiFile(document);
|
||||
PsiFile targetContainer = null;
|
||||
if (editor != null) {
|
||||
final Document document = editor.getDocument();
|
||||
targetContainer = PsiDocumentManager.getInstance(project).getPsiFile(document);
|
||||
if (targetContainer instanceof PyFile) {
|
||||
final List<PyElement> moduleMembers = collectAllMovableElementsInSelection(editor, (PyFile)targetContainer);
|
||||
if (moduleMembers.isEmpty()) {
|
||||
showBadSelectionErrorHint(project, editor);
|
||||
}
|
||||
doMove(project, new PsiElement[] {e}, targetContainer, null);
|
||||
else {
|
||||
doMove(project, ContainerUtil.findAllAsArray(moduleMembers, PsiNamedElement.class), targetContainer, null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to the old way to select single element to move
|
||||
final PsiNamedElement e = PyMoveModuleMembersHelper.extractNamedElement(element);
|
||||
if (e != null && PyMoveModuleMembersHelper.isMovableElement(e)) {
|
||||
if (PyUtil.isTopLevel(e)) {
|
||||
doMove(project, new PsiElement[]{e}, targetContainer, null);
|
||||
}
|
||||
else {
|
||||
CommonRefactoringUtil.showErrorHint(project, editor, PyBundle.message("refactoring.move.module.members.error.selection"),
|
||||
RefactoringBundle.message("error.title"), null);
|
||||
showBadSelectionErrorHint(project, editor);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiNamedElement getElementToMove(@NotNull PsiElement element) {
|
||||
if (element instanceof PsiNamedElement) {
|
||||
return (PsiNamedElement)element;
|
||||
}
|
||||
return null;
|
||||
private static void showBadSelectionErrorHint(@NotNull Project project, @Nullable Editor editor) {
|
||||
CommonRefactoringUtil.showErrorHint(project, editor,
|
||||
PyBundle.message("refactoring.move.module.members.error.selection"),
|
||||
RefactoringBundle.message("error.title"), null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<PyElement> collectAllMovableElementsInSelection(@NotNull Editor editor, @NotNull PyFile pyFile) {
|
||||
final SelectionModel selectionModel = editor.getSelectionModel();
|
||||
final TextRange selectionRange = new TextRange(selectionModel.getSelectionStart(), selectionModel.getSelectionEnd());
|
||||
final List<PyElement> members = PyMoveModuleMembersHelper.getTopLevelModuleMembers(pyFile);
|
||||
return ContainerUtil.filter(members, new Condition<PyElement>() {
|
||||
@Override
|
||||
public boolean value(PyElement member) {
|
||||
final PsiElement body = PyMoveModuleMembersHelper.expandNamedElementBody(((PsiNamedElement)member));
|
||||
return body != null && body.getTextRange().intersects(selectionRange);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ public class PyMoveModuleMembersDialog extends RefactoringDialog {
|
||||
final PyFile pyFile = (PyFile)firstElement.getContainingFile();
|
||||
myModuleMemberModel = new PyModuleMemberInfoModel(pyFile);
|
||||
|
||||
final List<PyModuleMemberInfo> symbolsInfos = myModuleMemberModel.collectTopLevelSymbolsInfo();
|
||||
final List<PyModuleMemberInfo> symbolsInfos = collectModuleMemberInfos(myModuleMemberModel.myPyFile);
|
||||
for (PyModuleMemberInfo info : symbolsInfos) {
|
||||
info.setChecked(elements.contains(info.getMember()));
|
||||
}
|
||||
@@ -221,6 +221,17 @@ public class PyMoveModuleMembersDialog extends RefactoringDialog {
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<PyModuleMemberInfo> collectModuleMemberInfos(@NotNull PyFile pyFile) {
|
||||
final List<PyElement> moduleMembers = PyMoveModuleMembersHelper.getTopLevelModuleMembers(pyFile);
|
||||
return ContainerUtil.mapNotNull(moduleMembers, new Function<PyElement, PyModuleMemberInfo>() {
|
||||
@Override
|
||||
public PyModuleMemberInfo fun(PyElement element) {
|
||||
return new PyModuleMemberInfo(element);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getContainingFileName(@NotNull PsiElement element) {
|
||||
final VirtualFile file = element.getContainingFile().getVirtualFile();
|
||||
|
||||
+18
-3
@@ -6,13 +6,16 @@ import com.jetbrains.python.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.jetbrains.python.psi.PyUtil.as;
|
||||
|
||||
/**
|
||||
* @author Mikhail Golubev
|
||||
*/
|
||||
public class PyMoveModuleMemberUtil {
|
||||
private PyMoveModuleMemberUtil() {
|
||||
public class PyMoveModuleMembersHelper {
|
||||
private PyMoveModuleMembersHelper() {
|
||||
// Utility class
|
||||
}
|
||||
|
||||
@@ -49,6 +52,18 @@ public class PyMoveModuleMemberUtil {
|
||||
return assignment != null && assignment.getTargets().length == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects all top-level variables, classes and functions (in this order) as returned by {@link PyFile#getTopLevelAttributes()},
|
||||
* {@link PyFile#getTopLevelClasses()} and {@link PyFile#getTopLevelFunctions()}.
|
||||
*/
|
||||
public static List<PyElement> getTopLevelModuleMembers(@NotNull PyFile pyFile) {
|
||||
final List<PyElement> result = new ArrayList<PyElement>();
|
||||
result.addAll(pyFile.getTopLevelAttributes());
|
||||
result.addAll(pyFile.getTopLevelClasses());
|
||||
result.addAll(pyFile.getTopLevelFunctions());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expands given named element to the closet parent suitable for "Move" refactoring. In particular for target expression
|
||||
* it returns parental assignment statement if any and element itself for functions and classes.
|
||||
@@ -74,7 +89,7 @@ public class PyMoveModuleMemberUtil {
|
||||
*/
|
||||
@Nullable
|
||||
public static PsiNamedElement extractNamedElement(@NotNull PsiElement element) {
|
||||
if (element instanceof PyClass || element instanceof PyFunction) {
|
||||
if (element instanceof PyClass || element instanceof PyFunction || element instanceof PyTargetExpression) {
|
||||
return (PsiNamedElement)element;
|
||||
}
|
||||
final PyAssignmentStatement assignment = as(element, PyAssignmentStatement.class);
|
||||
@@ -150,11 +150,11 @@ public class PyMoveModuleMembersProcessor extends BaseRefactoringProcessor {
|
||||
|
||||
private void moveElement(@NotNull PsiNamedElement element, @NotNull Collection<UsageInfo> usages, @NotNull PyFile destination) {
|
||||
final PsiFile file = element.getContainingFile();
|
||||
final PsiElement oldElementBody = PyMoveModuleMemberUtil.expandNamedElementBody(element);
|
||||
final PsiElement oldElementBody = PyMoveModuleMembersHelper.expandNamedElementBody(element);
|
||||
if (oldElementBody != null) {
|
||||
PyClassRefactoringUtil.rememberNamedReferences(oldElementBody);
|
||||
final PsiElement newElementBody = addToFile(oldElementBody, destination, usages);
|
||||
final PsiNamedElement newElement = PyMoveModuleMemberUtil.extractNamedElement(newElementBody);
|
||||
final PsiNamedElement newElement = PyMoveModuleMembersHelper.extractNamedElement(newElementBody);
|
||||
assert newElement != null;
|
||||
for (UsageInfo usage : usages) {
|
||||
final PsiElement usageElement = usage.getElement();
|
||||
|
||||
@@ -44,7 +44,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import static com.jetbrains.python.refactoring.move.PyMoveModuleMemberUtil.isMovableModuleMember;
|
||||
import static com.jetbrains.python.refactoring.move.PyMoveModuleMembersHelper.isMovableModuleMember;
|
||||
|
||||
/**
|
||||
* @author vlan
|
||||
|
||||
Reference in New Issue
Block a user