コード例 #1
0
  public void doTest(String input, List<SourceFile> files, String expected) {
    testEditor = configureEditor("Test.kt", input);

    if (files != null) {
      for (SourceFile file : files) {
        createSourceFile(file.getName(), file.getContent());
      }
    }

    testEditor.save();
    joinBuildThread();

    try {
      IMarker[] markers =
          testEditor.getEditingFile().findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
      List<IMarkerResolution> resolutions = collectResolutions(markers);
      for (IMarkerResolution resolution : resolutions) {
        resolution.run(null);
      }
    } catch (CoreException e) {
      throw new RuntimeException(e);
    }

    EditorTestUtils.assertByEditor(testEditor.getEditor(), expected);
  }
コード例 #2
0
  @Override
  protected void performTest(String fileText, String expected) {
    IFile file = testEditor.getEditingFile();

    Character typedCharacter = TypingUtils.typedCharacter(fileText);
    if (typedCharacter != null) {
      testEditor.type(typedCharacter);
    }

    for (DiagnosticAnnotation annotation :
        DiagnosticAnnotationUtil.INSTANCE.createParsingDiagnosticAnnotations(file)) {
      AnnotationManager.addProblemMarker(annotation, file);
    }

    try {
      IMarker[] markers =
          testEditor.getEditingFile().findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
      String actual = insertTagsForErrors(EditorUtil.getSourceCode(getEditor()), markers);

      EditorTestUtils.assertByStringWithOffset(actual, expected);
    } catch (CoreException e) {
      KotlinLogger.logAndThrow(e);
    }
  }