cleanup
authorAlexey Kudravtsev <cdr@intellij.com>
Thu, 19 Aug 2010 10:19:07 +0000 (14:19 +0400)
committerAlexey Kudravtsev <cdr@intellij.com>
Thu, 19 Aug 2010 10:31:42 +0000 (14:31 +0400)
platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TextEditorHighlightingPassRegistrarImpl.java
platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/VisibleHighlightingPassFactory.java
platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorWindow.java
platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java
platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorProvider.java
xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/CreateNSDeclarationIntentionFix.java

index 52c4cccdd4eb415298e9811727dc578bc55133a9..00e4e0ef242ff872bca63ccf8c2eafda653ed9b7 100644 (file)
@@ -106,11 +106,12 @@ public class TextEditorHighlightingPassRegistrarImpl extends TextEditorHighlight
       }
     }
     PsiDocumentManager documentManager = PsiDocumentManager.getInstance(myProject);
-    PsiFile fileFromDoc = documentManager.getPsiFile(editor.getDocument());
+    final Document document = editor.getDocument();
+    PsiFile fileFromDoc = documentManager.getPsiFile(document);
     if (!(fileFromDoc instanceof PsiCompiledElement)) {
       assert fileFromDoc == psiFile : "Files are different: " + psiFile + ";" + fileFromDoc;
       Document documentFromFile = documentManager.getDocument(psiFile);
-      assert documentFromFile == editor.getDocument() : "Documents are different: " + editor.getDocument() + ";" + documentFromFile;
+      assert documentFromFile == document : "Documents are different: " + document + ";" + documentFromFile;
     }
     final TIntObjectHashMap<TextEditorHighlightingPass> id2Pass = new TIntObjectHashMap<TextEditorHighlightingPass>();
     final TIntArrayList passesRefusedToCreate = new TIntArrayList();
@@ -147,7 +148,7 @@ public class TextEditorHighlightingPassRegistrarImpl extends TextEditorHighlight
     final FileStatusMap statusMap = ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject)).getFileStatusMap();
     passesRefusedToCreate.forEach(new TIntProcedure() {
       public boolean execute(int passId) {
-        statusMap.markFileUpToDate(editor.getDocument(), psiFile, passId);
+        statusMap.markFileUpToDate(document, psiFile, passId);
         return true;
       }
     });
index 4c46c3bc302204fb8e9693401ceeca3be144db8c..83ce78d6afb3387f1211e159c34a8d8ff80f6e91 100644 (file)
@@ -36,7 +36,7 @@ public abstract class VisibleHighlightingPassFactory extends AbstractProjectComp
   }
 
   @NotNull
-  public static TextRange calculateVisibleRange(Editor editor) {
+  public static TextRange calculateVisibleRange(@NotNull Editor editor) {
     Rectangle rect = editor.getScrollingModel().getVisibleArea();
     LogicalPosition startPosition = editor.xyToLogicalPosition(new Point(rect.x, rect.y));
 
index 8b52d1e9c464438edd629bebb663d3c0bb4f2e0a..8d6bdec5de79b22cd1b07a4993df76ecd95ea6ba 100644 (file)
@@ -281,7 +281,7 @@ public class EditorWindow {
       }
       disposeTabs();
       if (currentFile != null) {
-        getManager().openFileImpl2(this, currentFile, focusEditor && myOwner.getCurrentWindow() == this, null);
+        getManager().openFileImpl2(this, currentFile, focusEditor && myOwner.getCurrentWindow() == this);
       }
       else {
         myPanel.repaint();
index 3a8d88acdbfdd1915e66066057db563efb21edf9..e45a8cd7741a63cf245a00746711b91d2b3299de 100644 (file)
@@ -41,7 +41,6 @@ import com.intellij.openapi.fileEditor.impl.text.TextEditorImpl;
 import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider;
 import com.intellij.openapi.fileTypes.FileTypeEvent;
 import com.intellij.openapi.fileTypes.FileTypeListener;
-import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.DumbAwareRunnable;
 import com.intellij.openapi.project.DumbService;
 import com.intellij.openapi.project.Project;
@@ -71,7 +70,6 @@ import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 import javax.swing.border.Border;
-import javax.swing.border.EmptyBorder;
 import java.awt.*;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
@@ -464,18 +462,19 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
       throw new IllegalArgumentException("file is not valid: " + file);
     }
     assertDispatchThread();
-    return openFileImpl2(getSplitters().getOrCreateCurrentWindow(file), file, focusEditor, null);
+    return openFileImpl2(getSplitters().getOrCreateCurrentWindow(file), file, focusEditor);
   }
 
-  @NotNull Pair<FileEditor[], FileEditorProvider[]> openFileImpl2(final EditorWindow window, final VirtualFile file, final boolean focusEditor,
-                                                                  final HistoryEntry entry) {
-    final Ref<Pair<FileEditor[], FileEditorProvider[]>> resHolder = new Ref<Pair<FileEditor[], FileEditorProvider[]>>();
+  @NotNull Pair<FileEditor[], FileEditorProvider[]> openFileImpl2(@NotNull final EditorWindow window,
+                                                                  @NotNull final VirtualFile file,
+                                                                  final boolean focusEditor) {
+    final Ref<Pair<FileEditor[], FileEditorProvider[]>> result = new Ref<Pair<FileEditor[], FileEditorProvider[]>>();
     CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
       public void run() {
-        resHolder.set(openFileImpl3(window, file, focusEditor, entry, true));
+        result.set(openFileImpl3(window, file, focusEditor, null, true));
       }
     }, "", null);
-    return resHolder.get();
+    return result.get();
   }
 
   /**
@@ -487,7 +486,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
    * @param entry map between FileEditorProvider and FileEditorState. If this parameter
    * @param current
    */
