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

Collapse All | Expand All

(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-1 / +1 lines)
Lines 3451-3457 Link Here
3451
				}
3451
				}
3452
			}
3452
			}
3453
		} else if(parent instanceof CastExpression) {
3453
		} else if(parent instanceof CastExpression) {
3454
			Expression e = ((CastExpression)parent).type;
3454
			TypeReference e = ((CastExpression)parent).type;
3455
			TypeBinding binding = e.resolvedType;
3455
			TypeBinding binding = e.resolvedType;
3456
			if(binding != null){
3456
			if(binding != null){
3457
				addExpectedType(binding, scope);
3457
				addExpectedType(binding, scope);
(-)codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java (-11 / +18 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 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 799-805 Link Here
799
				Expression castType;
799
				Expression castType;
800
				if(this.expressionPtr > 0
800
				if(this.expressionPtr > 0
801
					&& ((castType = this.expressionStack[this.expressionPtr-1]) instanceof TypeReference)) {
801
					&& ((castType = this.expressionStack[this.expressionPtr-1]) instanceof TypeReference)) {
802
					CastExpression cast = new CastExpression(expression, castType);
802
					CastExpression cast = new CastExpression(expression, (TypeReference) castType);
803
					cast.sourceStart = castType.sourceStart;
803
					cast.sourceStart = castType.sourceStart;
804
					cast.sourceEnd= expression.sourceEnd;
804
					cast.sourceEnd= expression.sourceEnd;
805
					this.assistNodeParent = cast;
805
					this.assistNodeParent = cast;
Lines 2056-2075 Link Here
2056
protected void consumeCastExpressionWithPrimitiveType() {
2056
protected void consumeCastExpressionWithPrimitiveType() {
2057
	popElement(K_CAST_STATEMENT);
2057
	popElement(K_CAST_STATEMENT);
2058
2058
2059
	Expression exp, cast, castType;
2059
	Expression exp;
2060
	Expression cast;
2061
	TypeReference castType;
2060
	this.expressionPtr--;
2062
	this.expressionPtr--;
2061
	this.expressionLengthPtr--;
2063
	this.expressionLengthPtr--;
2062
	this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr+1], castType = this.expressionStack[this.expressionPtr]);
2064
	this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr+1], castType = (TypeReference) this.expressionStack[this.expressionPtr]);
2063
	cast.sourceStart = castType.sourceStart - 1;
2065
	cast.sourceStart = castType.sourceStart - 1;
2064
	cast.sourceEnd = exp.sourceEnd;
2066
	cast.sourceEnd = exp.sourceEnd;
2065
}
2067
}
2066
protected void consumeCastExpressionWithGenericsArray() {
2068
protected void consumeCastExpressionWithGenericsArray() {
2067
	popElement(K_CAST_STATEMENT);
2069
	popElement(K_CAST_STATEMENT);
2068
2070
2069
	Expression exp, cast, castType;
2071
	Expression exp;
2072
	Expression cast;
2073
	TypeReference castType;
2070
	this.expressionPtr--;
2074
	this.expressionPtr--;
2071
	this.expressionLengthPtr--;
2075
	this.expressionLengthPtr--;
2072
	this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr + 1], castType = this.expressionStack[this.expressionPtr]);
2076
	this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr + 1], castType = (TypeReference) this.expressionStack[this.expressionPtr]);
2073
	cast.sourceStart = castType.sourceStart - 1;
2077
	cast.sourceStart = castType.sourceStart - 1;
2074
	cast.sourceEnd = exp.sourceEnd;
2078
	cast.sourceEnd = exp.sourceEnd;
