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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java (-20 / +24 lines)
Lines 39-45 Link Here
39
	String completeBehind = "Z<Y>.";
39
	String completeBehind = "Z<Y>.";
40
	int cursorLocation = str.indexOf("Z<Y>.") + completeBehind.length() - 1;
40
	int cursorLocation = str.indexOf("Z<Y>.") + completeBehind.length() - 1;
41
	String expectedCompletionNodeToString = "<CompleteOnType:Z<Y>.>";
41
	String expectedCompletionNodeToString = "<CompleteOnType:Z<Y>.>";
42
	String expectedParentNodeToString = "<NONE>";
42
	String expectedParentNodeToString = "T extends <CompleteOnType:Z<Y>.>";
43
	String completionIdentifier = "";
43
	String completionIdentifier = "";
44
	String expectedReplacedSource = "Z<Y>.";
44
	String expectedReplacedSource = "Z<Y>.";
45
	String expectedUnitDisplayString =
45
	String expectedUnitDisplayString =
Lines 67-73 Link Here
67
	String completeBehind = "Z<Y>.W";
67
	String completeBehind = "Z<Y>.W";
68
	int cursorLocation = str.indexOf("Z<Y>.W") + completeBehind.length() - 1;
68
	int cursorLocation = str.indexOf("Z<Y>.W") + completeBehind.length() - 1;
69
	String expectedCompletionNodeToString = "<CompleteOnType:Z<Y>.W>";
69
	String expectedCompletionNodeToString = "<CompleteOnType:Z<Y>.W>";
70
	String expectedParentNodeToString = "<NONE>";
70
	String expectedParentNodeToString = "T extends <CompleteOnType:Z<Y>.W>";
71
	String completionIdentifier = "W";
71
	String completionIdentifier = "W";
72
	String expectedReplacedSource = "Z<Y>.W";
72
	String expectedReplacedSource = "Z<Y>.W";
73
	String expectedUnitDisplayString =
73
	String expectedUnitDisplayString =
Lines 95-101 Link Here
95
	String completeBehind = "X<Y>.Z";
95
	String completeBehind = "X<Y>.Z";
96
	int cursorLocation = str.indexOf("X<Y>.Z") + completeBehind.length() - 1;
96
	int cursorLocation = str.indexOf("X<Y>.Z") + completeBehind.length() - 1;
97
	String expectedCompletionNodeToString = "<CompleteOnType:test0001.X<Y>.Z>";
97
	String expectedCompletionNodeToString = "<CompleteOnType:test0001.X<Y>.Z>";
98
	String expectedParentNodeToString = "<NONE>";
98
	String expectedParentNodeToString = "T extends <CompleteOnType:test0001.X<Y>.Z>";
99
	String completionIdentifier = "Z";
99
	String completionIdentifier = "Z";
100
	String expectedReplacedSource = "test0001.X<Y>.Z";
100
	String expectedReplacedSource = "test0001.X<Y>.Z";
101
	String expectedUnitDisplayString =
101
	String expectedUnitDisplayString =
Lines 428-434 Link Here
428
	String completeBehind = "Y<Z>.";
428
	String completeBehind = "Y<Z>.";
429
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
429
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
430
	String expectedCompletionNodeToString = "<CompleteOnClass:Y<Z>.>";
430
	String expectedCompletionNodeToString = "<CompleteOnClass:Y<Z>.>";
431
	String expectedParentNodeToString = "<NONE>";
431
	String expectedParentNodeToString = 
432
		"public class X extends <CompleteOnClass:Y<Z>.> {\n" + 
433
		"  public X() {\n" + 
434
		"  }\n" + 
435
		"}";
432
	String completionIdentifier = "";
436
	String completionIdentifier = "";
433
	String expectedReplacedSource = "Y<Z>.";
437
	String expectedReplacedSource = "Y<Z>.";
434
	String expectedUnitDisplayString =
438
	String expectedUnitDisplayString =
Lines 623-629 Link Here
623
	String completeBehind = "Y<Z>.";
627
	String completeBehind = "Y<Z>.";
624
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
628
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
625
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
629
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
626
	String expectedParentNodeToString = "<NONE>";
630
	String expectedParentNodeToString = "T extends <CompleteOnType:Y<Z>.>";
627
	String completionIdentifier = "";
631
	String completionIdentifier = "";
628
	String expectedReplacedSource = "Y<Z>.";
632
	String expectedReplacedSource = "Y<Z>.";
629
	String expectedUnitDisplayString =
633
	String expectedUnitDisplayString =
Lines 654-660 Link Here
654
	String completeBehind = "Y<Z>.";
658
	String completeBehind = "Y<Z>.";
655
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
659
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
656
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
660
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
657
	String expectedParentNodeToString = "<NONE>";
661
	String expectedParentNodeToString = "T extends <CompleteOnType:Y<Z>.>";
658
	String completionIdentifier = "";
662
	String completionIdentifier = "";
