### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/core/compiler/CharOperation.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/CharOperation.java,v retrieving revision 1.88 diff -u -r1.88 CharOperation.java --- compiler/org/eclipse/jdt/core/compiler/CharOperation.java 9 Aug 2010 09:43:40 -0000 1.88 +++ compiler/org/eclipse/jdt/core/compiler/CharOperation.java 9 Nov 2010 16:17:00 -0000 @@ -2962,6 +2962,63 @@ } /** + * Answers true if the given name, starting from the given index, starts with the given prefix, + * false otherwise. isCaseSensitive is used to find out whether or not the comparison should be + * case sensitive. + *
+ *
+ * For example: + *
    + *
  1. + *    prefix = { 'a' , 'B' }
    + *    name = { 'c', 'd', 'a' , 'b', 'b', 'a', 'b', 'a' }
    + *    startIndex = 2
    + *    isCaseSensitive = false
    + *    result => true
    + * 
    + *
  2. + *
  3. + *    prefix = { 'a' , 'B' }
    + *    name = { 'c', 'd', 'a' , 'b', 'b', 'a', 'b', 'a' }
    + *    startIndex = 2
    + *    isCaseSensitive = true
    + *    result => false
    + * 
    + *
  4. + *
+ * + * @param prefix the given prefix + * @param name the given name + * @param isCaseSensitive to find out whether or not the comparison should be case sensitive + * @param startIndex index from which the prefix should be searched in the name + * @return true if the given name starts with the given prefix, false otherwise + * @throws NullPointerException if the given name is null or if the given prefix is null + * @since 3.7 + */ +public static final boolean prefixEquals( + char[] prefix, + char[] name, + boolean isCaseSensitive, + int startIndex) { + + int max = prefix.length; + if (name.length - startIndex < max) + return false; + if (isCaseSensitive) { + for (int i = max; --i >= 0;) // assumes the prefix is not larger than the name + if (prefix[i] != name[startIndex + i]) + return false; + return true; + } + + for (int i = max; --i >= 0;) // assumes the prefix is not larger than the name + if (ScannerHelper.toLowerCase(prefix[i]) + != ScannerHelper.toLowerCase(name[startIndex + i])) + return false; + return true; +} + +/** * Answers a new array removing a given character. Answers the given array if there is * no occurrence of the character to remove. *
Index: model/org/eclipse/jdt/internal/core/JavadocContents.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavadocContents.java,v retrieving revision 1.3 diff -u -r1.3 JavadocContents.java --- model/org/eclipse/jdt/internal/core/JavadocContents.java 9 Aug 2010 09:43:40 -0000 1.3 +++ model/org/eclipse/jdt/internal/core/JavadocContents.java 9 Nov 2010 16:17:00 -0000 @@ -145,7 +145,7 @@ for (int i = 0; i < this.tempAnchorIndexesCount; i++) { int anchorEndStart = this.tempAnchorIndexes[i]; - if (anchorEndStart != -1 && CharOperation.indexOf(anchor, this.content, false, anchorEndStart) == anchorEndStart) { + if (anchorEndStart != -1 && CharOperation.prefixEquals(anchor, this.content, false, anchorEndStart)) { this.tempAnchorIndexes[i] = -1; @@ -165,7 +165,7 @@ this.tempLastAnchorFoundIndex = anchorEndStart; - if (CharOperation.indexOf(anchor, this.content, false, anchorEndStart) == anchorEndStart) { + if (CharOperation.prefixEquals(anchor, this.content, false, anchorEndStart)) { return computeChildRange(anchorEndStart, anchor, indexOfSectionBottom); } else { if (this.tempAnchorIndexes.length == this.tempAnchorIndexesCount) {