Merge remote-tracking branch 'origin/master'

This commit is contained in:
Anna Kozlova
2014-06-27 13:18:12 +02:00
19 changed files with 125 additions and 85 deletions
@@ -158,6 +158,7 @@ public class MethodCandidateInfo extends CandidateInfo{
return level;
}
@NotNull
public PsiSubstitutor getSiteSubstitutor() {
PsiSubstitutor incompleteSubstitutor = super.getSubstitutor();
if (myTypeArguments != null) {
@@ -760,7 +760,6 @@ public class PsiClassImplUtil {
@NotNull
private static PsiClass[] getSupersInner(@NotNull PsiClass psiClass) {
PsiClassType[] extendsListTypes = psiClass.getExtendsListTypes();
PsiClassType[] implementsListTypes = psiClass.getImplementsListTypes();
if (psiClass.isInterface()) {
return resolveClassReferenceList(extendsListTypes, psiClass.getManager(), psiClass.getResolveScope(), true);
@@ -792,6 +791,7 @@ public class PsiClassImplUtil {
return resolveClassReferenceList(extendsListTypes, psiClass.getManager(), psiClass.getResolveScope(), false);
}
PsiClassType[] implementsListTypes = psiClass.getImplementsListTypes();
PsiClass[] interfaces = resolveClassReferenceList(implementsListTypes, psiClass.getManager(), psiClass.getResolveScope(), false);
PsiClass superClass = getSuperClass(psiClass);
@@ -219,7 +219,7 @@ public class MethodReferenceResolver implements ResolveCache.PolyVariantContextR
}
@Override
protected int getPertinentApplicabilityLevel(MethodCandidateInfo conflict) {
protected int getPertinentApplicabilityLevel(@NotNull MethodCandidateInfo conflict) {
return conflict.isVarargs() ? MethodCandidateInfo.ApplicabilityLevel.VARARGS : MethodCandidateInfo.ApplicabilityLevel.FIXED_ARITY;
}
@@ -299,7 +299,7 @@ public class MethodReferenceResolver implements ResolveCache.PolyVariantContextR
}
@Override
protected boolean nonComparable(CandidateInfo method, CandidateInfo conflict) {
protected boolean nonComparable(@NotNull CandidateInfo method, @NotNull CandidateInfo conflict) {
if (method == conflict) return true;
PsiElement psiElement = method.getElement();
PsiElement conflictElement = conflict.getElement();
@@ -131,9 +131,11 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
private static PsiLambdaExpression findNestedLambdaExpression(PsiExpression expression) {
if (expression instanceof PsiLambdaExpression) {
return (PsiLambdaExpression)expression;
} else if (expression instanceof PsiParenthesizedExpression) {
}
else if (expression instanceof PsiParenthesizedExpression) {
return findNestedLambdaExpression(((PsiParenthesizedExpression)expression).getExpression());
} else if (expression instanceof PsiConditionalExpression) {
}
else if (expression instanceof PsiConditionalExpression) {
PsiLambdaExpression lambdaExpression = findNestedLambdaExpression(((PsiConditionalExpression)expression).getThenExpression());
if (lambdaExpression != null) {
return lambdaExpression;
@@ -143,7 +145,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
return null;
}
private static void checkLambdaApplicable(List<CandidateInfo> conflicts, int i, PsiLambdaExpression lambdaExpression) {
private static void checkLambdaApplicable(@NotNull List<CandidateInfo> conflicts, int i, @NotNull PsiLambdaExpression lambdaExpression) {
for (Iterator<CandidateInfo> iterator = conflicts.iterator(); iterator.hasNext(); ) {
ProgressManager.checkCanceled();
final CandidateInfo conflict = iterator.next();
@@ -192,12 +194,12 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
}
}
protected boolean nonComparable(CandidateInfo method, CandidateInfo conflict) {
protected boolean nonComparable(@NotNull CandidateInfo method, @NotNull CandidateInfo conflict) {
assert method != conflict;
return false;
}
protected static void checkAccessStaticLevels(List<CandidateInfo> conflicts, boolean checkAccessible) {
protected static void checkAccessStaticLevels(@NotNull List<CandidateInfo> conflicts, boolean checkAccessible) {
int conflictsCount = conflicts.size();
int maxCheckLevel = -1;
@@ -350,13 +352,13 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
}
}
private static boolean areTypeParametersAgree(CandidateInfo info) {
private static boolean areTypeParametersAgree(@NotNull CandidateInfo info) {
return ((MethodCandidateInfo)info).getPertinentApplicabilityLevel() != MethodCandidateInfo.ApplicabilityLevel.NOT_APPLICABLE;
}
private static boolean checkParametersNumber(final List<CandidateInfo> conflicts,
final int argumentsCount,
boolean ignoreIfStaticsProblem) {
private static boolean checkParametersNumber(@NotNull List<CandidateInfo> conflicts,
final int argumentsCount,
boolean ignoreIfStaticsProblem) {
boolean atLeastOneMatch = false;
TIntArrayList unmatchedIndices = null;
for (int i = 0; i < conflicts.size(); i++) {
@@ -392,7 +394,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
}
@MethodCandidateInfo.ApplicabilityLevelConstant
protected int checkApplicability(List<CandidateInfo> conflicts) {
protected int checkApplicability(@NotNull List<CandidateInfo> conflicts) {
@MethodCandidateInfo.ApplicabilityLevelConstant int maxApplicabilityLevel = 0;
boolean toFilter = false;
for (CandidateInfo conflict : conflicts) {
@@ -420,27 +422,29 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
return maxApplicabilityLevel;
}
protected int getPertinentApplicabilityLevel(MethodCandidateInfo conflict) {
protected int getPertinentApplicabilityLevel(@NotNull MethodCandidateInfo conflict) {
return conflict.getPertinentApplicabilityLevel();
}
private static int getCheckAccessLevel(MethodCandidateInfo method){
private static int getCheckAccessLevel(@NotNull MethodCandidateInfo method){
boolean visible = method.isAccessible();
return visible ? 1 : 0;
}
private static int getCheckStaticLevel(MethodCandidateInfo method){
private static int getCheckStaticLevel(@NotNull MethodCandidateInfo method){
boolean available = method.isStaticsScopeCorrect();
return (available ? 1 : 0) << 1 |
(method.getCurrentFileResolveScope() instanceof PsiImportStaticStatement ? 0 : 1);
}
@NotNull
private PsiType[] getActualParameterTypes() {
if (myActualParameterTypes == null) {
PsiType[] types = myActualParameterTypes;
if (types == null) {
LOG.assertTrue(myArgumentsList instanceof PsiExpressionList, myArgumentsList);
myActualParameterTypes = getArgumentTypes();
myActualParameterTypes = types = getArgumentTypes();
}
return myActualParameterTypes;
return types;
}
private int getActualParametersLength() {
@@ -451,6 +455,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
return myActualParameterTypes.length;
}
@NotNull
protected PsiType[] getArgumentTypes() {
return ((PsiExpressionList)myArgumentsList).getExpressionTypes();
}
@@ -470,8 +475,8 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
return TypeConversionUtil.boxingConversionApplicable(parameterType, argType);
}
private Specifics isMoreSpecific(final MethodCandidateInfo info1,
final MethodCandidateInfo info2,
private Specifics isMoreSpecific(@NotNull MethodCandidateInfo info1,
@NotNull MethodCandidateInfo info2,
@MethodCandidateInfo.ApplicabilityLevelConstant int applicabilityLevel,
@NotNull LanguageLevel languageLevel) {
PsiMethod method1 = info1.getElement();
@@ -684,11 +689,11 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
return Specifics.NEITHER;
}
private boolean isApplicableTo(PsiType[] types2AtSite,
PsiMethod method1,
LanguageLevel languageLevel,
private boolean isApplicableTo(@NotNull PsiType[] types2AtSite,
@NotNull PsiMethod method1,
@NotNull LanguageLevel languageLevel,
boolean varargsPosition,
final PsiSubstitutor methodSubstitutor1,
@NotNull PsiSubstitutor methodSubstitutor1,
PsiMethod method2,
PsiSubstitutor siteSubstitutor1) {
if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8) && method2 != null && method1.getTypeParameters().length > 0 && myArgumentsList instanceof PsiExpressionList) {
@@ -701,7 +706,8 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
return applicabilityLevel > MethodCandidateInfo.ApplicabilityLevel.NOT_APPLICABLE;
}
private static PsiType[] typesAtSite(PsiType[] types1, PsiSubstitutor siteSubstitutor1) {
@NotNull
private static PsiType[] typesAtSite(@NotNull PsiType[] types1, @NotNull PsiSubstitutor siteSubstitutor1) {
final PsiType[] types = PsiType.createArray(types1.length);
for (int i = 0; i < types1.length; i++) {
types[i] = siteSubstitutor1.substitute(types1[i]);
@@ -709,11 +715,12 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
return types;
}
private static PsiSubstitutor calculateMethodSubstitutor(final PsiTypeParameter[] typeParameters,
final PsiMethod method,
final PsiSubstitutor siteSubstitutor,
final PsiType[] types1,
final PsiType[] types2,
@NotNull
private static PsiSubstitutor calculateMethodSubstitutor(@NotNull PsiTypeParameter[] typeParameters,
@NotNull PsiMethod method,
@NotNull PsiSubstitutor siteSubstitutor,
@NotNull PsiType[] types1,
@NotNull PsiType[] types2,
@NotNull LanguageLevel languageLevel) {
PsiSubstitutor substitutor = PsiResolveHelper.SERVICE.getInstance(method.getProject())
.inferTypeArguments(typeParameters, types1, types2, languageLevel);
@@ -742,7 +749,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
return substitutor;
}
public void checkPrimitiveVarargs(final List<CandidateInfo> conflicts,
public void checkPrimitiveVarargs(@NotNull List<CandidateInfo> conflicts,
final int argumentsCount) {
if (JavaVersionService.getInstance().isAtLeast(myArgumentsList, JavaSdkVersion.JDK_1_7)) return;
CandidateInfo objectVararg = null;
@@ -778,7 +785,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
}
@Nullable
private static PsiType getFunctionalType(int functionalTypeIdx, CandidateInfo candidateInfo) {
private static PsiType getFunctionalType(int functionalTypeIdx, @NotNull CandidateInfo candidateInfo) {
final PsiMethod psiMethod = (PsiMethod)candidateInfo.getElement();
LOG.assertTrue(true);
final PsiParameter[] methodParameters = psiMethod.getParameterList().getParameters();
@@ -787,8 +794,9 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
return ((MethodCandidateInfo)candidateInfo).getSiteSubstitutor().substitute(param.getType());
}
private static Specifics isFunctionalTypeMoreSpecific(CandidateInfo method,
CandidateInfo conflict,
@NotNull
private static Specifics isFunctionalTypeMoreSpecific(@NotNull CandidateInfo method,
@NotNull CandidateInfo conflict,
PsiExpression expr,
int functionalInterfaceIdx) {
if (expr instanceof PsiParenthesizedExpression) {
@@ -779,4 +779,12 @@ public class ApplicationInfoImpl extends ApplicationInfoEx implements JDOMExtern
return myDependentPlugin;
}
}
private static volatile boolean myInPerformanceTest;
public static boolean isInPerformanceTest() {
return myInPerformanceTest;
}
public static void setInPerformanceTest(boolean inPerformanceTest) {
myInPerformanceTest = inPerformanceTest;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
package com.intellij.openapi.editor.impl;
import com.intellij.diagnostic.Dumpable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.event.DocumentEvent;
import com.intellij.openapi.util.text.StringUtil;
@@ -39,6 +41,7 @@ import java.util.concurrent.locks.ReentrantLock;
* @author cdr
*/
abstract class CharArray implements CharSequenceBackedByArray, Dumpable {
private static final boolean CHECK_DOCUMENT_CONSISTENCY = ApplicationManager.getApplication() != null && ApplicationManager.getApplication().isUnitTestMode() && !ApplicationInfoImpl.isInPerformanceTest();
private static final Logger LOG = Logger.getInstance("#" + CharArray.class.getName());
@SuppressWarnings("UseOfArchaicSystemPropertyAccessors")
@@ -77,7 +80,7 @@ abstract class CharArray implements CharSequenceBackedByArray, Dumpable {
private final boolean myDebug = isDebug();
boolean isDebug() {
return DEBUG_DEFERRED_PROCESSING || DocumentImpl.CHECK_DOCUMENT_CONSISTENCY;
return DEBUG_DEFERRED_PROCESSING || CHECK_DOCUMENT_CONSISTENCY;
}
/**
@@ -56,7 +56,6 @@ import java.util.List;
public class DocumentImpl extends UserDataHolderBase implements DocumentEx {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.impl.DocumentImpl");
public static boolean CHECK_DOCUMENT_CONSISTENCY = ApplicationManager.getApplication() != null && ApplicationManager.getApplication().isUnitTestMode();
private final Ref<DocumentListener[]> myCachedDocumentListeners = Ref.create(null);
private final List<DocumentListener> myDocumentListeners = ContainerUtil.createLockFreeCopyOnWriteList();
@@ -16,6 +16,7 @@
package com.intellij.openapi.editor.impl;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.event.DocumentEvent;
@@ -37,7 +38,8 @@ import java.util.concurrent.atomic.AtomicInteger;
*/
public class RangeMarkerTree<T extends RangeMarkerEx> extends IntervalTreeImpl<T> {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.impl.RangeMarkerTree");
private static final boolean DEBUG = LOG.isDebugEnabled() || ApplicationManager.getApplication() != null && (ApplicationManager.getApplication().isUnitTestMode() || ApplicationManager.getApplication().isInternal());
private static final boolean DEBUG = LOG.isDebugEnabled() || ApplicationManager.getApplication() != null && (ApplicationManager.getApplication().isUnitTestMode() && !ApplicationInfoImpl
.isInPerformanceTest() || ApplicationManager.getApplication().isInternal());
private final PrioritizedDocumentListener myListener;
private final Document myDocument;
@@ -17,6 +17,7 @@ package com.intellij.openapi.vfs.impl;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.TraceableDisposable;
@@ -51,7 +52,7 @@ public class VirtualFilePointerContainerImpl extends TraceableDisposable impleme
private volatile long myTimeStampOfCachedThings = -1;
@NonNls public static final String URL_ATTR = "url";
private boolean myDisposed;
private static final boolean TRACE_CREATION = LOG.isDebugEnabled() || ApplicationManager.getApplication().isUnitTestMode();
private static final boolean TRACE_CREATION = LOG.isDebugEnabled() || (ApplicationManager.getApplication().isUnitTestMode() && !ApplicationInfoImpl.isInPerformanceTest());
public VirtualFilePointerContainerImpl(@NotNull VirtualFilePointerManager manager,
@NotNull Disposable parentDisposable,
@Nullable VirtualFilePointerListener listener) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@ import com.intellij.lang.LighterASTTokenNode;
import com.intellij.lang.impl.PsiBuilderImpl;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.UserDataHolderBase;
@@ -75,7 +76,7 @@ public class DebugUtil {
public static final boolean DO_EXPENSIVE_CHECKS;
static {
Application application = ApplicationManager.getApplication();
DO_EXPENSIVE_CHECKS = application != null && application.isUnitTestMode();
DO_EXPENSIVE_CHECKS = application != null && application.isUnitTestMode() && !ApplicationInfoImpl.isInPerformanceTest();
}
public static final boolean CHECK_INSIDE_ATOMIC_ACTION_ENABLED = DO_EXPENSIVE_CHECKS;
@@ -26,6 +26,7 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.ex.ApplicationManagerEx;
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
@@ -62,7 +63,7 @@ import java.util.concurrent.atomic.AtomicInteger;
*/
public class PassExecutorService implements Disposable {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.PassExecutorService");
private static final boolean CHECK_CONSISTENCY = ApplicationManager.getApplication().isUnitTestMode();
private static final boolean CHECK_CONSISTENCY = ApplicationManager.getApplication().isUnitTestMode() && !ApplicationInfoImpl.isInPerformanceTest();
private final Map<ScheduledPass, Job<Void>> mySubmittedPasses = new ConcurrentHashMap<ScheduledPass, Job<Void>>();
private final Project myProject;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@ class FilePointerPartNode {
}
boolean getPointersUnder(@NotNull String path, int start, @NotNull List<FilePointerPartNode> out) {
checkStructure();
checkConsistency();
if (pointersUnder == 0) return false;
// invariant: upper nodes are matched
int index = indexOfFirstDifferentChar(path, start);
@@ -76,12 +76,12 @@ class FilePointerPartNode {
return false;
}
void checkStructure() {
void checkConsistency() {
if (!DEBUG) return;
int childSum = 0;
for (FilePointerPartNode child : children) {
childSum += child.pointersUnder;
child.checkStructure();
child.checkConsistency();
assert child.parent == this;
}
if (leaf != null) childSum++;
@@ -37,7 +37,6 @@ import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.io.URLUtil;
import com.intellij.util.messages.MessageBus;
import gnu.trove.THashMap;
import gnu.trove.TObjectHashingStrategy;
import gnu.trove.TObjectIntHashMap;
import gnu.trove.TObjectIntProcedure;
import org.jetbrains.annotations.NonNls;
@@ -196,7 +195,7 @@ public class VirtualFilePointerManagerImpl extends VirtualFilePointerManager imp
String path;
if (file == null) {
path = protocolEnd == -1 ? url : url.substring(protocolEnd + URLUtil.SCHEME_SEPARATOR.length());
path = url.substring(protocolEnd + URLUtil.SCHEME_SEPARATOR.length());
String cleanPath = cleanupPath(path, isJar);
// if newly created path is the same as substringed one then the url did not change, we can reuse it
//noinspection StringEquality
@@ -263,7 +262,7 @@ public class VirtualFilePointerManagerImpl extends VirtualFilePointerManager imp
}
pointer.myNode.incrementUsageCount(1);
root.checkStructure();
root.checkConsistency();
return pointer;
}
@@ -327,7 +326,7 @@ public class VirtualFilePointerManagerImpl extends VirtualFilePointerManager imp
}
}
private void addAllPointers(Collection<VirtualFilePointerImpl> pointers) {
private void addAllPointers(@NotNull Collection<VirtualFilePointerImpl> pointers) {
List<FilePointerPartNode> out = new ArrayList<FilePointerPartNode>();
for (FilePointerPartNode root : myPointers.values()) {
root.getPointersUnder("", 0, out);
@@ -381,9 +380,9 @@ public class VirtualFilePointerManagerImpl extends VirtualFilePointerManager imp
return virtualFilePointerContainer;
}
@Nullable private List<EventDescriptor> myEvents = Collections.emptyList();
@Nullable private List<FilePointerPartNode> myPointersToUpdateUrl = Collections.emptyList();
@Nullable private List<FilePointerPartNode> myPointersToFire = Collections.emptyList();
private List<EventDescriptor> myEvents = Collections.emptyList();
private List<FilePointerPartNode> myPointersToUpdateUrl = Collections.emptyList();
private List<FilePointerPartNode> myPointersToFire = Collections.emptyList();
@Override
public void before(@NotNull final List<? extends VFileEvent> events) {
@@ -518,7 +517,7 @@ public class VirtualFilePointerManagerImpl extends VirtualFilePointerManager imp
myEvents = Collections.emptyList();
myPointersToFire = Collections.emptyList();
for (FilePointerPartNode root : myPointers.values()) {
root.checkStructure();
root.checkConsistency();
}
}
@@ -528,12 +527,12 @@ public class VirtualFilePointerManagerImpl extends VirtualFilePointerManager imp
myPointers.remove(listener);
}
else {
myPointers.get(listener).checkStructure();
myPointers.get(listener).checkConsistency();
}
}
private static class DelegatingDisposable implements Disposable {
private static final ConcurrentMap<Disposable, DelegatingDisposable> ourInstances = new ConcurrentHashMap<Disposable, DelegatingDisposable>(TObjectHashingStrategy.IDENTITY);
private static final ConcurrentMap<Disposable, DelegatingDisposable> ourInstances = new ConcurrentHashMap<Disposable, DelegatingDisposable>(ContainerUtil.<Disposable>identityStrategy());
private final TObjectIntHashMap<VirtualFilePointerImpl> myCounts = new TObjectIntHashMap<VirtualFilePointerImpl>();
private final Disposable myParent;
@@ -23,6 +23,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.roots.OrderEnumerator;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
@@ -67,7 +68,12 @@ public class VfsRootAccess {
return;
}
Set<String> allowed = allowedRoots();
Set<String> allowed = ApplicationManager.getApplication().runReadAction(new Computable<Set<String>>() {
@Override
public Set<String> compute() {
return allowedRoots();
}
});
boolean isUnder = allowed == null || allowed.isEmpty();
if (!isUnder) {
@@ -16,6 +16,7 @@
package com.intellij.openapi.vfs.newvfs.impl;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileAttributes;
@@ -54,7 +55,7 @@ import java.util.List;
public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl");
public static boolean CHECK = ApplicationManager.getApplication().isUnitTestMode();
public static boolean CHECK = ApplicationManager.getApplication().isUnitTestMode() && !ApplicationInfoImpl.isInPerformanceTest();
static final VirtualDirectoryImpl NULL_VIRTUAL_FILE =
new VirtualDirectoryImpl(-42, null, null, null, LocalFileSystem.getInstance()) {
@@ -157,6 +158,7 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
if (name.isEmpty()) return null;
}
VirtualFileSystemEntry child;
synchronized (myData) {
// maybe another doFindChild() sneaked in the middle
if (myData.isAdoptedName(name)) return NULL_VIRTUAL_FILE;
@@ -173,7 +175,7 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
if (id <= 0) {
return null;
}
VirtualFileSystemEntry child = createChild(FileNameCache.storeName(name), id, delegate);
child = createChild(FileNameCache.storeName(name), id, delegate);
int[] after = myData.myChildrenIds;
if (after != array) {
@@ -185,8 +187,15 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
insertChildAt(child, indexInReal);
assertConsistency(!delegate.isCaseSensitive(), name);
}
return child;
}
if (!child.isDirectory()) {
// access check should only be called when child is actually added to the parent, otherwise it may break VirtualFilePointers validity
//noinspection TestOnlyProblems
VfsRootAccess.assertAccessInTests(child, getFileSystem());
}
return child;
}
private VirtualFileSystemEntry[] getArraySafely() {
@@ -419,12 +428,6 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
appended[i] = file.getId();
System.arraycopy(array, i, appended, i + 1, array.length - i);
myData.myChildrenIds = appended;
if (!file.isDirectory()) {
// access check should only be called when child is actually added to the parent, otherwise it may break VirtualFilePointers validity
//noinspection TestOnlyProblems
VfsRootAccess.assertAccessInTests(file, getFileSystem());
}
}
public void removeChild(@NotNull VirtualFile file) {
@@ -538,5 +541,4 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
protected boolean changeUserMap(KeyFMap oldMap, KeyFMap newMap) {
return myData.changeUserMap(oldMap, UserDataInterner.internUserData(newMap));
}
}
@@ -22,6 +22,7 @@ import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.application.ex.PathManagerEx;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.IoTestUtil;
@@ -262,13 +263,13 @@ public class VfsUtilTest extends PlatformLangTestCase {
public void testDirAttributeRefreshes() throws IOException {
File tempDir = createTempDirectory();
VirtualFile vDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempDir);
VirtualFile vDir = refreshAndFindFile(tempDir);
assertNotNull(vDir);
assertTrue(vDir.isDirectory());
File file = FileUtil.createTempFile(tempDir, "xxx", "yyy", true);
assertNotNull(file);
VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
VirtualFile vFile = refreshAndFindFile(file);
assertNotNull(vFile);
assertFalse(vFile.isDirectory());
@@ -278,11 +279,20 @@ public class VfsUtilTest extends PlatformLangTestCase {
assertTrue(created);
assertTrue(file.exists());
VirtualFile vFile2 = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
VirtualFile vFile2 = refreshAndFindFile(file);
assertNotNull(vFile2);
assertTrue(vFile2.isDirectory());
}
private static VirtualFile refreshAndFindFile(final File file) {
return UIUtil.invokeAndWaitIfNeeded(new Computable<VirtualFile>() {
@Override
public VirtualFile compute() {
return LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
}
});
}
public void testPresentableUrlSurvivesDeletion() throws IOException {
final VirtualFile file = createTempFile("txt", null, "content", Charset.defaultCharset());
String url = file.getPresentableUrl();
@@ -360,7 +370,7 @@ public class VfsUtilTest extends PlatformLangTestCase {
public void testFindChildByNamePerformance() throws IOException {
File tempDir = createTempDirectory();
final VirtualFile vDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempDir);
final VirtualFile vDir = refreshAndFindFile(tempDir);
assertNotNull(vDir);
assertTrue(vDir.isDirectory());
@@ -398,7 +408,7 @@ public class VfsUtilTest extends PlatformLangTestCase {
public void testFindRootWithDenormalizedPath() throws IOException {
File tempJar = IoTestUtil.createTestJar();
VirtualFile jar = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempJar);
VirtualFile jar = refreshAndFindFile(tempJar);
assertNotNull(jar);
JarFileSystem fs = JarFileSystem.getInstance();
@@ -410,7 +420,7 @@ public class VfsUtilTest extends PlatformLangTestCase {
public void testFindRootPerformance() throws IOException {
File tempJar = IoTestUtil.createTestJar();
final VirtualFile jar = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempJar);
final VirtualFile jar = refreshAndFindFile(tempJar);
assertNotNull(jar);
final JarFileSystem fs = JarFileSystem.getInstance();
@@ -440,7 +450,7 @@ public class VfsUtilTest extends PlatformLangTestCase {
assertTrue(new File(tempDir, "CssInvalidElement").createNewFile());
assertTrue(new File(tempDir, "extFiles").createNewFile());
VirtualFile vDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempDir);
VirtualFile vDir = refreshAndFindFile(tempDir);
assertNotNull(vDir);
assertTrue(vDir.isDirectory());
@@ -37,6 +37,7 @@ import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ex.ApplicationEx;
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.command.impl.UndoManagerImpl;
import com.intellij.openapi.command.undo.UndoManager;
@@ -344,6 +345,8 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
try {
LightPlatformTestCase.super.setUp();
initApplication();
ApplicationInfoImpl.setInPerformanceTest(isPerformanceTest());
ourApplication.setDataProvider(LightPlatformTestCase.this);
doSetup(new SimpleLightProjectDescriptor(getModuleType(), getProjectJDK()), configureLocalInspectionTools(),
myAvailableInspectionTools);
@@ -27,6 +27,7 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.command.impl.UndoManagerImpl;
@@ -48,8 +49,6 @@ import com.intellij.openapi.project.impl.ProjectManagerImpl;
import com.intellij.openapi.project.impl.TooManyProjectLeakedException;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.ModuleRootModificationUtil;
import com.intellij.openapi.roots.impl.DirectoryIndex;
import com.intellij.openapi.roots.impl.DirectoryIndexImpl;
import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.EmptyRunnable;
@@ -136,13 +135,14 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
autodetectPlatformPrefix();
ourApplication = IdeaTestApplication.getInstance(getApplicationConfigDirPath());
ourApplication.setDataProvider(this);
ApplicationInfoImpl.setInPerformanceTest(isPerformanceTest());
if (firstTime) {
cleanPersistedVFSContent();
}
}
private static String[] PREFIX_CANDIDATES = new String[] {
private static final String[] PREFIX_CANDIDATES = {
"AppCode", "CppIde", "CidrCommon",
"Python", "PyCharmCore", "UltimateLangXml", "Idea" };
@@ -412,8 +412,6 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
}
try {
Project project = getProject();
DirectoryIndexImpl directoryIndex =
project != null ? (DirectoryIndexImpl)DirectoryIndex.getInstance(project) : null;
disposeProject(result);
if (project != null) {
@@ -789,7 +787,7 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
setContentOnDisk(temp, bom, content, charset);
myFilesToDelete.add(temp);
final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(temp);
final VirtualFile file = getVirtualFile(temp);
assert file != null : temp;
return file;
}
@@ -843,7 +841,7 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
protected static VirtualFile createChildData(@NotNull final VirtualFile dir, @NotNull @NonNls final String name) {
return new WriteAction<VirtualFile>() {
@Override
protected void run(Result<VirtualFile> result) throws Throwable {
protected void run(@NotNull Result<VirtualFile> result) throws Throwable {
result.setResult(dir.createChildData(null, name));
}
}.execute().throwException().getResultObject();
@@ -852,7 +850,7 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
protected static VirtualFile createChildDirectory(@NotNull final VirtualFile dir, @NotNull @NonNls final String name) {
return new WriteAction<VirtualFile>() {
@Override
protected void run(Result<VirtualFile> result) throws Throwable {
protected void run(@NotNull Result<VirtualFile> result) throws Throwable {
result.setResult(dir.createChildDirectory(null, name));
}
}.execute().throwException().getResultObject();
@@ -138,8 +138,6 @@ public abstract class UsefulTestCase extends TestCase {
myTempDir = FileUtil.toSystemDependentName(ORIGINAL_TEMP_DIR + "/" + TEMP_DIR_MARKER + testName + "_"+ RNG.nextInt(1000));
FileUtil.resetCanonicalTempPathCache(myTempDir);
}
//noinspection AssignmentToStaticFieldFromInstanceMethod
DocumentImpl.CHECK_DOCUMENT_CONSISTENCY = !isPerformanceTest();
}
@Override