Merge remote-tracking branch 'origin/master'

This commit is contained in:
Konstantin Bulenkov
2012-09-13 13:13:09 +04:00
69 changed files with 243 additions and 74 deletions
@@ -34,6 +34,7 @@ import com.intellij.psi.impl.source.resolve.FileContextUtil;
import com.intellij.psi.impl.source.tree.JavaElementType;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.PsiModificationTracker;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.ConcurrencyUtil;
import com.intellij.util.Processor;
import com.intellij.util.SmartList;
@@ -333,7 +334,9 @@ public class JavaPsiFacadeImpl extends JavaPsiFacadeEx {
ContainerUtil.quickSort(list, new Comparator<PsiClass>() {
@Override
public int compare(PsiClass o1, PsiClass o2) {
return scope.compare(o2.getContainingFile().getVirtualFile(), o1.getContainingFile().getVirtualFile());
VirtualFile file2 = PsiUtil.getVirtualFile(o2);
VirtualFile file1 = PsiUtil.getVirtualFile(o1);
return scope.compare(file2, file1);
}
});
@@ -299,7 +299,7 @@ public class PsiFieldImpl extends JavaStubPsiElement<PsiFieldStub> implements Ps
if (initializer == null) return null;
}
else{
String initializerText = getInitializerText();
String initializerText = stub.getInitializerText();
if (initializerText == null) return null;
if (PsiFieldStub.INITIALIZER_NOT_STORED.equals(initializerText)) return null;
@@ -25,6 +25,7 @@ import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.testFramework.EditorActionTestCase;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.annotations.NotNull;
/**
* @author max
@@ -274,6 +275,7 @@ public class CompleteStatementTest extends EditorActionTestCase {
return IdeActions.ACTION_EDITOR_COMPLETE_STATEMENT;
}
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -12,6 +12,7 @@ import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.testFramework.LightCodeInsightTestCase;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.annotations.NotNull;
/**
* Created by IntelliJ IDEA.
@@ -29,6 +30,7 @@ public class CompletionStyleTest extends LightCodeInsightTestCase{
return LanguageLevel.JDK_1_6;
}
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -1,6 +1,7 @@
package com.intellij.codeInsight.completion;
import com.intellij.JavaTestUtil;
import org.jetbrains.annotations.NotNull;
/**
* @author Maxim.Mossienko
@@ -8,6 +9,7 @@ import com.intellij.JavaTestUtil;
public class CustomFileTypeCompletionTest extends LightCompletionTestCase {
private static final String BASE_PATH = "/codeInsight/completion/customFileType/";
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -17,12 +17,14 @@ package com.intellij.codeInsight.completion;
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.CodeInsightSettings;
import org.jetbrains.annotations.NotNull;
/**
* @author ik
* Date: 21.01.2003
*/
public class DotCompletionTest extends LightCompletionTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath() + "/codeInsight/completion/dot/";
@@ -18,6 +18,7 @@ package com.intellij.codeInsight.completion;
import com.intellij.JavaTestUtil;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
/**
* @author ik
@@ -33,6 +34,7 @@ public class KeywordCompletionTest extends LightCompletionTestCase {
private static final String[] CLASS_SCOPE_KEYWORDS_2 = new String[]{
"package", "public", "private", "protected", "transient", "volatile", "static", "import", "final", "class", "interface", "abstract"};
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -6,11 +6,13 @@ import com.intellij.codeInspection.javaDoc.JavaDocLocalInspection;
import com.intellij.codeInspection.javaDoc.JavaDocReferenceInspection;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
import org.jetbrains.annotations.NotNull;
public class JavadocHighlightingTest extends LightDaemonAnalyzerTestCase {
private static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/javaDoc";
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -21,8 +21,10 @@
package com.intellij.codeInsight.daemon.quickFix;
import com.intellij.JavaTestUtil;
import org.jetbrains.annotations.NotNull;
public class ReplaceImplementsWithStaticImportTest extends LightQuickFixTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -22,6 +22,7 @@ import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.testFramework.LightCodeInsightTestCase;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.io.Reader;
@@ -34,6 +35,7 @@ import java.io.StringReader;
public class ExternalJavadocPresentationTest extends LightCodeInsightTestCase {
private static final String TEST_ROOT = "/codeInsight/externalJavadoc/";
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -25,8 +25,10 @@ import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
import com.intellij.codeInspection.varScopeCanBeNarrowed.ParameterCanBeLocalInspection;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
public class ConvertParameterToLocalVariableTest extends LightQuickFixTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath() + "/inspection";
@@ -9,8 +9,10 @@ import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
import com.intellij.codeInspection.sameParameterValue.SameParameterValueInspection;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
public class InlineSameParameterValueTest extends LightQuickFixTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath() + "/inspection";
@@ -18,6 +18,7 @@ package com.intellij.refactoring;
import com.intellij.JavaTestUtil;
import com.intellij.refactoring.anonymousToInner.AnonymousToInnerHandler;
import com.intellij.testFramework.LightCodeInsightTestCase;
import org.jetbrains.annotations.NotNull;
/**
* @author yole
@@ -25,6 +26,7 @@ import com.intellij.testFramework.LightCodeInsightTestCase;
public class AnonymousToInnerTest extends LightCodeInsightTestCase {
private static final String TEST_ROOT = "/refactoring/anonymousToInner/";
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -15,6 +15,7 @@ import com.intellij.refactoring.changeSignature.ThrownExceptionInfo;
import com.intellij.refactoring.util.CanonicalTypes;
import com.intellij.util.containers.HashSet;
import junit.framework.Assert;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.Set;
@@ -174,6 +175,7 @@ public class ChangeSignaturePropagationTest extends LightRefactoringTestCase {
return result;
}
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -26,8 +26,10 @@ import com.intellij.psi.PsiMember;
import com.intellij.refactoring.changeSignature.JavaChangeSignatureHandler;
import com.intellij.testFramework.LightCodeInsightTestCase;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
public class ChangeSignatureTargetTest extends LightCodeInsightTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -25,6 +25,7 @@ import com.intellij.refactoring.changeSignature.ThrownExceptionInfo;
import com.intellij.refactoring.util.CanonicalTypes;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashSet;
@@ -446,6 +447,7 @@ public class ChangeSignatureTest extends LightRefactoringTestCase {
}
}
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -22,10 +22,12 @@ package com.intellij.refactoring;
import com.intellij.JavaTestUtil;
import com.intellij.testFramework.LightCodeInsightTestCase;
import org.jetbrains.annotations.NotNull;
public class ExtractMethod15Test extends LightCodeInsightTestCase {
private static final String BASE_PATH = "/refactoring/extractMethod15/";
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -11,8 +11,10 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import com.intellij.refactoring.extractMethodObject.ExtractMethodObjectHandler;
import com.intellij.refactoring.extractMethodObject.ExtractMethodObjectProcessor;
import org.jetbrains.annotations.NotNull;
public class ExtractMethodObjectTest extends LightRefactoringTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -11,8 +11,10 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiExpression;
import com.intellij.refactoring.extractMethodObject.ExtractMethodObjectHandler;
import com.intellij.refactoring.extractMethodObject.ExtractMethodObjectProcessor;
import org.jetbrains.annotations.NotNull;
public class ExtractMethodObjectWithMultipleExitPointsTest extends LightRefactoringTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -32,6 +32,7 @@ import com.intellij.refactoring.util.duplicates.Match;
import com.intellij.testFramework.LightCodeInsightTestCase;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -39,6 +40,7 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
@NonNls private static final String BASE_PATH = "/refactoring/extractMethod/";
private boolean myCatchOnNewLine = true;
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -12,8 +12,10 @@ import com.intellij.psi.PsiMember;
import com.intellij.refactoring.util.duplicates.MethodDuplicatesHandler;
import com.intellij.testFramework.LightCodeInsightTestCase;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
public abstract class FindMethodDuplicatesBaseTest extends LightCodeInsightTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -11,6 +11,7 @@ import com.intellij.testFramework.TestDataPath;
import com.intellij.util.VisibilityUtil;
import junit.framework.Assert;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
/**
* @author ven
@@ -19,6 +20,7 @@ import org.jetbrains.annotations.NonNls;
public class IntroduceConstantTest extends LightCodeInsightTestCase {
@NonNls private static final String BASE_PATH = "/refactoring/introduceConstant/";
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -7,6 +7,7 @@ import com.intellij.psi.PsiType;
import com.intellij.refactoring.introduceField.BaseExpressionToFieldHandler;
import com.intellij.refactoring.util.CommonRefactoringUtil;
import com.intellij.testFramework.LightCodeInsightTestCase;
import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -14,6 +15,7 @@ import java.util.List;
* @author ven
*/
public class IntroduceFieldInSameClassTest extends LightCodeInsightTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -25,12 +25,14 @@ import com.intellij.refactoring.util.occurrences.ExpressionOccurrenceManager;
import com.intellij.testFramework.TestDataPath;
import gnu.trove.TIntArrayList;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
@TestDataPath("$CONTENT_ROOT/testData")
public class IntroduceParameterTest extends LightRefactoringTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -16,6 +16,7 @@ import com.intellij.testFramework.LightCodeInsightTestCase;
import com.intellij.util.containers.MultiMap;
import junit.framework.Assert;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
@@ -24,6 +25,7 @@ import java.util.Collection;
*/
public class IntroduceVariableTest extends LightCodeInsightTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -5,11 +5,13 @@ import com.intellij.codeInsight.TargetElementUtilBase;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNamedElement;
import com.intellij.refactoring.invertBoolean.InvertBooleanProcessor;
import org.jetbrains.annotations.NotNull;
/**
* @author ven
*/
public class InvertBooleanTest extends LightRefactoringTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -13,12 +13,14 @@ import com.intellij.refactoring.makeStatic.MakeClassStaticProcessor;
import com.intellij.refactoring.makeStatic.MakeStaticUtil;
import com.intellij.refactoring.makeStatic.Settings;
import com.intellij.refactoring.util.ParameterTablePanel;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
public class MakeClassStaticTest extends LightRefactoringTestCase {
private static final String TEST_ROOT = "/refactoring/makeClassStatic/";
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -23,10 +23,12 @@ import com.intellij.refactoring.makeStatic.MakeMethodStaticProcessor;
import com.intellij.refactoring.makeStatic.MakeStaticUtil;
import com.intellij.refactoring.makeStatic.Settings;
import com.intellij.refactoring.util.ParameterTablePanel;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
public class MakeMethodStaticTest extends LightRefactoringTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -13,6 +13,7 @@ import com.intellij.refactoring.memberPullUp.PullUpHelper;
import com.intellij.refactoring.util.DocCommentPolicy;
import com.intellij.refactoring.util.classMembers.MemberInfo;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
/**
* @author ven
@@ -161,6 +162,7 @@ public class PullUpTest extends LightRefactoringTestCase {
checkResultByFile(BASE_PATH + getTestName(false) + "_after.java");
}
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -13,11 +13,13 @@ import com.intellij.refactoring.util.classMembers.MemberInfo;
import com.intellij.refactoring.util.classMembers.MemberInfoStorage;
import com.intellij.usageView.UsageInfo;
import com.intellij.util.containers.MultiMap;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
public class PushDownTest extends LightRefactoringTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -7,6 +7,7 @@ import com.intellij.refactoring.rename.RenameProcessor;
import com.intellij.refactoring.rename.RenameUtil;
import com.intellij.refactoring.util.MoveRenameUsageInfo;
import com.intellij.usageView.UsageInfo;
import org.jetbrains.annotations.NotNull;
import org.junit.Assert;
import java.util.HashMap;
@@ -17,6 +18,7 @@ import java.util.HashMap;
public class RenameCollisionsTest extends LightRefactoringTestCase {
private static final String BASE_PATH = "/refactoring/renameCollisions/";
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -32,8 +32,10 @@ import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.refactoring.rename.RenameProcessor;
import com.intellij.refactoring.rename.RenameWrongRefHandler;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
public class RenameFieldTest extends LightRefactoringTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -14,6 +14,7 @@ import com.intellij.refactoring.rename.RenameProcessor;
import com.intellij.refactoring.rename.RenameWrongRefHandler;
import com.intellij.refactoring.rename.inplace.VariableInplaceRenameHandler;
import com.intellij.testFramework.fixtures.CodeInsightTestUtil;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
@@ -23,6 +24,7 @@ import java.util.HashSet;
public class RenameLocalTest extends LightRefactoringTestCase {
private static final String BASE_PATH = "/refactoring/renameLocal/";
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -21,6 +21,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.refactoring.rename.inplace.MemberInplaceRenameHandler;
import com.intellij.testFramework.LightCodeInsightTestCase;
import com.intellij.testFramework.fixtures.CodeInsightTestUtil;
import org.jetbrains.annotations.NotNull;
/**
* User: anna
@@ -29,6 +30,7 @@ import com.intellij.testFramework.fixtures.CodeInsightTestUtil;
public class RenameMembersInplaceTest extends LightCodeInsightTestCase {
private static final String BASE_PATH = "/refactoring/renameInplace/";
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -5,11 +5,13 @@ import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.refactoring.replaceConstructorWithFactory.ReplaceConstructorWithFactoryProcessor;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
/**
* @author dsl
*/
public class ReplaceConstructorWithFactoryTest extends LightRefactoringTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -33,12 +33,14 @@ import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
import com.intellij.refactoring.util.ParameterTablePanel;
import com.intellij.testFramework.LightCodeInsightTestCase;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
public class SuggestedParamTypesTest extends LightCodeInsightTestCase {
@NonNls private static final String BASE_PATH = "/refactoring/suggestedTypes/";
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -7,6 +7,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.refactoring.LightRefactoringTestCase;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
/**
* @author dsl
@@ -14,6 +15,7 @@ import org.jetbrains.annotations.NonNls;
public class ChangeClassSignatureTest extends LightRefactoringTestCase {
@NonNls private static final String DATA_PATH = "/refactoring/changeClassSignature/";
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -6,11 +6,13 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import com.intellij.refactoring.LightRefactoringTestCase;
import com.intellij.util.VisibilityUtil;
import org.jetbrains.annotations.NotNull;
/**
* @author dsl
*/
public class ConvertToInstanceMethodTest extends LightRefactoringTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -8,8 +8,10 @@ import com.intellij.psi.PsiReference;
import com.intellij.psi.PsiReferenceExpression;
import com.intellij.refactoring.LightRefactoringTestCase;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
public class InlineConstantFieldTest extends LightRefactoringTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -10,11 +10,13 @@ import com.intellij.psi.PsiReference;
import com.intellij.psi.PsiReferenceExpression;
import com.intellij.refactoring.RefactoringBundle;
import com.intellij.testFramework.LightCodeInsightTestCase;
import org.jetbrains.annotations.NotNull;
/**
* @author ven
*/
public class InlineLocalTest extends LightCodeInsightTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -11,8 +11,10 @@ import com.intellij.refactoring.LightRefactoringTestCase;
import com.intellij.refactoring.MockInlineMethodOptions;
import com.intellij.refactoring.util.InlineUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
public class InlineMethodTest extends LightRefactoringTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -7,12 +7,14 @@ import com.intellij.refactoring.BaseRefactoringProcessor;
import com.intellij.refactoring.LightRefactoringTestCase;
import com.intellij.refactoring.util.CommonRefactoringUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
/**
* @author yole
*/
public class InlineParameterTest extends LightRefactoringTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -10,6 +10,7 @@ import com.intellij.refactoring.LightRefactoringTestCase;
import com.intellij.usageView.UsageInfo;
import com.intellij.util.containers.MultiMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.Iterator;
@@ -17,6 +18,7 @@ import java.util.Iterator;
* @author yole
*/
public class InlineToAnonymousClassTest extends LightRefactoringTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -9,6 +9,7 @@ import com.intellij.refactoring.LightRefactoringTestCase;
import com.intellij.refactoring.move.moveInstanceMethod.MoveInstanceMethodHandler;
import com.intellij.refactoring.move.moveInstanceMethod.MoveInstanceMethodProcessor;
import com.intellij.util.VisibilityUtil;
import org.jetbrains.annotations.NotNull;
/**
* @author ven
@@ -95,6 +96,7 @@ public class MoveInstanceMethodTest extends LightRefactoringTestCase {
}
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -21,6 +21,7 @@ import com.intellij.codeInsight.lookup.impl.LookupImpl;
import com.intellij.testFramework.LightCodeInsightTestCase;
import com.intellij.util.containers.HashSet;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collection;
@@ -41,7 +42,7 @@ public abstract class LightCompletionTestCase extends LightCodeInsightTestCase {
}
@Override
protected void configureByFile(String filePath) {
protected void configureByFile(@NotNull String filePath) {
super.configureByFile(filePath);
complete();
@@ -149,6 +149,7 @@ public abstract class GlobalSearchScope extends SearchScope implements ProjectAw
return GlobalSearchScope.this.isSearchInLibraries();
}
@NonNls
@Override
public String toString() {
return "UnionToLocal: (" + GlobalSearchScope.this.toString() + ", " + scope + ")";
@@ -368,6 +369,7 @@ public abstract class GlobalSearchScope extends SearchScope implements ProjectAw
return 31 * myScope1.hashCode() + myScope2.hashCode();
}
@NonNls
@Override
public String toString() {
return "Intersection: (" + myScope1 + ", " + myScope2 + ")";
@@ -518,9 +520,7 @@ public abstract class GlobalSearchScope extends SearchScope implements ProjectAw
FileTypeRestrictionScope that = (FileTypeRestrictionScope)o;
if (!Arrays.equals(myFileTypes, that.myFileTypes)) return false;
return true;
return Arrays.equals(myFileTypes, that.myFileTypes);
}
@Override
@@ -71,7 +71,7 @@ public class CollectHighlightsUtil {
private static final int STARTING_TREE_HEIGHT = 100;
private static List<PsiElement> getElementsToHighlight(final PsiElement commonParent, final int startOffset, final int endOffset) {
private static List<PsiElement> getElementsToHighlight(@NotNull PsiElement commonParent, final int startOffset, final int endOffset) {
final List<PsiElement> result = new ArrayList<PsiElement>();
final int currentOffset = commonParent.getTextRange().getStartOffset();
final Condition<PsiElement>[] filters = Extensions.getExtensions(EP_NAME);
@@ -122,6 +122,7 @@ public class CollectHighlightsUtil {
if (offset > endOffset) break;
children.push(child.getNextSibling());
starts.push(offset);
assert element != null;
elements.push(element);
element = child;
child = PsiUtilCore.NULL_PSI_ELEMENT;
@@ -116,7 +116,7 @@ public class ShowParameterInfoContext implements CreateParameterInfoContext {
) {
if (ParameterInfoController.isAlreadyShown(editor, elementStart)) return;
if (editor.isDisposed()) return;
if (editor.isDisposed() || !editor.getComponent().isVisible()) return;
final ParameterInfoComponent component = new ParameterInfoComponent(descriptors, editor,handler);
component.setParameterOwner(element);
if (highlighted != null) {
@@ -39,6 +39,7 @@ import com.intellij.openapi.util.Iconable;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.psi.util.PsiUtilBase;
import com.intellij.util.containers.ConcurrentHashSet;
import gnu.trove.THashSet;
import gnu.trove.TObjectHashingStrategy;
import org.jetbrains.annotations.NotNull;
@@ -53,10 +54,10 @@ import java.util.*;
class IntentionListStep implements ListPopupStep<IntentionActionWithTextCaching>, SpeedSearchFilter<IntentionActionWithTextCaching> {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.intention.impl.IntentionListStep");
private final Set<IntentionActionWithTextCaching> myCachedIntentions = new THashSet<IntentionActionWithTextCaching>(ACTION_TEXT_AND_CLASS_EQUALS);
private final Set<IntentionActionWithTextCaching> myCachedErrorFixes = new THashSet<IntentionActionWithTextCaching>(ACTION_TEXT_AND_CLASS_EQUALS);
private final Set<IntentionActionWithTextCaching> myCachedInspectionFixes = new THashSet<IntentionActionWithTextCaching>(ACTION_TEXT_AND_CLASS_EQUALS);
private final Set<IntentionActionWithTextCaching> myCachedGutters = new THashSet<IntentionActionWithTextCaching>(ACTION_TEXT_AND_CLASS_EQUALS);
private final Set<IntentionActionWithTextCaching> myCachedIntentions = new ConcurrentHashSet<IntentionActionWithTextCaching>(ACTION_TEXT_AND_CLASS_EQUALS);
private final Set<IntentionActionWithTextCaching> myCachedErrorFixes = new ConcurrentHashSet<IntentionActionWithTextCaching>(ACTION_TEXT_AND_CLASS_EQUALS);
private final Set<IntentionActionWithTextCaching> myCachedInspectionFixes = new ConcurrentHashSet<IntentionActionWithTextCaching>(ACTION_TEXT_AND_CLASS_EQUALS);
private final Set<IntentionActionWithTextCaching> myCachedGutters = new ConcurrentHashSet<IntentionActionWithTextCaching>(ACTION_TEXT_AND_CLASS_EQUALS);
private final IntentionManagerSettings mySettings;
@Nullable
private final IntentionHintComponent myIntentionHintComponent;
@@ -307,10 +308,10 @@ class IntentionListStep implements ListPopupStep<IntentionActionWithTextCaching>
if (a instanceof HighPriorityAction) {
return group + 3;
}
else if (a instanceof LowPriorityAction) {
if (a instanceof LowPriorityAction) {
return group - 3;
}
else if (a instanceof QuickFixWrapper) {
if (a instanceof QuickFixWrapper) {
final LocalQuickFix quickFix = ((QuickFixWrapper)a).getFix();
if (quickFix instanceof HighPriorityAction) {
return group + 3;
@@ -326,15 +327,13 @@ class IntentionListStep implements ListPopupStep<IntentionActionWithTextCaching>
if (myCachedErrorFixes.contains(action)) {
return 20;
}
else if (myCachedInspectionFixes.contains(action)) {
if (myCachedInspectionFixes.contains(action)) {
return 10;
}
else if (action.getAction() instanceof EmptyIntentionAction) {
if (action.getAction() instanceof EmptyIntentionAction) {
return -10;
}
else {
return 0;
}
return 0;
}
@Override
@@ -33,6 +33,7 @@ import javax.accessibility.AccessibleRole;
import javax.accessibility.AccessibleStateSet;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.tree.TreeCellRenderer;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
@@ -92,7 +93,7 @@ public class SimpleColoredComponent extends JComponent implements Accessible {
private boolean myIconOpaque = true;
private boolean myAutoInvalidate = true;
private boolean myAutoInvalidate = !(this instanceof TreeCellRenderer);
private AccessibleContext myContext = new MyAccessibleContext();
@@ -45,7 +45,7 @@ public class EditorUtil {
private EditorUtil() { }
public static int getLastVisualLineColumnNumber(Editor editor, final int line) {
public static int getLastVisualLineColumnNumber(@NotNull Editor editor, final int line) {
Document document = editor.getDocument();
int lastLine = document.getLineCount() - 1;
if (lastLine < 0) {
@@ -160,7 +160,7 @@ public class EditorUtil {
return editor.logicalPositionToOffset(endLineLogicalPosition);
}
public static float calcVerticalScrollProportion(Editor editor) {
public static float calcVerticalScrollProportion(@NotNull Editor editor) {
Rectangle viewArea = editor.getScrollingModel().getVisibleAreaOnScrollingFinished();
if (viewArea.height == 0) {
return 0;
@@ -170,7 +170,7 @@ public class EditorUtil {
return (location.y - viewArea.y) / (float) viewArea.height;
}
public static void setVerticalScrollProportion(Editor editor, float proportion) {
public static void setVerticalScrollProportion(@NotNull Editor editor, float proportion) {
Rectangle viewArea = editor.getScrollingModel().getVisibleArea();
LogicalPosition caretPosition = editor.getCaretModel().getLogicalPosition();
Point caretLocation = editor.logicalPositionToXY(caretPosition);
@@ -179,15 +179,15 @@ public class EditorUtil {
editor.getScrollingModel().scrollVertically(yPos);
}
public static void fillVirtualSpaceUntilCaret(final Editor editor) {
public static void fillVirtualSpaceUntilCaret(@NotNull Editor editor) {
final LogicalPosition position = editor.getCaretModel().getLogicalPosition();
fillVirtualSpaceUntil(editor, position.column, position.line);
}
public static void fillVirtualSpaceUntil(final Editor editor, int columnNumber, int lineNumber) {
public static void fillVirtualSpaceUntil(@NotNull final Editor editor, int columnNumber, int lineNumber) {
final int offset = editor.logicalPositionToOffset(new LogicalPosition(lineNumber, columnNumber));
final String filler = EditorModificationUtil.calcStringToFillVirtualSpace(editor);
if (filler.length() > 0) {
if (!filler.isEmpty()) {
new WriteAction(){
@Override
protected void run(final Result result) throws Throwable {
@@ -211,9 +211,13 @@ public class EditorUtil {
* @param debugBuffer buffer to hold debug info during the processing (if any)
* @return given text offset that identifies the same position that is pointed by the given visual column
*/
public static int calcOffset(EditorEx editor, CharSequence text, int start, int end, int columnNumber, int tabSize,
@Nullable StringBuilder debugBuffer)
{
public static int calcOffset(@NotNull EditorEx editor,
@NotNull CharSequence text,
int start,
int end,
int columnNumber,
int tabSize,
@Nullable StringBuilder debugBuffer) {
assert start >= 0 : "start (" + start + ") must not be negative. end (" + end + ")";
assert end >= start : "start (" + start + ") must not be greater than end (" + end + ")";
if (debugBuffer != null) {
@@ -275,8 +279,15 @@ public class EditorUtil {
* @return target offset that belongs to the <code>[start; end)</code> range and points to the target logical
* column if any; <code>-1</code> otherwise
*/
private static int calcSoftWrapUnawareOffset(Editor editor, CharSequence text, int start, int end, int columnNumber, int tabSize, int x,
int[] currentColumn, @Nullable StringBuilder debugBuffer) {
private static int calcSoftWrapUnawareOffset(@NotNull Editor editor,
@NotNull CharSequence text,
int start,
int end,
int columnNumber,
int tabSize,
int x,
@NotNull int[] currentColumn,
@Nullable StringBuilder debugBuffer) {
if (debugBuffer != null) {
debugBuffer.append(String.format(
"Starting calcSoftWrapUnawareOffset(). Target range: [%d; %d), target column number to map: %d, tab size: %d, "
@@ -313,7 +324,7 @@ public class EditorUtil {
// Perform optimized processing if possible. 'Optimized' here means the processing when we exactly know how many logical
// columns are occupied by tabulation symbols.
if (editor == null || useOptimization) {
if (useOptimization) {
if (!hasTabs) {
int result = start + columnNumber - currentColumn[0];
if (result < end) {
@@ -431,11 +442,11 @@ public class EditorUtil {
return tabSize - colNumber % tabSize;
}
public static int calcColumnNumber(Editor editor, CharSequence text, int start, int offset) {
public static int calcColumnNumber(@NotNull Editor editor, @NotNull CharSequence text, int start, int offset) {
return calcColumnNumber(editor, text, start, offset, getTabSize(editor));
}
public static int calcColumnNumber(Editor editor, CharSequence text, final int start, final int offset, final int tabSize) {
public static int calcColumnNumber(@Nullable Editor editor, @NotNull CharSequence text, final int start, final int offset, final int tabSize) {
boolean useOptimization = true;
if (editor != null) {
SoftWrap softWrap = editor.getSoftWrapModel().getSoftWrap(start);
@@ -488,7 +499,7 @@ public class EditorUtil {
return editorImpl.calcColumnNumber(text, start, offset, tabSize);
}
public static void setHandCursor(Editor view) {
public static void setHandCursor(@NotNull Editor view) {
Cursor c = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
// XXX: Workaround, simply view.getContentComponent().setCursor(c) doesn't work
if (view.getContentComponent().getCursor() != c) {
@@ -496,25 +507,25 @@ public class EditorUtil {
}
}
public static FontInfo fontForChar(final char c, @JdkConstants.FontStyle int style, Editor editor) {
public static FontInfo fontForChar(final char c, @JdkConstants.FontStyle int style, @NotNull Editor editor) {
EditorColorsScheme colorsScheme = editor.getColorsScheme();
return ComplementaryFontsRegistry.getFontAbleToDisplay(c, colorsScheme.getEditorFontSize(), style, colorsScheme.getEditorFontName());
}
public static int charWidth(char c, @JdkConstants.FontStyle int fontType, Editor editor) {
public static int charWidth(char c, @JdkConstants.FontStyle int fontType, @NotNull Editor editor) {
return fontForChar(c, fontType, editor).charWidth(c);
}
public static int getSpaceWidth(@JdkConstants.FontStyle int fontType, Editor editor) {
public static int getSpaceWidth(@JdkConstants.FontStyle int fontType, @NotNull Editor editor) {
int width = charWidth(' ', fontType, editor);
return width > 0 ? width : 1;
}
public static int getTabSize(Editor editor) {
public static int getTabSize(@NotNull Editor editor) {
return editor.getSettings().getTabSize(editor.getProject());
}
public static int nextTabStop(int x, Editor editor) {
public static int nextTabStop(int x, @NotNull Editor editor) {
int tabSize = getTabSize(editor);
if (tabSize <= 0) {
tabSize = 1;
@@ -522,7 +533,7 @@ public class EditorUtil {
return nextTabStop(x, editor, tabSize);
}
public static int nextTabStop(int x, Editor editor, int tabSize) {
public static int nextTabStop(int x, @NotNull Editor editor, int tabSize) {
return nextTabStop(x, getSpaceWidth(Font.PLAIN, editor), tabSize);
}
@@ -536,7 +547,7 @@ public class EditorUtil {
return (nTabs + 1) * tabSize;
}
public static int textWidthInColumns(@NotNull Editor editor, CharSequence text, int start, int end, int x) {
public static int textWidthInColumns(@NotNull Editor editor, @NotNull CharSequence text, int start, int end, int x) {
int startToUse = start;
int lastTabSymbolIndex = -1;
@@ -556,7 +567,6 @@ public class EditorUtil {
}
int result = 0;
int prevX;
int spaceSize = getSpaceWidth(Font.PLAIN, editor);
// Calculate number of columns up to the latest tabulation symbol.
@@ -566,7 +576,7 @@ public class EditorUtil {
x = softWrap.getIndentInPixels();
}
char c = text.charAt(i);
prevX = x;
int prevX = x;
switch (c) {
case '\t':
x = nextTabStop(x, editor);
@@ -636,7 +646,7 @@ public class EditorUtil {
* from <code>[1; tab size]</code> (check {@link #nextTabStop(int, Editor)} for more details)
* @return width in pixels required for target text representation
*/
public static int textWidth(@NotNull Editor editor, CharSequence text, int start, int end, @JdkConstants.FontStyle int fontType, int x) {
public static int textWidth(@NotNull Editor editor, @NotNull CharSequence text, int start, int end, @JdkConstants.FontStyle int fontType, int x) {
int result = 0;
for (int i = start; i < end; i++) {
char c = text.charAt(i);
@@ -659,7 +669,7 @@ public class EditorUtil {
* @return surrounding logical positions
* @see #calcSurroundingRange(Editor, VisualPosition, VisualPosition)
*/
public static Pair<LogicalPosition, LogicalPosition> calcCaretLineRange(Editor editor) {
public static Pair<LogicalPosition, LogicalPosition> calcCaretLineRange(@NotNull Editor editor) {
return calcSurroundingRange(editor, editor.getCaretModel().getVisualPosition(), editor.getCaretModel().getVisualPosition());
}
@@ -685,7 +695,7 @@ public class EditorUtil {
* @return pair of the closest surrounding non-soft-wrapped logical positions for the visual line start and end
*/
@SuppressWarnings("AssignmentToForLoopParameter")
public static Pair<LogicalPosition, LogicalPosition> calcSurroundingRange(Editor editor, VisualPosition start, VisualPosition end) {
public static Pair<LogicalPosition, LogicalPosition> calcSurroundingRange(@NotNull Editor editor, @NotNull VisualPosition start, @NotNull VisualPosition end) {
final Document document = editor.getDocument();
final FoldingModel foldingModel = editor.getFoldingModel();
@@ -734,19 +744,19 @@ public class EditorUtil {
return new Pair<LogicalPosition, LogicalPosition>(first, second);
}
public static void scrollToTheEnd(final Editor editor) {
public static void scrollToTheEnd(@NotNull Editor editor) {
editor.getCaretModel().moveToOffset(editor.getDocument().getTextLength());
editor.getSelectionModel().removeSelection();
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
}
public static boolean isChangeFontSize(MouseWheelEvent e) {
public static boolean isChangeFontSize(@NotNull MouseWheelEvent e) {
return SystemInfo.isMac
? !e.isControlDown() && e.isMetaDown() && !e.isAltDown() && !e.isShiftDown()
: e.isControlDown() && !e.isMetaDown() && !e.isAltDown() && !e.isShiftDown();
}
public static boolean inVirtualSpace(Editor editor, LogicalPosition logicalPosition) {
public static boolean inVirtualSpace(@NotNull Editor editor, @NotNull LogicalPosition logicalPosition) {
return !editor.offsetToLogicalPosition(editor.logicalPositionToOffset(logicalPosition)).equals(logicalPosition);
}
}
@@ -358,8 +358,7 @@ public class InfoAndProgressPanel extends JPanel implements CustomStatusBarWidge
return Pair.create(myInfoPanel.getText(), myCurrentRequestor);
}
boolean logMode = myInfoPanel.updateText(requestor == EventLog.LOG_REQUESTOR
? "" : text);
boolean logMode = myInfoPanel.updateText(requestor == EventLog.LOG_REQUESTOR ? "" : text);
myCurrentRequestor = logMode ? EventLog.LOG_REQUESTOR : requestor;
return Pair.create(text, requestor);
}
@@ -114,7 +114,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
* @param filePath - relative path from %IDEA_INSTALLATION_HOME%/testData/
* @throws Exception
*/
protected void configureByFile(@TestDataFile @NonNls String filePath) {
protected void configureByFile(@TestDataFile @NonNls @NotNull String filePath) {
try {
String fullPath = getTestDataPath() + filePath;
@@ -130,6 +130,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
}
@NonNls
@NotNull
protected String getTestDataPath() {
return PathManagerEx.getTestDataPath();
}
@@ -141,10 +142,22 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
* @throws java.io.IOException
*/
@NotNull
protected static Document configureFromFileText(@NonNls final String fileName, @NonNls final String fileText) throws IOException {
protected static Document configureFromFileText(@NonNls @NotNull final String fileName, @NonNls @NotNull final String fileText) throws IOException {
return ApplicationManager.getApplication().runWriteAction(new Computable<Document>() {
@Override
public Document compute() {
if (myVFile != null) {
// avoid messing with invalid files, in case someone calls configureXXX() several times
PsiDocumentManager.getInstance(ourProject).commitAllDocuments();
FileEditorManager.getInstance(ourProject).closeFile(myVFile);
try {
myVFile.delete(this);
}
catch (IOException e) {
LOG.error(e);
}
myVFile = null;
}
final Document fakeDocument = new DocumentImpl(fileText);
int caretIndex = fileText.indexOf(CARET_MARKER);
@@ -200,14 +213,14 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
}
}
protected static Editor createEditor(VirtualFile file) {
protected static Editor createEditor(@NotNull VirtualFile file) {
Editor editor = FileEditorManager.getInstance(getProject()).openTextEditor(new OpenFileDescriptor(getProject(), file, 0), false);
((EditorImpl)editor).setCaretActive();
return editor;
}
@NotNull
private static Document setupFileEditorAndDocument(final String fileName, String fileText) throws IOException {
private static Document setupFileEditorAndDocument(@NotNull String fileName, @NotNull String fileText) throws IOException {
EncodingProjectManager.getInstance(getProject()).setEncoding(null, CharsetToolkit.UTF8_CHARSET);
EncodingProjectManager.getInstance(ProjectManager.getInstance().getDefaultProject()).setEncoding(null, CharsetToolkit.UTF8_CHARSET);
PostprocessReformattingAspect.getInstance(ourProject).doPostponedFormatting();
@@ -273,7 +286,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
* @param filePath - relative path from %IDEA_INSTALLATION_HOME%/testData/
* @throws Exception
*/
protected void checkResultByFile(@NonNls String filePath) {
protected void checkResultByFile(@NonNls @NotNull String filePath) {
checkResultByFile(null, filePath, false);
}
@@ -285,7 +298,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
* @param ignoreTrailingSpaces - whether trailing spaces in editor in data file should be stripped prior to comparing.
* @throws Exception
*/
protected void checkResultByFile(@Nullable String message, final String filePath, final boolean ignoreTrailingSpaces) {
protected void checkResultByFile(@Nullable String message, @NotNull String filePath, final boolean ignoreTrailingSpaces) {
bringRealEditorBack();
getProject().getComponent(PostprocessReformattingAspect.class).doPostponedFormatting();
@@ -315,7 +328,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
* Same as checkResultByFile but text is provided directly.
* @param fileText
*/
protected void checkResultByText(@NonNls String fileText) {
protected void checkResultByText(@NonNls @NotNull String fileText) {
checkResultByText(null, fileText, false, null);
}
@@ -325,7 +338,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
* @param fileText
* @param ignoreTrailingSpaces - whether trailing spaces in editor in data file should be stripped prior to comparing.
*/
protected void checkResultByText(final String message, final String fileText, final boolean ignoreTrailingSpaces) {
protected void checkResultByText(final String message, @NotNull String fileText, final boolean ignoreTrailingSpaces) {
checkResultByText(message, fileText, ignoreTrailingSpaces, null);
}
@@ -335,7 +348,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
* @param fileText
* @param ignoreTrailingSpaces - whether trailing spaces in editor in data file should be stripped prior to comparing.
*/
protected void checkResultByText(final String message, final String fileText, final boolean ignoreTrailingSpaces, final String filePath) {
protected void checkResultByText(final String message, @NotNull final String fileText, final boolean ignoreTrailingSpaces, final String filePath) {
bringRealEditorBack();
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 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.
@@ -80,8 +80,7 @@ public class IdeaPicoContainer extends DefaultPicoContainer {
result.add(cacheHit);
}
for (final Object o : getNonAssignableAdapters()) {
ComponentAdapter componentAdapter = (ComponentAdapter)o;
for (final ComponentAdapter componentAdapter : getNonAssignableAdapters()) {
if (componentAdapter instanceof AssignableToComponentAdapter) {
AssignableToComponentAdapter assignableToComponentAdapter = (AssignableToComponentAdapter)componentAdapter;
@@ -69,6 +69,7 @@ import com.intellij.openapi.wm.WindowManager;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentFactory;
import com.intellij.ui.content.MessageView;
import com.intellij.util.ArrayUtil;
import com.intellij.util.AsynchConsumer;
import com.intellij.util.BufferedListConsumer;
import com.intellij.util.Consumer;
@@ -78,6 +79,7 @@ import com.intellij.util.ui.MessageCategory;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import java.awt.*;
import java.io.File;
@@ -90,6 +92,12 @@ public class AbstractVcsHelperImpl extends AbstractVcsHelper {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.impl.AbstractVcsHelperImpl");
private final Project myProject;
private Consumer<VcsException> myCustomHandler = new Consumer<VcsException>() {
@Override
public void consume(VcsException e) {
throw new RuntimeException(e);
}
};
public AbstractVcsHelperImpl(Project project) {
myProject = project;
@@ -227,28 +235,29 @@ public class AbstractVcsHelperImpl extends AbstractVcsHelper {
return CommitChangeListDialog.commitChanges(myProject, changes, initialChangeList, executor, commitMessage);
}
private void addDirectMessages(VcsErrorViewPanel vcsErrorViewPanel, List<VcsException> abstractVcsExceptions) {
private static void addDirectMessages(VcsErrorViewPanel vcsErrorViewPanel, List<VcsException> abstractVcsExceptions) {
for (final VcsException exception : abstractVcsExceptions) {
String[] messages = getExceptionMessages(exception);
vcsErrorViewPanel.addMessage(getErrorCategory(exception), messages, exception.getVirtualFile(), -1, -1, null);
}
}
private String[] getExceptionMessages(VcsException exception) {
private static String[] getExceptionMessages(VcsException exception) {
String[] messages = exception.getMessages();
if (messages.length == 0) messages = new String[]{VcsBundle.message("exception.text.unknown.error")};
final List<String> list = new ArrayList<String>();
for (String message : messages) {
list.addAll(StringUtil.split(StringUtil.convertLineSeparators(message), "\n"));
}
return list.toArray(new String[list.size()]);
return ArrayUtil.toStringArray(list);
}
private void showErrorsImpl(final boolean isEmpty, final Getter<VcsException> firstGetter, @NotNull final String tabDisplayName,
final Consumer<VcsErrorViewPanel> viewFiller) {
if (ApplicationManager.getApplication().isUnitTestMode() && !isEmpty) {
throw new RuntimeException(firstGetter.get());
} else if (ApplicationManager.getApplication().isUnitTestMode()) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
if (!isEmpty) {
myCustomHandler.consume(firstGetter.get());
}
return;
}
ApplicationManager.getApplication().invokeLater(new Runnable() {
@@ -704,4 +713,9 @@ public class AbstractVcsHelperImpl extends AbstractVcsHelper {
return myRevisionsReturned;
}
}
@TestOnly
public static void setCustomExceptionHandler(Project project, Consumer<VcsException> customHandler) {
((AbstractVcsHelperImpl)getInstance(project)).myCustomHandler = customHandler;
}
}
@@ -19,8 +19,10 @@ import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.openapi.application.PluginPathManager;
import com.siyeh.ig.controlflow.UnnecessaryReturnInspection;
import org.jetbrains.annotations.NotNull;
public class CommonIGInspectionsTest extends LightDaemonAnalyzerTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return PluginPathManager.getPluginHomePath("InspectionGadgets") + "/test";
@@ -18,6 +18,7 @@ package com.siyeh.ig.inheritance;
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.openapi.application.PluginPathManager;
import org.jetbrains.annotations.NotNull;
/**
* User: cdr
@@ -37,6 +38,7 @@ public class StaticInheritanceTest extends LightQuickFixTestCase {
return "/com/siyeh/igtest/inheritance/staticInheritance/";
}
@NotNull
@Override
protected String getTestDataPath() {
return PluginPathManager.getPluginHomePath("InspectionGadgets") + "/test";
@@ -31,13 +31,14 @@ import java.util.List;
public class AntCompletionTest extends LightCodeInsightTestCase {
@NotNull
@Override
protected String getTestDataPath() {
return PluginPathManager.getPluginHomePath("ant") + "/tests/data/psi/completion/";
}
@Override
protected void configureByFile(@TestDataFile @NonNls String filePath) {
protected void configureByFile(@NotNull @TestDataFile @NonNls String filePath) {
super.configureByFile(filePath);
AntSupport.markFileAsAntFile(myVFile, myFile.getProject(), true);
}
@@ -25,6 +25,7 @@ import com.intellij.psi.PsiNamedElement;
import com.intellij.refactoring.RefactoringFactory;
import com.intellij.refactoring.RenameRefactoring;
import com.intellij.testFramework.LightCodeInsightTestCase;
import org.jetbrains.annotations.NotNull;
public class AntRenameTest extends LightCodeInsightTestCase {
@@ -128,6 +129,7 @@ public class AntRenameTest extends LightCodeInsightTestCase {
doTest();
}
@NotNull
@Override
protected String getTestDataPath() {
return PluginPathManager.getPluginHomePath("ant").replace('\\', '/') + "/tests/data/psi/rename/";
@@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.PluginPathManager;
import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
import com.intellij.testFramework.PlatformTestCase;
import org.jetbrains.annotations.NotNull;
/**
* @author cdr
@@ -34,6 +35,7 @@ public class PropertiesCommenterTest extends LightPlatformCodeInsightTestCase {
PlatformTestCase.initPlatformLangPrefix();
}
@NotNull
@Override
protected String getTestDataPath() {
return PluginPathManager.getPluginHomePath("properties") + "/testData";
@@ -23,6 +23,7 @@ import com.intellij.openapi.application.PluginPathManager;
import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
import com.intellij.testFramework.PlatformTestCase;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
/**
* @author cdr
@@ -34,6 +35,7 @@ public class PropertiesEnterTest extends LightPlatformCodeInsightTestCase {
PlatformTestCase.initPlatformLangPrefix();
}
@NotNull
@Override
protected String getTestDataPath() {
return PluginPathManager.getPluginHomePath("properties") + "/testData";
@@ -34,6 +34,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.*;
import java.util.Collections;
import java.util.List;
import java.util.Set;
@@ -146,7 +147,12 @@ public class DomImplUtil {
if (!tag.isValid()) {
throw new AssertionError("Invalid tag");
}
return ContainerUtil.findAll(tag.getSubTags(), new Condition<XmlTag>() {
final XmlTag[] tags = tag.getSubTags();
if (tags.length == 0) {
return Collections.emptyList();
}
return ContainerUtil.findAll(tags, new Condition<XmlTag>() {
public boolean value(XmlTag childTag) {
try {
return isNameSuitable(name, childTag.getLocalName(), childTag.getName(), childTag.getNamespace(), file);
@@ -166,6 +172,10 @@ public class DomImplUtil {
}
public static List<XmlTag> findSubTags(final XmlTag[] tags, final EvaluatedXmlName name, final XmlFile file) {
if (tags.length == 0) {
return Collections.emptyList();
}
return ContainerUtil.findAll(tags, new Condition<XmlTag>() {
public boolean value(XmlTag childTag) {
return isNameSuitable(name, childTag, file);
@@ -248,12 +258,22 @@ public class DomImplUtil {
}
public static List<XmlTag> getCustomSubTags(final DomInvocationHandler handler, final XmlTag[] subTags, final XmlFile file) {
if (subTags.length == 0) {
return Collections.emptyList();
}
final DomGenericInfoEx info = handler.getGenericInfo();
final Set<XmlName> usedNames = new THashSet<XmlName>();
for (final DomCollectionChildDescription description : info.getCollectionChildrenDescriptions()) {
List<? extends DomCollectionChildDescription> collectionChildrenDescriptions = info.getCollectionChildrenDescriptions();
//noinspection ForLoopReplaceableByForEach
for (int i = 0, size = collectionChildrenDescriptions.size(); i < size; i++) {
DomCollectionChildDescription description = collectionChildrenDescriptions.get(i);
usedNames.add(description.getXmlName());
}
for (final DomFixedChildDescription description : info.getFixedChildrenDescriptions()) {
List<? extends DomFixedChildDescription> fixedChildrenDescriptions = info.getFixedChildrenDescriptions();
//noinspection ForLoopReplaceableByForEach
for (int i = 0, size = fixedChildrenDescriptions.size(); i < size; i++) {
DomFixedChildDescription description = fixedChildrenDescriptions.get(i);
usedNames.add(description.getXmlName());
}
return ContainerUtil.findAll(subTags, new Condition<XmlTag>() {
@@ -16,6 +16,7 @@ import com.intellij.openapi.editor.actionSystem.EditorActionManager;
import com.intellij.testFramework.IdeaTestUtil;
import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.util.ThrowableRunnable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
@@ -34,6 +35,7 @@ public class XmlPerformanceTest extends LightQuickFixTestCase {
return "performance/";
}
@NotNull
@Override
protected String getTestDataPath() {
return PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/') + "/xml/tests/testData/";
@@ -2,6 +2,7 @@ package com.intellij.codeInsight;
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
import com.intellij.testFramework.PlatformTestUtil;
import org.jetbrains.annotations.NotNull;
import java.io.File;
@@ -16,6 +17,7 @@ public class XmlWrongClosingTagNameInspectionTest extends LightQuickFixTestCase
return "/wrongClosingTagName";
}
@NotNull
@Override
protected String getTestDataPath() {
return PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/') + "/xml/tests/testData/inspections";
@@ -10,6 +10,7 @@ import com.intellij.openapi.application.Result;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.testFramework.LightCodeInsightTestCase;
import com.intellij.testFramework.PlatformTestUtil;
import org.jetbrains.annotations.NotNull;
import java.io.File;
@@ -130,6 +131,7 @@ public class XmlSmartEnterTest extends LightCodeInsightTestCase {
return "";
}
@NotNull
@Override
protected String getTestDataPath() {
return PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/') + "/xml/tests/testData/";
@@ -3,6 +3,7 @@ package com.intellij.codeInsight.daemon.quickFix;
import com.intellij.codeInsight.daemon.impl.quickfix.FetchExtResourceAction;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.testFramework.PlatformTestUtil;
import org.jetbrains.annotations.NotNull;
import java.io.File;
@@ -36,6 +37,7 @@ public class FetchExternalResourcesFixTest extends LightQuickFixTestCase {
}
}
@NotNull
@Override
protected String getTestDataPath() {
return PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/') + "/xml/tests/testData/";
@@ -2,6 +2,7 @@ package com.intellij.codeInsight.daemon.quickFix;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.testFramework.PlatformTestUtil;
import org.jetbrains.annotations.NotNull;
import java.io.File;
@@ -22,6 +23,7 @@ public class IgnoreExternalResourcesFixTest extends LightQuickFixTestCase {
}
}
@NotNull
@Override
protected String getTestDataPath() {
return PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/') + "/xml/tests/testData/";
@@ -2,6 +2,7 @@ package com.intellij.codeInsight.daemon.quickFix;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.testFramework.PlatformTestUtil;
import org.jetbrains.annotations.NotNull;
import java.io.File;
@@ -22,6 +23,7 @@ public class ManuallySetupExternalResourcesFixTest extends LightQuickFixTestCase
}
}
@NotNull
@Override
protected String getTestDataPath() {
return PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/') + "/xml/tests/testData/";
@@ -2,6 +2,7 @@ package com.intellij.xml.actions;
import com.intellij.codeInsight.daemon.LightIntentionActionTestCase;
import com.intellij.testFramework.PlatformTestUtil;
import org.jetbrains.annotations.NotNull;
/**
* @author spleaner
@@ -20,6 +21,7 @@ public class SplitTagActionTest extends LightIntentionActionTestCase {
return "";
}
@NotNull
protected String getTestDataPath() {
return PlatformTestUtil.getCommunityPath() + "/xml/tests/testData/intentions/splitTag";
}