[580832] task tags should only match on whole words
diff --git a/core/bundles/org.eclipse.wst.sse.core/META-INF/MANIFEST.MF b/core/bundles/org.eclipse.wst.sse.core/META-INF/MANIFEST.MF index 0e3eef8..6abc009 100644 --- a/core/bundles/org.eclipse.wst.sse.core/META-INF/MANIFEST.MF +++ b/core/bundles/org.eclipse.wst.sse.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.wst.sse.core; singleton:=true -Bundle-Version: 1.2.800.qualifier +Bundle-Version: 1.2.900.qualifier Bundle-Activator: org.eclipse.wst.sse.core.internal.SSECorePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin
diff --git a/core/bundles/org.eclipse.wst.sse.core/pom.xml b/core/bundles/org.eclipse.wst.sse.core/pom.xml index c66f064..1acee3c 100644 --- a/core/bundles/org.eclipse.wst.sse.core/pom.xml +++ b/core/bundles/org.eclipse.wst.sse.core/pom.xml
@@ -21,7 +21,7 @@ <groupId>org.eclipse.webtools.sourceediting</groupId> <artifactId>org.eclipse.wst.sse.core</artifactId> - <version>1.2.800-SNAPSHOT</version> + <version>1.2.900-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> <build>
diff --git a/core/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/StructuredFileTaskScanner.java b/core/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/StructuredFileTaskScanner.java index dccb6f4..f3928d2 100644 --- a/core/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/StructuredFileTaskScanner.java +++ b/core/bundles/org.eclipse.wst.sse.core/src-tasktags/org/eclipse/wst/sse/core/internal/tasks/StructuredFileTaskScanner.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2021 IBM Corporation and others. + * Copyright (c) 2001, 2022 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -148,17 +148,32 @@ int end = Math.min(endOffset, line.getOffset() + line.getLength()); int length = end - begin; - /* XXX: This generates a lot of garbage objects */ + /* XXX: This generates a lot of garbage strings */ String commentedText = getCommentedText(document, begin, length); - String comparisonText = commentedText.toLowerCase(Locale.ENGLISH); + String lowercaseText = commentedText.toLowerCase(Locale.ENGLISH); for (int i = 0; i < taskTags.length; i++) { - int tagIndex = comparisonText.indexOf(taskTags[i].getTag().toLowerCase(Locale.ENGLISH)); + int tagIndex = lowercaseText.indexOf(taskTags[i].getTag().toLowerCase(Locale.ENGLISH)); if (tagIndex >= 0) { + boolean isEndOfComment = tagIndex + taskTags[i].getTag().length() == lowercaseText.length(); + if (!isEndOfComment) { + char nextChar = lowercaseText.charAt(tagIndex + taskTags[i].getTag().length()); + boolean followedByWhitespaceOrColon = Character.isWhitespace(nextChar) || nextChar == ':'; + if (!followedByWhitespaceOrColon) { + continue; + } + boolean precededByWhitespaceOrNonLetter = tagIndex == 0 || Character.isWhitespace(lowercaseText.charAt(tagIndex - 1)) || !Character.isLetter(lowercaseText.charAt(tagIndex - 1)); + if (!precededByWhitespaceOrNonLetter) { + continue; + } + } String markerDescription = commentedText.substring(tagIndex); - if (markerDescription.length() > 500) { - markerDescription = markerDescription.substring(0,500); + if (markerDescription.trim().length() == taskTags[i].getTag().length()) { + continue; + } + if (markerDescription.length() > 120) { + markerDescription = markerDescription.substring(0,120); } int markerOffset = begin + tagIndex; int markerLength = end - markerOffset;
diff --git a/xml/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/tasks/XMLStreamingFileTaskScanner.java b/xml/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/tasks/XMLStreamingFileTaskScanner.java index 5a107f3..45e9450 100644 --- a/xml/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/tasks/XMLStreamingFileTaskScanner.java +++ b/xml/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/tasks/XMLStreamingFileTaskScanner.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2021 IBM Corporation and others. + * Copyright (c) 2001, 2022 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -125,15 +125,30 @@ String lowercaseText = lineComment.toLowerCase(Locale.ENGLISH); for (int i = 0; i < taskTags.length; i++) { - int tagIndex = lowercaseText.indexOf(searchTags[i]); + int tagIndex = lowercaseText.indexOf(taskTags[i].getTag().toLowerCase(Locale.ENGLISH)); if (tagIndex >= 0) { + boolean isEndOfComment = tagIndex + taskTags[i].getTag().length() == lowercaseText.length(); + if (!isEndOfComment) { + char nextChar = lowercaseText.charAt(tagIndex + taskTags[i].getTag().length()); + boolean followedByWhitespaceOrColon = Character.isWhitespace(nextChar) || nextChar == ':'; + if (!followedByWhitespaceOrColon) { + continue; + } + boolean precededByWhitespaceOrNonLetter = tagIndex == 0 || Character.isWhitespace(lowercaseText.charAt(tagIndex - 1)) || !Character.isLetter(lowercaseText.charAt(tagIndex - 1)); + if (!precededByWhitespaceOrNonLetter) { + continue; + } + } String markerDescription = lineComment.substring(tagIndex); - if (markerDescription.length() > 500) { - markerDescription = markerDescription.substring(0,500); + if (markerDescription.trim().length() == taskTags[i].getTag().length()) { + continue; + } + if (markerDescription.length() > 120) { + markerDescription = markerDescription.substring(0,120); } int markerOffset = getOffset() + line.getOffset() + tagIndex; int markerLength = line.getLength() - tagIndex; - fNewMarkerAttributeMaps.add(createInitialMarkerAttributes(markerDescription, lineNumber + getLine(), markerOffset, markerLength, taskTags[i].getPriority())); + fNewMarkerAttributeMaps.add(createInitialMarkerAttributes(markerDescription, lineNumber, markerOffset, markerLength, taskTags[i].getPriority())); } } }