}
}
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();
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;
}
});
}
@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));
}
disposeTabs();
if (currentFile != null) {
- getManager().openFileImpl2(this, currentFile, focusEditor && myOwner.getCurrentWindow() == this, null);
+ getManager().openFileImpl2(this, currentFile, focusEditor && myOwner.getCurrentWindow() == this);
}
else {
myPanel.repaint();
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;
import javax.swing.*;
import javax.swing.border.Border;
-import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
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();
}
/**
* @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,
}
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
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) {
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;
}
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;
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);