コード例 #1
0
  public void dispose() {
    final EditorFactory editorFactory = EditorFactory.getInstance();
    editorFactory.releaseEditor(myConsoleEditor);
    editorFactory.releaseEditor(myHistoryViewer);

    final FileEditorManager editorManager = FileEditorManager.getInstance(getProject());
    final boolean isOpen = editorManager.isFileOpen(myVirtualFile);
    if (isOpen) {
      editorManager.closeFile(myVirtualFile);
    }
  }
 @Override
 protected void tearDown() throws Exception {
   FileEditorManager editorManager = FileEditorManager.getInstance(getProject());
   VirtualFile[] openFiles = editorManager.getOpenFiles();
   for (VirtualFile openFile : openFiles) {
     editorManager.closeFile(openFile);
   }
   deleteVFile();
   myEditor = null;
   myFile = null;
   myVFile = null;
   super.tearDown();
 }
コード例 #3
0
  private String processFile(final PsiFile file)
      throws IncorrectOperationException, InvalidDataException, IOException {
    String result = "";
    String fileText = file.getText();
    int startOffset = fileText.indexOf(TestUtils.BEGIN_MARKER);
    if (startOffset < 0) {
      startOffset = fileText.indexOf(ALL_MARKER);
      replaceAllOccurences = true;
      fileText = removeAllMarker(fileText);
    } else {
      replaceAllOccurences = false;
      fileText = TestUtils.removeBeginMarker(fileText);
    }
    int endOffset = fileText.indexOf(TestUtils.END_MARKER);
    fileText = TestUtils.removeEndMarker(fileText);
    myFile = TestUtils.createPseudoPhysicalScalaFile(myProject, fileText);
    fileEditorManager = FileEditorManager.getInstance(myProject);
    myEditor =
        fileEditorManager.openTextEditor(
            new OpenFileDescriptor(myProject, myFile.getVirtualFile(), 0), false);

    try {

      String varName = "value";
      final ScType varType = null;

      ScalaVariableValidator validator =
          IntroduceVariableTestUtil.getValidator(
              myProject, myEditor, (ScalaFile) myFile, startOffset, endOffset);
      String[] res = validator.isOKImpl(varName, replaceAllOccurences);
      for (String s : res) result += s + "\n";
    } finally {
      fileEditorManager.closeFile(myFile.getVirtualFile());
      myEditor = null;
    }
    return result;
  }