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

Collapse All | Expand All

(-)model/org/eclipse/jdt/core/CompletionRequestor.java (-2 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2005 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 205-211 Link Here
205
	 * It can be a reference to a static method or field (as in a static import)<br>
205
	 * It can be a reference to a static method or field (as in a static import)<br>
206
	 * e.g. <code>{"java.util.Arrays.equals"}</code>
206
	 * e.g. <code>{"java.util.Arrays.equals"}</code>
207
	 * </p>
207
	 * </p>
208
	 *
208
	 * <p>
209
	 * Currently only on demand type references (<code>"java.util.Arrays.*"</code>),
210
	 * references to a static method or a static field are used to compute completion proposals.
211
	 * Other kind of reference could be used in the future.
212
	 * </p>
209
	 * @return favorites imports
213
	 * @return favorites imports
210
	 * 
214
	 * 
211
	 * @since 3.3
215
	 * @since 3.3
(-)model/org/eclipse/jdt/core/CompletionProposal.java (-12 / +196 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 631-636 Link Here
631
	public static final int JAVADOC_INLINE_TAG = 20;
631
	public static final int JAVADOC_INLINE_TAG = 20;
632
632
633
	/**
633
	/**
634
	 * Completion is an import of reference to a field.
635
	 * <p>
636
	 * The following additional context information is available
637
	 * for this kind of completion proposal at little extra cost:
638
	 * <ul>
639
	 * <li>{@link #getDeclarationSignature()} -
640
	 * the type signature of the type that declares the field that is imported
641
	 * </li>
642
	 * <li>{@link #getFlags()} -
643
	 * the modifiers flags (including ACC_ENUM) of the field that is imported
644
	 * </li>
645
	 * <li>{@link #getName()} -
646
	 * the simple name of the field that is imported
647
	 * </li>
648
	 * <li>{@link #getSignature()} -
649
	 * the type signature of the field's type (as opposed to the
650
	 * signature of the type in which the referenced field
651
	 * is declared)
652
	 * </li>
653
	 * <li>{@link #getAdditionalFlags()} -
654
	 * the completion flags (including ComletionFlags.StaticImport)
655
	 * of the prosposed import
656
	 * </li>
657
	 * </ul>
658
	 * </p>
659
	 * 
660
	 * @see #getKind()
661
	 * 
662
	 * @since 3.3
663
	 */
664
	public static final int FIELD_IMPORT = 21;
665
	
666
	/**
667
	 * Completion is an import of reference to a static method.
668
	 * <p>
669
	 * The following additional context information is available
670
	 * for this kind of completion proposal at little extra cost:
671
	 * <ul>
672
	 * <li>{@link #getDeclarationSignature()} -
673
	 * the type signature of the type that declares the method that is imported
674
	 * </li>
675
	 * <li>{@link #getFlags()} -
676
	 * the modifiers flags of the method that is imported
677
	 * </li>
678
	 * <li>{@link #getName()} -
679
	 * the simple name of the method that is imported
680
	 * </li>
681
	 * <li>{@link #getSignature()} -
682
	 * the method signature of the method that is imported
683
	 * </li>
684
	 * <li>{@link #getAdditionalFlags()} -
685
	 * the completion flags (including ComletionFlags.StaticImport)
686
	 * of the prosposed import
687
	 * </li>
688
	 * </ul>
689
	 * </p>
690
	 * 
691
	 * @see #getKind()
692
	 * 
693
	 * @since 3.3
694
	 */
695
	public static final int METHOD_IMPORT = 22;
696
	
697
	/**
698
	 * Completion is an import of reference to a type.
699
	 * Only reference to reference types are allowed.
700
	 * <p>
701
	 * The following additional context information is available
702
	 * for this kind of completion proposal at little extra cost:
703
	 * <ul>
704
	 * <li>{@link #getDeclarationSignature()} -
705
	 * the dot-based package name of the package that contains
706
	 * the type that is imported
707
	 * </li>
708
	 * <li>{@link #getSignature()} -
709
	 * the type signature of the type that is imported
710
	 * </li>
711
	 * <li>{@link #getFlags()} -
712
	 * the modifiers flags (including Flags.AccInterface, AccEnum,
713
	 * and AccAnnotation) of the type that is imported
714
	 * </li>
715
	 * <li>{@link #getAdditionalFlags()} -
716
	 * the completion flags (including ComletionFlags.StaticImport)
717
	 * of the prosposed import
718
	 * </li>
719
	 * </ul>
720
	 * </p>
721
	 * 
722
	 * @see #getKind()
723
	 * 
724
	 * @since 3.3
725
	 */
726
	public static final int TYPE_IMPORT = 23;
727
	
728
	/**
634
	 * First valid completion kind.
729
	 * First valid completion kind.
635
	 * 
730
	 * 
636
	 * @since 3.1
731
	 * @since 3.1
Lines 642-648 Link Here
642
	 * 
737
	 * 
643
	 * @since 3.1
738
	 * @since 3.1
644
	 */
739
	 */
645
	protected static final int LAST_KIND = JAVADOC_INLINE_TAG;
740
	protected static final int LAST_KIND = TYPE_IMPORT;
646
	
741
	
647
	/**
742
	/**
648
	 * Kind of completion request.
743
	 * Kind of completion request.
Lines 744-749 Link Here
744
	 */
839
	 */
745
	private int flags = Flags.AccDefault;
840
	private int flags = Flags.AccDefault;
746
	
841
	
842
	private int additionalFlags = 0;
843
	
747
	/**
844
	/**
748
	 * Parameter names (for method completions), or
845
	 * Parameter names (for method completions), or
749
	 * <code>null</code> if none. Lazily computed.
846
	 * <code>null</code> if none. Lazily computed.
Lines 804-809 Link Here
804
	}
901
	}
805
	
902
	
806
	/**
903
	/**
904
	 * Returns the completion flags relevant in the context, or
905
	 * <code>CompletionFlags.Default</code> if none.
906
	 * <p>
907
	 * This field is available for the following kinds of
908
	 * completion proposals:
909
	 * <ul>
910
	 * <li><code>FIELD_IMPORT</code> - completion flags
911
	 * of the attribute that is referenced. Completion flags for
912
	 * this proposal kind can only include <code>CompletionFlags.StaticImport</code></li>
913
	 * <li><code>METHOD_IMPORT</code> - completion flags
914
	 * of the attribute that is referenced. Completion flags for
915
	 * this proposal kind can only include <code>CompletionFlags.StaticImport</code></li>
916
	 * <li><code>TYPE_IMPORT</code> - completion flags
917
	 * of the attribute that is referenced. Completion flags for
918
	 * this proposal kind can only include <code>CompletionFlags.StaticImport</code></li>
919
	 * </ul>
920
	 * For other kinds of completion proposals, this method returns
921
	 * <code>CompletionFlags.Default</code>.
922
	 * </p>
923
	 * 
924
	 * @return the completion flags, or
925
	 * <code>CompletionFlags.Default</code> if none
926
	 * @see CompletionFlags
927
	 * 
928
	 * @since 3.3
929
	 */
930
	public int getAdditionalFlags() {
931
		return this.additionalFlags;
932
	}
933
934
	/**
935
	 * Sets the completion flags relevant in the context.
936
	 * <p>
937
	 * If not set, defaults to none.
938
	 * </p>
939
	 * <p>
940
	 * The completion engine creates instances of this class and sets
941
	 * its properties; this method is not intended to be used by other clients.
942
	 * </p>
943
	 * 
944
	 * @param additionalFlags the completion flags, or
945
	 * <code>CompletionFlags.Default</code> if none
946
	 * 
947
	 * @since 3.3
948
	 */
949
	public void setAdditionalFlags(int additionalFlags) {
950
		this.additionalFlags = additionalFlags;
951
	}
952
	
953
	/**
807
	 * Returns the kind of completion being proposed.
954
	 * Returns the kind of completion being proposed.
808
	 * <p>
955
	 * <p>
809
	 * The set of different kinds of completion proposals is
956
	 * The set of different kinds of completion proposals is
Lines 1057-1072 Link Here
1057
	 * of the annotation that declares the attribute that is referenced</li>
1204
	 * of the annotation that declares the attribute that is referenced</li>
1058
	 * <li><code>ANONYMOUS_CLASS_DECLARATION</code> - type signature
1205
	 * <li><code>ANONYMOUS_CLASS_DECLARATION</code> - type signature
1059
	 * of the type that is being subclassed or implemented</li>
1206
	 * of the type that is being subclassed or implemented</li>
1060
	 * 	<li><code>FIELD_REF</code> - type signature
1207
	 * 	<li><code>FIELD_IMPORT</code> - type signature
1208
	 * of the type that declares the field that is imported</li>
1209
	 *  <li><code>FIELD_REF</code> - type signature
1061
	 * of the type that declares the field that is referenced</li>
1210
	 * of the type that declares the field that is referenced</li>
1062
	 * 	<li><code>METHOD_REF</code> - type signature
1211
	 * 	<li><code>METHOD_IMPORT</code> - type signature
1212
	 * of the type that declares the method that is imported</li>
1213
	 *  <li><code>METHOD_REF</code> - type signature
1063
	 * of the type that declares the method that is referenced</li>
1214
	 * of the type that declares the method that is referenced</li>
1064
	 * 	<li><code>METHOD_DECLARATION</code> - type signature
1215
	 * 	<li><code>METHOD_DECLARATION</code> - type signature
1065
	 * of the type that declares the method that is being
1216
	 * of the type that declares the method that is being
1066
	 * implemented or overridden</li>
1217
	 * implemented or overridden</li>
1067
	 * 	<li><code>PACKAGE_REF</code> - dot-based package 
1218
	 * 	<li><code>PACKAGE_REF</code> - dot-based package 
1068
	 * name of the package that is referenced</li>
1219
	 * name of the package that is referenced</li>
1069
	 * 	<li><code>TYPE_REF</code> - dot-based package 
1220
	 * 	<li><code>TYPE_IMPORT</code> - dot-based package 
1221
	 * name of the package containing the type that is imported</li>
1222
	 *  <li><code>TYPE_REF</code> - dot-based package 
1070
	 * name of the package containing the type that is referenced</li>
1223
	 * name of the package containing the type that is referenced</li>
1071
	 *  <li><code>POTENTIAL_METHOD_DECLARATION</code> - type signature
1224
	 *  <li><code>POTENTIAL_METHOD_DECLARATION</code> - type signature
1072
	 * of the type that declares the method that is being created</li>
1225
	 * of the type that declares the method that is being created</li>
Lines 1156-1166 Link Here
1156
	 * completion proposals:
1309
	 * completion proposals:
1157
	 * <ul>
1310
	 * <ul>
1158
	 *  <li><code>ANNOTATION_ATTRIBUT_REF</code> - the name of the attribute</li>
1311
	 *  <li><code>ANNOTATION_ATTRIBUT_REF</code> - the name of the attribute</li>
1159
	 * 	<li><code>FIELD_REF</code> - the name of the field</li>
1312
	 * 	<li><code>FIELD_IMPORT</code> - the name of the field</li>
1313
	 *  <li><code>FIELD_REF</code> - the name of the field</li>
1160
	 * 	<li><code>KEYWORD</code> - the keyword</li>
1314
	 * 	<li><code>KEYWORD</code> - the keyword</li>
1161
	 * 	<li><code>LABEL_REF</code> - the name of the label</li>
1315
	 * 	<li><code>LABEL_REF</code> - the name of the label</li>
1162
	 * 	<li><code>LOCAL_VARIABLE_REF</code> - the name of the local variable</li>
1316
	 * 	<li><code>LOCAL_VARIABLE_REF</code> - the name of the local variable</li>
1163
	 * 	<li><code>METHOD_REF</code> - the name of the method (the type simple name for constructor)</li>
1317
	 * 	<li><code>METHOD_IMPORT</code> - the name of the method</li>
1318
	 *  <li><code>METHOD_REF</code> - the name of the method (the type simple name for constructor)</li>
1164
	 * 	<li><code>METHOD_DECLARATION</code> - the name of the method (the type simple name for constructor)</li>
1319
	 * 	<li><code>METHOD_DECLARATION</code> - the name of the method (the type simple name for constructor)</li>
1165
	 * 	<li><code>VARIABLE_DECLARATION</code> - the name of the variable</li>
1320
	 * 	<li><code>VARIABLE_DECLARATION</code> - the name of the variable</li>
1166
	 *  <li><code>POTENTIAL_METHOD_DECLARATION</code> - the name of the method</li>
1321
	 *  <li><code>POTENTIAL_METHOD_DECLARATION</code> - the name of the method</li>
Lines 1208-1221 Link Here
1208
	 * of the referenced attribute's type</li>
1363
	 * of the referenced attribute's type</li>
1209
	 * <li><code>ANONYMOUS_CLASS_DECLARATION</code> - method signature
1364
	 * <li><code>ANONYMOUS_CLASS_DECLARATION</code> - method signature
1210
	 * of the constructor that is being invoked</li>
1365
	 * of the constructor that is being invoked</li>
1211
	 * 	<li><code>FIELD_REF</code> - the type signature
1366
	 * 	<li><code>FIELD_IMPORT</code> - the type signature
1367
	 * of the referenced field's type</li>
1368
	 *  <li><code>FIELD_REF</code> - the type signature
1212
	 * of the referenced field's type</li>
1369
	 * of the referenced field's type</li>
1213
	 * 	<li><code>LOCAL_VARIABLE_REF</code> - the type signature
1370
	 * 	<li><code>LOCAL_VARIABLE_REF</code> - the type signature
1214
	 * of the referenced local variable's type</li>
1371
	 * of the referenced local variable's type</li>
1215
	 * 	<li><code>METHOD_REF</code> - method signature
1372
	 * 	<li><code>METHOD_IMPORT</code> - method signature
1373
	 * of the method that is imported</li>
1374
	 *  <li><code>METHOD_REF</code> - method signature
1216
	 * of the method that is referenced</li>
1375
	 * of the method that is referenced</li>
1217
	 * 	<li><code>METHOD_DECLARATION</code> - method signature
1376
	 * 	<li><code>METHOD_DECLARATION</code> - method signature
1218
	 * of the method that is being implemented or overridden</li>
1377
	 * of the method that is being implemented or overridden</li>
1378
	 * 	<li><code>TYPE_IMPORT</code> - type signature
1379
	 * of the type that is imported</li>
1219
	 * 	<li><code>TYPE_REF</code> - type signature
1380
	 * 	<li><code>TYPE_REF</code> - type signature
1220
	 * of the type that is referenced</li>
1381
	 * of the type that is referenced</li>
1221
	 * 	<li><code>VARIABLE_DECLARATION</code> - the type signature
1382
	 * 	<li><code>VARIABLE_DECLARATION</code> - the type signature
Lines 1512-1518 Link Here
1512
	 * of the attribute that is referenced; 
1673
	 * of the attribute that is referenced; 
1513
	 * <li><code>ANONYMOUS_CLASS_DECLARATION</code> - modifier flags
1674
	 * <li><code>ANONYMOUS_CLASS_DECLARATION</code> - modifier flags
1514
	 * of the constructor that is referenced</li>
1675
	 * of the constructor that is referenced</li>
1515
	 * 	<li><code>FIELD_REF</code> - modifier flags
1676
	 * 	<li><code>FIELD_IMPORT</code> - modifier flags
1677
	 * of the field that is imported.</li>
1678
	 *  <li><code>FIELD_REF</code> - modifier flags
1516
	 * of the field that is referenced; 
1679
	 * of the field that is referenced; 
1517
	 * <code>Flags.AccEnum</code> can be used to recognize
1680
	 * <code>Flags.AccEnum</code> can be used to recognize
1518
	 * references to enum constants
1681
	 * references to enum constants
Lines 1521-1534 Link Here
1521
	 * corrresponding to the modifier keyword</li>
1684
	 * corrresponding to the modifier keyword</li>
1522
	 * 	<li><code>LOCAL_VARIABLE_REF</code> - modifier flags
1685
	 * 	<li><code>LOCAL_VARIABLE_REF</code> - modifier flags
1523
	 * of the local variable that is referenced</li>
1686
	 * of the local variable that is referenced</li>
1687
	 *  <li><code>METHOD_IMPORT</code> - modifier flags
1688
	 * of the method that is imported;
1689
	 *  </li>
1524
	 * 	<li><code>METHOD_REF</code> - modifier flags
1690
	 * 	<li><code>METHOD_REF</code> - modifier flags
1525
	 * of the method that is referenced;
1691
	 * of the method that is referenced;
1526
	 * <code>Flags.AccAnnotation</code> can be used to recognize
1692
	 * <code>Flags.AccAnnotation</code> can be used to recognize
1527
	 * references to annotation type members
1693
	 * references to annotation type members
1528
	 * </li>
1694
	 * </li>
1529
	 * 	<li><code>METHOD_DECLARATION</code> - modifier flags
1695
	 * <li><code>METHOD_DECLARATION</code> - modifier flags
1530
	 * for the method that is being implemented or overridden</li>
1696
	 * for the method that is being implemented or overridden</li>
1531
	 * 	<li><code>TYPE_REF</code> - modifier flags
1697
	 * <li><code>TYPE_IMPORT</code> - modifier flags
1698
	 * of the type that is imporetd; <code>Flags.AccInterface</code>
1699
	 * can be used to recognize references to interfaces, 
1700
	 * <code>Flags.AccEnum</code> enum types,
1701
	 * and <code>Flags.AccAnnotation</code> annotation types</li>
1702
	 * <li><code>TYPE_REF</code> - modifier flags
1532
	 * of the type that is referenced; <code>Flags.AccInterface</code>
1703
	 * of the type that is referenced; <code>Flags.AccInterface</code>
1533
	 * can be used to recognize references to interfaces, 
1704
	 * can be used to recognize references to interfaces, 
1534
	 * <code>Flags.AccEnum</code> enum types,
1705
	 * <code>Flags.AccEnum</code> enum types,
Lines 1580-1590 Link Here
1580
	 * 	<li><code>FIELD_REF</code> - The allowed required proposals for this kind are:
1751
	 * 	<li><code>FIELD_REF</code> - The allowed required proposals for this kind are:
1581
	 *   <ul>
1752
	 *   <ul>
1582
	 *    <li><code>TYPE_REF</code></li>
1753
	 *    <li><code>TYPE_REF</code></li>
1754
	 *    <li><code>TYPE_IMPORT</code></li>
1755
	 *    <li><code>FIELD_IMPORT</code></li>
1583
	 *   </ul>
1756
	 *   </ul>
1584
	 * </li>
1757
	 * </li>
1585
	 * 	<li><code>METHOD_REF</code> - The allowed required proposals for this kind are:
1758
	 * 	<li><code>METHOD_REF</code> - The allowed required proposals for this kind are:
1586
	 *   <ul>
1759
	 *   <ul>
1587
	 *    <li><code>TYPE_REF</code></li>
1760
	 *    <li><code>TYPE_REF</code></li>
1761
	 *    <li><code>TYPE_IMPORT</code></li>
1762
	 *    <li><code>METHOD_IMPORT</code></li>
1588
	 *   </ul>
1763
	 *   </ul>
1589
	 *  </li>
1764
	 *  </li>
1590
	 * </ul>
1765
	 * </ul>
Lines 1837-1842 Link Here
1837
			case CompletionProposal.JAVADOC_VALUE_REF :
2012
			case CompletionProposal.JAVADOC_VALUE_REF :
1838
				buffer.append("JAVADOC_VALUE_REF"); //$NON-NLS-1$
2013
				buffer.append("JAVADOC_VALUE_REF"); //$NON-NLS-1$
1839
				break;
2014
				break;
2015
			case CompletionProposal.FIELD_IMPORT :
2016
				buffer.append("FIELD_IMPORT"); //$NON-NLS-1$
2017
				break;
2018
			case CompletionProposal.METHOD_IMPORT :
2019
				buffer.append("METHOD_IMPORT"); //$NON-NLS-1$
2020
				break;
2021
			case CompletionProposal.TYPE_IMPORT :
2022
				buffer.append("TYPE_IMPORT"); //$NON-NLS-1$
2023
				break;
1840
			default :
2024
			default :
1841
				buffer.append("PROPOSAL"); //$NON-NLS-1$
2025
				buffer.append("PROPOSAL"); //$NON-NLS-1$
1842
				break;
2026
				break;
(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-54 / +273 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2007 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 15-20 Link Here
15
import java.util.Map;
15
import java.util.Map;
16
16
17
import org.eclipse.jdt.core.CompletionContext;
17
import org.eclipse.jdt.core.CompletionContext;
18
import org.eclipse.jdt.core.CompletionFlags;
18
import org.eclipse.jdt.core.CompletionProposal;
19
import org.eclipse.jdt.core.CompletionProposal;
19
import org.eclipse.jdt.core.CompletionRequestor;
20
import org.eclipse.jdt.core.CompletionRequestor;
20
import org.eclipse.jdt.core.Flags;
21
import org.eclipse.jdt.core.Flags;
Lines 214-219 Link Here
214
	
215
	
215
	private final static char[] VARARGS = "...".toCharArray();  //$NON-NLS-1$
216
	private final static char[] VARARGS = "...".toCharArray();  //$NON-NLS-1$
216
	
217
	
218
	private final static char[] IMPORT = "import".toCharArray();  //$NON-NLS-1$
219
	private final static char[] STATIC = "static".toCharArray();  //$NON-NLS-1$
220
	private final static char[] ON_DEMAND = ".*".toCharArray();  //$NON-NLS-1$
221
	private final static char[] IMPORT_END = ";\n".toCharArray();  //$NON-NLS-1$
222
	
217
	private final static int SUPERTYPE = 1;
223
	private final static int SUPERTYPE = 1;
218
	private final static int SUBTYPE = 2;
224
	private final static int SUBTYPE = 2;
219
	
225
	
Lines 3360-3367 Link Here
3360
			
3366
			
3361
			fieldsFound.add(new Object[]{field, receiverType});
3367
			fieldsFound.add(new Object[]{field, receiverType});
3362
			
3368
			
3363
			char[] completion = CharOperation.concat(typeName, field.name, '.');
3364
3365
			int relevance = computeBaseRelevance();
3369
			int relevance = computeBaseRelevance();
3366
			relevance += computeRelevanceForInterestingProposal(field);
3370
			relevance += computeRelevanceForInterestingProposal(field);
3367
			if (fieldName != null) relevance += computeRelevanceForCaseMatching(fieldName, field.name);
3371
			if (fieldName != null) relevance += computeRelevanceForCaseMatching(fieldName, field.name);
Lines 3369-3392 Link Here
3369
			relevance += computeRelevanceForStatic(true, true);
3373
			relevance += computeRelevanceForStatic(true, true);
3370
			relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
3374
			relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
3371
			
3375
			
3376
			CompilationUnitDeclaration cu = this.unitScope.referenceContext;
3377
			int importStart = cu.types[0].declarationSourceStart;
3378
			int importEnd = importStart;
3379
			
3372
			this.noProposal = false;
3380
			this.noProposal = false;
3373
			
3381
			
3374
			if (!this.isIgnored(CompletionProposal.FIELD_REF)) {
3382
			if (this.compilerOptions.complianceLevel < ClassFileConstants.JDK1_5) {
3375
				CompletionProposal proposal = this.createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition);
3383
				if (!this.isIgnored(CompletionProposal.FIELD_REF, CompletionProposal.TYPE_IMPORT)) {
3376
				proposal.setDeclarationSignature(getSignature(field.declaringClass));
3384
					char[] completion = CharOperation.concat(receiverType.sourceName, field.name, '.');
3377
				proposal.setSignature(getSignature(field.type));
3385
					
3378
				proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName());
3386
					CompletionProposal proposal = this.createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition);
3379
				proposal.setDeclarationTypeName(field.declaringClass.qualifiedSourceName());
3387
					proposal.setDeclarationSignature(getSignature(field.declaringClass));
3380
				proposal.setPackageName(field.type.qualifiedPackageName());
3388
					proposal.setSignature(getSignature(field.type));
3381
				proposal.setTypeName(field.type.qualifiedSourceName()); 
3389
					proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName());
3382
				proposal.setName(field.name);
3390
					proposal.setDeclarationTypeName(field.declaringClass.qualifiedSourceName());
3383
				proposal.setCompletion(completion);
3391
					proposal.setPackageName(field.type.qualifiedPackageName());
3384
				proposal.setFlags(field.modifiers);
3392
					proposal.setTypeName(field.type.qualifiedSourceName()); 
3385
				proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
3393
					proposal.setName(field.name);
3386
				proposal.setRelevance(relevance);
3394
					proposal.setCompletion(completion);
3387
				this.requestor.accept(proposal);
3395
					proposal.setFlags(field.modifiers);
3388
				if(DEBUG) {
3396
					proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
3389
					this.printDebug(proposal);
3397
					proposal.setRelevance(relevance);
3398
					
3399
					char[] typeImportCompletion = createImportCharArray(typeName, false, false);
3400
					
3401
					CompletionProposal typeImportProposal = this.createProposal(CompletionProposal.TYPE_IMPORT, this.actualCompletionPosition);
3402
					typeImportProposal.nameLookup = this.nameEnvironment.nameLookup;
3403
					typeImportProposal.completionEngine = this;
3404
					char[] packageName = receiverType.qualifiedPackageName();
3405
					typeImportProposal.setDeclarationSignature(packageName);
3406
					typeImportProposal.setSignature(getSignature(receiverType));
3407
					typeImportProposal.setPackageName(packageName);
3408
					typeImportProposal.setTypeName(receiverType.qualifiedSourceName());
3409
					typeImportProposal.setCompletion(typeImportCompletion);
3410
					typeImportProposal.setFlags(receiverType.modifiers);
3411
					typeImportProposal.setAdditionalFlags(CompletionFlags.Default);
3412
					typeImportProposal.setReplaceRange(importStart - this.offset, importEnd - this.offset);
3413
					typeImportProposal.setRelevance(relevance);
3414
					
3415
					proposal.setRequiredProposals(new CompletionProposal[]{typeImportProposal});
3416
					
3417
					this.requestor.accept(proposal);
3418
					if(DEBUG) {
3419
						this.printDebug(proposal);
3420
					}
3421
				}
3422
			} else {
3423
				if (!this.isIgnored(CompletionProposal.FIELD_REF, CompletionProposal.FIELD_IMPORT)) {
3424
					char[] completion = field.name;
3425
					
3426
					CompletionProposal proposal = this.createProposal(CompletionProposal.FIELD_REF, this.actualCompletionPosition);
3427
					proposal.setDeclarationSignature(getSignature(field.declaringClass));
3428
					proposal.setSignature(getSignature(field.type));
3429
					proposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName());
3430
					proposal.setDeclarationTypeName(field.declaringClass.qualifiedSourceName());
3431
					proposal.setPackageName(field.type.qualifiedPackageName());
3432
					proposal.setTypeName(field.type.qualifiedSourceName()); 
3433
					proposal.setName(field.name);
3434
					proposal.setCompletion(completion);
3435
					proposal.setFlags(field.modifiers);
3436
					proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
3437
					proposal.setRelevance(relevance);
3438
					
3439
					char[] fieldImportCompletion = createImportCharArray(CharOperation.concat(typeName, field.name, '.'), true, false);
3440
3441
					CompletionProposal fieldImportProposal = this.createProposal(CompletionProposal.FIELD_IMPORT, this.actualCompletionPosition);
3442
					fieldImportProposal.setDeclarationSignature(getSignature(field.declaringClass));
3443
					fieldImportProposal.setSignature(getSignature(field.type));
3444
					fieldImportProposal.setDeclarationPackageName(field.declaringClass.qualifiedPackageName());
3445
					fieldImportProposal.setDeclarationTypeName(field.declaringClass.qualifiedSourceName());
3446
					fieldImportProposal.setPackageName(field.type.qualifiedPackageName());
3447
					fieldImportProposal.setTypeName(field.type.qualifiedSourceName()); 
3448
					fieldImportProposal.setName(field.name);
3449
					fieldImportProposal.setCompletion(fieldImportCompletion);
3450
					fieldImportProposal.setFlags(field.modifiers);
3451
					fieldImportProposal.setAdditionalFlags(CompletionFlags.StaticImport);
3452
					fieldImportProposal.setReplaceRange(importStart - this.offset, importEnd - this.offset);
3453
					fieldImportProposal.setRelevance(relevance);
3454
					
3455
					proposal.setRequiredProposals(new CompletionProposal[]{fieldImportProposal});
3456
					
3457
					this.requestor.accept(proposal);
3458
					if(DEBUG) {
3459
						this.printDebug(proposal);
3460
					}
3390
				}
3461
				}
3391
			}
3462
			}
3392
		}
3463
		}
Lines 4681-4686 Link Here
4681
					MethodBinding otherMethod = (MethodBinding) other[0];
4752
					MethodBinding otherMethod = (MethodBinding) other[0];
4682
					
4753
					
4683
					if (method == otherMethod) continue next;
4754
					if (method == otherMethod) continue next;
4755
					
4756
					if (CharOperation.equals(method.selector, otherMethod.selector, true)) {
4757
						if (lookupEnvironment.methodVerifier().doesMethodOverride(otherMethod, method)) {
4758
							continue next;
4759
						}
4760
					}
4761
				}
4762
				
4763
				boolean proposeStaticImport = !(this.compilerOptions.complianceLevel < ClassFileConstants.JDK1_5);
4764
				
4765
				boolean isAlreadyImported = false;
4766
				if (!proposeStaticImport) {
4767
					if(!this.importCachesInitialized) {
4768
						this.initializeImportCaches();
4769
					}
4770
					for (int j = 0; j < this.importCacheCount; j++) {
4771
						char[][] importName = this.importsCache[j];
4772
						if(CharOperation.equals(receiverType.sourceName, importName[0])) {
4773
							if (!CharOperation.equals(typeName, importName[1])) {
4774
								continue next;
4775
							} else {
4776
								isAlreadyImported = true;
4777
							}
4778
						}
4779
					}
4684
				}
4780
				}
4685
				
4781
				
4686
				methodsFound.add(new Object[]{method, receiverType});
4782
				methodsFound.add(new Object[]{method, receiverType});
Lines 4718-4725 Link Here
4718
					completion = CharOperation.concat(method.selector, new char[] { '(', ')' });
4814
					completion = CharOperation.concat(method.selector, new char[] { '(', ')' });
4719
				}
4815
				}
4720
				
4816
				
4721
				completion = CharOperation.concat(typeName, completion, '.');
4722
4723
				int relevance = computeBaseRelevance();
4817
				int relevance = computeBaseRelevance();
4724
				relevance += computeRelevanceForInterestingProposal();
4818
				relevance += computeRelevanceForInterestingProposal();
4725
				if (methodName != null) relevance += computeRelevanceForCaseMatching(methodName, method.selector);
4819
				if (methodName != null) relevance += computeRelevanceForCaseMatching(methodName, method.selector);
Lines 4728-4759 Link Here
4728
				relevance += computeRelevanceForQualification(true);
4822
				relevance += computeRelevanceForQualification(true);
4729
				relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4823
				relevance += computeRelevanceForRestrictions(IAccessRule.K_ACCESSIBLE);
4730
4824
4825
				CompilationUnitDeclaration cu = this.unitScope.referenceContext;
4826
				int importStart = cu.types[0].declarationSourceStart;
4827
				int importEnd = importStart;
4731
				
4828
				
4732
				this.noProposal = false;
4829
				this.noProposal = false;
4733
				// Standard proposal
4830
				
4734
				if(!this.isIgnored(CompletionProposal.METHOD_REF)) {
4831
				if (!proposeStaticImport) {
4735
					CompletionProposal proposal = this.createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition);
4832
					if (isAlreadyImported) {
4736
					proposal.setDeclarationSignature(getSignature(method.declaringClass));
4833
						if (!isIgnored(CompletionProposal.METHOD_REF)) {
4737
					proposal.setSignature(getSignature(method));
4834
							completion = CharOperation.concat(receiverType.sourceName, completion, '.');
4738
					MethodBinding original = method.original();
4835
							
4739
					if(original != method) {
4836
							CompletionProposal proposal = this.createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition);
4740
						proposal.setOriginalSignature(getSignature(original));
4837
							proposal.setDeclarationSignature(getSignature(method.declaringClass));
4741
					}
4838
							proposal.setSignature(getSignature(method));
4742
					proposal.setDeclarationPackageName(method.declaringClass.qualifiedPackageName());
4839
							MethodBinding original = method.original();
4743
					proposal.setDeclarationTypeName(method.declaringClass.qualifiedSourceName());
4840
							if(original != method) {
4744
					proposal.setParameterPackageNames(parameterPackageNames);
4841
								proposal.setOriginalSignature(getSignature(original));
4745
					proposal.setParameterTypeNames(parameterTypeNames);
4842
							}
4746
					proposal.setPackageName(method.returnType.qualifiedPackageName());
4843
							proposal.setDeclarationPackageName(method.declaringClass.qualifiedPackageName());
4747
					proposal.setTypeName(method.returnType.qualifiedSourceName());
4844
							proposal.setDeclarationTypeName(method.declaringClass.qualifiedSourceName());
4748
					proposal.setName(method.selector);
4845
							proposal.setParameterPackageNames(parameterPackageNames);
4749
					proposal.setCompletion(completion);
4846
							proposal.setParameterTypeNames(parameterTypeNames);
4750
					proposal.setFlags(method.modifiers);
4847
							proposal.setPackageName(method.returnType.qualifiedPackageName());
4751
					proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
4848
							proposal.setTypeName(method.returnType.qualifiedSourceName());
4752
					proposal.setRelevance(relevance);
4849
							proposal.setName(method.selector);
4753
					if(parameterNames != null) proposal.setParameterNames(parameterNames);
4850
							proposal.setCompletion(completion);
4754
					this.requestor.accept(proposal);
4851
							proposal.setFlags(method.modifiers);
4755
					if(DEBUG) {
4852
							proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
4756
						this.printDebug(proposal);
4853
							proposal.setRelevance(relevance);
4854
							if(parameterNames != null) proposal.setParameterNames(parameterNames);
4855
							
4856
							this.requestor.accept(proposal);
4857
							if(DEBUG) {
4858
								this.printDebug(proposal);
4859
							}
4860
						}
4861
					} else if (!this.isIgnored(CompletionProposal.METHOD_REF, CompletionProposal.TYPE_IMPORT)) {
4862
						completion = CharOperation.concat(receiverType.sourceName, completion, '.');
4863
						
4864
						CompletionProposal proposal = this.createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition);
4865
						proposal.setDeclarationSignature(getSignature(method.declaringClass));
4866
						proposal.setSignature(getSignature(method));
4867
						MethodBinding original = method.original();
4868
						if(original != method) {
4869
							proposal.setOriginalSignature(getSignature(original));
4870
						}
4871
						proposal.setDeclarationPackageName(method.declaringClass.qualifiedPackageName());
4872
						proposal.setDeclarationTypeName(method.declaringClass.qualifiedSourceName());
4873
						proposal.setParameterPackageNames(parameterPackageNames);
4874
						proposal.setParameterTypeNames(parameterTypeNames);
4875
						proposal.setPackageName(method.returnType.qualifiedPackageName());
4876
						proposal.setTypeName(method.returnType.qualifiedSourceName());
4877
						proposal.setName(method.selector);
4878
						proposal.setCompletion(completion);
4879
						proposal.setFlags(method.modifiers);
4880
						proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
4881
						proposal.setRelevance(relevance);
4882
						if(parameterNames != null) proposal.setParameterNames(parameterNames);
4883
						
4884
						char[] typeImportCompletion = createImportCharArray(typeName, false, false);
4885
						
4886
						CompletionProposal typeImportProposal = this.createProposal(CompletionProposal.TYPE_IMPORT, this.actualCompletionPosition);
4887
						typeImportProposal.nameLookup = this.nameEnvironment.nameLookup;
4888
						typeImportProposal.completionEngine = this;
4889
						char[] packageName = receiverType.qualifiedPackageName();
4890
						typeImportProposal.setDeclarationSignature(packageName);
4891
						typeImportProposal.setSignature(getSignature(receiverType));
4892
						typeImportProposal.setPackageName(packageName);
4893
						typeImportProposal.setTypeName(receiverType.qualifiedSourceName());
4894
						typeImportProposal.setCompletion(typeImportCompletion);
4895
						typeImportProposal.setFlags(receiverType.modifiers);
4896
						typeImportProposal.setAdditionalFlags(CompletionFlags.Default);
4897
						typeImportProposal.setReplaceRange(importStart - this.offset, importEnd - this.offset);
4898
						typeImportProposal.setRelevance(relevance);
4899
						
4900
						proposal.setRequiredProposals(new CompletionProposal[]{typeImportProposal});
4901
						
4902
						this.requestor.accept(proposal);
4903
						if(DEBUG) {
4904
							this.printDebug(proposal);
4905
						}
4906
					}
4907
				} else {
4908
					if (!this.isIgnored(CompletionProposal.METHOD_REF, CompletionProposal.METHOD_IMPORT)) {
4909
						CompletionProposal proposal = this.createProposal(CompletionProposal.METHOD_REF, this.actualCompletionPosition);
4910
						proposal.setDeclarationSignature(getSignature(method.declaringClass));
4911
						proposal.setSignature(getSignature(method));
4912
						MethodBinding original = method.original();
4913
						if(original != method) {
4914
							proposal.setOriginalSignature(getSignature(original));
4915
						}
4916
						proposal.setDeclarationPackageName(method.declaringClass.qualifiedPackageName());
4917
						proposal.setDeclarationTypeName(method.declaringClass.qualifiedSourceName());
4918
						proposal.setParameterPackageNames(parameterPackageNames);
4919
						proposal.setParameterTypeNames(parameterTypeNames);
4920
						proposal.setPackageName(method.returnType.qualifiedPackageName());
4921
						proposal.setTypeName(method.returnType.qualifiedSourceName());
4922
						proposal.setName(method.selector);
4923
						proposal.setCompletion(completion);
4924
						proposal.setFlags(method.modifiers);
4925
						proposal.setReplaceRange(this.startPosition - this.offset, this.endPosition - this.offset);
4926
						proposal.setRelevance(relevance);
4927
						if(parameterNames != null) proposal.setParameterNames(parameterNames);
4928
						
4929
						char[] methodImportCompletion = createImportCharArray(CharOperation.concat(typeName, method.selector, '.'), true, false);
4930
						
4931
						CompletionProposal methodImportProposal = this.createProposal(CompletionProposal.METHOD_IMPORT, this.actualCompletionPosition);
4932
						methodImportProposal.setDeclarationSignature(getSignature(method.declaringClass));
4933
						methodImportProposal.setSignature(getSignature(method));
4934
						if(original != method) {
4935
							proposal.setOriginalSignature(getSignature(original));
4936
						}
4937
						methodImportProposal.setDeclarationPackageName(method.declaringClass.qualifiedPackageName());
4938
						methodImportProposal.setDeclarationTypeName(method.declaringClass.qualifiedSourceName());
4939
						methodImportProposal.setParameterPackageNames(parameterPackageNames);
4940
						methodImportProposal.setParameterTypeNames(parameterTypeNames);
4941
						methodImportProposal.setPackageName(method.returnType.qualifiedPackageName());
4942
						methodImportProposal.setTypeName(method.returnType.qualifiedSourceName());
4943
						methodImportProposal.setName(method.selector);
4944
						methodImportProposal.setCompletion(methodImportCompletion);
4945
						methodImportProposal.setFlags(method.modifiers);
4946
						methodImportProposal.setAdditionalFlags(CompletionFlags.StaticImport);
4947
						methodImportProposal.setReplaceRange(importStart - this.offset, importEnd - this.offset);
4948
						methodImportProposal.setRelevance(relevance);
4949
						if(parameterNames != null) methodImportProposal.setParameterNames(parameterNames);
4950
						
4951
						proposal.setRequiredProposals(new CompletionProposal[]{methodImportProposal});
4952
						
4953
						this.requestor.accept(proposal);
4954
						if(DEBUG) {
4955
							this.printDebug(proposal);
4956
						}
4757
					}
4957
					}
4758
				}
4958
				}
4759
				
4959
				
Lines 5326-5331 Link Here
5326
			createType(type, completion);
5526
			createType(type, completion);
5327
		}
5527
		}
5328
	}
5528
	}
5529
	private char[] createImportCharArray(char[] importedElement, boolean isStatic, boolean onDemand) {
5530
		char[] result = IMPORT;
5531
		if (isStatic) {
5532
			result = CharOperation.concat(result, STATIC, ' ');
5533
		}
5534
		result = CharOperation.concat(result, importedElement, ' ');
5535
		if (onDemand) {
5536
			result = CharOperation.concat(result, ON_DEMAND);
5537
		}
5538
		return CharOperation.concat(result, IMPORT_END);
5539
	}
5329
	private void createMethod(MethodBinding method, char[][] parameterPackageNames, char[][] parameterTypeNames, char[][] parameterNames, StringBuffer completion) {
5540
	private void createMethod(MethodBinding method, char[][] parameterPackageNames, char[][] parameterTypeNames, char[][] parameterNames, StringBuffer completion) {
5330
		//// Modifiers
5541
		//// Modifiers
5331
		// flush uninteresting modifiers
5542
		// flush uninteresting modifiers
Lines 5404-5409 Link Here
5404
		return this.requestor.isIgnored(kind);
5615
		return this.requestor.isIgnored(kind);
5405
	}
5616
	}
5406
	
5617
	
5618
	private boolean isIgnored(int kind, int requiredProposalKind) {
5619
		return this.requestor.isIgnored(kind) ||
5620
			!this.requestor.isAllowingRequiredProposals(kind, requiredProposalKind);
5621
	}
5622
	
5407
	private void findMethods(
5623
	private void findMethods(
5408
		char[] selector,
5624
		char[] selector,
5409
		TypeBinding[] typeArgTypes,
5625
		TypeBinding[] typeArgTypes,
Lines 6845-6851 Link Here
6845
				}
7061
				}
6846
			}
7062
			}
6847
			
7063
			
6848
			boolean isStatic = this.compilerOptions.sourceLevel > ClassFileConstants.JDK1_4;
7064
			boolean isStatic = true;
6849
			
7065
			
6850
			ImportReference importReference =
7066
			ImportReference importReference =
6851
				new ImportReference(
7067
				new ImportReference(
Lines 6860-6873 Link Here
6860
				continue next;
7076
				continue next;
6861
			}
7077
			}
6862
			
7078
			
6863
			if (onDemand) {
7079
			if (importBinding instanceof PackageBinding) {
6864
				if (importReference.isStatic() && importBinding instanceof PackageBinding) {
7080
				continue next;
6865
					importReference.modifiers = importReference.modifiers & ~ClassFileConstants.AccStatic;
6866
				}
6867
			} else {
6868
				if (importBinding instanceof PackageBinding) {
6869
					continue next;
6870
				}
6871
			}
7081
			}
6872
			
7082
			
6873
			resolvedImports[count++] =
7083
			resolvedImports[count++] =
Lines 7878-7883 Link Here
7878
			case CompletionProposal.ANNOTATION_ATTRIBUTE_REF :
8088
			case CompletionProposal.ANNOTATION_ATTRIBUTE_REF :
7879
				buffer.append("ANNOTATION_ATTRIBUT_REF"); //$NON-NLS-1$
8089
				buffer.append("ANNOTATION_ATTRIBUT_REF"); //$NON-NLS-1$
7880
				break;
8090
				break;
8091
			case CompletionProposal.FIELD_IMPORT :
8092
				buffer.append("FIELD_IMPORT"); //$NON-NLS-1$
8093
				break;
8094
			case CompletionProposal.METHOD_IMPORT :
8095
				buffer.append("METHOD_IMPORT"); //$NON-NLS-1$
8096
				break;
8097
			case CompletionProposal.TYPE_IMPORT :
8098
				buffer.append("TYPE_IMPORT"); //$NON-NLS-1$
8099
				break;
7881
			default :
8100
			default :
7882
				buffer.append("PROPOSAL"); //$NON-NLS-1$
8101
				buffer.append("PROPOSAL"); //$NON-NLS-1$
7883
				break;
8102
				break;
(-)model/org/eclipse/jdt/core/CompletionFlags.java (+51 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.core;
12
13
/**
14
 * Utility class for decoding additional flags in completion proposal.
15
 * <p>
16
 * This class provides static methods only; it is not intended to be
17
 * instantiated or subclassed by clients.
18
 * </p>
19
 *
20
 * @see CompletionProposal#getAdditionalFlags()
21
 * 
22
 * @since 3.3
23
 */
24
public final class CompletionFlags {
25
	/**
26
	 * Constant representing the absence of any flag
27
	 */
28
	public static final int Default = 0x0000;
29
	
30
	/**
31
	 * Constant representing a static import
32
	 */
33
	public static final int StaticImport = 0x0001;
34
35
	/**
36
	 * Not instantiable.
37
	 */
38
	private CompletionFlags() {
39
		// Not instantiable
40
	}
41
	
42
	/**
43
	 * Returns whether the given integer includes the {@link #StaticImport} flag.
44
	 *
45
	 * @param flags the flags
46
	 * @return <code>true</code> if the {@link #StaticImport} flag is included
47
	 */
48
	public static boolean isStaticImport(int flags) {
49
		return (flags & StaticImport) != 0;
50
	}
51
}
(-)src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor2.java (-2 / +14 lines)
Lines 71-78 Link Here
71
	}
71
	}
