mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
encapsulate ImmutableText
This commit is contained in:
@@ -848,13 +848,6 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx {
|
||||
return myText;
|
||||
}
|
||||
|
||||
// Breaks encapsulation, yet required for current zero-latency typing implementation.
|
||||
// TODO Should be removed when we implement typing without starting write actions.
|
||||
@NotNull
|
||||
public ImmutableText getImmutableText() {
|
||||
return myText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDocumentListener(@NotNull DocumentListener listener) {
|
||||
myCachedDocumentListeners.set(null);
|
||||
@@ -896,11 +889,11 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx {
|
||||
doRemoveDocumentListener(listener, myCachedDocumentListeners, myDocumentListeners);
|
||||
}
|
||||
|
||||
public void addInternalBulkModeListener(@NotNull DocumentBulkUpdateListener listener) {
|
||||
void addInternalBulkModeListener(@NotNull DocumentBulkUpdateListener listener) {
|
||||
myBulkDocumentInternalListeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeInternalBulkModeListener(@NotNull DocumentBulkUpdateListener listener) {
|
||||
void removeInternalBulkModeListener(@NotNull DocumentBulkUpdateListener listener) {
|
||||
myBulkDocumentInternalListeners.remove(listener);
|
||||
}
|
||||
|
||||
|
||||
+9
-5
@@ -27,7 +27,6 @@ import com.intellij.openapi.editor.ex.PrioritizedDocumentListener;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
|
||||
import com.intellij.openapi.editor.highlighter.HighlighterClient;
|
||||
import com.intellij.openapi.editor.highlighter.HighlighterIterator;
|
||||
import com.intellij.openapi.editor.impl.DocumentImpl;
|
||||
import com.intellij.openapi.editor.impl.EditorDocumentPriorities;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.fileTypes.PlainSyntaxHighlighter;
|
||||
@@ -39,7 +38,8 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.text.ImmutableCharSequence;
|
||||
import com.intellij.util.text.ImmutableText;
|
||||
import com.intellij.util.text.MergingCharSequence;
|
||||
import com.intellij.util.text.SingleCharSequence;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -368,6 +368,7 @@ public class LexerEditorHighlighter implements EditorHighlighter, PrioritizedDoc
|
||||
return myHighlighter;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private TextAttributes getAttributes(IElementType tokenType) {
|
||||
TextAttributes attrs = myAttributesMap.get(tokenType);
|
||||
if (attrs == null) {
|
||||
@@ -380,7 +381,8 @@ public class LexerEditorHighlighter implements EditorHighlighter, PrioritizedDoc
|
||||
|
||||
// Called to determine visual attributes of inserted character prior to starting a write action.
|
||||
// TODO Should be removed when we implement typing without starting write actions.
|
||||
public TextAttributes getAttributes(DocumentImpl document, int offset, char c) {
|
||||
@NotNull
|
||||
public TextAttributes getAttributesForTypedChar(@NotNull Document document, int offset, char c) {
|
||||
int startOffset = 0;
|
||||
|
||||
if (mySegments.getSegmentCount() > 0) {
|
||||
@@ -404,7 +406,8 @@ public class LexerEditorHighlighter implements EditorHighlighter, PrioritizedDoc
|
||||
startOffset = mySegments.getSegmentStart(startIndex);
|
||||
}
|
||||
|
||||
ImmutableText newText = document.getImmutableText().insert(offset, Character.toString(c));
|
||||
CharSequence text = document.getImmutableCharSequence();
|
||||
CharSequence newText = new MergingCharSequence(new MergingCharSequence(text.subSequence(0, offset), new SingleCharSequence(c)), text.subSequence(offset, text.length()));
|
||||
|
||||
myLexer.start(newText, startOffset, newText.length(), myInitialState);
|
||||
|
||||
@@ -420,7 +423,8 @@ public class LexerEditorHighlighter implements EditorHighlighter, PrioritizedDoc
|
||||
return getAttributes(tokenType);
|
||||
}
|
||||
|
||||
protected TextAttributes convertAttributes(@NotNull TextAttributesKey[] keys) {
|
||||
@NotNull
|
||||
TextAttributes convertAttributes(@NotNull TextAttributesKey[] keys) {
|
||||
TextAttributes attrs = new TextAttributes();
|
||||
for (TextAttributesKey key : keys) {
|
||||
TextAttributes attrs2 = myScheme.getAttributes(key);
|
||||
|
||||
@@ -17,9 +17,6 @@ package com.intellij.openapi.editor.impl;
|
||||
|
||||
import com.intellij.ide.plugins.IdeaPluginDescriptor;
|
||||
import com.intellij.ide.plugins.PluginManager;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationGroup;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
@@ -230,7 +227,7 @@ public class ImmediatePainter {
|
||||
private void paintImmediately(Graphics g, int offset, char c, boolean insert) {
|
||||
if (g == null) return; // editor component is currently not displayable
|
||||
|
||||
TextAttributes attributes = ((LexerEditorHighlighter)getHighlighter()).getAttributes((DocumentImpl)getDocument(), offset, c);
|
||||
TextAttributes attributes = ((LexerEditorHighlighter)getHighlighter()).getAttributesForTypedChar(getDocument(), offset, c);
|
||||
|
||||
int fontType = attributes.getFontType();
|
||||
FontInfo fontInfo = EditorUtil.fontForChar(c, attributes.getFontType(), myEditor);
|
||||
|
||||
Reference in New Issue
Block a user