mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
simplified API calls
This commit is contained in:
@@ -130,7 +130,7 @@ public class PositionHighlighter {
|
||||
if(!myIsActive) return;
|
||||
myIsActive = false;
|
||||
if (myHighlighter != null) {
|
||||
myEditor.getMarkupModel().removeHighlighter(myHighlighter);
|
||||
myHighlighter.dispose();
|
||||
myHighlighter = null;
|
||||
}
|
||||
}
|
||||
|
||||
+7
-10
@@ -112,8 +112,8 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
|
||||
}
|
||||
|
||||
protected Breakpoint init() {
|
||||
if(!isValid()) {
|
||||
getDocument().getMarkupModel(myProject).removeHighlighter(myHighlighter);
|
||||
if (!isValid()) {
|
||||
myHighlighter.dispose();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -379,12 +379,9 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
|
||||
if (highlighter != null) {
|
||||
DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() {
|
||||
public void run() {
|
||||
if (highlighter.isValid()) {
|
||||
MarkupModel markupModel = highlighter.getDocument().getMarkupModel(myProject);
|
||||
markupModel.removeHighlighter(highlighter);
|
||||
//we should delete it here, so gutter will not fire events to deleted breakpoint
|
||||
BreakpointWithHighlighter.super.delete();
|
||||
}
|
||||
highlighter.dispose();
|
||||
//we should delete it here, so gutter will not fire events to deleted breakpoint
|
||||
BreakpointWithHighlighter.super.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -461,13 +458,13 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
|
||||
reload();
|
||||
|
||||
if(!isValid()) {
|
||||
oldDocument.getMarkupModel(myProject).removeHighlighter(myHighlighter);
|
||||
myHighlighter.dispose();
|
||||
myHighlighter = oldHighlighter;
|
||||
reload();
|
||||
return false;
|
||||
}
|
||||
|
||||
oldDocument.getMarkupModel(myProject).removeHighlighter(oldHighlighter);
|
||||
oldHighlighter.dispose();
|
||||
|
||||
DebuggerManagerEx.getInstanceEx(getProject()).getBreakpointManager().fireBreakpointChanged(this);
|
||||
updateUI();
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ public class RunToCursorBreakpoint extends LineBreakpoint {
|
||||
}
|
||||
|
||||
RunToCursorBreakpoint breakpoint = new RunToCursorBreakpoint(project, createHighlighter(project, document, lineIndex), restoreBreakpoints);
|
||||
document.getMarkupModel(project).removeHighlighter(breakpoint.getHighlighter());
|
||||
breakpoint.getHighlighter().dispose();
|
||||
|
||||
return (RunToCursorBreakpoint)breakpoint.init();
|
||||
}
|
||||
|
||||
+1
-2
@@ -157,9 +157,8 @@ public class OccurrencesChooser {
|
||||
}
|
||||
|
||||
private void dropHighlighters() {
|
||||
final MarkupModel markupModel = myEditor.getMarkupModel();
|
||||
for (RangeHighlighter highlight : myRangeHighlighters) {
|
||||
markupModel.removeHighlighter(highlight);
|
||||
highlight.dispose();
|
||||
}
|
||||
myRangeHighlighters.clear();
|
||||
}
|
||||
|
||||
+5
-5
@@ -574,16 +574,16 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
|
||||
HighlightInfo toAdd) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
|
||||
stripWarningsCoveredByErrors(project, markup, toAdd);
|
||||
stripWarningsCoveredByErrors(project, toAdd, markup.getDocument());
|
||||
}
|
||||
|
||||
private static void stripWarningsCoveredByErrors(Project project, MarkupModel markup, final HighlightInfo toAdd) {
|
||||
private static void stripWarningsCoveredByErrors(Project project, final HighlightInfo toAdd, Document document) {
|
||||
final SeverityRegistrar severityRegistrar = SeverityRegistrar.getInstance(project);
|
||||
final Set<HighlightInfo> covered = new THashSet<HighlightInfo>();
|
||||
|
||||
// either toAdd is warning and covered by one of errors in highlightsToSet or toAdd is an error and covers warnings in highlightsToSet or it is OK
|
||||
final boolean addingError = severityRegistrar.compare(HighlightSeverity.ERROR, toAdd.getSeverity()) <= 0;
|
||||
boolean toAddIsVisible = processHighlights(markup.getDocument(), project, null, toAdd.getActualStartOffset(),
|
||||
boolean toAddIsVisible = processHighlights(document, project, null, toAdd.getActualStartOffset(),
|
||||
toAdd.getActualEndOffset(), new Processor<HighlightInfo>() {
|
||||
public boolean process(HighlightInfo interval) {
|
||||
boolean isError = severityRegistrar.compare(HighlightSeverity.ERROR, interval.getSeverity()) <= 0;
|
||||
@@ -595,12 +595,12 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
|
||||
});
|
||||
if (!toAddIsVisible) {
|
||||
// toAdd is covered by
|
||||
markup.removeHighlighter(toAdd.highlighter);
|
||||
toAdd.highlighter.dispose();
|
||||
}
|
||||
for (HighlightInfo warning : covered) {
|
||||
RangeHighlighter highlighter = warning.highlighter;
|
||||
if (highlighter != null) {
|
||||
markup.removeHighlighter(highlighter);
|
||||
highlighter.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -161,7 +161,7 @@ public class IdentifierHighlighterPass extends TextEditorHighlightingPass {
|
||||
}
|
||||
HighlightInfo info = (HighlightInfo)tooltip;
|
||||
if (info.type == ourReadHighlightInfoType || info.type == ourWriteHighlightInfoType) {
|
||||
markupModel.removeHighlighter(highlighter);
|
||||
highlighter.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ public class IndentsPass extends TextEditorHighlightingPass implements DumbAware
|
||||
curRange++;
|
||||
}
|
||||
else if (cmp > 0) {
|
||||
mm.removeHighlighter(highlighter);
|
||||
highlighter.dispose();
|
||||
curHighlight++;
|
||||
}
|
||||
else {
|
||||
@@ -251,7 +251,8 @@ public class IndentsPass extends TextEditorHighlightingPass implements DumbAware
|
||||
}
|
||||
|
||||
for (; curHighlight < oldHighlighters.size(); curHighlight++) {
|
||||
mm.removeHighlighter(oldHighlighters.get(curHighlight));
|
||||
RangeHighlighter highlighter = oldHighlighters.get(curHighlight);
|
||||
highlighter.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -285,7 +285,7 @@ public class UpdateHighlightersUtil {
|
||||
}
|
||||
});
|
||||
for (RangeHighlighter highlighter : infosToRemove.forAllInGarbageBin()) {
|
||||
markup.removeHighlighter(highlighter);
|
||||
highlighter.dispose();
|
||||
changed[0] = true;
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@ public class UpdateHighlightersUtil {
|
||||
}
|
||||
});
|
||||
for (RangeHighlighter highlighter : infosToRemove.forAllInGarbageBin()) {
|
||||
markup.removeHighlighter(highlighter);
|
||||
highlighter.dispose();
|
||||
changed[0] = true;
|
||||
}
|
||||
|
||||
@@ -565,7 +565,7 @@ public class UpdateHighlightersUtil {
|
||||
}
|
||||
|
||||
for (RangeHighlighter highlighter : toReuse.forAllInGarbageBin()) {
|
||||
markupModel.removeHighlighter(highlighter);
|
||||
highlighter.dispose();
|
||||
}
|
||||
|
||||
DaemonCodeAnalyzerImpl.setLineMarkers(document, array, project);
|
||||
@@ -648,7 +648,7 @@ public class UpdateHighlightersUtil {
|
||||
|
||||
for (HighlightInfo info : removed) {
|
||||
if (!info.highlighter.isValid() || info.type.equals(HighlightInfoType.WRONG_REF)) {
|
||||
markup.removeHighlighter(info.highlighter);
|
||||
info.highlighter.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-4
@@ -408,9 +408,8 @@ public class BraceHighlightingHandler {
|
||||
List<RangeHighlighter> highlighters = myEditor.getUserData(BRACE_HIGHLIGHTERS_IN_EDITOR_VIEW_KEY);
|
||||
if (highlighters == null) return;
|
||||
myEditor.putUserData(BRACE_HIGHLIGHTERS_IN_EDITOR_VIEW_KEY, null);
|
||||
for (final Object highlighter : highlighters) {
|
||||
RangeHighlighter rangeHighlighter = (RangeHighlighter)highlighter;
|
||||
myEditor.getMarkupModel().removeHighlighter(rangeHighlighter);
|
||||
for (final RangeHighlighter highlighter : highlighters) {
|
||||
highlighter.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,7 +430,7 @@ public class BraceHighlightingHandler {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
RangeHighlighter marker = myEditor.getUserData(LINE_MARKER_IN_EDITOR_KEY);
|
||||
if (marker != null && ((MarkupModelEx)myEditor.getMarkupModel()).containsHighlighter(marker)) {
|
||||
myEditor.getMarkupModel().removeHighlighter(marker);
|
||||
marker.dispose();
|
||||
}
|
||||
myEditor.putUserData(LINE_MARKER_IN_EDITOR_KEY, null);
|
||||
}
|
||||
|
||||
+2
-2
@@ -138,7 +138,7 @@ public class HighlightManagerImpl extends HighlightManager implements ProjectCom
|
||||
if (info == null) return false;
|
||||
MarkupModel markupModel = info.editor.getMarkupModel();
|
||||
if (((MarkupModelEx)markupModel).containsHighlighter(highlighter)) {
|
||||
markupModel.removeHighlighter(highlighter);
|
||||
highlighter.dispose();
|
||||
}
|
||||
map.remove(highlighter);
|
||||
return true;
|
||||
@@ -317,4 +317,4 @@ public class HighlightManagerImpl extends HighlightManager implements ProjectCom
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,6 @@ import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.ui.MultiLineLabelUI;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -60,9 +59,9 @@ import com.intellij.pom.Navigatable;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
|
||||
import com.intellij.psi.search.searches.DefinitionsSearch;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.ui.LightweightHint;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -370,7 +369,7 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
|
||||
return found.size() != 2;
|
||||
}
|
||||
});
|
||||
return found.toArray(new PsiElement[found.size()]);
|
||||
return PsiUtilBase.toPsiElementArray(found);
|
||||
}
|
||||
}.searchImplementations(editor, element, offset);
|
||||
if (targetElements.length > 1) {
|
||||
@@ -418,7 +417,7 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
|
||||
|
||||
private void disposeHighlighter() {
|
||||
if (myHighlighter != null) {
|
||||
myHighlighter.deinstall();
|
||||
myHighlighter.uninstall();
|
||||
HintManager.getInstance().hideAllHints();
|
||||
myHighlighter = null;
|
||||
}
|
||||
@@ -563,9 +562,9 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
|
||||
myStoredInfo = storedInfo;
|
||||
}
|
||||
|
||||
public void deinstall() {
|
||||
public void uninstall() {
|
||||
for (RangeHighlighter highlighter : myHighlighters) {
|
||||
myHighlighterView.getMarkupModel().removeHighlighter(highlighter);
|
||||
highlighter.dispose();
|
||||
}
|
||||
|
||||
Component internalComponent = myHighlighterView.getContentComponent();
|
||||
|
||||
+2
-2
@@ -137,7 +137,7 @@ public class IncrementalSearchHandler {
|
||||
super.hide();
|
||||
|
||||
if (data.segmentHighlighter != null){
|
||||
editor.getMarkupModel().removeHighlighter(data.segmentHighlighter);
|
||||
data.segmentHighlighter.dispose();
|
||||
}
|
||||
PerEditorSearchData editorData = editor.getUserData(SEARCH_DATA_IN_EDITOR_VIEW_KEY);
|
||||
editorData.hint = null;
|
||||
@@ -281,7 +281,7 @@ public class IncrementalSearchHandler {
|
||||
|
||||
if (nothingIfFailed && index < 0) return;
|
||||
if (data.segmentHighlighter != null) {
|
||||
editor.getMarkupModel().removeHighlighter(data.segmentHighlighter);
|
||||
data.segmentHighlighter.dispose();
|
||||
data.segmentHighlighter = null;
|
||||
}
|
||||
if (index < 0) {
|
||||
|
||||
@@ -79,7 +79,7 @@ public class TemplateState implements Disposable {
|
||||
private Map<String, String> myPredefinedVariableValues;
|
||||
|
||||
private RangeMarker myTemplateRange = null;
|
||||
private final ArrayList<RangeHighlighter> myTabStopHighlighters = new ArrayList<RangeHighlighter>();
|
||||
private final List<RangeHighlighter> myTabStopHighlighters = new ArrayList<RangeHighlighter>();
|
||||
private int myCurrentVariableNumber = -1;
|
||||
private int myCurrentSegmentNumber = -1;
|
||||
private boolean ourLookupShown = false;
|
||||
@@ -89,7 +89,7 @@ public class TemplateState implements Disposable {
|
||||
|
||||
private CommandAdapter myCommandListener;
|
||||
|
||||
private List<TemplateEditingListener> myListeners = new ArrayList<TemplateEditingListener>();
|
||||
private final List<TemplateEditingListener> myListeners = new ArrayList<TemplateEditingListener>();
|
||||
private DocumentAdapter myEditorDocumentListener;
|
||||
private final Map myProperties = new HashMap();
|
||||
private boolean myTemplateIndented = false;
|
||||
@@ -245,15 +245,14 @@ public class TemplateState implements Disposable {
|
||||
myPrevTemplate = myTemplate;
|
||||
myTemplate = null;
|
||||
releaseEditor();
|
||||
myTabStopHighlighters.clear();
|
||||
}
|
||||
|
||||
private void releaseEditor() {
|
||||
if (myEditor != null) {
|
||||
for (RangeHighlighter segmentHighlighter : myTabStopHighlighters) {
|
||||
myEditor.getMarkupModel().removeHighlighter(segmentHighlighter);
|
||||
segmentHighlighter.dispose();
|
||||
}
|
||||
|
||||
myTabStopHighlighters.clear();
|
||||
myEditor = null;
|
||||
}
|
||||
}
|
||||
@@ -963,7 +962,7 @@ public class TemplateState implements Disposable {
|
||||
final int segmentNumber = getCurrentSegmentNumber();
|
||||
RangeHighlighter newSegmentHighlighter = getSegmentHighlighter(segmentNumber, toSelect, false);
|
||||
if (newSegmentHighlighter != null) {
|
||||
myEditor.getMarkupModel().removeHighlighter(segmentHighlighter);
|
||||
segmentHighlighter.dispose();
|
||||
myTabStopHighlighters.set(myCurrentVariableNumber, newSegmentHighlighter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class ScopeHighlighter {
|
||||
|
||||
public void dropHighlight() {
|
||||
for (RangeHighlighter h : myActiveHighliters) {
|
||||
myEditor.getMarkupModel().removeHighlighter(h);
|
||||
h.dispose();
|
||||
}
|
||||
myActiveHighliters.clear();
|
||||
}
|
||||
|
||||
@@ -1078,7 +1078,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
RangeHighlighter[] allHighlighters = myEditor.getMarkupModel().getAllHighlighters();
|
||||
for (RangeHighlighter highlighter : allHighlighters) {
|
||||
if (highlighter.getStartOffset() >= token.startOffset) {
|
||||
myEditor.getMarkupModel().removeHighlighter(highlighter);
|
||||
highlighter.dispose();
|
||||
}
|
||||
}
|
||||
HighlighterIterator iterator = ((EditorEx)editor).getHighlighter().createIterator(0);
|
||||
@@ -1163,7 +1163,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
//refresh highlighter text attributes
|
||||
RangeHighlighter dummy =
|
||||
markupModel.addRangeHighlighter(0, 0, HYPERLINK_LAYER, getHyperlinkAttributes(), HighlighterTargetArea.EXACT_RANGE);
|
||||
markupModel.removeHighlighter(dummy);
|
||||
dummy.dispose();
|
||||
}
|
||||
|
||||
public HyperlinkInfo getHyperlinkInfoByPoint(final Point p) {
|
||||
|
||||
@@ -629,7 +629,7 @@ public class FindUtil {
|
||||
|
||||
private void removeAll() {
|
||||
myEditor.getCaretModel().removeCaretListener(this);
|
||||
myEditor.getMarkupModel().removeHighlighter(mySegmentHighlighter);
|
||||
mySegmentHighlighter.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ public class Bookmark {
|
||||
|
||||
public void release() {
|
||||
if (myHighlighter != null) {
|
||||
getDocument().getMarkupModel(myProject).removeHighlighter(myHighlighter);
|
||||
myHighlighter.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -870,7 +870,7 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider {
|
||||
|
||||
public void clearSelection() {
|
||||
if (myHighlighter != null && Arrays.asList(myEditor.getMarkupModel().getAllHighlighters()).contains(myHighlighter)) {
|
||||
myEditor.getMarkupModel().removeHighlighter(myHighlighter);
|
||||
myHighlighter.dispose();
|
||||
myHighlighter = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class RangeBlinker {
|
||||
|
||||
for (RangeHighlighter highlighter : myAddedHighlighters) {
|
||||
if (ArrayUtil.indexOf(allHighlighters, highlighter) != -1) {
|
||||
markupModel.removeHighlighter(highlighter);
|
||||
highlighter.dispose();
|
||||
}
|
||||
}
|
||||
myAddedHighlighters.clear();
|
||||
|
||||
@@ -691,9 +691,7 @@ public class HintManagerImpl extends HintManager implements Disposable {
|
||||
|
||||
hint.addHintListener(new HintListener() {
|
||||
public void hintHidden(EventObject event) {
|
||||
if (!editor.isDisposed()) {
|
||||
editor.getMarkupModel().removeHighlighter(highlighter);
|
||||
}
|
||||
highlighter.dispose();
|
||||
|
||||
if (myQuestionHint == hint) {
|
||||
myQuestionAction = null;
|
||||
|
||||
@@ -138,7 +138,7 @@ public class SelectInEditorManagerImpl extends SelectInEditorManager implements
|
||||
|
||||
private void releaseAll() {
|
||||
if (mySegmentHighlighter != null && myEditor != null){
|
||||
myEditor.getMarkupModel().removeHighlighter(mySegmentHighlighter);
|
||||
mySegmentHighlighter.dispose();
|
||||
myEditor.getContentComponent().removeFocusListener(this);
|
||||
myEditor.getCaretModel().removeCaretListener(this);
|
||||
mySegmentHighlighter = null;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class CurrentLineMarker implements CaretListener {
|
||||
void hide() {
|
||||
if (myHighlighter != null) {
|
||||
LOG.assertTrue(myEditor != null);
|
||||
myEditor.getMarkupModel().removeHighlighter(myHighlighter);
|
||||
myHighlighter.dispose();
|
||||
myHighlighter = null;
|
||||
}
|
||||
}
|
||||
@@ -64,4 +64,4 @@ public class CurrentLineMarker implements CaretListener {
|
||||
if (isHiden()) return;
|
||||
set();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -119,7 +119,7 @@ public abstract class DiffMarkup implements EditorSource {
|
||||
}
|
||||
|
||||
private void removeHighlighter(RangeHighlighter highlighter) {
|
||||
getMarkupModel().removeHighlighter(highlighter);
|
||||
highlighter.dispose();
|
||||
myHighLighters.remove(highlighter);
|
||||
myActionHighlighters.remove(highlighter);
|
||||
}
|
||||
@@ -171,7 +171,7 @@ public abstract class DiffMarkup implements EditorSource {
|
||||
MarkupModel markupModel = getMarkupModel();
|
||||
if (markupModel != null) {
|
||||
for (RangeHighlighter highlighter : highlighters) {
|
||||
markupModel.removeHighlighter(highlighter);
|
||||
highlighter.dispose();
|
||||
}
|
||||
}
|
||||
highlighters.clear();
|
||||
|
||||
+5
-9
@@ -31,12 +31,11 @@ import com.intellij.openapi.editor.markup.MarkupModel;
|
||||
import com.intellij.openapi.editor.markup.RangeHighlighter;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
|
||||
public abstract class Change {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.diff.impl.incrementalMerge.Change");
|
||||
@@ -193,20 +192,17 @@ public abstract class Change {
|
||||
LOG.assertTrue(myMainHighlighter == null);
|
||||
return;
|
||||
}
|
||||
MarkupModel markupModel = myEditor.getMarkupModel();
|
||||
for (Iterator<RangeHighlighter> iterator = myHighlighters.iterator(); iterator.hasNext();) {
|
||||
RangeHighlighter highlighter = iterator.next();
|
||||
markupModel.removeHighlighter(highlighter);
|
||||
iterator.remove();
|
||||
for (RangeHighlighter highlighter : myHighlighters) {
|
||||
highlighter.dispose();
|
||||
}
|
||||
myHighlighters.clear();
|
||||
removeActionHighlighters();
|
||||
myMainHighlighter = null;
|
||||
}
|
||||
|
||||
private void removeActionHighlighters() {
|
||||
MarkupModel markupModel = myEditor.getMarkupModel();
|
||||
for (RangeHighlighter actionHighlighter : myActionHighlighters) {
|
||||
markupModel.removeHighlighter(actionHighlighter);
|
||||
actionHighlighter.dispose();
|
||||
}
|
||||
myActionHighlighters = RangeHighlighter.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx {
|
||||
private boolean myIsReadOnly = false;
|
||||
private boolean isStripTrailingSpacesEnabled = true;
|
||||
private volatile long myModificationStamp;
|
||||
private final ConcurrentMap<Project, MarkupModel> myProjectToMarkupModelMap = new ConcurrentHashMap<Project, MarkupModel>();
|
||||
private final ConcurrentMap<Project, MarkupModelImpl> myProjectToMarkupModelMap = new ConcurrentHashMap<Project, MarkupModelImpl>();
|
||||
private final PropertyChangeSupport myPropertyChangeSupport = new PropertyChangeSupport(this);
|
||||
|
||||
private volatile MarkupModelEx myMarkupModel;
|
||||
@@ -630,13 +630,6 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx {
|
||||
myReadOnlyListeners.remove(listener);
|
||||
}
|
||||
|
||||
public void removeMarkupModel(Project project) {
|
||||
MarkupModel model = myProjectToMarkupModelMap.remove(project);
|
||||
if (model != null) {
|
||||
((MarkupModelEx)model).dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public MarkupModel getMarkupModel(Project project) {
|
||||
return getMarkupModel(project, true);
|
||||
@@ -651,7 +644,7 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx {
|
||||
}
|
||||
|
||||
private final Object lock = new Object();
|
||||
public MarkupModel getMarkupModel(@Nullable Project project, boolean create) {
|
||||
public MarkupModel getMarkupModel(@Nullable final Project project, boolean create) {
|
||||
if (project == null) {
|
||||
MarkupModelEx markupModel = myMarkupModel;
|
||||
if (create && markupModel == null) {
|
||||
@@ -665,19 +658,26 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx {
|
||||
return markupModel;
|
||||
}
|
||||
|
||||
final DocumentMarkupModelManager documentMarkupModelManager = project.isDisposed() ? null : DocumentMarkupModelManager.getInstance(project);
|
||||
if (documentMarkupModelManager == null || documentMarkupModelManager.isDisposed()) {
|
||||
if (project.isDisposed()) {
|
||||
return new EmptyMarkupModel(this);
|
||||
}
|
||||
|
||||
MarkupModel model = myProjectToMarkupModelMap.get(project);
|
||||
MarkupModelImpl model = myProjectToMarkupModelMap.get(project);
|
||||
if (create && model == null) {
|
||||
synchronized (lock) {
|
||||
model = myProjectToMarkupModelMap.get(project);
|
||||
if (model == null) {
|
||||
model = new MarkupModelImpl(this);
|
||||
myProjectToMarkupModelMap.put(project, model);
|
||||
documentMarkupModelManager.registerDocument(this);
|
||||
Disposer.register(project, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
MarkupModelImpl removed = myProjectToMarkupModelMap.remove(project);
|
||||
if (removed != null) {
|
||||
removed.dispose();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -763,13 +763,14 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx {
|
||||
}
|
||||
|
||||
public void normalizeRangeMarkers() {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
myRangeMarkers.normalize();
|
||||
|
||||
MarkupModel model = getMarkupModel(null, false);
|
||||
if (model != null) ((MarkupModelImpl)model).normalize();
|
||||
|
||||
for (MarkupModel markupModel : myProjectToMarkupModelMap.values()) {
|
||||
((MarkupModelImpl)markupModel).normalize();
|
||||
for (MarkupModelImpl markupModel : myProjectToMarkupModelMap.values()) {
|
||||
markupModel.normalize();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-80
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.editor.impl;
|
||||
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.containers.WeakHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class DocumentMarkupModelManager implements ProjectComponent {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.impl.DocumentMarkupModelManager");
|
||||
|
||||
private final WeakHashMap<DocumentImpl,String> myDocumentSet = new WeakHashMap<DocumentImpl, String>();
|
||||
private final Project myProject;
|
||||
private boolean myIsDisposed = false;
|
||||
|
||||
public static DocumentMarkupModelManager getInstance(Project project) {
|
||||
return project.getComponent(DocumentMarkupModelManager.class);
|
||||
}
|
||||
|
||||
public DocumentMarkupModelManager(Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
public void projectOpened() {
|
||||
}
|
||||
|
||||
public void projectClosed() {
|
||||
cleanup();
|
||||
}
|
||||
|
||||
public void registerDocument(DocumentImpl doc) {
|
||||
LOG.assertTrue(!myIsDisposed);
|
||||
myDocumentSet.put(doc, "");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "DocumentMarkupModelManager";
|
||||
}
|
||||
|
||||
public boolean isDisposed() {
|
||||
return myIsDisposed;
|
||||
}
|
||||
|
||||
public void initComponent() { }
|
||||
|
||||
public void disposeComponent() {
|
||||
cleanup();
|
||||
}
|
||||
|
||||
private void cleanup() {
|
||||
if (!myIsDisposed) {
|
||||
myIsDisposed = true;
|
||||
Set<DocumentImpl> docs = myDocumentSet.keySet();
|
||||
for (DocumentImpl doc : docs) {
|
||||
doc.removeMarkupModel(myProject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,7 @@ class RangeHighlighterImpl extends RangeMarkerImpl implements RangeHighlighterEx
|
||||
|
||||
@Override
|
||||
protected boolean unregisterInDocument() {
|
||||
if (myNode == null) return false;
|
||||
// we store highlighters in MarkupModel
|
||||
getData().unregisterMe();
|
||||
myNode = null;
|
||||
|
||||
@@ -19,10 +19,6 @@
|
||||
<!--<component>-->
|
||||
<!--<implementation-class>com.intellij.jsp.impl.browserprofile.BrowserProfileProvider</implementation-class>-->
|
||||
<!--</component>-->
|
||||
<component>
|
||||
<interface-class>com.intellij.openapi.editor.impl.DocumentMarkupModelManager</interface-class>
|
||||
<implementation-class>com.intellij.openapi.editor.impl.DocumentMarkupModelManager</implementation-class>
|
||||
</component>
|
||||
<component>
|
||||
<implementation-class>com.intellij.openapi.fileEditor.impl.EditorHistoryManager</implementation-class>
|
||||
<option name="workspace" value="true"/>
|
||||
@@ -36,4 +32,4 @@
|
||||
</component>
|
||||
|
||||
</project-components>
|
||||
</components>
|
||||
</components>
|
||||
|
||||
@@ -96,7 +96,7 @@ public class UsagePreviewPanel extends JPanel implements Disposable {
|
||||
MarkupModel markupModel = myEditor.getMarkupModel();
|
||||
for (RangeHighlighter highlighter : markupModel.getAllHighlighters()) {
|
||||
if (highlighter.getUserData(IN_PREVIEW_USAGE_FLAG) != null) {
|
||||
markupModel.removeHighlighter(highlighter);
|
||||
highlighter.dispose();
|
||||
}
|
||||
}
|
||||
for (int i = infos.size()-1; i>=0; i--) { // finish with the first usage so that caret end up there
|
||||
|
||||
@@ -176,10 +176,9 @@ public class LineStatusTracker {
|
||||
}
|
||||
|
||||
private void removeHighlightersFromMarkupModel() {
|
||||
final MarkupModel markupModel = myDocument.getMarkupModel(myProject);
|
||||
synchronized (myLock) {
|
||||
for (Range range : myRanges) {
|
||||
markupModel.removeHighlighter(range.getHighlighter());
|
||||
range.getHighlighter().dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -327,8 +326,6 @@ public class LineStatusTracker {
|
||||
}
|
||||
|
||||
private List<Range> mergeRanges(List<Range> ranges) {
|
||||
final MarkupModel markupModel = myDocument.getMarkupModel(myProject);
|
||||
|
||||
ArrayList<Range> result = new ArrayList<Range>();
|
||||
Iterator<Range> iterator = ranges.iterator();
|
||||
if (!iterator.hasNext()) return result;
|
||||
@@ -336,8 +333,8 @@ public class LineStatusTracker {
|
||||
while (iterator.hasNext()) {
|
||||
Range range = iterator.next();
|
||||
if (prev.canBeMergedWith(range)) {
|
||||
markupModel.removeHighlighter(range.getHighlighter());
|
||||
markupModel.removeHighlighter(prev.getHighlighter());
|
||||
range.getHighlighter().dispose();
|
||||
prev.getHighlighter().dispose();
|
||||
prev = prev.mergeWith(range, LineStatusTracker.this);
|
||||
}
|
||||
else {
|
||||
@@ -350,10 +347,8 @@ public class LineStatusTracker {
|
||||
}
|
||||
|
||||
private void replaceRanges(List<Range> rangesInChange, List<Range> newRangesInChange) {
|
||||
final MarkupModel markupModel = myDocument.getMarkupModel(myProject);
|
||||
|
||||
for (Range range : rangesInChange) {
|
||||
markupModel.removeHighlighter(range.getHighlighter());
|
||||
range.getHighlighter().dispose();
|
||||
range.setHighlighter(null);
|
||||
}
|
||||
for (Range range : newRangesInChange) {
|
||||
|
||||
+1
-1
@@ -200,7 +200,7 @@ public class XLineBreakpointImpl<P extends XBreakpointProperties> extends XBreak
|
||||
|
||||
private void removeHighlighter() {
|
||||
if (myHighlighter != null) {
|
||||
myHighlighter.getDocument().getMarkupModel(getProject()).removeHighlighter(myHighlighter);
|
||||
myHighlighter.dispose();
|
||||
myHighlighter = null;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -168,7 +168,7 @@ public abstract class AbstractValueHint {
|
||||
myCurrentHint = null;
|
||||
}
|
||||
if(myHighlighter != null) {
|
||||
myEditor.getMarkupModel().removeHighlighter(myHighlighter);
|
||||
myHighlighter.dispose();
|
||||
myHighlighter = null;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -118,7 +118,7 @@ public class ExecutionPointHighlighter {
|
||||
}
|
||||
if (myRangeHighlighter == null || myEditor == null) return;
|
||||
|
||||
myEditor.getMarkupModel().removeHighlighter(myRangeHighlighter);
|
||||
myRangeHighlighter.dispose();
|
||||
myRangeHighlighter = null;
|
||||
}
|
||||
|
||||
|
||||
+1
-5
@@ -73,15 +73,11 @@ public class TestDataHighlightingPass extends TextEditorHighlightingPass {
|
||||
|
||||
private void removeHighlighters() {
|
||||
final MarkupModel model = myDocument.getMarkupModel(myProject);
|
||||
ArrayList<RangeHighlighter> toRemove = new ArrayList<RangeHighlighter>();
|
||||
for (RangeHighlighter highlighter : model.getAllHighlighters()) {
|
||||
if (highlighter.getUserData(KEY) == VALUE) {
|
||||
toRemove.add(highlighter);
|
||||
highlighter.dispose();
|
||||
}
|
||||
}
|
||||
for (RangeHighlighter highlighter : toRemove) {
|
||||
model.removeHighlighter(highlighter);
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyGutterIconRenderer extends GutterIconRenderer {
|
||||
|
||||
+2
-2
@@ -129,7 +129,7 @@ public abstract class BaseIntroduceAction<Settings extends RefactoringOptions> e
|
||||
protected void run() throws Throwable {
|
||||
if (extractImpl(expression, matchingExpressions, otherMatches, dlg)) {
|
||||
for (RangeHighlighter highlighter : highlighters) {
|
||||
editor.getMarkupModel().removeHighlighter(highlighter);
|
||||
highlighter.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,4 +138,4 @@ public abstract class BaseIntroduceAction<Settings extends RefactoringOptions> e
|
||||
extractImpl(expression, matchingExpressions, otherMatches, dlg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ public class XPathEvalAction extends XPathAction {
|
||||
|
||||
input = inputXPathExpression(project, contextNode);
|
||||
if (contextHighlighter != null) {
|
||||
editor.getMarkupModel().removeHighlighter(contextHighlighter);
|
||||
contextHighlighter.dispose();
|
||||
}
|
||||
if (input == null) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user