72
	
72
	
73
	public void allowAllRequiredProposals() {
73
	public void allowAllRequiredProposals() {
74
		for (int i = CompletionProposal.ANONYMOUS_CLASS_DECLARATION; i <= CompletionProposal.JAVADOC_INLINE_TAG; i++) {
74
		for (int i = CompletionProposal.ANONYMOUS_CLASS_DECLARATION; i <= CompletionProposal.TYPE_IMPORT; i++) {
75
			for (int j = CompletionProposal.ANONYMOUS_CLASS_DECLARATION; j <= CompletionProposal.JAVADOC_INLINE_TAG; j++) {
75
			for (int j = CompletionProposal.ANONYMOUS_CLASS_DECLARATION; j <= CompletionProposal.TYPE_IMPORT; j++) {
76
				this.setAllowsRequiredProposals(i, j, true);
76
				this.setAllowsRequiredProposals(i, j, true);
77
			}
77
			}
78
		}
78
		}
Lines 289-294 Link Here
289
			case CompletionProposal.JAVADOC_VALUE_REF :
289
			case CompletionProposal.JAVADOC_VALUE_REF :
290
				buffer.append("JAVADOC_VALUE_REF"); //$NON-NLS-1$
290
				buffer.append("JAVADOC_VALUE_REF"); //$NON-NLS-1$
291
				break;
291
				break;
292
			case CompletionProposal.FIELD_IMPORT :
293
				buffer.append("FIELD_IMPORT"); //$NON-NLS-1$
294
				break;
295
			case CompletionProposal.METHOD_IMPORT :
296
				buffer.append("METHOD_IMPORT"); //$NON-NLS-1$
297
				break;
298
			case CompletionProposal.TYPE_IMPORT :
299
				buffer.append("TYPE_IMPORT"); //$NON-NLS-1$
300
				break;
292
			default :
301
			default :
293
				buffer.append("PROPOSAL"); //$NON-NLS-1$
302
				buffer.append("PROPOSAL"); //$NON-NLS-1$
294
				break;
303
				break;
Lines 412-417 Link Here
412
			case CompletionProposal.ANONYMOUS_CLASS_DECLARATION :
421
			case CompletionProposal.ANONYMOUS_CLASS_DECLARATION :
413
				return new String(Signature.getSignatureSimpleName(proposal.getDeclarationSignature()));
422
				return new String(Signature.getSignatureSimpleName(proposal.getDeclarationSignature()));
414
			case CompletionProposal.TYPE_REF :
423
			case CompletionProposal.TYPE_REF :
424
			case CompletionProposal.TYPE_IMPORT :
415
			case CompletionProposal.JAVADOC_TYPE_REF :
425
			case CompletionProposal.JAVADOC_TYPE_REF :
416
				return new String(Signature.getSignatureSimpleName(proposal.getSignature()));
426
				return new String(Signature.getSignatureSimpleName(proposal.getSignature()));
417
			case CompletionProposal.FIELD_REF :
427
			case CompletionProposal.FIELD_REF :
Lines 430-435 Link Here
430
			case CompletionProposal.JAVADOC_METHOD_REF :
440
			case CompletionProposal.JAVADOC_METHOD_REF :
431
			case CompletionProposal.JAVADOC_PARAM_REF :
441
			case CompletionProposal.JAVADOC_PARAM_REF :
432
			case CompletionProposal.JAVADOC_VALUE_REF :
442
			case CompletionProposal.JAVADOC_VALUE_REF :
443
			case CompletionProposal.FIELD_IMPORT :
444
			case CompletionProposal.METHOD_IMPORT :
433
				return new String(proposal.getName());
445
				return new String(proposal.getName());
434
			case CompletionProposal.PACKAGE_REF:
446
			case CompletionProposal.PACKAGE_REF:
435
				return new String(proposal.getDeclarationSignature());	
447
				return new String(proposal.getDeclarationSignature());	
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests.java (-40 / +332 lines)
Lines 13397-13412 Link Here
13397
			"    public static int foo;\n" +
13397
			"    public static int foo;\n" +
13398
			"}");
13398
			"}");
