Initial version of storing SourceElements in descriptors

Introduce SourceElement, JavaSourceElementFactory, DeclarationDescriptorWithSource
Implement getSource() for eager, lazy and java descriptors
This commit is contained in:
Pavel V. Talanov
2014-07-07 21:20:53 +04:00
parent e3b1639edf
commit 59e43020c3
86 changed files with 576 additions and 219 deletions
@@ -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;
@@ -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());
@@ -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
@@ -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;
}
@@ -46,7 +46,8 @@ public class LazyJavaPackageFragmentProvider(
outerContext.errorReporter,
outerContext.methodSignatureChecker,
outerContext.javaResolverCache,
outerContext.javaPropertyInitializerEvaluator
outerContext.javaPropertyInitializerEvaluator,
outerContext.sourceElementFactory
)
override fun getModule() = _module
@@ -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,
@@ -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());
@@ -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
}
@@ -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 {
@@ -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> {
@@ -245,7 +245,9 @@ public final class DescriptorResolverUtils {
typeParameter.isReified(),
typeParameter.getVariance(),
typeParameter.getName(),
typeParameter.getIndex()));
typeParameter.getIndex(),
SourceElement.NO_SOURCE)
);
}
return result;
}
@@ -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());
@@ -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());
@@ -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);
}
@@ -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
}
@@ -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
@@ -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() { };
}
@@ -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();
@@ -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
@@ -109,4 +109,10 @@ public abstract class AbstractReceiverParameterDescriptor extends DeclarationDes
public CallableDescriptor getOriginal() {
return this;
}
@NotNull
@Override
public SourceElement getSource() {
return SourceElement.NO_SOURCE;
}
}
@@ -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;
@@ -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);
}
}
@@ -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;
}
}
@@ -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(),
@@ -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
@@ -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;
}
}
@@ -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)
}
@@ -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
@@ -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;
@@ -202,4 +202,10 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
public ConstructorDescriptor getUnsubstitutedPrimaryConstructor() {
return original.getUnsubstitutedPrimaryConstructor();
}
@NotNull
@Override
public SourceElement getSource() {
return SourceElement.NO_SOURCE;
}
}
@@ -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
}
}
@@ -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;
@@ -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
@@ -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;
}
@@ -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
);
}
@@ -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(
@@ -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
@@ -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
@@ -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
@@ -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(),
@@ -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;
@@ -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;
@@ -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));
@@ -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,
@@ -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;
}
@@ -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;
}