Lines 13-27
Link Here
|
13 |
import org.eclipse.core.runtime.Assert; |
13 |
import org.eclipse.core.runtime.Assert; |
14 |
|
14 |
|
15 |
import org.eclipse.jdt.core.dom.ASTVisitor; |
15 |
import org.eclipse.jdt.core.dom.ASTVisitor; |
|
|
16 |
import org.eclipse.jdt.core.dom.AnonymousClassDeclaration; |
16 |
import org.eclipse.jdt.core.dom.FieldAccess; |
17 |
import org.eclipse.jdt.core.dom.FieldAccess; |
17 |
import org.eclipse.jdt.core.dom.IBinding; |
18 |
import org.eclipse.jdt.core.dom.IBinding; |
18 |
import org.eclipse.jdt.core.dom.IMethodBinding; |
19 |
import org.eclipse.jdt.core.dom.IMethodBinding; |
19 |
import org.eclipse.jdt.core.dom.ITypeBinding; |
20 |
import org.eclipse.jdt.core.dom.ITypeBinding; |
20 |
import org.eclipse.jdt.core.dom.IVariableBinding; |
21 |
import org.eclipse.jdt.core.dom.IVariableBinding; |
|
|
22 |
import org.eclipse.jdt.core.dom.LambdaExpression; |
21 |
import org.eclipse.jdt.core.dom.MethodInvocation; |
23 |
import org.eclipse.jdt.core.dom.MethodInvocation; |
22 |
import org.eclipse.jdt.core.dom.Modifier; |
24 |
import org.eclipse.jdt.core.dom.Modifier; |
23 |
import org.eclipse.jdt.core.dom.Name; |
25 |
import org.eclipse.jdt.core.dom.Name; |
24 |
import org.eclipse.jdt.core.dom.QualifiedName; |
26 |
import org.eclipse.jdt.core.dom.QualifiedName; |
|
|
27 |
import org.eclipse.jdt.core.dom.ReturnStatement; |
25 |
import org.eclipse.jdt.core.dom.SimpleName; |
28 |
import org.eclipse.jdt.core.dom.SimpleName; |
26 |
import org.eclipse.jdt.core.dom.SuperFieldAccess; |
29 |
import org.eclipse.jdt.core.dom.SuperFieldAccess; |
27 |
import org.eclipse.jdt.core.dom.SuperMethodInvocation; |
30 |
import org.eclipse.jdt.core.dom.SuperMethodInvocation; |
Lines 35-41
Link Here
|
35 |
|
38 |
|
36 |
private final IExpressionFragment fExpression; |
39 |
private final IExpressionFragment fExpression; |
37 |
protected boolean fResult= true; |
40 |
protected boolean fResult= true; |
38 |
|
41 |
protected boolean anonymous= false; |
|
|
42 |
protected boolean lambda= false; |
43 |
|
39 |
public ExpressionChecker(IExpressionFragment ex) { |
44 |
public ExpressionChecker(IExpressionFragment ex) { |
40 |
fExpression= ex; |
45 |
fExpression= ex; |
41 |
} |
46 |
} |
Lines 95-100
Link Here
|
95 |
return false; //Do not descend further |
100 |
return false; //Do not descend further |
96 |
} |
101 |
} |
97 |
|
102 |
|
|
|
103 |
@Override |
104 |
public boolean visit(AnonymousClassDeclaration node) { |
105 |
anonymous = true; |
106 |
return true; |
107 |
} |
108 |
|
109 |
@Override |
110 |
public boolean visit(LambdaExpression node) { |
111 |
lambda = true; |
112 |
return true; |
113 |
} |
114 |
|
115 |
@Override |
116 |
public boolean visit(ReturnStatement node) { |
117 |
return true; |
118 |
} |
119 |
|
98 |
private boolean checkName(Name name) { |
120 |
private boolean checkName(Name name) { |
99 |
IBinding binding= name.resolveBinding(); |
121 |
IBinding binding= name.resolveBinding(); |
100 |
if (binding == null) |
122 |
if (binding == null) |
Lines 102-107
Link Here
|
102 |
scenarios which may have been deemed unacceptable in |
124 |
scenarios which may have been deemed unacceptable in |
103 |
the presence of semantic information will be admitted. */ |
125 |
the presence of semantic information will be admitted. */ |
104 |
|
126 |
|
|
|
127 |
if (anonymous || lambda) { |
128 |
return true; |
129 |
} |
105 |
// If name represents a member: |
130 |
// If name represents a member: |
106 |
if (binding instanceof IVariableBinding || binding instanceof IMethodBinding) |
131 |
if (binding instanceof IVariableBinding || binding instanceof IMethodBinding) |
107 |
return isMemberReferenceValidInClassInitialization(name); |
132 |
return isMemberReferenceValidInClassInitialization(name); |