13399
	
13399
	
13400
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13400
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13401
	requestor.allowAllRequiredProposals();
13401
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13402
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13402
	
13403
	
13403
	String str = this.workingCopies[0].getSource();
13404
	String str = this.workingCopies[0].getSource();
13404
	String completeBehind = "foo";
13405
	String completeBehind = "foo";
13405
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13406
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13406
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13407
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13407
13408
	
13409
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13410
	int start1 = str.lastIndexOf("foo") + "".length();
13411
	int end1 = start1 + "foo".length();
13412
	int start2 = str.lastIndexOf("public class");
13413
	int end2 = start2 + "".length();
13408
	assertResults(
13414
	assertResults(
13409
			"foo[FIELD_REF]{test.p.ZZZ.foo, Ltest.p.ZZZ;, I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
13415
			"foo[FIELD_REF]{ZZZ.foo, Ltest.p.ZZZ;, I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13416
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
13410
			requestor.getResults());
13417
			requestor.getResults());
13411
}
13418
}
13412
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13419
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 13428-13434 Link Here
13428
			"    public static int foo(){}\n" +
13435
			"    public static int foo(){}\n" +
13429
			"}");
13436
			"}");
13430
	
13437
	
13431
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13438
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13439
	requestor.allowAllRequiredProposals();
