Introduced package view and fragment classes.
This commit is contained in:
@@ -359,6 +359,12 @@ public class ResolveSession implements KotlinCodeAnalyzer {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void visitPackageViewDescriptor(PackageViewDescriptor descriptor, Void data) {
|
||||||
|
ForceResolveUtil.forceResolveAllContents(descriptor);
|
||||||
|
return super.visitPackageViewDescriptor(descriptor, data);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void visitClassDescriptor(ClassDescriptor descriptor, Void data) {
|
public Void visitClassDescriptor(ClassDescriptor descriptor, Void data) {
|
||||||
ForceResolveUtil.forceResolveAllContents(descriptor);
|
ForceResolveUtil.forceResolveAllContents(descriptor);
|
||||||
|
|||||||
@@ -65,6 +65,11 @@ public class ExpectedLoadErrorsUtil {
|
|||||||
return visitDeclarationRecursively(descriptor, descriptor.getMemberScope());
|
return visitDeclarationRecursively(descriptor, descriptor.getMemberScope());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void visitPackageViewDescriptor(PackageViewDescriptor descriptor, Void data) {
|
||||||
|
return visitDeclarationRecursively(descriptor, descriptor.getMemberScope());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void visitClassDescriptor(ClassDescriptor descriptor, Void data) {
|
public Void visitClassDescriptor(ClassDescriptor descriptor, Void data) {
|
||||||
return visitDeclarationRecursively(descriptor, descriptor.getDefaultType().getMemberScope());
|
return visitDeclarationRecursively(descriptor, descriptor.getDefaultType().getMemberScope());
|
||||||
|
|||||||
@@ -183,6 +183,11 @@ public class JdkAnnotationsValidityTest extends UsefulTestCase {
|
|||||||
return visitDeclarationRecursively(descriptor, descriptor.getMemberScope());
|
return visitDeclarationRecursively(descriptor, descriptor.getMemberScope());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void visitPackageViewDescriptor(PackageViewDescriptor descriptor, Void data) {
|
||||||
|
return visitDeclarationRecursively(descriptor, descriptor.getMemberScope());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void visitClassDescriptor(ClassDescriptor descriptor, Void data) {
|
public Void visitClassDescriptor(ClassDescriptor descriptor, Void data) {
|
||||||
// skip java.util.Collection, etc.
|
// skip java.util.Collection, etc.
|
||||||
|
|||||||
@@ -182,6 +182,22 @@ public class DescriptorValidator {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean visitPackageFragmentDescriptor(
|
||||||
|
PackageFragmentDescriptor descriptor, DiagnosticCollector collector
|
||||||
|
) {
|
||||||
|
validateScope(descriptor.getMemberScope(), collector);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean visitPackageViewDescriptor(
|
||||||
|
PackageViewDescriptor descriptor, DiagnosticCollector collector
|
||||||
|
) {
|
||||||
|
validateScope(descriptor.getMemberScope(), collector);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean visitVariableDescriptor(
|
public Boolean visitVariableDescriptor(
|
||||||
VariableDescriptor descriptor, DiagnosticCollector collector
|
VariableDescriptor descriptor, DiagnosticCollector collector
|
||||||
@@ -368,6 +384,22 @@ public class DescriptorValidator {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void visitPackageFragmentDescriptor(
|
||||||
|
PackageFragmentDescriptor descriptor, JetScope scope
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void visitPackageViewDescriptor(
|
||||||
|
PackageViewDescriptor descriptor, JetScope scope
|
||||||
|
) {
|
||||||
|
// TODO
|
||||||
|
//assertFound(scope, descriptor, scope.getPackage(descriptor.getName()));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void visitVariableDescriptor(
|
public Void visitVariableDescriptor(
|
||||||
VariableDescriptor descriptor, JetScope scope
|
VariableDescriptor descriptor, JetScope scope
|
||||||
|
|||||||
@@ -65,6 +65,18 @@ public class RecursiveDescriptorProcessor {
|
|||||||
&& visitChildren(descriptor.getValueParameters(), data);
|
&& visitChildren(descriptor.getValueParameters(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean visitPackageFragmentDescriptor(PackageFragmentDescriptor descriptor, D data) {
|
||||||
|
return applyWorker(descriptor, data)
|
||||||
|
&& visitChildren(descriptor.getMemberScope().getAllDescriptors(), data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean visitPackageViewDescriptor(PackageViewDescriptor descriptor, D data) {
|
||||||
|
return applyWorker(descriptor, data)
|
||||||
|
&& visitChildren(descriptor.getMemberScope().getAllDescriptors(), data);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean visitNamespaceDescriptor(NamespaceDescriptor descriptor, D data) {
|
public Boolean visitNamespaceDescriptor(NamespaceDescriptor descriptor, D data) {
|
||||||
return applyWorker(descriptor, data)
|
return applyWorker(descriptor, data)
|
||||||
|
|||||||
@@ -97,6 +97,20 @@ public class RecursiveDescriptorProcessorTest extends KotlinTestWithEnvironment
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean visitPackageFragmentDescriptor(
|
||||||
|
PackageFragmentDescriptor descriptor, Void data
|
||||||
|
) {
|
||||||
|
add(descriptor);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean visitPackageViewDescriptor(PackageViewDescriptor descriptor, Void data) {
|
||||||
|
add(descriptor);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean visitVariableDescriptor(VariableDescriptor descriptor, Void data) {
|
public Boolean visitVariableDescriptor(VariableDescriptor descriptor, Void data) {
|
||||||
add(descriptor);
|
add(descriptor);
|
||||||
|
|||||||
+5
@@ -17,8 +17,13 @@
|
|||||||
package org.jetbrains.jet.lang.descriptors;
|
package org.jetbrains.jet.lang.descriptors;
|
||||||
|
|
||||||
public interface DeclarationDescriptorVisitor<R, D> {
|
public interface DeclarationDescriptorVisitor<R, D> {
|
||||||
|
@Deprecated
|
||||||
R visitNamespaceDescriptor(NamespaceDescriptor descriptor, D data);
|
R visitNamespaceDescriptor(NamespaceDescriptor descriptor, D data);
|
||||||
|
|
||||||
|
R visitPackageFragmentDescriptor(PackageFragmentDescriptor descriptor, D data);
|
||||||
|
|
||||||
|
R visitPackageViewDescriptor(PackageViewDescriptor descriptor, D data);
|
||||||
|
|
||||||
R visitVariableDescriptor(VariableDescriptor descriptor, D data);
|
R visitVariableDescriptor(VariableDescriptor descriptor, D data);
|
||||||
|
|
||||||
R visitFunctionDescriptor(FunctionDescriptor descriptor, D data);
|
R visitFunctionDescriptor(FunctionDescriptor descriptor, D data);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import org.jetbrains.jet.lang.descriptors.impl.NamespaceDescriptorParent;
|
|||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public interface NamespaceDescriptor extends ClassOrNamespaceDescriptor, NamespaceDescriptorParent {
|
public interface NamespaceDescriptor extends ClassOrNamespaceDescriptor, NamespaceDescriptorParent {
|
||||||
@NotNull
|
@NotNull
|
||||||
JetScope getMemberScope();
|
JetScope getMemberScope();
|
||||||
|
|||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
|
|
||||||
|
public interface PackageFragmentDescriptor extends ClassOrNamespaceDescriptor {
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
ModuleDescriptor getContainingDeclaration();
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
FqName getFqName();
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
JetScope getMemberScope();
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
|
|
||||||
|
public interface PackageViewDescriptor extends DeclarationDescriptor {
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
PackageViewDescriptor getContainingDeclaration();
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
FqName getFqName();
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
JetScope getMemberScope();
|
||||||
|
}
|
||||||
+10
@@ -43,6 +43,16 @@ public class DeclarationDescriptorVisitorEmptyBodies<R, D> implements Declaratio
|
|||||||
return visitDeclarationDescriptor(descriptor, data);
|
return visitDeclarationDescriptor(descriptor, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R visitPackageFragmentDescriptor(PackageFragmentDescriptor descriptor, D data) {
|
||||||
|
return visitDeclarationDescriptor(descriptor, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R visitPackageViewDescriptor(PackageViewDescriptor descriptor, D data) {
|
||||||
|
return visitDeclarationDescriptor(descriptor, data);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R visitClassDescriptor(ClassDescriptor descriptor, D data) {
|
public R visitClassDescriptor(ClassDescriptor descriptor, D data) {
|
||||||
return visitDeclarationDescriptor(descriptor, data);
|
return visitDeclarationDescriptor(descriptor, data);
|
||||||
|
|||||||
@@ -687,6 +687,18 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
|
|||||||
renderName(namespace, builder);
|
renderName(namespace, builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void renderPackageView(@NotNull PackageViewDescriptor packageView, @NotNull StringBuilder builder) {
|
||||||
|
builder.append(renderKeyword("package")).append(" ");
|
||||||
|
renderName(packageView, builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderPackageFragment(@NotNull PackageFragmentDescriptor fragment, @NotNull StringBuilder builder) {
|
||||||
|
builder.append(renderKeyword("package-fragment")).append(" ");
|
||||||
|
renderName(fragment, builder);
|
||||||
|
builder.append(" in context of ");
|
||||||
|
renderName(fragment.getContainingDeclaration(), builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* STUPID DISPATCH-ONLY VISITOR */
|
/* STUPID DISPATCH-ONLY VISITOR */
|
||||||
private class RenderDeclarationDescriptorVisitor extends DeclarationDescriptorVisitorEmptyBodies<Void, StringBuilder> {
|
private class RenderDeclarationDescriptorVisitor extends DeclarationDescriptorVisitorEmptyBodies<Void, StringBuilder> {
|
||||||
@@ -737,6 +749,22 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void visitPackageFragmentDescriptor(
|
||||||
|
PackageFragmentDescriptor descriptor, StringBuilder builder
|
||||||
|
) {
|
||||||
|
renderPackageFragment(descriptor, builder);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void visitPackageViewDescriptor(
|
||||||
|
PackageViewDescriptor descriptor, StringBuilder builder
|
||||||
|
) {
|
||||||
|
renderPackageView(descriptor, builder);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void visitModuleDeclaration(ModuleDescriptor descriptor, StringBuilder builder) {
|
public Void visitModuleDeclaration(ModuleDescriptor descriptor, StringBuilder builder) {
|
||||||
renderModuleOrScript(descriptor, builder);
|
renderModuleOrScript(descriptor, builder);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import com.intellij.psi.util.PsiTreeUtil;
|
|||||||
import com.intellij.testFramework.ResolveTestCase;
|
import com.intellij.testFramework.ResolveTestCase;
|
||||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.PackageViewDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.impl.DeclarationDescriptorVisitorEmptyBodies;
|
import org.jetbrains.jet.lang.descriptors.impl.DeclarationDescriptorVisitorEmptyBodies;
|
||||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||||
@@ -101,6 +102,12 @@ public class BuiltInsReferenceResolverTest extends ResolveTestCase {
|
|||||||
return visitDescriptors(descriptor.getMemberScope().getAllDescriptors());
|
return visitDescriptors(descriptor.getMemberScope().getAllDescriptors());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void visitPackageViewDescriptor(PackageViewDescriptor descriptor, Void data) {
|
||||||
|
descriptors.add(descriptor);
|
||||||
|
return visitDescriptors(descriptor.getMemberScope().getAllDescriptors());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void visitDeclarationDescriptor(DeclarationDescriptor descriptor, Void data) {
|
public Void visitDeclarationDescriptor(DeclarationDescriptor descriptor, Void data) {
|
||||||
descriptors.add(descriptor);
|
descriptors.add(descriptor);
|
||||||
|
|||||||
Reference in New Issue
Block a user