2075
}
2079
}
Lines 2077-2086 Link Here
2077
protected void consumeCastExpressionWithQualifiedGenericsArray() {
2081
protected void consumeCastExpressionWithQualifiedGenericsArray() {
2078
	popElement(K_CAST_STATEMENT);
2082
	popElement(K_CAST_STATEMENT);
2079
2083
2080
	Expression exp, cast, castType;
2084
	Expression exp;
2085
	Expression cast;
2086
	TypeReference castType;
2081
	this.expressionPtr--;
2087
	this.expressionPtr--;
2082
	this.expressionLengthPtr--;
2088
	this.expressionLengthPtr--;
2083
	this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr + 1], castType = this.expressionStack[this.expressionPtr]);
2089
	this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr + 1], castType = (TypeReference) this.expressionStack[this.expressionPtr]);
2084
	cast.sourceStart = castType.sourceStart - 1;
2090
	cast.sourceStart = castType.sourceStart - 1;
2085
	cast.sourceEnd = exp.sourceEnd;
2091
	cast.sourceEnd = exp.sourceEnd;
2086
}
2092
}
Lines 2088-2098 Link Here
2088
	// CastExpression ::= PushLPAREN Name Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
2094
	// CastExpression ::= PushLPAREN Name Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
2089
	popElement(K_CAST_STATEMENT);
2095
	popElement(K_CAST_STATEMENT);
2090
2096
2091
	Expression exp, cast, castType;
2097
	Expression exp;
2092
2098
	Expression cast;
2099
	TypeReference castType;
2093
	this.expressionPtr--;
2100
	this.expressionPtr--;
2094
	this.expressionLengthPtr--;
2101
	this.expressionLengthPtr--;
2095
	this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr+1], castType = this.expressionStack[this.expressionPtr]);
2102
	this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr+1], castType = (TypeReference) this.expressionStack[this.expressionPtr]);
2096
	cast.sourceStart = castType.sourceStart - 1;
2103
	cast.sourceStart = castType.sourceStart - 1;
2097
	cast.sourceEnd = exp.sourceEnd;
2104
	cast.sourceEnd = exp.sourceEnd;
2098
}
2105
}
(-)codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 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 134-140 Link Here
134
				Expression castType;
134
				Expression castType;
