Initial version of storing SourceElements in descriptors
Introduce SourceElement, JavaSourceElementFactory, DeclarationDescriptorWithSource Implement getSource() for eager, lazy and java descriptors
This commit is contained in:
@@ -38,7 +38,7 @@ public class AccessorForFunctionDescriptor extends SimpleFunctionDescriptorImpl
|
||||
) {
|
||||
super(containingDeclaration, null, Annotations.EMPTY,
|
||||
Name.identifier((descriptor instanceof ConstructorDescriptor ? "$init" : descriptor.getName()) + "$b$" + index),
|
||||
Kind.DECLARATION);
|
||||
Kind.DECLARATION, SourceElement.NO_SOURCE);
|
||||
|
||||
initialize(DescriptorUtils.getReceiverParameterType(descriptor.getReceiverParameter()),
|
||||
descriptor instanceof ConstructorDescriptor ? NO_RECEIVER_PARAMETER : descriptor.getExpectedThisObject(),
|
||||
@@ -56,7 +56,7 @@ public class AccessorForFunctionDescriptor extends SimpleFunctionDescriptorImpl
|
||||
for (TypeParameterDescriptor typeParameter : typeParameters) {
|
||||
TypeParameterDescriptorImpl copy = TypeParameterDescriptorImpl.createForFurtherModification(
|
||||
this, typeParameter.getAnnotations(), typeParameter.isReified(),
|
||||
typeParameter.getVariance(), typeParameter.getName(), typeParameter.getIndex()
|
||||
typeParameter.getVariance(), typeParameter.getName(), typeParameter.getIndex(), SourceElement.NO_SOURCE
|
||||
);
|
||||
for (JetType upperBound : typeParameter.getUpperBounds()) {
|
||||
copy.addUpperBound(upperBound);
|
||||
|
||||
@@ -45,7 +45,7 @@ public class AccessorForPropertyDescriptor extends PropertyDescriptorImpl {
|
||||
) {
|
||||
super(containingDeclaration, null, Annotations.EMPTY, Modality.FINAL, Visibilities.LOCAL,
|
||||
original.isVar(), Name.identifier(original.getName() + "$b$" + index),
|
||||
Kind.DECLARATION);
|
||||
Kind.DECLARATION, SourceElement.NO_SOURCE);
|
||||
|
||||
setType(propertyType, Collections.<TypeParameterDescriptorImpl>emptyList(), expectedThisObject, receiverType);
|
||||
initialize(new Getter(this), new Setter(this));
|
||||
@@ -54,15 +54,15 @@ public class AccessorForPropertyDescriptor extends PropertyDescriptorImpl {
|
||||
public static class Getter extends PropertyGetterDescriptorImpl {
|
||||
public Getter(AccessorForPropertyDescriptor property) {
|
||||
super(property, Annotations.EMPTY, Modality.FINAL, Visibilities.LOCAL,
|
||||
false,
|
||||
false, Kind.DECLARATION, null);
|
||||
false, false, Kind.DECLARATION, null, SourceElement.NO_SOURCE);
|
||||
initialize(property.getType());
|
||||
}
|
||||
}
|
||||
|
||||
public static class Setter extends PropertySetterDescriptorImpl {
|
||||
public Setter(AccessorForPropertyDescriptor property) {
|
||||
super(property, Annotations.EMPTY, Modality.FINAL, Visibilities.LOCAL, false, false, Kind.DECLARATION, null);
|
||||
super(property, Annotations.EMPTY, Modality.FINAL, Visibilities.LOCAL,
|
||||
false, false, Kind.DECLARATION, null, SourceElement.NO_SOURCE);
|
||||
initializeDefault();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,8 @@ public class JvmCodegenUtil {
|
||||
? KotlinBuiltIns.getInstance().getExtensionFunction(arity) : KotlinBuiltIns.getInstance().getFunction(arity),
|
||||
Annotations.EMPTY,
|
||||
Name.identifier("invoke"),
|
||||
CallableMemberDescriptor.Kind.DECLARATION
|
||||
CallableMemberDescriptor.Kind.DECLARATION,
|
||||
SourceElement.NO_SOURCE
|
||||
);
|
||||
|
||||
invokeDescriptor.initialize(DescriptorUtils.getReceiverParameterType(fd.getReceiverParameter()),
|
||||
|
||||
@@ -68,14 +68,14 @@ public class JvmRuntimeTypes {
|
||||
@NotNull String... typeParameters
|
||||
) {
|
||||
MutableClassDescriptor descriptor = new MutableClassDescriptor(packageFragment, packageFragment.getMemberScope(),
|
||||
ClassKind.CLASS, false, Name.identifier(name));
|
||||
ClassKind.CLASS, false, Name.identifier(name), SourceElement.NO_SOURCE);
|
||||
List<TypeParameterDescriptor> typeParameterDescriptors = new ArrayList<TypeParameterDescriptor>(typeParameters.length);
|
||||
for (int i = 0; i < typeParameters.length; i++) {
|
||||
String[] s = typeParameters[i].split(" ");
|
||||
Variance variance = Variance.valueOf(s[0].toUpperCase() + "_VARIANCE");
|
||||
String typeParameterName = s[1];
|
||||
TypeParameterDescriptorImpl typeParameter = TypeParameterDescriptorImpl.createForFurtherModification(
|
||||
descriptor, Annotations.EMPTY, false, variance, Name.identifier(typeParameterName), i
|
||||
descriptor, Annotations.EMPTY, false, variance, Name.identifier(typeParameterName), i, SourceElement.NO_SOURCE
|
||||
);
|
||||
typeParameter.setInitialized();
|
||||
typeParameterDescriptors.add(typeParameter);
|
||||
|
||||
@@ -52,6 +52,7 @@ import java.util.List;
|
||||
import static org.jetbrains.jet.codegen.AsmUtil.boxType;
|
||||
import static org.jetbrains.jet.codegen.AsmUtil.isPrimitive;
|
||||
import static org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor.Kind.SYNTHESIZED;
|
||||
import static org.jetbrains.jet.lang.descriptors.SourceElement.NO_SOURCE;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.VARIABLE;
|
||||
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.*;
|
||||
import static org.jetbrains.jet.lang.resolve.java.diagnostics.DiagnosticsPackage.OtherOrigin;
|
||||
@@ -203,7 +204,7 @@ public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclaratio
|
||||
if (clInit == null) {
|
||||
MethodVisitor mv = v.newMethod(OtherOrigin(descriptor), ACC_STATIC, "<clinit>", "()V", null, null);
|
||||
SimpleFunctionDescriptorImpl clInit =
|
||||
SimpleFunctionDescriptorImpl.create(descriptor, Annotations.EMPTY, Name.special("<clinit>"), SYNTHESIZED);
|
||||
SimpleFunctionDescriptorImpl.create(descriptor, Annotations.EMPTY, Name.special("<clinit>"), SYNTHESIZED, NO_SOURCE);
|
||||
clInit.initialize(null, null, Collections.<TypeParameterDescriptor>emptyList(),
|
||||
Collections.<ValueParameterDescriptor>emptyList(), null, null, Visibilities.PRIVATE);
|
||||
|
||||
|
||||
@@ -17,10 +17,6 @@
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.resolve.kotlin.PackagePartClassUtils;
|
||||
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.context.CodegenContext;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||
@@ -30,9 +26,13 @@ import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaClassDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.kotlin.PackagePartClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -69,7 +69,8 @@ public class SamWrapperCodegen {
|
||||
samType.getJavaClassDescriptor().getContainingDeclaration(),
|
||||
fqName.shortName(),
|
||||
Modality.FINAL,
|
||||
Collections.singleton(samType.getType())
|
||||
Collections.singleton(samType.getType()),
|
||||
SourceElement.NO_SOURCE
|
||||
);
|
||||
// e.g. compare(T, T)
|
||||
SimpleFunctionDescriptor erasedInterfaceFunction = samType.getAbstractMethod().getOriginal().copy(
|
||||
|
||||
+3
-2
@@ -100,8 +100,9 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
|
||||
|
||||
@NotNull
|
||||
private ClassDescriptor recordClassForFunction(@NotNull FunctionDescriptor funDescriptor, @NotNull Collection<JetType> supertypes) {
|
||||
ClassDescriptorImpl classDescriptor =
|
||||
new ClassDescriptorImpl(funDescriptor.getContainingDeclaration(), Name.special("<closure>"), Modality.FINAL, supertypes);
|
||||
ClassDescriptorImpl classDescriptor = new ClassDescriptorImpl(
|
||||
funDescriptor.getContainingDeclaration(), Name.special("<closure>"), Modality.FINAL, supertypes, SourceElement.NO_SOURCE
|
||||
);
|
||||
classDescriptor.initialize(JetScope.EMPTY, Collections.<ConstructorDescriptor>emptySet(), null);
|
||||
|
||||
bindingTrace.record(CLASS_FOR_FUNCTION, funDescriptor, classDescriptor);
|
||||
|
||||
@@ -142,7 +142,7 @@ public class CodegenBinding {
|
||||
) {
|
||||
ClassDescriptorImpl classDescriptor =
|
||||
new ClassDescriptorImpl(scriptDescriptor, Name.special("<script-" + asmType.getInternalName() + ">"), Modality.FINAL,
|
||||
Collections.singleton(KotlinBuiltIns.getInstance().getAnyType()));
|
||||
Collections.singleton(KotlinBuiltIns.getInstance().getAnyType()), SourceElement.NO_SOURCE);
|
||||
classDescriptor.initialize(JetScope.EMPTY, Collections.<ConstructorDescriptor>emptySet(), null);
|
||||
|
||||
recordClosure(bindingTrace, null, classDescriptor, null, asmType);
|
||||
|
||||
@@ -179,7 +179,7 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
|
||||
@NotNull
|
||||
public ConstructorContext intoConstructor(@Nullable ConstructorDescriptor descriptor, @Nullable MutableClosure closure) {
|
||||
if (descriptor == null) {
|
||||
descriptor = ConstructorDescriptorImpl.create(getThisDescriptor(), Annotations.EMPTY, true)
|
||||
descriptor = ConstructorDescriptorImpl.create(getThisDescriptor(), Annotations.EMPTY, true, SourceElement.NO_SOURCE)
|
||||
.initialize(Collections.<TypeParameterDescriptor>emptyList(), Collections.<ValueParameterDescriptor>emptyList(),
|
||||
Visibilities.PUBLIC, false);
|
||||
}
|
||||
|
||||
+4
-1
@@ -29,6 +29,7 @@ import org.jetbrains.jet.lang.resolve.java.resolver.TraceBasedErrorReporter;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.PsiBasedMethodSignatureChecker;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.PsiBasedExternalAnnotationResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaPropertyInitializerEvaluatorImpl;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaSourceElementFactoryImpl;
|
||||
import org.jetbrains.jet.lang.resolve.kotlin.VirtualFileFinder;
|
||||
import org.jetbrains.jet.lang.resolve.java.lazy.LazyJavaPackageFragmentProvider;
|
||||
import org.jetbrains.jet.lang.resolve.java.lazy.GlobalJavaResolverContext;
|
||||
@@ -58,6 +59,7 @@ public class InjectorForJavaDescriptorResolver {
|
||||
private final PsiBasedMethodSignatureChecker psiBasedMethodSignatureChecker;
|
||||
private final PsiBasedExternalAnnotationResolver psiBasedExternalAnnotationResolver;
|
||||
private final JavaPropertyInitializerEvaluatorImpl javaPropertyInitializerEvaluator;
|
||||
private final JavaSourceElementFactoryImpl javaSourceElementFactory;
|
||||
private final VirtualFileFinder virtualFileFinder;
|
||||
private final LazyJavaPackageFragmentProvider lazyJavaPackageFragmentProvider;
|
||||
private final GlobalJavaResolverContext globalJavaResolverContext;
|
||||
@@ -86,7 +88,8 @@ public class InjectorForJavaDescriptorResolver {
|
||||
this.psiBasedMethodSignatureChecker = new PsiBasedMethodSignatureChecker();
|
||||
this.traceBasedJavaResolverCache = new TraceBasedJavaResolverCache();
|
||||
this.javaPropertyInitializerEvaluator = new JavaPropertyInitializerEvaluatorImpl();
|
||||
this.globalJavaResolverContext = new GlobalJavaResolverContext(lockBasedStorageManager, getJavaClassFinder(), virtualFileFinder, deserializedDescriptorResolver, psiBasedExternalAnnotationResolver, traceBasedExternalSignatureResolver, traceBasedErrorReporter, psiBasedMethodSignatureChecker, traceBasedJavaResolverCache, javaPropertyInitializerEvaluator);
|
||||
this.javaSourceElementFactory = new JavaSourceElementFactoryImpl();
|
||||
this.globalJavaResolverContext = new GlobalJavaResolverContext(lockBasedStorageManager, getJavaClassFinder(), virtualFileFinder, deserializedDescriptorResolver, psiBasedExternalAnnotationResolver, traceBasedExternalSignatureResolver, traceBasedErrorReporter, psiBasedMethodSignatureChecker, traceBasedJavaResolverCache, javaPropertyInitializerEvaluator, javaSourceElementFactory);
|
||||
this.lazyJavaPackageFragmentProvider = new LazyJavaPackageFragmentProvider(globalJavaResolverContext, getModule());
|
||||
this.javaDescriptorResolver = new JavaDescriptorResolver(lazyJavaPackageFragmentProvider, getModule());
|
||||
this.javaClassDataFinder = new JavaClassDataFinder(virtualFileFinder, deserializedDescriptorResolver);
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.jetbrains.jet.lang.resolve.java.resolver.TraceBasedErrorReporter;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.PsiBasedMethodSignatureChecker;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.PsiBasedExternalAnnotationResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaPropertyInitializerEvaluatorImpl;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaSourceElementFactoryImpl;
|
||||
import org.jetbrains.jet.lang.resolve.AnnotationResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.ArgumentTypeResolver;
|
||||
@@ -85,6 +86,7 @@ public class InjectorForLazyResolveWithJava {
|
||||
private final PsiBasedMethodSignatureChecker psiBasedMethodSignatureChecker;
|
||||
private final PsiBasedExternalAnnotationResolver psiBasedExternalAnnotationResolver;
|
||||
private final JavaPropertyInitializerEvaluatorImpl javaPropertyInitializerEvaluator;
|
||||
private final JavaSourceElementFactoryImpl javaSourceElementFactory;
|
||||
private final AnnotationResolver annotationResolver;
|
||||
private final CallResolver callResolver;
|
||||
private final ArgumentTypeResolver argumentTypeResolver;
|
||||
@@ -137,7 +139,8 @@ public class InjectorForLazyResolveWithJava {
|
||||
this.psiBasedMethodSignatureChecker = new PsiBasedMethodSignatureChecker();
|
||||
this.lazyResolveBasedCache = new LazyResolveBasedCache();
|
||||
this.javaPropertyInitializerEvaluator = new JavaPropertyInitializerEvaluatorImpl();
|
||||
this.globalJavaResolverContext = new GlobalJavaResolverContext(lockBasedStorageManager, javaClassFinder, virtualFileFinder, deserializedDescriptorResolver, psiBasedExternalAnnotationResolver, traceBasedExternalSignatureResolver, traceBasedErrorReporter, psiBasedMethodSignatureChecker, lazyResolveBasedCache, javaPropertyInitializerEvaluator);
|
||||
this.javaSourceElementFactory = new JavaSourceElementFactoryImpl();
|
||||
this.globalJavaResolverContext = new GlobalJavaResolverContext(lockBasedStorageManager, javaClassFinder, virtualFileFinder, deserializedDescriptorResolver, psiBasedExternalAnnotationResolver, traceBasedExternalSignatureResolver, traceBasedErrorReporter, psiBasedMethodSignatureChecker, lazyResolveBasedCache, javaPropertyInitializerEvaluator, javaSourceElementFactory);
|
||||
this.lazyJavaPackageFragmentProvider = new LazyJavaPackageFragmentProvider(globalJavaResolverContext, getModule());
|
||||
this.javaDescriptorResolver = new JavaDescriptorResolver(lazyJavaPackageFragmentProvider, getModule());
|
||||
this.annotationResolver = new AnnotationResolver();
|
||||
|
||||
+4
-1
@@ -34,6 +34,7 @@ import org.jetbrains.jet.lang.resolve.java.resolver.TraceBasedErrorReporter;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.PsiBasedMethodSignatureChecker;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.PsiBasedExternalAnnotationResolver;
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaPropertyInitializerEvaluatorImpl;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.JavaSourceElementFactoryImpl;
|
||||
import org.jetbrains.jet.lang.resolve.kotlin.VirtualFileFinder;
|
||||
import org.jetbrains.jet.lang.resolve.BodyResolver;
|
||||
import org.jetbrains.jet.lang.resolve.AnnotationResolver;
|
||||
@@ -96,6 +97,7 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
|
||||
private final PsiBasedMethodSignatureChecker psiBasedMethodSignatureChecker;
|
||||
private final PsiBasedExternalAnnotationResolver psiBasedExternalAnnotationResolver;
|
||||
private final JavaPropertyInitializerEvaluatorImpl javaPropertyInitializerEvaluator;
|
||||
private final JavaSourceElementFactoryImpl javaSourceElementFactory;
|
||||
private final VirtualFileFinder virtualFileFinder;
|
||||
private final BodyResolver bodyResolver;
|
||||
private final AnnotationResolver annotationResolver;
|
||||
@@ -158,7 +160,8 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
|
||||
this.psiBasedMethodSignatureChecker = new PsiBasedMethodSignatureChecker();
|
||||
this.traceBasedJavaResolverCache = new TraceBasedJavaResolverCache();
|
||||
this.javaPropertyInitializerEvaluator = new JavaPropertyInitializerEvaluatorImpl();
|
||||
this.globalJavaResolverContext = new GlobalJavaResolverContext(storageManager, javaClassFinder, virtualFileFinder, deserializedDescriptorResolver, psiBasedExternalAnnotationResolver, traceBasedExternalSignatureResolver, traceBasedErrorReporter, psiBasedMethodSignatureChecker, traceBasedJavaResolverCache, javaPropertyInitializerEvaluator);
|
||||
this.javaSourceElementFactory = new JavaSourceElementFactoryImpl();
|
||||
this.globalJavaResolverContext = new GlobalJavaResolverContext(storageManager, javaClassFinder, virtualFileFinder, deserializedDescriptorResolver, psiBasedExternalAnnotationResolver, traceBasedExternalSignatureResolver, traceBasedErrorReporter, psiBasedMethodSignatureChecker, traceBasedJavaResolverCache, javaPropertyInitializerEvaluator, javaSourceElementFactory);
|
||||
this.lazyJavaPackageFragmentProvider = new LazyJavaPackageFragmentProvider(globalJavaResolverContext, getModuleDescriptor());
|
||||
this.javaDescriptorResolver = new JavaDescriptorResolver(lazyJavaPackageFragmentProvider, getModuleDescriptor());
|
||||
this.javaClassDataFinder = new JavaClassDataFinder(virtualFileFinder, deserializedDescriptorResolver);
|
||||
|
||||
+4
-1
@@ -22,6 +22,7 @@ import com.intellij.util.containers.ComparatorUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement;
|
||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl;
|
||||
@@ -211,7 +212,9 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
altName != null ? altName : originalParameterDescriptor.getName(),
|
||||
alternativeType,
|
||||
originalParameterDescriptor.declaresDefaultValue(),
|
||||
alternativeVarargElementType));
|
||||
alternativeVarargElementType,
|
||||
SourceElement.NO_SOURCE
|
||||
));
|
||||
}
|
||||
|
||||
altValueParameters = altParamDescriptors;
|
||||
|
||||
+6
-3
@@ -30,10 +30,10 @@ import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.ValueParameterDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.KotlinToJvmSignatureMapper;
|
||||
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaMethodDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmSignaturePackage;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.KotlinToJvmSignatureMapper;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.TypeUsage;
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaMethod;
|
||||
@@ -99,7 +99,9 @@ public class SignaturesPropagationData {
|
||||
JavaMethodDescriptor autoMethodDescriptor = JavaMethodDescriptor.createJavaMethod(
|
||||
containingClass,
|
||||
Annotations.EMPTY,
|
||||
method.getName()
|
||||
method.getName(),
|
||||
//TODO: what to do?
|
||||
SourceElement.NO_SOURCE
|
||||
);
|
||||
autoMethodDescriptor.initialize(
|
||||
receiverType,
|
||||
@@ -253,7 +255,8 @@ public class SignaturesPropagationData {
|
||||
stableName != null ? stableName : originalParam.getName(),
|
||||
altType,
|
||||
originalParam.declaresDefaultValue(),
|
||||
varargCheckResult.isVararg ? KotlinBuiltIns.getInstance().getArrayElementType(altType) : null
|
||||
varargCheckResult.isVararg ? KotlinBuiltIns.getInstance().getArrayElementType(altType) : null,
|
||||
SourceElement.NO_SOURCE
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.java.resolver
|
||||
|
||||
import org.jetbrains.jet.lang.resolve.source.PsiSourceElement
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaElement
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaElementImpl
|
||||
import org.jetbrains.jet.lang.resolve.java.sources.JavaSourceElementFactory
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement
|
||||
|
||||
private class JavaSourceElementImpl(val element: JavaElement) : PsiSourceElement {
|
||||
override val psi: PsiElement?
|
||||
get() = (element as JavaElementImpl<*>).getPsi()
|
||||
}
|
||||
|
||||
public class JavaSourceElementFactoryImpl : JavaSourceElementFactory {
|
||||
override fun source(javaElement: JavaElement): SourceElement = JavaSourceElementImpl(javaElement)
|
||||
}
|
||||
+4
-6
@@ -18,10 +18,7 @@ package org.jetbrains.jet.lang.descriptors.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptorVisitor;
|
||||
import org.jetbrains.jet.lang.descriptors.Visibilities;
|
||||
import org.jetbrains.jet.lang.descriptors.Visibility;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -35,9 +32,10 @@ public class LocalVariableDescriptor extends VariableDescriptorImpl {
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull Name name,
|
||||
@Nullable JetType type,
|
||||
boolean mutable
|
||||
boolean mutable,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(containingDeclaration, annotations, name, type);
|
||||
super(containingDeclaration, annotations, name, type, source);
|
||||
isVar = mutable;
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -65,9 +65,10 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
|
||||
@NotNull JetScope outerScope,
|
||||
@NotNull ClassKind kind,
|
||||
boolean isInner,
|
||||
@NotNull Name name
|
||||
@NotNull Name name,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(LockBasedStorageManager.NO_LOCKS, containingDeclaration, name);
|
||||
super(LockBasedStorageManager.NO_LOCKS, containingDeclaration, name, source);
|
||||
this.kind = kind;
|
||||
this.isInner = isInner;
|
||||
|
||||
|
||||
+18
-12
@@ -57,12 +57,14 @@ public class ScriptDescriptorImpl extends DeclarationDescriptorNonRootImpl imple
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
int priority,
|
||||
@NotNull JetScope scriptScope,
|
||||
@NotNull Name className
|
||||
@NotNull Name className,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(containingDeclaration, Annotations.EMPTY, NAME);
|
||||
super(containingDeclaration, Annotations.EMPTY, NAME, source);
|
||||
this.priority = priority;
|
||||
|
||||
classDescriptor = new MutableClassDescriptor(containingDeclaration, scriptScope, ClassKind.CLASS, false, className);
|
||||
classDescriptor = new MutableClassDescriptor(containingDeclaration, scriptScope, ClassKind.CLASS,
|
||||
false, className, SourceElement.NO_SOURCE);
|
||||
classDescriptor.addSupertype(KotlinBuiltIns.getInstance().getAnyType());
|
||||
classDescriptor.setModality(Modality.FINAL);
|
||||
classDescriptor.setVisibility(Visibilities.PUBLIC);
|
||||
@@ -102,7 +104,8 @@ public class ScriptDescriptorImpl extends DeclarationDescriptorNonRootImpl imple
|
||||
Visibilities.PUBLIC,
|
||||
false,
|
||||
Name.identifier(LAST_EXPRESSION_VALUE_FIELD_NAME),
|
||||
CallableMemberDescriptor.Kind.DECLARATION);
|
||||
CallableMemberDescriptor.Kind.DECLARATION,
|
||||
SourceElement.NO_SOURCE);
|
||||
JetType returnType = scriptDescriptor.getScriptCodeDescriptor().getReturnType();
|
||||
assert returnType != null : "Return type not initialized for " + scriptDescriptor;
|
||||
propertyDescriptor.setType(
|
||||
@@ -164,7 +167,7 @@ public class ScriptDescriptorImpl extends DeclarationDescriptorNonRootImpl imple
|
||||
public static ConstructorDescriptorImpl createConstructor(
|
||||
@NotNull ScriptDescriptor scriptDescriptor, @NotNull List<ValueParameterDescriptor> valueParameters
|
||||
) {
|
||||
return ConstructorDescriptorImpl.create(scriptDescriptor.getClassDescriptor(), Annotations.EMPTY, true)
|
||||
return ConstructorDescriptorImpl.create(scriptDescriptor.getClassDescriptor(), Annotations.EMPTY, true, SourceElement.NO_SOURCE)
|
||||
.initialize(
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
valueParameters,
|
||||
@@ -178,13 +181,16 @@ public class ScriptDescriptorImpl extends DeclarationDescriptorNonRootImpl imple
|
||||
@NotNull ScriptDescriptor scriptDescriptor,
|
||||
@NotNull ValueParameterDescriptor parameter
|
||||
) {
|
||||
PropertyDescriptorImpl propertyDescriptor = PropertyDescriptorImpl.create(scriptDescriptor.getClassDescriptor(),
|
||||
Annotations.EMPTY,
|
||||
Modality.FINAL,
|
||||
Visibilities.PUBLIC,
|
||||
false,
|
||||
parameter.getName(),
|
||||
CallableMemberDescriptor.Kind.DECLARATION);
|
||||
PropertyDescriptorImpl propertyDescriptor = PropertyDescriptorImpl.create(
|
||||
scriptDescriptor.getClassDescriptor(),
|
||||
Annotations.EMPTY,
|
||||
Modality.FINAL,
|
||||
Visibilities.PUBLIC,
|
||||
false,
|
||||
parameter.getName(),
|
||||
CallableMemberDescriptor.Kind.DECLARATION,
|
||||
SourceElement.NO_SOURCE
|
||||
);
|
||||
propertyDescriptor.setType(
|
||||
parameter.getType(),
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
|
||||
@@ -57,6 +57,7 @@ import static org.jetbrains.jet.lang.diagnostics.Errors.*;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.*;
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.*;
|
||||
import static org.jetbrains.jet.lang.resolve.ModifiersChecker.*;
|
||||
import static org.jetbrains.jet.lang.resolve.source.SourcePackage.toSourceElement;
|
||||
import static org.jetbrains.jet.lexer.JetTokens.OVERRIDE_KEYWORD;
|
||||
import static org.jetbrains.jet.lexer.JetTokens.VARARG_KEYWORD;
|
||||
|
||||
@@ -127,7 +128,8 @@ public class DescriptorResolver {
|
||||
typeParameter.hasModifier(JetTokens.REIFIED_KEYWORD),
|
||||
typeParameter.getVariance(),
|
||||
JetPsiUtil.safeName(typeParameter.getName()),
|
||||
index
|
||||
index,
|
||||
toSourceElement(typeParameter)
|
||||
);
|
||||
trace.record(BindingContext.TYPE_PARAMETER, typeParameter, typeParameterDescriptor);
|
||||
typeParameters.add(typeParameterDescriptor);
|
||||
@@ -302,7 +304,8 @@ public class DescriptorResolver {
|
||||
containingDescriptor,
|
||||
annotations,
|
||||
JetPsiUtil.safeName(function.getName()),
|
||||
CallableMemberDescriptor.Kind.DECLARATION
|
||||
CallableMemberDescriptor.Kind.DECLARATION,
|
||||
toSourceElement(function)
|
||||
);
|
||||
WritableScope innerScope = new WritableScopeImpl(scope, functionDescriptor, new TraceBasedRedeclarationHandler(trace),
|
||||
"Function descriptor header scope");
|
||||
@@ -386,7 +389,8 @@ public class DescriptorResolver {
|
||||
classDescriptor,
|
||||
Annotations.EMPTY,
|
||||
Name.identifier(functionName),
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
SourceElement.NO_SOURCE
|
||||
);
|
||||
|
||||
functionDescriptor.initialize(
|
||||
@@ -416,7 +420,8 @@ public class DescriptorResolver {
|
||||
classDescriptor,
|
||||
Annotations.EMPTY,
|
||||
COPY_METHOD_NAME,
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
SourceElement.NO_SOURCE
|
||||
);
|
||||
|
||||
List<ValueParameterDescriptor> parameterDescriptors = Lists.newArrayList();
|
||||
@@ -429,7 +434,7 @@ public class DescriptorResolver {
|
||||
new ValueParameterDescriptorImpl(functionDescriptor, null, parameter.getIndex(), parameter.getAnnotations(),
|
||||
parameter.getName(), parameter.getType(),
|
||||
declaresDefaultValue,
|
||||
parameter.getVarargElementType());
|
||||
parameter.getVarargElementType(), SourceElement.NO_SOURCE);
|
||||
parameterDescriptors.add(parameterDescriptor);
|
||||
if (declaresDefaultValue) {
|
||||
trace.record(BindingContext.VALUE_PARAMETER_AS_PROPERTY, parameterDescriptor, propertyDescriptor);
|
||||
@@ -555,7 +560,8 @@ public class DescriptorResolver {
|
||||
JetPsiUtil.safeName(valueParameter.getName()),
|
||||
variableType,
|
||||
valueParameter.hasDefaultValue(),
|
||||
varargElementType
|
||||
varargElementType,
|
||||
toSourceElement(valueParameter)
|
||||
);
|
||||
|
||||
trace.record(BindingContext.VALUE_PARAMETER, valueParameter, valueParameterDescriptor);
|
||||
@@ -606,7 +612,8 @@ public class DescriptorResolver {
|
||||
typeParameter.hasModifier(JetTokens.REIFIED_KEYWORD),
|
||||
typeParameter.getVariance(),
|
||||
JetPsiUtil.safeName(typeParameter.getName()),
|
||||
index
|
||||
index,
|
||||
toSourceElement(typeParameter)
|
||||
);
|
||||
trace.record(BindingContext.TYPE_PARAMETER, typeParameter, typeParameterDescriptor);
|
||||
extensibleScope.addTypeParameterDescriptor(typeParameterDescriptor);
|
||||
@@ -615,11 +622,12 @@ public class DescriptorResolver {
|
||||
|
||||
@NotNull
|
||||
public static ConstructorDescriptorImpl createAndRecordPrimaryConstructorForObject(
|
||||
@Nullable PsiElement object,
|
||||
@Nullable JetClassOrObject object,
|
||||
@NotNull ClassDescriptor classDescriptor,
|
||||
@NotNull BindingTrace trace
|
||||
) {
|
||||
ConstructorDescriptorImpl constructorDescriptor = DescriptorFactory.createPrimaryConstructorForObject(classDescriptor);
|
||||
ConstructorDescriptorImpl constructorDescriptor =
|
||||
DescriptorFactory.createPrimaryConstructorForObject(classDescriptor, toSourceElement(object));
|
||||
if (object != null) {
|
||||
trace.record(CONSTRUCTOR, object, constructorDescriptor);
|
||||
}
|
||||
@@ -815,7 +823,9 @@ public class DescriptorResolver {
|
||||
annotationResolver.resolveAnnotationsWithArguments(scope, parameter.getModifierList(), trace),
|
||||
JetPsiUtil.safeName(parameter.getName()),
|
||||
type,
|
||||
false);
|
||||
false,
|
||||
toSourceElement(parameter)
|
||||
);
|
||||
trace.record(BindingContext.VALUE_PARAMETER, parameter, variableDescriptor);
|
||||
return variableDescriptor;
|
||||
}
|
||||
@@ -837,7 +847,8 @@ public class DescriptorResolver {
|
||||
Visibilities.INTERNAL,
|
||||
variable.isVar(),
|
||||
JetPsiUtil.safeName(variable.getName()),
|
||||
CallableMemberDescriptor.Kind.DECLARATION
|
||||
CallableMemberDescriptor.Kind.DECLARATION,
|
||||
toSourceElement(variable)
|
||||
);
|
||||
|
||||
JetType type =
|
||||
@@ -886,7 +897,9 @@ public class DescriptorResolver {
|
||||
annotationResolver.resolveAnnotationsWithArguments(scope, variable.getModifierList(), trace),
|
||||
JetPsiUtil.safeName(variable.getName()),
|
||||
type,
|
||||
variable.isVar());
|
||||
variable.isVar(),
|
||||
toSourceElement(variable)
|
||||
);
|
||||
trace.record(BindingContext.VARIABLE, variable, variableDescriptor);
|
||||
return variableDescriptor;
|
||||
}
|
||||
@@ -914,7 +927,8 @@ public class DescriptorResolver {
|
||||
visibility,
|
||||
isVar,
|
||||
JetPsiUtil.safeName(property.getName()),
|
||||
CallableMemberDescriptor.Kind.DECLARATION
|
||||
CallableMemberDescriptor.Kind.DECLARATION,
|
||||
toSourceElement(property)
|
||||
);
|
||||
|
||||
List<TypeParameterDescriptorImpl> typeParameterDescriptors;
|
||||
@@ -1155,7 +1169,7 @@ public class DescriptorResolver {
|
||||
resolveModalityFromModifiers(setter, propertyDescriptor.getModality()),
|
||||
resolveVisibilityFromModifiers(setter, propertyDescriptor.getVisibility()),
|
||||
setter.hasBody(), false,
|
||||
CallableMemberDescriptor.Kind.DECLARATION, null);
|
||||
CallableMemberDescriptor.Kind.DECLARATION, null, toSourceElement(setter));
|
||||
if (parameter != null) {
|
||||
|
||||
// This check is redundant: the parser does not allow a default value, but we'll keep it just in case
|
||||
@@ -1231,7 +1245,7 @@ public class DescriptorResolver {
|
||||
resolveModalityFromModifiers(getter, propertyDescriptor.getModality()),
|
||||
resolveVisibilityFromModifiers(getter, propertyDescriptor.getVisibility()),
|
||||
getter.hasBody(), false,
|
||||
CallableMemberDescriptor.Kind.DECLARATION, null);
|
||||
CallableMemberDescriptor.Kind.DECLARATION, null, toSourceElement(getter));
|
||||
getterDescriptor.initialize(returnType);
|
||||
trace.record(BindingContext.PROPERTY_ACCESSOR, getter, getterDescriptor);
|
||||
}
|
||||
@@ -1254,7 +1268,8 @@ public class DescriptorResolver {
|
||||
ConstructorDescriptorImpl constructorDescriptor = ConstructorDescriptorImpl.create(
|
||||
classDescriptor,
|
||||
annotationResolver.resolveAnnotationsWithoutArguments(scope, modifierList, trace),
|
||||
isPrimary
|
||||
isPrimary,
|
||||
toSourceElement(declarationToTrace)
|
||||
);
|
||||
trace.record(BindingContext.CONSTRUCTOR, declarationToTrace, constructorDescriptor);
|
||||
WritableScopeImpl parameterScope = new WritableScopeImpl(
|
||||
@@ -1316,7 +1331,8 @@ public class DescriptorResolver {
|
||||
resolveVisibilityFromModifiers(parameter, getDefaultVisibility(parameter, classDescriptor)),
|
||||
isMutable,
|
||||
name,
|
||||
CallableMemberDescriptor.Kind.DECLARATION
|
||||
CallableMemberDescriptor.Kind.DECLARATION,
|
||||
toSourceElement(parameter)
|
||||
);
|
||||
propertyDescriptor.setType(type, Collections.<TypeParameterDescriptor>emptyList(),
|
||||
getExpectedThisObjectIfNeeded(classDescriptor), NO_RECEIVER_PARAMETER);
|
||||
|
||||
@@ -122,22 +122,27 @@ public class FunctionDescriptorUtil {
|
||||
function.getContainingDeclaration(),
|
||||
function.getAnnotations(),
|
||||
function.getName(),
|
||||
function.getKind());
|
||||
function.getKind(),
|
||||
SourceElement.NO_SOURCE
|
||||
);
|
||||
List<ValueParameterDescriptor> parameters = new ArrayList<ValueParameterDescriptor>(newParameters.size());
|
||||
int idx = 0;
|
||||
for (ValueParameterDescriptor parameter : newParameters) {
|
||||
JetType returnType = parameter.getReturnType();
|
||||
assert returnType != null;
|
||||
|
||||
parameters.add(new ValueParameterDescriptorImpl(
|
||||
descriptor,
|
||||
null,
|
||||
idx,
|
||||
parameter.getAnnotations(),
|
||||
parameter.getName(),
|
||||
returnType,
|
||||
parameter.declaresDefaultValue(),
|
||||
parameter.getVarargElementType())
|
||||
parameters.add(
|
||||
new ValueParameterDescriptorImpl(
|
||||
descriptor,
|
||||
null,
|
||||
idx,
|
||||
parameter.getAnnotations(),
|
||||
parameter.getName(),
|
||||
returnType,
|
||||
parameter.declaresDefaultValue(),
|
||||
parameter.getVarargElementType(),
|
||||
SourceElement.NO_SOURCE
|
||||
)
|
||||
);
|
||||
idx++;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.source.SourcePackage.toSourceElement;
|
||||
|
||||
// SCRIPT: Resolve declarations in scripts
|
||||
public class ScriptHeaderResolver {
|
||||
|
||||
@@ -65,7 +67,7 @@ public class ScriptHeaderResolver {
|
||||
|
||||
FqName nameForScript = ScriptNameUtil.classNameForScript(script);
|
||||
Name className = nameForScript.shortName();
|
||||
ScriptDescriptorImpl scriptDescriptor = new ScriptDescriptorImpl(ns, priority, outerScope, className);
|
||||
ScriptDescriptorImpl scriptDescriptor = new ScriptDescriptorImpl(ns, priority, outerScope, className, toSourceElement(script));
|
||||
|
||||
WritableScopeImpl scriptScope = new WritableScopeImpl(outerScope, scriptDescriptor, RedeclarationHandler.DO_NOTHING, "script");
|
||||
scriptScope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.resolve;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.ScriptDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.ValueParameterDescriptorImpl;
|
||||
@@ -57,7 +58,7 @@ public final class ScriptParameterResolver {
|
||||
@NotNull ScriptDescriptor script
|
||||
) {
|
||||
return new ValueParameterDescriptorImpl(script, null, index, Annotations.EMPTY, scriptParameter.getName(),
|
||||
scriptParameter.getType(), false, null);
|
||||
scriptParameter.getType(), false, null, SourceElement.NO_SOURCE);
|
||||
}
|
||||
|
||||
private ScriptParameterResolver() {
|
||||
|
||||
@@ -44,6 +44,7 @@ import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isObject;
|
||||
import static org.jetbrains.jet.lang.resolve.ModifiersChecker.getDefaultClassVisibility;
|
||||
import static org.jetbrains.jet.lang.resolve.ModifiersChecker.resolveVisibilityFromModifiers;
|
||||
import static org.jetbrains.jet.lang.resolve.name.SpecialNames.getClassObjectName;
|
||||
import static org.jetbrains.jet.lang.resolve.source.SourcePackage.toSourceElement;
|
||||
|
||||
public class TypeHierarchyResolver {
|
||||
private static final DFS.Neighbors<ClassDescriptor> CLASS_INHERITANCE_EDGES = new DFS.Neighbors<ClassDescriptor>() {
|
||||
@@ -431,8 +432,9 @@ public class TypeHierarchyResolver {
|
||||
|
||||
@NotNull
|
||||
private MutableClassDescriptor createSyntheticClassObjectForSingleton(@NotNull ClassDescriptor classDescriptor) {
|
||||
MutableClassDescriptor classObject = new MutableClassDescriptor(classDescriptor, outerScope, ClassKind.CLASS_OBJECT, false,
|
||||
getClassObjectName(classDescriptor.getName()));
|
||||
MutableClassDescriptor classObject =
|
||||
new MutableClassDescriptor(classDescriptor, outerScope, ClassKind.CLASS_OBJECT, false,
|
||||
getClassObjectName(classDescriptor.getName()), SourceElement.NO_SOURCE);
|
||||
|
||||
classObject.setModality(Modality.FINAL);
|
||||
classObject.setVisibility(DescriptorUtils.getSyntheticClassObjectVisibility());
|
||||
@@ -450,8 +452,9 @@ public class TypeHierarchyResolver {
|
||||
// Kind check is needed in order to not consider enums as inner in any case
|
||||
// (otherwise it would be impossible to create a class object in the enum)
|
||||
boolean isInner = kind == ClassKind.CLASS && klass.isInner();
|
||||
MutableClassDescriptor descriptor = new MutableClassDescriptor(containingDeclaration, outerScope, kind, isInner,
|
||||
JetPsiUtil.safeName(klass.getName()));
|
||||
MutableClassDescriptor descriptor = new MutableClassDescriptor(
|
||||
containingDeclaration, outerScope, kind, isInner, JetPsiUtil.safeName(klass.getName()),
|
||||
toSourceElement(klass));
|
||||
c.getDeclaredClasses().put(klass, descriptor);
|
||||
trace.record(FQNAME_TO_CLASS_DESCRIPTOR, JetNamedDeclarationUtil.getUnsafeFQName(klass), descriptor);
|
||||
|
||||
@@ -471,7 +474,8 @@ public class TypeHierarchyResolver {
|
||||
@NotNull Name name,
|
||||
@NotNull ClassKind kind
|
||||
) {
|
||||
MutableClassDescriptor descriptor = new MutableClassDescriptor(owner.getOwnerForChildren(), outerScope, kind, false, name);
|
||||
MutableClassDescriptor descriptor = new MutableClassDescriptor(owner.getOwnerForChildren(), outerScope, kind, false, name,
|
||||
toSourceElement(declaration));
|
||||
|
||||
prepareForDeferredCall(descriptor.getScopeForMemberDeclarationResolution(), descriptor, declaration);
|
||||
|
||||
@@ -485,7 +489,7 @@ public class TypeHierarchyResolver {
|
||||
|
||||
@NotNull
|
||||
private ConstructorDescriptorImpl createPrimaryConstructorForObject(
|
||||
@Nullable PsiElement object,
|
||||
@Nullable JetClassOrObject object,
|
||||
@NotNull MutableClassDescriptor mutableClassDescriptor
|
||||
) {
|
||||
ConstructorDescriptorImpl constructorDescriptor = DescriptorResolver
|
||||
|
||||
+4
-1
@@ -62,6 +62,7 @@ import static org.jetbrains.jet.lang.diagnostics.Errors.CLASS_OBJECT_NOT_ALLOWED
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isSyntheticClassObject;
|
||||
import static org.jetbrains.jet.lang.resolve.ModifiersChecker.*;
|
||||
import static org.jetbrains.jet.lang.resolve.name.SpecialNames.getClassObjectName;
|
||||
import static org.jetbrains.jet.lang.resolve.source.SourcePackage.toSourceElement;
|
||||
|
||||
public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDescriptorWithResolutionScopes, LazyEntity {
|
||||
private static final Predicate<JetType> VALID_SUPERTYPE = new Predicate<JetType>() {
|
||||
@@ -100,7 +101,9 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
@NotNull Name name,
|
||||
@NotNull JetClassLikeInfo classLikeInfo
|
||||
) {
|
||||
super(resolveSession.getStorageManager(), containingDeclaration, name);
|
||||
super(resolveSession.getStorageManager(), containingDeclaration, name,
|
||||
toSourceElement(classLikeInfo.getCorrespondingClassOrObject())
|
||||
);
|
||||
this.resolveSession = resolveSession;
|
||||
|
||||
if (classLikeInfo.getCorrespondingClassOrObject() != null) {
|
||||
|
||||
+4
-2
@@ -40,6 +40,7 @@ import org.jetbrains.jet.lang.descriptors.DeclarationDescriptorVisitor
|
||||
import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope
|
||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.source.toSourceElement
|
||||
|
||||
public class LazyScriptDescriptor(
|
||||
val resolveSession: ResolveSession,
|
||||
@@ -52,9 +53,9 @@ public class LazyScriptDescriptor(
|
||||
resolveSession.getPackageFragment(fqName).sure("Package not found $fqName")
|
||||
},
|
||||
Annotations.EMPTY,
|
||||
ScriptDescriptor.NAME
|
||||
ScriptDescriptor.NAME,
|
||||
jetScript.toSourceElement()
|
||||
) {
|
||||
|
||||
{
|
||||
resolveSession.getTrace().record(BindingContext.SCRIPT, jetScript, this)
|
||||
}
|
||||
@@ -80,6 +81,7 @@ public class LazyScriptDescriptor(
|
||||
)
|
||||
result
|
||||
}
|
||||
|
||||
override fun getScriptCodeDescriptor() = _scriptCodeDescriptor()
|
||||
|
||||
override fun getScopeForBodyResolution(): JetScope {
|
||||
|
||||
+4
-1
@@ -31,6 +31,8 @@ import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.source.SourcePackage.toSourceElement;
|
||||
|
||||
public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescriptor implements LazyEntity {
|
||||
private final ResolveSession resolveSession;
|
||||
|
||||
@@ -47,7 +49,8 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri
|
||||
jetTypeParameter.getNameAsSafeName(),
|
||||
jetTypeParameter.getVariance(),
|
||||
jetTypeParameter.hasModifier(JetTokens.REIFIED_KEYWORD),
|
||||
index
|
||||
index,
|
||||
toSourceElement(jetTypeParameter)
|
||||
);
|
||||
this.resolveSession = resolveSession;
|
||||
this.jetTypeParameter = jetTypeParameter;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.source
|
||||
|
||||
import org.jetbrains.jet.lang.psi.JetElement
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement
|
||||
import com.intellij.psi.PsiElement
|
||||
|
||||
public class KotlinSourceElement(override val psi: JetElement) : PsiSourceElement
|
||||
|
||||
public fun JetElement?.toSourceElement(): SourceElement = if (this == null) SourceElement.NO_SOURCE else KotlinSourceElement(this)
|
||||
|
||||
public fun SourceElement.getPsi(): PsiElement? = (this as? PsiSourceElement)?.psi
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.source
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement
|
||||
|
||||
public trait PsiSourceElement : SourceElement {
|
||||
public val psi: PsiElement?
|
||||
}
|
||||
+4
-2
@@ -74,6 +74,7 @@ import static org.jetbrains.jet.lang.resolve.BindingContext.*;
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.getStaticNestedClassesScope;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.context.ContextDependency.INDEPENDENT;
|
||||
import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue.NO_RECEIVER;
|
||||
import static org.jetbrains.jet.lang.resolve.source.SourcePackage.toSourceElement;
|
||||
import static org.jetbrains.jet.lang.types.TypeUtils.NO_EXPECTED_TYPE;
|
||||
import static org.jetbrains.jet.lang.types.TypeUtils.noExpectedType;
|
||||
import static org.jetbrains.jet.lang.types.expressions.ControlStructureTypingUtils.createCallForSpecialConstruction;
|
||||
@@ -532,7 +533,8 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
AnonymousFunctionDescriptor functionDescriptor = new AnonymousFunctionDescriptor(
|
||||
context.scope.getContainingDeclaration(),
|
||||
Annotations.EMPTY,
|
||||
CallableMemberDescriptor.Kind.DECLARATION
|
||||
CallableMemberDescriptor.Kind.DECLARATION,
|
||||
toSourceElement(expression)
|
||||
);
|
||||
|
||||
FunctionDescriptorUtil.initializeFromFunctionType(functionDescriptor, type, null, Modality.FINAL, Visibilities.PUBLIC);
|
||||
@@ -560,7 +562,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
|
||||
LocalVariableDescriptor localVariable =
|
||||
new LocalVariableDescriptor(context.scope.getContainingDeclaration(), Annotations.EMPTY, Name.special("<anonymous>"),
|
||||
type, /* mutable = */ false);
|
||||
type, /* mutable = */ false, toSourceElement(expression));
|
||||
|
||||
context.trace.record(VARIABLE, expression, localVariable);
|
||||
|
||||
|
||||
+6
-2
@@ -42,6 +42,7 @@ import java.util.List;
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.*;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.*;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.context.ContextDependency.INDEPENDENT;
|
||||
import static org.jetbrains.jet.lang.resolve.source.SourcePackage.toSourceElement;
|
||||
import static org.jetbrains.jet.lang.types.TypeUtils.*;
|
||||
import static org.jetbrains.jet.lang.types.expressions.CoercionStrategy.COERCION_TO_UNIT;
|
||||
|
||||
@@ -131,7 +132,9 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
JetFunctionLiteral functionLiteral = expression.getFunctionLiteral();
|
||||
JetTypeReference receiverTypeRef = functionLiteral.getReceiverTypeRef();
|
||||
AnonymousFunctionDescriptor functionDescriptor = new AnonymousFunctionDescriptor(
|
||||
context.scope.getContainingDeclaration(), Annotations.EMPTY, CallableMemberDescriptor.Kind.DECLARATION);
|
||||
context.scope.getContainingDeclaration(), Annotations.EMPTY, CallableMemberDescriptor.Kind.DECLARATION,
|
||||
toSourceElement(functionLiteral)
|
||||
);
|
||||
|
||||
List<ValueParameterDescriptor> valueParameterDescriptors = createValueParameterDescriptors(context, functionLiteral,
|
||||
functionDescriptor, functionTypeExpected);
|
||||
@@ -180,7 +183,8 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
ValueParameterDescriptor valueParameterDescriptor = expectedValueParameters.get(0);
|
||||
ValueParameterDescriptor it = new ValueParameterDescriptorImpl(
|
||||
functionDescriptor, null, 0, Annotations.EMPTY, Name.identifier("it"),
|
||||
valueParameterDescriptor.getType(), valueParameterDescriptor.hasDefaultValue(), valueParameterDescriptor.getVarargElementType()
|
||||
valueParameterDescriptor.getType(), valueParameterDescriptor.hasDefaultValue(), valueParameterDescriptor.getVarargElementType(),
|
||||
SourceElement.NO_SOURCE
|
||||
);
|
||||
valueParameterDescriptors.add(it);
|
||||
context.trace.record(AUTO_CREATED_IT, it);
|
||||
|
||||
+4
-2
@@ -86,7 +86,7 @@ public class ControlStructureTypingUtils {
|
||||
|
||||
SimpleFunctionDescriptorImpl function = SimpleFunctionDescriptorImpl.create(
|
||||
ErrorUtils.getErrorModule(),//todo hack to avoid returning true in 'isError(DeclarationDescriptor)'
|
||||
Annotations.EMPTY, specialFunctionName, CallableMemberDescriptor.Kind.DECLARATION);
|
||||
Annotations.EMPTY, specialFunctionName, CallableMemberDescriptor.Kind.DECLARATION, SourceElement.NO_SOURCE);
|
||||
|
||||
TypeParameterDescriptor typeParameter = TypeParameterDescriptorImpl.createWithDefaultBound(
|
||||
function, Annotations.EMPTY, false, Variance.INVARIANT,
|
||||
@@ -99,7 +99,9 @@ public class ControlStructureTypingUtils {
|
||||
for (int i = 0; i < argumentNames.size(); i++) {
|
||||
JetType argumentType = isArgumentNullable.get(i) ? nullableType : type;
|
||||
ValueParameterDescriptorImpl valueParameter = new ValueParameterDescriptorImpl(
|
||||
function, null, i, Annotations.EMPTY, Name.identifier(argumentNames.get(i)), argumentType, false, null);
|
||||
function, null, i, Annotations.EMPTY, Name.identifier(argumentNames.get(i)),
|
||||
argumentType, false, null, SourceElement.NO_SOURCE
|
||||
);
|
||||
valueParameters.add(valueParameter);
|
||||
}
|
||||
function.initialize(
|
||||
|
||||
@@ -95,7 +95,8 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
||||
}
|
||||
|
||||
private ClassDescriptorWithResolutionScopes createClassDescriptor(ClassKind kind, JetClass aClass) {
|
||||
MutableClassDescriptor classDescriptor = new MutableClassDescriptor(root, scope, kind, false, aClass.getNameAsSafeName());
|
||||
MutableClassDescriptor classDescriptor =
|
||||
new MutableClassDescriptor(root, scope, kind, false, aClass.getNameAsSafeName(), SourceElement.NO_SOURCE);
|
||||
TopDownAnalysisParameters parameters = TopDownAnalysisParameters.create(
|
||||
LockBasedStorageManager.NO_LOCKS, new ExceptionTracker(), Predicates.<PsiFile>alwaysTrue(), false, false
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user