13432
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13440
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13433
	
13441
	
13434
	String str = this.workingCopies[0].getSource();
13442
	String str = this.workingCopies[0].getSource();
Lines 13436-13443 Link Here
13436
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13444
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13437
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13445
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13438
13446
13447
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13448
	int start1 = str.lastIndexOf("foo") + "".length();
13449
	int end1 = start1 + "foo".length();
13450
	int start2 = str.lastIndexOf("public class");
13451
	int end2 = start2 + "".length();
13439
	assertResults(
13452
	assertResults(
13440
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
13453
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13454
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
13441
			requestor.getResults());
13455
			requestor.getResults());
13442
}
13456
}
13443
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13457
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 13459-13465 Link Here
13459
			"    public static int foo;\n" +
13473
			"    public static int foo;\n" +
13460
			"}");
13474
			"}");
13461
	
13475
	
13462
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13476
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13477
	requestor.allowAllRequiredProposals();
13463
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ"});
13478
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ"});
13464
	
13479
	
13465
	String str = this.workingCopies[0].getSource();
13480
	String str = this.workingCopies[0].getSource();
Lines 13490-13496 Link Here
13490
			"    public static int foo(){}\n" +
13505
			"    public static int foo(){}\n" +
13491
			"}");
13506
			"}");
13492
	
