Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2013-09-05 23:19:02 +0000
committerChristian W. Damus2013-09-06 18:39:01 +0000
commit769d79b9046d310471852cea0acf1a2c31d9376c (patch)
treec328147665883bdb98bb72e47b75b8f5aa6d3ee8 /plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org
parentb753888ec881037b4778a42e4f92808aa82ac9d1 (diff)
downloadorg.eclipse.papyrus-769d79b9046d310471852cea0acf1a2c31d9376c.tar.gz
org.eclipse.papyrus-769d79b9046d310471852cea0acf1a2c31d9376c.tar.xz
org.eclipse.papyrus-769d79b9046d310471852cea0acf1a2c31d9376c.zip
415371: Fix erroneous uses of Match::getLength() as an end index
https://bugs.eclipse.org/bugs/show_bug.cgi?id=415371
Diffstat (limited to 'plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org')
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java14
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/results/PapyrusSearchResult.java3
2 files changed, 11 insertions, 6 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java
index 83cac65d9fd..d133e3adf43 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java
@@ -45,7 +45,7 @@ public class AttributeMatchLabelProvider implements IFilteredLabelProvider {
}
private String printResult(String sectionThatMatch, String value, int offset, int lenght, String attributeName) {
- return "\"" + sectionThatMatch + "\"" + Messages.AttributeMatchLabelProvider_3 + "\"" + value + "\" [" + offset + "," + lenght + "] (" + attributeName + Messages.AttributeMatchLabelProvider_8 + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
+ return "\"" + sectionThatMatch + "\"" + Messages.AttributeMatchLabelProvider_3 + "\"" + value + "\" [" + offset + "," + (offset + lenght) + "] (" + attributeName + Messages.AttributeMatchLabelProvider_8 + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
}
public String getText(Object element) {
@@ -58,11 +58,13 @@ public class AttributeMatchLabelProvider implements IFilteredLabelProvider {
EAttribute source = (EAttribute)attributeMatch.getMetaAttribute();
if(target.eGet(source) instanceof String) {
String value = (String)target.eGet(source);
- return printResult(value.substring(attributeMatch.getOffset(), attributeMatch.getLength()), value, attributeMatch.getOffset(), attributeMatch.getLength(), source.getName());
+ int end = attributeMatch.getOffset() + attributeMatch.getLength();
+ return printResult(value.substring(attributeMatch.getOffset(), end), value, attributeMatch.getOffset(), attributeMatch.getLength(), source.getName());
} else {
String value = String.valueOf(target.eGet(source));
- return printResult(value.substring(attributeMatch.getOffset(), attributeMatch.getLength()), value, attributeMatch.getOffset(), attributeMatch.getLength(), source.getName());
+ int end = attributeMatch.getOffset() + attributeMatch.getLength();
+ return printResult(value.substring(attributeMatch.getOffset(), end), value, attributeMatch.getOffset(), attributeMatch.getLength(), source.getName());
}
} else if(attributeMatch.getMetaAttribute() instanceof Property) {
@@ -75,10 +77,12 @@ public class AttributeMatchLabelProvider implements IFilteredLabelProvider {
if(tagValue instanceof String) {
String value = (String)tagValue;
- return printResult(value.substring(attributeMatch.getOffset(), attributeMatch.getLength()), value, attributeMatch.getOffset(), attributeMatch.getLength(), source.getName());
+ int end = attributeMatch.getOffset() + attributeMatch.getLength();
+ return printResult(value.substring(attributeMatch.getOffset(), end), value, attributeMatch.getOffset(), attributeMatch.getLength(), source.getName());
} else {
String value = String.valueOf(tagValue);
- return printResult(value.substring(attributeMatch.getOffset(), attributeMatch.getLength()), value, attributeMatch.getOffset(), attributeMatch.getLength(), source.getName());
+ int end = attributeMatch.getOffset() + attributeMatch.getLength();
+ return printResult(value.substring(attributeMatch.getOffset(), end), value, attributeMatch.getOffset(), attributeMatch.getLength(), source.getName());
}
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/results/PapyrusSearchResult.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/results/PapyrusSearchResult.java
index ab64b08cc8e..b64c82da64c 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/results/PapyrusSearchResult.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/results/PapyrusSearchResult.java
@@ -183,7 +183,8 @@ public class PapyrusSearchResult extends AbstractTextSearchResult implements IEd
}
if(value != null && !this.getQuery().isRegularExpression()) {
if(value.length() >= match.getOffset() + match.getLength()) {
- value = value.substring(match.getOffset(), match.getLength());
+ int end = match.getOffset() + match.getLength();
+ value = value.substring(match.getOffset(), end);
if(this.searchQuery.isCaseSensitive()) {
if(value.equals(this.searchQuery.getSearchQueryText())) {
((AbstractResultEntry)match).recursiveHierarchy((AbstractResultEntry)((AbstractResultEntry)match).getParent());

Back to the top