View | Details | Raw Unified | Return to bug 266837
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java (+21 lines)
Lines 10622-10625 Link Here
10622
	}
10622
	}
10623
}
10623
}
10624
10624
10625
/**
10626
 * @bug 266837: SourceField.getConstant does not supply a value if type is fully qualified
10627
 * @test Ensure that source field constant is not null when fully qualified type String is used
10628
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=266837"
10629
 */
10630
public void testBug266837() throws Exception {
10631
	this.workingCopies = new ICompilationUnit[1];
10632
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java",
10633
		"public class Test {\n" + 
10634
		"	private static final java.lang.String f266837 = \"myString\";\n" + 
10635
		"}\n"
10636
	);
10637
	SearchRequestor requestor = new SearchRequestor() {
10638
		public void acceptSearchMatch(SearchMatch searchMatch) throws CoreException {
10639
	        IField sourceField = (IField) searchMatch.getElement();
10640
	        assertEquals("Unexpected source field constant!", "\"myString\"", sourceField.getConstant());
10641
        }
10642
	};
10643
	search("f266837", FIELD, DECLARATIONS, requestor);
10644
}
10645
10625
}
10646
}
(-)src/org/eclipse/jdt/core/tests/model/GetSourceTests.java (-1 / +13 lines)
Lines 85-91 Link Here
85
			"  static final char field4 = ' ';\n" +
85
			"  static final char field4 = ' ';\n" +
86
			"  static final double field5 = 938245798324893D;\n" +
86
			"  static final double field5 = 938245798324893D;\n" +
87
			"  static final float field6 = 123456f;\n" +
87
			"  static final float field6 = 123456f;\n" +
88
			"  static final int field7 = 1<<0;\n" +
88
			"  static final String field7 = \"simple string\";\n" +
89
			"  static final java.lang.String field8 = \"qualified string\";\n" +
90
			"  static final int field9 = 1<<0;\n" +
89
			"}";
91
			"}";
90
		createFile("/P/p/Constants.java", cuSource);
92
		createFile("/P/p/Constants.java", cuSource);
91
	}
93
	}
Lines 158-163 Link Here
158
160
159
	public void testFieldConstant07() throws CoreException {
161
	public void testFieldConstant07() throws CoreException {
160
		IField field = getConstantField("field7");
162
		IField field = getConstantField("field7");
163
		assertEquals("Wrong value", "\"simple string\"", field.getConstant());
164
	}
165
166
	public void testFieldConstant08() throws CoreException {
167
		IField field = getConstantField("field8");
168
		assertEquals("Wrong value", "\"qualified string\"", field.getConstant());
169
	}
170
171
	public void testFieldConstant09() throws CoreException {
172
		IField field = getConstantField("field9");
161
173
162
		Object constant = field.getConstant();
174
		Object constant = field.getConstant();
163
		assertNull("Should not be a constant", constant);
175
		assertNull("Should not be a constant", constant);
(-)src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java (+3 lines)
Lines 825-830 Link Here
825
	protected void search(String patternString, int searchFor, int limitTo, IJavaSearchScope scope) throws CoreException {
825
	protected void search(String patternString, int searchFor, int limitTo, IJavaSearchScope scope) throws CoreException {
826
		search(patternString, searchFor, limitTo, EXACT_RULE, scope, this.resultCollector);
826
		search(patternString, searchFor, limitTo, EXACT_RULE, scope, this.resultCollector);
827
	}
827
	}
828
	protected void search(String patternString, int searchFor, int limitTo, SearchRequestor requestor) throws CoreException {
829
		search(patternString, searchFor, limitTo, EXACT_RULE, getJavaSearchScope(), requestor);
830
	}
828
	protected void search(String patternString, int searchFor, int limitTo, int matchRule, IJavaSearchScope scope) throws CoreException {
831
	protected void search(String patternString, int searchFor, int limitTo, int matchRule, IJavaSearchScope scope) throws CoreException {
829
		search(patternString, searchFor, limitTo, matchRule, scope, this.resultCollector);
832
		search(patternString, searchFor, limitTo, matchRule, scope, this.resultCollector);
830
	}
833
	}
(-)model/org/eclipse/jdt/internal/core/SourceField.java (+2 lines)
Lines 85-90 Link Here
85
			}
85
			}
86
		} else if (signature.equals("QString;")) {//$NON-NLS-1$
86
		} else if (signature.equals("QString;")) {//$NON-NLS-1$
87
			constant = constantSource;
87
			constant = constantSource;
88
		} else if (signature.equals("Qjava.lang.String;")) {//$NON-NLS-1$
89
			constant = constantSource;
88
		}
90
		}
89
	} catch (NumberFormatException e) {
91
	} catch (NumberFormatException e) {
90
		// not a parsable constant
92
		// not a parsable constant

Return to bug 266837