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
@@ -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;