JetNamespace eliminated
This commit is contained in:
@@ -7,7 +7,7 @@ import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
|
||||
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
||||
import org.jetbrains.jet.lang.diagnostics.Severity;
|
||||
import org.jetbrains.jet.lang.diagnostics.UnresolvedReferenceDiagnostic;
|
||||
import org.jetbrains.jet.lang.psi.JetNamespace;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacade;
|
||||
@@ -132,8 +132,8 @@ public class JetTestUtils {
|
||||
}
|
||||
};
|
||||
|
||||
public static BindingContext analyzeNamespace(@NotNull JetNamespace namespace, @NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||
return AnalyzerFacade.analyzeOneNamespaceWithJavaIntegration(namespace, flowDataTraceFactory);
|
||||
public static BindingContext analyzeFile(@NotNull JetFile namespace, @NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||
return AnalyzerFacade.analyzeOneFileWithJavaIntegration(namespace, flowDataTraceFactory);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ public class ReadClassDataTest extends UsefulTestCase {
|
||||
|
||||
CompileEnvironment.writeToOutputDirectory(classFileFactory, tmpdir.getPath());
|
||||
|
||||
NamespaceDescriptor namespaceFromSource = (NamespaceDescriptor) bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, psiFile.getRootNamespace());
|
||||
NamespaceDescriptor namespaceFromSource = (NamespaceDescriptor) bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, psiFile);
|
||||
|
||||
Assert.assertEquals("test", namespaceFromSource.getName());
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public class JetControlFlowTest extends JetLiteFixture {
|
||||
|
||||
};
|
||||
|
||||
JetTestUtils.analyzeNamespace(file.getRootNamespace(), new JetControlFlowDataTraceFactory() {
|
||||
JetTestUtils.analyzeFile(file, new JetControlFlowDataTraceFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
public JetPseudocodeTrace createTrace(JetElement element) {
|
||||
|
||||
@@ -81,8 +81,8 @@ public class CheckerTestUtilTest extends JetLiteFixture {
|
||||
}
|
||||
|
||||
public void test(final @NotNull PsiFile psiFile) {
|
||||
BindingContext bindingContext = AnalyzerFacade.analyzeOneNamespaceWithJavaIntegration(
|
||||
((JetFile) psiFile).getRootNamespace(),
|
||||
BindingContext bindingContext = AnalyzerFacade.analyzeOneFileWithJavaIntegration(
|
||||
(JetFile) psiFile,
|
||||
JetControlFlowDataTraceFactory.EMPTY);
|
||||
|
||||
String expectedText = CheckerTestUtil.addDiagnosticMarkersToText(psiFile, CheckerTestUtil.getDiagnosticsIncludingSyntaxErrors(bindingContext, psiFile)).toString();
|
||||
|
||||
@@ -13,7 +13,6 @@ import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.lang.Configuration;
|
||||
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
|
||||
import org.jetbrains.jet.lang.psi.JetDeclaration;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
@@ -96,17 +95,17 @@ public class JetDiagnosticsTest extends JetLiteFixture {
|
||||
boolean importJdk = expectedText.contains("+JDK");
|
||||
// Configuration configuration = importJdk ? JavaBridgeConfiguration.createJavaBridgeConfiguration(getProject()) : Configuration.EMPTY;
|
||||
|
||||
List<JetDeclaration> namespaces = Lists.newArrayList();
|
||||
List<JetFile> jetFiles = Lists.newArrayList();
|
||||
for (TestFile testFileFile : testFileFiles) {
|
||||
namespaces.add(testFileFile.jetFile.getRootNamespace());
|
||||
jetFiles.add(testFileFile.jetFile);
|
||||
}
|
||||
|
||||
BindingContext bindingContext;
|
||||
if (importJdk) {
|
||||
bindingContext = AnalyzerFacade.analyzeNamespacesWithJavaIntegration(getProject(), namespaces, Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY);
|
||||
bindingContext = AnalyzerFacade.analyzeFilesWithJavaIntegration(getProject(), jetFiles, Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY);
|
||||
}
|
||||
else {
|
||||
bindingContext = AnalyzingUtils.analyzeNamespaces(getProject(), Configuration.EMPTY, namespaces, Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY);
|
||||
bindingContext = AnalyzingUtils.analyzeFiles(getProject(), Configuration.EMPTY, jetFiles, Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY);
|
||||
}
|
||||
|
||||
StringBuilder actualText = new StringBuilder();
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
import org.jetbrains.jet.lang.psi.JetNamespace;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetLiteFixture;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetNamespace;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiUtil;
|
||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
||||
import org.jetbrains.jet.parsing.JetParsingTest;
|
||||
@@ -91,8 +90,7 @@ public abstract class CodegenTestCase extends JetLiteFixture {
|
||||
ClassFileFactory codegens = generateClassesInFile();
|
||||
GeneratedClassLoader loader = new GeneratedClassLoader(codegens);
|
||||
|
||||
final JetNamespace namespace = myFile.getRootNamespace();
|
||||
String fqName = NamespaceCodegen.getJVMClassName(JetPsiUtil.getFQName(namespace)).replace("/", ".");
|
||||
String fqName = NamespaceCodegen.getJVMClassName(JetPsiUtil.getFQName(myFile)).replace("/", ".");
|
||||
Class<?> namespaceClass = loader.loadClass(fqName);
|
||||
Method method = namespaceClass.getMethod("box");
|
||||
return (String) method.invoke(null);
|
||||
@@ -112,8 +110,7 @@ public abstract class CodegenTestCase extends JetLiteFixture {
|
||||
}
|
||||
|
||||
protected Class loadRootNamespaceClass(ClassFileFactory state) {
|
||||
final JetNamespace namespace = myFile.getRootNamespace();
|
||||
String fqName = NamespaceCodegen.getJVMClassName(JetPsiUtil.getFQName(namespace)).replace("/", ".");
|
||||
String fqName = NamespaceCodegen.getJVMClassName(JetPsiUtil.getFQName(myFile)).replace("/", ".");
|
||||
Map<String, Class> classMap = loadAllClasses(state);
|
||||
return classMap.get(fqName);
|
||||
}
|
||||
|
||||
@@ -1,20 +1,7 @@
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.jet.compiler.CompileEnvironment;
|
||||
import org.jetbrains.jet.compiler.CompileSession;
|
||||
import org.jetbrains.jet.lang.psi.JetNamespace;
|
||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
||||
import org.jetbrains.jet.parsing.JetParsingTest;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author alex.tkachman
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.jetbrains.jet.resolve;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -23,7 +22,6 @@ import org.jetbrains.jet.lang.types.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeConstructor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -122,12 +120,7 @@ public abstract class ExpectedResolveData {
|
||||
JetSemanticServices semanticServices = JetSemanticServices.createSemanticServices(project);
|
||||
JetStandardLibrary lib = semanticServices.getStandardLibrary();
|
||||
|
||||
List<JetDeclaration> declarations = Lists.newArrayList();
|
||||
for (JetFile file : files) {
|
||||
declarations.add(file.getRootNamespace());
|
||||
}
|
||||
|
||||
BindingContext bindingContext = AnalyzerFacade.analyzeNamespacesWithJavaIntegration(project, declarations, Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY);
|
||||
BindingContext bindingContext = AnalyzerFacade.analyzeFilesWithJavaIntegration(project, files, Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY);
|
||||
for (Diagnostic diagnostic : bindingContext.getDiagnostics()) {
|
||||
if (diagnostic instanceof UnresolvedReferenceDiagnostic) {
|
||||
UnresolvedReferenceDiagnostic unresolvedReferenceDiagnostic = (UnresolvedReferenceDiagnostic) diagnostic;
|
||||
@@ -135,15 +128,20 @@ public abstract class ExpectedResolveData {
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, JetDeclaration> nameToDeclaration = new HashMap<String, JetDeclaration>();
|
||||
Map<String, PsiElement> nameToDeclaration = Maps.newHashMap();
|
||||
|
||||
Map<JetDeclaration, String> declarationToName = new HashMap<JetDeclaration, String>();
|
||||
Map<PsiElement, String> declarationToName = Maps.newHashMap();
|
||||
for (Map.Entry<String, Position> entry : declarationToPosition.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
Position position = entry.getValue();
|
||||
PsiElement element = position.getElement();
|
||||
|
||||
JetDeclaration ancestorOfType = getAncestorOfType(JetDeclaration.class, element);
|
||||
PsiElement ancestorOfType = getAncestorOfType(JetDeclaration.class, element);
|
||||
if (ancestorOfType == null) {
|
||||
JetNamespaceHeader header = getAncestorOfType(JetNamespaceHeader.class, element);
|
||||
assert header != null : "Not a declaration: " + name;
|
||||
ancestorOfType = header.getContainingFile();
|
||||
}
|
||||
nameToDeclaration.put(name, ancestorOfType);
|
||||
declarationToName.put(ancestorOfType, name);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
||||
|
||||
private JetScope createScope(JetScope libraryScope) {
|
||||
JetFile file = JetPsiFactory.createFile(getProject(), "abstract class C { abstract fun foo(); abstract val a: Int }");
|
||||
List<JetDeclaration> declarations = file.getRootNamespace().getDeclarations();
|
||||
List<JetDeclaration> declarations = file.getDeclarations();
|
||||
JetDeclaration aClass = declarations.get(0);
|
||||
assert aClass instanceof JetClass;
|
||||
BindingContext bindingContext = AnalyzerFacade.analyzeFileWithCache(file, AnalyzerFacade.SINGLE_DECLARATION_PROVIDER);
|
||||
|
||||
Reference in New Issue
Block a user