Move around some descriptor implementations
- mutable class, mutable package fragment and their dependencies go to module 'frontend' - ModuleDescriptorImpl and PackageFragmentDescriptorImpl are moved to the package "impl" in their module
This commit is contained in:
+1
-9
@@ -17,23 +17,15 @@
|
||||
package org.jetbrains.jet.lang.resolve.java.lazy.descriptors
|
||||
|
||||
import org.jetbrains.jet.lang.resolve.java.lazy.LazyJavaResolverContext
|
||||
import org.jetbrains.jet.lang.resolve.name.Name
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaPackage
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe
|
||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaClass
|
||||
import org.jetbrains.kotlin.util.sure
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.impl.DeclarationDescriptorNonRootImpl
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptorVisitor
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor
|
||||
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaPackageFragmentDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.PackageFragmentProvider
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations
|
||||
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaClassStaticsPackageFragmentDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaClassDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.PackageFragmentDescriptorImpl
|
||||
import org.jetbrains.jet.lang.descriptors.impl.PackageFragmentDescriptorImpl
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
class LazyPackageFragmentForJavaPackage(
|
||||
|
||||
-41
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
import org.jetbrains.annotations.ReadOnly;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface ClassDescriptorWithResolutionScopes extends ClassDescriptor {
|
||||
@NotNull
|
||||
JetScope getScopeForClassHeaderResolution();
|
||||
|
||||
@NotNull
|
||||
JetScope getScopeForMemberDeclarationResolution();
|
||||
|
||||
@NotNull
|
||||
JetScope getScopeForInitializerResolution();
|
||||
|
||||
@NotNull
|
||||
JetScope getScopeForMemberLookup();
|
||||
|
||||
@NotNull
|
||||
@ReadOnly
|
||||
Collection<CallableMemberDescriptor> getDeclaredCallableMembers();
|
||||
}
|
||||
+2
-5
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.descriptors;
|
||||
package org.jetbrains.jet.lang.descriptors.impl;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
@@ -22,10 +22,8 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.PlatformToKotlinClassMap;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.CompositePackageFragmentProvider;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.DeclarationDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.PackageViewDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.resolve.ImportPath;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
@@ -38,7 +36,6 @@ import java.util.Map;
|
||||
public class ModuleDescriptorImpl extends DeclarationDescriptorImpl implements ModuleDescriptor {
|
||||
private static final Logger LOG = Logger.getInstance(ModuleDescriptorImpl.class);
|
||||
|
||||
|
||||
private final Map<DependencyKind, List<PackageFragmentProvider>> prioritizedFragmentProviders = Maps.newHashMap();
|
||||
private final List<PackageFragmentProvider> fragmentProviders = Lists.newArrayList();
|
||||
private final CompositePackageFragmentProvider packageFragmentProvider = new CompositePackageFragmentProvider(fragmentProviders);
|
||||
-376
@@ -1,376 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.impl;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
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.descriptors.annotations.AnnotationsImpl;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.*;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.storage.LockBasedStorageManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class MutableClassDescriptor extends ClassDescriptorBase implements ClassDescriptorWithResolutionScopes {
|
||||
private final ClassKind kind;
|
||||
private final boolean isInner;
|
||||
|
||||
private Annotations annotations;
|
||||
private Modality modality;
|
||||
private Visibility visibility;
|
||||
private TypeConstructor typeConstructor;
|
||||
private List<TypeParameterDescriptor> typeParameters;
|
||||
private Collection<JetType> supertypes = new ArrayList<JetType>();
|
||||
|
||||
private ClassDescriptor classObjectDescriptor;
|
||||
|
||||
private final Set<ConstructorDescriptor> constructors = Sets.newLinkedHashSet();
|
||||
private ConstructorDescriptor primaryConstructor;
|
||||
|
||||
private final Set<CallableMemberDescriptor> declaredCallableMembers = Sets.newLinkedHashSet();
|
||||
private final Set<CallableMemberDescriptor> allCallableMembers = Sets.newLinkedHashSet(); // includes fake overrides
|
||||
private final Set<PropertyDescriptor> properties = Sets.newLinkedHashSet();
|
||||
private final Set<SimpleFunctionDescriptor> functions = Sets.newLinkedHashSet();
|
||||
|
||||
private final WritableScope scopeForMemberResolution;
|
||||
// This scope contains type parameters but does not contain inner classes
|
||||
private final WritableScope scopeForSupertypeResolution;
|
||||
private WritableScope scopeForInitializers = null; //contains members + primary constructor value parameters + map for backing fields
|
||||
private JetScope scopeForMemberLookup;
|
||||
|
||||
public MutableClassDescriptor(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull JetScope outerScope,
|
||||
@NotNull ClassKind kind,
|
||||
boolean isInner,
|
||||
@NotNull Name name
|
||||
) {
|
||||
super(LockBasedStorageManager.NO_LOCKS, containingDeclaration, name);
|
||||
this.kind = kind;
|
||||
this.isInner = isInner;
|
||||
|
||||
RedeclarationHandler redeclarationHandler = RedeclarationHandler.DO_NOTHING;
|
||||
|
||||
setScopeForMemberLookup(new WritableScopeImpl(JetScope.EMPTY, this, redeclarationHandler, "MemberLookup")
|
||||
.changeLockLevel(WritableScope.LockLevel.BOTH));
|
||||
this.scopeForSupertypeResolution = new WritableScopeImpl(outerScope, this, redeclarationHandler, "SupertypeResolution")
|
||||
.changeLockLevel(WritableScope.LockLevel.BOTH);
|
||||
this.scopeForMemberResolution = new WritableScopeImpl(scopeForSupertypeResolution, this, redeclarationHandler, "MemberResolution")
|
||||
.changeLockLevel(WritableScope.LockLevel.BOTH);
|
||||
if (getKind() == ClassKind.TRAIT) {
|
||||
setUpScopeForInitializers(this);
|
||||
}
|
||||
|
||||
scopeForMemberResolution.addLabeledDeclaration(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ClassDescriptor getClassObjectDescriptor() {
|
||||
return classObjectDescriptor;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Annotations getAnnotations() {
|
||||
if (annotations == null) {
|
||||
annotations = new AnnotationsImpl(new ArrayList<AnnotationDescriptor>(0));
|
||||
}
|
||||
return annotations;
|
||||
}
|
||||
|
||||
public void addAnnotations(@NotNull Iterable<AnnotationDescriptor> annotationsToAdd) {
|
||||
List<AnnotationDescriptor> annotations = ((AnnotationsImpl) getAnnotations()).getAnnotationDescriptors();
|
||||
for (AnnotationDescriptor annotationDescriptor : annotationsToAdd) {
|
||||
annotations.add(annotationDescriptor);
|
||||
}
|
||||
}
|
||||
|
||||
public void setModality(@NotNull Modality modality) {
|
||||
this.modality = modality;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Modality getModality() {
|
||||
return modality;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ClassKind getKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
public void setVisibility(@NotNull Visibility visibility) {
|
||||
this.visibility = visibility;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Visibility getVisibility() {
|
||||
return visibility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInner() {
|
||||
return isInner;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public TypeConstructor getTypeConstructor() {
|
||||
return typeConstructor;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Collection<JetType> getSupertypes() {
|
||||
return supertypes;
|
||||
}
|
||||
|
||||
public void setSupertypes(@NotNull Collection<JetType> supertypes) {
|
||||
this.supertypes = supertypes;
|
||||
}
|
||||
|
||||
public void addSupertype(@NotNull JetType supertype) {
|
||||
assert !supertype.isError() : "Error types must be filtered out in DescriptorResolver";
|
||||
if (TypeUtils.getClassDescriptor(supertype) != null) {
|
||||
// See the Errors.SUPERTYPE_NOT_A_CLASS_OR_TRAIT
|
||||
supertypes.add(supertype);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPrimaryConstructor(@NotNull ConstructorDescriptor constructorDescriptor) {
|
||||
assert primaryConstructor == null : "Primary constructor assigned twice " + this;
|
||||
primaryConstructor = constructorDescriptor;
|
||||
|
||||
constructors.add(constructorDescriptor);
|
||||
|
||||
((ConstructorDescriptorImpl) constructorDescriptor).setReturnType(new DelegatingType() {
|
||||
@Override
|
||||
protected JetType getDelegate() {
|
||||
return getDefaultType();
|
||||
}
|
||||
});
|
||||
|
||||
if (constructorDescriptor.isPrimary()) {
|
||||
setUpScopeForInitializers(constructorDescriptor);
|
||||
}
|
||||
}
|
||||
|
||||
public void addConstructorParametersToInitializersScope(@NotNull Collection<? extends VariableDescriptor> variables) {
|
||||
WritableScope scope = getWritableScopeForInitializers();
|
||||
for (VariableDescriptor variable : variables) {
|
||||
scope.addVariableDescriptor(variable);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<ConstructorDescriptor> getConstructors() {
|
||||
return constructors;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ConstructorDescriptor getUnsubstitutedPrimaryConstructor() {
|
||||
return primaryConstructor;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Set<SimpleFunctionDescriptor> getFunctions() {
|
||||
return functions;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Set<PropertyDescriptor> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Set<CallableMemberDescriptor> getDeclaredCallableMembers() {
|
||||
return declaredCallableMembers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Set<CallableMemberDescriptor> getAllCallableMembers() {
|
||||
return allCallableMembers;
|
||||
}
|
||||
|
||||
public void setTypeParameterDescriptors(@NotNull List<TypeParameterDescriptor> typeParameters) {
|
||||
if (this.typeParameters != null) {
|
||||
throw new IllegalStateException("Type parameters are already set for " + getName());
|
||||
}
|
||||
this.typeParameters = new ArrayList<TypeParameterDescriptor>(typeParameters);
|
||||
for (TypeParameterDescriptor typeParameterDescriptor : typeParameters) {
|
||||
scopeForSupertypeResolution.addTypeParameterDescriptor(typeParameterDescriptor);
|
||||
}
|
||||
scopeForSupertypeResolution.changeLockLevel(WritableScope.LockLevel.READING);
|
||||
}
|
||||
|
||||
public void createTypeConstructor() {
|
||||
assert typeConstructor == null : typeConstructor;
|
||||
this.typeConstructor = TypeConstructorImpl.createForClass(
|
||||
this,
|
||||
Annotations.EMPTY, // TODO : pass annotations from the class?
|
||||
!getModality().isOverridable(),
|
||||
getName().asString(),
|
||||
typeParameters,
|
||||
supertypes
|
||||
);
|
||||
for (FunctionDescriptor functionDescriptor : getConstructors()) {
|
||||
((ConstructorDescriptorImpl) functionDescriptor).setReturnType(getDefaultType());
|
||||
}
|
||||
scopeForMemberResolution.setImplicitReceiver(getThisAsReceiverParameter());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JetScope getScopeForClassHeaderResolution() {
|
||||
return scopeForSupertypeResolution;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JetScope getScopeForMemberDeclarationResolution() {
|
||||
return scopeForMemberResolution;
|
||||
}
|
||||
|
||||
private WritableScope getWritableScopeForInitializers() {
|
||||
if (scopeForInitializers == null) {
|
||||
throw new IllegalStateException("Scope for initializers queried before the primary constructor is set");
|
||||
}
|
||||
return scopeForInitializers;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JetScope getScopeForInitializerResolution() {
|
||||
return getWritableScopeForInitializers();
|
||||
}
|
||||
|
||||
private void setUpScopeForInitializers(@NotNull DeclarationDescriptor containingDeclaration) {
|
||||
this.scopeForInitializers = new WritableScopeImpl(
|
||||
scopeForMemberResolution, containingDeclaration, RedeclarationHandler.DO_NOTHING, "Initializers")
|
||||
.changeLockLevel(WritableScope.LockLevel.BOTH);
|
||||
}
|
||||
|
||||
public void setScopeForMemberLookup(@NotNull JetScope scopeForMemberLookup) {
|
||||
this.scopeForMemberLookup = scopeForMemberLookup;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JetScope getScopeForMemberLookup() {
|
||||
return scopeForMemberLookup;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private WritableScope getScopeForMemberLookupAsWritableScope() {
|
||||
// hack
|
||||
return (WritableScope) scopeForMemberLookup;
|
||||
}
|
||||
|
||||
public void lockScopes() {
|
||||
getScopeForMemberLookupAsWritableScope().changeLockLevel(WritableScope.LockLevel.READING);
|
||||
if (classObjectDescriptor instanceof MutableClassDescriptor) {
|
||||
((MutableClassDescriptor) classObjectDescriptor).lockScopes();
|
||||
}
|
||||
scopeForSupertypeResolution.changeLockLevel(WritableScope.LockLevel.READING);
|
||||
scopeForMemberResolution.changeLockLevel(WritableScope.LockLevel.READING);
|
||||
getWritableScopeForInitializers().changeLockLevel(WritableScope.LockLevel.READING);
|
||||
}
|
||||
|
||||
private PackageLikeBuilder builder = null;
|
||||
|
||||
@NotNull
|
||||
public PackageLikeBuilder getBuilder() {
|
||||
if (builder == null) {
|
||||
builder = new PackageLikeBuilder() {
|
||||
@NotNull
|
||||
@Override
|
||||
public DeclarationDescriptor getOwnerForChildren() {
|
||||
return MutableClassDescriptor.this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addClassifierDescriptor(@NotNull MutableClassDescriptor classDescriptor) {
|
||||
getScopeForMemberLookupAsWritableScope().addClassifierDescriptor(classDescriptor);
|
||||
scopeForMemberResolution.addClassifierDescriptor(classDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFunctionDescriptor(@NotNull SimpleFunctionDescriptor functionDescriptor) {
|
||||
getScopeForMemberLookupAsWritableScope().addFunctionDescriptor(functionDescriptor);
|
||||
functions.add(functionDescriptor);
|
||||
if (functionDescriptor.getKind().isReal()) {
|
||||
declaredCallableMembers.add(functionDescriptor);
|
||||
}
|
||||
allCallableMembers.add(functionDescriptor);
|
||||
scopeForMemberResolution.addFunctionDescriptor(functionDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassObjectStatus setClassObjectDescriptor(@NotNull ClassDescriptor classObjectDescriptor) {
|
||||
if (getKind() == ClassKind.CLASS_OBJECT || isInner()) {
|
||||
return ClassObjectStatus.NOT_ALLOWED;
|
||||
}
|
||||
|
||||
if (MutableClassDescriptor.this.classObjectDescriptor != null) {
|
||||
return ClassObjectStatus.DUPLICATE;
|
||||
}
|
||||
|
||||
assert classObjectDescriptor.getKind() == ClassKind.CLASS_OBJECT;
|
||||
MutableClassDescriptor.this.classObjectDescriptor = classObjectDescriptor;
|
||||
|
||||
// Members of the class object are accessible from the class
|
||||
// The scope must be lazy, because classObjectDescriptor may not by fully built yet
|
||||
scopeForMemberResolution.importScope(new ClassObjectMixinScope(classObjectDescriptor));
|
||||
|
||||
return ClassObjectStatus.OK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyDescriptor(@NotNull PropertyDescriptor propertyDescriptor) {
|
||||
getScopeForMemberLookupAsWritableScope().addPropertyDescriptor(propertyDescriptor);
|
||||
properties.add(propertyDescriptor);
|
||||
if (propertyDescriptor.getKind().isReal()) {
|
||||
declaredCallableMembers.add(propertyDescriptor);
|
||||
}
|
||||
allCallableMembers.add(propertyDescriptor);
|
||||
scopeForMemberResolution.addPropertyDescriptor(propertyDescriptor);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return DeclarationDescriptorImpl.toString(this);
|
||||
}
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
|
||||
public class MutablePackageFragmentDescriptor extends PackageFragmentDescriptorImpl {
|
||||
private final WritableScope scope;
|
||||
private final PackageLikeBuilder builder;
|
||||
|
||||
public MutablePackageFragmentDescriptor(@NotNull ModuleDescriptor module, @NotNull FqName fqName) {
|
||||
super(module, fqName);
|
||||
|
||||
scope = new WritableScopeImpl(JetScope.EMPTY, this, RedeclarationHandler.DO_NOTHING, "Members of " + fqName + " in " + module);
|
||||
scope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
||||
builder = new ScopeBasedPackageLikeBuilder(this, scope);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public WritableScope getMemberScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PackageLikeBuilder getBuilder() {
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -14,11 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.descriptors
|
||||
package org.jetbrains.jet.lang.descriptors.impl
|
||||
|
||||
import org.jetbrains.jet.lang.descriptors.impl.DeclarationDescriptorNonRootImpl
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName
|
||||
import org.jetbrains.jet.lang.descriptors.*
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor
|
||||
|
||||
public abstract class PackageFragmentDescriptorImpl(
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||
|
||||
public interface PackageLikeBuilder {
|
||||
@NotNull
|
||||
DeclarationDescriptor getOwnerForChildren();
|
||||
|
||||
void addClassifierDescriptor(@NotNull MutableClassDescriptor classDescriptor);
|
||||
|
||||
void addFunctionDescriptor(@NotNull SimpleFunctionDescriptor functionDescriptor);
|
||||
|
||||
void addPropertyDescriptor(@NotNull PropertyDescriptor propertyDescriptor);
|
||||
|
||||
enum ClassObjectStatus {
|
||||
OK,
|
||||
DUPLICATE,
|
||||
NOT_ALLOWED
|
||||
}
|
||||
|
||||
ClassObjectStatus setClassObjectDescriptor(@NotNull ClassDescriptor classObjectDescriptor);
|
||||
}
|
||||
-51
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||
|
||||
public class PackageLikeBuilderDummy implements PackageLikeBuilder {
|
||||
@NotNull
|
||||
@Override
|
||||
public DeclarationDescriptor getOwnerForChildren() {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addClassifierDescriptor(@NotNull MutableClassDescriptor classDescriptor) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFunctionDescriptor(@NotNull SimpleFunctionDescriptor functionDescriptor) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyDescriptor(@NotNull PropertyDescriptor propertyDescriptor) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassObjectStatus setClassObjectDescriptor(@NotNull ClassDescriptor classObjectDescriptor) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
-63
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
|
||||
public class ScopeBasedPackageLikeBuilder implements PackageLikeBuilder {
|
||||
private final DeclarationDescriptor containingDeclaration;
|
||||
private final WritableScope scope;
|
||||
|
||||
ScopeBasedPackageLikeBuilder(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull WritableScope scope
|
||||
) {
|
||||
this.containingDeclaration = containingDeclaration;
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public DeclarationDescriptor getOwnerForChildren() {
|
||||
return containingDeclaration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addClassifierDescriptor(@NotNull MutableClassDescriptor classDescriptor) {
|
||||
scope.addClassifierDescriptor(classDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFunctionDescriptor(@NotNull SimpleFunctionDescriptor functionDescriptor) {
|
||||
scope.addFunctionDescriptor(functionDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyDescriptor(@NotNull PropertyDescriptor propertyDescriptor) {
|
||||
scope.addPropertyDescriptor(propertyDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassObjectStatus setClassObjectDescriptor(@NotNull ClassDescriptor classObjectDescriptor) {
|
||||
throw new IllegalStateException("Must be guaranteed not to happen by the parser");
|
||||
}
|
||||
}
|
||||
@@ -22,10 +22,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.PlatformToKotlinClassMap;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.ClassDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.ConstructorDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.PropertyDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.*;
|
||||
import org.jetbrains.jet.lang.resolve.ImportPath;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
|
||||
@@ -21,12 +21,16 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.descriptors.serialization.*;
|
||||
import org.jetbrains.jet.descriptors.serialization.context.DeserializationContext;
|
||||
import org.jetbrains.jet.descriptors.serialization.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.descriptors.serialization.descriptors.AnnotationLoader;
|
||||
import org.jetbrains.jet.descriptors.serialization.descriptors.ConstantLoader;
|
||||
import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedPackageMemberScope;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.PackageFragmentDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.PackageFragmentProvider;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.PackageFragmentDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.storage.NotNullLazyValue;
|
||||
import org.jetbrains.jet.storage.StorageManager;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.jet.lang.PlatformToKotlinClassMap;
|
||||
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.descriptors.impl.ModuleDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.ValueParameterDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.ImportPath;
|
||||
|
||||
Reference in New Issue
Block a user