Пример #1
0
  @SuppressWarnings("ConstantConditions")
  private JetScope addImports(JetScope scope) {
    WritableScopeImpl writableScope =
        new WritableScopeImpl(
            scope,
            scope.getContainingDeclaration(),
            RedeclarationHandler.DO_NOTHING,
            "JetTypeCheckerTest.addImports");
    List<JetScope> scopeChain = new ArrayList<JetScope>();
    scopeChain.add(writableScope);

    ModuleDescriptor module = LazyResolveTestUtil.resolveProject(getProject());
    for (ImportPath defaultImport : module.getDefaultImports()) {
      FqName fqName = defaultImport.fqnPart();
      if (defaultImport.isAllUnder()) {
        scopeChain.add(module.getPackage(fqName).getMemberScope());
      } else {
        Name shortName = fqName.shortName();
        assert shortName.equals(defaultImport.getImportedName());
        writableScope.addClassifierDescriptor(
            module.getPackage(fqName.parent()).getMemberScope().getClassifier(shortName));
      }
    }
    scopeChain.add(module.getPackage(FqName.ROOT).getMemberScope());
    writableScope.changeLockLevel(WritableScope.LockLevel.BOTH);
    return new ChainedScope(
        scope.getContainingDeclaration(),
        "JetTypeCheckerTest.addImports scope with imports",
        scopeChain.toArray(new JetScope[scopeChain.size()]));
  }
Пример #2
0
 @SuppressWarnings("ConstantConditions")
 private WritableScopeImpl addImports(JetScope scope) {
   WritableScopeImpl writableScope =
       new WritableScopeImpl(
           scope,
           scope.getContainingDeclaration(),
           RedeclarationHandler.DO_NOTHING,
           "JetTypeCheckerTest.addImports");
   InjectorForJavaDescriptorResolver injector =
       new InjectorForJavaDescriptorResolver(getProject(), new BindingTraceContext());
   JavaDescriptorResolver javaDescriptorResolver = injector.getJavaDescriptorResolver();
   writableScope.importScope(
       javaDescriptorResolver
           .resolveNamespace(FqName.ROOT, INCLUDE_KOTLIN_SOURCES)
           .getMemberScope());
   writableScope.importScope(
       javaDescriptorResolver
           .resolveNamespace(new FqName("java.lang"), IGNORE_KOTLIN_SOURCES)
           .getMemberScope());
   writableScope.changeLockLevel(WritableScope.LockLevel.BOTH);
   writableScope.importScope(builtIns.getBuiltInsScope());
   return writableScope;
 }
Пример #3
0
 @NotNull
 @Override
 public DeclarationDescriptor getContainingDeclaration() {
   return workerScope.getContainingDeclaration();
 }