... and rename
This commit is contained in:
+1
-1
@@ -36,7 +36,7 @@ import java.util.*;
|
|||||||
/**
|
/**
|
||||||
* @author Stepan Koltsov
|
* @author Stepan Koltsov
|
||||||
*/
|
*/
|
||||||
public class MutableClassDescriptorLite extends MutableDeclarationDescriptor implements ClassDescriptor, NamespaceLike {
|
public class MutableClassDescriptorLite extends MutableDeclarationDescriptor implements ClassDescriptor, NamespaceLikeBuilder {
|
||||||
private ConstructorDescriptor primaryConstructor;
|
private ConstructorDescriptor primaryConstructor;
|
||||||
private final Set<ConstructorDescriptor> constructors = Sets.newLinkedHashSet();
|
private final Set<ConstructorDescriptor> constructors = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public class NamespaceDescriptorImpl extends AbstractNamespaceDescriptorImpl implements NamespaceLike {
|
public class NamespaceDescriptorImpl extends AbstractNamespaceDescriptorImpl implements NamespaceLikeBuilder {
|
||||||
|
|
||||||
private WritableScope memberScope;
|
private WritableScope memberScope;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public interface NamespaceLike {
|
public interface NamespaceLikeBuilder {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
DeclarationDescriptor getOwnerForChildren();
|
DeclarationDescriptor getOwnerForChildren();
|
||||||
@@ -136,7 +136,7 @@ public class AnalyzingUtils {
|
|||||||
});
|
});
|
||||||
|
|
||||||
TopDownAnalyzer.process(project, bindingTraceContext, scope,
|
TopDownAnalyzer.process(project, bindingTraceContext, scope,
|
||||||
new NamespaceLike() {
|
new NamespaceLikeBuilder() {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public class DeclarationResolver {
|
|||||||
for (Map.Entry<JetFile, WritableScope> entry : context.getNamespaceScopes().entrySet()) {
|
for (Map.Entry<JetFile, WritableScope> entry : context.getNamespaceScopes().entrySet()) {
|
||||||
JetFile namespace = entry.getKey();
|
JetFile namespace = entry.getKey();
|
||||||
WritableScope namespaceScope = entry.getValue();
|
WritableScope namespaceScope = entry.getValue();
|
||||||
NamespaceLike namespaceDescriptor = context.getNamespaceDescriptors().get(namespace);
|
NamespaceLikeBuilder namespaceDescriptor = context.getNamespaceDescriptors().get(namespace);
|
||||||
|
|
||||||
resolveFunctionAndPropertyHeaders(namespace.getDeclarations(), namespaceScope, namespaceScope, namespaceScope, namespaceDescriptor);
|
resolveFunctionAndPropertyHeaders(namespace.getDeclarations(), namespaceScope, namespaceScope, namespaceScope, namespaceDescriptor);
|
||||||
}
|
}
|
||||||
@@ -138,7 +138,7 @@ public class DeclarationResolver {
|
|||||||
private void resolveFunctionAndPropertyHeaders(@NotNull List<JetDeclaration> declarations,
|
private void resolveFunctionAndPropertyHeaders(@NotNull List<JetDeclaration> declarations,
|
||||||
final @NotNull JetScope scopeForFunctions,
|
final @NotNull JetScope scopeForFunctions,
|
||||||
final @NotNull JetScope scopeForPropertyInitializers, final @NotNull JetScope scopeForPropertyAccessors,
|
final @NotNull JetScope scopeForPropertyInitializers, final @NotNull JetScope scopeForPropertyAccessors,
|
||||||
final @NotNull NamespaceLike namespaceLike)
|
final @NotNull NamespaceLikeBuilder namespaceLike)
|
||||||
{
|
{
|
||||||
for (JetDeclaration declaration : declarations) {
|
for (JetDeclaration declaration : declarations) {
|
||||||
declaration.accept(new JetVisitorVoid() {
|
declaration.accept(new JetVisitorVoid() {
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class TopDownAnalyzer {
|
|||||||
public static void process(
|
public static void process(
|
||||||
Project project, @NotNull BindingTrace trace,
|
Project project, @NotNull BindingTrace trace,
|
||||||
@NotNull JetScope outerScope,
|
@NotNull JetScope outerScope,
|
||||||
@NotNull NamespaceLike owner,
|
@NotNull NamespaceLikeBuilder owner,
|
||||||
@NotNull Collection<JetFile> files,
|
@NotNull Collection<JetFile> files,
|
||||||
@NotNull Predicate<PsiFile> analyzeCompletely,
|
@NotNull Predicate<PsiFile> analyzeCompletely,
|
||||||
@NotNull JetControlFlowDataTraceFactory flowDataTraceFactory,
|
@NotNull JetControlFlowDataTraceFactory flowDataTraceFactory,
|
||||||
@@ -97,7 +97,7 @@ public class TopDownAnalyzer {
|
|||||||
@NotNull Project project,
|
@NotNull Project project,
|
||||||
@NotNull BindingTrace trace,
|
@NotNull BindingTrace trace,
|
||||||
@NotNull JetScope outerScope,
|
@NotNull JetScope outerScope,
|
||||||
@NotNull NamespaceLike owner,
|
@NotNull NamespaceLikeBuilder owner,
|
||||||
@NotNull Collection<? extends PsiElement> declarations,
|
@NotNull Collection<? extends PsiElement> declarations,
|
||||||
@NotNull Predicate<PsiFile> analyzeCompletely,
|
@NotNull Predicate<PsiFile> analyzeCompletely,
|
||||||
@NotNull JetControlFlowDataTraceFactory flowDataTraceFactory,
|
@NotNull JetControlFlowDataTraceFactory flowDataTraceFactory,
|
||||||
@@ -110,7 +110,7 @@ public class TopDownAnalyzer {
|
|||||||
|
|
||||||
private void doProcess(
|
private void doProcess(
|
||||||
TopDownAnalysisContext context, JetScope outerScope,
|
TopDownAnalysisContext context, JetScope outerScope,
|
||||||
NamespaceLike owner,
|
NamespaceLikeBuilder owner,
|
||||||
Collection<? extends PsiElement> declarations) {
|
Collection<? extends PsiElement> declarations) {
|
||||||
// context.enableDebugOutput();
|
// context.enableDebugOutput();
|
||||||
context.debug("Enter");
|
context.debug("Enter");
|
||||||
@@ -171,7 +171,7 @@ public class TopDownAnalyzer {
|
|||||||
@NotNull JetScope outerScope,
|
@NotNull JetScope outerScope,
|
||||||
@NotNull final DeclarationDescriptor containingDeclaration,
|
@NotNull final DeclarationDescriptor containingDeclaration,
|
||||||
@NotNull JetObjectDeclaration object) {
|
@NotNull JetObjectDeclaration object) {
|
||||||
process(project, trace, outerScope, new NamespaceLike() {
|
process(project, trace, outerScope, new NamespaceLikeBuilder() {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class TypeHierarchyResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void process(@NotNull JetScope outerScope, @NotNull NamespaceLike owner, @NotNull Collection<? extends PsiElement> declarations) {
|
public void process(@NotNull JetScope outerScope, @NotNull NamespaceLikeBuilder owner, @NotNull Collection<? extends PsiElement> declarations) {
|
||||||
collectNamespacesAndClassifiers(outerScope, outerScope, owner, declarations); // namespaceScopes, classes
|
collectNamespacesAndClassifiers(outerScope, outerScope, owner, declarations); // namespaceScopes, classes
|
||||||
|
|
||||||
importsResolver.processTypeImports();
|
importsResolver.processTypeImports();
|
||||||
@@ -105,7 +105,7 @@ public class TypeHierarchyResolver {
|
|||||||
private void collectNamespacesAndClassifiers(
|
private void collectNamespacesAndClassifiers(
|
||||||
@NotNull final JetScope outerScope,
|
@NotNull final JetScope outerScope,
|
||||||
@NotNull final JetScope outerScopeForStatic,
|
@NotNull final JetScope outerScopeForStatic,
|
||||||
@NotNull final NamespaceLike owner,
|
@NotNull final NamespaceLikeBuilder owner,
|
||||||
@NotNull Collection<? extends PsiElement> declarations) {
|
@NotNull Collection<? extends PsiElement> declarations) {
|
||||||
for (PsiElement declaration : declarations) {
|
for (PsiElement declaration : declarations) {
|
||||||
declaration.accept(new JetVisitorVoid() {
|
declaration.accept(new JetVisitorVoid() {
|
||||||
@@ -165,7 +165,7 @@ public class TypeHierarchyResolver {
|
|||||||
classObjectDescriptor.addObjectDescriptor(mutableClassDescriptor);
|
classObjectDescriptor.addObjectDescriptor(mutableClassDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private MutableClassDescriptor createClassDescriptorForObject(@NotNull JetClassOrObject declaration, @NotNull NamespaceLike owner, JetScope scope, ClassKind classKind) {
|
private MutableClassDescriptor createClassDescriptorForObject(@NotNull JetClassOrObject declaration, @NotNull NamespaceLikeBuilder owner, JetScope scope, ClassKind classKind) {
|
||||||
MutableClassDescriptor mutableClassDescriptor = new MutableClassDescriptor(context.getTrace(), owner.getOwnerForChildren(), scope, classKind) {
|
MutableClassDescriptor mutableClassDescriptor = new MutableClassDescriptor(context.getTrace(), owner.getOwnerForChildren(), scope, classKind) {
|
||||||
@Override
|
@Override
|
||||||
public ClassObjectStatus setClassObjectDescriptor(@NotNull MutableClassDescriptorLite classObjectDescriptor) {
|
public ClassObjectStatus setClassObjectDescriptor(@NotNull MutableClassDescriptorLite classObjectDescriptor) {
|
||||||
@@ -210,7 +210,7 @@ public class TypeHierarchyResolver {
|
|||||||
public void visitClassObject(JetClassObject classObject) {
|
public void visitClassObject(JetClassObject classObject) {
|
||||||
JetObjectDeclaration objectDeclaration = classObject.getObjectDeclaration();
|
JetObjectDeclaration objectDeclaration = classObject.getObjectDeclaration();
|
||||||
if (objectDeclaration != null) {
|
if (objectDeclaration != null) {
|
||||||
NamespaceLike.ClassObjectStatus status = owner.setClassObjectDescriptor(createClassDescriptorForObject(objectDeclaration, owner, outerScopeForStatic, ClassKind.OBJECT));
|
NamespaceLikeBuilder.ClassObjectStatus status = owner.setClassObjectDescriptor(createClassDescriptorForObject(objectDeclaration, owner, outerScopeForStatic, ClassKind.OBJECT));
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case DUPLICATE:
|
case DUPLICATE:
|
||||||
context.getTrace().report(MANY_CLASS_OBJECTS.on(classObject));
|
context.getTrace().report(MANY_CLASS_OBJECTS.on(classObject));
|
||||||
@@ -225,10 +225,10 @@ public class TypeHierarchyResolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private NamespaceDescriptorImpl createNamespaceDescriptorPathIfNeeded(JetFile file, NamespaceLike owner, JetScope outerScope) {
|
private NamespaceDescriptorImpl createNamespaceDescriptorPathIfNeeded(JetFile file, NamespaceLikeBuilder owner, JetScope outerScope) {
|
||||||
JetNamespaceHeader namespaceHeader = file.getNamespaceHeader();
|
JetNamespaceHeader namespaceHeader = file.getNamespaceHeader();
|
||||||
|
|
||||||
NamespaceLike currentOwner = owner;
|
NamespaceLikeBuilder currentOwner = owner;
|
||||||
|
|
||||||
for (JetSimpleNameExpression nameExpression : namespaceHeader.getParentNamespaceNames()) {
|
for (JetSimpleNameExpression nameExpression : namespaceHeader.getParentNamespaceNames()) {
|
||||||
String namespaceName = JetPsiUtil.safeName(nameExpression.getReferencedName());
|
String namespaceName = JetPsiUtil.safeName(nameExpression.getReferencedName());
|
||||||
@@ -250,7 +250,7 @@ public class TypeHierarchyResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private NamespaceDescriptorImpl createNamespaceDescriptorIfNeeded(@Nullable JetFile file, @NotNull NamespaceLike owner, String name) {
|
private NamespaceDescriptorImpl createNamespaceDescriptorIfNeeded(@Nullable JetFile file, @NotNull NamespaceLikeBuilder owner, String name) {
|
||||||
NamespaceDescriptorImpl namespaceDescriptor = owner.getNamespace(name);
|
NamespaceDescriptorImpl namespaceDescriptor = owner.getNamespace(name);
|
||||||
if (namespaceDescriptor == null) {
|
if (namespaceDescriptor == null) {
|
||||||
namespaceDescriptor = new NamespaceDescriptorImpl(
|
namespaceDescriptor = new NamespaceDescriptorImpl(
|
||||||
|
|||||||
Reference in New Issue
Block a user