Merge remote-tracking branch 'origin/master'

This commit is contained in:
Yann Cebron
2011-09-23 22:10:13 +02:00
25 changed files with 131 additions and 63 deletions
+3 -2
View File
@@ -1,11 +1,12 @@
<component name="libraryTable">
<library name="CGLIB">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/cglib-2.2.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/cglib-2.2.2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/lib/src/cglib-src-2.2.jar!/src/proxy" />
<root url="jar://$PROJECT_DIR$/lib/src/cglib-src-2.2.2.jar!/src/proxy" />
<root url="jar://$PROJECT_DIR$/lib/src/cglib-src-2.2.2.jar!/src/test" />
</SOURCES>
</library>
</component>
+1 -1
View File
@@ -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/")
@@ -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;
@@ -0,0 +1,5 @@
class Super {
void foo(String[] params, int... indices) {
foo(new String[<caret>], 0);
}
}
@@ -0,0 +1,5 @@
class Super {
void foo(String[] params, int... indices) {
foo(new <caret>, 0);
}
}
@@ -2,7 +2,7 @@ class Foooo {
int bar(int a, Object... varargs) {}
int foo() {
bar(hashCode())<caret>;
bar(hashCode()<caret>);
}
}
@@ -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(); }
Binary file not shown.
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -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
@@ -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
@@ -72,7 +72,7 @@ public class FavoritesPanel {
}
private void setupDnD() {
DnDSupport.createBuilder(myTree)
DnDSupport.createBuilder(myViewPanel)
.setBeanProvider(new Function<DnDActionInfo, DnDDragStartBean>() {
@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();
}
}
@@ -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);
}
@@ -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<VirtualFile> virtualFileProcessor = new ReadActionProcessor<VirtualFile>() {
@Override
@@ -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<VirtualFile, RequestWithProcessor> collectFiles(MultiMap<Set<IdIndexEntry>, RequestWithProcessor> singles,
ProgressIndicator progress) {
final ProjectFileIndex index = ProjectRootManager.getInstance(myManager.getProject()).getFileIndex();
final FileIndexFacade index = FileIndexFacade.getInstance(myManager.getProject());
final MultiMap<VirtualFile, RequestWithProcessor> result = createMultiMap();
for (Set<IdIndexEntry> key : singles.keySet()) {
if (key.isEmpty()) {
@@ -707,7 +706,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
}
private static MultiMap<VirtualFile, RequestWithProcessor> findFilesWithIndexEntry(final IdIndexEntry entry,
final ProjectFileIndex index,
final FileIndexFacade index,
final Collection<RequestWithProcessor> data,
final GlobalSearchScope commonScope,
final ProgressIndicator progress) {
@@ -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 &&
@@ -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;
}
@@ -1349,6 +1349,7 @@ literal.as.arg.to.string.equals.problem.descriptor=<code>#ref</code> 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
@@ -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);
}
}
@@ -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;
}
@@ -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;
}
}
}
@@ -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);
}
}
}
@@ -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 =
@@ -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);