-  @NotNull Pair<FileEditor[], FileEditorProvider[]> openFileImpl3(final EditorWindow window,
+  @NotNull Pair<FileEditor[], FileEditorProvider[]> openFileImpl3(@NotNull final EditorWindow window,
                                                                   @NotNull final VirtualFile file,
                                                                   final boolean focusEditor,
                                                                   final HistoryEntry entry,
index 467666f31177ae055ff17ed2121deb0cffdae071..fb2ad1a3baaf762d95a79c8c3c0c4dd930be5f3f 100644 (file)
@@ -70,11 +70,7 @@ public class TextEditorProvider implements FileEditorProvider, DumbAware {
     }
 
     final FileType ft = file.getFileType();
-    if (ft.isBinary()) {
-      return BinaryFileTypeDecompilers.INSTANCE.forFileType(ft) != null;
-    }
-
-    return true;
+    return !ft.isBinary() || BinaryFileTypeDecompilers.INSTANCE.forFileType(ft) != null;
   }
 
   @NotNull
@@ -143,12 +139,7 @@ public class TextEditorProvider implements FileEditorProvider, DumbAware {
     if (editor instanceof DocumentsEditor) {
       DocumentsEditor documentsEditor = (DocumentsEditor)editor;
       Document[] documents = documentsEditor.getDocuments();
-      if (documents.length > 0) {
-        return documents;
-      }
-      else {
-        return null;
-      }
+      return documents.length > 0 ? documents : null;
     }
 
     if (editor instanceof TextEditor) {
@@ -182,7 +173,7 @@ public class TextEditorProvider implements FileEditorProvider, DumbAware {
     state.SELECTION_END = editor.getSelectionModel().getSelectionEnd();
 
     // Saving scrolling proportion on UNDO may cause undesirable results of undo action fails to perform since
-    // scrolling proportion restored sligtly differs from what have been saved.
+    // scrolling proportion restored slightly differs from what have been saved.
     state.VERTICAL_SCROLL_PROPORTION = level == FileEditorStateLevel.UNDO ? -1 : EditorUtil.calcVerticalScrollProportion(editor);
     return state;
   }
index e711a255308a8fbc8559ead074c993b79201427e..cd585dc71aba544c318c5f4ea84967671363ed05 100644 (file)
@@ -20,6 +20,7 @@ import com.intellij.codeInsight.CodeInsightUtilBase;
 import com.intellij.codeInsight.completion.ExtendedTagInsertHandler;
 import com.intellij.codeInsight.daemon.XmlErrorMessages;
 import com.intellij.codeInsight.daemon.impl.ShowAutoImportPass;
+import com.intellij.codeInsight.daemon.impl.VisibleHighlightingPassFactory;
 import com.intellij.codeInsight.hint.HintManager;
 import com.intellij.codeInsight.intention.IntentionAction;
 import com.intellij.codeInspection.HintAction;
@@ -182,7 +183,7 @@ public class CreateNSDeclarationIntentionFix implements HintAction, LocalQuickFi
       final String title = getTitle();
       final ImportNSAction action = new ImportNSAction(namespaces, myFile, myElement, editor, title);
       if (myElement instanceof XmlTag) {
-        if (ShowAutoImportPass.getVisibleRange(editor).contains(myToken.getTextRange())) {
+        if (VisibleHighlightingPassFactory.calculateVisibleRange(editor).contains(myToken.getTextRange())) {
           HintManager.getInstance().showQuestionHint(editor, message,
                                                      myToken.getTextOffset(),
                                                      myToken.getTextOffset() + myNamespacePrefix.length(), action);