135
				if(this.expressionPtr > 0
135
				if(this.expressionPtr > 0
136
					&& ((castType = this.expressionStack[this.expressionPtr-1]) instanceof TypeReference)) {
136
					&& ((castType = this.expressionStack[this.expressionPtr-1]) instanceof TypeReference)) {
137
					CastExpression cast = new CastExpression(expression, castType);
137
					CastExpression cast = new CastExpression(expression, (TypeReference) castType);
138
					cast.sourceStart = castType.sourceStart;
138
					cast.sourceStart = castType.sourceStart;
139
					cast.sourceEnd= expression.sourceEnd;
139
					cast.sourceEnd= expression.sourceEnd;
140
					parentNode = cast;
140
					parentNode = cast;
(-)compiler/org/eclipse/jdt/core/compiler/IProblem.java (+1 lines)
Lines 526-531 Link Here
526
	int ThisInStaticContext = Internal + 200;
526
	int ThisInStaticContext = Internal + 200;
527
	int StaticMethodRequested = Internal + MethodRelated + 201;
527
	int StaticMethodRequested = Internal + MethodRelated + 201;
528
	int IllegalDimension = Internal + 202;
528
	int IllegalDimension = Internal + 202;
529
	/** @deprecated - problem is no longer generated */
529
	int InvalidTypeExpression = Internal + 203;
530
	int InvalidTypeExpression = Internal + 203;
530
	int ParsingError = Syntax + Internal + 204;
531
	int ParsingError = Syntax + Internal + 204;
531
	int ParsingErrorNoSuggestion = Syntax + Internal + 205;
532
	int ParsingErrorNoSuggestion = Syntax + Internal + 205;
(-)compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java (-45 / +36 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 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 37-47 Link Here
37
public class CastExpression extends Expression {
37
public class CastExpression extends Expression {
38
38
39
	public Expression expression;
39
	public Expression expression;
40
	public Expression type;
40
	public TypeReference type;
41
	public TypeBinding expectedType; // when assignment conversion to a given expected type: String s = (String) t;
41
	public TypeBinding expectedType; // when assignment conversion to a given expected type: String s = (String) t;
42
42
43
//expression.implicitConversion holds the cast for baseType casting
43
//expression.implicitConversion holds the cast for baseType casting
44
public CastExpression(Expression expression, Expression type) {
44
public CastExpression(Expression expression, TypeReference type) {
45
	this.expression = expression;
45
	this.expression = expression;
46
	this.type = type;
46
	this.type = type;
47
	type.bits |= ASTNode.IgnoreRawTypeCheck; // no need to worry about raw type usage
47
	type.bits |= ASTNode.IgnoreRawTypeCheck; // no need to worry about raw type usage
Lines 476-530 Link Here
476
	this.constant = Constant.NotAConstant;
476
	this.constant = Constant.NotAConstant;
477
	this.implicitConversion = TypeIds.T_undefined;
477
	this.implicitConversion = TypeIds.T_undefined;
478
478
479
	if ((this.type instanceof TypeReference) || (this.type instanceof NameReference)
479
	boolean exprContainCast = false;
480
			&& ((this.type.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) == 0) { // no extra parenthesis around type: ((A))exp
481
480
482
		boolean exprContainCast = false;
481
	TypeBinding castType = this.resolvedType = this.type.resolveType(scope);
483
482
	//expression.setExpectedType(this.resolvedType); // needed in case of generic method invocation
484
		TypeBinding castType = this.resolvedType = this.type.resolveType(scope);
483
	if (this.expression instanceof CastExpression) {
485
		//expression.setExpectedType(this.resolvedType); // needed in case of generic method invocation
484
		this.expression.bits |= ASTNode.DisableUnnecessaryCastCheck;
486
		if (this.expression instanceof CastExpression) {
485
		exprContainCast = true;
487
			this.expression.bits |= ASTNode.DisableUnnecessaryCastCheck;
486
	}
488
			exprContainCast = true;
487
	TypeBinding expressionType = this.expression.resolveType(scope);
489
		}
488
	if (castType != null) {
490
		TypeBinding expressionType = this.expression.resolveType(scope);
489
		if (expressionType != null) {
491
		if (castType != null) {
490
			boolean isLegal = checkCastTypesCompatibility(scope, castType, expressionType, this.expression);
492
			if (expressionType != null) {
491
			if (isLegal) {
493
				boolean isLegal = checkCastTypesCompatibility(scope, castType, expressionType, this.expression);
492
				this.expression.computeConversion(scope, castType, expressionType);
494
				if (isLegal) {
493
				if ((this.bits & ASTNode.UnsafeCast) != 0) { // unsafe cast
495
					this.expression.computeConversion(scope, castType, expressionType);
494
					if (scope.compilerOptions().reportUnavoidableGenericTypeProblems || !this.expression.forcedToBeRaw(scope.referenceContext())) {
496
					if ((this.bits & ASTNode.UnsafeCast) != 0) { // unsafe cast
495
						scope.problemReporter().unsafeCast(this, scope);
497
						if (scope.compilerOptions().reportUnavoidableGenericTypeProblems || !this.expression.forcedToBeRaw(scope.referenceContext())) {
498
							scope.problemReporter().unsafeCast(this, scope);
499
						}
500
					} else {
501
						if (castType.isRawType() && scope.compilerOptions().getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore){
502
							scope.problemReporter().rawTypeReference(this.type, castType);
503
						}
504
						if ((this.bits & (ASTNode.UnnecessaryCast|ASTNode.DisableUnnecessaryCastCheck)) == ASTNode.UnnecessaryCast) { // unnecessary cast
505
							if (!isIndirectlyUsed()) // used for generic type inference or boxing ?
506
								scope.problemReporter().unnecessaryCast(this);
507
						}
508
					}
496
					}
509
				} else { // illegal cast
497
				} else {
510
					if ((castType.tagBits & TagBits.HasMissingType) == 0) { // no complaint if secondary error
498
					if (castType.isRawType() && scope.compilerOptions().getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore){
511
						scope.problemReporter().typeCastError(this, castType, expressionType);
499
						scope.problemReporter().rawTypeReference(this.type, castType);
500
					}
501
					if ((this.bits & (ASTNode.UnnecessaryCast|ASTNode.DisableUnnecessaryCastCheck)) == ASTNode.UnnecessaryCast) { // unnecessary cast
502
						if (!isIndirectlyUsed()) // used for generic type inference or boxing ?
503
							scope.problemReporter().unnecessaryCast(this);
512
					}
504
					}
513
					this.bits |= ASTNode.DisableUnnecessaryCastCheck; // disable further secondary diagnosis
514
				}
505
				}
506
			} else { // illegal cast
507
				if ((castType.tagBits & TagBits.HasMissingType) == 0) { // no complaint if secondary error
508
					scope.problemReporter().typeCastError(this, castType, expressionType);
509
				}
510
				this.bits |= ASTNode.DisableUnnecessaryCastCheck; // disable further secondary diagnosis
515
			}
511
			}
516
			this.resolvedType = castType.capture(scope, this.sourceEnd);
517
			if (exprContainCast) {
518
				checkNeedForCastCast(scope, this);
519
			}
520
		}
512
		}
521
		return this.resolvedType;
513
		this.resolvedType = castType.capture(scope, this.sourceEnd);
522
	} else { // expression as a cast
514
		if (exprContainCast) {
523
		TypeBinding expressionType = this.expression.resolveType(scope);
515
			checkNeedForCastCast(scope, this);
524
		if (expressionType == null) return null;
516
		}
525
		scope.problemReporter().invalidTypeReference(this.type);
526
		return null;
527
	}
517
	}
518
	return this.resolvedType;
528
}
519
}
529
520
530
/**
521
/**
(-)compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java (-6 / +15 lines)
Lines 2026-2037 Link Here
2026
2026
2027
	//optimize push/pop
2027
	//optimize push/pop
2028
2028
2029
	Expression cast,exp;
2029
	Expression cast;
2030
	Expression exp;
2030
	this.expressionPtr--;
2031
	this.expressionPtr--;
2031
	this.expressionStack[this.expressionPtr] =
2032
	this.expressionStack[this.expressionPtr] =
2032
		cast = new CastExpression(
2033
		cast = new CastExpression(
2033
			exp=this.expressionStack[this.expressionPtr+1] ,
2034
			exp=this.expressionStack[this.expressionPtr+1] ,
2034
			this.expressionStack[this.expressionPtr]);
2035
			(TypeReference) this.expressionStack[this.expressionPtr]);
2035
	this.expressionLengthPtr -- ;
2036
	this.expressionLengthPtr -- ;
2036
	updateSourcePosition(cast);
2037
	updateSourcePosition(cast);
2037
	cast.sourceEnd=exp.sourceEnd;
2038
	cast.sourceEnd=exp.sourceEnd;
Lines 2039-2045 Link Here
2039
protected void consumeCastExpressionWithGenericsArray() {
2040
protected void consumeCastExpressionWithGenericsArray() {
2040
	// CastExpression ::= PushLPAREN Name TypeArguments Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
2041
	// CastExpression ::= PushLPAREN Name TypeArguments Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
2041
2042
2042
	Expression exp, cast, castType;
2043
	Expression exp;
2044
	Expression cast;
2045
	TypeReference castType;
2043
	int end = this.intStack[this.intPtr--];
2046
	int end = this.intStack[this.intPtr--];
2044
2047
2045
	int dim = this.intStack[this.intPtr--];
2048
	int dim = this.intStack[this.intPtr--];
Lines 2054-2060 Link Here
2054
protected void consumeCastExpressionWithNameArray() {
2057
protected void consumeCastExpressionWithNameArray() {
2055
	// CastExpression ::= PushLPAREN Name Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
2058
	// CastExpression ::= PushLPAREN Name Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
2056
2059
2057
	Expression exp, cast, castType;
2060
	Expression exp;
2061
	Expression cast;
2062
	TypeReference castType;
2058
	int end = this.intStack[this.intPtr--];
2063
	int end = this.intStack[this.intPtr--];
2059
2064
2060
	// handle type arguments
2065
	// handle type arguments
Lines 2073-2079 Link Here
2073
2078
2074
	//optimize the push/pop
2079
	//optimize the push/pop
2075
2080
2076
	Expression exp, cast, castType;
2081
	Expression exp;
2082
	Expression cast;
2083
	TypeReference castType;
2077
	int end = this.intStack[this.intPtr--];
2084
	int end = this.intStack[this.intPtr--];
2078
	this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr], castType = getTypeReference(this.intStack[this.intPtr--]));
2085
	this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr], castType = getTypeReference(this.intStack[this.intPtr--]));
2079
	castType.sourceEnd = end - 1;
2086
	castType.sourceEnd = end - 1;
Lines 2082-2088 Link Here
2082
}
2089
}
2083
protected void consumeCastExpressionWithQualifiedGenericsArray() {
2090
protected void consumeCastExpressionWithQualifiedGenericsArray() {
2084
	// CastExpression ::= PushLPAREN Name OnlyTypeArguments '.' ClassOrInterfaceType Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
2091
	// CastExpression ::= PushLPAREN Name OnlyTypeArguments '.' ClassOrInterfaceType Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
2085
	Expression exp, cast, castType;
2092
	Expression exp;
2093
	Expression cast;
2094
	TypeReference castType;
2086
	int end = this.intStack[this.intPtr--];
2095
	int end = this.intStack[this.intPtr--];
2087
2096
2088
	int dim = this.intStack[this.intPtr--];
2097
	int dim = this.intStack[this.intPtr--];
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-8 lines)
Lines 3807-3820 Link Here
3807
			expression.sourceStart,
3807
			expression.sourceStart,
3808
			expression.sourceEnd);
3808
			expression.sourceEnd);
3809
}
3809
}
3810
public void invalidTypeReference(Expression expression) {
3811
	this.handle(
3812
		IProblem.InvalidTypeExpression,
3813
		NoArgument,
3814
		NoArgument,
3815
		expression.sourceStart,
3816
		expression.sourceEnd);
3817
}
3818
public void invalidTypeToSynchronize(Expression expression, TypeBinding type) {
3810
public void invalidTypeToSynchronize(Expression expression, TypeBinding type) {
3819
	this.handle(
3811
	this.handle(
3820
		IProblem.InvalidTypeToSynchronized,
3812
		IProblem.InvalidTypeToSynchronized,
(-)compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties (-1 / +1 lines)
Lines 181-187 Link Here
181
200 = Cannot use {0} in a static context
181
200 = Cannot use {0} in a static context
182
201 = Cannot make a static reference to the non-static method {1}({2}) from the type {0}
182
201 = Cannot make a static reference to the non-static method {1}({2}) from the type {0}
183
202 = Cannot specify an array dimension after an empty dimension
183
202 = Cannot specify an array dimension after an empty dimension
184
203 = Invalid cast expression
184
#203 = Invalid cast expression
185
204 = Syntax error on token "{0}", {1} expected
185
204 = Syntax error on token "{0}", {1} expected
186
205 = Syntax error on token "{0}", no accurate correction available
186
205 = Syntax error on token "{0}", no accurate correction available
187
206 = Invalid argument to operation ++/--
187
206 = Invalid argument to operation ++/--
(-)dom/org/eclipse/jdt/core/dom/ASTConverter.java (-18 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 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 1196-1208 Link Here
1196
	public CastExpression convert(org.eclipse.jdt.internal.compiler.ast.CastExpression expression) {
1196
	public CastExpression convert(org.eclipse.jdt.internal.compiler.ast.CastExpression expression) {
1197
		CastExpression castExpression = new CastExpression(this.ast);
1197
		CastExpression castExpression = new CastExpression(this.ast);
1198
		castExpression.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
1198
		castExpression.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
1199
		org.eclipse.jdt.internal.compiler.ast.Expression type = expression.type;
1199
		TypeReference type = expression.type;
1200
		trimWhiteSpacesAndComments(type);
1200
		trimWhiteSpacesAndComments(type);
1201
		if (type instanceof org.eclipse.jdt.internal.compiler.ast.TypeReference ) {
1201
		castExpression.setType(convertType(type));
1202
			castExpression.setType(convertType((org.eclipse.jdt.internal.compiler.ast.TypeReference)type));
1203
		} else if (type instanceof org.eclipse.jdt.internal.compiler.ast.NameReference) {
1204
			castExpression.setType(convertToType((org.eclipse.jdt.internal.compiler.ast.NameReference)type));
1205
		}
1206
		castExpression.setExpression(convert(expression.expression));
1202
		castExpression.setExpression(convert(expression.expression));
1207
		if (this.resolveBindings) {
1203
		if (this.resolveBindings) {
1208
			recordNodes(castExpression, expression);
1204
			recordNodes(castExpression, expression);
Lines 2965-2981 Link Here
2965
		return parenthesizedExpression;
2961
		return parenthesizedExpression;
2966
	}
2962
	}
2967
2963
2968
	public Type convertToType(org.eclipse.jdt.internal.compiler.ast.NameReference reference) {
2969
		Name name = convert(reference);
2970
		final SimpleType type = new SimpleType(this.ast);
2971
		type.setName(name);
2972
		type.setSourceRange(name.getStartPosition(), name.getLength());
2973
		if (this.resolveBindings) {
2974
			this.recordNodes(type, reference);
2975
		}
2976
		return type;
2977
	}
2978
2979
	protected VariableDeclarationExpression convertToVariableDeclarationExpression(org.eclipse.jdt.internal.compiler.ast.LocalDeclaration localDeclaration) {
2964
	protected VariableDeclarationExpression convertToVariableDeclarationExpression(org.eclipse.jdt.internal.compiler.ast.LocalDeclaration localDeclaration) {
2980
		final VariableDeclarationFragment variableDeclarationFragment = convertToVariableDeclarationFragment(localDeclaration);
2965
		final VariableDeclarationFragment variableDeclarationFragment = convertToVariableDeclarationFragment(localDeclaration);
2981
		final VariableDeclarationExpression variableDeclarationExpression = new VariableDeclarationExpression(this.ast);
2966
		final VariableDeclarationExpression variableDeclarationExpression = new VariableDeclarationExpression(this.ast);
(-)search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java (-16 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 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 213-257 Link Here
213
	super.consumeCastExpressionLL1();
213
	super.consumeCastExpressionLL1();
214
	if ((this.patternFineGrain & IJavaSearchConstants.CAST_TYPE_REFERENCE) != 0) {
214
	if ((this.patternFineGrain & IJavaSearchConstants.CAST_TYPE_REFERENCE) != 0) {
215
		CastExpression castExpression = (CastExpression) this.expressionStack[this.expressionPtr];
215
		CastExpression castExpression = (CastExpression) this.expressionStack[this.expressionPtr];
216
		if (castExpression.type instanceof TypeReference) {
216
		this.patternLocator.match(castExpression.type, this.nodeSet);
217
			this.patternLocator.match((TypeReference) castExpression.type, this.nodeSet);
218
        }
219
	}
217
	}
220
}
218
}
221
protected void consumeCastExpressionWithGenericsArray() {
219
protected void consumeCastExpressionWithGenericsArray() {
222
	super.consumeCastExpressionWithGenericsArray();
220
	super.consumeCastExpressionWithGenericsArray();
223
	if ((this.patternFineGrain & IJavaSearchConstants.CAST_TYPE_REFERENCE) != 0) {
221
	if ((this.patternFineGrain & IJavaSearchConstants.CAST_TYPE_REFERENCE) != 0) {
224
		CastExpression castExpression = (CastExpression) this.expressionStack[this.expressionPtr];
222
		CastExpression castExpression = (CastExpression) this.expressionStack[this.expressionPtr];
225
		if (castExpression.type instanceof Reference) {
223
		this.patternLocator.match(castExpression.type, this.nodeSet);
226
			this.patternLocator.match((Reference) castExpression.type, this.nodeSet);
227
        }
228
	}
224
	}
229
}
225
}
230
protected void consumeCastExpressionWithNameArray() {
226
protected void consumeCastExpressionWithNameArray() {
231
	super.consumeCastExpressionWithNameArray();
227
	super.consumeCastExpressionWithNameArray();
232
	if ((this.patternFineGrain & IJavaSearchConstants.CAST_TYPE_REFERENCE) != 0) {
228
	if ((this.patternFineGrain & IJavaSearchConstants.CAST_TYPE_REFERENCE) != 0) {
233
		CastExpression castExpression = (CastExpression) this.expressionStack[this.expressionPtr];
229
		CastExpression castExpression = (CastExpression) this.expressionStack[this.expressionPtr];
234
		if (castExpression.type instanceof Reference) {
230
		this.patternLocator.match(castExpression.type, this.nodeSet);
235
			this.patternLocator.match((Reference) castExpression.type, this.nodeSet);
236
        }
237
	}
231
	}
238
}
232
}
239
protected void consumeCastExpressionWithPrimitiveType() {
233
protected void consumeCastExpressionWithPrimitiveType() {
240
	super.consumeCastExpressionWithPrimitiveType();
234
	super.consumeCastExpressionWithPrimitiveType();
241
	if ((this.patternFineGrain & IJavaSearchConstants.CAST_TYPE_REFERENCE) != 0) {
235
	if ((this.patternFineGrain & IJavaSearchConstants.CAST_TYPE_REFERENCE) != 0) {
242
		CastExpression castExpression = (CastExpression) this.expressionStack[this.expressionPtr];
236
		CastExpression castExpression = (CastExpression) this.expressionStack[this.expressionPtr];
243
		if (castExpression.type instanceof Reference) {
237
		this.patternLocator.match(castExpression.type, this.nodeSet);
244
			this.patternLocator.match((Reference) castExpression.type, this.nodeSet);
245
        }
246
	}
238
	}
247
}
239
}
248
protected void consumeCastExpressionWithQualifiedGenericsArray() {
240
protected void consumeCastExpressionWithQualifiedGenericsArray() {
249
	super.consumeCastExpressionWithQualifiedGenericsArray();
241
	super.consumeCastExpressionWithQualifiedGenericsArray();
250
	if ((this.patternFineGrain & IJavaSearchConstants.CAST_TYPE_REFERENCE) != 0) {
242
	if ((this.patternFineGrain & IJavaSearchConstants.CAST_TYPE_REFERENCE) != 0) {
251
		CastExpression castExpression = (CastExpression) this.expressionStack[this.expressionPtr];
243
		CastExpression castExpression = (CastExpression) this.expressionStack[this.expressionPtr];
252
		if (castExpression.type instanceof Reference) {
244
		this.patternLocator.match(castExpression.type, this.nodeSet);
253
			this.patternLocator.match((Reference) castExpression.type, this.nodeSet);
254
        }
255
	}
245
	}
256
}
246
}
257
247

Return to bug 338118