コード例 #1
0
 public static Editor create(
     @NotNull final DocumentWindowImpl documentRange,
     @NotNull final EditorImpl editor,
     @NotNull final PsiFile injectedFile) {
   assert documentRange.isValid();
   assert injectedFile.isValid();
   EditorWindow window;
   synchronized (allEditors) {
     for (EditorWindow editorWindow : allEditors) {
       if (editorWindow.getDocument() == documentRange && editorWindow.getDelegate() == editor) {
         editorWindow.myInjectedFile = injectedFile;
         if (editorWindow.isValid()) {
           return editorWindow;
         }
       }
       if (editorWindow.getDocument().areRangesEqual(documentRange)) {
         // int i = 0;
       }
     }
     window = new EditorWindow(documentRange, editor, injectedFile, documentRange.isOneLine());
     allEditors.add(window);
   }
   assert window.isValid();
   return window;
 }
コード例 #2
0
  public boolean equals(final Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    final EditorWindow that = (EditorWindow) o;

    DocumentWindow thatWindow = that.getDocument();
    return myDelegate.equals(that.myDelegate) && myDocumentWindow.equals(thatWindow);
  }
コード例 #3
0
  public static void disposeInvalidEditors() {
    ApplicationManager.getApplication().assertWriteAccessAllowed();
    Iterator<EditorWindow> iterator = allEditors.iterator();
    while (iterator.hasNext()) {
      EditorWindow editorWindow = iterator.next();
      if (!editorWindow.isValid()) {
        editorWindow.dispose();

        InjectedLanguageUtil.clearCaches(editorWindow.myInjectedFile, editorWindow.getDocument());
        iterator.remove();
      }
    }
  }