diff --git a/.idea/libraries/CGLIB.xml b/.idea/libraries/CGLIB.xml index 4b574fe43b94..23bbd886aca8 100644 --- a/.idea/libraries/CGLIB.xml +++ b/.idea/libraries/CGLIB.xml @@ -1,11 +1,12 @@ - + - + + \ No newline at end of file diff --git a/build/scripts/libLicenses.gant b/build/scripts/libLicenses.gant index cd0eca57fecf..28f31f83e692 100644 --- a/build/scripts/libLicenses.gant +++ b/build/scripts/libLicenses.gant @@ -154,7 +154,7 @@ libraryLicense(name: "Alloy L&F", libraryName: "alloy.jar", version: "1.4.4", li libraryLicense(name: "Ant", version: "1.7", license: "Apache 2.0", url: "http://ant.apache.org/", licenseUrl: "http://ant.apache.org/license.html") libraryLicense(name: "ASM Bytecode Manipulation Framework", libraryName: "asm", version: "3.3", license: "BSD", url: "http://asm.objectweb.org/", licenseUrl: "http://asm.objectweb.org/license.html") libraryLicense(name: "Axis", libraryName: "axis-1.4", version: "1.4", license: "Apache 2.0", url: "http://ws.apache.org/axis/", licenseUrl: "http://svn.jetbrains.org/idea/Trunk/bundled/WebServices/resources/lib/axis-1.4.0/axis.LICENSE") -libraryLicense(name: "CGLib", libraryName: "CGLIB", version: "2.2", license: "Apache", url: "http://cglib.sourceforge.net/", licenseUrl: "http://www.apache.org/foundation/licence-FAQ.html") +libraryLicense(name: "CGLib", libraryName: "CGLIB", version: "2.2.2", license: "Apache", url: "http://cglib.sourceforge.net/", licenseUrl: "http://www.apache.org/foundation/licence-FAQ.html") libraryLicense(name: "classworlds", libraryName: "classworlds-1.1.jar", version: "1.1", license: "codehaus", url: "http://classworlds.codehaus.org/", licenseUrl: "http://classworlds.codehaus.org/license.html") libraryLicense(name: "Android SDK Tools", libraryName: "android-sdk-tools", license: "Apache 2.0", url: "http://source.android.com/") libraryLicense(name: "Apache Commons BeanUtils", libraryName: "commons-beanutils.jar", version: "1.6", license: "Apache 2.0", url: "http://commons.apache.org/beanutils/") diff --git a/java/java-impl/src/com/intellij/codeInsight/ExpectedTypesProvider.java b/java/java-impl/src/com/intellij/codeInsight/ExpectedTypesProvider.java index 52ab4e3d7da2..0ab601395ec0 100644 --- a/java/java-impl/src/com/intellij/codeInsight/ExpectedTypesProvider.java +++ b/java/java-impl/src/com/intellij/codeInsight/ExpectedTypesProvider.java @@ -959,11 +959,10 @@ public class ExpectedTypesProvider { private static TailType getMethodArgumentTailType(final PsiExpression argument, final int index, final PsiMethod method, final PsiSubstitutor substitutor, final PsiParameter[] params) { - if (index >= params.length) { + if (index >= params.length || index == params.length - 2 && params[index + 1].isVarArgs()) { return TailType.NONE; } - if (index == params.length - 1 || index == params.length - 2 && params[index + 1].isVarArgs()) { - //myTailType = CompletionUtil.NONE_TAIL; + if (index == params.length - 1) { final PsiElement call = argument.getParent().getParent(); if (call instanceof JspMethodCall) return TailType.NONE; diff --git a/java/java-tests/testData/codeInsight/completion/smartType/ArrayInitializerBeforeVarargs-out.java b/java/java-tests/testData/codeInsight/completion/smartType/ArrayInitializerBeforeVarargs-out.java new file mode 100644 index 000000000000..49ce3eb54d4b --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/smartType/ArrayInitializerBeforeVarargs-out.java @@ -0,0 +1,5 @@ +class Super { + void foo(String[] params, int... indices) { + foo(new String[], 0); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/smartType/ArrayInitializerBeforeVarargs.java b/java/java-tests/testData/codeInsight/completion/smartType/ArrayInitializerBeforeVarargs.java new file mode 100644 index 000000000000..a783d14851e4 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/smartType/ArrayInitializerBeforeVarargs.java @@ -0,0 +1,5 @@ +class Super { + void foo(String[] params, int... indices) { + foo(new , 0); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/smartType/NoCommaBeforeVarargs-out.java b/java/java-tests/testData/codeInsight/completion/smartType/NoCommaBeforeVarargs-out.java index 3d0404d5ba78..ff7e54e5bd0e 100644 --- a/java/java-tests/testData/codeInsight/completion/smartType/NoCommaBeforeVarargs-out.java +++ b/java/java-tests/testData/codeInsight/completion/smartType/NoCommaBeforeVarargs-out.java @@ -2,7 +2,7 @@ class Foooo { int bar(int a, Object... varargs) {} int foo() { - bar(hashCode()); + bar(hashCode()); } } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionTest.java index 782412884087..6503a6fcd151 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartTypeCompletionTest.java @@ -1010,6 +1010,7 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase { doItemTest(); } + public void testArrayInitializerBeforeVarargs() throws Throwable { doTest(); } public void testInheritorMembers() throws Throwable { doTest(); } public void testInheritorEnumMembers() throws Throwable { doTest(); } public void testDuplicateMembersFromSuperClass() throws Throwable { doTest(); } diff --git a/lib/cglib-2.2.2.jar b/lib/cglib-2.2.2.jar new file mode 100644 index 000000000000..564b9f8834e3 Binary files /dev/null and b/lib/cglib-2.2.2.jar differ diff --git a/lib/cglib-2.2.jar b/lib/cglib-2.2.jar deleted file mode 100644 index 084ef6e54b51..000000000000 Binary files a/lib/cglib-2.2.jar and /dev/null differ diff --git a/lib/required_for_dist.txt b/lib/required_for_dist.txt index 6dd33f7bcbf9..ac2d8cf57f82 100644 --- a/lib/required_for_dist.txt +++ b/lib/required_for_dist.txt @@ -2,7 +2,7 @@ asm-commons.jar asm.jar automaton.jar cli-10.jar -cglib-2.2.jar +cglib-2.2.2.jar commons-codec-1.3.jar commons-collections.jar commons-httpclient-3.1-patched.jar diff --git a/lib/src/cglib-src-2.2.jar b/lib/src/cglib-src-2.2.2.jar similarity index 88% rename from lib/src/cglib-src-2.2.jar rename to lib/src/cglib-src-2.2.2.jar index 4a32ba9861ef..ef9a73a672ef 100644 Binary files a/lib/src/cglib-src-2.2.jar and b/lib/src/cglib-src-2.2.2.jar differ diff --git a/platform/core-api/src/com/intellij/openapi/roots/FileIndexFacade.java b/platform/core-api/src/com/intellij/openapi/roots/FileIndexFacade.java index e4250e898e4b..598954811b6a 100644 --- a/platform/core-api/src/com/intellij/openapi/roots/FileIndexFacade.java +++ b/platform/core-api/src/com/intellij/openapi/roots/FileIndexFacade.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.roots; +import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; @@ -30,9 +31,14 @@ public abstract class FileIndexFacade { myProject = project; } + public static FileIndexFacade getInstance(Project project) { + return ServiceManager.getService(project, FileIndexFacade.class); + } + public abstract boolean isInContent(VirtualFile file); public abstract boolean isInSource(VirtualFile file); public abstract boolean isInLibraryClasses(VirtualFile file); + public abstract boolean isInLibrarySource(VirtualFile file); public abstract boolean isExcludedFile(VirtualFile file); @Nullable diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesPanel.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesPanel.java index ced0a9ca0ae0..76fff16831f6 100644 --- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesPanel.java +++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesPanel.java @@ -72,7 +72,7 @@ public class FavoritesPanel { } private void setupDnD() { - DnDSupport.createBuilder(myTree) + DnDSupport.createBuilder(myViewPanel) .setBeanProvider(new Function() { @Override public DnDDragStartBean fun(DnDActionInfo dnDActionInfo) { @@ -82,11 +82,10 @@ public class FavoritesPanel { .setTargetChecker(new DnDTargetChecker() { @Override public boolean update(DnDEvent event) { - final Point p = event.getPoint(); - + final Point p = SwingUtilities.convertPoint(myViewPanel, event.getPoint(), myTree); FavoritesListNode node = findFavoritesListNode(p); if (node != null) { - TreePath pathToList = myTree.getPathForLocation(p.x, p.y); + TreePath pathToList = myTree.getPath(node); while (pathToList != null) { final Object pathObj = pathToList.getLastPathComponent(); if (pathObj instanceof DefaultMutableTreeNode) { @@ -144,6 +143,6 @@ public class FavoritesPanel { } } } - return null; + return (FavoritesListNode)((FavoritesRootNode)myTreeStructure.getRootElement()).getChildren().iterator().next(); } } diff --git a/platform/lang-impl/src/com/intellij/openapi/vcs/impl/ProjectFileIndexFacade.java b/platform/lang-impl/src/com/intellij/openapi/vcs/impl/ProjectFileIndexFacade.java index 9928dc2a960a..bef825a4f88e 100644 --- a/platform/lang-impl/src/com/intellij/openapi/vcs/impl/ProjectFileIndexFacade.java +++ b/platform/lang-impl/src/com/intellij/openapi/vcs/impl/ProjectFileIndexFacade.java @@ -51,6 +51,11 @@ public class ProjectFileIndexFacade extends FileIndexFacade { return myRootManager.getFileIndex().isInLibraryClasses(file); } + @Override + public boolean isInLibrarySource(VirtualFile file) { + return myRootManager.getFileIndex().isInLibrarySource(file); + } + public boolean isExcludedFile(final VirtualFile file) { return myRootManager.getFileIndex().isIgnored(file); } diff --git a/platform/lang-impl/src/com/intellij/psi/impl/cache/impl/IndexCacheManagerImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/cache/impl/IndexCacheManagerImpl.java index ced908fd080c..1801359bd76c 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/cache/impl/IndexCacheManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/cache/impl/IndexCacheManagerImpl.java @@ -24,6 +24,7 @@ import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.FileIndexFacade; import com.intellij.openapi.roots.ProjectFileIndex; import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.vfs.VirtualFile; @@ -72,7 +73,7 @@ public class IndexCacheManagerImpl implements CacheManager{ return processor.getResults().isEmpty() ? PsiFile.EMPTY_ARRAY : processor.toArray(PsiFile.EMPTY_ARRAY); } - public static boolean shouldBeFound(GlobalSearchScope scope, VirtualFile virtualFile, ProjectFileIndex index) { + public static boolean shouldBeFound(GlobalSearchScope scope, VirtualFile virtualFile, FileIndexFacade index) { return (scope.isSearchOutsideRootModel() || index.isInContent(virtualFile) || index.isInLibrarySource(virtualFile)) && !virtualFile.getFileType().isBinary(); } @@ -104,7 +105,7 @@ public class IndexCacheManagerImpl implements CacheManager{ if (vFiles.isEmpty()) return true; - final ProjectFileIndex index = ProjectRootManager.getInstance(myProject).getFileIndex(); + final FileIndexFacade index = FileIndexFacade.getInstance(myProject); final Processor virtualFileProcessor = new ReadActionProcessor() { @Override diff --git a/platform/lang-impl/src/com/intellij/psi/impl/search/PsiSearchHelperImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/search/PsiSearchHelperImpl.java index 3812fabe709f..d96b223146f6 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/search/PsiSearchHelperImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/search/PsiSearchHelperImpl.java @@ -26,8 +26,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; -import com.intellij.openapi.roots.ProjectFileIndex; -import com.intellij.openapi.roots.ProjectRootManager; +import com.intellij.openapi.roots.FileIndexFacade; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.TextRange; @@ -656,7 +655,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper { private MultiMap collectFiles(MultiMap, RequestWithProcessor> singles, ProgressIndicator progress) { - final ProjectFileIndex index = ProjectRootManager.getInstance(myManager.getProject()).getFileIndex(); + final FileIndexFacade index = FileIndexFacade.getInstance(myManager.getProject()); final MultiMap result = createMultiMap(); for (Set key : singles.keySet()) { if (key.isEmpty()) { @@ -707,7 +706,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper { } private static MultiMap findFilesWithIndexEntry(final IdIndexEntry entry, - final ProjectFileIndex index, + final FileIndexFacade index, final Collection data, final GlobalSearchScope commonScope, final ProgressIndicator progress) { diff --git a/platform/platform-impl/src/net/sf/cglib/proxy/AdvancedEnhancer.java b/platform/platform-impl/src/net/sf/cglib/proxy/AdvancedEnhancer.java index 666bec9f3783..7f77a0a50018 100644 --- a/platform/platform-impl/src/net/sf/cglib/proxy/AdvancedEnhancer.java +++ b/platform/platform-impl/src/net/sf/cglib/proxy/AdvancedEnhancer.java @@ -989,6 +989,12 @@ public class AdvancedEnhancer extends AbstractClassGenerator public Signature getImplSignature(MethodInfo method) { return rename(method.getSignature(), (Integer)positions.get(method)); } + + @Override + public void emitInvoke(CodeEmitter codeEmitter, MethodInfo methodInfo) { + codeEmitter.super_invoke(methodInfo.getSignature()); + } + public CodeEmitter beginMethod(ClassEmitter ce, MethodInfo method) { CodeEmitter e = EmitUtils.begin_method(ce, method); if (!interceptDuringConstruction && diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/DefaultFileIndexFacade.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/DefaultFileIndexFacade.java index 97c05132e651..e5b40d5e0cf2 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/DefaultFileIndexFacade.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/DefaultFileIndexFacade.java @@ -49,6 +49,11 @@ public class DefaultFileIndexFacade extends FileIndexFacade { return false; } + @Override + public boolean isInLibrarySource(VirtualFile file) { + return false; + } + public boolean isExcludedFile(final VirtualFile file) { return false; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties index d310a55f8a0e..d0ef95489ab5 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties +++ b/plugins/InspectionGadgets/src/com/siyeh/InspectionGadgetsBundle.properties @@ -1349,6 +1349,7 @@ literal.as.arg.to.string.equals.problem.descriptor=#ref is argument literal.as.arg.to.string.equals.flip.quickfix=Flip 'equals()' c.style.array.declaration.replace.quickfix=Replace with Java-style array declaration chained.method.call.ignore.option=Ignore chained method calls in field initializers +chained.method.call.ignore.this.super.option=Ignore chained method calls in this() and super() calls introduce.variable.quickfix=Introduce variable flip.comparison.quickfix=Flip comparison control.flow.statement.without.braces.add.quickfix=Add braces diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/ExpressionUtils.java b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/ExpressionUtils.java index 186fd4e8d70f..e12bc1d83a82 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/ExpressionUtils.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/ExpressionUtils.java @@ -418,4 +418,18 @@ public class ExpressionUtils { } return false; } + + + public static boolean isConstructorInvocation(PsiElement element) { + if (!(element instanceof PsiMethodCallExpression)) { + return false; + } + final PsiMethodCallExpression methodCallExpression = + (PsiMethodCallExpression)element; + final PsiReferenceExpression methodExpression = + methodCallExpression.getMethodExpression(); + final String callName = methodExpression.getReferenceName(); + return PsiKeyword.THIS.equals(callName) || + PsiKeyword.SUPER.equals(callName); + } } \ No newline at end of file diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/FinalUtils.java b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/FinalUtils.java index 7089c78c675f..047cc4de256a 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/FinalUtils.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/FinalUtils.java @@ -569,7 +569,7 @@ public class FinalUtils { } @NonNls final String referenceName = methodExpression.getReferenceName(); - if ("this".equals(referenceName)) { + if (PsiKeyword.THIS.equals(referenceName)) { definitelyUnassigned = false; definitelyAssigned = true; } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/style/ChainedMethodCallInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/style/ChainedMethodCallInspection.java index 0edf257bceed..7bbf1813a1ec 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/style/ChainedMethodCallInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/style/ChainedMethodCallInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ package com.siyeh.ig.style; import com.intellij.codeInspection.ProblemDescriptor; -import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel; +import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel; import com.intellij.ide.DataManager; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.application.ApplicationManager; @@ -29,6 +29,7 @@ import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; import com.siyeh.ig.InspectionGadgetsFix; +import com.siyeh.ig.psiutils.ExpressionUtils; import com.siyeh.ig.psiutils.ParenthesesUtils; import org.jetbrains.annotations.NotNull; @@ -36,36 +37,50 @@ import javax.swing.*; public class ChainedMethodCallInspection extends BaseInspection { - /** @noinspection PublicField */ + @SuppressWarnings("PublicField") public boolean m_ignoreFieldInitializations = true; + @SuppressWarnings("PublicField") + public boolean m_ignoreThisSuperCalls = true; + + @Override @NotNull public String getDisplayName() { return InspectionGadgetsBundle.message( "chained.method.call.display.name"); } + @Override @NotNull protected String buildErrorString(Object... infos) { return InspectionGadgetsBundle.message( "chained.method.call.problem.descriptor"); } + @Override public JComponent createOptionsPanel() { - return new SingleCheckboxOptionsPanel( - InspectionGadgetsBundle.message( - "chained.method.call.ignore.option"), - this, "m_ignoreFieldInitializations"); + final MultipleCheckboxOptionsPanel panel = + new MultipleCheckboxOptionsPanel(this); + panel.addCheckbox(InspectionGadgetsBundle.message( + "chained.method.call.ignore.option"), + "m_ignoreFieldInitializations"); + panel.addCheckbox(InspectionGadgetsBundle.message( + "chained.method.call.ignore.this.super.option"), + "m_ignoreThisSuperCalls"); + return panel; } + @Override protected boolean buildQuickFixesOnlyForOnTheFlyErrors() { return true; } + @Override public BaseInspectionVisitor buildVisitor() { return new ChainedMethodCallVisitor(); } + @Override protected InspectionGadgetsFix buildFix(Object... infos) { return new ChainedMethodCallFix(); } @@ -78,6 +93,7 @@ public class ChainedMethodCallInspection extends BaseInspection { "introduce.variable.quickfix"); } + @Override public void doFix(final Project project, ProblemDescriptor descriptor) { final JavaRefactoringActionHandlerFactory factory = JavaRefactoringActionHandlerFactory.getInstance(); @@ -92,16 +108,17 @@ public class ChainedMethodCallInspection extends BaseInspection { final DataManager dataManager = DataManager.getInstance(); final DataContext dataContext = dataManager.getDataContext(); final Runnable runnable = new Runnable() { - public void run() { - introduceHandler.invoke(project, new PsiElement[]{qualifier}, - dataContext); - } + public void run() { + introduceHandler.invoke(project, + new PsiElement[]{qualifier}, dataContext); + } }; if (ApplicationManager.getApplication().isUnitTestMode()) { - runnable.run(); + runnable.run(); } else { - ApplicationManager.getApplication().invokeLater(runnable, project.getDisposed()); + ApplicationManager.getApplication().invokeLater(runnable, + project.getDisposed()); } } } @@ -127,13 +144,24 @@ public class ChainedMethodCallInspection extends BaseInspection { return; } } + if (m_ignoreThisSuperCalls) { + final PsiExpressionList expressionList = + PsiTreeUtil.getParentOfType(expression, + PsiExpressionList.class); + if (expressionList != null) { + final PsiElement parent = expressionList.getParent(); + if (ExpressionUtils.isConstructorInvocation(parent)) { + return; + } + } + } registerMethodCallError(expression); } private boolean isCallExpression(PsiExpression expression) { expression = ParenthesesUtils.stripParentheses(expression); return expression instanceof PsiMethodCallExpression || - expression instanceof PsiNewExpression; + expression instanceof PsiNewExpression; } } } \ No newline at end of file diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/style/ImplicitCallToSuperInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/style/ImplicitCallToSuperInspection.java index 80557649207e..62c84a810bce 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/style/ImplicitCallToSuperInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/style/ImplicitCallToSuperInspection.java @@ -25,9 +25,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.ExpressionUtils; import org.jetbrains.annotations.NotNull; -import javax.swing.*; +import javax.swing.JComponent; public class ImplicitCallToSuperInspection extends BaseInspection { @@ -145,16 +146,7 @@ public class ImplicitCallToSuperInspection extends BaseInspection { (PsiExpressionStatement)statement; final PsiExpression expression = expressionStatement.getExpression(); - if (!(expression instanceof PsiMethodCallExpression)) { - return false; - } - final PsiMethodCallExpression methodCall = - (PsiMethodCallExpression)expression; - final PsiReferenceExpression methodExpression = - methodCall.getMethodExpression(); - final String text = methodExpression.getText(); - return PsiKeyword.SUPER.equals(text) || - PsiKeyword.THIS.equals(text); + return ExpressionUtils.isConstructorInvocation(expression); } } } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/style/NestedMethodCallInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/style/NestedMethodCallInspection.java index 55773441f9c7..59b671737021 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/style/NestedMethodCallInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/style/NestedMethodCallInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,27 +29,31 @@ import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; import com.siyeh.ig.InspectionGadgetsFix; +import com.siyeh.ig.psiutils.ExpressionUtils; import org.jetbrains.annotations.NotNull; -import javax.swing.*; +import javax.swing.JComponent; public class NestedMethodCallInspection extends BaseInspection { /** @noinspection PublicField */ public boolean m_ignoreFieldInitializations = true; + @Override @NotNull public String getDisplayName() { return InspectionGadgetsBundle.message( "nested.method.call.display.name"); } + @Override @NotNull protected String buildErrorString(Object... infos) { return InspectionGadgetsBundle.message( "nested.method.call.problem.descriptor"); } + @Override public JComponent createOptionsPanel() { return new SingleCheckboxOptionsPanel( InspectionGadgetsBundle.message( @@ -57,26 +61,31 @@ public class NestedMethodCallInspection extends BaseInspection { this, "m_ignoreFieldInitializations"); } + @Override public BaseInspectionVisitor buildVisitor() { return new NestedMethodCallVisitor(); } + @Override protected InspectionGadgetsFix buildFix(Object... infos) { return new NestedMethodCallFix(); } + @Override protected boolean buildQuickFixesOnlyForOnTheFlyErrors() { return true; } private static class NestedMethodCallFix extends InspectionGadgetsFix { + @Override @NotNull public String getName() { return InspectionGadgetsBundle.message( "introduce.variable.quickfix"); } + @Override public void doFix(final Project project, ProblemDescriptor descriptor) { final JavaRefactoringActionHandlerFactory factory = JavaRefactoringActionHandlerFactory.getInstance(); @@ -101,7 +110,8 @@ public class NestedMethodCallInspection extends BaseInspection { runnable.run(); } else { - ApplicationManager.getApplication().invokeLater(runnable, project.getDisposed()); + ApplicationManager.getApplication().invokeLater(runnable, + project.getDisposed()); } } } @@ -127,19 +137,10 @@ public class NestedMethodCallInspection extends BaseInspection { if (!(grandParent instanceof PsiCallExpression)) { return; } - if (grandParent instanceof PsiMethodCallExpression) { - - final PsiMethodCallExpression surroundingCall = - (PsiMethodCallExpression)grandParent; - final PsiReferenceExpression methodExpression = - surroundingCall.getMethodExpression(); - final String callName = methodExpression.getReferenceName(); - if (PsiKeyword.THIS.equals(callName) || - PsiKeyword.SUPER.equals(callName)) { - //ignore nested method calls at the start of a constructor, - //where they can't be extracted - return; - } + if (ExpressionUtils.isConstructorInvocation(grandParent)) { + //ignore nested method calls at the start of a constructor, + //where they can't be extracted + return; } if (m_ignoreFieldInitializations) { final PsiElement field = diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/threading/WaitNotInSynchronizedContextInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/threading/WaitNotInSynchronizedContextInspection.java index 32a3c2c9db2e..bb4c6a862226 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/threading/WaitNotInSynchronizedContextInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/threading/WaitNotInSynchronizedContextInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ public class WaitNotInSynchronizedContextInspection final PsiElement element = (PsiElement)infos[0]; text = element.getText(); } else { - text = "this"; + text = PsiKeyword.THIS; } return InspectionGadgetsBundle.message( "wait.not.in.synchronized.context.problem.descriptor", text);