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
|
||||
);
|
||||
|
||||
+10
-6
@@ -21,6 +21,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.ConstructorDescriptorImpl;
|
||||
|
||||
@@ -33,18 +34,20 @@ public class JavaConstructorDescriptor extends ConstructorDescriptorImpl impleme
|
||||
@Nullable JavaConstructorDescriptor original,
|
||||
@NotNull Annotations annotations,
|
||||
boolean isPrimary,
|
||||
@NotNull Kind kind
|
||||
@NotNull Kind kind,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(containingDeclaration, original, annotations, isPrimary, kind);
|
||||
super(containingDeclaration, original, annotations, isPrimary, kind, source);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JavaConstructorDescriptor createJavaConstructor(
|
||||
@NotNull ClassDescriptor containingDeclaration,
|
||||
@NotNull Annotations annotations,
|
||||
boolean isPrimary
|
||||
boolean isPrimary,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
return new JavaConstructorDescriptor(containingDeclaration, null, annotations, isPrimary, Kind.DECLARATION);
|
||||
return new JavaConstructorDescriptor(containingDeclaration, null, annotations, isPrimary, Kind.DECLARATION, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,8 +83,9 @@ public class JavaConstructorDescriptor extends ConstructorDescriptorImpl impleme
|
||||
"newOwner: " + newOwner + "\n" +
|
||||
"kind: " + kind);
|
||||
}
|
||||
JavaConstructorDescriptor result =
|
||||
new JavaConstructorDescriptor((ClassDescriptor) newOwner, this, Annotations.EMPTY /* TODO */, isPrimary, kind);
|
||||
JavaConstructorDescriptor result = new JavaConstructorDescriptor(
|
||||
(ClassDescriptor) newOwner, this, Annotations.EMPTY /* TODO */, isPrimary, kind, SourceElement.NO_SOURCE
|
||||
);
|
||||
result.setHasStableParameterNames(hasStableParameterNames());
|
||||
result.setHasSynthesizedParameterNames(hasSynthesizedParameterNames());
|
||||
return result;
|
||||
|
||||
+9
-5
@@ -21,6 +21,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.FunctionDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||
@@ -35,18 +36,20 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
|
||||
@Nullable SimpleFunctionDescriptor original,
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull Name name,
|
||||
@NotNull Kind kind
|
||||
@NotNull Kind kind,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(containingDeclaration, original, annotations, name, kind);
|
||||
super(containingDeclaration, original, annotations, name, kind, source);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JavaMethodDescriptor createJavaMethod(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull Name name
|
||||
@NotNull Name name,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
return new JavaMethodDescriptor(containingDeclaration, null, annotations, name, Kind.DECLARATION);
|
||||
return new JavaMethodDescriptor(containingDeclaration, null, annotations, name, Kind.DECLARATION, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -81,7 +84,8 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
|
||||
(SimpleFunctionDescriptor) original,
|
||||
getAnnotations(),
|
||||
getName(),
|
||||
kind
|
||||
kind,
|
||||
SourceElement.NO_SOURCE
|
||||
);
|
||||
result.setHasStableParameterNames(hasStableParameterNames());
|
||||
result.setHasSynthesizedParameterNames(hasSynthesizedParameterNames());
|
||||
|
||||
+4
-2
@@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.resolve.java.descriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.Modality;
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement;
|
||||
import org.jetbrains.jet.lang.descriptors.Visibility;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.PropertyDescriptorImpl;
|
||||
@@ -30,9 +31,10 @@ public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements Ja
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull Visibility visibility,
|
||||
boolean isVar,
|
||||
@NotNull Name name
|
||||
@NotNull Name name,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(containingDeclaration, null, annotations, Modality.FINAL, visibility, isVar, name, Kind.DECLARATION);
|
||||
super(containingDeclaration, null, annotations, Modality.FINAL, visibility, isVar, name, Kind.DECLARATION, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.resolve.java.descriptor;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassOrPackageFragmentDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement;
|
||||
import org.jetbrains.jet.lang.descriptors.SynthesizedCallableMemberDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||
|
||||
@@ -29,7 +30,8 @@ public class SamConstructorDescriptor extends SimpleFunctionDescriptorImpl
|
||||
@NotNull ClassOrPackageFragmentDescriptor containingDeclaration,
|
||||
@NotNull JavaClassDescriptor samInterface
|
||||
) {
|
||||
super(containingDeclaration, null, samInterface.getAnnotations(), samInterface.getName(), Kind.SYNTHESIZED);
|
||||
super(containingDeclaration, null, samInterface.getAnnotations(), samInterface.getName(),
|
||||
Kind.SYNTHESIZED, samInterface.getSource());
|
||||
this.samInterface = samInterface;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -46,7 +46,8 @@ public class LazyJavaPackageFragmentProvider(
|
||||
outerContext.errorReporter,
|
||||
outerContext.methodSignatureChecker,
|
||||
outerContext.javaResolverCache,
|
||||
outerContext.javaPropertyInitializerEvaluator
|
||||
outerContext.javaPropertyInitializerEvaluator,
|
||||
outerContext.sourceElementFactory
|
||||
)
|
||||
|
||||
override fun getModule() = _module
|
||||
|
||||
+11
-5
@@ -29,6 +29,7 @@ import org.jetbrains.jet.lang.resolve.java.resolver.JavaResolverCache
|
||||
import org.jetbrains.jet.lang.resolve.kotlin.DeserializedDescriptorResolver
|
||||
import org.jetbrains.jet.lang.resolve.kotlin.KotlinClassFinder
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaPropertyInitializerEvaluator
|
||||
import org.jetbrains.jet.lang.resolve.java.sources.JavaSourceElementFactory
|
||||
|
||||
open class GlobalJavaResolverContext(
|
||||
val storageManager: StorageManager,
|
||||
@@ -40,7 +41,8 @@ open class GlobalJavaResolverContext(
|
||||
val errorReporter: ErrorReporter,
|
||||
val methodSignatureChecker: MethodSignatureChecker,
|
||||
val javaResolverCache: JavaResolverCache,
|
||||
val javaPropertyInitializerEvaluator: JavaPropertyInitializerEvaluator
|
||||
val javaPropertyInitializerEvaluator: JavaPropertyInitializerEvaluator,
|
||||
val sourceElementFactory: JavaSourceElementFactory
|
||||
)
|
||||
|
||||
open class LazyJavaResolverContext(
|
||||
@@ -55,10 +57,12 @@ open class LazyJavaResolverContext(
|
||||
errorReporter: ErrorReporter,
|
||||
methodSignatureChecker: MethodSignatureChecker,
|
||||
javaResolverCache: JavaResolverCache,
|
||||
javaPropertyInitializerEvaluator: JavaPropertyInitializerEvaluator
|
||||
javaPropertyInitializerEvaluator: JavaPropertyInitializerEvaluator,
|
||||
sourceElementFactory: JavaSourceElementFactory
|
||||
) : GlobalJavaResolverContext(storageManager, finder, kotlinClassFinder, deserializedDescriptorResolver,
|
||||
externalAnnotationResolver, externalSignatureResolver,
|
||||
errorReporter, methodSignatureChecker, javaResolverCache, javaPropertyInitializerEvaluator)
|
||||
errorReporter, methodSignatureChecker, javaResolverCache, javaPropertyInitializerEvaluator,
|
||||
sourceElementFactory)
|
||||
|
||||
fun LazyJavaResolverContext.withTypes(
|
||||
typeParameterResolver: TypeParameterResolver = TypeParameterResolver.EMPTY
|
||||
@@ -75,6 +79,7 @@ fun LazyJavaResolverContext.withTypes(
|
||||
methodSignatureChecker,
|
||||
javaResolverCache,
|
||||
javaPropertyInitializerEvaluator,
|
||||
sourceElementFactory,
|
||||
LazyJavaTypeResolver(this, typeParameterResolver),
|
||||
typeParameterResolver)
|
||||
|
||||
@@ -91,12 +96,13 @@ class LazyJavaResolverContextWithTypes(
|
||||
methodSignatureChecker: MethodSignatureChecker,
|
||||
javaResolverCache: JavaResolverCache,
|
||||
javaPropertyInitializerEvaluator: JavaPropertyInitializerEvaluator,
|
||||
sourceElementFactory: JavaSourceElementFactory,
|
||||
val typeResolver: LazyJavaTypeResolver,
|
||||
val typeParameterResolver: TypeParameterResolver
|
||||
) : LazyJavaResolverContext(packageFragmentProvider, javaClassResolver, storageManager, finder,
|
||||
kotlinClassFinder, deserializedDescriptorResolver,
|
||||
externalAnnotationResolver, externalSignatureResolver,
|
||||
errorReporter, methodSignatureChecker, javaResolverCache, javaPropertyInitializerEvaluator)
|
||||
externalAnnotationResolver, externalSignatureResolver, errorReporter, methodSignatureChecker,
|
||||
javaResolverCache, javaPropertyInitializerEvaluator, sourceElementFactory)
|
||||
|
||||
fun LazyJavaResolverContextWithTypes.child(
|
||||
containingDeclaration: DeclarationDescriptor,
|
||||
|
||||
+3
-1
@@ -49,13 +49,15 @@ import org.jetbrains.jet.lang.resolve.java.descriptor.JavaClassStaticsPackageFra
|
||||
import org.jetbrains.jet.lang.types.AbstractClassTypeConstructor
|
||||
import org.jetbrains.jet.lang.resolve.java.lazy.resolveTopLevelClassInModule
|
||||
import org.jetbrains.jet.lang.descriptors.impl.EnumClassObjectDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement
|
||||
|
||||
class LazyJavaClassDescriptor(
|
||||
private val outerC: LazyJavaResolverContextWithTypes,
|
||||
containingDeclaration: DeclarationDescriptor,
|
||||
internal val fqName: FqName,
|
||||
private val jClass: JavaClass
|
||||
) : ClassDescriptorBase(outerC.storageManager, containingDeclaration, fqName.shortName()), LazyJavaDescriptor, JavaClassDescriptor {
|
||||
) : ClassDescriptorBase(outerC.storageManager, containingDeclaration, fqName.shortName(),
|
||||
outerC.sourceElementFactory.source(jClass)), LazyJavaDescriptor, JavaClassDescriptor {
|
||||
|
||||
private val c: LazyJavaResolverContextWithTypes = outerC.child(this, jClass.getTypeParameters().toSet());
|
||||
|
||||
|
||||
+9
-4
@@ -114,7 +114,9 @@ public class LazyJavaClassMemberScope(
|
||||
}
|
||||
|
||||
private fun resolveConstructor(constructor: JavaMethod, classDescriptor: ClassDescriptor, isStaticClass: Boolean): JavaConstructorDescriptor {
|
||||
val constructorDescriptor = JavaConstructorDescriptor.createJavaConstructor(classDescriptor, Annotations.EMPTY, /* isPrimary = */ false)
|
||||
val constructorDescriptor = JavaConstructorDescriptor.createJavaConstructor(
|
||||
classDescriptor, Annotations.EMPTY, /* isPrimary = */ false, c.sourceElementFactory.source(constructor)
|
||||
)
|
||||
|
||||
val valueParameters = resolveValueParameters(c, constructorDescriptor, constructor.getValueParameters())
|
||||
val effectiveSignature = c.externalSignatureResolver.resolveAlternativeMethodSignature(
|
||||
@@ -147,7 +149,9 @@ public class LazyJavaClassMemberScope(
|
||||
return null
|
||||
|
||||
val classDescriptor = getContainingDeclaration()
|
||||
val constructorDescriptor = JavaConstructorDescriptor.createJavaConstructor(classDescriptor, Annotations.EMPTY, /* isPrimary = */ true)
|
||||
val constructorDescriptor = JavaConstructorDescriptor.createJavaConstructor(
|
||||
classDescriptor, Annotations.EMPTY, /* isPrimary = */ true, c.sourceElementFactory.source(jClass)
|
||||
)
|
||||
val typeParameters = classDescriptor.getTypeConstructor().getParameters()
|
||||
val valueParameters = if (isAnnotation) createAnnotationConstructorParameters(constructorDescriptor)
|
||||
else Collections.emptyList<ValueParameterDescriptor>()
|
||||
@@ -198,7 +202,8 @@ public class LazyJavaClassMemberScope(
|
||||
TypeUtils.makeNotNullable(returnType),
|
||||
method.hasAnnotationParameterDefaultValue(),
|
||||
// Nulls are not allowed in annotation arguments in Java
|
||||
varargElementType?.let { TypeUtils.makeNotNullable(it) }
|
||||
varargElementType?.let { TypeUtils.makeNotNullable(it) },
|
||||
SourceElement.NO_SOURCE
|
||||
))
|
||||
}
|
||||
|
||||
@@ -222,7 +227,7 @@ public class LazyJavaClassMemberScope(
|
||||
EnumEntrySyntheticClassDescriptor.create(c.storageManager, getContainingDeclaration(), name,
|
||||
c.storageManager.createLazyValue {
|
||||
memberIndex().getAllFieldNames() + memberIndex().getAllMethodNames()
|
||||
})
|
||||
}, SourceElement.NO_SOURCE)
|
||||
}
|
||||
else null
|
||||
}
|
||||
|
||||
+7
-3
@@ -112,7 +112,9 @@ public abstract class LazyJavaMemberScope(
|
||||
|
||||
fun resolveMethodToFunctionDescriptor(method: JavaMethod, record: Boolean = true): JavaMethodDescriptor {
|
||||
|
||||
val functionDescriptorImpl = JavaMethodDescriptor.createJavaMethod(_containingDeclaration, c.resolveAnnotations(method), method.getName())
|
||||
val functionDescriptorImpl = JavaMethodDescriptor.createJavaMethod(
|
||||
_containingDeclaration, c.resolveAnnotations(method), method.getName(), c.sourceElementFactory.source(method)
|
||||
)
|
||||
|
||||
val c = c.child(functionDescriptorImpl, method.getTypeParameters().toSet())
|
||||
|
||||
@@ -210,7 +212,8 @@ public abstract class LazyJavaMemberScope(
|
||||
name,
|
||||
outType,
|
||||
false,
|
||||
varargElementType
|
||||
varargElementType,
|
||||
SourceElement.NO_SOURCE
|
||||
)
|
||||
}.toList()
|
||||
return ResolvedValueParameters(descriptors, synthesizedNames)
|
||||
@@ -273,7 +276,8 @@ public abstract class LazyJavaMemberScope(
|
||||
val annotations = c.resolveAnnotations(field)
|
||||
val propertyName = field.getName()
|
||||
|
||||
return JavaPropertyDescriptor(_containingDeclaration, annotations, visibility, isVar, propertyName)
|
||||
return JavaPropertyDescriptor(_containingDeclaration, annotations, visibility, isVar, propertyName,
|
||||
c.sourceElementFactory.source(field))
|
||||
}
|
||||
|
||||
private fun getPropertyType(field: JavaField): JetType {
|
||||
|
||||
+3
-1
@@ -25,6 +25,7 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
||||
import org.jetbrains.jet.lang.resolve.java.resolver.TypeUsage
|
||||
import org.jetbrains.jet.lang.resolve.java.lazy.LazyJavaResolverContextWithTypes
|
||||
import org.jetbrains.jet.lang.resolve.java.lazy.types.toAttributes
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement
|
||||
|
||||
class LazyJavaTypeParameterDescriptor(
|
||||
private val c: LazyJavaResolverContextWithTypes,
|
||||
@@ -36,7 +37,8 @@ class LazyJavaTypeParameterDescriptor(
|
||||
javaTypeParameter.getName(),
|
||||
Variance.INVARIANT,
|
||||
/* isReified = */ false,
|
||||
javaTypeParameter.getIndex()
|
||||
javaTypeParameter.getIndex(),
|
||||
SourceElement.NO_SOURCE
|
||||
) {
|
||||
|
||||
override fun resolveUpperBounds(): Set<JetType> {
|
||||
|
||||
+3
-1
@@ -245,7 +245,9 @@ public final class DescriptorResolverUtils {
|
||||
typeParameter.isReified(),
|
||||
typeParameter.getVariance(),
|
||||
typeParameter.getName(),
|
||||
typeParameter.getIndex()));
|
||||
typeParameter.getIndex(),
|
||||
SourceElement.NO_SOURCE)
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+3
-1
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.jet.lang.resolve.java.sam;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement;
|
||||
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaConstructorDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.java.descriptor.SamAdapterDescriptor;
|
||||
|
||||
@@ -24,7 +25,8 @@ import org.jetbrains.jet.lang.resolve.java.descriptor.SamAdapterDescriptor;
|
||||
private final JavaConstructorDescriptor declaration;
|
||||
|
||||
public SamAdapterConstructorDescriptor(@NotNull JavaConstructorDescriptor declaration) {
|
||||
super(declaration.getContainingDeclaration(), null, declaration.getAnnotations(), declaration.isPrimary(), Kind.SYNTHESIZED);
|
||||
super(declaration.getContainingDeclaration(), null, declaration.getAnnotations(),
|
||||
declaration.isPrimary(), Kind.SYNTHESIZED, declaration.getSource());
|
||||
this.declaration = declaration;
|
||||
setHasStableParameterNames(declaration.hasStableParameterNames());
|
||||
setHasSynthesizedParameterNames(declaration.hasSynthesizedParameterNames());
|
||||
|
||||
+3
-1
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.jet.lang.resolve.java.sam;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement;
|
||||
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaMethodDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.java.descriptor.SamAdapterDescriptor;
|
||||
|
||||
@@ -24,7 +25,8 @@ import org.jetbrains.jet.lang.resolve.java.descriptor.SamAdapterDescriptor;
|
||||
private final JavaMethodDescriptor declaration;
|
||||
|
||||
public SamAdapterFunctionDescriptor(@NotNull JavaMethodDescriptor declaration) {
|
||||
super(declaration.getContainingDeclaration(), null, declaration.getAnnotations(), declaration.getName(), Kind.SYNTHESIZED);
|
||||
super(declaration.getContainingDeclaration(), null, declaration.getAnnotations(),
|
||||
declaration.getName(), Kind.SYNTHESIZED, declaration.getSource());
|
||||
this.declaration = declaration;
|
||||
setHasStableParameterNames(declaration.hasStableParameterNames());
|
||||
setHasSynthesizedParameterNames(declaration.hasSynthesizedParameterNames());
|
||||
|
||||
+4
-2
@@ -145,7 +145,7 @@ public class SingleAbstractMethodUtils {
|
||||
assert parameterType != null : "couldn't substitute type: " + parameterTypeUnsubstituted +
|
||||
", substitutor = " + typeParameters.substitutor;
|
||||
ValueParameterDescriptor parameter = new ValueParameterDescriptorImpl(
|
||||
result, null, 0, Annotations.EMPTY, Name.identifier("function"), parameterType, false, null);
|
||||
result, null, 0, Annotations.EMPTY, Name.identifier("function"), parameterType, false, null, SourceElement.NO_SOURCE);
|
||||
|
||||
JetType returnType = typeParameters.substitutor.substitute(samInterface.getDefaultType(), Variance.OUT_VARIANCE);
|
||||
assert returnType != null : "couldn't substitute type: " + samInterface.getDefaultType() +
|
||||
@@ -249,7 +249,9 @@ public class SingleAbstractMethodUtils {
|
||||
assert newType != null : "couldn't substitute type: " + newTypeUnsubstituted + ", substitutor = " + typeParameters.substitutor;
|
||||
|
||||
ValueParameterDescriptor newParam = new ValueParameterDescriptorImpl(
|
||||
adapter, null, originalParam.getIndex(), originalParam.getAnnotations(), originalParam.getName(), newType, false, null);
|
||||
adapter, null, originalParam.getIndex(), originalParam.getAnnotations(),
|
||||
originalParam.getName(), newType, false, null, SourceElement.NO_SOURCE
|
||||
);
|
||||
valueParameters.add(newParam);
|
||||
}
|
||||
|
||||
|
||||
+24
@@ -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.java.sources
|
||||
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaElement
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement
|
||||
|
||||
trait JavaSourceElementFactory {
|
||||
fun source(javaElement: JavaElement): SourceElement
|
||||
}
|
||||
+1
-1
@@ -18,7 +18,7 @@ package org.jetbrains.jet.lang.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface DeclarationDescriptorNonRoot extends DeclarationDescriptor {
|
||||
public interface DeclarationDescriptorNonRoot extends DeclarationDescriptorWithSource {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
|
||||
+24
@@ -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.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface DeclarationDescriptorWithSource extends DeclarationDescriptor {
|
||||
@NotNull
|
||||
SourceElement getSource();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.descriptors;
|
||||
|
||||
public interface SourceElement {
|
||||
SourceElement NO_SOURCE = new SourceElement() { };
|
||||
}
|
||||
+1
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
//TODO: drop
|
||||
public interface SynthesizedCallableMemberDescriptor<D extends DeclarationDescriptor> extends CallableMemberDescriptor {
|
||||
@NotNull
|
||||
D getBaseForSynthesized();
|
||||
|
||||
+4
-2
@@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.descriptors.impl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement;
|
||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
@@ -38,9 +39,10 @@ public abstract class AbstractLazyTypeParameterDescriptor extends AbstractTypePa
|
||||
@NotNull Name name,
|
||||
@NotNull Variance variance,
|
||||
boolean isReified,
|
||||
int index
|
||||
int index,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(storageManager, containingDeclaration, Annotations.EMPTY /* TODO */, name, variance, isReified, index);
|
||||
super(storageManager, containingDeclaration, Annotations.EMPTY /* TODO */, name, variance, isReified, index, source);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+6
@@ -109,4 +109,10 @@ public abstract class AbstractReceiverParameterDescriptor extends DeclarationDes
|
||||
public CallableDescriptor getOriginal() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public SourceElement getSource() {
|
||||
return SourceElement.NO_SOURCE;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-2
@@ -21,6 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.ReadOnly;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptorVisitor;
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement;
|
||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
@@ -52,9 +53,10 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip
|
||||
@NotNull Name name,
|
||||
@NotNull Variance variance,
|
||||
boolean isReified,
|
||||
int index
|
||||
int index,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(containingDeclaration, annotations, name);
|
||||
super(containingDeclaration, annotations, name, source);
|
||||
this.variance = variance;
|
||||
this.reified = isReified;
|
||||
this.index = index;
|
||||
|
||||
+4
-2
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.descriptors.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
@@ -25,8 +26,9 @@ public class AnonymousFunctionDescriptor extends SimpleFunctionDescriptorImpl {
|
||||
public AnonymousFunctionDescriptor(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull Kind kind
|
||||
@NotNull Kind kind,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(containingDeclaration, null, annotations, Name.special("<anonymous>"), kind);
|
||||
super(containingDeclaration, null, annotations, Name.special("<anonymous>"), kind, source);
|
||||
}
|
||||
}
|
||||
|
||||
+11
-1
@@ -18,20 +18,24 @@ package org.jetbrains.jet.lang.descriptors.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.storage.StorageManager;
|
||||
|
||||
public abstract class ClassDescriptorBase extends AbstractClassDescriptor {
|
||||
|
||||
private final DeclarationDescriptor containingDeclaration;
|
||||
private final SourceElement source;
|
||||
|
||||
protected ClassDescriptorBase(
|
||||
@NotNull StorageManager storageManager,
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull Name name
|
||||
@NotNull Name name,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(storageManager, name);
|
||||
this.containingDeclaration = containingDeclaration;
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -39,4 +43,10 @@ public abstract class ClassDescriptorBase extends AbstractClassDescriptor {
|
||||
public DeclarationDescriptor getContainingDeclaration() {
|
||||
return containingDeclaration;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public SourceElement getSource() {
|
||||
return source;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -43,9 +43,10 @@ public class ClassDescriptorImpl extends ClassDescriptorBase {
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull Name name,
|
||||
@NotNull Modality modality,
|
||||
@NotNull Collection<JetType> supertypes
|
||||
@NotNull Collection<JetType> supertypes,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(LockBasedStorageManager.NO_LOCKS, containingDeclaration, name);
|
||||
super(LockBasedStorageManager.NO_LOCKS, containingDeclaration, name, source);
|
||||
this.modality = modality;
|
||||
|
||||
this.typeConstructor = TypeConstructorImpl.createForClass(this, Annotations.EMPTY, false, getName().asString(),
|
||||
|
||||
+10
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -40,9 +40,10 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements
|
||||
@Nullable ConstructorDescriptor original,
|
||||
@NotNull Annotations annotations,
|
||||
boolean isPrimary,
|
||||
@NotNull Kind kind
|
||||
@NotNull Kind kind,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(containingDeclaration, original, annotations, NAME, kind);
|
||||
super(containingDeclaration, original, annotations, NAME, kind, source);
|
||||
this.isPrimary = isPrimary;
|
||||
}
|
||||
|
||||
@@ -50,9 +51,10 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements
|
||||
public static ConstructorDescriptorImpl create(
|
||||
@NotNull ClassDescriptor containingDeclaration,
|
||||
@NotNull Annotations annotations,
|
||||
boolean isPrimary
|
||||
boolean isPrimary,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
return new ConstructorDescriptorImpl(containingDeclaration, null, annotations, isPrimary, Kind.DECLARATION);
|
||||
return new ConstructorDescriptorImpl(containingDeclaration, null, annotations, isPrimary, Kind.DECLARATION, source);
|
||||
}
|
||||
|
||||
public ConstructorDescriptorImpl initialize(
|
||||
@@ -124,7 +126,9 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements
|
||||
this,
|
||||
Annotations.EMPTY, // TODO
|
||||
isPrimary,
|
||||
Kind.DECLARATION);
|
||||
Kind.DECLARATION,
|
||||
SourceElement.NO_SOURCE
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+14
-1
@@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.descriptors.impl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptorNonRoot;
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
@@ -29,13 +30,19 @@ public abstract class DeclarationDescriptorNonRootImpl
|
||||
@NotNull
|
||||
private final DeclarationDescriptor containingDeclaration;
|
||||
|
||||
@NotNull
|
||||
private final SourceElement source;
|
||||
|
||||
protected DeclarationDescriptorNonRootImpl(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull Name name) {
|
||||
@NotNull Name name,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(annotations, name);
|
||||
|
||||
this.containingDeclaration = containingDeclaration;
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,4 +51,10 @@ public abstract class DeclarationDescriptorNonRootImpl
|
||||
return containingDeclaration;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public SourceElement getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
-5
@@ -39,8 +39,8 @@ import kotlin.properties.Delegates
|
||||
public class EnumClassObjectDescriptor(
|
||||
storageManager: StorageManager,
|
||||
enumClass: ClassDescriptor
|
||||
) : ClassDescriptorBase(storageManager, enumClass, SpecialNames.getClassObjectName(enumClass.getName())) {
|
||||
private val primaryConstructor = DescriptorFactory.createPrimaryConstructorForObject(this)
|
||||
) : ClassDescriptorBase(storageManager, enumClass, SpecialNames.getClassObjectName(enumClass.getName()), SourceElement.NO_SOURCE) {
|
||||
private val primaryConstructor = DescriptorFactory.createPrimaryConstructorForObject(this, SourceElement.NO_SOURCE)
|
||||
|
||||
;{
|
||||
primaryConstructor.setReturnType(object : DelegatingType() {
|
||||
@@ -112,14 +112,14 @@ public class EnumClassObjectDescriptor(
|
||||
|
||||
private fun createEnumClassObjectValuesMethod(enumType: JetType): SimpleFunctionDescriptor {
|
||||
val enumArrayType = KotlinBuiltIns.getInstance().getArrayType(enumType)
|
||||
val values = SimpleFunctionDescriptorImpl.create(enumClassObject, Annotations.EMPTY, Name.identifier("values"), SYNTHESIZED)
|
||||
val values = SimpleFunctionDescriptorImpl.create(enumClassObject, Annotations.EMPTY, Name.identifier("values"), SYNTHESIZED, SourceElement.NO_SOURCE)
|
||||
return values.initialize(null, getThisAsReceiverParameter(), listOf(), listOf(), enumArrayType, Modality.FINAL, Visibilities.PUBLIC)
|
||||
}
|
||||
|
||||
private fun createEnumClassObjectValueOfMethod(enumType: JetType): SimpleFunctionDescriptor {
|
||||
val values = SimpleFunctionDescriptorImpl.create(enumClassObject, Annotations.EMPTY, Name.identifier("valueOf"), SYNTHESIZED)
|
||||
val values = SimpleFunctionDescriptorImpl.create(enumClassObject, Annotations.EMPTY, Name.identifier("valueOf"), SYNTHESIZED, SourceElement.NO_SOURCE)
|
||||
val parameter = ValueParameterDescriptorImpl(values, null, 0, Annotations.EMPTY, Name.identifier("value"),
|
||||
KotlinBuiltIns.getInstance().getStringType(), false, null)
|
||||
KotlinBuiltIns.getInstance().getStringType(), false, null, SourceElement.NO_SOURCE)
|
||||
return values.initialize(null, getThisAsReceiverParameter(), listOf(), listOf(parameter), enumType, Modality.FINAL, Visibilities.PUBLIC)
|
||||
}
|
||||
|
||||
|
||||
+8
-6
@@ -58,11 +58,12 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
@NotNull StorageManager storageManager,
|
||||
@NotNull ClassDescriptor enumClass,
|
||||
@NotNull Name name,
|
||||
@NotNull NotNullLazyValue<Collection<Name>> enumMemberNames
|
||||
@NotNull NotNullLazyValue<Collection<Name>> enumMemberNames,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
JetType enumType = enumClass.getDefaultType();
|
||||
|
||||
return new EnumEntrySyntheticClassDescriptor(storageManager, enumClass, enumType, name, ClassKind.ENUM_ENTRY, enumMemberNames);
|
||||
return new EnumEntrySyntheticClassDescriptor(storageManager, enumClass, enumType, name, ClassKind.ENUM_ENTRY, enumMemberNames, source);
|
||||
}
|
||||
|
||||
private EnumEntrySyntheticClassDescriptor(
|
||||
@@ -71,9 +72,10 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
@NotNull JetType supertype,
|
||||
@NotNull Name name,
|
||||
@NotNull ClassKind kind,
|
||||
@NotNull NotNullLazyValue<Collection<Name>> enumMemberNames
|
||||
@NotNull NotNullLazyValue<Collection<Name>> enumMemberNames,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(storageManager, containingClass, name);
|
||||
super(storageManager, containingClass, name, source);
|
||||
this.kind = kind;
|
||||
|
||||
this.typeConstructor =
|
||||
@@ -83,7 +85,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
this.scope = new EnumEntryScope(storageManager);
|
||||
this.enumMemberNames = enumMemberNames;
|
||||
|
||||
ConstructorDescriptorImpl primaryConstructor = DescriptorFactory.createPrimaryConstructorForObject(this);
|
||||
ConstructorDescriptorImpl primaryConstructor = DescriptorFactory.createPrimaryConstructorForObject(this, source);
|
||||
primaryConstructor.setReturnType(getDefaultType());
|
||||
this.primaryConstructor = primaryConstructor;
|
||||
|
||||
@@ -91,7 +93,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
kind == ClassKind.CLASS_OBJECT
|
||||
? null
|
||||
: new EnumEntrySyntheticClassDescriptor(storageManager, this, getDefaultType(), SpecialNames.getClassObjectName(name),
|
||||
ClassKind.CLASS_OBJECT, enumMemberNames);
|
||||
ClassKind.CLASS_OBJECT, enumMemberNames, SourceElement.NO_SOURCE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+8
-4
@@ -41,8 +41,8 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
protected JetType unsubstitutedReturnType;
|
||||
private ReceiverParameterDescriptor receiverParameter;
|
||||
protected ReceiverParameterDescriptor expectedThisObject;
|
||||
|
||||
protected Modality modality;
|
||||
|
||||
protected Visibility visibility;
|
||||
protected final Set<FunctionDescriptor> overriddenFunctions = Sets.newLinkedHashSet(); // LinkedHashSet is essential here
|
||||
private final FunctionDescriptor original;
|
||||
@@ -53,8 +53,10 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
@Nullable FunctionDescriptor original,
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull Name name,
|
||||
@NotNull Kind kind) {
|
||||
super(containingDeclaration, annotations, name);
|
||||
@NotNull Kind kind,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(containingDeclaration, annotations, name, source);
|
||||
this.original = original == null ? this : original;
|
||||
this.kind = kind;
|
||||
}
|
||||
@@ -276,7 +278,9 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
unsubstitutedValueParameter.getName(),
|
||||
substitutedType,
|
||||
unsubstitutedValueParameter.declaresDefaultValue(),
|
||||
substituteVarargElementType)
|
||||
substituteVarargElementType,
|
||||
SourceElement.NO_SOURCE
|
||||
)
|
||||
);
|
||||
}
|
||||
return result;
|
||||
|
||||
+6
@@ -202,4 +202,10 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
||||
public ConstructorDescriptor getUnsubstitutedPrimaryConstructor() {
|
||||
return original.getUnsubstitutedPrimaryConstructor();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public SourceElement getSource() {
|
||||
return SourceElement.NO_SOURCE;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -24,7 +24,8 @@ import org.jetbrains.jet.lang.types.TypeSubstitutor
|
||||
public abstract class PackageFragmentDescriptorImpl(
|
||||
module: ModuleDescriptor,
|
||||
override val fqName: FqName
|
||||
) : DeclarationDescriptorNonRootImpl(module, Annotations.EMPTY, fqName.shortNameOrSpecial()), PackageFragmentDescriptor {
|
||||
) : DeclarationDescriptorNonRootImpl(module, Annotations.EMPTY, fqName.shortNameOrSpecial(), SourceElement.NO_SOURCE),
|
||||
PackageFragmentDescriptor {
|
||||
override fun substitute(substitutor: TypeSubstitutor): DeclarationDescriptor? = this
|
||||
|
||||
override fun <R, D> accept(visitor: DeclarationDescriptorVisitor<R, D>, data: D): R =
|
||||
@@ -33,4 +34,8 @@ public abstract class PackageFragmentDescriptorImpl(
|
||||
override fun getContainingDeclaration(): ModuleDescriptor {
|
||||
return super<DeclarationDescriptorNonRootImpl>.getContainingDeclaration() as ModuleDescriptor
|
||||
}
|
||||
|
||||
override fun getSource(): SourceElement {
|
||||
return SourceElement.NO_SOURCE
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -45,9 +45,10 @@ public abstract class PropertyAccessorDescriptorImpl extends DeclarationDescript
|
||||
@NotNull Name name,
|
||||
boolean hasBody,
|
||||
boolean isDefault,
|
||||
Kind kind
|
||||
Kind kind,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(correspondingProperty.getContainingDeclaration(), annotations, name);
|
||||
super(correspondingProperty.getContainingDeclaration(), annotations, name, source);
|
||||
this.modality = modality;
|
||||
this.visibility = visibility;
|
||||
this.correspondingProperty = correspondingProperty;
|
||||
|
||||
+9
-7
@@ -59,9 +59,10 @@ public class PropertyDescriptorImpl extends VariableDescriptorImpl implements Pr
|
||||
@NotNull Visibility visibility,
|
||||
boolean isVar,
|
||||
@NotNull Name name,
|
||||
@NotNull Kind kind
|
||||
@NotNull Kind kind,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(containingDeclaration, annotations, name, null);
|
||||
super(containingDeclaration, annotations, name, null, source);
|
||||
this.isVar = isVar;
|
||||
this.modality = modality;
|
||||
this.visibility = visibility;
|
||||
@@ -77,9 +78,10 @@ public class PropertyDescriptorImpl extends VariableDescriptorImpl implements Pr
|
||||
@NotNull Visibility visibility,
|
||||
boolean isVar,
|
||||
@NotNull Name name,
|
||||
@NotNull Kind kind
|
||||
@NotNull Kind kind,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
return new PropertyDescriptorImpl(containingDeclaration, null, annotations, modality, visibility, isVar, name, kind);
|
||||
return new PropertyDescriptorImpl(containingDeclaration, null, annotations, modality, visibility, isVar, name, kind, source);
|
||||
}
|
||||
|
||||
public void setType(
|
||||
@@ -243,7 +245,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorImpl implements Pr
|
||||
|
||||
PropertyGetterDescriptorImpl newGetter = getter == null ? null : new PropertyGetterDescriptorImpl(
|
||||
substitutedDescriptor, getter.getAnnotations(), newModality, convertVisibility(getter.getVisibility(), newVisibility),
|
||||
getter.hasBody(), getter.isDefault(), kind, getter.getOriginal()
|
||||
getter.hasBody(), getter.isDefault(), kind, getter.getOriginal(), SourceElement.NO_SOURCE
|
||||
);
|
||||
if (newGetter != null) {
|
||||
JetType returnType = getter.getReturnType();
|
||||
@@ -251,7 +253,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorImpl implements Pr
|
||||
}
|
||||
PropertySetterDescriptorImpl newSetter = setter == null ? null : new PropertySetterDescriptorImpl(
|
||||
substitutedDescriptor, setter.getAnnotations(), newModality, convertVisibility(setter.getVisibility(), newVisibility),
|
||||
setter.hasBody(), setter.isDefault(), kind, setter.getOriginal()
|
||||
setter.hasBody(), setter.isDefault(), kind, setter.getOriginal(), SourceElement.NO_SOURCE
|
||||
);
|
||||
if (newSetter != null) {
|
||||
List<ValueParameterDescriptor> substitutedValueParameters = FunctionDescriptorImpl.getSubstitutedValueParameters(newSetter, setter, substitutor);
|
||||
@@ -292,7 +294,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorImpl implements Pr
|
||||
@NotNull Kind kind
|
||||
) {
|
||||
return new PropertyDescriptorImpl(newOwner, original,
|
||||
getAnnotations(), newModality, newVisibility, isVar(), getName(), kind);
|
||||
getAnnotations(), newModality, newVisibility, isVar(), getName(), kind, SourceElement.NO_SOURCE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+4
-2
@@ -41,10 +41,12 @@ public class PropertyGetterDescriptorImpl extends PropertyAccessorDescriptorImpl
|
||||
boolean hasBody,
|
||||
boolean isDefault,
|
||||
@NotNull Kind kind,
|
||||
@Nullable PropertyGetterDescriptor original
|
||||
@Nullable PropertyGetterDescriptor original,
|
||||
@NotNull SourceElement source
|
||||
)
|
||||
{
|
||||
super(modality, visibility, correspondingProperty, annotations, Name.special("<get-" + correspondingProperty.getName() + ">"), hasBody, isDefault, kind);
|
||||
super(modality, visibility, correspondingProperty, annotations, Name.special("<get-" + correspondingProperty.getName() + ">"),
|
||||
hasBody, isDefault, kind, source);
|
||||
this.original = original != null ? original : this;
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -19,7 +19,6 @@ package org.jetbrains.jet.lang.descriptors.impl;
|
||||
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.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -43,9 +42,11 @@ public class PropertySetterDescriptorImpl extends PropertyAccessorDescriptorImpl
|
||||
boolean hasBody,
|
||||
boolean isDefault,
|
||||
@NotNull Kind kind,
|
||||
@Nullable PropertySetterDescriptor original
|
||||
@Nullable PropertySetterDescriptor original,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(modality, visibility, correspondingProperty, annotations, Name.special("<set-" + correspondingProperty.getName() + ">"), hasBody, isDefault, kind);
|
||||
super(modality, visibility, correspondingProperty, annotations, Name.special("<set-" + correspondingProperty.getName() + ">"),
|
||||
hasBody, isDefault, kind, source);
|
||||
this.original = original != null ? original : this;
|
||||
}
|
||||
|
||||
@@ -64,7 +65,7 @@ public class PropertySetterDescriptorImpl extends PropertyAccessorDescriptorImpl
|
||||
@NotNull JetType type
|
||||
) {
|
||||
return new ValueParameterDescriptorImpl(
|
||||
setterDescriptor, null, 0, Annotations.EMPTY, Name.special("<set-?>"), type, false, null
|
||||
setterDescriptor, null, 0, Annotations.EMPTY, Name.special("<set-?>"), type, false, null, SourceElement.NO_SOURCE
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ import java.util.List;
|
||||
public class ScriptCodeDescriptor extends FunctionDescriptorImpl {
|
||||
|
||||
public ScriptCodeDescriptor(@NotNull ScriptDescriptor containingDeclaration) {
|
||||
super(containingDeclaration, null, Annotations.EMPTY, Name.special("<script-code>"), Kind.DECLARATION);
|
||||
super(containingDeclaration, null, Annotations.EMPTY, Name.special("<script-code>"), Kind.DECLARATION, SourceElement.NO_SOURCE);
|
||||
}
|
||||
|
||||
public void initialize(
|
||||
|
||||
+10
-5
@@ -37,8 +37,10 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
||||
@Nullable SimpleFunctionDescriptor original,
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull Name name,
|
||||
@NotNull Kind kind) {
|
||||
super(containingDeclaration, original, annotations, name, kind);
|
||||
@NotNull Kind kind,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(containingDeclaration, original, annotations, name, kind, source);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -46,9 +48,10 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull Name name,
|
||||
@NotNull Kind kind
|
||||
@NotNull Kind kind,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
return new SimpleFunctionDescriptorImpl(containingDeclaration, null, annotations, name, kind);
|
||||
return new SimpleFunctionDescriptorImpl(containingDeclaration, null, annotations, name, kind, source);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +91,9 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
||||
// TODO : safeSubstitute
|
||||
getAnnotations(),
|
||||
getName(),
|
||||
kind);
|
||||
kind,
|
||||
SourceElement.NO_SOURCE
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+9
-5
@@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.descriptors.impl;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement;
|
||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
@@ -42,7 +43,8 @@ public class TypeParameterDescriptorImpl extends AbstractTypeParameterDescriptor
|
||||
@NotNull Name name,
|
||||
int index
|
||||
) {
|
||||
TypeParameterDescriptorImpl typeParameterDescriptor = createForFurtherModification(containingDeclaration, annotations, reified, variance, name, index);
|
||||
TypeParameterDescriptorImpl typeParameterDescriptor =
|
||||
createForFurtherModification(containingDeclaration, annotations, reified, variance, name, index, SourceElement.NO_SOURCE);
|
||||
typeParameterDescriptor.addUpperBound(KotlinBuiltIns.getInstance().getDefaultBound());
|
||||
typeParameterDescriptor.setInitialized();
|
||||
return typeParameterDescriptor;
|
||||
@@ -54,9 +56,10 @@ public class TypeParameterDescriptorImpl extends AbstractTypeParameterDescriptor
|
||||
boolean reified,
|
||||
@NotNull Variance variance,
|
||||
@NotNull Name name,
|
||||
int index
|
||||
int index,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
return new TypeParameterDescriptorImpl(containingDeclaration, annotations, reified, variance, name, index);
|
||||
return new TypeParameterDescriptorImpl(containingDeclaration, annotations, reified, variance, name, index, source);
|
||||
}
|
||||
|
||||
private final Set<JetType> upperBounds = Sets.newLinkedHashSet();
|
||||
@@ -68,9 +71,10 @@ public class TypeParameterDescriptorImpl extends AbstractTypeParameterDescriptor
|
||||
boolean reified,
|
||||
@NotNull Variance variance,
|
||||
@NotNull Name name,
|
||||
int index
|
||||
int index,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(LockBasedStorageManager.NO_LOCKS, containingDeclaration, annotations, name, variance, reified, index);
|
||||
super(LockBasedStorageManager.NO_LOCKS, containingDeclaration, annotations, name, variance, reified, index, source);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+4
-3
@@ -48,9 +48,10 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme
|
||||
@NotNull Name name,
|
||||
@NotNull JetType outType,
|
||||
boolean declaresDefaultValue,
|
||||
@Nullable JetType varargElementType
|
||||
@Nullable JetType varargElementType,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(containingDeclaration, annotations, name, outType);
|
||||
super(containingDeclaration, annotations, name, outType, source);
|
||||
this.original = original == null ? this : original;
|
||||
this.index = index;
|
||||
this.declaresDefaultValue = declaresDefaultValue;
|
||||
@@ -125,7 +126,7 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme
|
||||
@NotNull
|
||||
@Override
|
||||
public ValueParameterDescriptor copy(@NotNull DeclarationDescriptor newOwner, @NotNull Name newName) {
|
||||
return new ValueParameterDescriptorImpl(newOwner, null, index, getAnnotations(), newName, getType(), declaresDefaultValue(), varargElementType);
|
||||
return new ValueParameterDescriptorImpl(newOwner, null, index, getAnnotations(), newName, getType(), declaresDefaultValue(), varargElementType, SourceElement.NO_SOURCE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+4
-2
@@ -37,8 +37,10 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull Name name,
|
||||
@Nullable JetType outType) {
|
||||
super(containingDeclaration, annotations, name);
|
||||
@Nullable JetType outType,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(containingDeclaration, annotations, name, source);
|
||||
|
||||
this.outType = outType;
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ import static org.jetbrains.jet.lang.resolve.DescriptorUtils.getDefaultConstruct
|
||||
|
||||
public class DescriptorFactory {
|
||||
private static class DefaultConstructorDescriptor extends ConstructorDescriptorImpl {
|
||||
public DefaultConstructorDescriptor(@NotNull ClassDescriptor containingClass) {
|
||||
super(containingClass, null, Annotations.EMPTY, true, Kind.DECLARATION);
|
||||
public DefaultConstructorDescriptor(@NotNull ClassDescriptor containingClass, @NotNull SourceElement source) {
|
||||
super(containingClass, null, Annotations.EMPTY, true, Kind.DECLARATION, source);
|
||||
initialize(Collections.<TypeParameterDescriptor>emptyList(), Collections.<ValueParameterDescriptor>emptyList(),
|
||||
getDefaultConstructorVisibility(containingClass), true);
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class DescriptorFactory {
|
||||
PropertySetterDescriptorImpl setterDescriptor =
|
||||
new PropertySetterDescriptorImpl(propertyDescriptor, Annotations.EMPTY, propertyDescriptor.getModality(),
|
||||
propertyDescriptor.getVisibility(), !isDefault, isDefault,
|
||||
CallableMemberDescriptor.Kind.DECLARATION, null);
|
||||
CallableMemberDescriptor.Kind.DECLARATION, null, SourceElement.NO_SOURCE);
|
||||
setterDescriptor.initializeDefault();
|
||||
return setterDescriptor;
|
||||
}
|
||||
@@ -68,12 +68,15 @@ public class DescriptorFactory {
|
||||
public static PropertyGetterDescriptorImpl createGetter(@NotNull PropertyDescriptor propertyDescriptor, boolean isDefault) {
|
||||
return new PropertyGetterDescriptorImpl(propertyDescriptor, Annotations.EMPTY, propertyDescriptor.getModality(),
|
||||
propertyDescriptor.getVisibility(), !isDefault, isDefault,
|
||||
CallableMemberDescriptor.Kind.DECLARATION, null);
|
||||
CallableMemberDescriptor.Kind.DECLARATION, null, SourceElement.NO_SOURCE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ConstructorDescriptorImpl createPrimaryConstructorForObject(@NotNull ClassDescriptor containingClass) {
|
||||
return new DefaultConstructorDescriptor(containingClass);
|
||||
public static ConstructorDescriptorImpl createPrimaryConstructorForObject(
|
||||
@NotNull ClassDescriptor containingClass,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
return new DefaultConstructorDescriptor(containingClass, source);
|
||||
}
|
||||
|
||||
public static boolean isDefaultPrimaryConstructor(@NotNull ConstructorDescriptor constructor) {
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.types;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement;
|
||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl;
|
||||
|
||||
@@ -66,7 +67,8 @@ public class DescriptorSubstitutor {
|
||||
descriptor.isReified(),
|
||||
descriptor.getVariance(),
|
||||
descriptor.getName(),
|
||||
descriptor.getIndex()
|
||||
descriptor.getIndex(),
|
||||
SourceElement.NO_SOURCE
|
||||
);
|
||||
substituted.setInitialized();
|
||||
|
||||
|
||||
@@ -229,9 +229,9 @@ public class ErrorUtils {
|
||||
private static class ErrorClassDescriptor extends ClassDescriptorImpl {
|
||||
public ErrorClassDescriptor(@Nullable String name) {
|
||||
super(getErrorModule(), Name.special(name == null ? "<ERROR CLASS>" : "<ERROR CLASS: " + name + ">"),
|
||||
Modality.OPEN, Collections.<JetType>emptyList());
|
||||
Modality.OPEN, Collections.<JetType>emptyList(), SourceElement.NO_SOURCE);
|
||||
|
||||
ConstructorDescriptorImpl errorConstructor = ConstructorDescriptorImpl.create(this, Annotations.EMPTY, true);
|
||||
ConstructorDescriptorImpl errorConstructor = ConstructorDescriptorImpl.create(this, Annotations.EMPTY, true, SourceElement.NO_SOURCE);
|
||||
errorConstructor.initialize(Collections.<TypeParameterDescriptor>emptyList(), Collections.<ValueParameterDescriptor>emptyList(),
|
||||
Visibilities.INTERNAL, false);
|
||||
JetScope memberScope = createErrorScope(getName().asString());
|
||||
@@ -300,7 +300,8 @@ public class ErrorUtils {
|
||||
Visibilities.INTERNAL,
|
||||
true,
|
||||
Name.special("<ERROR PROPERTY>"),
|
||||
CallableMemberDescriptor.Kind.DECLARATION
|
||||
CallableMemberDescriptor.Kind.DECLARATION,
|
||||
SourceElement.NO_SOURCE
|
||||
);
|
||||
descriptor.setType(ERROR_PROPERTY_TYPE,
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ public class ErrorSimpleFunctionDescriptorImpl extends SimpleFunctionDescriptorI
|
||||
private final ErrorUtils.ErrorScope ownerScope;
|
||||
|
||||
public ErrorSimpleFunctionDescriptorImpl(@NotNull ClassDescriptor containingDeclaration, @NotNull ErrorUtils.ErrorScope ownerScope) {
|
||||
super(containingDeclaration, null, Annotations.EMPTY, Name.special("<ERROR FUNCTION>"), Kind.DECLARATION);
|
||||
super(containingDeclaration, null, Annotations.EMPTY, Name.special("<ERROR FUNCTION>"), Kind.DECLARATION, SourceElement.NO_SOURCE);
|
||||
this.ownerScope = ownerScope;
|
||||
}
|
||||
|
||||
|
||||
@@ -766,7 +766,7 @@ public class KotlinBuiltIns {
|
||||
TypeProjection parameterType = parameterTypes.get(i);
|
||||
ValueParameterDescriptorImpl valueParameterDescriptor = new ValueParameterDescriptorImpl(
|
||||
functionDescriptor, null, i, Annotations.EMPTY,
|
||||
Name.identifier("p" + (i + 1)), parameterType.getType(), false, null);
|
||||
Name.identifier("p" + (i + 1)), parameterType.getType(), false, null, SourceElement.NO_SOURCE);
|
||||
valueParameters.add(valueParameterDescriptor);
|
||||
}
|
||||
return valueParameters;
|
||||
|
||||
+5
-4
@@ -100,7 +100,7 @@ public class MemberDeserializer {
|
||||
modality(Flags.MODALITY.get(getterFlags)),
|
||||
visibility(Flags.VISIBILITY.get(getterFlags)),
|
||||
isNotDefault, !isNotDefault,
|
||||
property.getKind(), null);
|
||||
property.getKind(), null, SourceElement.NO_SOURCE);
|
||||
}
|
||||
else {
|
||||
getter = DescriptorFactory.createDefaultGetter(property);
|
||||
@@ -117,7 +117,7 @@ public class MemberDeserializer {
|
||||
modality(Flags.MODALITY.get(setterFlags)),
|
||||
visibility(Flags.VISIBILITY.get(setterFlags)), isNotDefault,
|
||||
!isNotDefault,
|
||||
property.getKind(), null);
|
||||
property.getKind(), null, SourceElement.NO_SOURCE);
|
||||
DeserializationContextWithTypes setterLocal = local.childContext(setter, Collections.<TypeParameter>emptyList(),
|
||||
Collections.<TypeParameterDescriptor>emptyList());
|
||||
List<ValueParameterDescriptor> valueParameters
|
||||
@@ -186,7 +186,7 @@ public class MemberDeserializer {
|
||||
classDescriptor,
|
||||
getAnnotations(proto, proto.getFlags(), AnnotatedCallableKind.FUNCTION),
|
||||
// TODO: primary
|
||||
true);
|
||||
true, SourceElement.NO_SOURCE);
|
||||
List<TypeParameterDescriptor> typeParameters = new ArrayList<TypeParameterDescriptor>(proto.getTypeParameterCount());
|
||||
DeserializationContextWithTypes local = context.childContext(descriptor, Collections.<TypeParameter>emptyList(), typeParameters);
|
||||
descriptor.initialize(
|
||||
@@ -260,7 +260,8 @@ public class MemberDeserializer {
|
||||
context.getNameResolver().getName(proto.getName()),
|
||||
context.getTypeDeserializer().type(proto.getType()),
|
||||
Flags.DECLARES_DEFAULT_VALUE.get(proto.getFlags()),
|
||||
context.getTypeDeserializer().typeOrNull(proto.hasVarargElementType() ? proto.getVarargElementType() : null))
|
||||
context.getTypeDeserializer().typeOrNull(proto.hasVarargElementType() ? proto.getVarargElementType() : null),
|
||||
SourceElement.NO_SOURCE)
|
||||
);
|
||||
}
|
||||
return result;
|
||||
|
||||
+8
-2
@@ -200,7 +200,7 @@ public class DeserializedClassDescriptor extends AbstractClassDescriptor impleme
|
||||
|
||||
ProtoBuf.Class.PrimaryConstructor constructorProto = classProto.getPrimaryConstructor();
|
||||
if (!constructorProto.hasData()) {
|
||||
ConstructorDescriptorImpl descriptor = DescriptorFactory.createPrimaryConstructorForObject(this);
|
||||
ConstructorDescriptorImpl descriptor = DescriptorFactory.createPrimaryConstructorForObject(this, SourceElement.NO_SOURCE);
|
||||
descriptor.setReturnType(getDefaultType());
|
||||
return descriptor;
|
||||
}
|
||||
@@ -267,6 +267,12 @@ public class DeserializedClassDescriptor extends AbstractClassDescriptor impleme
|
||||
return "deserialized class " + getName().toString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public SourceElement getSource() {
|
||||
return SourceElement.NO_SOURCE;
|
||||
}
|
||||
|
||||
private class DeserializedClassTypeConstructor extends AbstractClassTypeConstructor {
|
||||
private final Collection<JetType> supertypes = computeSuperTypes();
|
||||
private final List<TypeParameterDescriptor> parameters;
|
||||
@@ -441,7 +447,7 @@ public class DeserializedClassDescriptor extends AbstractClassDescriptor impleme
|
||||
public ClassDescriptor invoke(Name name) {
|
||||
if (enumEntryNames.contains(name)) {
|
||||
return EnumEntrySyntheticClassDescriptor
|
||||
.create(storageManager, DeserializedClassDescriptor.this, name, enumMemberNames);
|
||||
.create(storageManager, DeserializedClassDescriptor.this, name, enumMemberNames, SourceElement.NO_SOURCE);
|
||||
}
|
||||
if (nestedClassNames.contains(name)) {
|
||||
return ContextPackage.deserializeClass(context, classId.createNestedClassId(name));
|
||||
|
||||
+2
-1
@@ -26,6 +26,7 @@ import org.jetbrains.jet.descriptors.serialization.NameResolver
|
||||
import org.jetbrains.jet.lang.descriptors.impl.PropertyDescriptorImpl
|
||||
import org.jetbrains.jet.descriptors.serialization.ProtoBuf
|
||||
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor.Kind
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement
|
||||
|
||||
public class DeserializedPropertyDescriptor(
|
||||
containingDeclaration: DeclarationDescriptor,
|
||||
@@ -39,7 +40,7 @@ public class DeserializedPropertyDescriptor(
|
||||
override public val proto: ProtoBuf.Callable,
|
||||
override public val nameResolver: NameResolver
|
||||
) : DeserializedCallableMemberDescriptor,
|
||||
PropertyDescriptorImpl(containingDeclaration, original, annotations, modality, visibility, isVar, name, kind) {
|
||||
PropertyDescriptorImpl(containingDeclaration, original, annotations, modality, visibility, isVar, name, kind, SourceElement.NO_SOURCE) {
|
||||
|
||||
override fun createSubstitutedCopy(
|
||||
newOwner: DeclarationDescriptor,
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ import org.jetbrains.jet.descriptors.serialization.*;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.FunctionDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||
@@ -40,7 +41,7 @@ public class DeserializedSimpleFunctionDescriptor extends SimpleFunctionDescript
|
||||
@NotNull Kind kind,
|
||||
@NotNull ProtoBuf.Callable proto,
|
||||
@NotNull NameResolver nameResolver) {
|
||||
super(containingDeclaration, original, annotations, name, kind);
|
||||
super(containingDeclaration, original, annotations, name, kind, SourceElement.NO_SOURCE);
|
||||
this.proto = proto;
|
||||
this.nameResolver = nameResolver;
|
||||
}
|
||||
|
||||
+3
-2
@@ -20,12 +20,13 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.descriptors.serialization.ProtoBuf;
|
||||
import org.jetbrains.jet.descriptors.serialization.TypeDeserializer;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.SourceElement;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.AbstractLazyTypeParameterDescriptor;
|
||||
import org.jetbrains.jet.storage.StorageManager;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.Variance;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.storage.StorageManager;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
@@ -45,7 +46,7 @@ public class DeserializedTypeParameterDescriptor extends AbstractLazyTypeParamet
|
||||
boolean isReified,
|
||||
int index
|
||||
) {
|
||||
super(storageManager, containingDeclaration, name, variance, isReified, index);
|
||||
super(storageManager, containingDeclaration, name, variance, isReified, index, SourceElement.NO_SOURCE);
|
||||
this.proto = proto;
|
||||
this.typeDeserializer = typeDeserializer;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,8 @@ private fun generatorForTopDownAnalyzerForJvm() =
|
||||
javaClass<PsiBasedMethodSignatureChecker>(),
|
||||
javaClass<PsiBasedExternalAnnotationResolver>(),
|
||||
javaClass<MutablePackageFragmentProvider>(),
|
||||
javaClass<JavaPropertyInitializerEvaluatorImpl>()
|
||||
javaClass<JavaPropertyInitializerEvaluatorImpl>(),
|
||||
javaClass<JavaSourceElementFactoryImpl>()
|
||||
)
|
||||
field(javaClass<VirtualFileFinder>(), init = GivenExpression(javaClass<VirtualFileFinder>().getName() + ".SERVICE.getInstance(project)"))
|
||||
}
|
||||
@@ -128,7 +129,8 @@ private fun generatorForJavaDescriptorResolver() =
|
||||
javaClass<TraceBasedErrorReporter>(),
|
||||
javaClass<PsiBasedMethodSignatureChecker>(),
|
||||
javaClass<PsiBasedExternalAnnotationResolver>(),
|
||||
javaClass<JavaPropertyInitializerEvaluatorImpl>()
|
||||
javaClass<JavaPropertyInitializerEvaluatorImpl>(),
|
||||
javaClass<JavaSourceElementFactoryImpl>()
|
||||
)
|
||||
field(javaClass<VirtualFileFinder>(),
|
||||
init = GivenExpression(javaClass<VirtualFileFinder>().getName() + ".SERVICE.getInstance(project)"))
|
||||
@@ -159,7 +161,8 @@ private fun generatorForLazyResolveWithJava() =
|
||||
javaClass<TraceBasedErrorReporter>(),
|
||||
javaClass<PsiBasedMethodSignatureChecker>(),
|
||||
javaClass<PsiBasedExternalAnnotationResolver>(),
|
||||
javaClass<JavaPropertyInitializerEvaluatorImpl>()
|
||||
javaClass<JavaPropertyInitializerEvaluatorImpl>(),
|
||||
javaClass<JavaSourceElementFactoryImpl>()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ private class PackageFragmentProviderForMissingDependencies(val moduleDescriptor
|
||||
}
|
||||
|
||||
private class MissingDependencyErrorClassDescriptor(containing: DeclarationDescriptor, override val fullFqName: FqName)
|
||||
: MissingDependencyErrorClass, ClassDescriptorImpl(containing, fullFqName.shortName(), Modality.OPEN, listOf()) {
|
||||
: MissingDependencyErrorClass, ClassDescriptorImpl(containing, fullFqName.shortName(), Modality.OPEN, listOf(), SourceElement.NO_SOURCE) {
|
||||
|
||||
private val scope = ScopeWithMissingDependencies(fullFqName, this)
|
||||
|
||||
@@ -84,7 +84,7 @@ private class MissingDependencyErrorClassDescriptor(containing: DeclarationDescr
|
||||
}
|
||||
|
||||
{
|
||||
val emptyConstructor = ConstructorDescriptorImpl.create(this, Annotations.EMPTY, true)
|
||||
val emptyConstructor = ConstructorDescriptorImpl.create(this, Annotations.EMPTY, true, SourceElement.NO_SOURCE)
|
||||
emptyConstructor.initialize(listOf(), listOf(), Visibilities.INTERNAL, false)
|
||||
emptyConstructor.setReturnType(createErrorType("<ERROR RETURN TYPE>"))
|
||||
initialize(JetScope.EMPTY, setOf(emptyConstructor), emptyConstructor)
|
||||
|
||||
@@ -166,4 +166,4 @@ public abstract class JetMultiReference<T : JetElement>(expression: T) : Abstrac
|
||||
}
|
||||
return multiResolve(false).map { it.getElement() }.filterNotNull().any { checkElementMatch(it, element) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user