better import jet namespace
This commit is contained in:
@@ -796,7 +796,9 @@ public class JetTypeMapper {
|
||||
|
||||
private boolean isForceReal(JvmClassName className) {
|
||||
return JvmPrimitiveType.getByWrapperClass(className) != null
|
||||
|| className.getFqName().equals("java.lang.String") || className.getFqName().equals("java.lang.Object");
|
||||
|| className.getFqName().equals("java.lang.String")
|
||||
|| className.getFqName().equals("java.lang.CharSequence")
|
||||
|| className.getFqName().equals("java.lang.Object");
|
||||
}
|
||||
|
||||
public boolean isGenericsArray(JetType type) {
|
||||
|
||||
@@ -18,12 +18,16 @@ package org.jetbrains.jet.lang;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetImportDirective;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.ImportPath;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -32,7 +36,7 @@ import java.util.Collection;
|
||||
*/
|
||||
public class DefaultModuleConfiguration implements ModuleConfiguration {
|
||||
public static final ImportPath[] DEFAULT_JET_IMPORTS = new ImportPath[] {
|
||||
new ImportPath("kotlin.*"), new ImportPath("kotlin.io.*") };
|
||||
new ImportPath("kotlin.*"), new ImportPath("kotlin.io.*"), new ImportPath("jet.*"), };
|
||||
|
||||
private Project project;
|
||||
|
||||
@@ -53,5 +57,8 @@ public class DefaultModuleConfiguration implements ModuleConfiguration {
|
||||
|
||||
@Override
|
||||
public void extendNamespaceScope(@NotNull BindingTrace trace, @NotNull NamespaceDescriptor namespaceDescriptor, @NotNull WritableScope namespaceMemberScope) {
|
||||
if (DescriptorUtils.getFQName(namespaceDescriptor).equals(JetStandardClasses.STANDARD_CLASSES_FQNAME.toUnsafe())) {
|
||||
namespaceMemberScope.importScope(JetStandardLibrary.getInstance().getLibraryScope());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,14 +292,17 @@ public class TopDownAnalyzer {
|
||||
new TraceBasedRedeclarationHandler(topDownAnalysisParameters.getTrace())).setDebugName("Root scope in analyzeNamespace");
|
||||
scope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
||||
|
||||
// Import the lang package
|
||||
scope.importScope(JetStandardLibrary.getInstance().getLibraryScope());
|
||||
|
||||
NamespaceDescriptorImpl rootNs = namespaceFactory.createNamespaceDescriptorPathIfNeeded(FqName.ROOT);
|
||||
|
||||
// map "jet" namespace into JetStandardLibrary/Classes
|
||||
// @see DefaultModuleConfiguraiton#extendNamespaceScope
|
||||
namespaceFactory.createNamespaceDescriptorPathIfNeeded(JetStandardClasses.STANDARD_CLASSES_FQNAME);
|
||||
|
||||
// Import a scope that contains all top-level namespaces that come from dependencies
|
||||
// This makes the namespaces visible at all, does not import themselves
|
||||
scope.importScope(rootNs.getMemberScope());
|
||||
|
||||
scope.changeLockLevel(WritableScope.LockLevel.READING);
|
||||
|
||||
// dummy builder is used because "root" is module descriptor,
|
||||
// namespaces added to module explicitly in
|
||||
|
||||
@@ -22,6 +22,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.*;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -54,7 +56,9 @@ public class JetStandardClasses {
|
||||
FAKE_STANDARD_CLASSES_MODULE.setRootNs(STANDARD_CLASSES_FAKE_ROOT_NS);
|
||||
}
|
||||
|
||||
/*package*/ static NamespaceDescriptorImpl STANDARD_CLASSES_NAMESPACE = new NamespaceDescriptorImpl(STANDARD_CLASSES_FAKE_ROOT_NS, Collections.<AnnotationDescriptor>emptyList(), "jet");
|
||||
public static NamespaceDescriptorImpl STANDARD_CLASSES_NAMESPACE = new NamespaceDescriptorImpl(STANDARD_CLASSES_FAKE_ROOT_NS, Collections.<AnnotationDescriptor>emptyList(), "jet");
|
||||
|
||||
public static final FqName STANDARD_CLASSES_FQNAME = DescriptorUtils.getFQName(STANDARD_CLASSES_NAMESPACE).toSafe();
|
||||
|
||||
private static final ClassDescriptor NOTHING_CLASS = new ClassDescriptorImpl(
|
||||
STANDARD_CLASSES_NAMESPACE,
|
||||
|
||||
@@ -95,8 +95,8 @@ fun LinkedList<Int>.sum(f : (Int, Int) -> Int) : Int {
|
||||
}
|
||||
|
||||
fun <T> List<T>.backwards() : Iterable<T> = object : Iterable<T> {
|
||||
override fun iterator() : Iterator<T> =
|
||||
object : Iterator<T> {
|
||||
override fun iterator() : jet.Iterator<T> =
|
||||
object : jet.Iterator<T> {
|
||||
var current = size()
|
||||
override fun next() : T = get(--current)
|
||||
override val hasNext : Boolean get() = current > 0
|
||||
@@ -141,4 +141,4 @@ fun Reader.forEachChar(body : (Char) -> Unit) {
|
||||
if (i == -1) break
|
||||
body(i.toChar())
|
||||
} while(true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// KT-441 Exception in type inference when multiple overloads accepting an integer literal are accessible
|
||||
|
||||
import java.util.*
|
||||
import jet.Iterator
|
||||
|
||||
fun <T> Iterator<T>.foreach(operation: (element: T) -> Unit) : Unit = while(hasNext) operation(next())
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package kotlin.util
|
||||
|
||||
import java.util.*
|
||||
import jet.Iterator
|
||||
|
||||
fun <T, U: Collection<in T>> Iterator<T>.to(container: U) : U {
|
||||
while(hasNext)
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
namespace test
|
||||
|
||||
final fun ff(/*0*/ p: java.util.List<jet.CharSequence>): jet.Int
|
||||
final fun ff(/*0*/ p: java.util.List<java.lang.CharSequence>): jet.Int
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
namespace test
|
||||
|
||||
final fun ff(/*0*/ p: java.util.List<jet.CharSequence?>): jet.Int
|
||||
final fun ff(/*0*/ p: java.util.List<java.lang.CharSequence?>): jet.Int
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
namespace test
|
||||
|
||||
final fun ffgg(): java.util.List<jet.CharSequence>
|
||||
final fun ffgg(): java.util.List<java.lang.CharSequence>
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
namespace test
|
||||
|
||||
final fun ffgg(): java.util.List<jet.CharSequence?>
|
||||
final fun ffgg(): java.util.List<java.lang.CharSequence?>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace test
|
||||
|
||||
final val jet.Int.ggg: jet.CharSequence
|
||||
final val jet.Int.ggg: java.lang.CharSequence
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace test
|
||||
|
||||
final val jet.Int.ggg: jet.CharSequence?
|
||||
final val jet.Int.ggg: java.lang.CharSequence?
|
||||
|
||||
@@ -3,4 +3,4 @@ fun never(): Array<java.lang.CharSequence> = throw Exception()
|
||||
// method: namespace::never
|
||||
// jvm signature: ()[Ljava/lang/CharSequence;
|
||||
// generic signature: null
|
||||
// kotlin signature: ()[Ljava/lang/CharSequence; // TODO: need to skip kotlin signature
|
||||
// kotlin signature: ()[Mjava/lang/CharSequence; // TODO: need to skip kotlin signature
|
||||
|
||||
@@ -3,4 +3,4 @@ fun cc(): Comparable<java.lang.CharSequence>? = null
|
||||
// method: namespace::cc
|
||||
// jvm signature: ()Ljava/lang/Comparable;
|
||||
// generic signature: ()Ljava/lang/Comparable<Ljava/lang/CharSequence;>;
|
||||
// kotlin signature: ()?Ljava/lang/Comparable<Ljava/lang/CharSequence;>;
|
||||
// kotlin signature: ()?Ljava/lang/Comparable<Mjava/lang/CharSequence;>;
|
||||
|
||||
@@ -6,4 +6,4 @@ fun foo(p: List<CharSequence>) = 1
|
||||
// method: namespace::foo
|
||||
// jvm signature: (Ljava/util/List;)I
|
||||
// generic signature: (Ljava/util/List<Ljava/lang/CharSequence;>;)I
|
||||
// kotlin signature: (Ljava/util/List<Ljava/lang/CharSequence;>;)I // TODO: skip Kotlin signature
|
||||
// kotlin signature: (Ljava/util/List<Mjava/lang/CharSequence;>;)I // TODO: skip Kotlin signature
|
||||
|
||||
@@ -3,4 +3,4 @@ fun foo(vararg tail: java.lang.CharSequence) = 1
|
||||
// method: namespace::foo
|
||||
// jvm signature: ([Ljava/lang/CharSequence;)I
|
||||
// generic signature: null
|
||||
// kotlin signature: ([Ljava/lang/CharSequence;)I // TODO: need to skip kotlin signature
|
||||
// kotlin signature: ([Mjava/lang/CharSequence;)I // TODO: need to skip kotlin signature
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.util.*;
|
||||
import java.lang.*;
|
||||
|
||||
|
||||
|
||||
native
|
||||
val noImpl : Nothing = throw Exception();
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.DefaultModuleConfiguration;
|
||||
import org.jetbrains.jet.lang.ModuleConfiguration;
|
||||
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
@@ -30,6 +31,7 @@ import org.jetbrains.jet.lang.psi.JetImportDirective;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.lang.resolve.*;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.k2js.config.Config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -122,11 +124,13 @@ public final class AnalyzerFacadeForJS {
|
||||
public void addDefaultImports(@NotNull WritableScope rootScope,
|
||||
@NotNull Collection<JetImportDirective> directives) {
|
||||
directives.add(JetPsiFactory.createImportDirective(project, new ImportPath("js.*")));
|
||||
directives.add(JetPsiFactory.createImportDirective(project, new ImportPath(JetStandardClasses.STANDARD_CLASSES_FQNAME, true)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extendNamespaceScope(@NotNull BindingTrace trace, @NotNull NamespaceDescriptor namespaceDescriptor,
|
||||
@NotNull WritableScope namespaceMemberScope) {
|
||||
DefaultModuleConfiguration.createStandardConfiguration(project).extendNamespaceScope(trace, namespaceDescriptor, namespaceMemberScope);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package kotlin.concurrent
|
||||
|
||||
import java.lang.*
|
||||
import java.util.concurrent.Executor
|
||||
|
||||
inline val currentThread : Thread
|
||||
|
||||
Reference in New Issue
Block a user