From bb7108ca4201bdd877f595e53e74bc2e391a8859 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Mon, 18 Jan 2010 21:01:38 +0300 Subject: [PATCH] Make: heuristics for processing removed constant fields added. If precise analysis (resolve) takes too long to complete, skip it and mark for recompilation all files where identifiers were found --- .../make/ChangedConstantsDependencyProcessor.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/make/ChangedConstantsDependencyProcessor.java b/java/compiler/impl/src/com/intellij/compiler/make/ChangedConstantsDependencyProcessor.java index 380ca77f4d62..ce11da5d72bb 100644 --- a/java/compiler/impl/src/com/intellij/compiler/make/ChangedConstantsDependencyProcessor.java +++ b/java/compiler/impl/src/com/intellij/compiler/make/ChangedConstantsDependencyProcessor.java @@ -45,6 +45,7 @@ class ChangedConstantsDependencyProcessor { private final int myQName; private final FieldChangeInfo[] myChangedFields; private final FieldChangeInfo[] myRemovedFields; + private static final long ANALYSIS_DURATION_THRESHOLD_MILLIS = 30000L /*30 sec*/; public ChangedConstantsDependencyProcessor(Project project, CachingSearcher searcher, DependencyCache dependencyCache, int qName, FieldChangeInfo[] changedFields, FieldChangeInfo[] removedFields) { @@ -106,13 +107,18 @@ class ChangedConstantsDependencyProcessor { } } final PsiSearchHelper psiSearchHelper = PsiManager.getInstance(myProject).getSearchHelper(); + + final long analysisStart = System.currentTimeMillis(); + boolean skipResolve = false; + PsiIdentifier[] identifiers = findIdentifiers(psiSearchHelper, myDependencyCache.resolve(info.getName()), searchScope, UsageSearchContext.IN_CODE); for (PsiIdentifier identifier : identifiers) { PsiElement parent = identifier.getParent(); if (parent instanceof PsiReferenceExpression) { PsiReferenceExpression refExpr = (PsiReferenceExpression)parent; PsiReference reference = refExpr.getReference(); - if (reference.resolve() == null) { + skipResolve = skipResolve || (System.currentTimeMillis() - analysisStart) > ANALYSIS_DURATION_THRESHOLD_MILLIS; + if (skipResolve || reference == null || reference.resolve() == null) { PsiClass ownerClass = getOwnerClass(refExpr); if (ownerClass != null && !ownerClass.equals(aClass)) { int qualifiedName = myDependencyCache.getSymbolTable().getId(ownerClass.getQualifiedName());