getContainigDeclaration cannot be null for all descriptors except ModuleDescriptor
Get rid of lot of warnings
This commit is contained in:
+2
-1
@@ -27,7 +27,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public abstract class AbstractNamespaceDescriptorImpl extends DeclarationDescriptorImpl implements NamespaceDescriptor {
|
||||
public abstract class AbstractNamespaceDescriptorImpl extends DeclarationDescriptorNonRootImpl implements NamespaceDescriptor {
|
||||
private NamespaceType namespaceType;
|
||||
|
||||
public AbstractNamespaceDescriptorImpl(
|
||||
@@ -44,6 +44,7 @@ public abstract class AbstractNamespaceDescriptorImpl extends DeclarationDescrip
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public NamespaceDescriptorParent getContainingDeclaration() {
|
||||
return (NamespaceDescriptorParent) super.getContainingDeclaration();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.Set;
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public interface CallableDescriptor extends DeclarationDescriptorWithVisibility {
|
||||
public interface CallableDescriptor extends DeclarationDescriptorWithVisibility, DeclarationDescriptorNonRoot {
|
||||
@NotNull
|
||||
ReceiverDescriptor getReceiverParameter();
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.*;
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public class ClassDescriptorImpl extends DeclarationDescriptorImpl implements ClassDescriptorFromSource {
|
||||
public class ClassDescriptorImpl extends DeclarationDescriptorNonRootImpl implements ClassDescriptorFromSource {
|
||||
private TypeConstructor typeConstructor;
|
||||
|
||||
private JetScope memberDeclarations;
|
||||
|
||||
+1
-1
@@ -19,5 +19,5 @@ package org.jetbrains.jet.lang.descriptors;
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
*/
|
||||
public interface ClassOrNamespaceDescriptor extends DeclarationDescriptor {
|
||||
public interface ClassOrNamespaceDescriptor extends DeclarationDescriptorNonRoot {
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.jet.lang.types.TypeConstructor;
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public interface ClassifierDescriptor extends DeclarationDescriptor {
|
||||
public interface ClassifierDescriptor extends DeclarationDescriptorNonRoot {
|
||||
@NotNull
|
||||
TypeConstructor getTypeConstructor();
|
||||
|
||||
|
||||
+2
-11
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.jet.lang.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotatedImpl;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
@@ -26,19 +25,16 @@ import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
* @author Stepan Koltsov
|
||||
*/
|
||||
public abstract class DeclarationDescriptorImpl extends AnnotatedImpl implements Named, DeclarationDescriptor {
|
||||
|
||||
@NotNull
|
||||
private final Name name;
|
||||
private final DeclarationDescriptor containingDeclaration;
|
||||
|
||||
public DeclarationDescriptorImpl(@Nullable DeclarationDescriptor containingDeclaration, @NotNull List<AnnotationDescriptor> annotations, @NotNull Name name) {
|
||||
public DeclarationDescriptorImpl(@NotNull List<AnnotationDescriptor> annotations, @NotNull Name name) {
|
||||
super(annotations);
|
||||
|
||||
this.name = name;
|
||||
this.containingDeclaration = containingDeclaration;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -53,11 +49,6 @@ public abstract class DeclarationDescriptorImpl extends AnnotatedImpl implements
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeclarationDescriptor getContainingDeclaration() {
|
||||
return containingDeclaration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptVoid(DeclarationDescriptorVisitor<Void, Void> visitor) {
|
||||
accept(visitor, null);
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
*/
|
||||
public interface DeclarationDescriptorNonRoot extends DeclarationDescriptor {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
DeclarationDescriptor getContainingDeclaration();
|
||||
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public abstract class DeclarationDescriptorNonRootImpl
|
||||
extends DeclarationDescriptorImpl
|
||||
implements DeclarationDescriptorNonRoot {
|
||||
|
||||
@NotNull
|
||||
private final DeclarationDescriptor containingDeclaration;
|
||||
|
||||
public DeclarationDescriptorNonRootImpl(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
@NotNull Name name) {
|
||||
super(annotations, name);
|
||||
|
||||
this.containingDeclaration = containingDeclaration;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public DeclarationDescriptor getContainingDeclaration() {
|
||||
return containingDeclaration;
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -39,7 +39,7 @@ import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public abstract class FunctionDescriptorImpl extends DeclarationDescriptorImpl implements FunctionDescriptor {
|
||||
public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRootImpl implements FunctionDescriptor {
|
||||
|
||||
protected List<TypeParameterDescriptor> typeParameters;
|
||||
protected List<ValueParameterDescriptor> unsubstitutedValueParameters;
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public interface MemberDescriptor extends DeclarationDescriptor, DeclarationDescriptorWithVisibility {
|
||||
public interface MemberDescriptor extends DeclarationDescriptorNonRoot, DeclarationDescriptorWithVisibility {
|
||||
@NotNull
|
||||
Modality getModality();
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.jet.lang.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
@@ -29,8 +30,8 @@ import java.util.Collections;
|
||||
public class ModuleDescriptor extends DeclarationDescriptorImpl implements ClassOrNamespaceDescriptor, NamespaceDescriptorParent {
|
||||
private NamespaceDescriptor rootNamepsace;
|
||||
|
||||
public ModuleDescriptor(Name name) {
|
||||
super(null, Collections.<AnnotationDescriptor>emptyList(), name);
|
||||
public ModuleDescriptor(@NotNull Name name) {
|
||||
super(Collections.<AnnotationDescriptor>emptyList(), name);
|
||||
if (!name.isSpecial()) {
|
||||
throw new IllegalArgumentException("module name must be special: " + name);
|
||||
}
|
||||
@@ -43,6 +44,12 @@ public class ModuleDescriptor extends DeclarationDescriptorImpl implements Class
|
||||
this.rootNamepsace = rootNs;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public DeclarationDescriptor getContainingDeclaration() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public NamespaceDescriptor getRootNamespace() {
|
||||
return rootNamepsace;
|
||||
}
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ import java.util.Set;
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public abstract class PropertyAccessorDescriptor extends DeclarationDescriptorImpl implements FunctionDescriptor, MemberDescriptor {
|
||||
public abstract class PropertyAccessorDescriptor extends DeclarationDescriptorNonRootImpl implements FunctionDescriptor, MemberDescriptor {
|
||||
|
||||
private final boolean hasBody;
|
||||
private final boolean isDefault;
|
||||
|
||||
@@ -31,7 +31,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
*/
|
||||
public class ScriptDescriptor extends DeclarationDescriptorImpl {
|
||||
public class ScriptDescriptor extends DeclarationDescriptorNonRootImpl {
|
||||
private static final Name NAME = Name.special("<script>");
|
||||
|
||||
private final int priority;
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ import java.util.Set;
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public class TypeParameterDescriptorImpl extends DeclarationDescriptorImpl implements TypeParameterDescriptor {
|
||||
public class TypeParameterDescriptorImpl extends DeclarationDescriptorNonRootImpl implements TypeParameterDescriptor {
|
||||
public static TypeParameterDescriptor createWithDefaultBound(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ import java.util.Set;
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public abstract class VariableDescriptorImpl extends DeclarationDescriptorImpl implements VariableDescriptor {
|
||||
public abstract class VariableDescriptorImpl extends DeclarationDescriptorNonRootImpl implements VariableDescriptor {
|
||||
private JetType outType;
|
||||
|
||||
public VariableDescriptorImpl(
|
||||
|
||||
Reference in New Issue
Block a user