frontend: base class for JetScope implementations

This commit is contained in:
Stepan Koltsov
2012-06-17 05:28:01 +04:00
parent 955369988f
commit b33fc76c12
7 changed files with 42 additions and 32 deletions
@@ -22,6 +22,7 @@ import org.jetbrains.jet.lang.resolve.name.LabelName;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.scopes.DescriptorPredicate;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.resolve.scopes.JetScopeBase;
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
import java.util.Collection;
@@ -33,7 +34,7 @@ import java.util.Set;
*
* @author abreslav
*/
public abstract class AbstractScopeAdapter implements JetScope {
public abstract class AbstractScopeAdapter extends JetScopeBase {
@NotNull
protected abstract JetScope getWorkerScope();
@@ -109,8 +110,4 @@ public abstract class AbstractScopeAdapter implements JetScope {
return getWorkerScope().getAllDescriptors(predicate);
}
@Override
public Collection<DeclarationDescriptor> getAllDescriptors() {
return getAllDescriptors(DescriptorPredicate.all());
}
}
@@ -29,6 +29,7 @@ import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.scopes.DescriptorPredicate;
import org.jetbrains.jet.lang.resolve.scopes.DescriptorPredicateUtils;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.resolve.scopes.JetScopeBase;
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
import java.util.*;
@@ -36,7 +37,7 @@ import java.util.*;
/**
* @author abreslav
*/
public abstract class AbstractLazyMemberScope<D extends DeclarationDescriptor, DP extends DeclarationProvider> implements JetScope {
public abstract class AbstractLazyMemberScope<D extends DeclarationDescriptor, DP extends DeclarationProvider> extends JetScopeBase {
protected final ResolveSession resolveSession;
protected final DP declarationProvider;
protected final D thisDescriptor;
@@ -231,11 +232,6 @@ public abstract class AbstractLazyMemberScope<D extends DeclarationDescriptor, D
return DescriptorPredicateUtils.filter(allDescriptors, predicate);
}
@Override
public Collection<DeclarationDescriptor> getAllDescriptors() {
return getAllDescriptors(DescriptorPredicate.all());
}
protected abstract void addExtraDescriptors();
@Override
@@ -31,7 +31,7 @@ import java.util.Set;
/**
* @author abreslav
*/
public class ChainedScope implements JetScope {
public class ChainedScope extends JetScopeBase {
private final DeclarationDescriptor containingDeclaration;
private final JetScope[] scopeChain;
private Collection<DeclarationDescriptor> allDescriptors;
@@ -167,8 +167,4 @@ public class ChainedScope implements JetScope {
return allDescriptors;
}
@Override
public Collection<DeclarationDescriptor> getAllDescriptors() {
return getAllDescriptors(DescriptorPredicate.all());
}
}
@@ -0,0 +1,33 @@
/*
* Copyright 2010-2012 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.scopes;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import java.util.Collection;
/**
* @author Stepan Koltsov
*/
public abstract class JetScopeBase implements JetScope {
@Override
public Collection<DeclarationDescriptor> getAllDescriptors() {
return getAllDescriptors(DescriptorPredicate.all());
}
}
@@ -30,7 +30,7 @@ import java.util.Set;
/**
* @author abreslav
*/
public abstract class JetScopeImpl implements JetScope {
public abstract class JetScopeImpl extends JetScopeBase {
@Override
public ClassifierDescriptor getClassifier(@NotNull Name name) {
return null;
@@ -92,11 +92,6 @@ public abstract class JetScopeImpl implements JetScope {
return Collections.emptyList();
}
@Override
public Collection<DeclarationDescriptor> getAllDescriptors() {
return getAllDescriptors(DescriptorPredicate.all());
}
@Override
public void getImplicitReceiversHierarchy(@NotNull List<ReceiverDescriptor> result) {
}
@@ -34,7 +34,7 @@ import java.util.Set;
/**
* @author abreslav
*/
public class SubstitutingScope implements JetScope {
public class SubstitutingScope extends JetScopeBase {
private final JetScope workerScope;
private final TypeSubstitutor substitutor;
@@ -163,8 +163,4 @@ public class SubstitutingScope implements JetScope {
return allDescriptors;
}
@Override
public Collection<DeclarationDescriptor> getAllDescriptors() {
return getAllDescriptors(DescriptorPredicate.all());
}
}
@@ -24,6 +24,7 @@ import org.jetbrains.jet.lang.resolve.name.LabelName;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.scopes.DescriptorPredicate;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.resolve.scopes.JetScopeBase;
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
import org.jetbrains.jet.lang.types.error.ErrorSimpleFunctionDescriptorImpl;
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
@@ -38,7 +39,7 @@ public class ErrorUtils {
private static final ModuleDescriptor ERROR_MODULE = new ModuleDescriptor(Name.special("<ERROR MODULE>"));
public static class ErrorScope implements JetScope {
public static class ErrorScope extends JetScopeBase {
private final String debugMessage;
@@ -117,10 +118,6 @@ public class ErrorUtils {
return Collections.emptyList();
}
@Override
public Collection<DeclarationDescriptor> getAllDescriptors() {
return getAllDescriptors(DescriptorPredicate.all());
}
}
private static final ClassDescriptorImpl ERROR_CLASS = new ClassDescriptorImpl(ERROR_MODULE, Collections.<AnnotationDescriptor>emptyList(), Name.special("<ERROR CLASS>")) {