@NotNull
  private PackageViewDescriptor analyzeFileToPackageView(@NotNull File... extraClassPath)
      throws IOException {
    Project project = createEnvironment(Arrays.asList(extraClassPath)).getProject();

    AnalysisResult result =
        JvmResolveUtil.analyzeOneFileWithJavaIntegrationAndCheckForErrors(
            KotlinTestUtils.loadJetFile(project, getTestDataFileWithExtension("kt")));

    PackageViewDescriptor packageView =
        result.getModuleDescriptor().getPackage(LoadDescriptorUtil.TEST_PACKAGE_FQNAME);
    assertFalse(
        "Failed to find package: " + LoadDescriptorUtil.TEST_PACKAGE_FQNAME, packageView.isEmpty());
    return packageView;
  }
  public void testNoWarningsOnJavaKotlinInheritance() throws Exception {
    // This test checks that there are no PARAMETER_NAME_CHANGED_ON_OVERRIDE or
    // DIFFERENT_NAMES_FOR_THE_SAME_PARAMETER_IN_SUPERTYPES
    // warnings when subclassing in Kotlin from Java binaries (in case when no parameter names are
    // available for Java classes)

    KotlinTestUtils.compileJavaFiles(
        Collections.singletonList(getTestDataFileWithExtension("java")),
        Arrays.asList("-d", tmpdir.getPath()));

    Project project = createEnvironment(Collections.singletonList(tmpdir)).getProject();

    AnalysisResult result =
        JvmResolveUtil.analyzeOneFileWithJavaIntegration(
            KotlinTestUtils.loadJetFile(project, getTestDataFileWithExtension("kt")));
    result.throwIfError();

    BindingContext bindingContext = result.getBindingContext();
    AnalyzerWithCompilerReport.Companion.reportDiagnostics(
        bindingContext.getDiagnostics(), PrintingMessageCollector.PLAIN_TEXT_TO_SYSTEM_ERR);

    assertEquals(
        "There should be no diagnostics", 0, Iterables.size(bindingContext.getDiagnostics()));
  }
示例#3
0
 @NotNull
 public static AnalysisResult analyzeFile(
     @NotNull KtFile file, @NotNull KotlinCoreEnvironment environment) {
   return JvmResolveUtil.analyzeOneFileWithJavaIntegration(file, environment);
 }