13507
	
13493
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13508
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13509
	requestor.allowAllRequiredProposals();
13494
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ"});
13510
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ"});
13495
	
13511
	
13496
	String str = this.workingCopies[0].getSource();
13512
	String str = this.workingCopies[0].getSource();
Lines 13521-13527 Link Here
13521
			"    public static int foo;\n" +
13537
			"    public static int foo;\n" +
13522
			"}");
13538
			"}");
13523
	
13539
	
13524
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13540
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13541
	requestor.allowAllRequiredProposals();
13525
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
13542
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
13526
	
13543
	
13527
	String str = this.workingCopies[0].getSource();
13544
	String str = this.workingCopies[0].getSource();
Lines 13529-13536 Link Here
13529
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13546
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13530
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13547
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13531
13548
13549
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13550
	int start1 = str.lastIndexOf("foo") + "".length();
13551
	int end1 = start1 + "foo".length();
13552
	int start2 = str.lastIndexOf("public class");
13553
	int end2 = start2 + "".length();
13532
	assertResults(
13554
	assertResults(
13533
			"",
13555
			"foo[FIELD_REF]{ZZZ.foo, Ltest.p.ZZZ;, I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13556
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
13534
			requestor.getResults());
13557
			requestor.getResults());
13535
}
13558
}
13536
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13559
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 13552-13558 Link Here
13552
			"    public static int foo(){}\n" +
13575
			"    public static int foo(){}\n" +
13553
			"}");
13576
			"}");
13554
	
13577
	
13555
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13578
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13579
	requestor.allowAllRequiredProposals();
13556
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
13580
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
13557
	
13581
	
13558
	String str = this.workingCopies[0].getSource();
13582
	String str = this.workingCopies[0].getSource();
Lines 13560-13567 Link Here
13560
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13584
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13561
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13585
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13562
13586
13587
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13588
	int start1 = str.lastIndexOf("foo") + "".length();
13589
	int end1 = start1 + "foo".length();
13590
	int start2 = str.lastIndexOf("public class");
13591
	int end2 = start2 + "".length();
13563
	assertResults(
13592
	assertResults(
13564
			"",
13593
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13594
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
13565
			requestor.getResults());
13595
			requestor.getResults());
13566
}
13596
}
13567
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13597
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 13584-13590 Link Here
13584
			"    public static int foo(){}\n" +
13614
			"    public static int foo(){}\n" +
13585
			"}");
13615
			"}");
13586
	
13616
	
13587
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13617
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13618
	requestor.allowAllRequiredProposals();
13588
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13619
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13589
	
13620
	
13590
	String str = this.workingCopies[0].getSource();
13621
	String str = this.workingCopies[0].getSource();
Lines 13592-13599 Link Here
13592
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13623
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13593
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13624
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13594
13625
13626
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13627
	int start1 = str.lastIndexOf("foo") + "".length();
13628
	int end1 = start1 + "foo".length();
13629
	int start2 = str.lastIndexOf("public class");
13630
	int end2 = start2 + "".length();
13595
	assertResults(
13631
	assertResults(
13596
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
13632
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13633
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
13597
			requestor.getResults());
13634
			requestor.getResults());
13598
}
13635
}
13599
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13636
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 13616-13622 Link Here
13616
			"    public static int foo(){}\n" +
13653
			"    public static int foo(){}\n" +
13617
			"}");
13654
			"}");
13618
	
13655
	
13619
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13656
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13657
	requestor.allowAllRequiredProposals();
13620
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
13658
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
13621
	
13659
	
13622
	String str = this.workingCopies[0].getSource();
13660
	String str = this.workingCopies[0].getSource();
Lines 13624-13631 Link Here
13624
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13662
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13625
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13663
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13626
13664
13665
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13666
	int start1 = str.lastIndexOf("foo") + "".length();
13667
	int end1 = start1 + "foo".length();
13668
	int start2 = str.lastIndexOf("public class");
13669
	int end2 = start2 + "".length();
13627
	assertResults(
13670
	assertResults(
13628
			"",
13671
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13672
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
13629
			requestor.getResults());
13673
			requestor.getResults());
13630
}
13674
}
13631
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13675
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 13648-13654 Link Here
13648
			"    public static int foo(){}\n" +
13692
			"    public static int foo(){}\n" +
13649
			"}");
13693
			"}");
13650
	
13694
	
13651
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13695
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13696
	requestor.allowAllRequiredProposals();
13652
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13697
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13653
	
13698
	
13654
	String str = this.workingCopies[0].getSource();
13699
	String str = this.workingCopies[0].getSource();
Lines 13656-13663 Link Here
13656
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13701
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13657
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13702
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13658
13703
13704
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13705
	int start1 = str.lastIndexOf("foo") + "".length();
13706
	int end1 = start1 + "foo".length();
13707
	int start2 = str.lastIndexOf("public class");
13708
	int end2 = start2 + "".length();
13659
	assertResults(
13709
	assertResults(
13660
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
13710
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13711
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
13661
			requestor.getResults());
13712
			requestor.getResults());
13662
}
13713
}
13663
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13714
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 13680-13686 Link Here
13680
			"    public static int foo(){}\n" +
13731
			"    public static int foo(){}\n" +
13681
			"}");
13732
			"}");
13682
	
13733
	
13683
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13734
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13735
	requestor.allowAllRequiredProposals();
13684
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
13736
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
13685
	
13737
	
13686
	String str = this.workingCopies[0].getSource();
13738
	String str = this.workingCopies[0].getSource();
Lines 13688-13695 Link Here
13688
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13740
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13689
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13741
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13690
13742
13743
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13744
	int start1 = str.lastIndexOf("foo") + "".length();
13745
	int end1 = start1 + "foo".length();
13746
	int start2 = str.lastIndexOf("public class");
13747
	int end2 = start2 + "".length();
13691
	assertResults(
13748
	assertResults(
13692
			"",
13749
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13750
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
13693
			requestor.getResults());
13751
			requestor.getResults());
13694
}
13752
}
13695
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13753
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 13713-13729 Link Here
13713
			"    public static int foo(){}\n" +
13771
			"    public static int foo(){}\n" +
13714
			"}");
13772
			"}");
13715
	
13773
	
13716
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13774
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13775
	requestor.allowAllRequiredProposals();
13717
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13776
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13718
	
13777
	
13719
	String str = this.workingCopies[0].getSource();
13778
	String str = this.workingCopies[0].getSource();
13720
	String completeBehind = "foo";
13779
	String completeBehind = "foo";
13721
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13780
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13722
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13781
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13723
13782
	
13724
	assertResults(
13783
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13725
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
13784
	int start1 = str.lastIndexOf("foo") + "".length();
13726
			"Test.foo[TYPE_REF]{foo, test, Ltest.Test$foo;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
13785
	int end1 = start1 + "foo".length();
13786
	int start2 = str.lastIndexOf("public class Test");
13787
	int end2 = start2 + "".length();
13788
	assertResults(
13789
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13790
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}\n"+
13791
			"Test.foo[TYPE_REF]{foo, test, Ltest.Test$foo;, null, null, ["+start1+", "+end1+"], "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
13727
			requestor.getResults());
13792
			requestor.getResults());
13728
}
13793
}
13729
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13794
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 13745-13751 Link Here
13745
			"    public static int foo(){}\n" +
13810
			"    public static int foo(){}\n" +
13746
			"}");
13811
			"}");
13747
	
13812
	
13748
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13813
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13814
	requestor.allowAllRequiredProposals();
13749
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13815
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13750
	
13816
	
13751
	String str = this.workingCopies[0].getSource();
13817
	String str = this.workingCopies[0].getSource();
Lines 13753-13761 Link Here
13753
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13819
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13754
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13820
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13755
13821
13822
	int start1 = str.lastIndexOf("foo") + "".length();
13823
	int end1 = start1 + "foo".length();
13756
	assertResults(
13824
	assertResults(
13757
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
13825
			"foo[METHOD_REF]{foo(), Ltest.Test;, ()V, foo, null, ["+start1+", "+end1+"], "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
13758
			"foo[METHOD_REF]{foo(), Ltest.Test;, ()V, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
13759
			requestor.getResults());
13826
			requestor.getResults());
13760
}
13827
}
13761
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13828
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 13778-13784 Link Here
13778
			"    public static int foo(){}\n" +
13845
			"    public static int foo(){}\n" +
13779
			"}");
13846
			"}");
13780
	
13847
	
13781
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13848
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13849
	requestor.allowAllRequiredProposals();
13782
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13850
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13783
	
13851
	
13784
	String str = this.workingCopies[0].getSource();
13852
	String str = this.workingCopies[0].getSource();
Lines 13786-13794 Link Here
13786
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13854
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13787
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13855
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13788
13856
13789
	assertResults(
13857
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13790
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
13858
	int start1 = str.lastIndexOf("foo") + "".length();
13791
			"foo[FIELD_REF]{foo, Ltest.Test;, I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
13859
	int end1 = start1 + "foo".length();
13860
	int start2 = str.lastIndexOf("public class Test");
13861
	int end2 = start2 + "".length();
13862
	assertResults(
13863
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13864
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}\n"+
13865
			"foo[FIELD_REF]{foo, Ltest.Test;, I, foo, null, ["+start1+", "+end1+"], "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
13792
			requestor.getResults());
13866
			requestor.getResults());
13793
}
13867
}
13794
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13868
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 13811-13817 Link Here
13811
			"    public static int foo(){}\n" +
13885
			"    public static int foo(){}\n" +
13812
			"}");
13886
			"}");
13813
	
13887
	
13814
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13888
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13889
	requestor.allowAllRequiredProposals();
13815
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13890
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13816
	
13891
	
13817
	String str = this.workingCopies[0].getSource();
13892
	String str = this.workingCopies[0].getSource();
Lines 13819-13827 Link Here
13819
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13894
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13820
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13895
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13821
13896
13822
	assertResults(
13897
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13823
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
13898
	int start1 = str.lastIndexOf("foo") + "".length();
13824
			"foo[LOCAL_VARIABLE_REF]{foo, null, I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
13899
	int end1 = start1 + "foo".length();
13900
	int start2 = str.lastIndexOf("public class Test");
13901
	int end2 = start2 + "".length();
13902
	assertResults(
13903
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13904
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}\n"+
13905
			"foo[LOCAL_VARIABLE_REF]{foo, null, I, foo, null, ["+start1+", "+end1+"], "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
13825
			requestor.getResults());
13906
			requestor.getResults());
13826
}
13907
}
13827
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13908
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 13844-13850 Link Here
13844
			"    public static int foo(int i){}\n" +
13925
			"    public static int foo(int i){}\n" +
13845
			"}");
13926
			"}");
13846
	
13927
	
13847
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13928
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13929
	requestor.allowAllRequiredProposals();
13848
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13930
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13849
	
13931
	
13850
	String str = this.workingCopies[0].getSource();
13932
	String str = this.workingCopies[0].getSource();
Lines 13852-13860 Link Here
13852
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13934
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13853
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13935
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13854
13936
13855
	assertResults(
13937
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
13856
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
13938
	int start1 = str.lastIndexOf("foo") + "".length();
13857
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, (I)I, foo, (i), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
13939
	int end1 = start1 + "foo".length();
13940
	int start2 = str.lastIndexOf("public class Test");
13941
	int end2 = start2 + "".length();
13942
	assertResults(
13943
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13944
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}\n"+
13945
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, (I)I, foo, (i), ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
13946
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
13858
			requestor.getResults());
