### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/CompletionTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java,v retrieving revision 1.231 diff -u -r1.231 CompletionTests.java --- src/org/eclipse/jdt/core/tests/model/CompletionTests.java 5 Nov 2010 13:40:20 -0000 1.231 +++ src/org/eclipse/jdt/core/tests/model/CompletionTests.java 24 Nov 2010 05:56:53 -0000 @@ -21856,4 +21856,41 @@ "myString1[LOCAL_VARIABLE_REF]{myString1, null, Ljava.lang.String;, myString1, null, " + (R_NON_STATIC + R_UNQUALIFIED + R_CASE + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}", requestor.getResults()); } + +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=325481 +// To verify that the fix doesnt cause grief when proposing fields in another +// compilation unit. +public void test325481b() throws JavaModelException { + CompletionTestsRequestor requestor = new CompletionTestsRequestor(); + Map options = COMPLETION_PROJECT.getOptions(true); + Object savedOptionCompliance = options.get(CompilerOptions.OPTION_Compliance); + try { + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + COMPLETION_PROJECT.setOptions(options); + ICompilationUnit cu= getCompilationUnit("Completion", "src3", "test325481", "Main.java"); + + String str = cu.getSource(); + String completeBehind = "IAttributeDefinitionDescriptor."; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + + cu.codeComplete(cursorLocation, requestor); + int relevance = R_INTERFACE + R_UNQUALIFIED + R_NON_RESTRICTED; + assumeEquals( + "should have two completions", + "element:ADD_CUSTOM_ATTRIBUTES completion:ADD_CUSTOM_ATTRIBUTES relevance:" + relevance +"\n" + + "element:ATTRIBUTE completion:ATTRIBUTE relevance:" + relevance +"\n" + + "element:BUILT_ATTRIBUTE completion:BUILT_ATTRIBUTE relevance:" + relevance +"\n" + + "element:RANKING_ATTRIBUTE completion:RANKING_ATTRIBUTE relevance:" + relevance +"\n" + + "element:RANKING_ATTRIBUTE_V2 completion:RANKING_ATTRIBUTE_V2 relevance:" + relevance +"\n" + + "element:REFERENCE_ATTRIBUTE completion:REFERENCE_ATTRIBUTE relevance:" + relevance +"\n" + + "element:WORK_ATTRIBUTE completion:WORK_ATTRIBUTE relevance:" + relevance +"\n" + + "element:class completion:class relevance:" + relevance +"\n" + + "element:this completion:this relevance:" + relevance, + requestor.getResults()); + } finally { + // Restore compliance settings. + options.put(CompilerOptions.OPTION_Compliance, savedOptionCompliance); + COMPLETION_PROJECT.setOptions(options); + } +} } Index: workspace/Completion/src3/test325481/ConfigurationData.java =================================================================== RCS file: workspace/Completion/src3/test325481/ConfigurationData.java diff -N workspace/Completion/src3/test325481/ConfigurationData.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/Completion/src3/test325481/ConfigurationData.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,12 @@ +package test325481; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD}) +public @interface ConfigurationData { + String value() default ""; +} \ No newline at end of file Index: workspace/Completion/src3/test325481/IAttributeDefinitionDescriptor.java =================================================================== RCS file: workspace/Completion/src3/test325481/IAttributeDefinitionDescriptor.java diff -N workspace/Completion/src3/test325481/IAttributeDefinitionDescriptor.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/Completion/src3/test325481/IAttributeDefinitionDescriptor.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,45 @@ +package test325481; + +@ConfigurationData(value= "configuration.attributes") +@Path("attribute") +public interface IAttributeDefinitionDescriptor { + + public static final String BUILT_ATTRIBUTE= "abc"; //$NON-NLS-1$ + public static final String WORK_ATTRIBUTE= "abc"; //$NON-NLS-1$ + public static final String RANKING_ATTRIBUTE= "abc"; //$NON-NLS-1$ + public static final String RANKING_ATTRIBUTE_V2= "abc"; //$NON-NLS-1$ + public static final String REFERENCE_ATTRIBUTE= "abc"; //$NON-NLS-1$ + + public static final String ATTRIBUTE= "attribute"; //$NON-NLS-1$ + public static final String ADD_CUSTOM_ATTRIBUTES= "addCustomAttributes"; //$NON-NLS-1$ + + @Path("@id") + String setId(String value); + + @Path("@name") + String setDisplayName(String value); + + @Path("@implementation") + String setImplementationName(String value); + @Path("@implementation") + String setImplementationD(String value); + @Path("@implementation") + String setImplementation2(String value); + @Path("@queryId") + String getQueryId(); + + @Path("@queryId") + String setQueryId(String value); + + @Path("@readOnly") + boolean isReadOnly(); + + @Path("@readOnly") + boolean setReadOnly(boolean value); + + @Path("@internal") + boolean isInternal(); + + @Path("@internal") + boolean setInternal(boolean value); +} Index: workspace/Completion/src3/test325481/Main.java =================================================================== RCS file: workspace/Completion/src3/test325481/Main.java diff -N workspace/Completion/src3/test325481/Main.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/Completion/src3/test325481/Main.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,11 @@ + +package test325481; + +public class Main { + + void m() { + + IAttributeDefinitionDescriptor. + } + +} Index: workspace/Completion/src3/test325481/Path.java =================================================================== RCS file: workspace/Completion/src3/test325481/Path.java diff -N workspace/Completion/src3/test325481/Path.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/Completion/src3/test325481/Path.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,19 @@ +package test325481; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD, ElementType.TYPE}) +public @interface Path { + String value() default ""; + + String from() default ""; + String to() default ""; + + String defaultDefinition() default ""; + + boolean refines() default false; +}