659
	String expectedReplacedSource = "Y<Z>.";
663
	String expectedReplacedSource = "Y<Z>.";
660
	String expectedUnitDisplayString =
664
	String expectedUnitDisplayString =
Lines 685-691 Link Here
685
	String completeBehind = "Y<Z>.";
689
	String completeBehind = "Y<Z>.";
686
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
690
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
687
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
691
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
688
	String expectedParentNodeToString = "<NONE>";
692
	String expectedParentNodeToString = "T extends <CompleteOnType:Y<Z>.>";
689
	String completionIdentifier = "";
693
	String completionIdentifier = "";
690
	String expectedReplacedSource = "Y<Z>.";
694
	String expectedReplacedSource = "Y<Z>.";
691
	String expectedUnitDisplayString =
695
	String expectedUnitDisplayString =
Lines 715-721 Link Here
715
	String completeBehind = "Y<Z>.";
719
	String completeBehind = "Y<Z>.";
716
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
720
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
717
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
721
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
718
	String expectedParentNodeToString = "<NONE>";
722
	String expectedParentNodeToString = "T extends <CompleteOnType:Y<Z>.>";
719
	String completionIdentifier = "";
723
	String completionIdentifier = "";
720
	String expectedReplacedSource = "Y<Z>.";
724
	String expectedReplacedSource = "Y<Z>.";
721
	String expectedUnitDisplayString =
725
	String expectedUnitDisplayString =
Lines 745-751 Link Here
745
	String completeBehind = "Y<Z>.";
749
	String completeBehind = "Y<Z>.";
746
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
750
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
747
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
751
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
748
	String expectedParentNodeToString = "<NONE>";
752
	String expectedParentNodeToString = "T extends <CompleteOnType:Y<Z>.>";
749
	String completionIdentifier = "";
753
	String completionIdentifier = "";
750
	String expectedReplacedSource = "Y<Z>.";
754
	String expectedReplacedSource = "Y<Z>.";
751
	String expectedUnitDisplayString =
755
	String expectedUnitDisplayString =
Lines 777-783 Link Here
777
	String completeBehind = "Y<Z>.";
781
	String completeBehind = "Y<Z>.";
778
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
782
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
779
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
783
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
780
	String expectedParentNodeToString = "<NONE>";
784
	String expectedParentNodeToString = "T extends <CompleteOnType:Y<Z>.>";
781
	String completionIdentifier = "";
785
	String completionIdentifier = "";
782
	String expectedReplacedSource = "Y<Z>.";
786
	String expectedReplacedSource = "Y<Z>.";
783
	String expectedUnitDisplayString =
787
	String expectedUnitDisplayString =
Lines 809-815 Link Here
809
	String completeBehind = "Y<Z>.";
813
	String completeBehind = "Y<Z>.";
810
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
814
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
811
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
815
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
812
	String expectedParentNodeToString = "<NONE>";
816
	String expectedParentNodeToString = "T extends <CompleteOnType:Y<Z>.>";
813
	String completionIdentifier = "";
817
	String completionIdentifier = "";
814
	String expectedReplacedSource = "Y<Z>.";
818
	String expectedReplacedSource = "Y<Z>.";
815
	String expectedUnitDisplayString =
819
	String expectedUnitDisplayString =
Lines 841-847 Link Here
841
	String completeBehind = "Y<Z>.";
845
	String completeBehind = "Y<Z>.";
842
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
846
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
843
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
847
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
844
	String expectedParentNodeToString = "<NONE>";
848
	String expectedParentNodeToString = "T extends <CompleteOnType:Y<Z>.>";
845
	String completionIdentifier = "";
849
	String completionIdentifier = "";
846
	String expectedReplacedSource = "Y<Z>.";
850
	String expectedReplacedSource = "Y<Z>.";
847
	String expectedUnitDisplayString =
851
	String expectedUnitDisplayString =
Lines 872-878 Link Here
872
	String completeBehind = "Y<Z>.";
876
	String completeBehind = "Y<Z>.";
873
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
877
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
874
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
878
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
875
	String expectedParentNodeToString = "<NONE>";
879
	String expectedParentNodeToString = "T extends <CompleteOnType:Y<Z>.>";
876
	String completionIdentifier = "";
880
	String completionIdentifier = "";
877
	String expectedReplacedSource = "Y<Z>.";
881
	String expectedReplacedSource = "Y<Z>.";
878
	String expectedUnitDisplayString =
882
	String expectedUnitDisplayString =
Lines 902-908 Link Here
902
	String completeBehind = "Y<Z>.";
906
	String completeBehind = "Y<Z>.";
903
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
907
	int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
904
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
908
	String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>";
905
	String expectedParentNodeToString = "<NONE>";
909
	String expectedParentNodeToString = "T extends <CompleteOnType:Y<Z>.>";
906
	String completionIdentifier = "";
910
	String completionIdentifier = "";
907
	String expectedReplacedSource = "Y<Z>.";
911
	String expectedReplacedSource = "Y<Z>.";