13947
			requestor.getResults());
13859
}
13948
}
13860
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13949
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 13876-13882 Link Here
13876
			"    public static int foo(){}\n" +
13965
			"    public static int foo(){}\n" +
13877
			"}");
13966
			"}");
13878
	
13967
	
13879
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13968
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
13969
	requestor.allowAllRequiredProposals();
13880
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13970
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
13881
	
13971
	
13882
	String str = this.workingCopies[0].getSource();
13972
	String str = this.workingCopies[0].getSource();
Lines 13888-13891 Link Here
13888
			"",
13978
			"",
13889
			requestor.getResults());
13979
			requestor.getResults());
13890
}
13980
}
13981
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
13982
public void testFavoriteImports023() throws JavaModelException {
13983
	this.workingCopies = new ICompilationUnit[2];
13984
	this.workingCopies[0] = getWorkingCopy(
13985
			"/Completion/src3/test/Test.java",
13986
			"package test;\n" +
13987
			"/** */\n" +
13988
			"public class Test {\n" +
13989
			"    public void method() {\n" +
13990
			"        foo\n" +
13991
			"    }\n" +
13992
			"}");
13993
	
13994
	this.workingCopies[1] = getWorkingCopy(
13995
			"/Completion/src3/test/p/ZZZ.java",
13996
			"package test.p;\n" +
13997
			"public class ZZZ {\n" +
13998
			"    public static int foo;\n" +
13999
			"}");
14000
	
14001
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14002
	requestor.allowAllRequiredProposals();
14003
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
14004
	
14005
	String str = this.workingCopies[0].getSource();
14006
	String completeBehind = "foo";
14007
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14008
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14009
14010
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
14011
	int start1 = str.lastIndexOf("foo") + "".length();
14012
	int end1 = start1 + "foo".length();
14013
	int start2 = str.lastIndexOf("/** */");
14014
	int end2 = start2 + "".length();
14015
	assertResults(
14016
			"foo[FIELD_REF]{ZZZ.foo, Ltest.p.ZZZ;, I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
14017
			"   ZZZ[TYPE_IMPORT]{import test.p.ZZZ;\n, test.p, Ltest.p.ZZZ;, null, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
14018
			requestor.getResults());
14019
}
14020
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14021
public void testFavoriteImports024() throws JavaModelException {
14022
	this.workingCopies = new ICompilationUnit[2];
14023
	this.workingCopies[0] = getWorkingCopy(
14024
			"/Completion/src3/test/Test.java",
14025
			"package test;\n" +
14026
			"public class Test {\n" +
14027
			"    public void method() {\n" +
14028
			"        foo\n" +
14029
			"    }\n" +
14030
			"}");
14031
	
14032
	this.workingCopies[1] = getWorkingCopy(
14033
			"/Completion/src3/test/p/ZZZ.java",
14034
			"package test.p;\n" +
14035
			"public class ZZZ {\n" +
14036
			"    public int foo;\n" +
14037
			"}");
14038
	
14039
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14040
	requestor.allowAllRequiredProposals();
14041
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
14042
	
14043
	String str = this.workingCopies[0].getSource();
14044
	String completeBehind = "foo";
14045
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14046
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14047
14048
	assertResults(
14049
			"",
14050
			requestor.getResults());
14051
}
14052
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14053
public void testFavoriteImports025() throws JavaModelException {
14054
	this.workingCopies = new ICompilationUnit[2];
14055
	this.workingCopies[0] = getWorkingCopy(
14056
			"/Completion/src3/test/Test.java",
14057
			"package test;\n" +
14058
			"public class Test {\n" +
14059
			"    public void method() {\n" +
14060
			"        foo\n" +
14061
			"    }\n" +
14062
			"}");
14063
	
14064
	this.workingCopies[1] = getWorkingCopy(
14065
			"/Completion/src3/test/p/ZZZ.java",
14066
			"package test.p;\n" +
14067
			"public class ZZZ {\n" +
14068
			"    public int foo;\n" +
14069
			"}");
14070
	
14071
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14072
	requestor.allowAllRequiredProposals();
14073
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
14074
	
14075
	String str = this.workingCopies[0].getSource();
14076
	String completeBehind = "foo";
14077
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14078
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14079
14080
	assertResults(
14081
			"",
14082
			requestor.getResults());
14083
}
14084
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14085
public void testFavoriteImports026() throws JavaModelException {
14086
	this.workingCopies = new ICompilationUnit[2];
14087
	this.workingCopies[0] = getWorkingCopy(
14088
			"/Completion/src3/test/Test.java",
14089
			"package test;\n" +
14090
			"public class Test {\n" +
14091
			"    public void method() {\n" +
14092
			"        foo\n" +
14093
			"    }\n" +
14094
			"}");
14095
	
14096
	this.workingCopies[1] = getWorkingCopy(
14097
			"/Completion/src3/test/p/ZZZ.java",
14098
			"package test.p;\n" +
14099
			"public class ZZZ {\n" +
14100
			"    public int foo(){return 0;};\n" +
14101
			"}");
14102
	
14103
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14104
	requestor.allowAllRequiredProposals();
14105
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
14106
	
14107
	String str = this.workingCopies[0].getSource();
14108
	String completeBehind = "foo";
14109
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14110
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14111
14112
	assertResults(
14113
			"",
14114
			requestor.getResults());
14115
}
14116
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14117
public void testFavoriteImports027() throws JavaModelException {
14118
	this.workingCopies = new ICompilationUnit[2];
14119
	this.workingCopies[0] = getWorkingCopy(
14120
			"/Completion/src3/test/Test.java",
14121
			"package test;\n" +
14122
			"public class Test {\n" +
14123
			"    public void method() {\n" +
14124
			"        foo\n" +
14125
			"    }\n" +
14126
			"}");
14127
	
14128
	this.workingCopies[1] = getWorkingCopy(
14129
			"/Completion/src3/test/p/ZZZ.java",
14130
			"package test.p;\n" +
14131
			"public class ZZZ {\n" +
14132
			"    public int foo(){return 0;};\n" +
14133
			"}");
14134
	
14135
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14136
	requestor.allowAllRequiredProposals();
14137
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
14138
	
14139
	String str = this.workingCopies[0].getSource();
14140
	String completeBehind = "foo";
14141
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14142
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14143
14144
	assertResults(
14145
			"",
14146
			requestor.getResults());
14147
}
14148
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14149
public void testFavoriteImports028() throws JavaModelException {
14150
	this.workingCopies = new ICompilationUnit[2];
14151
	this.workingCopies[0] = getWorkingCopy(
14152
			"/Completion/src3/test/Test.java",
14153
			"package test;\n" +
14154
			"import test.p.ZZZ;\n" +
14155
			"public class Test {\n" +
14156
			"    public void method() {\n" +
14157
			"        foo\n" +
14158
			"    }\n" +
14159
			"}");
14160
	
14161
	this.workingCopies[1] = getWorkingCopy(
14162
			"/Completion/src3/test/p/ZZZ.java",
14163
			"package test.p;\n" +
14164
			"public class ZZZ {\n" +
14165
			"    public static int foo(){return 0;};\n" +
14166
			"}");
14167
	
14168
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
14169
	requestor.allowAllRequiredProposals();
14170
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
14171
	
14172
	String str = this.workingCopies[0].getSource();
14173
	String completeBehind = "foo";
14174
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
14175
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
14176
14177
	int start1 = str.lastIndexOf("foo") + "".length();
14178
	int end1 = start1 + "foo".length();
14179
	assertResults(
14180
			"foo[METHOD_REF]{ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}",
14181
			requestor.getResults());
14182
}
13891
}
14183
}
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java (-55 / +372 lines)
Lines 9444-9450 Link Here
9444
			"    public static int foo;\n" +
9444
			"    public static int foo;\n" +
9445
			"}");
9445
			"}");
9446
	
9446
	
9447
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9447
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
9448
	requestor.allowAllRequiredProposals();
9448
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9449
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9449
	
9450
	
9450
	String str = this.workingCopies[0].getSource();
9451
	String str = this.workingCopies[0].getSource();
Lines 9452-9459 Link Here
9452
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9453
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9453
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9454
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9454
9455
9456
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
9457
	int start1 = str.lastIndexOf("foo") + "".length();
9458
	int end1 = start1 + "foo".length();
9459
	int start2 = str.lastIndexOf("public class");
9460
	int end2 = start2 + "".length();
9455
	assertResults(
9461
	assertResults(
9456
			"foo[FIELD_REF]{test.p.ZZZ.foo, Ltest.p.ZZZ;, I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
9462
			"foo[FIELD_REF]{foo, Ltest.p.ZZZ;, I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
9463
			"   foo[FIELD_IMPORT]{import static test.p.ZZZ.foo;\n, Ltest.p.ZZZ;, I, foo, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
9457
			requestor.getResults());
9464
			requestor.getResults());
9458
}
9465
}
9459
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9466
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 9475-9490 Link Here
9475
			"    public static int foo(){}\n" +
9482
			"    public static int foo(){}\n" +
9476
			"}");
9483
			"}");
9477
	
9484
	
9478
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9485
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
9486
	requestor.allowAllRequiredProposals();
9479
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9487
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9480
	
9488
	
9481
	String str = this.workingCopies[0].getSource();
9489
	String str = this.workingCopies[0].getSource();
9482
	String completeBehind = "foo";
9490
	String completeBehind = "foo";
9483
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9491
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9484
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9492
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9485
9493
	
9494
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
9495
	int start1 = str.lastIndexOf("foo") + "".length();
9496
	int end1 = start1 + "foo".length();
9497
	int start2 = str.lastIndexOf("public class");
9498
	int end2 = start2 + "".length();
9486
	assertResults(
9499
	assertResults(
9487
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
9500
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
9501
			"   foo[METHOD_IMPORT]{import static test.p.ZZZ.foo;\n, Ltest.p.ZZZ;, ()I, foo, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
9488
			requestor.getResults());
9502
			requestor.getResults());
9489
}
9503
}
9490
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9504
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 9506-9512 Link Here
9506
			"    public static int foo;\n" +
9520
			"    public static int foo;\n" +
9507
			"}");
9521
			"}");
9508
	
9522
	
9509
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9523
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
9524
	requestor.allowAllRequiredProposals();
9510
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ"});
9525
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ"});
9511
	
9526
	
9512
	String str = this.workingCopies[0].getSource();
9527
	String str = this.workingCopies[0].getSource();
Lines 9537-9543 Link Here
9537
			"    public static int foo(){}\n" +
9552
			"    public static int foo(){}\n" +
9538
			"}");
9553
			"}");
9539
	
9554
	
9540
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9555
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
9556
	requestor.allowAllRequiredProposals();
9541
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ"});
9557
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ"});
9542
	
9558
	
9543
	String str = this.workingCopies[0].getSource();
9559
	String str = this.workingCopies[0].getSource();
Lines 9568-9583 Link Here
9568
			"    public static int foo;\n" +
9584
			"    public static int foo;\n" +
9569
			"}");
9585
			"}");
9570
	
9586
	
9571
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9587
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
9588
	requestor.allowAllRequiredProposals();
9572
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
9589
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
9573
	
9590
	
9574
	String str = this.workingCopies[0].getSource();
9591
	String str = this.workingCopies[0].getSource();
9575
	String completeBehind = "foo";
9592
	String completeBehind = "foo";
9576
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9593
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9577
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9594
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9578
9595
	
9596
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
9597
	int start1 = str.lastIndexOf("foo") + "".length();
9598
	int end1 = start1 + "foo".length();
9599
	int start2 = str.lastIndexOf("public class");
9600
	int end2 = start2 + "".length();
9579
	assertResults(
9601
	assertResults(
9580
			"foo[FIELD_REF]{test.p.ZZZ.foo, Ltest.p.ZZZ;, I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
9602
			"foo[FIELD_REF]{foo, Ltest.p.ZZZ;, I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
9603
			"   foo[FIELD_IMPORT]{import static test.p.ZZZ.foo;\n, Ltest.p.ZZZ;, I, foo, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
9581
			requestor.getResults());
9604
			requestor.getResults());
9582
}
9605
}
9583
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9606
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 9599-9605 Link Here
9599
			"    public static int foo(){}\n" +
9622
			"    public static int foo(){}\n" +
9600
			"}");
9623
			"}");
9601
	
9624
	
9602
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9625
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
9626
	requestor.allowAllRequiredProposals();
9603
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
9627
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
9604
	
9628
	
9605
	String str = this.workingCopies[0].getSource();
9629
	String str = this.workingCopies[0].getSource();
Lines 9607-9614 Link Here
9607
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9631
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9608
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9632
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9609
9633
9634
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
9635
	int start1 = str.lastIndexOf("foo") + "".length();
9636
	int end1 = start1 + "foo".length();
9637
	int start2 = str.lastIndexOf("public class");
