Tests fixed

This commit is contained in:
Andrey Breslav
2011-10-28 22:41:01 +04:00
parent 04d4b8d53d
commit 9c49f551a9
@@ -1,6 +1,7 @@
package org.jetbrains.jet.lang.resolve; package org.jetbrains.jet.lang.resolve;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.compiler.ex.CompilerPathsEx; import com.intellij.openapi.compiler.ex.CompilerPathsEx;
import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.project.Project; import com.intellij.openapi.project.Project;
@@ -131,18 +132,23 @@ public class AnalyzingUtils {
final Project project = file.getProject(); final Project project = file.getProject();
final List<JetDeclaration> namespaces = Lists.newArrayList(); final List<JetDeclaration> namespaces = Lists.newArrayList();
ProjectRootManager rootManager = ProjectRootManager.getInstance(project); ProjectRootManager rootManager = ProjectRootManager.getInstance(project);
VirtualFile[] contentRoots = rootManager.getContentRoots(); if (rootManager != null && !ApplicationManager.getApplication().isUnitTestMode()) {
VirtualFile[] contentRoots = rootManager.getContentRoots();
CompilerPathsEx.visitFiles(contentRoots, new CompilerPathsEx.FileVisitor() { CompilerPathsEx.visitFiles(contentRoots, new CompilerPathsEx.FileVisitor() {
@Override @Override
protected void acceptFile(VirtualFile file, String fileRoot, String filePath) { protected void acceptFile(VirtualFile file, String fileRoot, String filePath) {
if (!(file.getName().endsWith(".kt") || file.getName().endsWith(".kts"))) return; if (!(file.getName().endsWith(".kt") || file.getName().endsWith(".kts"))) return;
PsiFile psiFile = PsiManager.getInstance(project).findFile(file); PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (psiFile instanceof JetFile) { if (psiFile instanceof JetFile) {
namespaces.add(((JetFile) psiFile).getRootNamespace()); namespaces.add(((JetFile) psiFile).getRootNamespace());
}
} }
} });
}); }
else {
namespaces.add(file.getRootNamespace());
}
try { try {
// JetNamespace rootNamespace = file.getRootNamespace(); // JetNamespace rootNamespace = file.getRootNamespace();
BindingContext bindingContext = analyzeNamespaces(project, namespaces, JetControlFlowDataTraceFactory.EMPTY); BindingContext bindingContext = analyzeNamespaces(project, namespaces, JetControlFlowDataTraceFactory.EMPTY);