### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java,v retrieving revision 1.166 diff -u -r1.166 JavaSearchBugsTests.java --- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 3 Mar 2009 08:56:18 -0000 1.166 +++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 3 Mar 2009 15:51:25 -0000 @@ -10622,4 +10622,25 @@ } } +/** + * @bug 266837: SourceField.getConstant does not supply a value if type is fully qualified + * @test Ensure that source field constant is not null when fully qualified type String is used + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=266837" + */ +public void testBug266837() throws Exception { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java", + "public class Test {\n" + + " private static final java.lang.String f266837 = \"myString\";\n" + + "}\n" + ); + SearchRequestor requestor = new SearchRequestor() { + public void acceptSearchMatch(SearchMatch searchMatch) throws CoreException { + IField sourceField = (IField) searchMatch.getElement(); + assertEquals("Unexpected source field constant!", "\"myString\"", sourceField.getConstant()); + } + }; + search("f266837", FIELD, DECLARATIONS, requestor); +} + } \ No newline at end of file Index: src/org/eclipse/jdt/core/tests/model/GetSourceTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/GetSourceTests.java,v retrieving revision 1.25 diff -u -r1.25 GetSourceTests.java --- src/org/eclipse/jdt/core/tests/model/GetSourceTests.java 27 Jun 2008 16:02:38 -0000 1.25 +++ src/org/eclipse/jdt/core/tests/model/GetSourceTests.java 3 Mar 2009 15:51:21 -0000 @@ -85,7 +85,9 @@ " static final char field4 = ' ';\n" + " static final double field5 = 938245798324893D;\n" + " static final float field6 = 123456f;\n" + - " static final int field7 = 1<<0;\n" + + " static final String field7 = \"simple string\";\n" + + " static final java.lang.String field8 = \"qualified string\";\n" + + " static final int field9 = 1<<0;\n" + "}"; createFile("/P/p/Constants.java", cuSource); } @@ -158,6 +160,16 @@ public void testFieldConstant07() throws CoreException { IField field = getConstantField("field7"); + assertEquals("Wrong value", "\"simple string\"", field.getConstant()); + } + + public void testFieldConstant08() throws CoreException { + IField field = getConstantField("field8"); + assertEquals("Wrong value", "\"qualified string\"", field.getConstant()); + } + + public void testFieldConstant09() throws CoreException { + IField field = getConstantField("field9"); Object constant = field.getConstant(); assertNull("Should not be a constant", constant); Index: src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java,v retrieving revision 1.38 diff -u -r1.38 AbstractJavaSearchTests.java --- src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java 16 Jan 2009 14:29:34 -0000 1.38 +++ src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java 3 Mar 2009 15:51:21 -0000 @@ -825,6 +825,9 @@ protected void search(String patternString, int searchFor, int limitTo, IJavaSearchScope scope) throws CoreException { search(patternString, searchFor, limitTo, EXACT_RULE, scope, this.resultCollector); } + protected void search(String patternString, int searchFor, int limitTo, SearchRequestor requestor) throws CoreException { + search(patternString, searchFor, limitTo, EXACT_RULE, getJavaSearchScope(), requestor); + } protected void search(String patternString, int searchFor, int limitTo, int matchRule, IJavaSearchScope scope) throws CoreException { search(patternString, searchFor, limitTo, matchRule, scope, this.resultCollector); } #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/SourceField.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceField.java,v retrieving revision 1.47 diff -u -r1.47 SourceField.java --- model/org/eclipse/jdt/internal/core/SourceField.java 27 Jun 2008 16:03:51 -0000 1.47 +++ model/org/eclipse/jdt/internal/core/SourceField.java 3 Mar 2009 15:51:27 -0000 @@ -85,6 +85,8 @@ } } else if (signature.equals("QString;")) {//$NON-NLS-1$ constant = constantSource; + } else if (signature.equals("Qjava.lang.String;")) {//$NON-NLS-1$ + constant = constantSource; } } catch (NumberFormatException e) { // not a parsable constant