908
	String expectedUnitDisplayString =
912
	String expectedUnitDisplayString =
Lines 7792-7798 Link Here
7792
	String completeBehind = "Z";
7796
	String completeBehind = "Z";
7793
	int cursorLocation = str.indexOf("Z") + completeBehind.length() - 1;
7797
	int cursorLocation = str.indexOf("Z") + completeBehind.length() - 1;
7794
	String expectedCompletionNodeToString = "<CompleteOnType:Z>";
7798
	String expectedCompletionNodeToString = "<CompleteOnType:Z>";
7795
	String expectedParentNodeToString = "<NONE>";
7799
	String expectedParentNodeToString = "T extends <CompleteOnType:Z>";
7796
	String completionIdentifier = "Z";
7800
	String completionIdentifier = "Z";
7797
	String expectedReplacedSource = "Z";
7801
	String expectedReplacedSource = "Z";
7798
	String expectedUnitDisplayString =
7802
	String expectedUnitDisplayString =
Lines 7820-7826 Link Here
7820
	String completeBehind = "Z";
7824
	String completeBehind = "Z";
7821
	int cursorLocation = str.indexOf("Z") + completeBehind.length() - 1;
7825
	int cursorLocation = str.indexOf("Z") + completeBehind.length() - 1;
7822
	String expectedCompletionNodeToString = "<CompleteOnType:X.Z>";
7826
	String expectedCompletionNodeToString = "<CompleteOnType:X.Z>";
7823
	String expectedParentNodeToString = "<NONE>";
7827
	String expectedParentNodeToString = "T extends <CompleteOnType:X.Z>";
7824
	String completionIdentifier = "Z";
7828
	String completionIdentifier = "Z";
7825
	String expectedReplacedSource = "X.Z";
7829
	String expectedReplacedSource = "X.Z";
7826
	String expectedUnitDisplayString =
7830
	String expectedUnitDisplayString =
Lines 7848-7854 Link Here
7848
	String completeBehind = "Z";
7852
	String completeBehind = "Z";
7849
	int cursorLocation = str.indexOf("Z") + completeBehind.length() - 1;
7853
	int cursorLocation = str.indexOf("Z") + completeBehind.length() - 1;
7850
	String expectedCompletionNodeToString = "<CompleteOnType:X<W>.Z>";
7854
	String expectedCompletionNodeToString = "<CompleteOnType:X<W>.Z>";
7851
	String expectedParentNodeToString = "<NONE>";
7855
	String expectedParentNodeToString = "T extends <CompleteOnType:X<W>.Z>";
7852
	String completionIdentifier = "Z";
7856
	String completionIdentifier = "Z";
7853
	String expectedReplacedSource = "X<W>.Z";
7857
	String expectedReplacedSource = "X<W>.Z";
7854
	String expectedUnitDisplayString =
7858
	String expectedUnitDisplayString =
Lines 7877-7883 Link Here
7877
	String completeBehind = "Z";
7881
	String completeBehind = "Z";
7878
	int cursorLocation = str.indexOf("Z") + completeBehind.length() - 1;
7882
	int cursorLocation = str.indexOf("Z") + completeBehind.length() - 1;
7879
	String expectedCompletionNodeToString = "<CompleteOnType:X<W>.Z>";
7883
	String expectedCompletionNodeToString = "<CompleteOnType:X<W>.Z>";
7880
	String expectedParentNodeToString = "<NONE>";
7884
	String expectedParentNodeToString = "T extends <CompleteOnType:X<W>.Z>";
7881
	String completionIdentifier = "Z";
7885
	String completionIdentifier = "Z";
7882
	String expectedReplacedSource = "X<W>.Z";
7886
	String expectedReplacedSource = "X<W>.Z";
7883
	String expectedUnitDisplayString =
7887
	String expectedUnitDisplayString =
Lines 9057-9063 Link Here
9057
	String completeBehind = "Strin";
9061
	String completeBehind = "Strin";
9058
	int cursorLocation = str.indexOf("Strin") + completeBehind.length() - 1;
9062
	int cursorLocation = str.indexOf("Strin") + completeBehind.length() - 1;
9059
	String expectedCompletionNodeToString = "<CompleteOnType:Strin>";
9063
	String expectedCompletionNodeToString = "<CompleteOnType:Strin>";
9060
	String expectedParentNodeToString = "<NONE>";
9064
	String expectedParentNodeToString = "? extends <CompleteOnType:Strin>";
9061
	String completionIdentifier = "Strin";
9065
	String completionIdentifier = "Strin";
9062
	String expectedReplacedSource = "String";
9066
	String expectedReplacedSource = "String";
9063
	String expectedUnitDisplayString =
9067
	String expectedUnitDisplayString =
Lines 10682-10688 Link Here
10682
	String completeBehind = "Obj";
10686
	String completeBehind = "Obj";
10683
	int cursorLocation = str.indexOf("Obj") + completeBehind.length() - 1;
