From 9c49f551a97e462374a2434b6a6041bf2a0214f4 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Fri, 28 Oct 2011 22:41:01 +0400 Subject: [PATCH] Tests fixed --- .../jet/lang/resolve/AnalyzingUtils.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java index 9a4e22e6374..70178295035 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java @@ -1,6 +1,7 @@ package org.jetbrains.jet.lang.resolve; import com.google.common.collect.Lists; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.compiler.ex.CompilerPathsEx; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.project.Project; @@ -131,18 +132,23 @@ public class AnalyzingUtils { final Project project = file.getProject(); final List namespaces = Lists.newArrayList(); 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() { - @Override - protected void acceptFile(VirtualFile file, String fileRoot, String filePath) { - if (!(file.getName().endsWith(".kt") || file.getName().endsWith(".kts"))) return; - PsiFile psiFile = PsiManager.getInstance(project).findFile(file); - if (psiFile instanceof JetFile) { - namespaces.add(((JetFile) psiFile).getRootNamespace()); + CompilerPathsEx.visitFiles(contentRoots, new CompilerPathsEx.FileVisitor() { + @Override + protected void acceptFile(VirtualFile file, String fileRoot, String filePath) { + if (!(file.getName().endsWith(".kt") || file.getName().endsWith(".kts"))) return; + PsiFile psiFile = PsiManager.getInstance(project).findFile(file); + if (psiFile instanceof JetFile) { + namespaces.add(((JetFile) psiFile).getRootNamespace()); + } } - } - }); + }); + } + else { + namespaces.add(file.getRootNamespace()); + } try { // JetNamespace rootNamespace = file.getRootNamespace(); BindingContext bindingContext = analyzeNamespaces(project, namespaces, JetControlFlowDataTraceFactory.EMPTY);