Get rid of recordSourceForSynthesized

Sam descriptors now implement a common interface
SynthesizedCallableMemberDescriptor, introduced in frontend.
BindingContext.SOURCE_DESCRIPTOR_FOR_SYNTHESIZED is no longer needed
This commit is contained in:
Alexander Udalov
2013-08-30 23:14:19 +04:00
parent 56ca247509
commit 202524ab03
16 changed files with 61 additions and 57 deletions
@@ -0,0 +1,24 @@
/*
* 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;
import org.jetbrains.annotations.NotNull;
public interface SynthesizedCallableMemberDescriptor<D extends DeclarationDescriptor> extends CallableMemberDescriptor {
@NotNull
D getBaseForSynthesized();
}
@@ -39,7 +39,6 @@ import org.jetbrains.jet.util.slicedmap.*;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import static org.jetbrains.jet.util.slicedmap.RewritePolicy.DO_NOTHING;
@@ -260,8 +259,6 @@ public interface BindingContext {
WritableSlice<ClassDescriptor, Boolean> INCOMPLETE_HIERARCHY = Slices.createCollectiveSetSlice();
WritableSlice<CallableMemberDescriptor, DeclarationDescriptor> SOURCE_DESCRIPTOR_FOR_SYNTHESIZED = Slices.createSimpleSlice();
@SuppressWarnings("UnusedDeclaration")
@Deprecated // This field is needed only for the side effects of its initializer
Void _static_initializer = BasicWritableSlice.initSliceDebugNames(BindingContext.class);
@@ -170,8 +170,12 @@ public class BindingContextUtils {
@Nullable
public static PsiElement callableDescriptorToDeclaration(@NotNull BindingContext context, @NotNull CallableMemberDescriptor callable) {
if (callable.getKind() == CallableMemberDescriptor.Kind.SYNTHESIZED) {
DeclarationDescriptor source = context.get(BindingContext.SOURCE_DESCRIPTOR_FOR_SYNTHESIZED, callable);
return source != null ? descriptorToDeclaration(context, source) : null;
CallableMemberDescriptor original = callable.getOriginal();
if (original instanceof SynthesizedCallableMemberDescriptor<?>) {
DeclarationDescriptor base = ((SynthesizedCallableMemberDescriptor<?>) original).getBaseForSynthesized();
return descriptorToDeclaration(context, base);
}
return null;
}
if (callable.getKind() == CallableMemberDescriptor.Kind.DECLARATION) {
@@ -191,8 +195,12 @@ public class BindingContextUtils {
@NotNull
private static List<PsiElement> callableDescriptorToDeclarations(@NotNull BindingContext context, @NotNull CallableMemberDescriptor callable) {
if (callable.getKind() == CallableMemberDescriptor.Kind.SYNTHESIZED) {
DeclarationDescriptor source = context.get(BindingContext.SOURCE_DESCRIPTOR_FOR_SYNTHESIZED, callable.getOriginal());
return source != null ? descriptorToDeclarations(context, source) : Collections.<PsiElement>emptyList();
CallableMemberDescriptor original = callable.getOriginal();
if (original instanceof SynthesizedCallableMemberDescriptor<?>) {
DeclarationDescriptor base = ((SynthesizedCallableMemberDescriptor<?>) original).getBaseForSynthesized();
return descriptorToDeclarations(context, base);
}
return Collections.emptyList();
}
if (callable.getKind() == CallableMemberDescriptor.Kind.DECLARATION) {