Esempio n. 1
0
  private JetScope getDeclarationsScope(String path) throws IOException {
    ModuleDescriptor moduleDescriptor =
        LazyResolveTestUtil.resolve(
            getProject(),
            Collections.singletonList(JetTestUtils.loadJetFile(getProject(), new File(path))));

    FqName fqName = new FqName("testData");
    PackageViewDescriptor packageView = moduleDescriptor.getPackage(fqName);
    assertNotNull("Package " + fqName + " not found", packageView);
    return addImports(packageView.getMemberScope());
  }
Esempio n. 2
0
  public static void resolveAllKotlinFiles(KotlinCoreEnvironment environment) throws IOException {
    List<ContentRoot> paths =
        environment.getConfiguration().get(CommonConfigurationKeys.CONTENT_ROOTS);
    if (paths == null) return;
    List<KtFile> jetFiles = Lists.newArrayList();
    for (ContentRoot root : paths) {
      if (!(root instanceof KotlinSourceRoot)) continue;

      String path = ((KotlinSourceRoot) root).getPath();
      File file = new File(path);
      if (file.isFile()) {
        jetFiles.add(loadJetFile(environment.getProject(), file));
      } else {
        //noinspection ConstantConditions
        for (File childFile : file.listFiles()) {
          if (childFile.getName().endsWith(".kt")) {
            jetFiles.add(loadJetFile(environment.getProject(), childFile));
          }
        }
      }
    }
    LazyResolveTestUtil.resolve(environment.getProject(), jetFiles, environment);
  }