9638
	int end2 = start2 + "".length();
9610
	assertResults(
9639
	assertResults(
9611
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
9640
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
9641
			"   foo[METHOD_IMPORT]{import static test.p.ZZZ.foo;\n, Ltest.p.ZZZ;, ()I, foo, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
9612
			requestor.getResults());
9642
			requestor.getResults());
9613
}
9643
}
9614
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9644
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 9631-9637 Link Here
9631
			"    public static int foo(){}\n" +
9661
			"    public static int foo(){}\n" +
9632
			"}");
9662
			"}");
9633
	
9663
	
9634
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9664
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
9665
	requestor.allowAllRequiredProposals();
9635
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9666
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9636
	
9667
	
9637
	String str = this.workingCopies[0].getSource();
9668
	String str = this.workingCopies[0].getSource();
Lines 9639-9646 Link Here
9639
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9670
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9640
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9671
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9641
9672
9673
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
9674
	int start1 = str.lastIndexOf("foo") + "".length();
9675
	int end1 = start1 + "foo".length();
9676
	int start2 = str.lastIndexOf("public class");
9677
	int end2 = start2 + "".length();
9642
	assertResults(
9678
	assertResults(
9643
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
9679
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
9680
			"   foo[METHOD_IMPORT]{import static test.p.ZZZ.foo;\n, Ltest.p.ZZZ;, ()I, foo, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
9644
			requestor.getResults());
9681
			requestor.getResults());
9645
}
9682
}
9646
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9683
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 9663-9678 Link Here
9663
			"    public static int foo(){}\n" +
9700
			"    public static int foo(){}\n" +
9664
			"}");
9701
			"}");
9665
	
9702
	
9666
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9703
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
9704
	requestor.allowAllRequiredProposals();
9667
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9705
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9668
	
9706
	
9669
	String str = this.workingCopies[0].getSource();
9707
	String str = this.workingCopies[0].getSource();
9670
	String completeBehind = "foo";
9708
	String completeBehind = "foo";
9671
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9709
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9672
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9710
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9673
9711
	
9712
	int start1 = str.lastIndexOf("foo") + "".length();
9713
	int end1 = start1 + "foo".length();
9674
	assertResults(
9714
	assertResults(
9675
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED +R_NON_RESTRICTED)+"}",
9715
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED +R_NON_RESTRICTED)+"}",
9676
			requestor.getResults());
9716
			requestor.getResults());
9677
}
9717
}
9678
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9718
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 9695-9701 Link Here
9695
			"    public static int foo(){}\n" +
9735
			"    public static int foo(){}\n" +
9696
			"}");
9736
			"}");
9697
	
9737
	
9698
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9738
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
9739
	requestor.allowAllRequiredProposals();
9699
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
9740
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
9700
	
9741
	
9701
	String str = this.workingCopies[0].getSource();
9742
	String str = this.workingCopies[0].getSource();
Lines 9703-9710 Link Here
9703
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9744
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9704
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9745
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9705
9746
9747
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
9748
	int start1 = str.lastIndexOf("foo") + "".length();
9749
	int end1 = start1 + "foo".length();
9750
	int start2 = str.lastIndexOf("public class");
9751
	int end2 = start2 + "".length();
9706
	assertResults(
9752
	assertResults(
9707
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
9753
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
9754
			"   foo[METHOD_IMPORT]{import static test.p.ZZZ.foo;\n, Ltest.p.ZZZ;, ()I, foo, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
9708
			requestor.getResults());
9755
			requestor.getResults());
9709
}
9756
}
9710
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9757
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 9727-9733 Link Here
9727
			"    public static int foo(){}\n" +
9774
			"    public static int foo(){}\n" +
9728
			"}");
9775
			"}");
9729
	
9776
	
9730
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9777
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
9778
	requestor.allowAllRequiredProposals();
9731
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
9779
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
9732
	
9780
	
9733
	String str = this.workingCopies[0].getSource();
9781
	String str = this.workingCopies[0].getSource();
Lines 9735-9742 Link Here
9735
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9783
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9736
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9784
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9737
9785
9786
	int start1 = str.lastIndexOf("foo") + "".length();
9787
	int end1 = start1 + "foo".length();
9738
	assertResults(
9788
	assertResults(
9739
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
9789
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED +R_NON_RESTRICTED)+"}",
9740
			requestor.getResults());
9790
			requestor.getResults());
9741
}
9791
}
9742
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9792
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 9759-9765 Link Here
9759
			"    public static int foo(){}\n" +
9809
			"    public static int foo(){}\n" +
9760
			"}");
9810
			"}");
9761
	
9811
	
9762
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9812
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
9813
	requestor.allowAllRequiredProposals();
9763
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9814
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9764
	
9815
	
9765
	String str = this.workingCopies[0].getSource();
9816
	String str = this.workingCopies[0].getSource();
Lines 9767-9774 Link Here
9767
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9818
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9768
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9819
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9769
9820
9821
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
9822
	int start1 = str.lastIndexOf("foo") + "".length();
9823
	int end1 = start1 + "foo".length();
9824
	int start2 = str.lastIndexOf("public class");
9825
	int end2 = start2 + "".length();
9770
	assertResults(
9826
	assertResults(
9771
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
9827
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
9828
			"   foo[METHOD_IMPORT]{import static test.p.ZZZ.foo;\n, Ltest.p.ZZZ;, ()I, foo, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
9772
			requestor.getResults());
9829
			requestor.getResults());
9773
}
9830
}
9774
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9831
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 9791-9797 Link Here
9791
			"    public static int foo(){}\n" +
9848
			"    public static int foo(){}\n" +
9792
			"}");
9849
			"}");
9793
	
9850
	
9794
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9851
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
9852
	requestor.allowAllRequiredProposals();
9795
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9853
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9796
	
9854
	
9797
	String str = this.workingCopies[0].getSource();
9855
	String str = this.workingCopies[0].getSource();
Lines 9799-9806 Link Here
9799
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9857
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9800
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9858
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9801
9859
9860
	int start1 = str.lastIndexOf("foo") + "".length();
9861
	int end1 = start1 + "foo".length();
9802
	assertResults(
9862
	assertResults(
9803
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
9863
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED +R_NON_RESTRICTED)+"}",
9804
			requestor.getResults());
9864
			requestor.getResults());
9805
}
9865
}
9806
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9866
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 9823-9829 Link Here
9823
			"    public static int foo(){}\n" +
9883
			"    public static int foo(){}\n" +
9824
			"}");
9884
			"}");
9825
	
9885
	
9826
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9886
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
9887
	requestor.allowAllRequiredProposals();
9827
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
9888
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
9828
	
9889
	
9829
	String str = this.workingCopies[0].getSource();
9890
	String str = this.workingCopies[0].getSource();
Lines 9831-9838 Link Here
9831
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9892
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9832
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9893
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9833
9894
9895
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
9896
	int start1 = str.lastIndexOf("foo") + "".length();
9897
	int end1 = start1 + "foo".length();
9898
	int start2 = str.lastIndexOf("public class");
9899
	int end2 = start2 + "".length();
9834
	assertResults(
9900
	assertResults(
9835
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
9901
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
9902
			"   foo[METHOD_IMPORT]{import static test.p.ZZZ.foo;\n, Ltest.p.ZZZ;, ()I, foo, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
9836
			requestor.getResults());
9903
			requestor.getResults());
9837
}
9904
}
9838
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9905
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 9855-9861 Link Here
9855
			"    public static int foo(){}\n" +
9922
			"    public static int foo(){}\n" +
9856
			"}");
9923
			"}");
9857
	
9924
	
9858
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9925
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
9926
	requestor.allowAllRequiredProposals();
9859
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
9927
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
9860
	
9928
	
9861
	String str = this.workingCopies[0].getSource();
9929
	String str = this.workingCopies[0].getSource();
Lines 9863-9870 Link Here
9863
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9931
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9864
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9932
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9865
9933
9934
	int start1 = str.lastIndexOf("foo") + "".length();
9935
	int end1 = start1 + "foo".length();
9866
	assertResults(
9936
	assertResults(
9867
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
9937
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED +R_NON_RESTRICTED)+"}",
9868
			requestor.getResults());
9938
			requestor.getResults());
9869
}
9939
}
9870
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9940
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 9894-9900 Link Here
9894
			"    public static int foo(){}\n" +
9964
			"    public static int foo(){}\n" +
9895
			"}");
9965
			"}");
9896
	
9966
	
9897
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
9967
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
9968
	requestor.allowAllRequiredProposals();
9898
	requestor.setFavoriteReferences(new String[]{"test.q.ZZZ2.foo"});
9969
	requestor.setFavoriteReferences(new String[]{"test.q.ZZZ2.foo"});
9899
	
9970
	
9900
	String str = this.workingCopies[0].getSource();
9971
	String str = this.workingCopies[0].getSource();
Lines 9902-9910 Link Here
9902
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9973
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9903
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9974
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9904
9975
9976
	int start1 = str.lastIndexOf("foo") + "".length();
9977
	int end1 = start1 + "foo".length();
9905
	assertResults(
9978
	assertResults(
9906
			"foo[METHOD_REF]{test.q.ZZZ2.foo(), Ltest.q.ZZZ2;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
9979
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
9907
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
9908
			requestor.getResults());
9980
			requestor.getResults());
9909
}
9981
}
9910
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
9982
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 9928-9944 Link Here
9928
			"    public static int foo(){}\n" +
10000
			"    public static int foo(){}\n" +
9929
			"}");
10001
			"}");
9930
	
10002
	
9931
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10003
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
10004
	requestor.allowAllRequiredProposals();
9932
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
10005
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9933
	
10006
	
9934
	String str = this.workingCopies[0].getSource();
10007
	String str = this.workingCopies[0].getSource();
9935
	String completeBehind = "foo";
10008
	String completeBehind = "foo";
9936
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10009
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9937
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10010
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9938
10011
	
9939
	assertResults(
10012
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
9940
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
10013
	int start1 = str.lastIndexOf("foo") + "".length();
9941
			"Test.foo[TYPE_REF]{foo, test, Ltest.Test$foo;, null, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
10014
	int end1 = start1 + "foo".length();
10015
	int start2 = str.lastIndexOf("public class Test");
10016
	int end2 = start2 + "".length();
10017
	assertResults(
10018
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], " + (relevance1) + "}\n" +
10019
			"   foo[METHOD_IMPORT]{import static test.p.ZZZ.foo;\n, Ltest.p.ZZZ;, ()I, foo, null, ["+start2+", "+end2+"], " + (relevance1) + "}\n" +
10020
			"Test.foo[TYPE_REF]{foo, test, Ltest.Test$foo;, null, null, ["+start1+", "+end1+"], "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
9942
			requestor.getResults());
10021
			requestor.getResults());
9943
}
10022
}
9944
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
10023
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 9960-9966 Link Here
9960
			"    public static int foo(){}\n" +
10039
			"    public static int foo(){}\n" +
9961
			"}");
10040
			"}");
9962
	
10041
	
9963
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10042
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
10043
	requestor.allowAllRequiredProposals();
9964
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
10044
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9965
	
10045
	
9966
	String str = this.workingCopies[0].getSource();
10046
	String str = this.workingCopies[0].getSource();
Lines 9968-9976 Link Here
9968
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10048
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
9969
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10049
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
9970
10050
10051
	int start1 = str.lastIndexOf("foo") + "".length();
10052
	int end1 = start1 + "foo".length();
9971
	assertResults(
10053
	assertResults(
9972
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
10054
			"foo[METHOD_REF]{foo(), Ltest.Test;, ()V, foo, null, ["+start1+", "+end1+"], "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
9973
			"foo[METHOD_REF]{foo(), Ltest.Test;, ()V, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
9974
			requestor.getResults());
10055
			requestor.getResults());
9975
}
10056
}
9976
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
10057
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 9993-9999 Link Here
9993
			"    public static int foo(){}\n" +
10074
			"    public static int foo(){}\n" +
9994
			"}");
10075
			"}");
9995
	
10076
	
9996
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10077
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
10078
	requestor.allowAllRequiredProposals();
9997
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
10079
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
9998
	
10080
	
9999
	String str = this.workingCopies[0].getSource();
10081
	String str = this.workingCopies[0].getSource();
Lines 10001-10009 Link Here
10001
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10083
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10002
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10084
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10003
10085
10004
	assertResults(
10086
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
10005
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
10087
	int start1 = str.lastIndexOf("foo") + "".length();
10006
			"foo[FIELD_REF]{foo, Ltest.Test;, I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
10088
	int end1 = start1 + "foo".length();
10089
	int start2 = str.lastIndexOf("public class");
10090
	int end2 = start2 + "".length();
10091
	assertResults(
10092
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
10093
			"   foo[METHOD_IMPORT]{import static test.p.ZZZ.foo;\n, Ltest.p.ZZZ;, ()I, foo, null, ["+start2+", "+end2+"], " + (relevance1) + "}\n"+
10094
			"foo[FIELD_REF]{foo, Ltest.Test;, I, foo, null, ["+start1+", "+end1+"], " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
10007
			requestor.getResults());
10095
			requestor.getResults());
