diff options
author | Dawid Pakuła | 2014-04-18 13:21:00 +0000 |
---|---|---|
committer | Nick Sandonato | 2014-04-24 02:57:44 +0000 |
commit | 2f0f662df276264f8e3119843b283099e40e28ef (patch) | |
tree | 90edcd495cf460143d2ba25725951fe30189543a | |
parent | 4478ecc9956eb5672c08d83e3cb5f94be9c15596 (diff) | |
download | webtools.sourceediting-2f0f662df276264f8e3119843b283099e40e28ef.tar.gz webtools.sourceediting-2f0f662df276264f8e3119843b283099e40e28ef.tar.xz webtools.sourceediting-2f0f662df276264f8e3119843b283099e40e28ef.zip |
[430312] If two highlighters always report same Position they are interchangeably usedv201404240319
Signed-off-by: Dawid Pakuła <zulus@w3des.net>
2 files changed, 13 insertions, 18 deletions
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/style/SemanticHighlightingManager.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/style/SemanticHighlightingManager.java index c1f811f4f7..6131843e5e 100644 --- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/style/SemanticHighlightingManager.java +++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/style/SemanticHighlightingManager.java @@ -371,19 +371,8 @@ public class SemanticHighlightingManager implements IPropertyChangeListener { Logger.logException(e); } if (highlighting != null) { - int length = semantics.size(); - int insertPosition = 0; - if (after != null) { - for (int k = 0; k < length - 1; k++) { - SemanticContent sc = (SemanticContent) semantics.get(k); - if (after.equals(sc.id)) { - insertPosition = k + 1; - break; - } - } - } // The highlighting was not inserted through priority; insert at the beginning of the list - semantics.add(insertPosition, new SemanticContent(targetContentType, highlighting, styleKey, id)); + semantics.add(new SemanticContent(targetContentType, highlighting, styleKey, id, after)); } break; @@ -414,18 +403,24 @@ public class SemanticHighlightingManager implements IPropertyChangeListener { public ISemanticHighlighting highlighting; public String styleKey; public String id; - public SemanticContent(IContentType type, ISemanticHighlighting highlighting, String styleKey, String id) { + public String after; + public SemanticContent(IContentType type, ISemanticHighlighting highlighting, String styleKey, String id, String after) { this.type = type; this.highlighting = highlighting; this.styleKey = styleKey; this.id = id; + this.after = after; } public int compareTo(Object arg0) { SemanticContent other = (SemanticContent) arg0; /* Equal weighting for the same types */ - if (this.type.equals(other.type)) + if (this.type.equals(other.type)) { + if (this.after != null && other.id != null && other.id.equals(this.after)) { + return 1; + } return 0; + } /* Subtypes have more weight than base types */ if (this.type.isKindOf(other.type)) return 1; diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/style/SemanticHighlightingPresenter.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/style/SemanticHighlightingPresenter.java index 79b29bd3e3..18e4e88618 100644 --- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/style/SemanticHighlightingPresenter.java +++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/style/SemanticHighlightingPresenter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2011 IBM Corporation and others. + * Copyright (c) 2009, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -98,15 +98,15 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener, int length= position.getLength(); int end= offset + length; - if (offset > eventEnd) + if (offset > eventEnd) { updateWithPrecedingEvent(position, event); - else if (end < eventOffset) { + } else if (end < eventOffset) { // do nothing // updateWithSucceedingEvent(position, event); } else if (offset <= eventOffset && end >= eventEnd) { // Previous region updated to overlap the beginning of this one; just bump the start. - if (i > 0 && positions[i - 1].offset + positions[i - 1].length > offset) + if (i > 0 && positions[i - 1].offset + positions[i - 1].length > offset + length && positions[i - 1].offset != offset) updateWithPrecedingEvent(position, event); else updateWithIncludedEvent(position, event); |