10687
	int cursorLocation = str.indexOf("Obj") + completeBehind.length() - 1;
10684
	String expectedCompletionNodeToString = "<CompleteOnType:Obj>";
10688
	String expectedCompletionNodeToString = "<CompleteOnType:Obj>";
10685
	String expectedParentNodeToString = "<NONE>";
10689
	String expectedParentNodeToString = "? extends <CompleteOnType:Obj>";
10686
	String completionIdentifier = "Obj";
10690
	String completionIdentifier = "Obj";
10687
	String expectedReplacedSource = "Obj";
10691
	String expectedReplacedSource = "Obj";
10688
	String expectedUnitDisplayString =
10692
	String expectedUnitDisplayString =
(-)src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest2.java (-1 / +7 lines)
Lines 9327-9333 Link Here
9327
	String completeBehind = "Z.";
9327
	String completeBehind = "Z.";
9328
	int cursorLocation = str.indexOf("Z.") + completeBehind.length() - 1;
9328
	int cursorLocation = str.indexOf("Z.") + completeBehind.length() - 1;
9329
	String expectedCompletionNodeToString = "<CompleteOnClass:Z.>";
9329
	String expectedCompletionNodeToString = "<CompleteOnClass:Z.>";
9330
	String expectedParentNodeToString = "<NONE>";
9330
	String expectedParentNodeToString = 
9331
		"public class X extends <CompleteOnClass:Z.> {\n" + 
9332
		"  {\n" + 
9333
		"  }\n" + 
9334
		"  public X() {\n" + 
9335
		"  }\n" + 
9336
		"}";
9331
	String completionIdentifier = "";
9337
	String completionIdentifier = "";
9332
	String expectedReplacedSource = "Z.";
9338
	String expectedReplacedSource = "Z.";
9333
	String expectedUnitDisplayString =
9339
	String expectedUnitDisplayString =
