diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TextEditorHighlightingPassRegistrarImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TextEditorHighlightingPassRegistrarImpl.java index 52c4cccdd4eb..00e4e0ef242f 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TextEditorHighlightingPassRegistrarImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TextEditorHighlightingPassRegistrarImpl.java @@ -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 id2Pass = new TIntObjectHashMap(); 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; } }); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/VisibleHighlightingPassFactory.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/VisibleHighlightingPassFactory.java index 4c46c3bc3022..83ce78d6afb3 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/VisibleHighlightingPassFactory.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/VisibleHighlightingPassFactory.java @@ -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)); diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorWindow.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorWindow.java index 8b52d1e9c464..8d6bdec5de79 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorWindow.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorWindow.java @@ -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(); diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java index 3a8d88acdbfd..e45a8cd7741a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java @@ -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 openFileImpl2(final EditorWindow window, final VirtualFile file, final boolean focusEditor, - final HistoryEntry entry) { - final Ref> resHolder = new Ref>(); + @NotNull Pair openFileImpl2(@NotNull final EditorWindow window, + @NotNull final VirtualFile file, + final boolean focusEditor) { + final Ref> result = new Ref>(); 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 openFileImpl3(final EditorWindow window, + @NotNull Pair openFileImpl3(@NotNull final EditorWindow window, @NotNull final VirtualFile file, final boolean focusEditor, final HistoryEntry entry, diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorProvider.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorProvider.java index 467666f31177..fb2ad1a3baaf 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorProvider.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorProvider.java @@ -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; } diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/CreateNSDeclarationIntentionFix.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/CreateNSDeclarationIntentionFix.java index e711a255308a..cd585dc71aba 100644 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/CreateNSDeclarationIntentionFix.java +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/CreateNSDeclarationIntentionFix.java @@ -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);