Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dmitry Batkovich
2015-10-16 17:05:18 +03:00
7 changed files with 77 additions and 11 deletions
+1
View File
@@ -84,6 +84,7 @@
<orderEntry type="module" module-name="github" />
<orderEntry type="module" module-name="hg4idea" />
<orderEntry type="module" module-name="relaxng" />
<orderEntry type="module" module-name="gradle" />
<orderEntry type="module" module-name="remote-servers-impl" />
<orderEntry type="module" module-name="dom-tests" />
<orderEntry type="module" module-name="colorSchemes" />
@@ -167,7 +167,10 @@ public class SwitchBootJdkAction extends AnAction implements DumbAware {
final ArrayList<JdkBundleDescriptor> pathsList = JdkUtil.findJdkPaths();
if (!jdkBundlesList.isEmpty()) {
pathsList.add(0, jdkBundlesList.get(0));
JdkBundleDescriptor jdkBundleDescription = jdkBundlesList.get(0);
if (jdkBundleDescription != null) {
pathsList.add(0, jdkBundleDescription);
}
}
myComboBox = new ComboBox();
@@ -191,7 +194,7 @@ public class SwitchBootJdkAction extends AnAction implements DumbAware {
JdkBundleDescriptor jdkBundleDescriptor = ((JdkBundleDescriptor)value);
setText(jdkBundleDescriptor.getVisualRepresentation());
} else {
LOG.error("Null value has been passed to a cell renderer. Available JDKs count: " + pathsList.size());
LOG.debug("Null value has been passed to a cell renderer. Available JDKs count: " + pathsList.size());
StringBuilder jdkNames = new StringBuilder();
for (JdkBundleDescriptor jdkBundlePath : pathsList) {
if (!jdkBundlesList.isEmpty()) {
@@ -199,7 +202,7 @@ public class SwitchBootJdkAction extends AnAction implements DumbAware {
}
jdkNames.append(jdkBundlePath.getVisualRepresentation()).append("; ");
}
LOG.error("Available JDKs names: " + jdkNames.toString());
LOG.debug("Available JDKs names: " + jdkNames.toString());
}
}
});
@@ -428,7 +428,7 @@ ide.mac.message.sheets.java.emulation.dialogs=true
ide.mac.message.sheets.java.emulation.dialogs.description=Use Java message sheets based on awt dialogs instead of native sheets
linux.native.menu=false
linux.native.menu.description=Enables native menu on Ubuntu
windows.jumplist=true
windows.jumplist=false
windows.jumplist.description=Enables JumpLists on Windows
GRADLE.system.in.process=true
@@ -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.
@@ -18,6 +18,7 @@ package com.siyeh.ig.resources;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.*;
import com.intellij.psi.util.InheritanceUtil;
import com.intellij.psi.util.PsiUtil;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
@@ -59,9 +60,7 @@ public class AutoCloseableResourceInspectionBase extends BaseInspection {
@NotNull
@Override
protected String buildErrorString(Object... infos) {
final PsiExpression expression = (PsiExpression)infos[0];
final PsiType type = expression.getType();
assert type != null;
final PsiType type = (PsiType)infos[0];
final String text = type.getPresentableText();
return InspectionGadgetsBundle.message("auto.closeable.resource.problem.descriptor", text);
}
@@ -108,7 +107,7 @@ public class AutoCloseableResourceInspectionBase extends BaseInspection {
if (!isNotSafelyClosedResource(expression)) {
return;
}
registerNewExpressionError(expression, expression);
registerNewExpressionError(expression, expression.getType());
}
@Override
@@ -120,11 +119,29 @@ public class AutoCloseableResourceInspectionBase extends BaseInspection {
if (!isNotSafelyClosedResource(expression)) {
return;
}
registerMethodCallError(expression, expression);
registerMethodCallError(expression, expression.getType());
}
@Override
public void visitMethodReferenceExpression(PsiMethodReferenceExpression expression) {
super.visitMethodReferenceExpression(expression);
if (!expression.isConstructor()) {
return;
}
final PsiType type = PsiMethodReferenceUtil.getQualifierType(expression);
if (!InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_LANG_AUTO_CLOSEABLE)) {
return;
}
for (String ignoredType : ignoredTypes) {
if (InheritanceUtil.isInheritor(type, ignoredType)) {
return;
}
}
registerError(expression, type);
}
private boolean isNotSafelyClosedResource(PsiExpression expression) {
if (!TypeUtils.expressionHasTypeOrSubtype(expression, "java.lang.AutoCloseable")) {
if (!TypeUtils.expressionHasTypeOrSubtype(expression, CommonClassNames.JAVA_LANG_AUTO_CLOSEABLE)) {
return false;
}
if (TypeUtils.expressionHasTypeOrSubtype(expression, ignoredTypes)) {
@@ -16,7 +16,9 @@
package com.siyeh.ig.resources;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.testFramework.LightProjectDescriptor;
import com.siyeh.ig.LightInspectionTestCase;
import org.jetbrains.annotations.NotNull;
/**
* @author Bas Leijdekkers
@@ -68,6 +70,22 @@ public class AutoCloseableResourceInspectionTest extends LightInspectionTestCase
"}");
}
public void testMethodReference() {
doTest("import java.util.*;" +
"class X {" +
" void m(List<String> list) {" +
" final Z<String, Y> f = /*'X.Y' used without 'try'-with-resources statement*/Y::new/**/;" +
" }" +
" class Y implements java.io.Closeable {" +
" Y(String s) {}" +
" public void close() throws java.io.IOException {}" +
" }" +
" interface Z<T, R> {\n" +
" R apply(T t);" +
" }" +
"}");
}
@Override
protected LocalInspectionTool getInspection() {
return new AutoCloseableResourceInspection();
@@ -452,4 +452,8 @@ public class IpnbFileEditor extends UserDataHolderBase implements FileEditor {
public VirtualFile getVirtualFile() {
return myFile;
}
public JScrollPane getScrollPane() {
return myScrollPane;
}
}
@@ -26,6 +26,7 @@ import com.intellij.ui.components.panels.HorizontalLayout;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.ipnb.editor.IpnbEditorUtil;
import org.jetbrains.plugins.ipnb.editor.IpnbFileEditor;
import org.jetbrains.plugins.ipnb.editor.actions.IpnbRunCellAction;
import org.jetbrains.plugins.ipnb.editor.actions.IpnbRunCellBaseAction;
import org.jetbrains.plugins.ipnb.editor.actions.IpnbRunCellInplaceAction;
@@ -97,6 +98,24 @@ public class IpnbCodeSourcePanel extends IpnbPanel<JComponent, IpnbCodeCell> imp
}
}
private void updateVisibleArea(boolean up) {
final IpnbFileEditor fileEditor = myParent.getFileEditor();
final IpnbFilePanel ipnbPanel = fileEditor.getIpnbFilePanel();
final Rectangle rect = ipnbPanel.getVisibleRect();
final Rectangle cellBounds = IpnbCodeSourcePanel.this.getIpnbCodePanel().getBounds();
final JScrollPane scrollPane = fileEditor.getScrollPane();
final int y = cellBounds.y + myEditor.visualPositionToXY(myEditor.getCaretModel().getVisualPosition()).y;
int delta = myEditor.getLineHeight() * 2;
if (y <= rect.getY() && up) {
scrollPane.getVerticalScrollBar().setValue(y);
}
if (y + delta > rect.getY() + rect.getHeight() && !up) {
scrollPane.getVerticalScrollBar().setValue(y - rect.height + delta);
}
}
@Override
public void keyReleased(KeyEvent e) {
final int keyCode = e.getKeyCode();
@@ -120,6 +139,10 @@ public class IpnbCodeSourcePanel extends IpnbPanel<JComponent, IpnbCodeCell> imp
else if (keyCode == KeyEvent.VK_ENTER && InputEvent.SHIFT_DOWN_MASK == e.getModifiersEx()) {
IpnbRunCellBaseAction.runCell(ipnbFilePanel, true);
}
else if (keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_DOWN || keyCode == KeyEvent.VK_PAGE_DOWN ||
keyCode == KeyEvent.VK_PAGE_UP) {
updateVisibleArea(keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_PAGE_UP);
}
}
}