mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
Generated
+1
-1
@@ -1,7 +1,7 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Eclipse">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/ecj-4.5.2.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/ecj-4.6.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
|
||||
+1
-3
@@ -298,9 +298,7 @@ public class LambdaCanBeMethodReferenceInspection extends BaseJavaBatchLocalInsp
|
||||
return null;
|
||||
}
|
||||
PsiType type = typeElement.getType();
|
||||
if (type instanceof PsiPrimitiveType) return null;
|
||||
type = type.getDeepComponentType();
|
||||
if (type instanceof PsiClassType && (((PsiClassType)type).resolve() instanceof PsiTypeParameter)) return null;
|
||||
if (type instanceof PsiPrimitiveType || PsiUtil.resolveClassInType(type) instanceof PsiTypeParameter) return null;
|
||||
return expression;
|
||||
}
|
||||
}
|
||||
|
||||
+21
-5
@@ -31,8 +31,8 @@ import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.util.LambdaRefactoringUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.siyeh.ig.psiutils.ParenthesesUtils;
|
||||
import com.siyeh.ig.style.MethodRefCanBeReplacedWithLambdaInspection;
|
||||
import one.util.streamex.StreamEx;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -87,8 +87,7 @@ public class InlineStreamMapAction extends PsiElementBaseIntentionAction {
|
||||
return lambdaExpression.getParameterList().getParametersCount() == 1 &&
|
||||
(!requireExpressionLambda || LambdaUtil.extractSingleExpressionFromBody(lambdaExpression.getBody()) != null);
|
||||
} else if(expression instanceof PsiMethodReferenceExpression) {
|
||||
PsiMethodReferenceExpression methodReference = (PsiMethodReferenceExpression)expression;
|
||||
return !MethodRefCanBeReplacedWithLambdaInspection.isWithSideEffects(methodReference);
|
||||
return LambdaRefactoringUtil.canConvertToLambda((PsiMethodReferenceExpression)expression);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -161,12 +160,29 @@ public class InlineStreamMapAction extends PsiElementBaseIntentionAction {
|
||||
}
|
||||
}
|
||||
if(nextName.equals("flatMap") && prevClassName.equals(CommonClassNames.JAVA_UTIL_STREAM_STREAM)) {
|
||||
String mapMethod = translateMap(prevName);
|
||||
return "flatM"+mapMethod.substring(1);
|
||||
return mapToFlatMap(prevName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
@Nullable
|
||||
private static String mapToFlatMap(String mapMethod) {
|
||||
switch (mapMethod) {
|
||||
case "map":
|
||||
return "flatMap";
|
||||
case "mapToInt":
|
||||
return "flatMapToInt";
|
||||
case "mapToLong":
|
||||
return "flatMapToLong";
|
||||
case "mapToDouble":
|
||||
return "flatMapToDouble";
|
||||
}
|
||||
// Something unsupported passed: ignore
|
||||
return null;
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
@NotNull
|
||||
private static String translateMap(String nextMethod) {
|
||||
switch (nextMethod) {
|
||||
|
||||
@@ -77,7 +77,6 @@ public class LambdaRefactoringUtil {
|
||||
final PsiParameter[] psiParameters = resolve instanceof PsiMethod ? ((PsiMethod)resolve).getParameterList().getParameters() : null;
|
||||
|
||||
final StringBuilder buf = new StringBuilder("(");
|
||||
LOG.assertTrue(functionalInterfaceType != null);
|
||||
buf.append(GenericsUtil.getVariableTypeByExpressionType(functionalInterfaceType).getCanonicalText()).append(")(");
|
||||
final PsiParameterList parameterList = interfaceMethod.getParameterList();
|
||||
final PsiParameter[] parameters = parameterList.getParameters();
|
||||
@@ -103,6 +102,7 @@ public class LambdaRefactoringUtil {
|
||||
else {
|
||||
initialName = parameter.getName();
|
||||
}
|
||||
LOG.assertTrue(initialName != null);
|
||||
baseName = codeStyleManager.variableNameToPropertyName(initialName, VariableKind.PARAMETER);
|
||||
}
|
||||
|
||||
@@ -265,4 +265,16 @@ public class LambdaRefactoringUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether method reference can be converted to lambda without significant semantics change
|
||||
* (i.e. method reference qualifier has no side effects)
|
||||
*
|
||||
* @param methodReferenceExpression method reference to check
|
||||
* @return true if method reference can be converted to lambda
|
||||
*/
|
||||
public static boolean canConvertToLambda(PsiMethodReferenceExpression methodReferenceExpression) {
|
||||
final PsiExpression qualifierExpression = methodReferenceExpression.getQualifierExpression();
|
||||
return qualifierExpression != null && !SideEffectChecker.mayHaveSideEffects(qualifierExpression);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -100,7 +100,7 @@ public class OrderEntryTest extends DaemonAnalyzerTestCase {
|
||||
|
||||
private IntentionAction findActionAndCheck(final ActionHint actionHint, Collection<HighlightInfo> infosBefore) {
|
||||
List<IntentionAction> actions = LightQuickFixTestCase.getAvailableActions(getEditor(), getFile());
|
||||
return actionHint.findAndCheck(actions, () -> "Infos: " + infosBefore);
|
||||
return actionHint.findAndCheck(actions, "Infos: " + infosBefore);
|
||||
}
|
||||
|
||||
public void testAddDependency() throws Exception {
|
||||
|
||||
+1
-1
@@ -517,7 +517,7 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
|
||||
}
|
||||
|
||||
@Override
|
||||
Configuration[] getPredefinedTemplates() {
|
||||
public Configuration[] getPredefinedTemplates() {
|
||||
return JavaPredefinedConfigurations.createPredefinedTemplates();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -72,19 +71,19 @@ public class ActionHint {
|
||||
* if this ActionHint asserts that no action should be present.
|
||||
*
|
||||
* @param actions actions collection to search inside
|
||||
* @param infoSupplier a supplier which provides additional info which will be appended to exception message if check fails
|
||||
* @param errorMessage an additional error message which will be appended to exception message if check fails
|
||||
* @return the action or null
|
||||
* @throws AssertionError if no action is found, but it should present, or if action is found, but it should not present.
|
||||
*/
|
||||
@Nullable
|
||||
public IntentionAction findAndCheck(Collection<IntentionAction> actions, Supplier<String> infoSupplier) {
|
||||
public IntentionAction findAndCheck(@NotNull Collection<IntentionAction> actions, @NotNull String errorMessage) {
|
||||
IntentionAction result = actions.stream().filter(t -> t.getText().equals(myExpectedText)).findFirst().orElse(null);
|
||||
if(result == null && myShouldPresent) {
|
||||
fail("Action with text '" + myExpectedText + "' not found\nAvailable actions: " +
|
||||
actions.stream().map(IntentionAction::getText).collect(Collectors.joining(", ", "[", "]\n")) +
|
||||
infoSupplier.get());
|
||||
errorMessage);
|
||||
} else if(result != null && !myShouldPresent) {
|
||||
fail("Action with text '" + myExpectedText + "' is present, but should not\n" + infoSupplier.get());
|
||||
fail("Action with text '" + myExpectedText + "' is present, but should not\n" + errorMessage);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+2
-2
@@ -103,7 +103,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
String testName,
|
||||
QuickFixTestCase quickFix) throws Exception {
|
||||
IntentionAction action = actionHint.findAndCheck(quickFix.getAvailableActions(),
|
||||
() -> "Test: "+testFullPath+"\nInfos: "+quickFix.doHighlighting());
|
||||
"Test: "+testFullPath+"\nInfos: "+quickFix.doHighlighting());
|
||||
if (action != null) {
|
||||
String text = action.getText();
|
||||
quickFix.invoke(action);
|
||||
@@ -157,7 +157,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
}
|
||||
|
||||
protected IntentionAction findActionAndCheck(@NotNull ActionHint hint, String testFullPath) {
|
||||
return hint.findAndCheck(getAvailableActions(), () -> "Test: "+testFullPath);
|
||||
return hint.findAndCheck(getAvailableActions(), "Test: "+testFullPath);
|
||||
}
|
||||
|
||||
protected IntentionAction findActionWithText(@NotNull String text) {
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.jps.incremental.CompileContext;
|
||||
import org.jetbrains.jps.incremental.Utils;
|
||||
import org.jetbrains.jps.model.java.compiler.JavaCompilers;
|
||||
|
||||
import javax.tools.*;
|
||||
import javax.tools.JavaCompiler;
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.util.Collections;
|
||||
@@ -34,6 +34,9 @@ import java.util.List;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
/**
|
||||
* The latest version of ecj batch compiler can be found here:
|
||||
* http://download.eclipse.org/eclipse/downloads/
|
||||
*
|
||||
* @author nik
|
||||
*/
|
||||
public class EclipseCompilerTool extends JavaCompilingTool {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -13,7 +13,7 @@ httpcore-4.4.5.jar
|
||||
httpclient-4.5.2.jar
|
||||
fluent-hc-4.5.2.jar
|
||||
httpmime-4.5.2.jar
|
||||
ecj-4.5.2.jar
|
||||
ecj-4.6.1.jar
|
||||
groovy-all-2.4.6.jar
|
||||
gson-2.5.jar
|
||||
guava-19.0.jar
|
||||
|
||||
+17
-2
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.dupLocator;
|
||||
|
||||
import com.intellij.dupLocator.util.NodeFilter;
|
||||
@@ -85,11 +100,11 @@ public abstract class AbstractMatchingVisitor {
|
||||
);
|
||||
}
|
||||
|
||||
protected boolean isLeftLooseMatching() {
|
||||
public boolean isLeftLooseMatching() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean isRightLooseMatching() {
|
||||
public boolean isRightLooseMatching() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -532,11 +532,19 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
public void setSelected(AnActionEvent event, boolean flag) {
|
||||
final AbstractProjectViewPane viewPane = getCurrentProjectViewPane();
|
||||
final SelectionInfo selectionInfo = SelectionInfo.create(viewPane);
|
||||
|
||||
if (isGlobalOptions()) {
|
||||
setFlattenPackages(flag, viewPane.getId());
|
||||
}
|
||||
super.setSelected(event, flag);
|
||||
|
||||
selectionInfo.apply(viewPane);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelected(AnActionEvent event) {
|
||||
if (isGlobalOptions()) return getGlobalOptions().getFlattenPackages();
|
||||
return super.isSelected(event);
|
||||
}
|
||||
}).setAsSecondary(true);
|
||||
}
|
||||
|
||||
@@ -549,6 +557,14 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
super(optionsMap, text, description, icon, optionDefaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent event, boolean flag) {
|
||||
if (isGlobalOptions()) {
|
||||
getGlobalOptions().setFlattenPackages(flag);
|
||||
}
|
||||
super.setSelected(event, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
super.update(e);
|
||||
@@ -1376,8 +1392,12 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
public void setFlattenPackages(boolean flattenPackages, String paneId) {
|
||||
if (isGlobalOptions()) {
|
||||
getGlobalOptions().setFlattenPackages(flattenPackages);
|
||||
for (String pane : myFlattenPackages.keySet()) {
|
||||
setPaneOption(myFlattenPackages, flattenPackages, pane, true);
|
||||
}
|
||||
} else {
|
||||
setPaneOption(myFlattenPackages, flattenPackages, paneId, true);
|
||||
}
|
||||
setPaneOption(myFlattenPackages, flattenPackages, paneId, true);
|
||||
}
|
||||
|
||||
public boolean isFoldersAlwaysOnTop() {
|
||||
@@ -1477,8 +1497,12 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
public void setHideEmptyPackages(boolean hideEmptyPackages, @NotNull String paneId) {
|
||||
if (isGlobalOptions()) {
|
||||
getGlobalOptions().setHideEmptyPackages(hideEmptyPackages);
|
||||
for (String pane : myHideEmptyPackages.keySet()) {
|
||||
setPaneOption(myHideEmptyPackages, hideEmptyPackages, pane, true);
|
||||
}
|
||||
} else {
|
||||
setPaneOption(myHideEmptyPackages, hideEmptyPackages, paneId, true);
|
||||
}
|
||||
setPaneOption(myHideEmptyPackages, hideEmptyPackages, paneId, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1516,16 +1540,25 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
final AbstractProjectViewPane viewPane = getCurrentProjectViewPane();
|
||||
final SelectionInfo selectionInfo = SelectionInfo.create(viewPane);
|
||||
|
||||
if (isGlobalOptions()) {
|
||||
getGlobalOptions().setHideEmptyPackages(flag);
|
||||
}
|
||||
super.setSelected(event, flag);
|
||||
|
||||
selectionInfo.apply(viewPane);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelected(AnActionEvent event) {
|
||||
if (isGlobalOptions()) return getGlobalOptions().getHideEmptyPackages();
|
||||
return super.isSelected(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
super.update(e);
|
||||
final Presentation presentation = e.getPresentation();
|
||||
if (isFlattenPackages(myCurrentViewId)) {
|
||||
if (isHideEmptyMiddlePackages(myCurrentViewId)) {
|
||||
presentation.setText(IdeBundle.message("action.hide.empty.middle.packages"));
|
||||
presentation.setDescription(IdeBundle.message("action.show.hide.empty.middle.packages"));
|
||||
}
|
||||
|
||||
+1
-6
@@ -180,12 +180,7 @@ public class GeneralCommandLine implements UserDataHolder {
|
||||
return myParentEnvironmentType != ParentEnvironmentType.NONE;
|
||||
}
|
||||
|
||||
/** @deprecated use {@link #withParentEnvironmentType(ParentEnvironmentType)} (to be removed in IDEA 2017.*) */
|
||||
public GeneralCommandLine withPassParentEnvironment(boolean passParentEnvironment) {
|
||||
return withParentEnvironmentType(passParentEnvironment ? ParentEnvironmentType.CONSOLE : ParentEnvironmentType.NONE);
|
||||
}
|
||||
|
||||
/** @deprecated use {@link #withParentEnvironmentType(ParentEnvironmentType)} (to be removed in IDEA 2017.*) */
|
||||
/** @deprecated use {@link #withParentEnvironmentType(ParentEnvironmentType)} (to be removed in IDEA 2018.*) */
|
||||
public void setPassParentEnvironment(boolean passParentEnvironment) {
|
||||
withParentEnvironmentType(passParentEnvironment ? ParentEnvironmentType.CONSOLE : ParentEnvironmentType.NONE);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.ui.tabs.UiDecorator;
|
||||
import com.intellij.ui.tabs.impl.table.TableLayout;
|
||||
import com.intellij.util.PairConsumer;
|
||||
import com.intellij.util.ui.Centerizer;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.accessibility.ScreenReader;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -204,9 +205,9 @@ public class TabLabel extends JPanel implements Accessible {
|
||||
};
|
||||
label.setOpaque(false);
|
||||
label.setBorder(null);
|
||||
label.setIconTextGap(tabs.isEditorTabs() ? (!UISettings.getInstance().HIDE_TABS_IF_NEED ? 4 : 2) : new JLabel().getIconTextGap());
|
||||
label.setIconTextGap(tabs.isEditorTabs() ? (!UISettings.getShadowInstance().HIDE_TABS_IF_NEED ? 4 : 2) : new JLabel().getIconTextGap());
|
||||
label.setIconOpaque(false);
|
||||
label.setIpad(new Insets(0, 0, 0, 0));
|
||||
label.setIpad(JBUI.emptyInsets());
|
||||
|
||||
return label;
|
||||
}
|
||||
@@ -214,7 +215,7 @@ public class TabLabel extends JPanel implements Accessible {
|
||||
@Override
|
||||
public Insets getInsets() {
|
||||
Insets insets = super.getInsets();
|
||||
if (myTabs.isEditorTabs() && UISettings.getInstance().SHOW_CLOSE_BUTTON) {
|
||||
if (myTabs.isEditorTabs() && UISettings.getShadowInstance().SHOW_CLOSE_BUTTON) {
|
||||
insets.right = 3;
|
||||
}
|
||||
return insets;
|
||||
@@ -462,6 +463,10 @@ public class TabLabel extends JPanel implements Accessible {
|
||||
}
|
||||
|
||||
public void apply(UiDecorator.UiDecoration decoration) {
|
||||
if (decoration == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (decoration.getLabelFont() != null) {
|
||||
setFont(decoration.getLabelFont());
|
||||
getLabelComponent().setFont(decoration.getLabelFont());
|
||||
@@ -671,23 +676,19 @@ public class TabLabel extends JPanel implements Accessible {
|
||||
@Override
|
||||
public String getAccessibleName() {
|
||||
String name = super.getAccessibleName();
|
||||
if (name == null) {
|
||||
if (myLabel instanceof Accessible){
|
||||
if (name == null && myLabel != null) {
|
||||
name = myLabel.getAccessibleContext().getAccessibleName();
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAccessibleDescription() {
|
||||
String name = super.getAccessibleDescription();
|
||||
if (name == null) {
|
||||
if (myLabel instanceof Accessible){
|
||||
name = myLabel.getAccessibleContext().getAccessibleDescription();
|
||||
}
|
||||
String description = super.getAccessibleDescription();
|
||||
if (description == null && myLabel != null) {
|
||||
description = myLabel.getAccessibleContext().getAccessibleDescription();
|
||||
}
|
||||
return name;
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -222,7 +222,7 @@ public abstract class StructuralSearchProfile {
|
||||
return fileType;
|
||||
}
|
||||
|
||||
Configuration[] getPredefinedTemplates() {
|
||||
public Configuration[] getPredefinedTemplates() {
|
||||
return Configuration.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
|
||||
+16
-1
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.structuralsearch;
|
||||
|
||||
import com.intellij.codeInsight.template.TemplateContextType;
|
||||
@@ -197,7 +212,7 @@ public class XmlStructuralSearchProfile extends StructuralSearchProfile {
|
||||
}
|
||||
|
||||
@Override
|
||||
Configuration[] getPredefinedTemplates() {
|
||||
public Configuration[] getPredefinedTemplates() {
|
||||
return XmlPredefinedConfigurations.createPredefinedTemplates();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -312,12 +312,12 @@ public class GlobalMatchingVisitor extends AbstractMatchingVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isLeftLooseMatching() {
|
||||
public boolean isLeftLooseMatching() {
|
||||
return matchContext.getOptions().isLooseMatching();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isRightLooseMatching() {
|
||||
public boolean isRightLooseMatching() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+18
-5
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.structuralsearch.impl.matcher.compiler;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -6,11 +21,9 @@ import com.intellij.structuralsearch.MatchOptions;
|
||||
import com.intellij.structuralsearch.impl.matcher.CompiledPattern;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: maxim
|
||||
* @author maxim
|
||||
* Date: 17.11.2004
|
||||
* Time: 19:26:37
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class CompileContext {
|
||||
private OptimizingSearchHelper searchHelper;
|
||||
@@ -49,7 +62,7 @@ public class CompileContext {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
MatchOptions getOptions() {
|
||||
public MatchOptions getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
@@ -57,7 +70,7 @@ public class CompileContext {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
Project getProject() {
|
||||
public Project getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
|
||||
+4
-17
@@ -34,14 +34,10 @@ import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.psiutils.SideEffectChecker;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MethodRefCanBeReplacedWithLambdaInspection extends BaseInspection {
|
||||
|
||||
@Nls
|
||||
@@ -74,16 +70,6 @@ public class MethodRefCanBeReplacedWithLambdaInspection extends BaseInspection {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isWithSideEffects(PsiMethodReferenceExpression methodReferenceExpression) {
|
||||
final PsiExpression qualifierExpression = methodReferenceExpression.getQualifierExpression();
|
||||
if (qualifierExpression != null) {
|
||||
final List<PsiElement> sideEffects = new ArrayList<>();
|
||||
SideEffectChecker.checkSideEffects(qualifierExpression, sideEffects);
|
||||
return !sideEffects.isEmpty();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class MethodRefToLambdaVisitor extends BaseInspectionVisitor {
|
||||
@Override
|
||||
public void visitMethodReferenceExpression(PsiMethodReferenceExpression methodReferenceExpression) {
|
||||
@@ -92,12 +78,13 @@ public class MethodRefCanBeReplacedWithLambdaInspection extends BaseInspection {
|
||||
if (interfaceType != null &&
|
||||
LambdaUtil.getFunctionalInterfaceMethod(interfaceType) != null &&
|
||||
methodReferenceExpression.resolve() != null) {
|
||||
registerError(methodReferenceExpression, getFixFactory(isWithSideEffects(methodReferenceExpression), isOnTheFly()));
|
||||
registerError(methodReferenceExpression,
|
||||
getFixFactory(LambdaRefactoringUtil.canConvertToLambda(methodReferenceExpression), isOnTheFly()));
|
||||
}
|
||||
}
|
||||
|
||||
private static FixFactory getFixFactory(boolean withSideEffects, boolean onTheFly) {
|
||||
if (!withSideEffects) return MethodRefToLambdaFix::new;
|
||||
private static FixFactory getFixFactory(boolean canConvert, boolean onTheFly) {
|
||||
if (canConvert) return MethodRefToLambdaFix::new;
|
||||
if (onTheFly || ApplicationManager.getApplication().isUnitTestMode()) return SideEffectsMethodRefToLambdaFix::new;
|
||||
return null;
|
||||
}
|
||||
|
||||
+48
-15
@@ -25,6 +25,7 @@ import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.rmi.RemoteProcessSupport;
|
||||
import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationListener;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
@@ -33,7 +34,9 @@ import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.components.Storage;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.projectRoots.*;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
@@ -51,6 +54,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.idea.maven.execution.MavenExecutionOptions;
|
||||
import org.jetbrains.idea.maven.execution.MavenRunnerSettings;
|
||||
import org.jetbrains.idea.maven.execution.RunnerBundle;
|
||||
import org.jetbrains.idea.maven.model.MavenExplicitProfiles;
|
||||
import org.jetbrains.idea.maven.model.MavenId;
|
||||
import org.jetbrains.idea.maven.model.MavenModel;
|
||||
@@ -59,10 +63,12 @@ import org.jetbrains.idea.maven.project.MavenGeneralSettings;
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsManager;
|
||||
import org.jetbrains.idea.maven.utils.MavenLog;
|
||||
import org.jetbrains.idea.maven.utils.MavenProgressIndicator;
|
||||
import org.jetbrains.idea.maven.utils.MavenSettings;
|
||||
import org.jetbrains.idea.maven.utils.MavenUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.impl.Log4jLoggerFactory;
|
||||
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import java.io.File;
|
||||
import java.rmi.RemoteException;
|
||||
import java.rmi.server.UnicastRemoteObject;
|
||||
@@ -283,14 +289,43 @@ public class MavenServerManager extends RemoteObjectWrapper<MavenServer> impleme
|
||||
}
|
||||
}
|
||||
|
||||
final String currentMavenVersion = forceMaven2 ? "2.2.1" : getCurrentMavenVersion();
|
||||
params.getVMParametersList().addProperty(MavenServerEmbedder.MAVEN_EMBEDDER_VERSION, currentMavenVersion);
|
||||
final File mavenHome;
|
||||
final String mavenVersion;
|
||||
final File currentMavenHomeFile = forceMaven2 ? BundledMavenPathHolder.myBundledMaven2Home : getCurrentMavenHomeFile();
|
||||
if (currentMavenHomeFile == null) {
|
||||
mavenHome = BundledMavenPathHolder.myBundledMaven3Home;
|
||||
mavenVersion = getMavenVersion(mavenHome);
|
||||
|
||||
Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
|
||||
final Project project = openProjects.length == 1 ? openProjects[0] : null;
|
||||
if (project != null) {
|
||||
new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP, "", RunnerBundle.message(
|
||||
"external.maven.home.invalid.substitution.warning.with.fix", myState.mavenHome, mavenVersion), NotificationType.WARNING,
|
||||
new NotificationListener() {
|
||||
@Override
|
||||
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
|
||||
ShowSettingsUtil.getInstance().showSettingsDialog(project, MavenSettings.DISPLAY_NAME);
|
||||
}
|
||||
}).notify(null);
|
||||
}
|
||||
else {
|
||||
new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP, "", RunnerBundle.message(
|
||||
"external.maven.home.invalid.substitution.warning", myState.mavenHome, mavenVersion), NotificationType.WARNING).notify(null);
|
||||
}
|
||||
}
|
||||
else {
|
||||
mavenHome = currentMavenHomeFile;
|
||||
mavenVersion = getMavenVersion(mavenHome);
|
||||
}
|
||||
assert mavenVersion != null;
|
||||
|
||||
params.getVMParametersList().addProperty(MavenServerEmbedder.MAVEN_EMBEDDER_VERSION, mavenVersion);
|
||||
String sdkConfigLocation = "Settings | Build, Execution, Deployment | Build Tools | Maven | Importing | JDK for Importer";
|
||||
verifyMavenSdkRequirements(jdk, currentMavenVersion, sdkConfigLocation);
|
||||
verifyMavenSdkRequirements(jdk, mavenVersion, sdkConfigLocation);
|
||||
|
||||
final List<String> classPath = new ArrayList<>();
|
||||
classPath.add(PathUtil.getJarPathForClass(org.apache.log4j.Logger.class));
|
||||
if (currentMavenVersion == null || StringUtil.compareVersionNumbers(currentMavenVersion, "3.1") < 0) {
|
||||
if (StringUtil.compareVersionNumbers(mavenVersion, "3.1") < 0) {
|
||||
classPath.add(PathUtil.getJarPathForClass(Logger.class));
|
||||
classPath.add(PathUtil.getJarPathForClass(Log4jLoggerFactory.class));
|
||||
}
|
||||
@@ -299,7 +334,7 @@ public class MavenServerManager extends RemoteObjectWrapper<MavenServer> impleme
|
||||
ContainerUtil.addIfNotNull(classPath, PathUtil.getJarPathForClass(Query.class));
|
||||
params.getClassPath().add(PathManager.getResourceRoot(getClass(), "/messages/CommonBundle.properties"));
|
||||
params.getClassPath().addAll(classPath);
|
||||
params.getClassPath().addAllFiles(collectClassPathAndLibsFolder(forceMaven2));
|
||||
params.getClassPath().addAllFiles(collectClassPathAndLibsFolder(mavenVersion, mavenHome));
|
||||
|
||||
String embedderXmx = System.getProperty("idea.maven.embedder.xmx");
|
||||
if (embedderXmx != null) {
|
||||
@@ -381,14 +416,12 @@ public class MavenServerManager extends RemoteObjectWrapper<MavenServer> impleme
|
||||
return MavenUtil.getMavenVersion(mavenHome);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getCurrentMavenVersion() {
|
||||
return getMavenVersion(myState.mavenHome);
|
||||
}
|
||||
|
||||
public List<File> collectClassPathAndLibsFolder(boolean forceMaven2) {
|
||||
final String currentMavenVersion = forceMaven2 ? "2.2.1" : getCurrentMavenVersion();
|
||||
File mavenHome = forceMaven2 ? BundledMavenPathHolder.myBundledMaven2Home : currentMavenVersion == null ? BundledMavenPathHolder.myBundledMaven3Home : getCurrentMavenHomeFile();
|
||||
|
||||
private static List<File> collectClassPathAndLibsFolder(@NotNull String mavenVersion, @NotNull File mavenHome) {
|
||||
final File pluginFileOrDir = new File(PathUtil.getJarPathForClass(MavenServerManager.class));
|
||||
final List<File> classpath = new ArrayList<>();
|
||||
final String root = pluginFileOrDir.getParent();
|
||||
@@ -396,11 +429,11 @@ public class MavenServerManager extends RemoteObjectWrapper<MavenServer> impleme
|
||||
if (pluginFileOrDir.isDirectory()) {
|
||||
classpath.add(new File(root, "maven-server-api"));
|
||||
File parentFile = getMavenPluginParentFile();
|
||||
if (forceMaven2 || (currentMavenVersion != null && StringUtil.compareVersionNumbers(currentMavenVersion, "3") < 0)) {
|
||||
if (StringUtil.compareVersionNumbers(mavenVersion, "3") < 0) {
|
||||
classpath.add(new File(root, "maven2-server-impl"));
|
||||
addDir(classpath, new File(parentFile, "maven2-server-impl/lib"));
|
||||
// use bundled maven 2.2.1 for all 2.0.x version (since we use org.apache.maven.project.interpolation.StringSearchModelInterpolator introduced in 2.1.0)
|
||||
if (StringUtil.compareVersionNumbers(currentMavenVersion, "2.1.0") < 0) {
|
||||
if (StringUtil.compareVersionNumbers(mavenVersion, "2.1.0") < 0) {
|
||||
mavenHome = BundledMavenPathHolder.myBundledMaven2Home;
|
||||
}
|
||||
}
|
||||
@@ -408,7 +441,7 @@ public class MavenServerManager extends RemoteObjectWrapper<MavenServer> impleme
|
||||
classpath.add(new File(root, "maven3-server-common"));
|
||||
addDir(classpath, new File(parentFile, "maven3-server-common/lib"));
|
||||
|
||||
if (currentMavenVersion == null || StringUtil.compareVersionNumbers(currentMavenVersion, "3.1") < 0) {
|
||||
if (StringUtil.compareVersionNumbers(mavenVersion, "3.1") < 0) {
|
||||
classpath.add(new File(root, "maven30-server-impl"));
|
||||
}
|
||||
else {
|
||||
@@ -419,7 +452,7 @@ public class MavenServerManager extends RemoteObjectWrapper<MavenServer> impleme
|
||||
else {
|
||||
classpath.add(new File(root, "maven-server-api.jar"));
|
||||
|
||||
if (forceMaven2 || (currentMavenVersion != null && StringUtil.compareVersionNumbers(currentMavenVersion, "3") < 0)) {
|
||||
if (StringUtil.compareVersionNumbers(mavenVersion, "3") < 0) {
|
||||
classpath.add(new File(root, "maven2-server-impl.jar"));
|
||||
addDir(classpath, new File(root, "maven2-server-lib"));
|
||||
}
|
||||
@@ -427,7 +460,7 @@ public class MavenServerManager extends RemoteObjectWrapper<MavenServer> impleme
|
||||
classpath.add(new File(root, "maven3-server-common.jar"));
|
||||
addDir(classpath, new File(root, "maven3-server-lib"));
|
||||
|
||||
if (currentMavenVersion == null || StringUtil.compareVersionNumbers(currentMavenVersion, "3.1") < 0) {
|
||||
if (StringUtil.compareVersionNumbers(mavenVersion, "3.1") < 0) {
|
||||
classpath.add(new File(root, "maven30-server-impl.jar"));
|
||||
}
|
||||
else {
|
||||
@@ -602,7 +635,7 @@ public class MavenServerManager extends RemoteObjectWrapper<MavenServer> impleme
|
||||
|
||||
public boolean isUseMaven2() {
|
||||
final String version = getCurrentMavenVersion();
|
||||
return StringUtil.compareVersionNumbers(version, "3") < 0 && StringUtil.compareVersionNumbers(version, "2") >= 0;
|
||||
return version != null && StringUtil.compareVersionNumbers(version, "3") < 0 && StringUtil.compareVersionNumbers(version, "2") >= 0;
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
|
||||
@@ -16,6 +16,9 @@ external.maven.home.does.not.exist.with.fix=Specified Maven home directory ({0})
|
||||
external.maven.home.invalid={0} is not a valid Maven home directory
|
||||
external.maven.home.invalid.with.fix={0} is not a valid Maven home directory. <a href="#">Configure Maven home</a>
|
||||
|
||||
external.maven.home.invalid.substitution.warning=Invalid Maven home directory configured <br>{0} <br>Bundled maven {1} will be used
|
||||
external.maven.home.invalid.substitution.warning.with.fix=Invalid Maven home directory configured <br>{0} <br>Bundled maven {1} will be used. <a href="#">Configure Maven home</a>.
|
||||
|
||||
embedded.executor.caption=Executing Maven - using embedded Maven
|
||||
embedded.cannot.create=Cannot create Maven Embedder
|
||||
embedded.build.failed=BUILD FAILED
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<body>
|
||||
Reports conditions like <code>if(Optional.isPresent())</code> which could be rewritten in functional style.
|
||||
<!-- tooltip end -->
|
||||
<p>
|
||||
<small>New in 2016.3</small>
|
||||
</body>
|
||||
</html>
|
||||
@@ -73,32 +73,28 @@ public class CreateAction extends PatchAction {
|
||||
|
||||
@Override
|
||||
protected void doApply(ZipFile patchFile, File backupDir, File toFile) throws IOException {
|
||||
if (toFile.getParentFile().exists()) {
|
||||
prepareToWriteFile(toFile);
|
||||
prepareToWriteFile(toFile);
|
||||
|
||||
ZipEntry entry = Utils.getZipEntry(patchFile, myPath);
|
||||
if (entry.isDirectory()) {
|
||||
if (!toFile.mkdir()) {
|
||||
throw new IOException("Unable to create directory " + myPath);
|
||||
}
|
||||
} else {
|
||||
InputStream in = Utils.findEntryInputStreamForEntry(patchFile, entry);
|
||||
try {
|
||||
int filePermissions = in.read();
|
||||
if (filePermissions > 1) {
|
||||
Utils.createLink(readLinkInfo(in, filePermissions), toFile);
|
||||
}
|
||||
else {
|
||||
Utils.copyStreamToFile(in, toFile);
|
||||
Utils.setExecutable(toFile, filePermissions == 1);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
in.close();
|
||||
}
|
||||
ZipEntry entry = Utils.getZipEntry(patchFile, myPath);
|
||||
if (entry.isDirectory()) {
|
||||
if (!toFile.mkdir()) {
|
||||
throw new IOException("Unable to create directory " + myPath);
|
||||
}
|
||||
} else {
|
||||
Runner.logger().info("Create action skipped. The parent is absent: " + toFile.getParentFile());
|
||||
InputStream in = Utils.findEntryInputStreamForEntry(patchFile, entry);
|
||||
try {
|
||||
int filePermissions = in.read();
|
||||
if (filePermissions > 1 ) {
|
||||
Utils.createLink(readLinkInfo(in, filePermissions), toFile);
|
||||
}
|
||||
else {
|
||||
Utils.copyStreamToFile(in, toFile);
|
||||
Utils.setExecutable(toFile, filePermissions == 1 );
|
||||
}
|
||||
}
|
||||
finally {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -319,8 +319,13 @@ public class Patch {
|
||||
boolean cancelled = false;
|
||||
try {
|
||||
forEach(actionsToProcess, "Applying patch...", ui, true, action -> {
|
||||
appliedActions.add(action);
|
||||
action.apply(patchFile, backupDir, toDir);
|
||||
if ((action instanceof CreateAction) &&
|
||||
!new File(toDir, action.getPath()).getParentFile().exists()) {
|
||||
Runner.logger().info("Create action: " + action.getPath() + " skipped. The parent folder is absent.");
|
||||
} else {
|
||||
appliedActions.add(action);
|
||||
action.apply(patchFile, backupDir, toDir);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (OperationCancelledException e) {
|
||||
|
||||
Reference in New Issue
Block a user