Skip to content

Commit d5af3a4

Browse files
committed
merge
1 parent b82266d commit d5af3a4

8 files changed

Lines changed: 676 additions & 491 deletions

File tree

java-execution-api/src/com/intellij/execution/filters/ExceptionFilter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@
2121

2222
public class ExceptionFilter implements Filter, DumbAware
2323
{
24-
private final GlobalSearchScope myScope;
24+
private final ExceptionInfoCache myCache;
2525

2626
public ExceptionFilter(@NotNull final GlobalSearchScope scope)
2727
{
28-
myScope = scope;
28+
myCache = new ExceptionInfoCache(scope);
2929
}
3030

3131
@Override
3232
public Result applyFilter(final String line, final int textEndOffset)
3333
{
34-
ExceptionWorker worker = new ExceptionWorker(myScope.getProject(), myScope);
34+
ExceptionWorker worker = new ExceptionWorker(myCache);
3535
worker.execute(line, textEndOffset);
3636
return worker.getResult();
3737
}

java-execution-api/src/com/intellij/execution/filters/ExceptionFilterFactory.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,20 @@
1515
*/
1616
package com.intellij.execution.filters;
1717

18+
import org.jetbrains.annotations.NotNull;
1819
import com.intellij.openapi.extensions.ExtensionPointName;
1920
import com.intellij.psi.search.GlobalSearchScope;
20-
import org.jetbrains.annotations.NotNull;
2121

2222
/**
2323
* Created by IntelliJ IDEA.
2424
* User: Irina.Chernushina
2525
* Date: 8/5/11
2626
* Time: 7:46 PM
2727
*/
28-
public interface ExceptionFilterFactory {
29-
ExtensionPointName<ExceptionFilterFactory> EP_NAME = ExtensionPointName.create("org.consulo.java.exceptionFilter");
28+
public interface ExceptionFilterFactory
29+
{
30+
ExtensionPointName<ExceptionFilterFactory> EP_NAME = ExtensionPointName.create("org.consulo.java.exceptionFilter");
3031

31-
@NotNull
32-
Filter create(@NotNull GlobalSearchScope searchScope);
32+
@NotNull
33+
Filter create(@NotNull GlobalSearchScope searchScope);
3334
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* Copyright 2000-2014 JetBrains s.r.o.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.intellij.execution.filters;
17+
18+
import java.util.concurrent.ConcurrentMap;
19+
20+
import org.jetbrains.annotations.NotNull;
21+
import com.intellij.openapi.project.DumbService;
22+
import com.intellij.openapi.project.Project;
23+
import com.intellij.openapi.util.Pair;
24+
import com.intellij.psi.JavaPsiFacade;
25+
import com.intellij.psi.PsiClass;
26+
import com.intellij.psi.PsiFile;
27+
import com.intellij.psi.search.GlobalSearchScope;
28+
import com.intellij.util.ObjectUtil;
29+
import com.intellij.util.containers.ContainerUtil;
30+
31+
/**
32+
* @author peter
33+
*/
34+
public class ExceptionInfoCache
35+
{
36+
private final ConcurrentMap<String, Pair<PsiClass[], PsiFile[]>> myCache = ContainerUtil.createConcurrentSoftValueMap();
37+
private final Project myProject;
38+
private final GlobalSearchScope mySearchScope;
39+
40+
public ExceptionInfoCache(GlobalSearchScope searchScope)
41+
{
42+
myProject = ObjectUtil.assertNotNull(searchScope.getProject());
43+
mySearchScope = searchScope;
44+
}
45+
46+
@NotNull
47+
public Project getProject()
48+
{
49+
return myProject;
50+
}
51+
52+
@NotNull
53+
private PsiClass[] findClassesPreferringMyScope(String className)
54+
{
55+
JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(myProject);
56+
PsiClass[] result = psiFacade.findClasses(className, mySearchScope);
57+
return result.length != 0 ? result : psiFacade.findClasses(className, GlobalSearchScope.allScope(myProject));
58+
}
59+
60+
Pair<PsiClass[], PsiFile[]> resolveClass(String className)
61+
{
62+
Pair<PsiClass[], PsiFile[]> cached = myCache.get(className);
63+
if(cached != null)
64+
{
65+
return cached;
66+
}
67+
68+
if(DumbService.isDumb(myProject))
69+
{
70+
return Pair.create(PsiClass.EMPTY_ARRAY, PsiFile.EMPTY_ARRAY);
71+
}
72+
73+
PsiClass[] classes = findClassesPreferringMyScope(className);
74+
if(classes.length == 0)
75+
{
76+
final int dollarIndex = className.indexOf('$');
77+
if(dollarIndex >= 0)
78+
{
79+
classes = findClassesPreferringMyScope(className.substring(0, dollarIndex));
80+
}
81+
}
82+
83+
PsiFile[] files = new PsiFile[classes.length];
84+
for(int i = 0; i < classes.length; i++)
85+
{
86+
files[i] = (PsiFile) classes[i].getContainingFile().getNavigationElement();
87+
}
88+
89+
Pair<PsiClass[], PsiFile[]> result = Pair.create(classes, files);
90+
myCache.put(className, result);
91+
return result;
92+
}
93+
94+
}

0 commit comments

Comments
 (0)