10008
}
10096
}
10009
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
10097
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 10026-10032 Link Here
10026
			"    public static int foo(){}\n" +
10114
			"    public static int foo(){}\n" +
10027
			"}");
10115
			"}");
10028
	
10116
	
10029
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10117
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
10118
	requestor.allowAllRequiredProposals();
10030
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
10119
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
10031
	
10120
	
10032
	String str = this.workingCopies[0].getSource();
10121
	String str = this.workingCopies[0].getSource();
Lines 10034-10042 Link Here
10034
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10123
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10035
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10124
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10036
10125
10037
	assertResults(
10126
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
10038
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
10127
	int start1 = str.lastIndexOf("foo") + "".length();
10039
			"foo[LOCAL_VARIABLE_REF]{foo, null, I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
10128
	int end1 = start1 + "foo".length();
10129
	int start2 = str.lastIndexOf("public class");
10130
	int end2 = start2 + "".length();
10131
	assertResults(
10132
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
10133
			"   foo[METHOD_IMPORT]{import static test.p.ZZZ.foo;\n, Ltest.p.ZZZ;, ()I, foo, null, ["+start2+", "+end2+"], " + (relevance1) + "}\n"+
10134
			"foo[LOCAL_VARIABLE_REF]{foo, null, I, foo, null, ["+start1+", "+end1+"], "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
10040
			requestor.getResults());
10135
			requestor.getResults());
10041
}
10136
}
10042
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
10137
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 10059-10065 Link Here
10059
			"    public static int foo(int i){}\n" +
10154
			"    public static int foo(int i){}\n" +
10060
			"}");
10155
			"}");
10061
	
10156
	
10062
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10157
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
10158
	requestor.allowAllRequiredProposals();
10063
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
10159
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
10064
	
10160
	
10065
	String str = this.workingCopies[0].getSource();
10161
	String str = this.workingCopies[0].getSource();
Lines 10067-10075 Link Here
10067
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10163
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10068
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10164
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10069
10165
10070
	assertResults(
10166
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
10071
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, ()I, foo, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED) + "}\n" +
10167
	int start1 = str.lastIndexOf("foo") + "".length();
10072
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, (I)I, foo, (i), "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
10168
	int end1 = start1 + "foo".length();
10169
	int start2 = str.lastIndexOf("public class");
10170
	int end2 = start2 + "".length();
10171
	assertResults(
10172
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
10173
			"   foo[METHOD_IMPORT]{import static test.p.ZZZ.foo;\n, Ltest.p.ZZZ;, ()I, foo, null, ["+start2+", "+end2+"], " + (relevance1) + "}\n"+
10174
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, (I)I, foo, (i), ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
10175
			"   foo[METHOD_IMPORT]{import static test.p.ZZZ.foo;\n, Ltest.p.ZZZ;, (I)I, foo, (i), ["+start2+", "+end2+"], " + (relevance1) + "}",
10073
			requestor.getResults());
10176
			requestor.getResults());
10074
}
10177
}
10075
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
10178
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 10091-10097 Link Here
10091
			"    public static <T> int foo(){}\n" +
10194
			"    public static <T> int foo(){}\n" +
10092
			"}");
10195
			"}");
10093
	
10196
	
10094
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10197
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
10198
	requestor.allowAllRequiredProposals();
10095
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
10199
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
10096
	
10200
	
10097
	String str = this.workingCopies[0].getSource();
10201
	String str = this.workingCopies[0].getSource();
Lines 10099-10106 Link Here
10099
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10203
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10100
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10204
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10101
10205
10206
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
10207
	int start1 = str.lastIndexOf("foo") + "".length();
10208
	int end1 = start1 + "foo".length();
10209
	int start2 = str.lastIndexOf("public class");
10210
	int end2 = start2 + "".length();
10102
	assertResults(
10211
	assertResults(
10103
			"foo[METHOD_REF]{test.p.ZZZ.foo(), Ltest.p.ZZZ;, <T:Ljava.lang.Object;>()I, foo, null, "+(R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED)+"}",
10212
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, <T:Ljava.lang.Object;>()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
10213
			"   foo[METHOD_IMPORT]{import static test.p.ZZZ.foo;\n, Ltest.p.ZZZ;, <T:Ljava.lang.Object;>()I, foo, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
10104
			requestor.getResults());
10214
			requestor.getResults());
10105
}
10215
}
10106
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
10216
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
Lines 10122-10128 Link Here
10122
			"    public static int foo(){}\n" +
10232
			"    public static int foo(){}\n" +
10123
			"}");
10233
			"}");
10124
	
10234
	
10125
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
10235
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
10236
	requestor.allowAllRequiredProposals();
10126
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
10237
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
10127
	
10238
	
10128
	String str = this.workingCopies[0].getSource();
10239
	String str = this.workingCopies[0].getSource();
Lines 10134-10137 Link Here
10134
			"",
10245
			"",
10135
			requestor.getResults());
10246
			requestor.getResults());
10136
}
10247
}
10248
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
10249
public void testFavoriteImports023() throws JavaModelException {
10250
	this.workingCopies = new ICompilationUnit[2];
10251
	this.workingCopies[0] = getWorkingCopy(
10252
			"/Completion/src3/test/Test.java",
10253
			"package test;\n" +
10254
			"/** */\n" +
10255
			"public class Test {\n" +
10256
			"    public void method() {\n" +
10257
			"        foo\n" +
10258
			"    }\n" +
10259
			"}");
10260
	
10261
	this.workingCopies[1] = getWorkingCopy(
10262
			"/Completion/src3/test/p/ZZZ.java",
10263
			"package test.p;\n" +
10264
			"public class ZZZ {\n" +
10265
			"    public static int foo;\n" +
10266
			"}");
10267
	
10268
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
10269
	requestor.allowAllRequiredProposals();
10270
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
10271
	
10272
	String str = this.workingCopies[0].getSource();
10273
	String completeBehind = "foo";
10274
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10275
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10276
10277
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
10278
	int start1 = str.lastIndexOf("foo") + "".length();
10279
	int end1 = start1 + "foo".length();
10280
	int start2 = str.lastIndexOf("/** */");
10281
	int end2 = start2 + "".length();
10282
	assertResults(
10283
			"foo[FIELD_REF]{foo, Ltest.p.ZZZ;, I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
10284
			"   foo[FIELD_IMPORT]{import static test.p.ZZZ.foo;\n, Ltest.p.ZZZ;, I, foo, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
10285
			requestor.getResults());
10286
}
10287
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
10288
public void testFavoriteImports024() throws JavaModelException {
10289
	this.workingCopies = new ICompilationUnit[2];
10290
	this.workingCopies[0] = getWorkingCopy(
10291
			"/Completion/src3/test/Test.java",
10292
			"package test;\n" +
10293
			"public class Test {\n" +
10294
			"    public void method() {\n" +
10295
			"        foo\n" +
10296
			"    }\n" +
10297
			"}");
10298
	
10299
	this.workingCopies[1] = getWorkingCopy(
10300
			"/Completion/src3/test/p/ZZZ.java",
10301
			"package test.p;\n" +
10302
			"public class ZZZ {\n" +
10303
			"    public int foo;\n" +
10304
			"}");
10305
	
10306
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
10307
	requestor.allowAllRequiredProposals();
10308
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
10309
	
10310
	String str = this.workingCopies[0].getSource();
10311
	String completeBehind = "foo";
10312
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10313
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10314
10315
	assertResults(
10316
			"",
10317
			requestor.getResults());
10318
}
10319
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
10320
public void testFavoriteImports025() throws JavaModelException {
10321
	this.workingCopies = new ICompilationUnit[2];
10322
	this.workingCopies[0] = getWorkingCopy(
10323
			"/Completion/src3/test/Test.java",
10324
			"package test;\n" +
10325
			"public class Test {\n" +
10326
			"    public void method() {\n" +
10327
			"        foo\n" +
10328
			"    }\n" +
10329
			"}");
10330
	
10331
	this.workingCopies[1] = getWorkingCopy(
10332
			"/Completion/src3/test/p/ZZZ.java",
10333
			"package test.p;\n" +
10334
			"public class ZZZ {\n" +
10335
			"    public int foo;\n" +
10336
			"}");
10337
	
10338
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
10339
	requestor.allowAllRequiredProposals();
10340
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
10341
	
10342
	String str = this.workingCopies[0].getSource();
10343
	String completeBehind = "foo";
10344
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10345
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10346
10347
	assertResults(
10348
			"",
10349
			requestor.getResults());
10350
}
10351
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
10352
public void testFavoriteImports026() throws JavaModelException {
10353
	this.workingCopies = new ICompilationUnit[2];
10354
	this.workingCopies[0] = getWorkingCopy(
10355
			"/Completion/src3/test/Test.java",
10356
			"package test;\n" +
10357
			"public class Test {\n" +
10358
			"    public void method() {\n" +
10359
			"        foo\n" +
10360
			"    }\n" +
10361
			"}");
10362
	
10363
	this.workingCopies[1] = getWorkingCopy(
10364
			"/Completion/src3/test/p/ZZZ.java",
10365
			"package test.p;\n" +
10366
			"public class ZZZ {\n" +
10367
			"    public int foo(){return 0;};\n" +
10368
			"}");
10369
	
10370
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
10371
	requestor.allowAllRequiredProposals();
10372
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.*"});
10373
	
10374
	String str = this.workingCopies[0].getSource();
10375
	String completeBehind = "foo";
10376
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10377
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10378
10379
	assertResults(
10380
			"",
10381
			requestor.getResults());
10382
}
10383
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
10384
public void testFavoriteImports027() throws JavaModelException {
10385
	this.workingCopies = new ICompilationUnit[2];
10386
	this.workingCopies[0] = getWorkingCopy(
10387
			"/Completion/src3/test/Test.java",
10388
			"package test;\n" +
10389
			"public class Test {\n" +
10390
			"    public void method() {\n" +
10391
			"        foo\n" +
10392
			"    }\n" +
10393
			"}");
10394
	
10395
	this.workingCopies[1] = getWorkingCopy(
10396
			"/Completion/src3/test/p/ZZZ.java",
10397
			"package test.p;\n" +
10398
			"public class ZZZ {\n" +
10399
			"    public int foo(){return 0;};\n" +
10400
			"}");
10401
	
10402
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
10403
	requestor.allowAllRequiredProposals();
10404
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
10405
	
10406
	String str = this.workingCopies[0].getSource();
10407
	String completeBehind = "foo";
10408
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10409
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10410
10411
	assertResults(
10412
			"",
10413
			requestor.getResults());
10414
}
10415
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
10416
public void testFavoriteImports029() throws JavaModelException {
10417
	this.workingCopies = new ICompilationUnit[2];
10418
	this.workingCopies[0] = getWorkingCopy(
10419
			"/Completion/src3/test/Test.java",
10420
			"package test;\n" +
10421
			"import test.p.ZZZ;\n" +
10422
			"public class Test {\n" +
10423
			"    public void method() {\n" +
10424
			"        foo\n" +
10425
			"    }\n" +
10426
			"}");
10427
	
10428
	this.workingCopies[1] = getWorkingCopy(
10429
			"/Completion/src3/test/p/ZZZ.java",
10430
			"package test.p;\n" +
10431
			"public class ZZZ {\n" +
10432
			"    public static int foo(){return 0;};\n" +
10433
			"}");
10434
	
10435
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, false, true);
10436
	requestor.allowAllRequiredProposals();
10437
	requestor.setFavoriteReferences(new String[]{"test.p.ZZZ.foo"});
10438
	
10439
	String str = this.workingCopies[0].getSource();
10440
	String completeBehind = "foo";
10441
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
10442
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
10443
10444
	int relevance1 = R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_NAME + R_NON_RESTRICTED;
10445
	int start1 = str.lastIndexOf("foo") + "".length();
10446
	int end1 = start1 + "foo".length();
10447
	int start2 = str.lastIndexOf("public class");
10448
	int end2 = start2 + "".length();
10449
	assertResults(
10450
			"foo[METHOD_REF]{foo(), Ltest.p.ZZZ;, ()I, foo, null, ["+start1+", "+end1+"], "+(relevance1)+"}\n" +
10451
			"   foo[METHOD_IMPORT]{import static test.p.ZZZ.foo;\n, Ltest.p.ZZZ;, ()I, foo, null, ["+start2+", "+end2+"], " + (relevance1) + "}",
10452
			requestor.getResults());
10453
}
10137
}
10454
}

Return to bug 152123