Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Revert "MPS-11123 java.lang.AssertionError: Two EditorMessages with s…

…ame type are attached to the same EditorCell"

This reverts commit 76c7a5b.
  • Loading branch information...
commit 94af0c3d93e3b7c9d444da643496656371f2d44b 1 parent b6ff5a5
Alexander Shatalin ashatalin authored
69 core/languageDesign/editor/source/jetbrains/mps/nodeEditor/NodeHighlightManager.java
@@ -53,28 +53,21 @@ public int compare(EditorMessage m1, EditorMessage m2) {
53 53 * all Chaches are synchronized using myMessagesLock
54 54 */
55 55 private Map<EditorCell, List<EditorMessage>> myMessagesCache;
56   - private ReloadAdapter myHandler;
  56 + public ReloadAdapter myHandler;
57 57 private RebuildListener myRebuildListener;
58 58 private Set<EditorMessageIconRenderer> myIconRenderersCache = new HashSet<EditorMessageIconRenderer>();
59 59 private boolean myRebuildIconRenderersCacheFlag;
60   - private volatile boolean myDisposed = false;
61 60
62 61 public NodeHighlightManager(@NotNull EditorComponent edtitor) {
63 62 myEditor = edtitor;
64 63 myHandler = new ReloadAdapter() {
65 64 public void onReload() {
66   - if (myDisposed) {
67   - return;
68   - }
69 65 clear();
70 66 }
71 67 };
72 68
73 69 edtitor.addRebuildListener(myRebuildListener = new RebuildListener() {
74 70 public void editorRebuilt(EditorComponent editor) {
75   - if (myDisposed) {
76   - return;
77   - }
78 71 synchronized (myMessagesLock) {
79 72 if (myMessagesCache == null) {
80 73 return;
@@ -149,9 +142,6 @@ private void rebuildMessages(EditorCell root) {
149 142 }
150 143
151 144 public List<EditorMessage> getMessages(EditorCell cell) {
152   - if (myDisposed) {
153   - return Collections.<EditorMessage>emptyList();
154   - }
155 145 List<EditorMessage> result = getMessagesCache().get(cell);
156 146 if (result != null) {
157 147 return new ArrayList<EditorMessage>(result);
@@ -227,9 +217,6 @@ private boolean removeMessage(EditorMessage m) {
227 217 }
228 218
229 219 public void mark(EditorMessage message) {
230   - if (myDisposed) {
231   - return;
232   - }
233 220 for (EditorMessage msg : getMessages()) {
234 221 if (msg.sameAs(message)) return;
235 222 }
@@ -242,17 +229,11 @@ public void mark(EditorMessage message) {
242 229 }
243 230
244 231 public void unmarkSingleMessage(EditorMessage message) {
245   - if (myDisposed) {
246   - return;
247   - }
248 232 unmark(message);
249 233 repaintAndRebuildEditorMessages();
250 234 }
251 235
252 236 public void unmark(EditorMessage message) {
253   - if (myDisposed) {
254   - return;
255   - }
256 237 synchronized (myMessagesLock) {
257 238 if (removeMessage(message)) {
258 239 rebuildMessages();
@@ -275,16 +256,10 @@ private void clear() {
275 256 }
276 257
277 258 public boolean clearForOwner(EditorMessageOwner owner) {
278   - if (myDisposed) {
279   - return false;
280   - }
281 259 return clearForOwner(owner, true);
282 260 }
283 261
284 262 public boolean clearForOwner(EditorMessageOwner owner, boolean repaintAndRebuild) {
285   - if (myDisposed) {
286   - return false;
287   - }
288 263 boolean result = myEditor.getMessagesGutter().removeMessages(owner);
289 264 synchronized (myMessagesLock) {
290 265 if (myOwnerToMessages.containsKey(owner)) {
@@ -306,14 +281,8 @@ public boolean clearForOwner(EditorMessageOwner owner, boolean repaintAndRebuild
306 281 * and repaint associated EditorComponent
307 282 */
308 283 public void repaintAndRebuildEditorMessages() {
309   - if (myDisposed) {
310   - return;
311   - }
312 284 ModelAccess.instance().runReadInEDT(new Runnable() {
313 285 public void run() {
314   - if (myDisposed) {
315   - return;
316   - }
317 286 refreshLeftHighlighterMessages();
318 287 myEditor.getExternalComponent().repaint();
319 288 }
@@ -342,17 +311,11 @@ private void refreshLeftHighlighterMessages() {
342 311 }
343 312
344 313 public void mark(SNode node, Color color, String messageText, EditorMessageOwner owner) {
345   - if (myDisposed) {
346   - return;
347   - }
348 314 if (node == null) return;
349 315 mark(new DefaultEditorMessage(node, color, messageText, owner));
350 316 }
351 317
352 318 public void mark(List<EditorMessage> messages) {
353   - if (myDisposed) {
354   - return;
355   - }
356 319 for (int i = 0; i < messages.size(); i++) {
357 320 mark(messages.get(i));
358 321 }
@@ -360,18 +323,12 @@ public void mark(List<EditorMessage> messages) {
360 323 }
361 324
362 325 public void markSingleMessage(EditorMessage message) {
363   - if (myDisposed) {
364   - return;
365   - }
366 326 mark(message);
367 327 repaintAndRebuildEditorMessages();
368 328 }
369 329
370 330 public Set<EditorMessage> getMessages() {
371 331 Set<EditorMessage> result = new HashSet<EditorMessage>();
372   - if (myDisposed) {
373   - return result;
374   - }
375 332 synchronized (myMessagesLock) {
376 333 result.addAll(myMessages);
377 334 }
@@ -381,9 +338,6 @@ public void markSingleMessage(EditorMessage message) {
381 338 // not used anymore?
382 339 @Deprecated
383 340 public Color getColorFor(SNode node) {
384   - if (myDisposed) {
385   - return null;
386   - }
387 341 synchronized (myMessagesLock) {
388 342 for (EditorMessage msg : myMessages) {
389 343 if (msg.getNode() == node) return msg.getColor();
@@ -393,9 +347,6 @@ public Color getColorFor(SNode node) {
393 347 }
394 348
395 349 public EditorMessage getMessageFor(SNode node) {
396   - if (myDisposed) {
397   - return null;
398   - }
399 350 synchronized (myMessagesLock) {
400 351 for (EditorMessage msg : myMessages) {
401 352 if (msg.getNode() == node) return msg;
@@ -406,9 +357,6 @@ public EditorMessage getMessageFor(SNode node) {
406 357
407 358 public List<EditorMessage> getMessagesFor(SNode node) {
408 359 List<EditorMessage> result = new ArrayList<EditorMessage>();
409   - if (myDisposed) {
410   - return null;
411   - }
412 360 synchronized (myMessagesLock) {
413 361 result.addAll(myMessagesToNodes.getBySecond(node));
414 362 }
@@ -417,9 +365,6 @@ public EditorMessage getMessageFor(SNode node) {
417 365
418 366 public List<EditorMessage> getMessagesFor(SNode node, EditorMessageOwner owner) {
419 367 List<EditorMessage> result = new ArrayList<EditorMessage>();
420   - if (myDisposed) {
421   - return result;
422   - }
423 368 synchronized (myMessagesLock) {
424 369 for (EditorMessage message : myMessagesToNodes.getBySecond(node)) {
425 370 if (message.getOwner() == owner) {
@@ -431,21 +376,11 @@ public EditorMessage getMessageFor(SNode node) {
431 376 }
432 377
433 378 public void dispose() {
434   - assert ModelAccess.instance().isInEDT() : "dispose() should be called from EDT only";
435   - myDisposed = true;
436 379 ClassLoaderManager.getInstance().removeReloadHandler(myHandler);
437 380 myEditor.removeRebuildListener(myRebuildListener);
438   - Set<EditorMessageIconRenderer> iconRenderers;
439   - synchronized (myMessagesLock) {
440   - iconRenderers = myIconRenderersCache;
441   - }
442   - myEditor.getLeftEditorHighlighter().removeAllIconRenderers(iconRenderers);
443 381 }
444 382
445 383 public EditorCell getCell(EditorMessage change) {
446   - if (myDisposed) {
447   - return null;
448   - }
449 384 for (Entry<EditorCell, List<EditorMessage>> e: getMessagesCache().entrySet()) {
450 385 if (e.getValue().contains(change)) {
451 386 return e.getKey();
@@ -454,4 +389,4 @@ public EditorCell getCell(EditorMessage change) {
454 389 return null;
455 390 }
456 391
457   -}
  392 +}

0 comments on commit 94af0c3

Please sign in to comment.
Something went wrong with that request. Please try again.