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:
@@ -22,12 +22,11 @@ import com.intellij.execution.junit2.info.MethodLocation;
|
||||
import com.intellij.ide.util.PsiClassListCellRenderer;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.fileEditor.TextEditor;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.searches.ClassInheritorsSearch;
|
||||
import com.intellij.psi.util.PsiClassUtil;
|
||||
@@ -37,7 +36,10 @@ import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Processor;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
@@ -57,7 +59,15 @@ public class InheritorChooser {
|
||||
final Runnable performRunnable,
|
||||
final PsiMethod psiMethod,
|
||||
final PsiClass containingClass) {
|
||||
if (containingClass != null && containingClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
return runMethodInAbstractClass(context, performRunnable, psiMethod, containingClass, Condition.TRUE);
|
||||
}
|
||||
|
||||
public boolean runMethodInAbstractClass(final ConfigurationContext context,
|
||||
final Runnable performRunnable,
|
||||
final PsiMethod psiMethod,
|
||||
final PsiClass containingClass,
|
||||
final Condition<PsiClass> acceptAbstractCondition) {
|
||||
if (containingClass != null && containingClass.hasModifierProperty(PsiModifier.ABSTRACT) && acceptAbstractCondition.value(containingClass)) {
|
||||
final Location location = context.getLocation();
|
||||
if (location instanceof MethodLocation) {
|
||||
final PsiClass aClass = ((MethodLocation)location).getContainingClass();
|
||||
|
||||
+1
-1
@@ -675,7 +675,7 @@ public class HighlightControlFlowUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isEffectivelyFinal(PsiVariable variable, PsiElement scope, PsiJavaCodeReferenceElement context) {
|
||||
public static boolean isEffectivelyFinal(PsiVariable variable, PsiElement scope, @Nullable PsiJavaCodeReferenceElement context) {
|
||||
boolean effectivelyFinal;
|
||||
if (variable instanceof PsiParameter) {
|
||||
effectivelyFinal = notAccessedForWriting(variable, new LocalSearchScope(((PsiParameter)variable).getDeclarationScope()));
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@ import com.intellij.codeInsight.daemon.QuickFixBundle;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.refactoring.util.RefactoringChangeUtil;
|
||||
@@ -95,7 +96,7 @@ public class AddTypeArgumentsFix extends MethodArgumentFix {
|
||||
methodExpression.setQualifierExpression(qualifierExpression);
|
||||
}
|
||||
|
||||
return copy;
|
||||
return (PsiExpression)JavaCodeStyleManager.getInstance(copy.getProject()).shortenClassReferences(copy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-6
@@ -95,12 +95,7 @@ public class RedundantLambdaCodeBlockInspection extends BaseJavaBatchLocalInspec
|
||||
return returnStatement.getReturnValue();
|
||||
}
|
||||
else {
|
||||
final PsiExpression expression = ((PsiExpressionStatement)statements[0]).getExpression();
|
||||
final PsiType psiType = expression.getType();
|
||||
if (psiType != PsiType.VOID) {
|
||||
return null;
|
||||
}
|
||||
return expression;
|
||||
return ((PsiExpressionStatement)statements[0]).getExpression();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+19
-16
@@ -331,24 +331,23 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
|
||||
iteration += ".filter(" + parameter.getName() + " -> " + condition.getText() +")";
|
||||
}
|
||||
}
|
||||
iteration +=".map(";
|
||||
|
||||
final PsiExpression mapperCall = methodCallExpression.getArgumentList().getExpressions()[0];
|
||||
|
||||
final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
|
||||
final PsiClass functionClass = psiFacade.findClass("java.util.function.Function", GlobalSearchScope.allScope(project));
|
||||
final PsiClassType functionalInterfaceType = functionClass != null ? psiFacade.getElementFactory().createType(functionClass, parameter.getType(), mapperCall.getType()) : null;
|
||||
final PsiCallExpression toConvertCall = LambdaCanBeMethodReferenceInspection.canBeMethodReferenceProblem(mapperCall,
|
||||
new PsiParameter[]{
|
||||
parameter},
|
||||
functionalInterfaceType);
|
||||
final String methodReferenceText = LambdaCanBeMethodReferenceInspection.createMethodReferenceText(toConvertCall, functionalInterfaceType, new PsiParameter[]{parameter});
|
||||
if (methodReferenceText != null) {
|
||||
iteration += methodReferenceText;
|
||||
} else {
|
||||
iteration += parameter.getName() + " -> " + mapperCall.getText();
|
||||
if (!isIdentityMapping(parameter, mapperCall)) {
|
||||
iteration +=".map(";
|
||||
final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
|
||||
final PsiClass functionClass = psiFacade.findClass("java.util.function.Function", GlobalSearchScope.allScope(project));
|
||||
final PsiClassType functionalInterfaceType = functionClass != null ? psiFacade.getElementFactory().createType(functionClass, parameter.getType(), mapperCall.getType()) : null;
|
||||
final PsiCallExpression toConvertCall = LambdaCanBeMethodReferenceInspection.canBeMethodReferenceProblem(mapperCall, new PsiParameter[]{parameter}, functionalInterfaceType);
|
||||
final String methodReferenceText = LambdaCanBeMethodReferenceInspection.createMethodReferenceText(toConvertCall, functionalInterfaceType, new PsiParameter[]{parameter});
|
||||
if (methodReferenceText != null) {
|
||||
iteration += methodReferenceText;
|
||||
} else {
|
||||
iteration += parameter.getName() + " -> " + mapperCall.getText();
|
||||
}
|
||||
iteration += ")";
|
||||
}
|
||||
iteration += ").collect(java.util.stream.Collectors.";
|
||||
|
||||
iteration += ".collect(java.util.stream.Collectors.";
|
||||
|
||||
String variableName = null;
|
||||
PsiExpression primitiveInitializer = null;
|
||||
@@ -403,6 +402,10 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isIdentityMapping(PsiParameter parameter, PsiExpression mapperCall) {
|
||||
return mapperCall instanceof PsiReferenceExpression && ((PsiReferenceExpression)mapperCall).resolve() == parameter;
|
||||
}
|
||||
}
|
||||
|
||||
public static PsiIfStatement extractIfStatement(PsiStatement body) {
|
||||
|
||||
+1
-1
@@ -259,7 +259,7 @@ public class IntroduceParameterObjectDialog extends RefactoringDialog {
|
||||
IntroduceParameterObjectDialog.this.doCancelAction();
|
||||
}
|
||||
};
|
||||
myParamsPanel.add(paramsPanel, BorderLayout.CENTER);
|
||||
myParamsPanel.add(paramsPanel, BorderLayout.NORTH);
|
||||
return myWholePanel;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
<grid id="27dc6" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="579" height="440"/>
|
||||
<xy x="20" y="20" width="579" height="446"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
@@ -207,7 +207,7 @@
|
||||
</grid>
|
||||
<grid id="783a4" binding="myParamsPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
|
||||
@@ -394,7 +394,7 @@ public class PsiSubstitutorImpl implements PsiSubstitutor {
|
||||
if (erasure != null) {
|
||||
final PsiType[] boundTypes = typeParameter.getExtendsListTypes();
|
||||
for (PsiType boundType : boundTypes) {
|
||||
if (TypeConversionUtil.isAssignable(boundType, erasure) || TypeConversionUtil.isAssignable(erasure, boundType)) {
|
||||
if (TypeConversionUtil.isAssignable(erasure, boundType)) {
|
||||
return boundType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -567,15 +567,13 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
|
||||
return dir.findChild(baseName + "$" + innerName + ".class");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ClassReader readerForInnerClass(VirtualFile innerClass) {
|
||||
public void accept(VirtualFile innerClass, StubBuildingVisitor<VirtualFile> visitor) {
|
||||
try {
|
||||
return new ClassReader(innerClass.contentsToByteArray());
|
||||
}
|
||||
catch (IOException e) {
|
||||
return null;
|
||||
byte[] bytes = innerClass.contentsToByteArray();
|
||||
new ClassReader(bytes).accept(visitor, ClassReader.SKIP_FRAMES);
|
||||
}
|
||||
catch (IOException ignored) { }
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.
|
||||
@@ -13,19 +13,16 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
package com.intellij.psi.impl.compiled;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.org.objectweb.asm.ClassReader;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public interface InnerClassSourceStrategy<T> {
|
||||
@Nullable
|
||||
T findInnerClass(String name, T outerClass);
|
||||
|
||||
@Nullable
|
||||
ClassReader readerForInnerClass(T innerClass);
|
||||
void accept(T innerClass, StubBuildingVisitor<T> visitor);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
public static final String FLOAT_NEGATIVE_INF = "-1.0f / 0.0";
|
||||
public static final String FLOAT_NAN = "0.0f / 0.0";
|
||||
|
||||
public static final int ASM_API = Opcodes.ASM5;
|
||||
private static final int ASM_API = Opcodes.ASM5;
|
||||
|
||||
@NonNls private static final String SYNTHETIC_CLASS_INIT_METHOD = "<clinit>";
|
||||
@NonNls private static final String SYNTHETIC_INIT_METHOD = "<init>";
|
||||
@@ -207,6 +207,9 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
case Opcodes.V1_7:
|
||||
return LanguageLevel.JDK_1_7;
|
||||
|
||||
case Opcodes.V1_8:
|
||||
return LanguageLevel.JDK_1_8;
|
||||
|
||||
default:
|
||||
return LanguageLevel.HIGHEST;
|
||||
}
|
||||
@@ -320,14 +323,11 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
return;
|
||||
}
|
||||
|
||||
final T innerSource = myInnersStrategy.findInnerClass(innerName, mySource);
|
||||
if (innerSource == null) return;
|
||||
|
||||
final ClassReader reader = myInnersStrategy.readerForInnerClass(innerSource);
|
||||
if (reader == null) return;
|
||||
|
||||
final StubBuildingVisitor<T> classVisitor = new StubBuildingVisitor<T>(innerSource, myInnersStrategy, myResult, access, innerName);
|
||||
reader.accept(classVisitor, ClassReader.SKIP_FRAMES);
|
||||
T innerClass = myInnersStrategy.findInnerClass(innerName, mySource);
|
||||
if (innerClass != null) {
|
||||
StubBuildingVisitor<T> visitor = new StubBuildingVisitor<T>(innerClass, myInnersStrategy, myResult, access, innerName);
|
||||
myInnersStrategy.accept(innerClass, visitor);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isCorrectName(String name) {
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ class Bug2<T extends Integer>{
|
||||
}
|
||||
|
||||
void bug1(Parametrized<? super T> param) {
|
||||
foo(param);
|
||||
<error descr="Inferred type 'capture<? super T>' for type parameter 'I' is not within its bound; should extend 'java.lang.Number'">foo(param)</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class Test {
|
||||
}
|
||||
|
||||
void bug1(Parametrized<? super T> param) {
|
||||
<error descr="Inferred type 'java.io.Serializable' for type parameter 'I' is not within its bound; should extend 'java.lang.Number'">foo(param)</error>;
|
||||
<error descr="Inferred type 'capture<? super T>' for type parameter 'I' is not within its bound; should extend 'java.lang.Number'">foo(param)</error>;
|
||||
}
|
||||
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
class Test {
|
||||
class Event {}
|
||||
class KeyEvent extends Event {
|
||||
int getCode() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
interface EventListener<T extends Event> {
|
||||
void handle(T event);
|
||||
}
|
||||
|
||||
class EventType<T extends Event>{}
|
||||
static final EventType<KeyEvent> KEY_PRESSED = null;
|
||||
|
||||
{
|
||||
addEventHandler(KEY_PRESSED, keyEvent -> {
|
||||
int i = keyEvent.getCode();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public final <T extends Event> void addEventHandler(final EventType<T> eventType, final EventListener<? super T> listener) {}
|
||||
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Add explicit type arguments" "true"
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
class Bar {
|
||||
public static void main(String[] args) {
|
||||
new Foo().foo(Collections.<Date>emptyList());
|
||||
}
|
||||
}
|
||||
|
||||
class Foo {
|
||||
void foo(List<java.util.Date> dates) { }
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Add explicit type arguments" "true"
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
class Bar {
|
||||
public static void main(String[] args) {
|
||||
new Foo().fo<caret>o(Collections.emptyList());
|
||||
}
|
||||
}
|
||||
|
||||
class Foo {
|
||||
void foo(List<java.util.Date> dates) { }
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Replace with expression lambda" "true"
|
||||
class Test {
|
||||
{
|
||||
Runnable c = () -> foo();
|
||||
}
|
||||
|
||||
int foo() {return 1;}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Replace with expression lambda" "false"
|
||||
// "Replace with expression lambda" "true"
|
||||
class Test {
|
||||
{
|
||||
Runnable c = () -> <caret>{foo();};
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with collect" "true"
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Collect {
|
||||
class Person {}
|
||||
|
||||
void collectNames(List<Person> persons){
|
||||
List<Person> names = persons.stream().collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with collect" "true"
|
||||
import java.util.*;
|
||||
|
||||
public class Collect {
|
||||
class Person {}
|
||||
|
||||
void collectNames(List<Person> persons){
|
||||
List<Person> names = new ArrayList<>();
|
||||
for (Person person : pers<caret>ons) {
|
||||
names.add(person);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -340,8 +340,6 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA120153() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
public void testIDEA120563() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
|
||||
public void testSuperWildcardWithBoundPromotion() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);}
|
||||
|
||||
public void testJavaUtilCollections_NoVerify() throws Exception {
|
||||
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
|
||||
assertNotNull(collectionsClass);
|
||||
|
||||
+2
@@ -751,6 +751,8 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSuperWildcardWithBoundPromotion() { doTest();}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
+4
@@ -174,6 +174,10 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA122700() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
@@ -568,7 +568,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
if (toolWindow != null) {
|
||||
myContentManager = toolWindow.getContentManager();
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
toolWindow.setContentUiType(ToolWindowContentUiType.getInstance("combo"), null);
|
||||
toolWindow.setContentUiType(ToolWindowContentUiType.COMBO, null);
|
||||
((ToolWindowEx)toolWindow).setAdditionalGearActions(myActionGroup);
|
||||
toolWindow.getComponent().putClientProperty(ToolWindowContentUi.HIDE_ID_LABEL, "true");
|
||||
}
|
||||
|
||||
@@ -37,11 +37,20 @@ public class ToolWindowContentUiType {
|
||||
public static ToolWindowContentUiType getInstance(String name) {
|
||||
if (TABBED.getName().equals(name)) {
|
||||
return TABBED;
|
||||
} else if (COMBO.getName().equals(name)) {
|
||||
}
|
||||
else if (COMBO.getName().equals(name)) {
|
||||
return COMBO;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LOG.debug("Unknown content type=" + name);
|
||||
return TABBED;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ToolWindowContentUiType{" +
|
||||
"myName='" + myName + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -276,7 +276,7 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
|
||||
assert mySession == this;
|
||||
|
||||
if (!myDir.exists()) return getAllStorageFiles();
|
||||
assert myDir.isDirectory();
|
||||
assert myDir.isDirectory() : myDir.getPath();
|
||||
|
||||
final List<IFile> filesToSave = new ArrayList<IFile>();
|
||||
|
||||
|
||||
@@ -29,12 +29,12 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.wm.*;
|
||||
import com.intellij.openapi.wm.ex.ToolWindowEx;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.UIBundle;
|
||||
import com.intellij.ui.components.panels.NonOpaquePanel;
|
||||
import com.intellij.ui.content.Content;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import com.intellij.util.Producer;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -44,11 +44,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.event.EventListenerList;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -63,7 +60,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
private WindowInfoImpl myInfo;
|
||||
private final ToolWindowImpl myToolWindow;
|
||||
private final MyDivider myDivider;
|
||||
private final EventListenerList myListenerList;
|
||||
private final EventDispatcher<InternalDecoratorListener> myDispatcher = EventDispatcher.create(InternalDecoratorListener.class);
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
@@ -77,7 +74,6 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
/**
|
||||
* Catches all event from tool window and modifies decorator's appearance.
|
||||
*/
|
||||
private final ToolWindowHandler myToolWindowHandler;
|
||||
private final MyKeymapManagerListener myWeakKeymapManagerListener;
|
||||
@NonNls private static final String HIDE_ACTIVE_WINDOW_ACTION_ID = "HideActiveWindow";
|
||||
@NonNls public static final String TOGGLE_PINNED_MODE_ACTION_ID = "TogglePinnedMode";
|
||||
@@ -101,8 +97,6 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
myToggleAutoHideModeAction = new TogglePinnedModeAction();
|
||||
myToggleContentUiTypeAction = new ToggleContentUiTypeAction();
|
||||
|
||||
myListenerList = new EventListenerList();
|
||||
|
||||
myHeader = new ToolWindowHeader(toolWindow, info, new Producer<ActionGroup>() {
|
||||
@Override
|
||||
public ActionGroup produce() {
|
||||
@@ -137,9 +131,6 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
|
||||
init();
|
||||
|
||||
myToolWindowHandler = new ToolWindowHandler();
|
||||
myToolWindow.addPropertyChangeListener(myToolWindowHandler);
|
||||
|
||||
apply(info);
|
||||
}
|
||||
|
||||
@@ -187,8 +178,6 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
validate();
|
||||
repaint();
|
||||
|
||||
//
|
||||
updateTitle();
|
||||
|
||||
// Push "apply" request forward
|
||||
|
||||
@@ -210,17 +199,16 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
}
|
||||
}
|
||||
|
||||
final void addInternalDecoratorListener(final InternalDecoratorListener l) {
|
||||
myListenerList.add(InternalDecoratorListener.class, l);
|
||||
final void addInternalDecoratorListener(InternalDecoratorListener l) {
|
||||
myDispatcher.addListener(l);
|
||||
}
|
||||
|
||||
final void removeInternalDecoratorListener(final InternalDecoratorListener l) {
|
||||
myListenerList.remove(InternalDecoratorListener.class, l);
|
||||
final void removeInternalDecoratorListener(InternalDecoratorListener l) {
|
||||
myDispatcher.removeListener(l);
|
||||
}
|
||||
|
||||
final void dispose() {
|
||||
removeAll();
|
||||
myToolWindow.removePropertyChangeListener(myToolWindowHandler);
|
||||
KeymapManagerEx.getInstanceEx().removeWeakListener(myWeakKeymapManagerListener);
|
||||
|
||||
Disposer.dispose(myHeader);
|
||||
@@ -228,76 +216,49 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
myProject = null;
|
||||
}
|
||||
|
||||
private void fireAnchorChanged(final ToolWindowAnchor anchor) {
|
||||
final InternalDecoratorListener[] listeners = myListenerList.getListeners(InternalDecoratorListener.class);
|
||||
for (InternalDecoratorListener listener : listeners) {
|
||||
listener.anchorChanged(this, anchor);
|
||||
}
|
||||
private void fireAnchorChanged(ToolWindowAnchor anchor) {
|
||||
myDispatcher.getMulticaster().anchorChanged(this, anchor);
|
||||
}
|
||||
|
||||
private void fireAutoHideChanged(final boolean autoHide) {
|
||||
final InternalDecoratorListener[] listeners = myListenerList.getListeners(InternalDecoratorListener.class);
|
||||
for (InternalDecoratorListener listener : listeners) {
|
||||
listener.autoHideChanged(this, autoHide);
|
||||
}
|
||||
private void fireAutoHideChanged(boolean autoHide) {
|
||||
myDispatcher.getMulticaster().autoHideChanged(this, autoHide);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires event that "hide" button has been pressed.
|
||||
*/
|
||||
final void fireHidden() {
|
||||
final InternalDecoratorListener[] listeners = myListenerList.getListeners(InternalDecoratorListener.class);
|
||||
for (InternalDecoratorListener listener : listeners) {
|
||||
listener.hidden(this);
|
||||
}
|
||||
myDispatcher.getMulticaster().hidden(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires event that "hide" button has been pressed.
|
||||
*/
|
||||
final void fireHiddenSide() {
|
||||
final InternalDecoratorListener[] listeners = myListenerList.getListeners(InternalDecoratorListener.class);
|
||||
for (InternalDecoratorListener listener : listeners) {
|
||||
listener.hiddenSide(this);
|
||||
}
|
||||
myDispatcher.getMulticaster().hiddenSide(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires event that user performed click into the title bar area.
|
||||
*/
|
||||
final void fireActivated() {
|
||||
final InternalDecoratorListener[] listeners = myListenerList.getListeners(InternalDecoratorListener.class);
|
||||
for (InternalDecoratorListener listener : listeners) {
|
||||
listener.activated(this);
|
||||
}
|
||||
myDispatcher.getMulticaster().activated(this);
|
||||
}
|
||||
|
||||
private void fireTypeChanged(final ToolWindowType type) {
|
||||
final InternalDecoratorListener[] listeners = myListenerList.getListeners(InternalDecoratorListener.class);
|
||||
for (InternalDecoratorListener listener : listeners) {
|
||||
listener.typeChanged(this, type);
|
||||
}
|
||||
private void fireTypeChanged(ToolWindowType type) {
|
||||
myDispatcher.getMulticaster().typeChanged(this, type);
|
||||
}
|
||||
|
||||
final void fireResized() {
|
||||
final InternalDecoratorListener[] listeners = myListenerList.getListeners(InternalDecoratorListener.class);
|
||||
for (InternalDecoratorListener listener : listeners) {
|
||||
listener.resized(this);
|
||||
}
|
||||
myDispatcher.getMulticaster().resized(this);
|
||||
}
|
||||
|
||||
private void fireSideStatusChanged(boolean isSide) {
|
||||
final InternalDecoratorListener[] listeners = myListenerList.getListeners(InternalDecoratorListener.class);
|
||||
for (InternalDecoratorListener listener : listeners) {
|
||||
listener.sideStatusChanged(this, isSide);
|
||||
}
|
||||
myDispatcher.getMulticaster().sideStatusChanged(this, isSide);
|
||||
}
|
||||
|
||||
private void fireContentUiTypeChanges(ToolWindowContentUiType type) {
|
||||
final InternalDecoratorListener[] listeners = myListenerList.getListeners(InternalDecoratorListener.class);
|
||||
for (InternalDecoratorListener listener : listeners) {
|
||||
listener.contentUiTypeChanges(this, type);
|
||||
}
|
||||
myDispatcher.getMulticaster().contentUiTypeChanges(this, type);
|
||||
}
|
||||
|
||||
private void init() {
|
||||
@@ -515,30 +476,6 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: to b removed
|
||||
private void updateTitle() {
|
||||
final StringBuffer fullTitle = new StringBuffer();
|
||||
// Due to JDK's bug #4234645 we cannot support custom decoration on Linux platform.
|
||||
// The prblem is that Window.setLocation() doesn't work properly wjen the dialod is displayable.
|
||||
// Therefore we use native WM decoration. When the dialog has native decoration we show window ID
|
||||
// in the dialog's title and window title at the custom title panel. If the custom decoration
|
||||
// is used we show composite string at the custom title panel.
|
||||
// TODO[vova] investigate the problem under Mac OSX.
|
||||
if (SystemInfo.isWindows || !myInfo.isFloating()) {
|
||||
fullTitle.append(myInfo.getId());
|
||||
final String title = myToolWindow.getTitle();
|
||||
if (title != null && title.length() > 0) {
|
||||
fullTitle.append(" - ").append(title);
|
||||
}
|
||||
}
|
||||
else { // Unixes ans MacOSX go here when tool window is in floating mode
|
||||
final String title = myToolWindow.getTitle();
|
||||
if (title != null && title.length() > 0) {
|
||||
fullTitle.append(title);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final class ChangeAnchorAction extends AnAction implements DumbAware {
|
||||
private final ToolWindowAnchor myAnchor;
|
||||
|
||||
@@ -816,22 +753,6 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronizes decorator with IdeToolWindow changes.
|
||||
*/
|
||||
private final class ToolWindowHandler implements PropertyChangeListener {
|
||||
@Override
|
||||
public final void propertyChange(final PropertyChangeEvent e) {
|
||||
final String name = e.getPropertyName();
|
||||
if (ToolWindowEx.PROP_TITLE.equals(name)) {
|
||||
updateTitle();
|
||||
if (myHeader != null) {
|
||||
myHeader.repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putInfo(@NotNull Map<String, String> info) {
|
||||
info.put("toolWindowTitle", myToolWindow.getTitle());
|
||||
|
||||
@@ -323,7 +323,7 @@ public final class StripeButton extends AnchoredButton implements ActionListener
|
||||
* and short cut registered in the key map.
|
||||
*/
|
||||
void updateText() {
|
||||
final String toolWindowId = getWindowInfo().getId();
|
||||
String toolWindowId = myDecorator.getToolWindow().getTitle();
|
||||
String text = toolWindowId;
|
||||
if (UISettings.getInstance().SHOW_TOOL_WINDOW_NUMBERS) {
|
||||
final int mnemonic = ActivateToolWindowAction.getMnemonicForToolWindow(toolWindowId);
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.intellij.ui.content.Content;
|
||||
import com.intellij.ui.content.ContentFactory;
|
||||
import com.intellij.ui.content.ContentManager;
|
||||
import com.intellij.ui.content.impl.ContentImpl;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.ui.update.Activatable;
|
||||
import com.intellij.util.ui.update.UiNotifyConnector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -59,7 +60,8 @@ public final class ToolWindowImpl implements ToolWindowEx {
|
||||
private final JComponent myComponent;
|
||||
private boolean myAvailable;
|
||||
private final ContentManager myContentManager;
|
||||
private Icon myIcon = null;
|
||||
private Icon myIcon;
|
||||
private String myTitle;
|
||||
|
||||
private static final Content EMPTY_CONTENT = new ContentImpl(new JLabel(), "", false);
|
||||
private final ToolWindowContentUi myContentUI;
|
||||
@@ -342,7 +344,7 @@ public final class ToolWindowImpl implements ToolWindowEx {
|
||||
|
||||
public final String getTitle() {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
return getSelectedContent().getDisplayName();
|
||||
return ObjectUtils.notNull(myTitle, myId);
|
||||
}
|
||||
|
||||
public final void setIcon(final Icon icon) {
|
||||
@@ -356,10 +358,10 @@ public final class ToolWindowImpl implements ToolWindowEx {
|
||||
myChangeSupport.firePropertyChange(PROP_ICON, oldIcon, icon);
|
||||
}
|
||||
|
||||
public final void setTitle(final String title) {
|
||||
public final void setTitle(String title) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
final String oldTitle = getTitle();
|
||||
getSelectedContent().setDisplayName(title);
|
||||
myTitle = title;
|
||||
myChangeSupport.firePropertyChange(PROP_TITLE, oldTitle, title);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ import com.intellij.ui.switcher.QuickAccessSettings;
|
||||
import com.intellij.ui.switcher.SwitchManager;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import com.intellij.util.IJSwingUtilities;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
@@ -69,7 +70,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.EventListenerList;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
import java.awt.*;
|
||||
@@ -89,7 +89,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
|
||||
private final Project myProject;
|
||||
private final WindowManagerEx myWindowManager;
|
||||
private final EventListenerList myListenerList;
|
||||
private final EventDispatcher<ToolWindowManagerListener> myDispatcher = EventDispatcher.create(ToolWindowManagerListener.class);
|
||||
private final DesktopLayout myLayout;
|
||||
private final Map<String, InternalDecorator> myId2InternalDecorator;
|
||||
private final Map<String, FloatingDecorator> myId2FloatingDecorator;
|
||||
@@ -163,7 +163,6 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
myWindowManager = windowManagerEx;
|
||||
myFileEditorManager = fem;
|
||||
myLafManager = lafManager;
|
||||
myListenerList = new EventListenerList();
|
||||
|
||||
if (!project.isDefault()) {
|
||||
actionManager.addAnActionListener(new AnActionListener() {
|
||||
@@ -570,13 +569,13 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToolWindowManagerListener(@NotNull final ToolWindowManagerListener l) {
|
||||
myListenerList.add(ToolWindowManagerListener.class, l);
|
||||
public void addToolWindowManagerListener(@NotNull ToolWindowManagerListener l) {
|
||||
myDispatcher.addListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeToolWindowManagerListener(@NotNull final ToolWindowManagerListener l) {
|
||||
myListenerList.remove(ToolWindowManagerListener.class, l);
|
||||
public void removeToolWindowManagerListener(@NotNull ToolWindowManagerListener l) {
|
||||
myDispatcher.addListener(l);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1662,17 +1661,11 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
}
|
||||
|
||||
private void fireToolWindowRegistered(final String id) {
|
||||
final ToolWindowManagerListener[] listeners = myListenerList.getListeners(ToolWindowManagerListener.class);
|
||||
for (ToolWindowManagerListener listener : listeners) {
|
||||
listener.toolWindowRegistered(id);
|
||||
}
|
||||
myDispatcher.getMulticaster().toolWindowRegistered(id);
|
||||
}
|
||||
|
||||
private void fireStateChanged() {
|
||||
final ToolWindowManagerListener[] listeners = myListenerList.getListeners(ToolWindowManagerListener.class);
|
||||
for (ToolWindowManagerListener listener : listeners) {
|
||||
listener.stateChanged();
|
||||
}
|
||||
myDispatcher.getMulticaster().stateChanged();
|
||||
}
|
||||
|
||||
boolean isToolWindowActive(final String id) {
|
||||
|
||||
@@ -71,7 +71,7 @@ abstract class ContentLayout {
|
||||
public abstract boolean shouldDrawDecorations();
|
||||
|
||||
protected void updateIdLabel(BaseLabel label) {
|
||||
label.setText(myUi.myWindow.getId() + (shouldDrawDecorations() ? ":" : ""));
|
||||
label.setText(myUi.myWindow.getTitle() + (shouldDrawDecorations() ? ":" : ""));
|
||||
label.setBorder(new EmptyBorder(0, 2, 0, 8));
|
||||
|
||||
if (myUi.myManager.getContentCount() == 1) {
|
||||
|
||||
+13
-5
@@ -15,16 +15,18 @@
|
||||
*/
|
||||
package com.siyeh.ig.dataflow;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightControlFlowUtil;
|
||||
import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.DefaultJDOMExternalizer;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.xmlb.XmlSerializer;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
@@ -162,11 +164,17 @@ public class UnnecessaryLocalVariableInspectionBase extends BaseInspection {
|
||||
VariableAccessUtils.variableIsAssigned(initialization, containingScope, false)) {
|
||||
return false;
|
||||
}
|
||||
if (!initialization.hasModifierProperty(PsiModifier.FINAL) && variable.hasModifierProperty(PsiModifier.FINAL)) {
|
||||
if (VariableAccessUtils.variableIsUsedInInnerClass(variable, containingScope)) {
|
||||
return false;
|
||||
|
||||
if (!initialization.hasModifierProperty(PsiModifier.FINAL) && variable.hasModifierProperty(PsiModifier.FINAL) ||
|
||||
PsiUtil.isLanguageLevel8OrHigher(initialization) && !HighlightControlFlowUtil.isEffectivelyFinal(initialization, containingScope, null) && HighlightControlFlowUtil.isEffectivelyFinal(variable, containingScope, null)) {
|
||||
for (PsiReference ref : ReferencesSearch.search(variable, new LocalSearchScope(containingScope))) {
|
||||
final PsiElement element = PsiTreeUtil.getParentOfType(ref.getElement(), PsiClass.class, PsiLambdaExpression.class);
|
||||
if (element != null && PsiTreeUtil.isAncestor(containingScope, element, true)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return !TypeConversionUtil.boxingConversionApplicable(variable.getType(), initialization.getType());
|
||||
}
|
||||
|
||||
|
||||
+30
-10
@@ -17,6 +17,7 @@ package com.siyeh.ig.visibility;
|
||||
|
||||
import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
@@ -85,18 +86,36 @@ public class MethodOverloadsParentMethodInspectionBase extends BaseInspection {
|
||||
if (MethodUtils.hasSuper(method)) {
|
||||
return;
|
||||
}
|
||||
PsiClass ancestorClass = aClass.getSuperClass();
|
||||
final Set<PsiClass> visitedClasses = new HashSet<PsiClass>();
|
||||
while (ancestorClass != null) {
|
||||
if (!visitedClasses.add(ancestorClass)) {
|
||||
return;
|
||||
}
|
||||
if (methodOverloads(method, ancestorClass)) {
|
||||
registerMethodError(method);
|
||||
return;
|
||||
}
|
||||
ancestorClass = ancestorClass.getSuperClass();
|
||||
processSupers(method, aClass, aClass, visitedClasses);
|
||||
}
|
||||
|
||||
private boolean processSupers(final PsiMethod method,
|
||||
final PsiClass psiClass,
|
||||
final PsiClass initialClass,
|
||||
final Set<PsiClass> visitedClasses) {
|
||||
if (!visitedClasses.add(psiClass)) {
|
||||
return false;
|
||||
}
|
||||
if (initialClass != psiClass && methodOverloads(method, psiClass)) {
|
||||
registerMethodError(method);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if (PsiUtil.isLanguageLevel8OrHigher(method)) {
|
||||
for (PsiClass superClass : psiClass.getSupers()) {
|
||||
if (processSupers(method, superClass, initialClass, visitedClasses)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
final PsiClass superClass = psiClass.getSuperClass();
|
||||
if (superClass != null) {
|
||||
return processSupers(method, superClass, initialClass, visitedClasses);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean methodOverloads(PsiMethod method, PsiClass ancestorClass) {
|
||||
@@ -107,6 +126,7 @@ public class MethodOverloadsParentMethodInspectionBase extends BaseInspection {
|
||||
for (final PsiMethod testMethod : methods) {
|
||||
if (!testMethod.hasModifierProperty(PsiModifier.PRIVATE) &&
|
||||
!testMethod.hasModifierProperty(PsiModifier.STATIC) &&
|
||||
!testMethod.hasModifierProperty(PsiModifier.ABSTRACT) &&
|
||||
!isOverriddenInClass(testMethod, method.getContainingClass())) {
|
||||
final PsiParameterList testParameterList = testMethod.getParameterList();
|
||||
final PsiParameter[] testParameters = testParameterList.getParameters();
|
||||
|
||||
+11
@@ -115,4 +115,15 @@ class C {
|
||||
System.out.println(k);
|
||||
}
|
||||
|
||||
void usedIn8Inner(int j) {
|
||||
for (int i = 0; i < 7; i++) {
|
||||
int k = i;
|
||||
int n = j;
|
||||
class F {
|
||||
{
|
||||
System.out.println(k + n);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
@@ -119,4 +119,10 @@
|
||||
<description>Local variable <code>k</code> is redundant #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>C.java</file>
|
||||
<line>121</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Redundant local variable</problem_class>
|
||||
<description>Local variable <code>n</code> is redundant #loc</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+21
@@ -24,4 +24,25 @@ class Parent {
|
||||
Object bla(double d) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class DefaultMethod {
|
||||
public static interface IFoo {
|
||||
default void foo(int i) {
|
||||
System.out.println("IFoo.foo(int): " + i);
|
||||
}
|
||||
|
||||
void bar(int i);
|
||||
|
||||
}
|
||||
|
||||
public static class Foo implements IFoo {
|
||||
public void foo(long l) {
|
||||
System.out.println("Foo.foo(long): " + l);
|
||||
}
|
||||
|
||||
public void bar(long l) {
|
||||
System.out.println("Foo.bar(long): " + l);
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
@@ -21,4 +21,11 @@
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Method overloads method of superclass</problem_class>
|
||||
<description>Method <code>bla()</code> overloads a compatible method of a superclass, when overriding might have been intended #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>MethodOverloadsParentMethod.java</file>
|
||||
<line>40</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Method overloads method of superclass</problem_class>
|
||||
<description>Method <code>foo()</code> overloads a compatible method of a superclass, when overriding might have been intended #loc</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+3
-4
@@ -15,18 +15,17 @@
|
||||
*/
|
||||
package com.siyeh.ig.dataflow;
|
||||
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.siyeh.ig.IGInspectionTestCase;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.siyeh.ig.IGInspectionTestCase;
|
||||
|
||||
public class UnnecessaryLocalVariableInspectionTest extends IGInspectionTestCase {
|
||||
@Override
|
||||
protected Sdk getTestProjectSdk() {
|
||||
final Sdk sdk = IdeaTestUtil.getMockJdk17();
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_7);
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.HIGHEST);
|
||||
return sdk;
|
||||
}
|
||||
|
||||
|
||||
+12
@@ -1,5 +1,9 @@
|
||||
package com.siyeh.ig.visibility;
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.siyeh.ig.IGInspectionTestCase;
|
||||
|
||||
public class MethodOverloadsParentMethodInspectionTest extends IGInspectionTestCase {
|
||||
@@ -7,4 +11,12 @@ public class MethodOverloadsParentMethodInspectionTest extends IGInspectionTestC
|
||||
public void test() throws Exception {
|
||||
doTest("com/siyeh/igtest/visibility/method_overloads_parent_method", new MethodOverloadsParentMethodInspection());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getTestProjectSdk() {
|
||||
final Sdk sdk = IdeaTestUtil.getMockJdk17();
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.HIGHEST);
|
||||
return sdk;
|
||||
}
|
||||
|
||||
}
|
||||
+7
-8
@@ -20,27 +20,21 @@
|
||||
*/
|
||||
package com.theoryinpractice.testng.configuration;
|
||||
|
||||
import com.intellij.execution.JavaRunConfigurationExtensionManager;
|
||||
import com.intellij.execution.Location;
|
||||
import com.intellij.execution.PsiLocation;
|
||||
import com.intellij.execution.RunnerAndConfigurationSettings;
|
||||
import com.intellij.execution.actions.ConfigurationContext;
|
||||
import com.intellij.execution.actions.ConfigurationFromContext;
|
||||
import com.intellij.execution.junit.InheritorChooser;
|
||||
import com.intellij.execution.junit.JUnitUtil;
|
||||
import com.intellij.execution.junit.JavaRuntimeConfigurationProducerBase;
|
||||
import com.intellij.execution.junit2.info.LocationUtil;
|
||||
import com.intellij.execution.junit2.info.MethodLocation;
|
||||
import com.intellij.openapi.actionSystem.LangDataKeys;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiClassUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.theoryinpractice.testng.model.TestData;
|
||||
import com.theoryinpractice.testng.util.TestNGUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -88,7 +82,12 @@ public class TestNGInClassConfigurationProducer extends TestNGConfigurationProdu
|
||||
super.runForClass(aClass, psiMethod, context, performRunnable);
|
||||
}
|
||||
};
|
||||
if (inheritorChooser.runMethodInAbstractClass(fromContext, performRunnable, psiMethod, containingClass)) return;
|
||||
if (inheritorChooser.runMethodInAbstractClass(fromContext, performRunnable, psiMethod, containingClass, new Condition<PsiClass>() {
|
||||
@Override
|
||||
public boolean value(PsiClass aClass) {
|
||||
return TestNGUtil.hasTest(aClass);
|
||||
}
|
||||
})) return;
|
||||
}
|
||||
super.onFirstRun(configuration, fromContext, performRunnable);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user