Merge remote branch 'origin/master'

This commit is contained in:
Alex Tkachman
2011-12-27 21:08:22 +02:00
233 changed files with 31636 additions and 32308 deletions
-1
View File
@@ -15,7 +15,6 @@
<entry name="?*.tld" /> <entry name="?*.tld" />
<entry name="?*.ftl" /> <entry name="?*.ftl" />
<entry name="?*.jet" /> <entry name="?*.jet" />
<entry name="/**/?*.kt" />
</wildcardResourcePatterns> </wildcardResourcePatterns>
<annotationProcessing enabled="false" useClasspath="true" /> <annotationProcessing enabled="false" useClasspath="true" />
</component> </component>
-1
View File
@@ -11,7 +11,6 @@
<module fileurl="file://$PROJECT_DIR$/compiler/frontend.java/frontend.java.iml" filepath="$PROJECT_DIR$/compiler/frontend.java/frontend.java.iml" /> <module fileurl="file://$PROJECT_DIR$/compiler/frontend.java/frontend.java.iml" filepath="$PROJECT_DIR$/compiler/frontend.java/frontend.java.iml" />
<module fileurl="file://$PROJECT_DIR$/grammar/grammar.iml" filepath="$PROJECT_DIR$/grammar/grammar.iml" /> <module fileurl="file://$PROJECT_DIR$/grammar/grammar.iml" filepath="$PROJECT_DIR$/grammar/grammar.iml" />
<module fileurl="file://$PROJECT_DIR$/idea/idea.iml" filepath="$PROJECT_DIR$/idea/idea.iml" /> <module fileurl="file://$PROJECT_DIR$/idea/idea.iml" filepath="$PROJECT_DIR$/idea/idea.iml" />
<module fileurl="file://$PROJECT_DIR$/shift/shift.iml" filepath="$PROJECT_DIR$/shift/shift.iml" />
<module fileurl="file://$PROJECT_DIR$/stdlib/stdlib.iml" filepath="$PROJECT_DIR$/stdlib/stdlib.iml" /> <module fileurl="file://$PROJECT_DIR$/stdlib/stdlib.iml" filepath="$PROJECT_DIR$/stdlib/stdlib.iml" />
</modules> </modules>
</component> </component>
+4 -44
View File
@@ -3,13 +3,9 @@
<property name="build.number" value="snapshot"/> <property name="build.number" value="snapshot"/>
<property name="output.name" value="kotlin-${build.number}"/> <property name="output.name" value="kotlin-${build.number}"/>
<path id="libs"> <path id="classpath">
<fileset dir="${basedir}/ideaSDK" includes="*.jar"/> <fileset dir="${basedir}/ideaSDK" includes="*.jar"/>
<fileset dir="${basedir}/lib" includes="*.jar"/> <fileset dir="${basedir}/lib" includes="*.jar"/>
</path>
<path id="classpath">
<path refid="libs"/>
<pathelement path="${output}/classes/runtime"/> <pathelement path="${output}/classes/runtime"/>
</path> </path>
@@ -43,23 +39,14 @@
<arg value="${basedir}/stdlib/ktSrc"/> <arg value="${basedir}/stdlib/ktSrc"/>
<arg value="-output"/> <arg value="-output"/>
<arg value="${basedir}/classes/stdlib"/> <arg value="${basedir}/classes/stdlib"/>
<arg value="-stdlib"/>
</java> </java>
</target> </target>
<target name="compileTests" depends="compile"> <target name="jarRT" depends="compile">
<mkdir dir="${output}/classes/tests"/>
<javac destdir="${output}/classes/tests" debug="true" debuglevel="lines,vars,source">
<src path="${basedir}/compiler/tests"/>
<classpath refid="classpath.kotlin"/>
</javac>
</target>
<target name="jarRT" depends="compileStdlib">
<jar destfile="${output}/kotlin-runtime.jar"> <jar destfile="${output}/kotlin-runtime.jar">
<fileset dir="${output}/classes/runtime"/> <fileset dir="${output}/classes/runtime"/>
<fileset dir="${output}/classes/stdlib"/> <!--<fileset dir="${output}/classes/stdlib"/>-->
<fileset dir="${basedir}/stdlib/ktSrc/" includes="**/*"/> <fileset dir="${basedir}" includes="stdlib/ktSrc/**/*"/>
</jar> </jar>
</target> </target>
@@ -70,7 +57,6 @@
<src refid="sourcepath"/> <src refid="sourcepath"/>
<classpath refid="classpath"/> <classpath refid="classpath"/>
</javac> </javac>
<copy file="${basedir}/compiler/frontend/src/jet/Library.jet" tofile="${output}/classes/compiler/jet/Library.jet"/>
</target> </target>
<target name="jar" depends="compile"> <target name="jar" depends="compile">
@@ -84,32 +70,6 @@
<delete dir="${output}"/> <delete dir="${output}"/>
</target> </target>
<target name="test" depends="compileTests,jar,jarRT">
<mkdir dir="${output}/reports"/>
<junit printsummary="yes" haltonerror="false" haltonfailure="false">
<classpath>
<pathelement location="${output}/kotlin-compiler.jar"/>
<pathelement location="${output}/kotlin-runtime.jar"/>
<pathelement location="${output}/classes/tests"/>
<path refid="classpath"/>
</classpath>
<formatter type="brief"/>
<formatter type="xml"/>
<batchtest todir="${output}/reports">
<fileset dir="${basedir}/compiler/tests">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
<junitreport>
<fileset dir="${output}/reports" includes="TEST-*.xml"/>
<report format="frames" todir="${output}/reports/html"/>
</junitreport>
</target>
<target name="dist" depends="clean,jarRT,jar"> <target name="dist" depends="clean,jarRT,jar">
<zip destfile="${output}/${output.name}.zip"> <zip destfile="${output}/${output.name}.zip">
<zipfileset prefix="${output.name}/bin" filemode="755" dir="${basedir}/compiler/cli/bin"/> <zipfileset prefix="${output.name}/bin" filemode="755" dir="${basedir}/compiler/cli/bin"/>
@@ -1,6 +1,6 @@
package org.jetbrains.jet.codegen; package org.jetbrains.jet.codegen;
import org.jetbrains.jet.lang.psi.JetNamespace; import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.psi.JetPsiUtil; import org.jetbrains.jet.lang.psi.JetPsiUtil;
import java.util.*; import java.util.*;
@@ -30,13 +30,13 @@ public class ClassFileFactory {
return newVisitor(className + ".class"); return newVisitor(className + ".class");
} }
NamespaceCodegen forNamespace(JetNamespace namespace) { NamespaceCodegen forNamespace(JetFile file) {
assert !isDone : "Already done!"; assert !isDone : "Already done!";
String fqName = JetPsiUtil.getFQName(namespace); String fqName = JetPsiUtil.getFQName(file);
NamespaceCodegen codegen = ns2codegen.get(fqName); NamespaceCodegen codegen = ns2codegen.get(fqName);
if (codegen == null) { if (codegen == null) {
final ClassBuilder builder = newVisitor(NamespaceCodegen.getJVMClassName(fqName) + ".class"); final ClassBuilder builder = newVisitor(NamespaceCodegen.getJVMClassName(fqName) + ".class");
codegen = new NamespaceCodegen(builder, fqName, state, namespace.getContainingFile()); codegen = new NamespaceCodegen(builder, fqName, state, file.getContainingFile());
ns2codegen.put(fqName, codegen); ns2codegen.put(fqName, codegen);
} }
@@ -6,6 +6,7 @@ package org.jetbrains.jet.codegen;
import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project; import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.Pair;
import com.intellij.psi.PsiElement;
import com.intellij.util.containers.Stack; import com.intellij.util.containers.Stack;
import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethods; import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethods;
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
@@ -78,15 +79,14 @@ public class GenerationState {
return Pair.create(className, factory.forAnonymousSubclass(className)); return Pair.create(className, factory.forAnonymousSubclass(className));
} }
public NamespaceCodegen forNamespace(JetNamespace namespace) { public NamespaceCodegen forNamespace(JetFile namespace) {
return factory.forNamespace(namespace); return factory.forNamespace(namespace);
} }
public BindingContext compile(JetFile psiFile) { public BindingContext compile(JetFile file) {
final JetNamespace namespace = psiFile.getRootNamespace(); final BindingContext bindingContext = AnalyzerFacade.analyzeOneFileWithJavaIntegration(file, JetControlFlowDataTraceFactory.EMPTY);
final BindingContext bindingContext = AnalyzerFacade.analyzeOneNamespaceWithJavaIntegration(namespace, JetControlFlowDataTraceFactory.EMPTY);
AnalyzingUtils.throwExceptionOnErrors(bindingContext); AnalyzingUtils.throwExceptionOnErrors(bindingContext);
compileCorrectNamespaces(bindingContext, Collections.singletonList(namespace)); compileCorrectFiles(bindingContext, Collections.singletonList(file));
return bindingContext; return bindingContext;
// NamespaceCodegen codegen = forNamespace(namespace); // NamespaceCodegen codegen = forNamespace(namespace);
// bindingContexts.push(bindingContext); // bindingContexts.push(bindingContext);
@@ -102,15 +102,15 @@ public class GenerationState {
// } // }
} }
public void compileCorrectNamespaces(BindingContext bindingContext, List<JetNamespace> namespaces) { public void compileCorrectFiles(BindingContext bindingContext, List<JetFile> files) {
compileCorrectNamespaces(bindingContext, namespaces, CompilationErrorHandler.THROW_EXCEPTION); compileCorrectFiles(bindingContext, files, CompilationErrorHandler.THROW_EXCEPTION);
} }
public void compileCorrectNamespaces(BindingContext bindingContext, List<JetNamespace> namespaces, CompilationErrorHandler errorHandler) { public void compileCorrectFiles(BindingContext bindingContext, List<JetFile> files, CompilationErrorHandler errorHandler) {
typeMapper = new JetTypeMapper(standardLibrary, bindingContext); typeMapper = new JetTypeMapper(standardLibrary, bindingContext);
bindingContexts.push(bindingContext); bindingContexts.push(bindingContext);
try { try {
for (JetNamespace namespace : namespaces) { for (JetFile namespace : files) {
try { try {
generateNamespace(namespace); generateNamespace(namespace);
} }
@@ -129,7 +129,7 @@ public class GenerationState {
} }
} }
protected void generateNamespace(JetNamespace namespace) { protected void generateNamespace(JetFile namespace) {
NamespaceCodegen codegen = forNamespace(namespace); NamespaceCodegen codegen = forNamespace(namespace);
codegen.generate(namespace); codegen.generate(namespace);
} }
@@ -149,8 +149,8 @@ public class GenerationState {
return new GeneratedAnonymousClassDescriptor(nameAndVisitor.first, callableMethod.getSignature().getAsmMethod(), objectContext.outerWasUsed, null); return new GeneratedAnonymousClassDescriptor(nameAndVisitor.first, callableMethod.getSignature().getAsmMethod(), objectContext.outerWasUsed, null);
} }
public static void prepareAnonymousClasses(JetElement aClass, final JetTypeMapper typeMapper) { public static void prepareAnonymousClasses(PsiElement element, final JetTypeMapper typeMapper) {
aClass.acceptChildren(new JetVisitorVoid() { element.acceptChildren(new JetVisitorVoid() {
@Override @Override
public void visitJetElement(JetElement element) { public void visitJetElement(JetElement element) {
super.visitJetElement(element); super.visitJetElement(element);
@@ -619,6 +619,11 @@ public class JetTypeMapper {
signatureVisitor.writeInterfaceBoundEnd(); signatureVisitor.writeInterfaceBoundEnd();
} }
} }
if (jetType.getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptor) {
signatureVisitor.writeInterfaceBound();
mapType(jetType, signatureVisitor);
signatureVisitor.writeInterfaceBoundEnd();
}
} }
signatureVisitor.writeFormalTypeParameterEnd(); signatureVisitor.writeFormalTypeParameterEnd();
@@ -753,11 +758,12 @@ public class JetTypeMapper {
return name; return name;
} }
@SuppressWarnings("unchecked") JetNamedDeclaration container = PsiTreeUtil.getParentOfType(expression, JetNamespace.class, JetClass.class, JetObjectDeclaration.class); @SuppressWarnings("unchecked")
PsiElement container = PsiTreeUtil.getParentOfType(expression, JetFile.class, JetClass.class, JetObjectDeclaration.class);
String baseName; String baseName;
if (container instanceof JetNamespace) { if (container instanceof JetFile) {
baseName = NamespaceCodegen.getJVMClassName(JetPsiUtil.getFQName(((JetNamespace) container))); baseName = NamespaceCodegen.getJVMClassName(JetPsiUtil.getFQName(((JetFile) container)));
} }
else { else {
ClassDescriptor aClass = bindingContext.get(BindingContext.CLASS, container); ClassDescriptor aClass = bindingContext.get(BindingContext.CLASS, container);
@@ -43,8 +43,8 @@ public class NamespaceCodegen {
v.visitSource(sourceFile.getName(), null); v.visitSource(sourceFile.getName(), null);
} }
public void generate(JetNamespace namespace) { public void generate(JetFile file) {
NamespaceDescriptor descriptor = state.getBindingContext().get(BindingContext.NAMESPACE, namespace); NamespaceDescriptor descriptor = state.getBindingContext().get(BindingContext.NAMESPACE, file);
final CodegenContext context = CodegenContext.STATIC.intoNamespace(descriptor); final CodegenContext context = CodegenContext.STATIC.intoNamespace(descriptor);
final FunctionCodegen functionCodegen = new FunctionCodegen(context, v, state); final FunctionCodegen functionCodegen = new FunctionCodegen(context, v, state);
@@ -52,10 +52,10 @@ public class NamespaceCodegen {
final ClassCodegen classCodegen = state.forClass(); final ClassCodegen classCodegen = state.forClass();
if (v.generateCode()) { if (v.generateCode()) {
GenerationState.prepareAnonymousClasses(namespace, state.getTypeMapper()); GenerationState.prepareAnonymousClasses(file, state.getTypeMapper());
} }
for (JetDeclaration declaration : namespace.getDeclarations()) { for (JetDeclaration declaration : file.getDeclarations()) {
if (declaration instanceof JetProperty) { if (declaration instanceof JetProperty) {
propertyCodegen.gen((JetProperty) declaration); propertyCodegen.gen((JetProperty) declaration);
} }
@@ -72,20 +72,20 @@ public class NamespaceCodegen {
else if (declaration instanceof JetClassOrObject) { else if (declaration instanceof JetClassOrObject) {
classCodegen.generate(context, (JetClassOrObject) declaration); classCodegen.generate(context, (JetClassOrObject) declaration);
} }
else if (declaration instanceof JetNamespace) { // else if (declaration instanceof JetFile) {
JetNamespace childNamespace = (JetNamespace) declaration; // JetFile childNamespace = (JetFile) declaration;
state.forNamespace(childNamespace).generate(childNamespace); // state.forNamespace(childNamespace).generate(childNamespace);
} // }
} }
if (hasNonConstantPropertyInitializers(namespace)) { if (hasNonConstantPropertyInitializers(file)) {
generateStaticInitializers(namespace); generateStaticInitializers(file);
} }
generateTypeInfoFields(namespace, context); generateTypeInfoFields(file, context);
} }
private void generateStaticInitializers(JetNamespace namespace) { private void generateStaticInitializers(JetFile namespace) {
MethodVisitor mv = v.newMethod(namespace, ACC_PUBLIC | ACC_STATIC, MethodVisitor mv = v.newMethod(namespace, ACC_PUBLIC | ACC_STATIC,
"<clinit>", "()V", null, null); "<clinit>", "()V", null, null);
if (v.generateCode()) { if (v.generateCode()) {
@@ -115,9 +115,9 @@ public class NamespaceCodegen {
} }
} }
private void generateTypeInfoFields(JetNamespace namespace, CodegenContext context) { private void generateTypeInfoFields(JetFile file, CodegenContext context) {
if(context.typeInfoConstants != null) { if(context.typeInfoConstants != null) {
String jvmClassName = getJVMClassName(namespace.getName()); String jvmClassName = getJVMClassName(file.getNamespaceHeader().getName());
for(int index = 0; index != context.typeInfoConstantsCount; index++) { for(int index = 0; index != context.typeInfoConstantsCount; index++) {
JetType type = context.reverseTypeInfoConstants.get(index); JetType type = context.reverseTypeInfoConstants.get(index);
String fieldName = "$typeInfoCache$" + index; String fieldName = "$typeInfoCache$" + index;
@@ -137,7 +137,7 @@ public class NamespaceCodegen {
v.visitFieldInsn(PUTSTATIC, jvmClassName, fieldName, "Ljet/TypeInfo;"); v.visitFieldInsn(PUTSTATIC, jvmClassName, fieldName, "Ljet/TypeInfo;");
v.visitLabel(end); v.visitLabel(end);
v.visitInsn(ARETURN); v.visitInsn(ARETURN);
FunctionCodegen.endVisit(v, "type info method", namespace); FunctionCodegen.endVisit(v, "type info method", file);
} }
} }
} }
@@ -187,7 +187,7 @@ public class NamespaceCodegen {
} }
} }
private static boolean hasNonConstantPropertyInitializers(JetNamespace namespace) { private static boolean hasNonConstantPropertyInitializers(JetFile namespace) {
for (JetDeclaration declaration : namespace.getDeclarations()) { for (JetDeclaration declaration : namespace.getDeclarations()) {
if (declaration instanceof JetProperty) { if (declaration instanceof JetProperty) {
final JetExpression initializer = ((JetProperty) declaration).getInitializer(); final JetExpression initializer = ((JetProperty) declaration).getInitializer();
@@ -1,19 +1,20 @@
package org.jetbrains.jet.compiler; package org.jetbrains.jet.compiler;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.PathManager; import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFileSystem;
import com.intellij.util.Function; import com.intellij.util.Function;
import com.intellij.util.Processor; import com.intellij.util.Processor;
import jet.ExtensionFunction0; import jet.ExtensionFunction0;
import jet.modules.IModuleBuilder; import jet.modules.IModuleBuilder;
import jet.modules.IModuleSetBuilder; import jet.modules.IModuleSetBuilder;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.JetCoreEnvironment;
import org.jetbrains.jet.codegen.ClassFileFactory; import org.jetbrains.jet.codegen.ClassFileFactory;
import org.jetbrains.jet.codegen.GeneratedClassLoader; import org.jetbrains.jet.codegen.GeneratedClassLoader;
import org.jetbrains.jet.lang.psi.JetNamespace; import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.psi.JetPsiUtil; import org.jetbrains.jet.lang.psi.JetPsiUtil;
import org.jetbrains.jet.plugin.JetMainDetector; import org.jetbrains.jet.plugin.JetMainDetector;
@@ -26,12 +27,73 @@ import java.util.List;
import java.util.jar.*; import java.util.jar.*;
/** /**
* @author alex.tkachman * The environment for compiling a bunch of source files or
*
* @author yole
*/ */
public abstract class AbstractCompileEnvironment { public class CompileEnvironment {
protected Project project; private JetCoreEnvironment myEnvironment;
private final Disposable myRootDisposable;
private PrintStream myErrorStream = System.out;
protected abstract void addToClasspath(File file); public CompileEnvironment() {
myRootDisposable = new Disposable() {
@Override
public void dispose() {
}
};
myEnvironment = new JetCoreEnvironment(myRootDisposable);
}
public void setErrorStream(PrintStream errorStream) {
myErrorStream = errorStream;
}
public void dispose() {
Disposer.dispose(myRootDisposable);
}
public boolean initializeKotlinRuntime() {
return initializeKotlinRuntime(myEnvironment);
}
public static boolean initializeKotlinRuntime(JetCoreEnvironment environment) {
final File unpackedRuntimePath = getUnpackedRuntimePath();
if (unpackedRuntimePath != null) {
environment.addToClasspath(unpackedRuntimePath);
}
else {
final File runtimeJarPath = getRuntimeJarPath();
if (runtimeJarPath != null && runtimeJarPath.exists()) {
environment.addToClasspath(runtimeJarPath);
}
else {
return false;
}
}
return true;
}
public static File getUnpackedRuntimePath() {
URL url = CompileEnvironment.class.getClassLoader().getResource("jet/JetObject.class");
if (url != null && url.getProtocol().equals("file")) {
return new File(url.getPath()).getParentFile().getParentFile();
}
return null;
}
public static File getRuntimeJarPath() {
URL url = CompileEnvironment.class.getClassLoader().getResource("jet/JetObject.class");
if (url != null && url.getProtocol().equals("jar")) {
String path = url.getPath();
return new File(path.substring(path.indexOf(":") + 1, path.indexOf("!/")));
}
return null;
}
public void setJavaRuntime(File rtJarPath) {
myEnvironment.addToClasspath(rtJarPath);
}
public static File findRtJar(boolean failOnError) { public static File findRtJar(boolean failOnError) {
String javaHome = System.getenv("JAVA_HOME"); String javaHome = System.getenv("JAVA_HOME");
@@ -99,52 +161,6 @@ public abstract class AbstractCompileEnvironment {
return null; return null;
} }
public abstract VirtualFileSystem getLocalFileSystem();
public abstract VirtualFileSystem getJarFileSystem();
public Project getProject() {
return project;
}
public static File getUnpackedRuntimePath() {
URL url = CoreCompileEnvironment.class.getClassLoader().getResource("jet/JetObject.class");
if (url != null && url.getProtocol().equals("file")) {
return new File(url.getPath()).getParentFile().getParentFile();
}
return null;
}
public static File getRuntimeJarPath() {
URL url = CoreCompileEnvironment.class.getClassLoader().getResource("jet/JetObject.class");
if (url != null && url.getProtocol().equals("jar")) {
String path = url.getPath();
return new File(path.substring(path.indexOf(":") + 1, path.indexOf("!/")));
}
return null;
}
public static boolean initializeKotlinRuntime(AbstractCompileEnvironment environment) {
final File unpackedRuntimePath = getUnpackedRuntimePath();
if (unpackedRuntimePath != null) {
environment.addToClasspath(unpackedRuntimePath);
}
else {
final File runtimeJarPath = getRuntimeJarPath();
if (runtimeJarPath != null && runtimeJarPath.exists()) {
environment.addToClasspath(runtimeJarPath);
}
else {
return false;
}
}
return true;
}
public void setJavaRuntime(File rtJarPath) {
addToClasspath(rtJarPath);
}
public void compileModuleScript(String moduleFile, String jarPath, boolean jarRuntime) { public void compileModuleScript(String moduleFile, String jarPath, boolean jarRuntime) {
final IModuleSetBuilder moduleSetBuilder = loadModuleScript(moduleFile); final IModuleSetBuilder moduleSetBuilder = loadModuleScript(moduleFile);
if (moduleSetBuilder == null) { if (moduleSetBuilder == null) {
@@ -164,11 +180,11 @@ public abstract class AbstractCompileEnvironment {
} }
public IModuleSetBuilder loadModuleScript(String moduleFile) { public IModuleSetBuilder loadModuleScript(String moduleFile) {
CompileSession scriptCompileSession = new CompileSession(this); CompileSession scriptCompileSession = new CompileSession(myEnvironment);
scriptCompileSession.addSources(moduleFile); scriptCompileSession.addSources(moduleFile);
scriptCompileSession.addStdLibSources(); scriptCompileSession.addStdLibSources();
if (!scriptCompileSession.analyze(System.out)) { if (!scriptCompileSession.analyze(myErrorStream)) {
return null; return null;
} }
final ClassFileFactory factory = scriptCompileSession.generate(); final ClassFileFactory factory = scriptCompileSession.generate();
@@ -204,22 +220,22 @@ public abstract class AbstractCompileEnvironment {
} }
public ClassFileFactory compileModule(IModuleBuilder moduleBuilder, String directory) { public ClassFileFactory compileModule(IModuleBuilder moduleBuilder, String directory) {
CompileSession moduleCompileSession = new CompileSession(this); CompileSession moduleCompileSession = new CompileSession(myEnvironment);
moduleCompileSession.addStdLibSources(); moduleCompileSession.addStdLibSources();
for (String sourceFile : moduleBuilder.getSourceFiles()) { for (String sourceFile : moduleBuilder.getSourceFiles()) {
moduleCompileSession.addSources(new File(directory, sourceFile).getPath()); moduleCompileSession.addSources(new File(directory, sourceFile).getPath());
} }
for (String classpathRoot : moduleBuilder.getClasspathRoots()) { for (String classpathRoot : moduleBuilder.getClasspathRoots()) {
addToClasspath(new File(classpathRoot)); myEnvironment.addToClasspath(new File(classpathRoot));
} }
if (!moduleCompileSession.analyze(System.out)) { if (!moduleCompileSession.analyze(myErrorStream)) {
return null; return null;
} }
return moduleCompileSession.generate(); return moduleCompileSession.generate();
} }
private static String getHomeDirectory() { private static String getHomeDirectory() {
return new File(PathManager.getResourceRoot(CoreCompileEnvironment.class, "/org/jetbrains/jet/compiler/CoreCompileEnvironment.class")).getParentFile().getParentFile().getParent(); return new File(PathManager.getResourceRoot(CompileEnvironment.class, "/org/jetbrains/jet/compiler/CompileEnvironment.class")).getParentFile().getParentFile().getParent();
} }
private static final List<String> sanitized = Arrays.asList("kotlin/", "std/"); private static final List<String> sanitized = Arrays.asList("kotlin/", "std/");
@@ -312,20 +328,19 @@ public abstract class AbstractCompileEnvironment {
} }
} }
public void compileBunchOfSources(String sourceFileOrDir, String jar, String outputDir, boolean includeRuntime, boolean stdlib) { public void compileBunchOfSources(String sourceFileOrDir, String jar, String outputDir, boolean includeRuntime) {
CompileSession session = new CompileSession(this); CompileSession session = new CompileSession(myEnvironment);
session.addSources(sourceFileOrDir); session.addSources(sourceFileOrDir);
if(!stdlib)
session.addStdLibSources(); session.addStdLibSources();
String mainClass = null; String mainClass = null;
for (JetNamespace namespace : session.getSourceFileNamespaces()) { for (JetFile file : session.getSourceFileNamespaces()) {
if (JetMainDetector.hasMain(namespace.getDeclarations())) { if (JetMainDetector.hasMain(file.getDeclarations())) {
mainClass = JetPsiUtil.getFQName(namespace) + ".namespace"; mainClass = JetPsiUtil.getFQName(file) + ".namespace";
break; break;
} }
} }
if (!session.analyze(System.out)) { if (!session.analyze(myErrorStream)) {
return; return;
} }
@@ -358,8 +373,4 @@ public abstract class AbstractCompileEnvironment {
// } // }
} }
} }
public boolean initializeKotlinRuntime() {
return initializeKotlinRuntime(this);
}
} }
@@ -4,14 +4,12 @@ import com.google.common.base.Predicates;
import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile; import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager; import com.intellij.psi.PsiManager;
import org.jetbrains.jet.JetCoreEnvironment;
import org.jetbrains.jet.codegen.ClassBuilderFactory; import org.jetbrains.jet.codegen.ClassBuilderFactory;
import org.jetbrains.jet.codegen.ClassFileFactory; import org.jetbrains.jet.codegen.ClassFileFactory;
import org.jetbrains.jet.codegen.CompilationErrorHandler;
import org.jetbrains.jet.codegen.GenerationState; import org.jetbrains.jet.codegen.GenerationState;
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
import org.jetbrains.jet.lang.psi.JetDeclaration;
import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.psi.JetNamespace;
import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacade; import org.jetbrains.jet.lang.resolve.java.AnalyzerFacade;
import org.jetbrains.jet.plugin.JetFileType; import org.jetbrains.jet.plugin.JetFileType;
@@ -19,7 +17,6 @@ import org.jetbrains.jet.plugin.JetFileType;
import java.io.File; import java.io.File;
import java.io.PrintStream; import java.io.PrintStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
/** /**
@@ -28,13 +25,13 @@ import java.util.List;
* @author yole * @author yole
*/ */
public class CompileSession { public class CompileSession {
private final List<JetNamespace> mySourceFileNamespaces = new ArrayList<JetNamespace>(); private final JetCoreEnvironment myEnvironment;
private final List<JetNamespace> myLibrarySourceFileNamespaces = new ArrayList<JetNamespace>(); private final List<JetFile> mySourceFiles = new ArrayList<JetFile>();
private final List<JetFile> myLibrarySourceFiles = new ArrayList<JetFile>();
private List<String> myErrors = new ArrayList<String>(); private List<String> myErrors = new ArrayList<String>();
private BindingContext myBindingContext; private BindingContext myBindingContext;
private AbstractCompileEnvironment myEnvironment;
public CompileSession(AbstractCompileEnvironment environment) { public CompileSession(JetCoreEnvironment environment) {
myEnvironment = environment; myEnvironment = environment;
} }
@@ -52,64 +49,42 @@ public class CompileSession {
return; return;
} }
addSources(new File(path), mySourceFileNamespaces); addSources(new File(path));
} }
private void addSources(File file, List<JetNamespace> namespaces) { private void addSources(File file) {
if(file.isDirectory()) { if(file.isDirectory()) {
for (File child : file.listFiles()) { for (File child : file.listFiles()) {
addSources(child, namespaces); addSources(child);
} }
} }
else { else {
VirtualFile fileByPath = myEnvironment.getLocalFileSystem().findFileByPath(file.getAbsolutePath()); VirtualFile fileByPath = myEnvironment.getLocalFileSystem().findFileByPath(file.getAbsolutePath());
PsiFile psiFile = PsiManager.getInstance(myEnvironment.getProject()).findFile(fileByPath); PsiFile psiFile = PsiManager.getInstance(myEnvironment.getProject()).findFile(fileByPath);
if(psiFile instanceof JetFile) { if(psiFile instanceof JetFile) {
namespaces.add(((JetFile) psiFile).getRootNamespace()); mySourceFiles.add((JetFile) psiFile);
} }
} }
} }
public void addSources(VirtualFile vFile) { public void addSources(VirtualFile vFile) {
addSources(vFile, mySourceFileNamespaces);
}
public void addSources(VirtualFile vFile, List<JetNamespace> namespaces) {
if (vFile.isDirectory()) { if (vFile.isDirectory()) {
for (VirtualFile virtualFile : vFile.getChildren()) { for (VirtualFile virtualFile : vFile.getChildren()) {
addSources(virtualFile, namespaces); addSources(virtualFile);
} }
} }
else { else {
if (vFile.getFileType() == JetFileType.INSTANCE) { if (vFile.getFileType() == JetFileType.INSTANCE) {
PsiFile psiFile = PsiManager.getInstance(myEnvironment.getProject()).findFile(vFile); PsiFile psiFile = PsiManager.getInstance(myEnvironment.getProject()).findFile(vFile);
if (psiFile instanceof JetFile) { if (psiFile instanceof JetFile) {
mySourceFileNamespaces.add(((JetFile) psiFile).getRootNamespace()); mySourceFiles.add((JetFile) psiFile);
} }
} }
} }
} }
public void addSources(VirtualFile[] allFiles) { public List<JetFile> getSourceFileNamespaces() {
for(VirtualFile vFile: allFiles) { return mySourceFiles;
if (vFile.getFileType() == JetFileType.INSTANCE) {
PsiFile psiFile = PsiManager.getInstance(myEnvironment.getProject()).findFile(vFile);
if (psiFile instanceof JetFile) {
mySourceFileNamespaces.add(((JetFile) psiFile).getRootNamespace());
}
}
}
}
public List<JetNamespace> getSourceFileNamespaces() {
return mySourceFileNamespaces;
}
public BindingContext analyze() {
List<JetNamespace> allNamespaces = new ArrayList<JetNamespace>(mySourceFileNamespaces);
allNamespaces.addAll(myLibrarySourceFileNamespaces);
return AnalyzerFacade.analyzeNamespacesWithJavaIntegration(
myEnvironment.getProject(), allNamespaces, Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY);
} }
public boolean analyze(final PrintStream out) { public boolean analyze(final PrintStream out) {
@@ -119,48 +94,38 @@ public class CompileSession {
} }
return false; return false;
} }
myBindingContext = analyze(); List<JetFile> allNamespaces = new ArrayList<JetFile>(mySourceFiles);
allNamespaces.addAll(myLibrarySourceFiles);
myBindingContext = AnalyzerFacade.analyzeFilesWithJavaIntegration(
myEnvironment.getProject(), allNamespaces, Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY);
ErrorCollector errorCollector = new ErrorCollector(myBindingContext); ErrorCollector errorCollector = new ErrorCollector(myBindingContext);
errorCollector.report(out); errorCollector.report(out);
return !errorCollector.hasErrors; return !errorCollector.hasErrors;
} }
public ClassFileFactory generate() { public ClassFileFactory generate() {
return generate(CompilationErrorHandler.THROW_EXCEPTION);
}
public ClassFileFactory generate(CompilationErrorHandler handler) {
GenerationState generationState = new GenerationState(myEnvironment.getProject(), ClassBuilderFactory.BINARIES); GenerationState generationState = new GenerationState(myEnvironment.getProject(), ClassBuilderFactory.BINARIES);
generationState.compileCorrectNamespaces(myBindingContext, mySourceFileNamespaces, handler); generationState.compileCorrectFiles(myBindingContext, mySourceFiles);
return generationState.getFactory(); return generationState.getFactory();
} }
public String generateText() { public String generateText() {
GenerationState generationState = new GenerationState(myEnvironment.getProject(), ClassBuilderFactory.TEXT); GenerationState generationState = new GenerationState(myEnvironment.getProject(), ClassBuilderFactory.TEXT);
generationState.compileCorrectNamespaces(myBindingContext, mySourceFileNamespaces); generationState.compileCorrectFiles(myBindingContext, mySourceFiles);
return generationState.createText(); return generationState.createText();
} }
public boolean addStdLibSources() { public boolean addStdLibSources() {
return addStdLibSources(false); final File unpackedRuntimePath = CompileEnvironment.getUnpackedRuntimePath();
}
public boolean addStdLibSources(boolean forAnalize) {
/*
@todo
We add sources as library sources in case of jar
but as regular one if there is no jar
*/
final File unpackedRuntimePath = CoreCompileEnvironment.getUnpackedRuntimePath();
if (unpackedRuntimePath != null) { if (unpackedRuntimePath != null) {
addSources(new File(unpackedRuntimePath, "stdlib/ktSrc").getAbsoluteFile(), forAnalize ? myLibrarySourceFileNamespaces : mySourceFileNamespaces); addSources(new File(unpackedRuntimePath, "../../../stdlib/ktSrc").getAbsoluteFile());
} }
else { else {
final File runtimeJarPath = CoreCompileEnvironment.getRuntimeJarPath(); final File runtimeJarPath = CompileEnvironment.getRuntimeJarPath();
if (runtimeJarPath != null && runtimeJarPath.exists()) { if (runtimeJarPath != null && runtimeJarPath.exists()) {
VirtualFile runtimeJar = myEnvironment.getLocalFileSystem().findFileByPath(runtimeJarPath.getAbsolutePath()); VirtualFile runtimeJar = myEnvironment.getLocalFileSystem().findFileByPath(runtimeJarPath.getAbsolutePath());
VirtualFile jarRoot = myEnvironment.getJarFileSystem().findFileByPath(runtimeJar.getPath() + "!/stdlib/ktSrc"); VirtualFile jarRoot = myEnvironment.getJarFileSystem().findFileByPath(runtimeJar.getPath() + "!/stdlib/ktSrc");
addSources(jarRoot, myLibrarySourceFileNamespaces); addSources(jarRoot);
} }
else { else {
return false; return false;
@@ -168,8 +133,4 @@ public class CompileSession {
} }
return true; return true;
} }
public List<JetNamespace> getLibrarySourceFileNamespaces() {
return myLibrarySourceFileNamespaces;
}
} }
@@ -1,84 +0,0 @@
package org.jetbrains.jet.compiler;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFileSystem;
import com.intellij.util.Processor;
import jet.ExtensionFunction0;
import jet.modules.IModuleBuilder;
import jet.modules.IModuleSetBuilder;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.JetCoreEnvironment;
import org.jetbrains.jet.codegen.ClassFileFactory;
import org.jetbrains.jet.codegen.GeneratedClassLoader;
import org.jetbrains.jet.lang.psi.JetNamespace;
import org.jetbrains.jet.lang.psi.JetPsiUtil;
import org.jetbrains.jet.plugin.JetMainDetector;
import java.io.*;
import java.lang.reflect.Field;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
import java.util.jar.*;
/**
* The environment for compiling a bunch of source files or
*
* @author yole
* @author alex.tkachman
*/
public class CoreCompileEnvironment extends AbstractCompileEnvironment {
private final Disposable myRootDisposable;
private final VirtualFileSystem localFileSystem;
private VirtualFileSystem jarFileSystem;
private JetCoreEnvironment myEnvironment;
public CoreCompileEnvironment() {
myRootDisposable = new Disposable() {
@Override
public void dispose() {
}
};
myEnvironment = new JetCoreEnvironment(myRootDisposable);
localFileSystem = myEnvironment.getLocalFileSystem();
jarFileSystem = myEnvironment.getJarFileSystem();
project = myEnvironment.getProject();
}
public CoreCompileEnvironment(JetCoreEnvironment myEnvironment) {
this.myRootDisposable = null;
this.myEnvironment = myEnvironment;
localFileSystem = myEnvironment.getLocalFileSystem();
jarFileSystem = myEnvironment.getJarFileSystem();
project = myEnvironment.getProject();
}
public void dispose() {
if(myRootDisposable != null)
Disposer.dispose(myRootDisposable);
}
@Override
public void addToClasspath(File file) {
myEnvironment.addToClasspath(file);
}
@Override
public VirtualFileSystem getLocalFileSystem() {
return localFileSystem;
}
@Override
public Project getProject() {
return project;
}
@Override
public VirtualFileSystem getJarFileSystem() {
return jarFileSystem;
}
}
@@ -2,8 +2,7 @@ package org.jetbrains.jet.cli;
import com.sampullara.cli.Args; import com.sampullara.cli.Args;
import com.sampullara.cli.Argument; import com.sampullara.cli.Argument;
import org.jetbrains.jet.compiler.AbstractCompileEnvironment; import org.jetbrains.jet.compiler.CompileEnvironment;
import org.jetbrains.jet.compiler.CoreCompileEnvironment;
import org.jetbrains.jet.compiler.CompileEnvironmentException; import org.jetbrains.jet.compiler.CompileEnvironmentException;
/** /**
@@ -26,8 +25,6 @@ public class KotlinCompiler {
public String module; public String module;
@Argument(value = "includeRuntime", description = "include Kotlin runtime in to resulting jar") @Argument(value = "includeRuntime", description = "include Kotlin runtime in to resulting jar")
public boolean includeRuntime; public boolean includeRuntime;
@Argument(value = "stdlib", description = "means that we compile stdlib itself")
public boolean stdlib;
} }
public static void main(String[] args) { public static void main(String[] args) {
@@ -42,10 +39,10 @@ public class KotlinCompiler {
return; return;
} }
CoreCompileEnvironment environment = new CoreCompileEnvironment(); CompileEnvironment environment = new CompileEnvironment();
try { try {
environment.setJavaRuntime(AbstractCompileEnvironment.findRtJar(true)); environment.setJavaRuntime(CompileEnvironment.findRtJar(true));
if (!environment.initializeKotlinRuntime()) { if (!environment.initializeKotlinRuntime()) {
System.out.println("No runtime library found"); System.out.println("No runtime library found");
return; return;
@@ -56,7 +53,7 @@ public class KotlinCompiler {
return; return;
} }
else { else {
environment.compileBunchOfSources(arguments.src, arguments.jar, arguments.outputDir, arguments.includeRuntime, arguments.stdlib); environment.compileBunchOfSources(arguments.src, arguments.jar, arguments.outputDir, arguments.includeRuntime);
} }
} catch (CompileEnvironmentException e) { } catch (CompileEnvironmentException e) {
System.out.println(e.getMessage()); System.out.println(e.getMessage());
@@ -17,45 +17,39 @@ import org.jetbrains.jet.lang.StandardConfiguration;
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils; import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
import org.jetbrains.jet.lang.diagnostics.Errors; import org.jetbrains.jet.lang.diagnostics.Errors;
import org.jetbrains.jet.lang.psi.JetDeclaration;
import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.psi.JetNamespace;
import org.jetbrains.jet.lang.resolve.AnalyzingUtils; import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.BindingTraceContext; import org.jetbrains.jet.lang.resolve.BindingTraceContext;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List;
/** /**
* @author abreslav * @author abreslav
*/ */
public class AnalyzerFacade { public class AnalyzerFacade {
public static final Function<JetFile, Collection<JetDeclaration>> SINGLE_DECLARATION_PROVIDER = new Function<JetFile, Collection<JetDeclaration>>() { public static final Function<JetFile, Collection<JetFile>> SINGLE_DECLARATION_PROVIDER = new Function<JetFile, Collection<JetFile>>() {
@Override @Override
public Collection<JetDeclaration> fun(JetFile file) { public Collection<JetFile> fun(JetFile file) {
return Collections.<JetDeclaration>singleton(file.getRootNamespace()); return Collections.singleton(file);
} }
}; };
private final static Key<CachedValue<BindingContext>> BINDING_CONTEXT = Key.create("BINDING_CONTEXT"); private final static Key<CachedValue<BindingContext>> BINDING_CONTEXT = Key.create("BINDING_CONTEXT");
private static final Object lock = new Object(); private static final Object lock = new Object();
public static BindingContext analyzeFileWithCache(@NotNull final JetFile file, @NotNull final Function<JetFile, Collection<JetDeclaration>> declarationProvider) { public static BindingContext analyzeFileWithCache(@NotNull final JetFile file, @NotNull final Function<JetFile, Collection<JetFile>> declarationProvider) {
// Need lock for getValue(), because parallel threads can start evaluation of compute() simultaneously // Need lock for getValue(), because parallel threads can start evaluation of compute() simultaneously
synchronized (lock) { synchronized (lock) {
CachedValue<BindingContext> bindingContextCachedValue = file.getUserData(BINDING_CONTEXT); CachedValue<BindingContext> bindingContextCachedValue = file.getUserData(BINDING_CONTEXT);
if (bindingContextCachedValue == null) { if (bindingContextCachedValue == null) {
bindingContextCachedValue = CachedValuesManager.getManager(file.getProject()).createCachedValue(new CachedValueProvider<BindingContext>() { bindingContextCachedValue = CachedValuesManager.getManager(file.getProject()).createCachedValue(new CachedValueProvider<BindingContext>() {
@Override @Override
public Result<BindingContext> compute() { public Result<BindingContext> compute() {
try { try {
BindingContext bindingContext = analyzeNamespacesWithJavaIntegration(file.getProject(), declarationProvider.fun(file), Predicates.<PsiFile>equalTo(file), JetControlFlowDataTraceFactory.EMPTY); BindingContext bindingContext = analyzeFilesWithJavaIntegration(file.getProject(), declarationProvider.fun(file), Predicates.<PsiFile>equalTo(file), JetControlFlowDataTraceFactory.EMPTY);
return new Result<BindingContext>(bindingContext, PsiModificationTracker.MODIFICATION_COUNT); return new Result<BindingContext>(bindingContext, PsiModificationTracker.MODIFICATION_COUNT);
} }
catch (ProcessCanceledException e) { catch (ProcessCanceledException e) {
@@ -73,46 +67,32 @@ public class AnalyzerFacade {
}, false); }, false);
file.putUserData(BINDING_CONTEXT, bindingContextCachedValue); file.putUserData(BINDING_CONTEXT, bindingContextCachedValue);
} }
return bindingContextCachedValue.getValue(); return bindingContextCachedValue.getValue();
} }
} }
public static BindingContext analyzeOneNamespaceWithJavaIntegration(JetNamespace namespace, JetControlFlowDataTraceFactory flowDataTraceFactory) { public static BindingContext analyzeOneFileWithJavaIntegration(JetFile file, JetControlFlowDataTraceFactory flowDataTraceFactory) {
return analyzeNamespacesWithJavaIntegration(namespace.getProject(), Collections.singleton(namespace), Predicates.<PsiFile>alwaysTrue(), flowDataTraceFactory); return analyzeFilesWithJavaIntegration(file.getProject(), Collections.singleton(file), Predicates.<PsiFile>alwaysTrue(), flowDataTraceFactory);
} }
public static BindingContext analyzeNamespacesWithJavaIntegration(Project project, Collection<? extends JetDeclaration> declarations, Predicate<PsiFile> filesToAnalyzeCompletely, JetControlFlowDataTraceFactory flowDataTraceFactory) { public static BindingContext analyzeFilesWithJavaIntegration(Project project, Collection<JetFile> files, Predicate<PsiFile> filesToAnalyzeCompletely, JetControlFlowDataTraceFactory flowDataTraceFactory) {
BindingTraceContext bindingTraceContext = new BindingTraceContext(); BindingTraceContext bindingTraceContext = new BindingTraceContext();
JetSemanticServices semanticServices = JetSemanticServices.createSemanticServices(project); JetSemanticServices semanticServices = JetSemanticServices.createSemanticServices(project);
return AnalyzingUtils.analyzeNamespacesWithGivenTrace( return AnalyzingUtils.analyzeFilesWithGivenTrace(
project, project,
JavaBridgeConfiguration.createJavaBridgeConfiguration(project, bindingTraceContext, StandardConfiguration.createStandardConfiguration(project)), JavaBridgeConfiguration.createJavaBridgeConfiguration(project, bindingTraceContext, StandardConfiguration.createStandardConfiguration(project)),
declarations, files,
filesToAnalyzeCompletely, filesToAnalyzeCompletely,
flowDataTraceFactory, flowDataTraceFactory,
bindingTraceContext, bindingTraceContext,
semanticServices); semanticServices);
} }
public static BindingContext shallowAnalyzeFiles(Collection<PsiFile> files) { public static BindingContext shallowAnalyzeFiles(Collection<JetFile> files) {
assert files.size() > 0; assert files.size() > 0;
Project project = files.iterator().next().getProject(); Project project = files.iterator().next().getProject();
Collection<JetNamespace> namespaces = collectRootNamespaces(files); return analyzeFilesWithJavaIntegration(project, files, Predicates.<PsiFile>alwaysFalse(), JetControlFlowDataTraceFactory.EMPTY);
return analyzeNamespacesWithJavaIntegration(project, namespaces, Predicates.<PsiFile>alwaysFalse(), JetControlFlowDataTraceFactory.EMPTY);
}
public static List<JetNamespace> collectRootNamespaces(Collection<PsiFile> files) {
List<JetNamespace> namespaces = new ArrayList<JetNamespace>();
for (PsiFile file : files) {
if (file instanceof JetFile) {
namespaces.add(((JetFile) file).getRootNamespace());
}
}
return namespaces;
} }
} }
@@ -166,8 +166,17 @@ public class JavaDescriptorResolver {
); );
classDescriptor.setName(name); classDescriptor.setName(name);
class OuterClassTypeVariableResolver implements TypeVariableResolver {
@NotNull
@Override
public TypeParameterDescriptor getTypeVariable(@NotNull String name) {
throw new IllegalStateException("not implemented"); // TODO
}
}
List<JetType> supertypes = new ArrayList<JetType>(); List<JetType> supertypes = new ArrayList<JetType>();
List<TypeParameterDescriptor> typeParameters = resolveClassTypeParameters(psiClass, classDescriptor); List<TypeParameterDescriptor> typeParameters = resolveClassTypeParameters(psiClass, classDescriptor, new OuterClassTypeVariableResolver());
classDescriptor.setTypeConstructor(new TypeConstructorImpl( classDescriptor.setTypeConstructor(new TypeConstructorImpl(
classDescriptor, classDescriptor,
Collections.<AnnotationDescriptor>emptyList(), // TODO Collections.<AnnotationDescriptor>emptyList(), // TODO
@@ -225,7 +234,10 @@ public class JavaDescriptorResolver {
classDescriptor, classDescriptor,
Collections.<AnnotationDescriptor>emptyList(), // TODO Collections.<AnnotationDescriptor>emptyList(), // TODO
false); false);
ValueParameterDescriptors valueParameterDescriptors = resolveParameterDescriptors(constructorDescriptor, constructor.getParameterList().getParameters()); ValueParameterDescriptors valueParameterDescriptors = resolveParameterDescriptors(constructorDescriptor,
constructor.getParameterList().getParameters(),
new TypeParameterListTypeVariableResolver(typeParameters) // TODO: outer too
);
if (valueParameterDescriptors.receiverType != null) { if (valueParameterDescriptors.receiverType != null) {
throw new IllegalStateException(); throw new IllegalStateException();
} }
@@ -242,14 +254,14 @@ public class JavaDescriptorResolver {
return classDescriptor; return classDescriptor;
} }
private List<TypeParameterDescriptor> resolveClassTypeParameters(PsiClass psiClass, JavaClassDescriptor classDescriptor) { private List<TypeParameterDescriptor> resolveClassTypeParameters(PsiClass psiClass, JavaClassDescriptor classDescriptor, TypeVariableResolver typeVariableResolver) {
for (PsiAnnotation annotation : psiClass.getModifierList().getAnnotations()) { for (PsiAnnotation annotation : psiClass.getModifierList().getAnnotations()) {
if (annotation.getQualifiedName().equals(JvmStdlibNames.JET_CLASS.getFqName())) { if (annotation.getQualifiedName().equals(JvmStdlibNames.JET_CLASS.getFqName())) {
PsiLiteralExpression attributeValue = (PsiLiteralExpression) annotation.findAttributeValue(JvmStdlibNames.JET_CLASS_SIGNATURE); PsiLiteralExpression attributeValue = (PsiLiteralExpression) annotation.findAttributeValue(JvmStdlibNames.JET_CLASS_SIGNATURE);
if (attributeValue != null) { if (attributeValue != null) {
String typeParametersString = (String) attributeValue.getValue(); String typeParametersString = (String) attributeValue.getValue();
if (typeParametersString != null) { if (typeParametersString != null) {
return resolveClassTypeParametersFromJetSignature(typeParametersString, psiClass, classDescriptor); return resolveClassTypeParametersFromJetSignature(typeParametersString, psiClass, classDescriptor, typeVariableResolver);
} }
} }
} }
@@ -290,14 +302,20 @@ public class JavaDescriptorResolver {
private final PsiTypeParameterListOwner psiOwner; private final PsiTypeParameterListOwner psiOwner;
private final String name; private final String name;
private final TypeInfoVariance variance; private final TypeInfoVariance variance;
private final TypeVariableResolver typeVariableResolver;
protected JetSignatureTypeParameterVisitor(DeclarationDescriptor containingDeclaration, PsiTypeParameterListOwner psiOwner, protected JetSignatureTypeParameterVisitor(DeclarationDescriptor containingDeclaration, PsiTypeParameterListOwner psiOwner,
String name, TypeInfoVariance variance) String name, TypeInfoVariance variance, TypeVariableResolver typeVariableResolver)
{ {
if (name.isEmpty()) {
throw new IllegalStateException();
}
this.containingDeclaration = containingDeclaration; this.containingDeclaration = containingDeclaration;
this.psiOwner = psiOwner; this.psiOwner = psiOwner;
this.name = name; this.name = name;
this.variance = variance; this.variance = variance;
this.typeVariableResolver = typeVariableResolver;
} }
int index = 0; int index = 0;
@@ -307,7 +325,7 @@ public class JavaDescriptorResolver {
@Override @Override
public JetSignatureVisitor visitClassBound() { public JetSignatureVisitor visitClassBound() {
return new JetTypeJetSignatureReader(JavaDescriptorResolver.this, semanticServices.getJetSemanticServices().getStandardLibrary()) { return new JetTypeJetSignatureReader(JavaDescriptorResolver.this, semanticServices.getJetSemanticServices().getStandardLibrary(), typeVariableResolver) {
@Override @Override
protected void done(@NotNull JetType jetType) { protected void done(@NotNull JetType jetType) {
if (isJavaLangObject(jetType)) { if (isJavaLangObject(jetType)) {
@@ -320,7 +338,7 @@ public class JavaDescriptorResolver {
@Override @Override
public JetSignatureVisitor visitInterfaceBound() { public JetSignatureVisitor visitInterfaceBound() {
return new JetTypeJetSignatureReader(JavaDescriptorResolver.this, semanticServices.getJetSemanticServices().getStandardLibrary()) { return new JetTypeJetSignatureReader(JavaDescriptorResolver.this, semanticServices.getJetSemanticServices().getStandardLibrary(), typeVariableResolver) {
@Override @Override
protected void done(@NotNull JetType jetType) { protected void done(@NotNull JetType jetType) {
upperBounds.add(jetType); upperBounds.add(jetType);
@@ -348,12 +366,28 @@ public class JavaDescriptorResolver {
/** /**
* @see #resolveMethodTypeParametersFromJetSignature(String, FunctionDescriptor) * @see #resolveMethodTypeParametersFromJetSignature(String, FunctionDescriptor)
*/ */
private List<TypeParameterDescriptor> resolveClassTypeParametersFromJetSignature(String jetSignature, final PsiClass clazz, final JavaClassDescriptor classDescriptor) { private List<TypeParameterDescriptor> resolveClassTypeParametersFromJetSignature(String jetSignature, final PsiClass clazz,
final JavaClassDescriptor classDescriptor, final TypeVariableResolver outerClassTypeVariableResolver) {
final List<TypeParameterDescriptor> r = new ArrayList<TypeParameterDescriptor>(); final List<TypeParameterDescriptor> r = new ArrayList<TypeParameterDescriptor>();
class MyTypeVariableResolver implements TypeVariableResolver {
@NotNull
@Override
public TypeParameterDescriptor getTypeVariable(@NotNull String name) {
for (TypeParameterDescriptor typeParameter : r) {
if (typeParameter.getName().equals(name)) {
return typeParameter;
}
}
return outerClassTypeVariableResolver.getTypeVariable(name);
}
}
new JetSignatureReader(jetSignature).accept(new JetSignatureExceptionsAdapter() { new JetSignatureReader(jetSignature).accept(new JetSignatureExceptionsAdapter() {
@Override @Override
public JetSignatureVisitor visitFormalTypeParameter(final String name, final TypeInfoVariance variance) { public JetSignatureVisitor visitFormalTypeParameter(final String name, final TypeInfoVariance variance) {
return new JetSignatureTypeParameterVisitor(classDescriptor, clazz, name, variance) { return new JetSignatureTypeParameterVisitor(classDescriptor, clazz, name, variance, new MyTypeVariableResolver()) {
@Override @Override
protected void done(TypeParameterDescriptor typeParameterDescriptor) { protected void done(TypeParameterDescriptor typeParameterDescriptor) {
r.add(typeParameterDescriptor); r.add(typeParameterDescriptor);
@@ -548,12 +582,13 @@ public class JavaDescriptorResolver {
} }
} }
public ValueParameterDescriptors resolveParameterDescriptors(DeclarationDescriptor containingDeclaration, PsiParameter[] parameters) { public ValueParameterDescriptors resolveParameterDescriptors(DeclarationDescriptor containingDeclaration,
PsiParameter[] parameters, TypeVariableResolver typeVariableResolver) {
List<ValueParameterDescriptor> result = new ArrayList<ValueParameterDescriptor>(); List<ValueParameterDescriptor> result = new ArrayList<ValueParameterDescriptor>();
JetType receiverType = null; JetType receiverType = null;
for (int i = 0, parametersLength = parameters.length; i < parametersLength; i++) { for (int i = 0, parametersLength = parameters.length; i < parametersLength; i++) {
PsiParameter parameter = parameters[i]; PsiParameter parameter = parameters[i];
JvmMethodParameterMeaning meaning = resolveParameterDescriptor(containingDeclaration, i, parameter); JvmMethodParameterMeaning meaning = resolveParameterDescriptor(containingDeclaration, i, parameter, typeVariableResolver);
if (meaning.kind == JvmMethodParameterKind.TYPE_INFO) { if (meaning.kind == JvmMethodParameterKind.TYPE_INFO) {
// TODO // TODO
} else if (meaning.kind == JvmMethodParameterKind.REGULAR) { } else if (meaning.kind == JvmMethodParameterKind.REGULAR) {
@@ -601,7 +636,8 @@ public class JavaDescriptorResolver {
} }
@NotNull @NotNull
private JvmMethodParameterMeaning resolveParameterDescriptor(DeclarationDescriptor containingDeclaration, int i, PsiParameter parameter) { private JvmMethodParameterMeaning resolveParameterDescriptor(DeclarationDescriptor containingDeclaration, int i,
PsiParameter parameter, TypeVariableResolver typeVariableResolver) {
PsiType psiType = parameter.getType(); PsiType psiType = parameter.getType();
JetType varargElementType; JetType varargElementType;
@@ -663,7 +699,7 @@ public class JavaDescriptorResolver {
JetType outType; JetType outType;
if (typeFromAnnotation != null && typeFromAnnotation.length() > 0) { if (typeFromAnnotation != null && typeFromAnnotation.length() > 0) {
outType = semanticServices.getTypeTransformer().transformToType(typeFromAnnotation); outType = semanticServices.getTypeTransformer().transformToType(typeFromAnnotation, typeVariableResolver);
} else { } else {
outType = semanticServices.getTypeTransformer().transformToType(psiType); outType = semanticServices.getTypeTransformer().transformToType(psiType);
} }
@@ -750,6 +786,26 @@ public class JavaDescriptorResolver {
return typeSubstitutor; return typeSubstitutor;
} }
private static class TypeParameterListTypeVariableResolver implements TypeVariableResolver {
private final List<TypeParameterDescriptor> typeParameters;
private TypeParameterListTypeVariableResolver(List<TypeParameterDescriptor> typeParameters) {
this.typeParameters = typeParameters;
}
@NotNull
@Override
public TypeParameterDescriptor getTypeVariable(@NotNull String name) {
for (TypeParameterDescriptor typeParameter : typeParameters) {
if (typeParameter.getName().equals(name)) {
return typeParameter;
}
}
throw new IllegalStateException("unresolver variable: " + name); // TODO: report properly
}
}
@Nullable @Nullable
public FunctionDescriptor resolveMethodToFunctionDescriptor(DeclarationDescriptor owner, PsiClass psiClass, TypeSubstitutor typeSubstitutorForGenericSuperclasses, PsiMethod method) { public FunctionDescriptor resolveMethodToFunctionDescriptor(DeclarationDescriptor owner, PsiClass psiClass, TypeSubstitutor typeSubstitutorForGenericSuperclasses, PsiMethod method) {
PsiType returnType = method.getReturnType(); PsiType returnType = method.getReturnType();
@@ -763,7 +819,17 @@ public class JavaDescriptorResolver {
} }
return functionDescriptor; return functionDescriptor;
} }
DeclarationDescriptor classDescriptor = method.hasModifierProperty(PsiModifier.STATIC) ? resolveNamespace(method.getContainingClass()) : resolveClass(method.getContainingClass()); DeclarationDescriptor classDescriptor;
final List<TypeParameterDescriptor> classTypeParameters;
if (method.hasModifierProperty(PsiModifier.STATIC)) {
classDescriptor = resolveNamespace(method.getContainingClass());
classTypeParameters = Collections.emptyList();
}
else {
ClassDescriptor classClassDescriptor = resolveClass(method.getContainingClass());
classDescriptor = classClassDescriptor;
classTypeParameters = classClassDescriptor.getTypeConstructor().getParameters();
}
if (classDescriptor == null) { if (classDescriptor == null) {
return null; return null;
} }
@@ -774,14 +840,39 @@ public class JavaDescriptorResolver {
method.getName() method.getName()
); );
methodDescriptorCache.put(method, functionDescriptorImpl); methodDescriptorCache.put(method, functionDescriptorImpl);
List<TypeParameterDescriptor> typeParameters = resolveMethodTypeParameters(method, functionDescriptorImpl);
ValueParameterDescriptors valueParameterDescriptors = resolveParameterDescriptors(functionDescriptorImpl, parameters); // TODO: add outer classes
TypeParameterListTypeVariableResolver typeVariableResolverForParameters = new TypeParameterListTypeVariableResolver(classTypeParameters);
final List<TypeParameterDescriptor> methodTypeParameters = resolveMethodTypeParameters(method, functionDescriptorImpl, typeVariableResolverForParameters);
class MethodTypeVariableResolver implements TypeVariableResolver {
@NotNull
@Override
public TypeParameterDescriptor getTypeVariable(@NotNull String name) {
for (TypeParameterDescriptor typeParameter : methodTypeParameters) {
if (typeParameter.getName().equals(name)) {
return typeParameter;
}
}
for (TypeParameterDescriptor typeParameter : classTypeParameters) {
if (typeParameter.getName().equals(name)) {
return typeParameter;
}
}
throw new IllegalStateException("unresolver variable: " + name); // TODO: report properly
}
}
ValueParameterDescriptors valueParameterDescriptors = resolveParameterDescriptors(functionDescriptorImpl, parameters, new MethodTypeVariableResolver());
functionDescriptorImpl.initialize( functionDescriptorImpl.initialize(
valueParameterDescriptors.receiverType, valueParameterDescriptors.receiverType,
DescriptorUtils.getExpectedThisObjectIfNeeded(classDescriptor), DescriptorUtils.getExpectedThisObjectIfNeeded(classDescriptor),
typeParameters, methodTypeParameters,
valueParameterDescriptors.descriptors, valueParameterDescriptors.descriptors,
makeReturnType(returnType, method), makeReturnType(returnType, method, new MethodTypeVariableResolver()),
Modality.convertFromFlags(method.hasModifierProperty(PsiModifier.ABSTRACT), !method.hasModifierProperty(PsiModifier.FINAL)), Modality.convertFromFlags(method.hasModifierProperty(PsiModifier.ABSTRACT), !method.hasModifierProperty(PsiModifier.FINAL)),
resolveVisibilityFromPsiModifiers(method) resolveVisibilityFromPsiModifiers(method)
); );
@@ -793,14 +884,14 @@ public class JavaDescriptorResolver {
return substitutedFunctionDescriptor; return substitutedFunctionDescriptor;
} }
private List<TypeParameterDescriptor> resolveMethodTypeParameters(PsiMethod method, FunctionDescriptorImpl functionDescriptorImpl) { private List<TypeParameterDescriptor> resolveMethodTypeParameters(PsiMethod method, FunctionDescriptorImpl functionDescriptorImpl, TypeVariableResolver classTypeVariableResolver) {
for (PsiAnnotation annotation : method.getModifierList().getAnnotations()) { for (PsiAnnotation annotation : method.getModifierList().getAnnotations()) {
if (annotation.getQualifiedName().equals(JvmStdlibNames.JET_METHOD.getFqName())) { if (annotation.getQualifiedName().equals(JvmStdlibNames.JET_METHOD.getFqName())) {
PsiLiteralExpression attributeValue = (PsiLiteralExpression) annotation.findAttributeValue(JvmStdlibNames.JET_METHOD_TYPE_PARAMETERS_FIELD); PsiLiteralExpression attributeValue = (PsiLiteralExpression) annotation.findAttributeValue(JvmStdlibNames.JET_METHOD_TYPE_PARAMETERS_FIELD);
if (attributeValue != null) { if (attributeValue != null) {
String typeParametersString = (String) attributeValue.getValue(); String typeParametersString = (String) attributeValue.getValue();
if (typeParametersString != null) { if (typeParametersString != null) {
List<TypeParameterDescriptor> r = resolveMethodTypeParametersFromJetSignature(typeParametersString, method, functionDescriptorImpl); List<TypeParameterDescriptor> r = resolveMethodTypeParametersFromJetSignature(typeParametersString, method, functionDescriptorImpl, classTypeVariableResolver);
initializeTypeParameters(method); initializeTypeParameters(method);
return r; return r;
} }
@@ -816,13 +907,30 @@ public class JavaDescriptorResolver {
/** /**
* @see #resolveClassTypeParametersFromJetSignature(String, com.intellij.psi.PsiClass, JavaClassDescriptor) * @see #resolveClassTypeParametersFromJetSignature(String, com.intellij.psi.PsiClass, JavaClassDescriptor)
*/ */
private List<TypeParameterDescriptor> resolveMethodTypeParametersFromJetSignature(String jetSignature, final PsiMethod method, final FunctionDescriptor functionDescriptor) { private List<TypeParameterDescriptor> resolveMethodTypeParametersFromJetSignature(String jetSignature, final PsiMethod method,
final FunctionDescriptor functionDescriptor, final TypeVariableResolver classTypeVariableResolver)
{
final List<TypeParameterDescriptor> r = new ArrayList<TypeParameterDescriptor>(); final List<TypeParameterDescriptor> r = new ArrayList<TypeParameterDescriptor>();
class MyTypeVariableResolver implements TypeVariableResolver {
@NotNull
@Override
public TypeParameterDescriptor getTypeVariable(@NotNull String name) {
for (TypeParameterDescriptor typeParameter : r) {
if (typeParameter.getName().equals(name)) {
return typeParameter;
}
}
return classTypeVariableResolver.getTypeVariable(name);
}
}
new JetSignatureReader(jetSignature).acceptFormalTypeParametersOnly(new JetSignatureExceptionsAdapter() { new JetSignatureReader(jetSignature).acceptFormalTypeParametersOnly(new JetSignatureExceptionsAdapter() {
@Override @Override
public JetSignatureVisitor visitFormalTypeParameter(final String name, final TypeInfoVariance variance) { public JetSignatureVisitor visitFormalTypeParameter(final String name, final TypeInfoVariance variance) {
return new JetSignatureTypeParameterVisitor(functionDescriptor, method, name, variance) { return new JetSignatureTypeParameterVisitor(functionDescriptor, method, name, variance, new MyTypeVariableResolver()) {
@Override @Override
protected void done(TypeParameterDescriptor typeParameterDescriptor) { protected void done(TypeParameterDescriptor typeParameterDescriptor) {
r.add(typeParameterDescriptor); r.add(typeParameterDescriptor);
@@ -834,7 +942,7 @@ public class JavaDescriptorResolver {
return r; return r;
} }
private JetType makeReturnType(PsiType returnType, PsiMethod method) { private JetType makeReturnType(PsiType returnType, PsiMethod method, TypeVariableResolver typeVariableResolver) {
boolean changeNullable = false; boolean changeNullable = false;
boolean nullable = true; boolean nullable = true;
@@ -859,7 +967,7 @@ public class JavaDescriptorResolver {
} }
JetType transformedType; JetType transformedType;
if (returnTypeFromAnnotation != null && returnTypeFromAnnotation.length() > 0) { if (returnTypeFromAnnotation != null && returnTypeFromAnnotation.length() > 0) {
transformedType = semanticServices.getTypeTransformer().transformToType(returnTypeFromAnnotation); transformedType = semanticServices.getTypeTransformer().transformToType(returnTypeFromAnnotation, typeVariableResolver);
} else { } else {
transformedType = semanticServices.getTypeTransformer().transformToType(returnType); transformedType = semanticServices.getTypeTransformer().transformToType(returnType);
} }
@@ -59,9 +59,9 @@ public class JavaTypeTransformer {
} }
@NotNull @NotNull
public JetType transformToType(@NotNull String kotlinSignature) { public JetType transformToType(@NotNull String kotlinSignature, TypeVariableResolver typeVariableResolver) {
final JetType[] r = new JetType[1]; final JetType[] r = new JetType[1];
JetTypeJetSignatureReader reader = new JetTypeJetSignatureReader(resolver, standardLibrary) { JetTypeJetSignatureReader reader = new JetTypeJetSignatureReader(resolver, standardLibrary, typeVariableResolver) {
@Override @Override
protected void done(@NotNull JetType jetType) { protected void done(@NotNull JetType jetType) {
r[0] = jetType; r[0] = jetType;
@@ -2,6 +2,7 @@ package org.jetbrains.jet.lang.resolve.java;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor; import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.types.ErrorUtils; import org.jetbrains.jet.lang.types.ErrorUtils;
import org.jetbrains.jet.lang.types.JetStandardClasses; import org.jetbrains.jet.lang.types.JetStandardClasses;
@@ -25,10 +26,12 @@ public abstract class JetTypeJetSignatureReader extends JetSignatureExceptionsAd
private final JavaDescriptorResolver javaDescriptorResolver; private final JavaDescriptorResolver javaDescriptorResolver;
private final JetStandardLibrary jetStandardLibrary; private final JetStandardLibrary jetStandardLibrary;
private final TypeVariableResolver typeVariableResolver;
public JetTypeJetSignatureReader(JavaDescriptorResolver javaDescriptorResolver, JetStandardLibrary jetStandardLibrary) { public JetTypeJetSignatureReader(JavaDescriptorResolver javaDescriptorResolver, JetStandardLibrary jetStandardLibrary, TypeVariableResolver typeVariableResolver) {
this.javaDescriptorResolver = javaDescriptorResolver; this.javaDescriptorResolver = javaDescriptorResolver;
this.jetStandardLibrary = jetStandardLibrary; this.jetStandardLibrary = jetStandardLibrary;
this.typeVariableResolver = typeVariableResolver;
} }
@@ -111,7 +114,7 @@ public abstract class JetTypeJetSignatureReader extends JetSignatureExceptionsAd
@Override @Override
public JetSignatureVisitor visitTypeArgument(final char wildcard) { public JetSignatureVisitor visitTypeArgument(final char wildcard) {
return new JetTypeJetSignatureReader(javaDescriptorResolver, jetStandardLibrary) { return new JetTypeJetSignatureReader(javaDescriptorResolver, jetStandardLibrary, typeVariableResolver) {
@Override @Override
protected void done(@NotNull JetType jetType) { protected void done(@NotNull JetType jetType) {
@@ -122,7 +125,7 @@ public abstract class JetTypeJetSignatureReader extends JetSignatureExceptionsAd
@Override @Override
public JetSignatureVisitor visitArrayType(final boolean nullable) { public JetSignatureVisitor visitArrayType(final boolean nullable) {
return new JetTypeJetSignatureReader(javaDescriptorResolver, jetStandardLibrary) { return new JetTypeJetSignatureReader(javaDescriptorResolver, jetStandardLibrary, typeVariableResolver) {
@Override @Override
protected void done(@NotNull JetType jetType) { protected void done(@NotNull JetType jetType) {
JetType arrayType = TypeUtils.makeNullableAsSpecified(jetStandardLibrary.getArrayType(jetType), nullable); JetType arrayType = TypeUtils.makeNullableAsSpecified(jetStandardLibrary.getArrayType(jetType), nullable);
@@ -133,8 +136,8 @@ public abstract class JetTypeJetSignatureReader extends JetSignatureExceptionsAd
@Override @Override
public void visitTypeVariable(String name, boolean nullable) { public void visitTypeVariable(String name, boolean nullable) {
// TODO: need a way to get type TypeParameterDescriptor by name JetType r = TypeUtils.makeNullableAsSpecified(typeVariableResolver.getTypeVariable(name).getDefaultType(), nullable);
throw new IllegalStateException(); done(r);
} }
@Override @Override
@@ -0,0 +1,12 @@
package org.jetbrains.jet.lang.resolve.java;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
/**
* @author Stepan Koltsov
*/
public interface TypeVariableResolver {
@NotNull
TypeParameterDescriptor getTypeVariable(@NotNull String name);
}
@@ -10,7 +10,6 @@ import org.jetbrains.jet.lang.psi.*;
public interface JetNodeTypes { public interface JetNodeTypes {
IFileElementType JET_FILE = new IFileElementType(JetLanguage.INSTANCE); IFileElementType JET_FILE = new IFileElementType(JetLanguage.INSTANCE);
JetNodeType NAMESPACE = new JetNodeType("NAMESPACE", JetNamespace.class);
JetNodeType CLASS = new JetNodeType("CLASS", JetClass.class); JetNodeType CLASS = new JetNodeType("CLASS", JetClass.class);
JetNodeType PROPERTY = new JetNodeType("PROPERTY", JetProperty.class); JetNodeType PROPERTY = new JetNodeType("PROPERTY", JetProperty.class);
JetNodeType FUN = new JetNodeType("FUN", JetNamedFunction.class); JetNodeType FUN = new JetNodeType("FUN", JetNamedFunction.class);
@@ -35,7 +34,6 @@ public interface JetNodeTypes {
JetNodeType CLASS_BODY = new JetNodeType("CLASS_BODY", JetClassBody.class); JetNodeType CLASS_BODY = new JetNodeType("CLASS_BODY", JetClassBody.class);
JetNodeType IMPORT_DIRECTIVE = new JetNodeType("IMPORT_DIRECTIVE", JetImportDirective.class); JetNodeType IMPORT_DIRECTIVE = new JetNodeType("IMPORT_DIRECTIVE", JetImportDirective.class);
JetNodeType NAMESPACE_BODY = new JetNodeType("NAMESPACE_BODY", JetNamespaceBody.class);
JetNodeType MODIFIER_LIST = new JetNodeType("MODIFIER_LIST", JetModifierList.class); JetNodeType MODIFIER_LIST = new JetNodeType("MODIFIER_LIST", JetModifierList.class);
JetNodeType PRIMARY_CONSTRUCTOR_MODIFIER_LIST = new JetNodeType("PRIMARY_CONSTRUCTOR_MODIFIER_LIST", JetModifierList.class); JetNodeType PRIMARY_CONSTRUCTOR_MODIFIER_LIST = new JetNodeType("PRIMARY_CONSTRUCTOR_MODIFIER_LIST", JetModifierList.class);
JetNodeType ANNOTATION = new JetNodeType("ANNOTATION", JetAnnotation.class); JetNodeType ANNOTATION = new JetNodeType("ANNOTATION", JetAnnotation.class);
@@ -7,8 +7,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContext;
import static org.jetbrains.jet.lang.diagnostics.Severity.ERROR;
/** /**
* @author abreslav * @author abreslav
*/ */
@@ -4,6 +4,7 @@ import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.psi.JetNamedDeclaration; import org.jetbrains.jet.lang.psi.JetNamedDeclaration;
import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContext;
@@ -45,6 +46,13 @@ public class RedeclarationDiagnosticFactory extends AbstractDiagnosticFactory {
return nameIdentifier.getTextRange(); return nameIdentifier.getTextRange();
} }
} }
else if (redeclaration instanceof JetFile) {
JetFile file = (JetFile) redeclaration;
PsiElement nameIdentifier = file.getNamespaceHeader().getNameIdentifier();
if (nameIdentifier != null) {
return nameIdentifier.getTextRange();
}
}
return redeclaration.getTextRange(); return redeclaration.getTextRange();
} }
@@ -497,7 +497,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
* : functionLiteral * : functionLiteral
* : declaration * : declaration
* : SimpleName * : SimpleName
* : "namespace" // foo the root namespace * : "package" // foo the root namespace
* ; * ;
*/ */
private void parseAtomicExpression() { private void parseAtomicExpression() {
@@ -80,13 +80,11 @@ public class JetParsing extends AbstractJetParsing {
*/ */
public void parseFile() { public void parseFile() {
PsiBuilder.Marker fileMarker = mark(); PsiBuilder.Marker fileMarker = mark();
PsiBuilder.Marker namespaceMarker = mark();
parsePreamble(); parsePreamble();
parseToplevelDeclarations(false); parseToplevelDeclarations(false);
namespaceMarker.done(NAMESPACE);
fileMarker.done(JET_FILE); fileMarker.done(JET_FILE);
} }
@@ -377,45 +375,6 @@ public class JetParsing extends AbstractJetParsing {
attribute.done(ANNOTATION_ENTRY); attribute.done(ANNOTATION_ENTRY);
} }
/*
* namespace
* : "namespace" SimpleName{"."} "{"
* import*
* toplevelObject[| import]*
* "}"
* ;
*/
private JetNodeType parseNamespaceBlock() {
assert _at(NAMESPACE_KEYWORD);
PsiBuilder.Marker namespaceHeader = mark();
advance(); // NAMESPACE_KEYWORD
if (at(LBRACE)) {
error("Expecting namespace name");
}
else {
parseNamespaceName();
}
namespaceHeader.done(NAMESPACE_HEADER);
if (!at(LBRACE)) {
error("A namespace block in '{...}' expected");
return NAMESPACE;
}
myBuilder.enableNewlines();
advance(); // LBRACE
PsiBuilder.Marker namespaceBody = mark();
parseToplevelDeclarations(true);
namespaceBody.done(NAMESPACE_BODY);
expect(RBRACE, "Expecting '}'");
myBuilder.restoreNewlinesState();
return NAMESPACE;
}
/* /*
* class * class
* : modifiers ("class" | "trait") SimpleName * : modifiers ("class" | "trait") SimpleName
@@ -7,11 +7,14 @@ import com.intellij.extapi.psi.PsiFileBase;
import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.FileType;
import com.intellij.psi.FileViewProvider; import com.intellij.psi.FileViewProvider;
import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.JetNodeTypes; import org.jetbrains.jet.JetNodeTypes;
import org.jetbrains.jet.plugin.JetFileType; import org.jetbrains.jet.plugin.JetFileType;
import org.jetbrains.jet.plugin.JetLanguage; import org.jetbrains.jet.plugin.JetLanguage;
import java.util.List;
public class JetFile extends PsiFileBase { public class JetFile extends PsiFileBase {
public JetFile(FileViewProvider viewProvider) { public JetFile(FileViewProvider viewProvider) {
super(viewProvider, JetLanguage.INSTANCE); super(viewProvider, JetLanguage.INSTANCE);
@@ -27,9 +30,23 @@ public class JetFile extends PsiFileBase {
return "JetFile: " + getName(); return "JetFile: " + getName();
} }
public List<JetDeclaration> getDeclarations() {
return PsiTreeUtil.getChildrenOfTypeAsList(this, JetDeclaration.class);
}
public List<JetImportDirective> getImportDirectives() {
return PsiTreeUtil.getChildrenOfTypeAsList(this, JetImportDirective.class);
}
@NotNull @NotNull
public JetNamespace getRootNamespace() { public JetNamespaceHeader getNamespaceHeader() {
return (JetNamespace) getNode().findChildByType(JetNodeTypes.NAMESPACE).getPsi(); return (JetNamespaceHeader) getNode().findChildByType(JetNodeTypes.NAMESPACE_HEADER).getPsi();
}
@NotNull
@Override
public String getName() {
return super.getName(); // TODO
} }
@Override @Override
@@ -1,61 +0,0 @@
package org.jetbrains.jet.lang.psi;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.JetNodeTypes;
import java.util.List;
/**
* @author max
*/
public class JetNamespace extends JetNamedDeclaration {
public JetNamespace(@NotNull ASTNode node) {
super(node);
}
@Override
public void accept(@NotNull JetVisitorVoid visitor) {
visitor.visitNamespace(this);
}
@Override
public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
return visitor.visitNamespace(this, data);
}
public List<JetDeclaration> getDeclarations() {
PsiElement body = findChildByType(JetNodeTypes.NAMESPACE_BODY);
return PsiTreeUtil.getChildrenOfTypeAsList(body != null ? body : this, JetDeclaration.class);
}
public List<JetImportDirective> getImportDirectives() {
PsiElement body = findChildByType(JetNodeTypes.NAMESPACE_BODY);
return PsiTreeUtil.getChildrenOfTypeAsList(body != null ? body : this, JetImportDirective.class);
}
public String getName() {
String name = super.getName();
return name == null ? "" : name;
}
@NotNull
public JetNamespaceHeader getHeader() {
return (JetNamespaceHeader) findChildByType(JetNodeTypes.NAMESPACE_HEADER);
}
@Override
public PsiElement getNameIdentifier() {
return getHeader().getNameIdentifier();
}
@Override
public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException {
throw new UnsupportedOperationException();
}
}
@@ -1,52 +0,0 @@
package org.jetbrains.jet.lang.psi;
/**
* @author max
*/
//public class JetNewExpression extends JetExpression implements JetCallElement {
// public JetNewExpression(@NotNull ASTNode node) {
// super(node);
// }
//
// @Override
// public void accept(JetVisitorVoid visitor) {
// visitor.visitNewExpression(this);
// }
//
// @Nullable @IfNotParsed
// public JetTypeReference getTypeReference() {
// return (JetTypeReference) findChildByType(JetNodeTypes.TYPE_REFERENCE);
// }
//
// @Override
// @Nullable
// public JetValueArgumentList getValueArgumentList() {
// return (JetValueArgumentList) findChildByType(JetNodeTypes.VALUE_ARGUMENT_LIST);
// }
//
// @Override
// @NotNull
// public List<JetValueArgument> getValueArguments() {
// JetValueArgumentList list = getValueArgumentList();
// return list != null ? list.getArguments() : Collections.<JetValueArgument>emptyList();
// }
//
// @Override
// @NotNull
// public List<JetExpression> getFunctionLiteralArguments() {
// return findChildrenByType(JetNodeTypes.FUNCTION_LITERAL_EXPRESSION);
// }
//
// @NotNull
// @Override
// public List<JetTypeProjection> getTypeArguments() {
// return Collections.emptyList();
// }
//
// @NotNull
// @Override
// public JetElement asElement() {
// return this;
// }
//
//}
@@ -60,8 +60,7 @@ public class JetPsiFactory {
private static <T> T createDeclaration(Project project, String text, Class<T> clazz) { private static <T> T createDeclaration(Project project, String text, Class<T> clazz) {
JetFile file = createFile(project, text); JetFile file = createFile(project, text);
JetNamespace rootNamespace = file.getRootNamespace(); List<JetDeclaration> dcls = file.getDeclarations();
List<JetDeclaration> dcls = rootNamespace.getDeclarations();
assert dcls.size() == 1 : dcls.size(); assert dcls.size() == 1 : dcls.size();
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
T result = (T) dcls.get(0); T result = (T) dcls.get(0);
@@ -92,13 +91,13 @@ public class JetPsiFactory {
return function.getValueParameters().get(0); return function.getValueParameters().get(0);
} }
public static JetNamespace createNamespace(Project project, String text) { // public static JetNamespace createNamespace(Project project, String text) {
JetFile file = createFile(project, text); // JetFile file = createFile(project, text);
return file.getRootNamespace(); // return file.getRootNamespace();
} // }
public static JetImportDirective createImportDirective(Project project, String classPath) { public static JetImportDirective createImportDirective(Project project, String classPath) {
JetNamespace namespace = createNamespace(project, "import " + classPath); JetFile namespace = createFile(project, "import " + classPath);
return namespace.getImportDirectives().iterator().next(); return namespace.getImportDirectives().iterator().next();
} }
@@ -1,7 +1,6 @@
package org.jetbrains.jet.lang.psi; package org.jetbrains.jet.lang.psi;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lexer.JetTokens; import org.jetbrains.jet.lexer.JetTokens;
@@ -72,7 +71,7 @@ public class JetPsiUtil {
public static JetNamedFunction getSurroundingFunction(@Nullable PsiElement element) { public static JetNamedFunction getSurroundingFunction(@Nullable PsiElement element) {
while (element != null) { while (element != null) {
if (element instanceof JetNamedFunction) return (JetNamedFunction) element; if (element instanceof JetNamedFunction) return (JetNamedFunction) element;
if (element instanceof JetClassOrObject || element instanceof JetNamespace) return null; if (element instanceof JetClassOrObject || element instanceof JetFile) return null;
element = element.getParent(); element = element.getParent();
} }
return null; return null;
@@ -104,16 +103,16 @@ public class JetPsiUtil {
} }
} }
public static String getFQName(JetNamespace jetNamespace) { // public static String getFQName(JetNamespace jetNamespace) {
JetNamespace parent = PsiTreeUtil.getParentOfType(jetNamespace, JetNamespace.class); // JetNamespace parent = PsiTreeUtil.getParentOfType(jetNamespace, JetNamespace.class);
if (parent != null) { // if (parent != null) {
String parentFQName = getFQName(parent); // String parentFQName = getFQName(parent);
if (parentFQName.length() > 0) { // if (parentFQName.length() > 0) {
return parentFQName + "." + getFQName(jetNamespace.getHeader()); // return parentFQName + "." + getFQName(jetNamespace.getNamespaceHeader());
} // }
} // }
return getFQName(jetNamespace.getHeader()); // TODO: Must include module root namespace // return getFQName(jetNamespace.getNamespaceHeader()); // TODO: Must include module root namespace
} // }
private static String getFQName(JetNamespaceHeader header) { private static String getFQName(JetNamespaceHeader header) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
@@ -121,15 +120,18 @@ public class JetPsiUtil {
builder.append(nameExpression.getReferencedName()); builder.append(nameExpression.getReferencedName());
builder.append("."); builder.append(".");
} }
// PsiElement nameIdentifier = header.getNameIdentifier();
builder.append(header.getName()); builder.append(header.getName());
return builder.toString(); return builder.toString();
} }
public static String getFQName(JetFile file) {
return getFQName(file.getNamespaceHeader());
}
public static String getFQName(JetClass jetClass) { public static String getFQName(JetClass jetClass) {
JetNamedDeclaration parent = PsiTreeUtil.getParentOfType(jetClass, JetNamespace.class, JetClass.class); PsiElement parent = jetClass.getParent();
if (parent instanceof JetNamespace) { if (parent instanceof JetFile) {
return makeFQName(getFQName(((JetNamespace) parent)), jetClass); return makeFQName(getFQName((JetFile) parent), jetClass);
} }
if (parent instanceof JetClass) { if (parent instanceof JetClass) {
return makeFQName(getFQName(((JetClass) parent)), jetClass); return makeFQName(getFQName(((JetClass) parent)), jetClass);
@@ -15,10 +15,6 @@ public class JetVisitor<R, D> extends PsiElementVisitor {
return visitExpression(dcl, data); return visitExpression(dcl, data);
} }
public R visitNamespace(JetNamespace namespace, D data) {
return visitDeclaration(namespace, data);
}
public R visitClass(JetClass klass, D data) { public R visitClass(JetClass klass, D data) {
return visitNamedDeclaration(klass, data); return visitNamedDeclaration(klass, data);
} }
@@ -14,10 +14,6 @@ public class JetVisitorVoid extends PsiElementVisitor {
visitExpression(dcl); visitExpression(dcl);
} }
public void visitNamespace(JetNamespace namespace) {
visitDeclaration(namespace);
}
public void visitClass(JetClass klass) { public void visitClass(JetClass klass) {
visitNamedDeclaration(klass); visitNamedDeclaration(klass);
} }
@@ -16,7 +16,7 @@ import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.diagnostics.Diagnostic; import org.jetbrains.jet.lang.diagnostics.Diagnostic;
import org.jetbrains.jet.lang.diagnostics.DiagnosticHolder; import org.jetbrains.jet.lang.diagnostics.DiagnosticHolder;
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils; 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.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.resolve.scopes.WritableScope; import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl; import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
@@ -69,21 +69,21 @@ public class AnalyzingUtils {
// -------------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------------
public static BindingContext analyzeNamespaces( public static BindingContext analyzeFiles(
@NotNull Project project, @NotNull Project project,
@NotNull Configuration configuration, @NotNull Configuration configuration,
@NotNull Collection<? extends JetDeclaration> declarations, @NotNull Collection<JetFile> files,
@NotNull Predicate<PsiFile> filesToAnalyzeCompletely, @NotNull Predicate<PsiFile> filesToAnalyzeCompletely,
@NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) { @NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) {
BindingTraceContext bindingTraceContext = new BindingTraceContext(); BindingTraceContext bindingTraceContext = new BindingTraceContext();
JetSemanticServices semanticServices = JetSemanticServices.createSemanticServices(project); JetSemanticServices semanticServices = JetSemanticServices.createSemanticServices(project);
return analyzeNamespacesWithGivenTrace(project, configuration, declarations, filesToAnalyzeCompletely, flowDataTraceFactory, bindingTraceContext, semanticServices); return analyzeFilesWithGivenTrace(project, configuration, files, filesToAnalyzeCompletely, flowDataTraceFactory, bindingTraceContext, semanticServices);
} }
public static BindingContext analyzeNamespacesWithGivenTrace( public static BindingContext analyzeFilesWithGivenTrace(
@NotNull Project project, @NotNull Project project,
@NotNull Configuration configuration, @NotNull Configuration configuration,
@NotNull Collection<? extends JetDeclaration> declarations, @NotNull Collection<JetFile> files,
@NotNull Predicate<PsiFile> filesToAnalyzeCompletely, @NotNull Predicate<PsiFile> filesToAnalyzeCompletely,
@NotNull JetControlFlowDataTraceFactory flowDataTraceFactory, @NotNull JetControlFlowDataTraceFactory flowDataTraceFactory,
@NotNull BindingTraceContext bindingTraceContext, @NotNull BindingTraceContext bindingTraceContext,
@@ -130,7 +130,7 @@ public class AnalyzingUtils {
public ClassObjectStatus setClassObjectDescriptor(@NotNull MutableClassDescriptor classObjectDescriptor) { public ClassObjectStatus setClassObjectDescriptor(@NotNull MutableClassDescriptor classObjectDescriptor) {
throw new IllegalStateException("Must be guaranteed not to happen by the parser"); throw new IllegalStateException("Must be guaranteed not to happen by the parser");
} }
}, declarations, filesToAnalyzeCompletely, flowDataTraceFactory, configuration); }, files, filesToAnalyzeCompletely, flowDataTraceFactory, configuration);
return bindingTraceContext.getBindingContext(); return bindingTraceContext.getBindingContext();
} }
@@ -8,7 +8,6 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.diagnostics.Diagnostic; import org.jetbrains.jet.lang.diagnostics.Diagnostic;
import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.calls.ResolvedCall; import org.jetbrains.jet.lang.resolve.calls.ResolvedCall;
import org.jetbrains.jet.lang.resolve.calls.ResolvedCallImpl;
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.types.DeferredType; import org.jetbrains.jet.lang.types.DeferredType;
@@ -63,8 +63,8 @@ public class DeclarationResolver {
} }
private void resolveFunctionAndPropertyHeaders() { private void resolveFunctionAndPropertyHeaders() {
for (Map.Entry<JetNamespace, WritableScope> entry : context.getNamespaceScopes().entrySet()) { for (Map.Entry<JetFile, WritableScope> entry : context.getNamespaceScopes().entrySet()) {
JetNamespace namespace = entry.getKey(); JetFile namespace = entry.getKey();
WritableScope namespaceScope = entry.getValue(); WritableScope namespaceScope = entry.getValue();
NamespaceLike namespaceDescriptor = context.getNamespaceDescriptors().get(namespace); NamespaceLike namespaceDescriptor = context.getNamespaceDescriptors().get(namespace);
@@ -39,15 +39,15 @@ public class ImportsResolver {
private void processImports(boolean firstPhase) { private void processImports(boolean firstPhase) {
ImportResolver importResolver = new ImportResolver(context.getTrace(), firstPhase); ImportResolver importResolver = new ImportResolver(context.getTrace(), firstPhase);
for (JetNamespace jetNamespace : context.getNamespaceDescriptors().keySet()) { for (JetFile file : context.getNamespaceDescriptors().keySet()) {
WritableScope namespaceScope = context.getNamespaceScopes().get(jetNamespace); WritableScope namespaceScope = context.getNamespaceScopes().get(file);
if (firstPhase) { if (firstPhase) {
context.getConfiguration().addDefaultImports(context.getTrace(), namespaceScope); context.getConfiguration().addDefaultImports(context.getTrace(), namespaceScope);
} }
List<JetImportDirective> importDirectives = jetNamespace.getImportDirectives(); List<JetImportDirective> importDirectives = file.getImportDirectives();
for (JetImportDirective importDirective : importDirectives) { for (JetImportDirective importDirective : importDirectives) {
importResolver.processImportReference(importDirective, namespaceScope, context.getDeclaringScopes().get(jetNamespace)); importResolver.processImportReference(importDirective, namespaceScope, JetScope.EMPTY);
} }
} }
} }
@@ -30,8 +30,8 @@ import java.util.Set;
private final ImportsResolver importsResolver; private final ImportsResolver importsResolver;
private final Map<JetClass, MutableClassDescriptor> classes = Maps.newLinkedHashMap(); private final Map<JetClass, MutableClassDescriptor> classes = Maps.newLinkedHashMap();
private final Map<JetObjectDeclaration, MutableClassDescriptor> objects = Maps.newLinkedHashMap(); private final Map<JetObjectDeclaration, MutableClassDescriptor> objects = Maps.newLinkedHashMap();
protected final Map<JetNamespace, WritableScope> namespaceScopes = Maps.newHashMap(); protected final Map<JetFile, WritableScope> namespaceScopes = Maps.newHashMap();
protected final Map<JetNamespace, NamespaceDescriptorImpl> namespaceDescriptors = Maps.newHashMap(); protected final Map<JetFile, NamespaceDescriptorImpl> namespaceDescriptors = Maps.newHashMap();
private final Map<JetDeclaration, JetScope> declaringScopes = Maps.newHashMap(); private final Map<JetDeclaration, JetScope> declaringScopes = Maps.newHashMap();
private final Map<JetNamedFunction, FunctionDescriptorImpl> functions = Maps.newLinkedHashMap(); private final Map<JetNamedFunction, FunctionDescriptorImpl> functions = Maps.newLinkedHashMap();
@@ -114,11 +114,11 @@ import java.util.Set;
return objects; return objects;
} }
public Map<JetNamespace, WritableScope> getNamespaceScopes() { public Map<JetFile, WritableScope> getNamespaceScopes() {
return namespaceScopes; return namespaceScopes;
} }
public Map<JetNamespace, NamespaceDescriptorImpl> getNamespaceDescriptors() { public Map<JetFile, NamespaceDescriptorImpl> getNamespaceDescriptors() {
return namespaceDescriptors; return namespaceDescriptors;
} }
@@ -2,14 +2,14 @@ package org.jetbrains.jet.lang.resolve;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile; import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.Configuration; import org.jetbrains.jet.lang.Configuration;
import org.jetbrains.jet.lang.JetSemanticServices; import org.jetbrains.jet.lang.JetSemanticServices;
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.psi.JetDeclaration; import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.psi.JetNamespace;
import org.jetbrains.jet.lang.psi.JetObjectDeclaration; import org.jetbrains.jet.lang.psi.JetObjectDeclaration;
import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.resolve.scopes.WritableScope; import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
@@ -29,12 +29,12 @@ public class TopDownAnalyzer {
@NotNull BindingTrace trace, @NotNull BindingTrace trace,
@NotNull JetScope outerScope, @NotNull JetScope outerScope,
@NotNull NamespaceLike owner, @NotNull NamespaceLike owner,
@NotNull Collection<? extends JetDeclaration> declarations, @NotNull Collection<JetFile> files,
@NotNull Predicate<PsiFile> analyzeCompletely, @NotNull Predicate<PsiFile> analyzeCompletely,
@NotNull JetControlFlowDataTraceFactory flowDataTraceFactory, @NotNull JetControlFlowDataTraceFactory flowDataTraceFactory,
@NotNull Configuration configuration @NotNull Configuration configuration
) { ) {
process(semanticServices, trace, outerScope, owner, declarations, analyzeCompletely, flowDataTraceFactory, configuration, false); process(semanticServices, trace, outerScope, owner, files, analyzeCompletely, flowDataTraceFactory, configuration, false);
} }
private static void process( private static void process(
@@ -42,7 +42,7 @@ public class TopDownAnalyzer {
@NotNull BindingTrace trace, @NotNull BindingTrace trace,
@NotNull JetScope outerScope, @NotNull JetScope outerScope,
@NotNull NamespaceLike owner, @NotNull NamespaceLike owner,
@NotNull Collection<? extends JetDeclaration> declarations, @NotNull Collection<? extends PsiElement> declarations,
@NotNull Predicate<PsiFile> analyzeCompletely, @NotNull Predicate<PsiFile> analyzeCompletely,
@NotNull JetControlFlowDataTraceFactory flowDataTraceFactory, @NotNull JetControlFlowDataTraceFactory flowDataTraceFactory,
@NotNull Configuration configuration, @NotNull Configuration configuration,
@@ -55,7 +55,7 @@ public class TopDownAnalyzer {
private static void doProcess( private static void doProcess(
TopDownAnalysisContext context, JetScope outerScope, TopDownAnalysisContext context, JetScope outerScope,
NamespaceLike owner, NamespaceLike owner,
Collection<? extends JetDeclaration> declarations, Collection<? extends PsiElement> declarations,
JetControlFlowDataTraceFactory flowDataTraceFactory) { JetControlFlowDataTraceFactory flowDataTraceFactory) {
// context.enableDebugOutput(); // context.enableDebugOutput();
context.debug("Enter"); context.debug("Enter");
@@ -93,14 +93,14 @@ public class TopDownAnalyzer {
@NotNull BindingTrace trace, @NotNull BindingTrace trace,
@NotNull WritableScope outerScope, @NotNull WritableScope outerScope,
@NotNull NamespaceDescriptorImpl standardLibraryNamespace, @NotNull NamespaceDescriptorImpl standardLibraryNamespace,
@NotNull JetNamespace namespace) { @NotNull JetFile file) {
TopDownAnalysisContext context = new TopDownAnalysisContext(semanticServices, trace, Predicates.<PsiFile>alwaysTrue(), Configuration.EMPTY, false); TopDownAnalysisContext context = new TopDownAnalysisContext(semanticServices, trace, Predicates.<PsiFile>alwaysTrue(), Configuration.EMPTY, false);
context.getNamespaceScopes().put(namespace, standardLibraryNamespace.getMemberScope()); context.getNamespaceDescriptors().put(file, standardLibraryNamespace);
context.getNamespaceDescriptors().put(namespace, standardLibraryNamespace); context.getNamespaceScopes().put(file, standardLibraryNamespace.getMemberScope());
context.getDeclaringScopes().put(namespace, outerScope); // context.getDeclaringScopes().put(file, outerScope);
context.setAnalyzingBootstrapLibrary(true); context.setAnalyzingBootstrapLibrary(true);
doProcess(context, outerScope, standardLibraryNamespace, namespace.getDeclarations(), JetControlFlowDataTraceFactory.EMPTY); doProcess(context, outerScope, standardLibraryNamespace, file.getDeclarations(), JetControlFlowDataTraceFactory.EMPTY);
} }
public static void processObject( public static void processObject(
@@ -140,7 +140,7 @@ public class TopDownAnalyzer {
public ClassObjectStatus setClassObjectDescriptor(@NotNull MutableClassDescriptor classObjectDescriptor) { public ClassObjectStatus setClassObjectDescriptor(@NotNull MutableClassDescriptor classObjectDescriptor) {
return ClassObjectStatus.NOT_ALLOWED; return ClassObjectStatus.NOT_ALLOWED;
} }
}, Collections.<JetDeclaration>singletonList(object), Predicates.equalTo(object.getContainingFile()), JetControlFlowDataTraceFactory.EMPTY, Configuration.EMPTY, true); }, Collections.<PsiElement>singletonList(object), Predicates.equalTo(object.getContainingFile()), JetControlFlowDataTraceFactory.EMPTY, Configuration.EMPTY, true);
} }
} }
@@ -39,7 +39,7 @@ public class TypeHierarchyResolver {
this.context = context; this.context = context;
} }
public void process(@NotNull JetScope outerScope, @NotNull NamespaceLike owner, @NotNull Collection<? extends JetDeclaration> declarations) { public void process(@NotNull JetScope outerScope, @NotNull NamespaceLike owner, @NotNull Collection<? extends PsiElement> declarations) {
collectNamespacesAndClassifiers(outerScope, outerScope, owner, declarations); // namespaceScopes, classes collectNamespacesAndClassifiers(outerScope, outerScope, owner, declarations); // namespaceScopes, classes
context.getImportsResolver().processTypeImports(); context.getImportsResolver().processTypeImports();
@@ -67,22 +67,21 @@ public class TypeHierarchyResolver {
@NotNull final JetScope outerScope, @NotNull final JetScope outerScope,
@NotNull final JetScope outerScopeForStatic, @NotNull final JetScope outerScopeForStatic,
@NotNull final NamespaceLike owner, @NotNull final NamespaceLike owner,
@NotNull Collection<? extends JetDeclaration> declarations) { @NotNull Collection<? extends PsiElement> declarations) {
for (JetDeclaration declaration : declarations) { for (PsiElement declaration : declarations) {
declaration.accept(new JetVisitorVoid() { declaration.accept(new JetVisitorVoid() {
@Override @Override
public void visitNamespace(JetNamespace namespace) { public void visitJetFile(JetFile file) {
NamespaceDescriptorImpl namespaceDescriptor = createNamespaceDescriptorPathIfNeeded(namespace, owner); NamespaceDescriptorImpl namespaceDescriptor = createNamespaceDescriptorPathIfNeeded(file, owner);
context.getNamespaceDescriptors().put(namespace, namespaceDescriptor); context.getNamespaceDescriptors().put(file, namespaceDescriptor);
WriteThroughScope namespaceScope = new WriteThroughScope(outerScope, namespaceDescriptor.getMemberScope(), new TraceBasedRedeclarationHandler(context.getTrace())); WriteThroughScope namespaceScope = new WriteThroughScope(outerScope, namespaceDescriptor.getMemberScope(), new TraceBasedRedeclarationHandler(context.getTrace()));
namespaceScope.changeLockLevel(WritableScope.LockLevel.BOTH); namespaceScope.changeLockLevel(WritableScope.LockLevel.BOTH);
context.getNamespaceScopes().put(namespace, namespaceScope); context.getNamespaceScopes().put(file, namespaceScope);
context.getDeclaringScopes().put(namespace, outerScope);
// processImports(namespace, namespaceScope, outerScope); // processImports(namespace, namespaceScope, outerScope);
collectNamespacesAndClassifiers(namespaceScope, namespaceScope, namespaceDescriptor, namespace.getDeclarations()); collectNamespacesAndClassifiers(namespaceScope, namespaceScope, namespaceDescriptor, file.getDeclarations());
} }
@Override @Override
@@ -195,19 +194,19 @@ public class TypeHierarchyResolver {
} }
} }
private NamespaceDescriptorImpl createNamespaceDescriptorPathIfNeeded(JetNamespace namespace, NamespaceLike owner) { private NamespaceDescriptorImpl createNamespaceDescriptorPathIfNeeded(JetFile file, NamespaceLike owner) {
NamespaceLike currentOwner = owner; NamespaceLike currentOwner = owner;
for (JetSimpleNameExpression nameExpression : namespace.getHeader().getParentNamespaceNames()) { for (JetSimpleNameExpression nameExpression : file.getNamespaceHeader().getParentNamespaceNames()) {
currentOwner = createNamespaceDescriptorIfNeeded(null, currentOwner, JetPsiUtil.safeName(nameExpression.getReferencedName())); currentOwner = createNamespaceDescriptorIfNeeded(null, currentOwner, JetPsiUtil.safeName(nameExpression.getReferencedName()));
context.getTrace().record(REFERENCE_TARGET, nameExpression, currentOwner); context.getTrace().record(REFERENCE_TARGET, nameExpression, currentOwner);
} }
String name = JetPsiUtil.safeName(namespace.getName()); String name = JetPsiUtil.safeName(file.getNamespaceHeader().getName());
return createNamespaceDescriptorIfNeeded(namespace, currentOwner, name); return createNamespaceDescriptorIfNeeded(file, currentOwner, name);
} }
@NotNull @NotNull
private NamespaceDescriptorImpl createNamespaceDescriptorIfNeeded(@Nullable JetNamespace namespace, @NotNull NamespaceLike owner, @NotNull String name) { private NamespaceDescriptorImpl createNamespaceDescriptorIfNeeded(@Nullable JetFile file, @NotNull NamespaceLike owner, @NotNull String name) {
NamespaceDescriptorImpl namespaceDescriptor = owner.getNamespace(name); NamespaceDescriptorImpl namespaceDescriptor = owner.getNamespace(name);
if (namespaceDescriptor == null) { if (namespaceDescriptor == null) {
namespaceDescriptor = new NamespaceDescriptorImpl( namespaceDescriptor = new NamespaceDescriptorImpl(
@@ -221,8 +220,8 @@ public class TypeHierarchyResolver {
namespaceDescriptor.initialize(scope); namespaceDescriptor.initialize(scope);
context.getConfiguration().extendNamespaceScope(context.getTrace(), namespaceDescriptor, scope); context.getConfiguration().extendNamespaceScope(context.getTrace(), namespaceDescriptor, scope);
owner.addNamespace(namespaceDescriptor); owner.addNamespace(namespaceDescriptor);
if (namespace != null) { if (file != null) {
context.getTrace().record(BindingContext.NAMESPACE, namespace, namespaceDescriptor); context.getTrace().record(BindingContext.NAMESPACE, file, namespaceDescriptor);
} }
} }
return namespaceDescriptor; return namespaceDescriptor;
@@ -137,7 +137,7 @@ public class JetStandardLibrary {
writableScope.changeLockLevel(WritableScope.LockLevel.BOTH); writableScope.changeLockLevel(WritableScope.LockLevel.BOTH);
// this.libraryScope = bootstrappingTDA.process(JetStandardClasses.STANDARD_CLASSES, file.getRootNamespace().getDeclarations()); // this.libraryScope = bootstrappingTDA.process(JetStandardClasses.STANDARD_CLASSES, file.getRootNamespace().getDeclarations());
// bootstrappingTDA.process(writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace().getDeclarations()); // bootstrappingTDA.process(writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace().getDeclarations());
TopDownAnalyzer.processStandardLibraryNamespace(bootstrappingSemanticServices, bindingTraceContext, writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace()); TopDownAnalyzer.processStandardLibraryNamespace(bootstrappingSemanticServices, bindingTraceContext, writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file);
// this.libraryScope = JetStandardClasses.STANDARD_CLASSES_NAMESPACE.getMemberScope(); // this.libraryScope = JetStandardClasses.STANDARD_CLASSES_NAMESPACE.getMemberScope();
AnalyzingUtils.throwExceptionOnErrors(bindingTraceContext.getBindingContext()); AnalyzingUtils.throwExceptionOnErrors(bindingTraceContext.getBindingContext());
+1 -2
View File
@@ -1,7 +1,6 @@
import kotlin.modules.* import kotlin.modules.*
val modules = module("smoke") { val modules = module("smoke") {
source files "src/Smoke.kt" source files "Smoke.kt"
testSource files "test/SmokeTest.kt"
jar name System.getProperty("java.io.tmpdir") + "/smoke.jar" jar name System.getProperty("java.io.tmpdir") + "/smoke.jar"
} }
@@ -1,9 +0,0 @@
import std.io
import junit.framework.*
class SmokeTest() : TestCase() {
fun testMe() {
println("test")
}
}
@@ -1,5 +1,4 @@
JetFile: AnnotatedExpressions.jet JetFile: AnnotatedExpressions.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
@@ -1,5 +1,4 @@
JetFile: AnonymousInitializer.jet JetFile: AnonymousInitializer.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
CLASS CLASS
-1
View File
@@ -1,5 +1,4 @@
JetFile: Attributes.jet JetFile: Attributes.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
PsiElement(namespace)('package') PsiElement(namespace)('package')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
@@ -1,5 +1,4 @@
JetFile: AttributesOnPatterns.jet JetFile: AttributesOnPatterns.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
-1
View File
@@ -1,5 +1,4 @@
JetFile: Attributes_ERR.jet JetFile: Attributes_ERR.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
PsiElement(namespace)('package') PsiElement(namespace)('package')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
-1
View File
@@ -1,5 +1,4 @@
JetFile: BabySteps.jet JetFile: BabySteps.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
PsiElement(namespace)('package') PsiElement(namespace)('package')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
-1
View File
@@ -1,5 +1,4 @@
JetFile: BabySteps_ERR.jet JetFile: BabySteps_ERR.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
PsiElement(namespace)('package') PsiElement(namespace)('package')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
-1
View File
@@ -1,5 +1,4 @@
JetFile: ByCaluses.jet JetFile: ByCaluses.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
CLASS CLASS
@@ -1,5 +1,4 @@
JetFile: CallWithManyClosures.jet JetFile: CallWithManyClosures.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
PROPERTY PROPERTY
-1
View File
@@ -1,5 +1,4 @@
JetFile: CallsInWhen.jet JetFile: CallsInWhen.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
-1
View File
@@ -1,5 +1,4 @@
JetFile: Constructors.jet JetFile: Constructors.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
CLASS CLASS
@@ -1,5 +1,4 @@
JetFile: ControlStructures.jet JetFile: ControlStructures.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
-1
View File
@@ -1,5 +1,4 @@
JetFile: EOLsInComments.jet JetFile: EOLsInComments.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
-1
View File
@@ -1,5 +1,4 @@
JetFile: EOLsOnRollback.jet JetFile: EOLsOnRollback.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
-1
View File
@@ -1,4 +1,3 @@
JetFile: EmptyFile.jet JetFile: EmptyFile.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
-1
View File
@@ -1,5 +1,4 @@
JetFile: Enums.jet JetFile: Enums.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
CLASS CLASS
@@ -1,5 +1,4 @@
JetFile: Expressions_ERR.jet JetFile: Expressions_ERR.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
PROPERTY PROPERTY
@@ -1,5 +1,4 @@
JetFile: ExtensionsWithQNReceiver.jet JetFile: ExtensionsWithQNReceiver.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
PROPERTY PROPERTY
-1
View File
@@ -1,5 +1,4 @@
JetFile: FileStart_ERR.jet JetFile: FileStart_ERR.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
PsiErrorElement:Expecting namespace or top level declaration PsiErrorElement:Expecting namespace or top level declaration
-1
View File
@@ -1,5 +1,4 @@
JetFile: FunctionCalls.jet JetFile: FunctionCalls.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
@@ -1,5 +1,4 @@
JetFile: FunctionLiterals.jet JetFile: FunctionLiterals.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
@@ -1,5 +1,4 @@
JetFile: FunctionLiterals_ERR.jet JetFile: FunctionLiterals_ERR.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
-1
View File
@@ -1,5 +1,4 @@
JetFile: FunctionTypes.jet JetFile: FunctionTypes.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
TYPEDEF TYPEDEF
@@ -1,5 +1,4 @@
JetFile: FunctionTypes_ERR.jet JetFile: FunctionTypes_ERR.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
TYPEDEF TYPEDEF
-1
View File
@@ -1,5 +1,4 @@
JetFile: Functions.jet JetFile: Functions.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
-1
View File
@@ -1,5 +1,4 @@
JetFile: Functions_ERR.jet JetFile: Functions_ERR.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
@@ -1,5 +1,4 @@
JetFile: HangOnLonelyModifier.jet JetFile: HangOnLonelyModifier.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
-1
View File
@@ -1,5 +1,4 @@
JetFile: IfWithPropery.jet JetFile: IfWithPropery.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
PROPERTY PROPERTY
-1
View File
@@ -1,5 +1,4 @@
JetFile: ImportSoftKW.jet JetFile: ImportSoftKW.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
IMPORT_DIRECTIVE IMPORT_DIRECTIVE
-1
View File
@@ -1,5 +1,4 @@
JetFile: Imports.jet JetFile: Imports.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
PsiElement(namespace)('package') PsiElement(namespace)('package')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
-1
View File
@@ -1,5 +1,4 @@
JetFile: Imports_ERR.jet JetFile: Imports_ERR.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
PsiElement(namespace)('package') PsiElement(namespace)('package')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
-1
View File
@@ -1,5 +1,4 @@
JetFile: Labels.jet JetFile: Labels.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
@@ -1,5 +1,4 @@
JetFile: LocalDeclarations.jet JetFile: LocalDeclarations.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
@@ -1,7 +1,6 @@
JetFile: ModifierAsSelector.jet JetFile: ModifierAsSelector.jet
PsiComment(EOL_COMMENT)('// JET-1') PsiComment(EOL_COMMENT)('// JET-1')
PsiWhiteSpace('\n\n') PsiWhiteSpace('\n\n')
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
PROPERTY PROPERTY
@@ -1,5 +1,4 @@
JetFile: NamespaceBlockFirst.jet JetFile: NamespaceBlockFirst.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
PsiErrorElement:Expecting namespace or top level declaration PsiErrorElement:Expecting namespace or top level declaration
@@ -1,5 +1,4 @@
JetFile: NamespaceModifiers.jet JetFile: NamespaceModifiers.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
MODIFIER_LIST MODIFIER_LIST
PsiElement(public)('public') PsiElement(public)('public')
@@ -1,5 +1,4 @@
JetFile: NewLinesValidOperations.jet JetFile: NewLinesValidOperations.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
@@ -1,5 +1,4 @@
JetFile: NewlinesInParentheses.jet JetFile: NewlinesInParentheses.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
-1
View File
@@ -1,5 +1,4 @@
JetFile: NotIsAndNotIn.jet JetFile: NotIsAndNotIn.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
-1
View File
@@ -1,5 +1,4 @@
JetFile: Precedence.jet JetFile: Precedence.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
@@ -1,5 +1,4 @@
JetFile: PredicateExpression.jet JetFile: PredicateExpression.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
@@ -1,5 +1,4 @@
JetFile: PrimaryConstructorModifiers_ERR.jet JetFile: PrimaryConstructorModifiers_ERR.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
CLASS CLASS
-1
View File
@@ -1,5 +1,4 @@
JetFile: Properties.jet JetFile: Properties.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
PROPERTY PROPERTY
@@ -1,5 +1,4 @@
JetFile: PropertiesFollowedByInitializers.jet JetFile: PropertiesFollowedByInitializers.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
CLASS CLASS
-1
View File
@@ -1,5 +1,4 @@
JetFile: Properties_ERR.jet JetFile: Properties_ERR.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
PROPERTY PROPERTY
@@ -1,5 +1,4 @@
JetFile: QuotedIdentifiers.jet JetFile: QuotedIdentifiers.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
-1
View File
@@ -1,5 +1,4 @@
JetFile: RootNamespace.jet JetFile: RootNamespace.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
PsiElement(namespace)('package') PsiElement(namespace)('package')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
@@ -1,5 +1,4 @@
JetFile: SemicolonAfterIf.jet JetFile: SemicolonAfterIf.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
@@ -1,5 +1,4 @@
JetFile: ShortAnnotations.jet JetFile: ShortAnnotations.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
MODIFIER_LIST MODIFIER_LIST
ANNOTATION_ENTRY ANNOTATION_ENTRY
@@ -1,5 +1,4 @@
JetFile: SimpleClassMembers.jet JetFile: SimpleClassMembers.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
CLASS CLASS
@@ -1,5 +1,4 @@
JetFile: SimpleClassMembers_ERR.jet JetFile: SimpleClassMembers_ERR.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
CLASS CLASS
@@ -1,5 +1,4 @@
JetFile: SimpleExpressions.jet JetFile: SimpleExpressions.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
@@ -1,5 +1,4 @@
JetFile: SimpleModifiers.jet JetFile: SimpleModifiers.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
PsiElement(namespace)('package') PsiElement(namespace)('package')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
-1
View File
@@ -1,5 +1,4 @@
JetFile: SoftKeywords.jet JetFile: SoftKeywords.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
PsiElement(namespace)('package') PsiElement(namespace)('package')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
@@ -1,5 +1,4 @@
JetFile: SoftKeywordsInTypeArguments.jet JetFile: SoftKeywordsInTypeArguments.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
CLASS CLASS
@@ -1,5 +1,4 @@
JetFile: StringTemplates.jet JetFile: StringTemplates.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
-1
View File
@@ -1,7 +1,6 @@
JetFile: Super.jet JetFile: Super.jet
PsiComment(EOL_COMMENT)('// KT-156 Fix the this<Super> syntax') PsiComment(EOL_COMMENT)('// KT-156 Fix the this<Super> syntax')
PsiWhiteSpace('\n') PsiWhiteSpace('\n')
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
FUN FUN
-1
View File
@@ -1,5 +1,4 @@
JetFile: ThisType.jet JetFile: ThisType.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
CLASS CLASS
-1
View File
@@ -1,5 +1,4 @@
JetFile: TupleTypes.jet JetFile: TupleTypes.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
CLASS CLASS
-1
View File
@@ -1,5 +1,4 @@
JetFile: TupleTypes_ERR.jet JetFile: TupleTypes_ERR.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
CLASS CLASS
@@ -1,5 +1,4 @@
JetFile: TuplesWithLabeledEntries.jet JetFile: TuplesWithLabeledEntries.jet
NAMESPACE
NAMESPACE_HEADER NAMESPACE_HEADER
<empty list> <empty list>
PROPERTY PROPERTY

Some files were not shown because too many files have changed in this diff Show More