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:
+10
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -68,7 +68,15 @@ public class StackFrameDescriptorImpl extends NodeDescriptorImpl implements Stac
|
||||
try {
|
||||
myUiIndex = frame.getFrameIndex();
|
||||
myLocation = frame.location();
|
||||
myThisObject = frame.thisObject();
|
||||
try {
|
||||
myThisObject = frame.thisObject();
|
||||
} catch (EvaluateException e) {
|
||||
// catch internal exceptions here
|
||||
if (!(e.getCause() instanceof InternalException)) {
|
||||
throw e;
|
||||
}
|
||||
LOG.info(e);
|
||||
}
|
||||
myMethodOccurrence = tracker.getMethodOccurrence(myUiIndex, myLocation.method());
|
||||
myIsSynthetic = DebuggerUtils.isSynthetic(myMethodOccurrence.getMethod());
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
|
||||
+7
-2
@@ -347,8 +347,13 @@ public class HighlightMethodUtil {
|
||||
TextRange fixRange = getFixRange(methodCall);
|
||||
highlightInfo = HighlightUtil.checkUnhandledExceptions(methodCall, fixRange);
|
||||
if (highlightInfo == null) {
|
||||
if (!LambdaUtil.isValidQualifier4InterfaceStaticMethodCall((PsiMethod)resolved, methodCall.getMethodExpression(), resolveResult.getCurrentFileResolveScope(), languageLevel)) {
|
||||
highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).descriptionAndTooltip("Static method may be invoked on containing interface class only").range(fixRange).create();
|
||||
final String invalidCallMessage =
|
||||
LambdaUtil.getInvalidQualifier4StaticInterfaceMethodMessage((PsiMethod)resolved, methodCall.getMethodExpression(), resolveResult.getCurrentFileResolveScope(), languageLevel);
|
||||
if (invalidCallMessage != null) {
|
||||
highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).descriptionAndTooltip(invalidCallMessage).range(fixRange).create();
|
||||
if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_8)) {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, new IncreaseLanguageLevelFix(LanguageLevel.JDK_1_8));
|
||||
}
|
||||
} else {
|
||||
highlightInfo = GenericsHighlightUtil.checkInferredIntersections(substitutor, fixRange);
|
||||
}
|
||||
|
||||
+4
-4
@@ -186,7 +186,7 @@ public class ExtractIfConditionAction extends PsiElementBaseIntentionAction {
|
||||
private static String createIfString(@NotNull PsiExpression condition,
|
||||
@NotNull PsiStatement thenBranch,
|
||||
@Nullable PsiStatement elseBranch) {
|
||||
return createIfString(condition.getText(), toThenBranchString(thenBranch), toElseBranchString(elseBranch));
|
||||
return createIfString(condition.getText(), toThenBranchString(thenBranch), toElseBranchString(elseBranch, false));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -200,7 +200,7 @@ public class ExtractIfConditionAction extends PsiElementBaseIntentionAction {
|
||||
private static String createIfString(@NotNull PsiExpression condition,
|
||||
@NotNull String thenBranch,
|
||||
@Nullable PsiStatement elseBranch) {
|
||||
return createIfString(condition.getText(), thenBranch, toElseBranchString(elseBranch));
|
||||
return createIfString(condition.getText(), thenBranch, toElseBranchString(elseBranch, true));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -221,12 +221,12 @@ public class ExtractIfConditionAction extends PsiElementBaseIntentionAction {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String toElseBranchString(@Nullable PsiStatement statement) {
|
||||
private static String toElseBranchString(@Nullable PsiStatement statement, boolean skipElse) {
|
||||
if (statement == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (statement instanceof PsiBlockStatement || statement instanceof PsiIfStatement) {
|
||||
if (statement instanceof PsiBlockStatement || skipElse && statement instanceof PsiIfStatement) {
|
||||
return statement.getText();
|
||||
}
|
||||
|
||||
|
||||
@@ -457,15 +457,28 @@ public class LambdaUtil {
|
||||
public static boolean isValidQualifier4InterfaceStaticMethodCall(@NotNull PsiMethod method,
|
||||
@NotNull PsiReferenceExpression methodReferenceExpression,
|
||||
@Nullable PsiElement scope, @NotNull LanguageLevel languageLevel) {
|
||||
if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8)) {
|
||||
final PsiExpression qualifierExpression = methodReferenceExpression.getQualifierExpression();
|
||||
final PsiClass containingClass = method.getContainingClass();
|
||||
if (containingClass != null && containingClass.isInterface() && method.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
return qualifierExpression == null && (scope instanceof PsiImportStaticStatement || PsiTreeUtil.isAncestor(containingClass, methodReferenceExpression, true))||
|
||||
qualifierExpression instanceof PsiReferenceExpression && ((PsiReferenceExpression)qualifierExpression).resolve() == containingClass;
|
||||
return getInvalidQualifier4StaticInterfaceMethodMessage(method, methodReferenceExpression, scope, languageLevel) == null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getInvalidQualifier4StaticInterfaceMethodMessage(@NotNull PsiMethod method,
|
||||
@NotNull PsiReferenceExpression methodReferenceExpression,
|
||||
@Nullable PsiElement scope, @NotNull LanguageLevel languageLevel) {
|
||||
final PsiExpression qualifierExpression = methodReferenceExpression.getQualifierExpression();
|
||||
final PsiClass containingClass = method.getContainingClass();
|
||||
if (containingClass != null && containingClass.isInterface() && method.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_8)) {
|
||||
return "Static interface method invocations are not supported at this language level";
|
||||
}
|
||||
|
||||
if (qualifierExpression == null &&
|
||||
(scope instanceof PsiImportStaticStatement || PsiTreeUtil.isAncestor(containingClass, methodReferenceExpression, true)) ||
|
||||
qualifierExpression instanceof PsiReferenceExpression && ((PsiReferenceExpression)qualifierExpression).resolve() == containingClass) {
|
||||
return null;
|
||||
}
|
||||
return "Static method may be invoked on containing interface class only";
|
||||
}
|
||||
return true;
|
||||
return null;
|
||||
}
|
||||
|
||||
//JLS 14.8 Expression Statements
|
||||
|
||||
@@ -726,9 +726,15 @@ public class ControlFlowUtil {
|
||||
if (nextOffset > flow.getSize()) nextOffset = flow.getSize();
|
||||
if (offset > endOffset) return;
|
||||
int throwToOffset = instruction.offset;
|
||||
boolean isNormal;
|
||||
boolean isNormal = false;
|
||||
if (throwToOffset == nextOffset) {
|
||||
isNormal = nextOffset == endOffset || throwToOffset <= endOffset && !isLeaf(nextOffset) && canCompleteNormally[nextOffset];
|
||||
|
||||
if (nextOffset == endOffset) {
|
||||
final Instruction lastInstruction = flow.getInstructions().get(endOffset - 1);
|
||||
isNormal = !(lastInstruction instanceof GoToInstruction && ((GoToInstruction)lastInstruction).isReturn);
|
||||
}
|
||||
|
||||
isNormal |= throwToOffset <= endOffset && !isLeaf(nextOffset) && canCompleteNormally[nextOffset];
|
||||
}
|
||||
else {
|
||||
isNormal = canCompleteNormally[nextOffset];
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public class SymbolCollectingProcessor extends BaseScopeProcessor implements Ele
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
|
||||
if (element instanceof PsiNamedElement) {
|
||||
if (element instanceof PsiNamedElement && element.isValid()) {
|
||||
PsiNamedElement named = (PsiNamedElement)element;
|
||||
String name = named.getName();
|
||||
if (name != null) {
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ public class CheckedExceptionCompatibilityConstraint extends InputOutputConstrai
|
||||
final List<PsiClassType> exceptions = ExceptionUtil.ourThrowsGuard.doPreventingRecursion(myExpression, false, new Computable<List<PsiClassType>>() {
|
||||
@Override
|
||||
public List<PsiClassType> compute() {
|
||||
return ExceptionUtil.getUnhandledExceptions(body);
|
||||
return ExceptionUtil.getUnhandledExceptions(new PsiElement[] {body});
|
||||
}
|
||||
});
|
||||
if (exceptions != null) {
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
class Test {
|
||||
interface I {
|
||||
<error descr="Extension methods are not supported at this language level">static void foo() {}</error>
|
||||
}
|
||||
|
||||
abstract class IImpl implements I {}
|
||||
interface I2 extends I {}
|
||||
|
||||
{
|
||||
<error descr="Static interface method invocations are not supported at this language level">I.foo();</error>
|
||||
<error descr="Static interface method invocations are not supported at this language level">IImpl.foo();</error>
|
||||
<error descr="Static interface method invocations are not supported at this language level">I2.foo();</error>
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
import java.io.File;
|
||||
|
||||
class Test {
|
||||
public interface A<E extends Throwable> {
|
||||
Object call() throws E;
|
||||
}
|
||||
|
||||
public interface B<E extends Throwable> {
|
||||
void call() throws E;
|
||||
}
|
||||
|
||||
static <T, E extends Throwable> T method(A<E> lambda) {
|
||||
try {
|
||||
lambda.call();
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static <E extends Throwable> void method(B<E> lambda) {
|
||||
try {
|
||||
lambda.call();
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
static String returns(String s) throws Exception {
|
||||
System.out.println(s); return null;
|
||||
}
|
||||
|
||||
static void voids(String s) throws Exception {
|
||||
System.out.println(s);
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
method(() -> {
|
||||
voids("B");
|
||||
});
|
||||
method(() -> voids("B"));
|
||||
|
||||
method(() -> {
|
||||
return new File(returns("A"));
|
||||
});
|
||||
method(() -> new File(returns("A")));
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
class Test {
|
||||
public interface A<E extends Throwable> {
|
||||
Object call() throws E;
|
||||
}
|
||||
|
||||
public interface B<E extends Throwable> {
|
||||
void call() throws E;
|
||||
}
|
||||
|
||||
static Object method(A lambda) {
|
||||
System.out.println("A::");
|
||||
try {
|
||||
lambda.call();
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static void method(B lambda) {
|
||||
System.out.println("B::");
|
||||
try {
|
||||
lambda.call();
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
static Object returns(String s) throws Exception {
|
||||
System.out.println(s); return null;
|
||||
}
|
||||
|
||||
static void voids(String s) throws Exception {
|
||||
System.out.println(s);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
method(() -> {
|
||||
voids("-> B");
|
||||
});
|
||||
|
||||
|
||||
method(() -> voids("-> B"));
|
||||
|
||||
method(() -> {
|
||||
return returns("-> A");
|
||||
});
|
||||
|
||||
method(() -> returns("-> A") );
|
||||
|
||||
method(() -> {
|
||||
returns("-> B");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Extract if (a)" "true"
|
||||
class TestThreadInspection {
|
||||
void f(boolean a, boolean b, boolean c){
|
||||
if (a)
|
||||
if (b) {
|
||||
System.out.println("a&b");
|
||||
} else {
|
||||
if (c) {
|
||||
System.out.println("c");
|
||||
}
|
||||
}
|
||||
else if (c) {
|
||||
System.out.println("c");
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Extract if (a)" "true"
|
||||
class TestThreadInspection {
|
||||
void f(boolean a, boolean b, boolean c){
|
||||
if (a)
|
||||
if (b) {
|
||||
System.out.println("a&b");
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Extract if (a)" "true"
|
||||
class TestThreadInspection {
|
||||
void f(boolean a, boolean b, boolean c){
|
||||
if (a) {
|
||||
System.out.println("a&b");
|
||||
} else if (b) {
|
||||
System.out.println("a&b");
|
||||
} else {
|
||||
if (c) {
|
||||
System.out.println("c");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Extract if (a)" "true"
|
||||
class TestThreadInspection {
|
||||
void f(boolean a, boolean b, boolean c){
|
||||
if (a) {
|
||||
System.out.println("a&b");
|
||||
} else if (b) {
|
||||
System.out.println("a&b");
|
||||
} else {
|
||||
System.out.println("c");
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Extract if (a)" "true"
|
||||
class TestThreadInspection {
|
||||
void f(boolean a, boolean b, boolean c){
|
||||
if (a)
|
||||
if (b) {
|
||||
System.out.println("a&b");
|
||||
} else {
|
||||
System.out.println("c");
|
||||
}
|
||||
else {
|
||||
System.out.println("c");
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Extract if (a)" "true"
|
||||
class TestThreadInspection {
|
||||
void f(boolean a, boolean b, boolean c){
|
||||
if (<caret>a && b) {
|
||||
System.out.println("a&b");
|
||||
} else if (c) {
|
||||
System.out.println("c");
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Extract if (a)" "true"
|
||||
class TestThreadInspection {
|
||||
void f(boolean a, boolean b, boolean c){
|
||||
if (<caret>a && b) {
|
||||
System.out.println("a&b");
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Extract if (a)" "true"
|
||||
class TestThreadInspection {
|
||||
void f(boolean a, boolean b, boolean c){
|
||||
if (<caret>a || b) {
|
||||
System.out.println("a&b");
|
||||
} else if (c) {
|
||||
System.out.println("c");
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Extract if (a)" "true"
|
||||
class TestThreadInspection {
|
||||
void f(boolean a, boolean b, boolean c){
|
||||
if (<caret>a || b) {
|
||||
System.out.println("a&b");
|
||||
} else {
|
||||
System.out.println("c");
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Extract if (a)" "true"
|
||||
class TestThreadInspection {
|
||||
void f(boolean a, boolean b, boolean c){
|
||||
if (<caret>a && b) {
|
||||
System.out.println("a&b");
|
||||
} else {
|
||||
System.out.println("c");
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -187,4 +187,5 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA111420() { doTest(false, false); }
|
||||
public void testIDEA111450() { doTest(true, false); }
|
||||
public void testExternalizable() { doTest(true, false); }
|
||||
public void testAccessToStaticMethodsFromInterfaces() { doTest(true, false); }
|
||||
}
|
||||
|
||||
+4
@@ -49,6 +49,10 @@ public class ExceptionVariablesInferenceTest extends LightDaemonAnalyzerTestCase
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testExceptionsThrownByCallArguments() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
+4
@@ -47,6 +47,10 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testVoidValueCompatibilityCantCompleteNormallyWithCallWithExceptionAsLastReturnStatement() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA102800() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.codeInsight.daemon.quickFix;
|
||||
|
||||
|
||||
|
||||
public class ExtractIfConditionTest extends LightQuickFixParameterizedTestCase {
|
||||
|
||||
public void test() throws Exception { doAllTests(); }
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/codeInsight/daemonCodeAnalyzer/quickFix/extractIfCondition";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,8 +31,6 @@ import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.testFramework.LightVirtualFile;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
+8
-1
@@ -33,6 +33,7 @@ import com.intellij.openapi.editor.impl.DocumentMarkupModel;
|
||||
import com.intellij.openapi.editor.markup.MarkupModel;
|
||||
import com.intellij.openapi.editor.markup.RangeHighlighter;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
@@ -85,7 +86,13 @@ public class IdentifierHighlighterPass extends TextEditorHighlightingPass {
|
||||
}
|
||||
|
||||
int flags = TargetElementUtilBase.ELEMENT_NAME_ACCEPTED | TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED;
|
||||
PsiElement myTarget = TargetElementUtilBase.getInstance().findTargetElement(myEditor, flags, myCaretOffset);
|
||||
PsiElement myTarget;
|
||||
try {
|
||||
myTarget = TargetElementUtilBase.getInstance().findTargetElement(myEditor, flags, myCaretOffset);
|
||||
}
|
||||
catch (IndexNotReadyException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (myTarget == null) {
|
||||
if (!PsiDocumentManager.getInstance(myProject).isUncommited(myEditor.getDocument())) {
|
||||
|
||||
+3
-2
@@ -25,6 +25,7 @@ import com.intellij.openapi.application.ex.ApplicationInfoEx;
|
||||
import com.intellij.openapi.extensions.PluginId;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.updateSettings.impl.UpdateSettings;
|
||||
import com.intellij.ui.DoubleClickListener;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
@@ -237,7 +238,7 @@ public class AvailablePluginsManagerMain extends PluginManagerMain {
|
||||
}
|
||||
|
||||
private AnAction createFilterByCategoryAction(final String availableCategory) {
|
||||
return new AnAction(availableCategory) {
|
||||
return new DumbAwareAction(availableCategory) {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final String filter = myFilter.getFilter().toLowerCase(Locale.ENGLISH);
|
||||
@@ -280,7 +281,7 @@ public class AvailablePluginsManagerMain extends PluginManagerMain {
|
||||
}
|
||||
|
||||
private AnAction createFilterByRepositoryAction(final String host) {
|
||||
return new AnAction(host) {
|
||||
return new DumbAwareAction(host) {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final String filter = myFilter.getFilter().toLowerCase(Locale.ENGLISH);
|
||||
|
||||
+2
-1
@@ -20,11 +20,12 @@ import com.intellij.ide.plugins.PluginTable;
|
||||
import com.intellij.ide.plugins.PluginTableModel;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public abstract class AbstractSortByAction extends ToggleAction {
|
||||
public abstract class AbstractSortByAction extends ToggleAction implements DumbAware {
|
||||
protected final PluginTable myTable;
|
||||
protected final PluginTableModel myModel;
|
||||
|
||||
|
||||
+1
-2
@@ -24,7 +24,6 @@ import com.intellij.execution.testframework.stacktrace.DiffHyperlink;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -118,7 +117,7 @@ public class ViewAssertEqualsDiffAction extends AnAction implements TestTreeView
|
||||
myProviders = providers;
|
||||
if (hyperlink != null) {
|
||||
for (DiffHyperlink viewProvider : providers) {
|
||||
if (Comparing.equal(hyperlink, viewProvider)) {
|
||||
if (hyperlink.equals(viewProvider)) {
|
||||
provider = viewProvider;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class XDebugSessionTab extends DebuggerSessionTabBase {
|
||||
private static final DataKey<XDebugSessionTab> TAB_KEY = DataKey.create("XDebugSessionTab");
|
||||
public static final DataKey<XDebugSessionTab> TAB_KEY = DataKey.create("XDebugSessionTab");
|
||||
|
||||
private XWatchesViewImpl myWatchesView;
|
||||
private final List<XDebugView> myViews = new ArrayList<XDebugView>();
|
||||
|
||||
+14
-6
@@ -16,6 +16,7 @@
|
||||
package com.intellij.xdebugger.impl.ui.tree;
|
||||
|
||||
import com.intellij.codeInsight.hint.HintManager;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.ui.AppUIUtil;
|
||||
@@ -24,6 +25,7 @@ import com.intellij.xdebugger.frame.XValueModifier;
|
||||
import com.intellij.xdebugger.frame.presentation.XValuePresentation;
|
||||
import com.intellij.xdebugger.impl.XDebuggerUtilImpl;
|
||||
import com.intellij.xdebugger.impl.breakpoints.XExpressionImpl;
|
||||
import com.intellij.xdebugger.impl.ui.XDebugSessionTab;
|
||||
import com.intellij.xdebugger.impl.ui.XDebuggerUIConstants;
|
||||
import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl;
|
||||
import com.intellij.xdebugger.impl.ui.tree.nodes.XValuePresentationUtil;
|
||||
@@ -104,12 +106,14 @@ public class SetValueInplaceEditor extends XDebuggerTreeInplaceEditor {
|
||||
myModifier.setValue(myExpressionEditor.getExpression().getExpression(), new XValueModifier.XModificationCallback() {
|
||||
@Override
|
||||
public void valueModified() {
|
||||
AppUIUtil.invokeOnEdt(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myTree.rebuildAndRestore(treeState);
|
||||
}
|
||||
});
|
||||
if (isDetachedTree(myTree)) {
|
||||
AppUIUtil.invokeOnEdt(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myTree.rebuildAndRestore(treeState);
|
||||
}
|
||||
});
|
||||
}
|
||||
XDebuggerUtilImpl.rebuildAllSessionsViews(getProject());
|
||||
}
|
||||
|
||||
@@ -131,6 +135,10 @@ public class SetValueInplaceEditor extends XDebuggerTreeInplaceEditor {
|
||||
});
|
||||
XDebuggerUtilImpl.rebuildAllSessionsViews(getProject());
|
||||
}
|
||||
|
||||
boolean isDetachedTree(XDebuggerTree tree) {
|
||||
return XDebugSessionTab.TAB_KEY.getData(DataManager.getInstance().getDataContext(tree)) == null;
|
||||
}
|
||||
});
|
||||
super.doOKAction();
|
||||
}
|
||||
|
||||
+8
-16
@@ -84,11 +84,8 @@ public class AbstractMethodWithMissingImplementationsInspection
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasMatchingImplementation(
|
||||
@NotNull PsiClass aClass,
|
||||
@NotNull PsiMethod method) {
|
||||
final PsiMethod overridingMethod =
|
||||
findOverridingMethod(aClass, method);
|
||||
private static boolean hasMatchingImplementation(@NotNull PsiClass aClass, @NotNull PsiMethod method) {
|
||||
final PsiMethod overridingMethod = findOverridingMethod(aClass, method);
|
||||
if (overridingMethod == null ||
|
||||
overridingMethod.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
return false;
|
||||
@@ -98,8 +95,7 @@ public class AbstractMethodWithMissingImplementationsInspection
|
||||
}
|
||||
final PsiClass superClass = method.getContainingClass();
|
||||
final PsiManager manager = overridingMethod.getManager();
|
||||
final JavaPsiFacade facade =
|
||||
JavaPsiFacade.getInstance(manager.getProject());
|
||||
final JavaPsiFacade facade = JavaPsiFacade.getInstance(manager.getProject());
|
||||
return facade.arePackagesTheSame(superClass, aClass);
|
||||
}
|
||||
|
||||
@@ -109,27 +105,23 @@ public class AbstractMethodWithMissingImplementationsInspection
|
||||
* @return the overriding method.
|
||||
*/
|
||||
@Nullable
|
||||
private static PsiMethod findOverridingMethod(
|
||||
PsiClass aClass, @NotNull PsiMethod method) {
|
||||
private static PsiMethod findOverridingMethod(PsiClass aClass, @NotNull PsiMethod method) {
|
||||
final PsiClass superClass = method.getContainingClass();
|
||||
if (aClass.equals(superClass)) {
|
||||
return null;
|
||||
}
|
||||
final PsiSubstitutor substitutor =
|
||||
TypeConversionUtil.getSuperClassSubstitutor(superClass,
|
||||
aClass, PsiSubstitutor.EMPTY);
|
||||
TypeConversionUtil.getSuperClassSubstitutor(superClass, aClass, PsiSubstitutor.EMPTY);
|
||||
final MethodSignature signature = method.getSignature(substitutor);
|
||||
final List<Pair<PsiMethod, PsiSubstitutor>> pairs =
|
||||
aClass.findMethodsAndTheirSubstitutorsByName(
|
||||
signature.getName(), true);
|
||||
aClass.findMethodsAndTheirSubstitutorsByName(signature.getName(), true);
|
||||
for (Pair<PsiMethod, PsiSubstitutor> pair : pairs) {
|
||||
final PsiMethod overridingMethod = pair.first;
|
||||
if (overridingMethod.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
continue;
|
||||
}
|
||||
final PsiClass containingClass =
|
||||
overridingMethod.getContainingClass();
|
||||
if (containingClass.isInterface()) {
|
||||
final PsiClass containingClass = overridingMethod.getContainingClass();
|
||||
if (containingClass != null && containingClass.isInterface() && !overridingMethod.hasModifierProperty(PsiModifier.DEFAULT)) {
|
||||
continue;
|
||||
}
|
||||
final PsiSubstitutor overridingSubstitutor = pair.second;
|
||||
|
||||
+2
-4
@@ -104,10 +104,8 @@ public class TypeUtils {
|
||||
if (expression == null) {
|
||||
return null;
|
||||
}
|
||||
PsiType type = expression.getType();
|
||||
if (type instanceof PsiLambdaExpressionType) {
|
||||
type = ((PsiLambdaExpressionType)type).getExpression().getFunctionalInterfaceType();
|
||||
}
|
||||
PsiType type = expression instanceof PsiFunctionalExpression ? ((PsiFunctionalExpression)expression).getFunctionalInterfaceType()
|
||||
: expression.getType();
|
||||
if (type == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+10
-2
@@ -18,6 +18,7 @@ package com.siyeh.ig.visibility;
|
||||
import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PropertyUtil;
|
||||
import com.siyeh.HardcodedMethodConstants;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
@@ -117,8 +118,15 @@ public class ParameterHidingMemberVariableInspectionBase extends BaseInspection
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (m_ignoreForPropertySetters && PropertyUtil.isSimplePropertySetter(method)) {
|
||||
return;
|
||||
if (m_ignoreForPropertySetters) {
|
||||
final String methodName = method.getName();
|
||||
if (methodName.startsWith(HardcodedMethodConstants.SET) && PsiType.VOID.equals(method.getReturnType())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (PropertyUtil.isSimplePropertySetter(method)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
final PsiClass aClass = checkFieldName(variable, method);
|
||||
if (aClass == null) {
|
||||
|
||||
+8
@@ -6,4 +6,12 @@ class WithDefaultMethods {
|
||||
}
|
||||
|
||||
class B implements A {}
|
||||
|
||||
interface C {
|
||||
void foo();
|
||||
}
|
||||
interface D extends C {
|
||||
default void foo(){}
|
||||
}
|
||||
class E implements C, D {}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.siyeh.igtest.threading.defaultRun;
|
||||
class TestMethodRef {
|
||||
{
|
||||
new Thread(this::method2);
|
||||
}
|
||||
|
||||
public void method2() {
|
||||
System.out.println("I am in thread");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user