View | Details | Raw Unified | Return to bug 329288 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/JavadocContents.java (-3 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2009, 2010 IBM Corporation and others.
2
 * Copyright (c) 2009, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 145-151 Link Here
145
			for (int i = 0; i < this.tempAnchorIndexesCount; i++) {
145
			for (int i = 0; i < this.tempAnchorIndexesCount; i++) {
146
				int anchorEndStart = this.tempAnchorIndexes[i];
146
				int anchorEndStart = this.tempAnchorIndexes[i];
147
				
147
				
148
				if (anchorEndStart != -1 && CharOperation.indexOf(anchor, this.content, false, anchorEndStart) == anchorEndStart) {
148
				if (anchorEndStart != -1 && Util.prefixEquals(anchor, this.content, false, anchorEndStart)) {
149
					
149
					
150
					this.tempAnchorIndexes[i] = -1;
150
					this.tempAnchorIndexes[i] = -1;
151
					
151
					
Lines 165-171 Link Here
165
			
165
			
166
			this.tempLastAnchorFoundIndex = anchorEndStart;
166
			this.tempLastAnchorFoundIndex = anchorEndStart;
167
			
167
			
168
			if (CharOperation.indexOf(anchor, this.content, false, anchorEndStart) == anchorEndStart) {
168
			if (Util.prefixEquals(anchor, this.content, false, anchorEndStart)) {
169
				return computeChildRange(anchorEndStart, anchor, indexOfSectionBottom);
169
				return computeChildRange(anchorEndStart, anchor, indexOfSectionBottom);
170
			} else {
170
			} else {
171
				if (this.tempAnchorIndexes.length == this.tempAnchorIndexesCount) {
171
				if (this.tempAnchorIndexes.length == this.tempAnchorIndexesCount) {
(-)model/org/eclipse/jdt/internal/core/util/Util.java (-1 / +57 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 3621-3624 Link Here
3621
			}
3621
			}
3622
		}
3622
		}
3623
	}
3623
	}
3624
	
3625
	/**
3626
	 * Answers true if the given name, starting from the given index, starts with the given prefix,
3627
	 * false otherwise. isCaseSensitive is used to find out whether or not the comparison should be
3628
	 * case sensitive.
3629
	 * <br>
3630
	 * <br>
3631
	 * For example:
3632
	 * <ol>
3633
	 * <li><pre>
3634
	 *    prefix = { 'a' , 'B' }
3635
	 *    name = { 'c', 'd', 'a' , 'b', 'b', 'a', 'b', 'a' }
3636
	 *    startIndex = 2
3637
	 *    isCaseSensitive = false
3638
	 *    result => true
3639
	 * </pre>
3640
	 * </li>
3641
	 * <li><pre>
3642
	 *    prefix = { 'a' , 'B' }
3643
	 *    name = { 'c', 'd', 'a' , 'b', 'b', 'a', 'b', 'a' }
3644
	 *    startIndex = 2
3645
	 *    isCaseSensitive = true
3646
	 *    result => false
3647
	 * </pre>
3648
	 * </li>
3649
	 * </ol>
3650
	 *
3651
	 * @param prefix the given prefix
3652
	 * @param name the given name
3653
	 * @param isCaseSensitive to find out whether or not the comparison should be case sensitive
3654
	 * @param startIndex index from which the prefix should be searched in the name
3655
	 * @return true if the given name starts with the given prefix, false otherwise
3656
	 * @throws NullPointerException if the given name is null or if the given prefix is null
3657
	 */
3658
	public static final boolean prefixEquals(
3659
		char[] prefix,
3660
		char[] name,
3661
		boolean isCaseSensitive,
3662
		int startIndex) {
3663
3664
		int max = prefix.length;
3665
		if (name.length - startIndex < max)
3666
			return false;
3667
		if (isCaseSensitive) {
3668
			for (int i = max; --i >= 0;) // assumes the prefix is not larger than the name
3669
				if (prefix[i] != name[startIndex + i])
3670
					return false;
3671
			return true;
3672
		}
3673
3674
		for (int i = max; --i >= 0;) // assumes the prefix is not larger than the name
3675
			if (ScannerHelper.toLowerCase(prefix[i])
3676
				!= ScannerHelper.toLowerCase(name[startIndex + i]))
3677
				return false;
3678
		return true;
3679
	}
3624
}
3680
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/UtilTest.java (+15 lines)
Lines 15-20 Link Here
15
//import org.apache.tools.ant.types.selectors.SelectorUtils;
15
//import org.apache.tools.ant.types.selectors.SelectorUtils;
16
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.jdt.core.compiler.CharOperation;
17
import org.eclipse.jdt.core.compiler.CharOperation;
18
import org.eclipse.jdt.internal.core.util.Util;
18
19
19
//import junit.framework.AssertionFailedError;
20
//import junit.framework.AssertionFailedError;
20
import junit.framework.Test;
21
import junit.framework.Test;
Lines 738-743 Link Here
738
	// Verify that there were no unexpected results
739
	// Verify that there were no unexpected results
739
    assertTrue(this.camelCaseErrors.toString(), this.camelCaseErrors.length()==0);
740
    assertTrue(this.camelCaseErrors.toString(), this.camelCaseErrors.length()==0);
740
}
741
}
742
743
// test org.eclipse.jdt.internal.compiler.util.Util.prefixEquals(char[], char[], boolean, int)
744
public void test010() {
745
	char[] name = new char[] {  'a' , 'b', 'c', 'a', 'a' };
746
	char[] prefix = new char[] { 'c', 'a', 'a' };
747
	assertTrue(Util.prefixEquals(prefix, name, false, 2));
748
	prefix = new char[] { 'c', 'a', 'a', 'a' };
749
	assertFalse(Util.prefixEquals(prefix, name, false, 2));
750
	prefix = new char[] { 'c', 'a', 'A' };
751
	assertFalse(Util.prefixEquals(prefix, name, true, 2));
752
	prefix = new char[] { 'b', 'c' };
753
	assertFalse(Util.prefixEquals(prefix, name, false, 2));
754
	assertTrue(Util.prefixEquals(prefix, name, false, 1));
755
}
741
public static Class testClass() {
756
public static Class testClass() {
742
	return UtilTest.class;
757
	return UtilTest.class;
743
}
758
}

Return to bug 329288