(-)codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java (+45 lines)
Lines 2076-2081 Link Here
2076
protected void consumeClassHeaderExtends() {
2076
protected void consumeClassHeaderExtends() {
2077
	pushOnElementStack(K_NEXT_TYPEREF_IS_CLASS);
2077
	pushOnElementStack(K_NEXT_TYPEREF_IS_CLASS);
2078
	super.consumeClassHeaderExtends();
2078
	super.consumeClassHeaderExtends();
2079
	if (this.assistNode != null && this.assistNodeParent == null) {
2080
		TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
2081
		if (typeDecl != null && typeDecl.superclass == this.assistNode)
2082
			this.assistNodeParent = typeDecl;
2083
	}
2079
	popElement(K_NEXT_TYPEREF_IS_CLASS);
2084
	popElement(K_NEXT_TYPEREF_IS_CLASS);
2080
	popElement(K_EXTENDS_KEYWORD);
2085
	popElement(K_EXTENDS_KEYWORD);
2081
2086
Lines 3752-3769 Link Here
3752
}
3757
}
3753
protected void consumeTypeParameterWithExtends() {
3758
protected void consumeTypeParameterWithExtends() {
3754
	super.consumeTypeParameterWithExtends();
3759
	super.consumeTypeParameterWithExtends();
3760
	if (this.assistNode != null && this.assistNodeParent == null) {
3761
		TypeParameter typeParameter = (TypeParameter) this.genericsStack[this.genericsPtr];
3762
		if (typeParameter != null && typeParameter.type == this.assistNode)
3763
			this.assistNodeParent = typeParameter;
3764
	}
3755
	popElement(K_EXTENDS_KEYWORD);
3765
	popElement(K_EXTENDS_KEYWORD);
3756
}
3766
}
3757
protected void consumeTypeParameterWithExtendsAndBounds() {
3767
protected void consumeTypeParameterWithExtendsAndBounds() {
3758
	super.consumeTypeParameterWithExtendsAndBounds();
3768
	super.consumeTypeParameterWithExtendsAndBounds();
3769
	if (this.assistNode != null && this.assistNodeParent == null) {
3770
		TypeParameter typeParameter = (TypeParameter) this.genericsStack[this.genericsPtr];
3771
		if (typeParameter != null && typeParameter.type == this.assistNode)
3772
			this.assistNodeParent = typeParameter;
3773
	}
3759
	popElement(K_EXTENDS_KEYWORD);
3774
	popElement(K_EXTENDS_KEYWORD);
3760
}
3775
}
3761
protected void consumeTypeParameter1WithExtends() {
3776
protected void consumeTypeParameter1WithExtends() {
3762
	super.consumeTypeParameter1WithExtends();
3777
	super.consumeTypeParameter1WithExtends();
3778
	if (this.assistNode != null && this.assistNodeParent == null) {
3779
		TypeParameter typeParameter = (TypeParameter) this.genericsStack[this.genericsPtr];
3780
		if (typeParameter != null && typeParameter.type == this.assistNode)
3781
			this.assistNodeParent = typeParameter;
3782
	}
3763
	popElement(K_EXTENDS_KEYWORD);
3783
	popElement(K_EXTENDS_KEYWORD);
3764
}
3784
}
3765
protected void consumeTypeParameter1WithExtendsAndBounds() {
3785
protected void consumeTypeParameter1WithExtendsAndBounds() {
3766
	super.consumeTypeParameter1WithExtendsAndBounds();
3786
	super.consumeTypeParameter1WithExtendsAndBounds();
3787
	if (this.assistNode != null && this.assistNodeParent == null) {
3788
		TypeParameter typeParameter = (TypeParameter) this.genericsStack[this.genericsPtr];
3789
		if (typeParameter != null && typeParameter.type == this.assistNode)
3790
			this.assistNodeParent = typeParameter;
3791
	}
3767
	popElement(K_EXTENDS_KEYWORD);
3792
	popElement(K_EXTENDS_KEYWORD);
3768
}
3793
}
3769
protected void consumeWildcard() {
3794
protected void consumeWildcard() {
Lines 3808-3825 Link Here
3808
}
3833
}
3809
protected void consumeWildcardBoundsExtends() {
3834
protected void consumeWildcardBoundsExtends() {
3810
	super.consumeWildcardBoundsExtends();
3835
	super.consumeWildcardBoundsExtends();
3836
	if (this.assistNode != null && this.assistNodeParent == null) {
3837
		Wildcard wildcard = (Wildcard) this.genericsStack[this.genericsPtr];
3838
		if (wildcard != null && wildcard.bound == this.assistNode)
3839
			this.assistNodeParent = wildcard;
3840
	}
3811
	popElement(K_EXTENDS_KEYWORD);
3841
	popElement(K_EXTENDS_KEYWORD);
3812
}
3842
}
3813
protected void consumeWildcardBounds1Extends() {
3843
protected void consumeWildcardBounds1Extends() {
3814
	super.consumeWildcardBounds1Extends();
3844
	super.consumeWildcardBounds1Extends();
3845
	if (this.assistNode != null && this.assistNodeParent == null) {
3846
		Wildcard wildcard = (Wildcard) this.genericsStack[this.genericsPtr];
3847
		if (wildcard != null && wildcard.bound == this.assistNode)
3848
			this.assistNodeParent = wildcard;
3849
	}
3815
	popElement(K_EXTENDS_KEYWORD);
3850
	popElement(K_EXTENDS_KEYWORD);
3816
}
3851
}
3817
protected void consumeWildcardBounds2Extends() {
3852
protected void consumeWildcardBounds2Extends() {
3818
	super.consumeWildcardBounds2Extends();
3853
	super.consumeWildcardBounds2Extends();
3854
	if (this.assistNode != null && this.assistNodeParent == null) {
3855
		Wildcard wildcard = (Wildcard) this.genericsStack[this.genericsPtr];
3856
		if (wildcard != null && wildcard.bound == this.assistNode)
3857
			this.assistNodeParent = wildcard;
3858
	}
3819
	popElement(K_EXTENDS_KEYWORD);
3859
	popElement(K_EXTENDS_KEYWORD);
3820
}
3860
}
3821
protected void consumeWildcardBounds3Extends() {
3861
protected void consumeWildcardBounds3Extends() {
3822
	super.consumeWildcardBounds3Extends();
3862
	super.consumeWildcardBounds3Extends();
3863
	if (this.assistNode != null && this.assistNodeParent == null) {
3864
		Wildcard wildcard = (Wildcard) this.genericsStack[this.genericsPtr];
3865
		if (wildcard != null && wildcard.bound == this.assistNode)
3866
			this.assistNodeParent = wildcard;
3867
	}
3823
	popElement(K_EXTENDS_KEYWORD);
3868
	popElement(K_EXTENDS_KEYWORD);
3824
}
3869
}
3825
protected void consumeUnaryExpression(int op) {
3870
protected void consumeUnaryExpression(int op) {
(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-1 / +24 lines)
Lines 504-509 Link Here
504
	boolean assistNodeIsAnnotation;
504
	boolean assistNodeIsAnnotation;
505
	boolean assistNodeIsConstructor;
505
	boolean assistNodeIsConstructor;
506
	boolean assistNodeIsSuperType;
506
	boolean assistNodeIsSuperType;
507
	boolean assistNodeIsExtendedType;
507
	int  assistNodeInJavadoc = 0;
508
	int  assistNodeInJavadoc = 0;
508
	boolean assistNodeCanBeSingleMemberAnnotation = false;
509
	boolean assistNodeCanBeSingleMemberAnnotation = false;
509
	
510
	
Lines 1113-1118 Link Here
1113
		this.foundTypesCount++;
1114
		this.foundTypesCount++;
1114
		
1115
		
1115
		if (this.options.checkDeprecation && (modifiers & ClassFileConstants.AccDeprecated) != 0) return;
1116
		if (this.options.checkDeprecation && (modifiers & ClassFileConstants.AccDeprecated) != 0) return;
1117
		if (this.assistNodeIsExtendedType && (modifiers & ClassFileConstants.AccFinal) != 0) return;
1116
1118
1117
		if (this.options.checkVisibility) {
1119
		if (this.options.checkVisibility) {
1118
			if((modifiers & ClassFileConstants.AccPublic) == 0) {
1120
			if((modifiers & ClassFileConstants.AccPublic) == 0) {
Lines 1604-1609 Link Here
1604
		if(astNodeParent != null) {
1606
		if(astNodeParent != null) {
1605
			if(!isValidParent(astNodeParent, astNode, scope)) return false;
1607
			if(!isValidParent(astNodeParent, astNode, scope)) return false;
1606
			computeExpectedTypes(astNodeParent, astNode, scope);
1608
			computeExpectedTypes(astNodeParent, astNode, scope);
1609
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=99399, don't propose final types for extension.
1610
			if (astNodeParent instanceof TypeDeclaration) {
1611
				TypeDeclaration typeDeclaration = (TypeDeclaration) astNodeParent;
1612
				if (typeDeclaration.superclass == astNode)
1613
					this.assistNodeIsExtendedType = true;	
1614
			} else if (astNodeParent instanceof TypeParameter) {
1615
				TypeParameter typeParameter = (TypeParameter) astNodeParent;
1616
				if (typeParameter.type == astNode)
1617
					this.assistNodeIsExtendedType = true;
1618
			} else if (astNodeParent instanceof Wildcard) {
1619
				Wildcard wildcard = (Wildcard) astNodeParent;
1620
				if (wildcard.bound == astNode && wildcard.kind == Wildcard.EXTENDS)
1621
					this.assistNodeIsExtendedType = true;
1622
			}
1607
		}
1623
		}
1608
1624
1609
		buildContext(astNode, astNodeParent, compilationUnitDeclaration, qualifiedBinding, scope);
1625
		buildContext(astNode, astNodeParent, compilationUnitDeclaration, qualifiedBinding, scope);
Lines 3343-3349 Link Here
3343
		this.hasJavaLangObjectAsExpectedType = false;
3359
		this.hasJavaLangObjectAsExpectedType = false;
3344
3360
3345
		// find types from parent
3361
		// find types from parent
3346
		if(parent instanceof AbstractVariableDeclaration) {
3362
		if(parent instanceof AbstractVariableDeclaration && !(parent instanceof TypeParameter)) {
3347
			AbstractVariableDeclaration variable = (AbstractVariableDeclaration)parent;
3363
			AbstractVariableDeclaration variable = (AbstractVariableDeclaration)parent;
3348
			TypeBinding binding = variable.type.resolvedType;
3364
			TypeBinding binding = variable.type.resolvedType;
3349
			if(binding != null) {
3365
			if(binding != null) {
Lines 9184-9189 Link Here
9184
9200
9185
			typesFound.add(memberType);
9201
			typesFound.add(memberType);
9186
9202
9203
			if (this.assistNodeIsExtendedType && memberType.isFinal()) continue next;
9187
			if(!this.insideQualifiedReference) {
9204
			if(!this.insideQualifiedReference) {
9188
				if(this.assistNodeIsClass) {
9205
				if(this.assistNodeIsClass) {
9189
					if(!memberType.isClass()) continue next;
9206
					if(!memberType.isClass()) continue next;
Lines 9671-9676 Link Here
9671
										continue next;
9688
										continue next;
9672
								}
9689
								}
9673
9690
9691
								if (this.assistNodeIsExtendedType && localType.isFinal()) continue next;
9674
								if(this.assistNodeIsClass) {
9692
								if(this.assistNodeIsClass) {
9675
									if(!localType.isClass()) continue next;
9693
									if(!localType.isClass()) continue next;
9676
								} else if(this.assistNodeIsInterface) {
9694
								} else if(this.assistNodeIsInterface) {
Lines 10051-10056 Link Here
10051
				
10069
				
10052
				typesFound.add(sourceType);
10070
				typesFound.add(sourceType);
10053
10071
10072
				if (this.assistNodeIsExtendedType && sourceType.isFinal()) continue next;
10054
				if(this.assistNodeIsClass) {
10073
				if(this.assistNodeIsClass) {
10055
					if(!sourceType.isClass()) continue next;
10074
					if(!sourceType.isClass()) continue next;
10056
				} else if(this.assistNodeIsInterface) {
10075
				} else if(this.assistNodeIsInterface) {
Lines 10271-10276 Link Here
10271
						!scope.isDefinedInSameUnit(sourceType))
10290
						!scope.isDefinedInSameUnit(sourceType))
10272
					continue;
10291
					continue;
10273
10292
10293
			    if (this.assistNodeIsExtendedType && sourceType.isFinal()) continue;
10274
				int accessibility = IAccessRule.K_ACCESSIBLE;
10294
				int accessibility = IAccessRule.K_ACCESSIBLE;
10275
				if(sourceType.hasRestrictedAccess()) {
10295
				if(sourceType.hasRestrictedAccess()) {
10276
					AccessRestriction accessRestriction = this.lookupEnvironment.getAccessRestriction(sourceType);
10296
					AccessRestriction accessRestriction = this.lookupEnvironment.getAccessRestriction(sourceType);
Lines 10463-10468 Link Here
10463
							}
10483
							}
10464
						}
10484
						}
10465
10485
10486
						if (this.assistNodeIsExtendedType && refBinding.isFinal()) continue next;
10466
						if(this.assistNodeIsClass) {
10487
						if(this.assistNodeIsClass) {
10467
							if(!refBinding.isClass()) continue next;
10488
							if(!refBinding.isClass()) continue next;
10468
						} else if(this.assistNodeIsInterface) {
10489
						} else if(this.assistNodeIsInterface) {
Lines 10592-10597 Link Here
10592
							
10613
							
10593
							typesFound.add(typeBinding);
10614
							typesFound.add(typeBinding);
10594
							
10615
							
10616
							if (this.assistNodeIsExtendedType && typeBinding.isFinal()) continue;
10595
							if(this.assistNodeIsClass) {
10617
							if(this.assistNodeIsClass) {
10596
								if(!typeBinding.isClass()) continue;
10618
								if(!typeBinding.isClass()) continue;
10597
							} else if(this.assistNodeIsInterface) {
10619
							} else if(this.assistNodeIsInterface) {
Lines 10694-10699 Link Here
10694
10716
10695
							typesFound.add(typeBinding);
10717
							typesFound.add(typeBinding);
10696
10718
10719
							if (this.assistNodeIsExtendedType && typeBinding.isFinal()) continue;
10697
							if(this.assistNodeIsClass) {
10720
							if(this.assistNodeIsClass) {
10698
								if(!typeBinding.isClass()) continue;
10721
								if(!typeBinding.isClass()) continue;
10699
							} else if(this.assistNodeIsInterface) {
10722
							} else if(this.assistNodeIsInterface) {
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests.java (+67 lines)
Lines 19353-19356 Link Here
19353
			"",
19353
			"",
19354
			requestor.getResults());
19354
			requestor.getResults());
19355
}
19355
}
19356
19357
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=99399 don't propose final types for extends type completion.
19358
public void testCompletionOnExtendFinalClass () throws JavaModelException {
19359
	this.workingCopies = new ICompilationUnit[1];
19360
	this.workingCopies[0] = getWorkingCopy(
19361
		"/Completion/src/test/Test.java",
19362
		"package test;"+
19363
		"class ThisClassIsNotFinal {}" +
19364
		"final class ThisClassIsFinal {}" +
19365
		"public class Event extends test.ThisClassI {\n" +
19366
		"}");
19367
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
19368
	String str = this.workingCopies[0].getSource();
19369
	String completeBehind = "test.ThisClassI";
19370
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
19371
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
19372
19373
	assertResults(
19374
			"ThisClassIsNotFinal[TYPE_REF]{ThisClassIsNotFinal, test, Ltest.ThisClassIsNotFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_RESTRICTED + R_CLASS) + "}",	
19375
			requestor.getResults());
19376
}
19377
19378
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=99399 don't propose final types for extends type completion.
19379
public void testCompletionOnExtendFinalClass2() throws JavaModelException {
19380
	this.workingCopies = new ICompilationUnit[1];
19381
	this.workingCopies[0] = getWorkingCopy(
19382
		"/Completion/src/test/Test.java",
19383
		"package test;"+
19384
		"class ThisClassIsNotFinal {}" +
19385
		"final class ThisClassIsFinal {}" +
19386
		"public class Event extends ThisClassI {\n" +
19387
		"}");
19388
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
19389
	String str = this.workingCopies[0].getSource();
19390
	String completeBehind = "ThisClassI";
19391
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
19392
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
19393
19394
	assertResults(
19395
			"ThisClassIsNotFinal[TYPE_REF]{ThisClassIsNotFinal, test, Ltest.ThisClassIsNotFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_CLASS) + "}",
19396
			requestor.getResults());
19397
}
19398
19399
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=99399 test to verify that we continue to propose final types
19400
// in other (non extends context).
19401
public void testCompletionOnExtendFinalClass3() throws JavaModelException {
19402
	this.workingCopies = new ICompilationUnit[1];
19403
	this.workingCopies[0] = getWorkingCopy(
19404
		"/Completion/src/test/Test.java",
19405
		"package test;"+
19406
		"class ThisClassIsNotFinal {}" +
19407
		"final class ThisClassIsFinal {}" +
19408
		"public class Event extends ThisClassIsFinal {\n" +
19409
		"	void Boo (ThisClassI x) {}\n" +
19410
		"}");
19411
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
19412
	String str = this.workingCopies[0].getSource();
19413
	String completeBehind = "ThisClassI";
19414
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
19415
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
19416
19417
	assertResults(
19418
			"ThisClassIsFinal[TYPE_REF]{ThisClassIsFinal, test, Ltest.ThisClassIsFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
19419
			"ThisClassIsNotFinal[TYPE_REF]{ThisClassIsNotFinal, test, Ltest.ThisClassIsNotFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
19420
			requestor.getResults());
19421
}
19422
19356
}
19423
}
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java (+101 lines)
Lines 13476-13479 Link Here
13476
			requestor.getResults());
13476
			requestor.getResults());
13477
}
13477
}
13478
13478
13479
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=99399 test to verify that we continue to propose final
13480
// types in extends contexts but where they are not directly extended.
13481
public void testCompletionOnExtends() throws JavaModelException {
13482
	this.workingCopies = new ICompilationUnit[1];
13483
	this.workingCopies[0] = getWorkingCopy(
13484
			"/Completion/src3/test/Test.java",
13485
			"package test;\n" +
13486
			"class X<T> {};\n" +
13487
			"final class ThisClassIsFinal {}\n" +
13488
			"class ThisClassIsNotFinal {}\n" +
13489
			"public class Test extends X<ThisClassI> {}");
13490
13491
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13492
13493
	String str = this.workingCopies[0].getSource();
13494
	String completeBehind = "ThisClassI";
13495
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13496
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13497
13498
	assertResults(
13499
			"ThisClassIsFinal[TYPE_REF]{ThisClassIsFinal, test, Ltest.ThisClassIsFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_CLASS) + "}\n" +
13500
			"ThisClassIsNotFinal[TYPE_REF]{ThisClassIsNotFinal, test, Ltest.ThisClassIsNotFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_CLASS) + "}",
13501
			requestor.getResults());
13502
}
13503
13504
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=99399 test to verify that we don't propose final
13505
//types in extends contexts where we should not.
13506
public void testCompletionOnExtends2() throws JavaModelException {
13507
	this.workingCopies = new ICompilationUnit[1];
13508
	this.workingCopies[0] = getWorkingCopy(
13509
			"/Completion/src3/test/Test.java",
13510
			"package test;\n" +
13511
			"final class ThisClassIsFinal {}\n" +
13512
			"class ThisClassIsNotFinal {}\n" +
13513
			"public class Test <T extends ThisClassI> {}\n");
13514
13515
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13516
13517
	String str = this.workingCopies[0].getSource();
13518
	String completeBehind = "ThisClassI";
13519
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13520
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13521
13522
	assertResults(
13523
			"ThisClassIsNotFinal[TYPE_REF]{ThisClassIsNotFinal, test, Ltest.ThisClassIsNotFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
13524
			requestor.getResults());
13525
}
13526
13527
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=99399 test to verify that we don't propose final
13528
//types in extends contexts where we should not.
13529
public void testCompletionOnExtends3() throws JavaModelException {
13530
	this.workingCopies = new ICompilationUnit[1];
13531
	this.workingCopies[0] = getWorkingCopy(
13532
			"/Completion/src3/test/Test.java",
13533
			"package test;\n" +
13534
			"final class ThisClassIsFinal {}\n" +
13535
			"class ThisClassIsNotFinal {}\n" +
13536
			"public class Test {\n" +
13537
			"    Test(Bag<? extends ThisClassI> p) {}" +
13538
			"}\n");
13539
13540
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13541
13542
	String str = this.workingCopies[0].getSource();
13543
	String completeBehind = "ThisClassI";
13544
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13545
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13546
13547
	assertResults(
13548
			"ThisClassIsNotFinal[TYPE_REF]{ThisClassIsNotFinal, test, Ltest.ThisClassIsNotFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
13549
			requestor.getResults());
13550
}
13551
13552
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=99399 test to verify that we do propose final
13553
//types in super contexts where we should.
13554
public void testCompletionOnExtends4() throws JavaModelException {
13555
	this.workingCopies = new ICompilationUnit[1];
13556
	this.workingCopies[0] = getWorkingCopy(
13557
			"/Completion/src3/test/Test.java",
13558
			"package test;\n" +
13559
			"final class ThisClassIsFinal {}\n" +
13560
			"class ThisClassIsNotFinal {}\n" +
13561
			"public class Test {\n" +
13562
			"    void boo() {\n" +
13563
			"        Bag<? super ThisClassI> local;\n" +
13564
			"    }\n" +
13565
			"}\n");
13566
13567
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
13568
13569
	String str = this.workingCopies[0].getSource();
13570
	String completeBehind = "ThisClassI";
13571
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13572
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13573
13574
	assertResults(
13575
			"ThisClassIsFinal[TYPE_REF]{ThisClassIsFinal, test, Ltest.ThisClassIsFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
13576
			"ThisClassIsNotFinal[TYPE_REF]{ThisClassIsNotFinal, test, Ltest.ThisClassIsNotFinal;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
13577
			requestor.getResults());
13578
}
13579
13479
}
13580
}

Return to bug 99399