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

Collapse All | Expand All

(-)codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java (-2 / +4 lines)
Lines 132-139 Link Here
132
		/* Initializer bodies are parsed in the context of the type declaration, we must thus search it inside */
132
		/* Initializer bodies are parsed in the context of the type declaration, we must thus search it inside */
133
		if (this.referenceContext instanceof TypeDeclaration){
133
		if (this.referenceContext instanceof TypeDeclaration){
134
			TypeDeclaration type = (TypeDeclaration) this.referenceContext;
134
			TypeDeclaration type = (TypeDeclaration) this.referenceContext;
135
			for (int i = 0; i < type.fields.length; i++){
135
			FieldDeclaration[] fields = type.fields;
136
				FieldDeclaration field = type.fields[i];
136
			int length = fields == null ? 0 : fields.length;
137
			for (int i = 0; i < length; i++){
138
				FieldDeclaration field = fields[i];
137
				if (field != null
139
				if (field != null
138
						&& field.getKind() == AbstractVariableDeclaration.INITIALIZER
140
						&& field.getKind() == AbstractVariableDeclaration.INITIALIZER
139
						&& field.declarationSourceStart <= this.scanner.initialPosition
141
						&& field.declarationSourceStart <= this.scanner.initialPosition
(-)compiler/org/eclipse/jdt/internal/compiler/ClassFile.java (-1 / +1 lines)
Lines 1998-2004 Link Here
1998
						// report an error and abort: will lead to a problem type classfile creation
1998
						// report an error and abort: will lead to a problem type classfile creation
1999
						TypeDeclaration typeDeclaration = this.referenceBinding.scope.referenceContext;
1999
						TypeDeclaration typeDeclaration = this.referenceBinding.scope.referenceContext;
2000
						FieldDeclaration[] fieldDecls = typeDeclaration.fields;
2000
						FieldDeclaration[] fieldDecls = typeDeclaration.fields;
2001
						for (int i = 0, max = fieldDecls.length; i < max; i++) {
2001
						for (int i = 0, max = (fieldDecls == null) ? 0 : fieldDecls.length; i < max; i++) {
2002
							if (fieldDecls[i].binding == fieldBinding) {
2002
							if (fieldDecls[i].binding == fieldBinding) {
2003
								// problem should abort
2003
								// problem should abort
2004
								typeDeclaration.scope.problemReporter().stringConstantIsExceedingUtf8Limit(
2004
								typeDeclaration.scope.problemReporter().stringConstantIsExceedingUtf8Limit(
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java (-12 / +18 lines)
Lines 166-173 Link Here
166
		FieldBinding existingField;
166
		FieldBinding existingField;
167
		if ((existingField = getField(synthField.name, true /*resolve*/)) != null) {
167
		if ((existingField = getField(synthField.name, true /*resolve*/)) != null) {
168
			TypeDeclaration typeDecl = this.scope.referenceContext;
168
			TypeDeclaration typeDecl = this.scope.referenceContext;
169
			for (int i = 0, max = typeDecl.fields.length; i < max; i++) {
169
			FieldDeclaration[] fieldDeclarations = typeDecl.fields;
170
				FieldDeclaration fieldDecl = typeDecl.fields[i];
170
			for (int i = 0, max = fieldDeclarations == null ? 0 : fieldDeclarations.length; i < max; i++) {
171
				FieldDeclaration fieldDecl = fieldDeclarations[i];
171
				if (fieldDecl.binding == existingField) {
172
				if (fieldDecl.binding == existingField) {
172
					synthField.name = CharOperation.concat(
173
					synthField.name = CharOperation.concat(
173
						TypeConstants.SYNTHETIC_OUTER_LOCAL_PREFIX,
174
						TypeConstants.SYNTHETIC_OUTER_LOCAL_PREFIX,
Lines 210-217 Link Here
210
		FieldBinding existingField;
211
		FieldBinding existingField;
211
		if ((existingField = getField(synthField.name, true /*resolve*/)) != null) {
212
		if ((existingField = getField(synthField.name, true /*resolve*/)) != null) {
212
			TypeDeclaration typeDecl = this.scope.referenceContext;
213
			TypeDeclaration typeDecl = this.scope.referenceContext;
213
			for (int i = 0, max = typeDecl.fields.length; i < max; i++) {
214
			FieldDeclaration[] fieldDeclarations = typeDecl.fields;
214
				FieldDeclaration fieldDecl = typeDecl.fields[i];
215
			for (int i = 0, max = fieldDeclarations == null ? 0 : fieldDeclarations.length; i < max; i++) {
216
				FieldDeclaration fieldDecl = fieldDeclarations[i];
215
				if (fieldDecl.binding == existingField) {
217
				if (fieldDecl.binding == existingField) {
216
					if (this.scope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_5) {
218
					if (this.scope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_5) {
217
						synthField.name = CharOperation.concat(
219
						synthField.name = CharOperation.concat(
Lines 255-262 Link Here
255
	FieldBinding existingField;
257
	FieldBinding existingField;
256
	if ((existingField = getField(synthField.name, true /*resolve*/)) != null) {
258
	if ((existingField = getField(synthField.name, true /*resolve*/)) != null) {
257
		TypeDeclaration typeDecl = blockScope.referenceType();
259
		TypeDeclaration typeDecl = blockScope.referenceType();
258
		for (int i = 0, max = typeDecl.fields.length; i < max; i++) {
260
		FieldDeclaration[] typeDeclarationFields = typeDecl.fields;
259
			FieldDeclaration fieldDecl = typeDecl.fields[i];
261
		for (int i = 0, max = typeDeclarationFields == null ? 0 : typeDeclarationFields.length; i < max; i++) {
262
			FieldDeclaration fieldDecl = typeDeclarationFields[i];
260
			if (fieldDecl.binding == existingField) {
263
			if (fieldDecl.binding == existingField) {
261
				blockScope.problemReporter().duplicateFieldInType(this, fieldDecl);
264
				blockScope.problemReporter().duplicateFieldInType(this, fieldDecl);
262
				break;
265
				break;
Lines 294-300 Link Here
294
		FieldBinding existingField;
297
		FieldBinding existingField;
295
		if ((existingField = getField(synthField.name, true /*resolve*/)) != null) {
298
		if ((existingField = getField(synthField.name, true /*resolve*/)) != null) {
296
			TypeDeclaration typeDecl = this.scope.referenceContext;
299
			TypeDeclaration typeDecl = this.scope.referenceContext;
297
			for (int i = 0, max = typeDecl.fields.length; i < max; i++) {
300
			for (int i = 0, max = (typeDecl.fields == null) ? 0 : typeDecl.fields.length; i < max; i++) {
298
				FieldDeclaration fieldDecl = typeDecl.fields[i];
301
				FieldDeclaration fieldDecl = typeDecl.fields[i];
299
				if (fieldDecl.binding == existingField) {
302
				if (fieldDecl.binding == existingField) {
300
					synthField.name = CharOperation.concat(
303
					synthField.name = CharOperation.concat(
Lines 337-344 Link Here
337
		FieldBinding existingField;
340
		FieldBinding existingField;
338
		if ((existingField = getField(synthField.name, true /*resolve*/)) != null) {
341
		if ((existingField = getField(synthField.name, true /*resolve*/)) != null) {
339
			TypeDeclaration typeDecl = this.scope.referenceContext;
342
			TypeDeclaration typeDecl = this.scope.referenceContext;
340
			for (int i = 0, max = typeDecl.fields.length; i < max; i++) {
343
			FieldDeclaration[] fieldDeclarations = typeDecl.fields;
341
				FieldDeclaration fieldDecl = typeDecl.fields[i];
344
			for (int i = 0, max = fieldDeclarations == null ? 0 : fieldDeclarations.length; i < max; i++) {
345
				FieldDeclaration fieldDecl = fieldDeclarations[i];
342
				if (fieldDecl.binding == existingField) {
346
				if (fieldDecl.binding == existingField) {
343
					synthField.name = CharOperation.concat(
347
					synthField.name = CharOperation.concat(
344
						TypeConstants.SYNTHETIC_ENUM_VALUES,
348
						TypeConstants.SYNTHETIC_ENUM_VALUES,
Lines 425-432 Link Here
425
		FieldBinding existingField;
429
		FieldBinding existingField;
426
		if ((existingField = getField(synthField.name, true /*resolve*/)) != null) {
430
		if ((existingField = getField(synthField.name, true /*resolve*/)) != null) {
427
			TypeDeclaration typeDecl = this.scope.referenceContext;
431
			TypeDeclaration typeDecl = this.scope.referenceContext;
428
			for (int i = 0, max = typeDecl.fields.length; i < max; i++) {
432
			FieldDeclaration[] fieldDeclarations = typeDecl.fields;
429
				FieldDeclaration fieldDecl = typeDecl.fields[i];
433
			for (int i = 0, max = fieldDeclarations == null ? 0 : fieldDeclarations.length; i < max; i++) {
434
				FieldDeclaration fieldDecl = fieldDeclarations[i];
430
				if (fieldDecl.binding == existingField) {
435
				if (fieldDecl.binding == existingField) {
431
					synthField.name = CharOperation.concat(
436
					synthField.name = CharOperation.concat(
432
						fieldName,
437
						fieldName,
Lines 1256-1262 Link Here
1256
	if (hasRestrictedAccess())
1261
	if (hasRestrictedAccess())
1257
		field.modifiers |= ExtraCompilerModifiers.AccRestrictedAccess;
1262
		field.modifiers |= ExtraCompilerModifiers.AccRestrictedAccess;
1258
	FieldDeclaration[] fieldDecls = this.scope.referenceContext.fields;
1263
	FieldDeclaration[] fieldDecls = this.scope.referenceContext.fields;
1259
	for (int f = 0, length = fieldDecls.length; f < length; f++) {
1264
	int length = fieldDecls == null ? 0 : fieldDecls.length;
1265
	for (int f = 0; f < length; f++) {
1260
		if (fieldDecls[f].binding != field)
1266
		if (fieldDecls[f].binding != field)
1261
			continue;
1267
			continue;
1262
1268
(-)compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java (-2 / +4 lines)
Lines 952-959 Link Here
952
			/* Initializer bodies are parsed in the context of the type declaration, we must thus search it inside */
952
			/* Initializer bodies are parsed in the context of the type declaration, we must thus search it inside */
953
			if (this.referenceContext instanceof TypeDeclaration){
953
			if (this.referenceContext instanceof TypeDeclaration){
954
				TypeDeclaration type = (TypeDeclaration) this.referenceContext;
954
				TypeDeclaration type = (TypeDeclaration) this.referenceContext;
955
				for (int i = 0; i < type.fields.length; i++){
955
				FieldDeclaration[] fieldDeclarations = type.fields;
956
					FieldDeclaration field = type.fields[i];
956
				int length = fieldDeclarations == null ? 0 : fieldDeclarations.length;
957
				for (int i = 0; i < length; i++){
958
					FieldDeclaration field = fieldDeclarations[i];
957
					if (field != null
959
					if (field != null
958
						&& field.getKind() == AbstractVariableDeclaration.INITIALIZER
960
						&& field.getKind() == AbstractVariableDeclaration.INITIALIZER
959
						&& ((Initializer) field).block != null
961
						&& ((Initializer) field).block != null
(-)model/org/eclipse/jdt/internal/core/util/HandleFactory.java (-1 / +2 lines)
Lines 204-210 Link Here
204
					// inside field or initializer, must find proper one
204
					// inside field or initializer, must find proper one
205
					TypeDeclaration type = methodScope.referenceType();
205
					TypeDeclaration type = methodScope.referenceType();
206
					int occurenceCount = 1;
206
					int occurenceCount = 1;
207
					for (int i = 0, length = type.fields.length; i < length; i++) {
207
					int length = type.fields == null ? 0 : type.fields.length;
208
					for (int i = 0; i < length; i++) {
208
						FieldDeclaration field = type.fields[i];
209
						FieldDeclaration field = type.fields[i];
209
						if (field.declarationSourceStart <= elementPosition && elementPosition <= field.declarationSourceEnd) {
210
						if (field.declarationSourceStart <= elementPosition && elementPosition <= field.declarationSourceEnd) {
210
							switch (field.getKind()) {
211
							switch (field.getKind()) {
(-)search/org/eclipse/jdt/internal/core/search/matching/FieldLocator.java (-5 / +7 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 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 278-287 Link Here
278
			TypeDeclaration typeDecl = scope.referenceContext;
278
			TypeDeclaration typeDecl = scope.referenceContext;
279
			FieldDeclaration fieldDecl = null;
279
			FieldDeclaration fieldDecl = null;
280
			FieldDeclaration[] fieldDecls = typeDecl.fields;
280
			FieldDeclaration[] fieldDecls = typeDecl.fields;
281
			for (int i = 0, length = fieldDecls.length; i < length; i++) {
281
			if (fieldDecls != null) {
282
				if (CharOperation.equals(bindingName, fieldDecls[i].name)) {
282
				for (int i = 0, length = fieldDecls.length; i < length; i++) {
283
					fieldDecl = fieldDecls[i];
283
					if (CharOperation.equals(bindingName, fieldDecls[i].name)) {
284
					break;
284
						fieldDecl = fieldDecls[i];
285
						break;
286
					}
285
				}
287
				}
286
			}
288
			}
287
			if (fieldDecl != null) {
289
			if (fieldDecl != null) {
(-)search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java (-2 / +3 lines)
Lines 557-566 Link Here
557
		// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=98378
557
		// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=98378
558
		return type;
558
		return type;
559
	}
559
	}
560
	// find occurence count of the given initializer in its type declaration
560
	// find occurrence count of the given initializer in its type declaration
561
	int occurrenceCount = 0;
561
	int occurrenceCount = 0;
562
	FieldDeclaration[] fields = typeDeclaration.fields;
562
	FieldDeclaration[] fields = typeDeclaration.fields;
563
	for (int i = 0, length = fields.length; i < length; i++) {
563
	int length = fields == null ? 0 : fields.length;
564
	for (int i = 0; i < length; i++) {
564
		if (fields[i].getKind() == AbstractVariableDeclaration.INITIALIZER) {
565
		if (fields[i].getKind() == AbstractVariableDeclaration.INITIALIZER) {
565
			occurrenceCount++;
566
			occurrenceCount++;
566
			if (fields[i].equals(fieldDeclaration)) break;
567
			if (fields[i].equals(fieldDeclaration)) break;
(-)src/org/eclipse/jdt/core/tests/compiler/parser/AbstractCompletionTest.java (-6 / +8 lines)
Lines 141-149 Link Here
141
			parser.parseBlockStatements((AbstractMethodDeclaration)foundMethod, unit);
141
			parser.parseBlockStatements((AbstractMethodDeclaration)foundMethod, unit);
142
		} else {
142
		} else {
143
			TypeDeclaration type = (TypeDeclaration)foundMethod;
143
			TypeDeclaration type = (TypeDeclaration)foundMethod;
144
			if (type.fields != null) {
144
			FieldDeclaration[] fields = type.fields;
145
				done : for (int i = 0; i < type.fields.length; i++) {
145
			if (fields != null) {
146
					FieldDeclaration field = type.fields[i];
146
				done : for (int i = 0; i < fields.length; i++) {
147
					FieldDeclaration field = fields[i];
147
					if (field.declarationSourceStart <= cursorLocation && (cursorLocation <= field.declarationSourceEnd || field.declarationSourceEnd == 0)) {
148
					if (field.declarationSourceStart <= cursorLocation && (cursorLocation <= field.declarationSourceEnd || field.declarationSourceEnd == 0)) {
148
						if (field instanceof Initializer) {
149
						if (field instanceof Initializer) {
149
							parser.parseBlockStatements((Initializer)field, type, unit);
150
							parser.parseBlockStatements((Initializer)field, type, unit);
Lines 359-367 Link Here
359
			}
360
			}
360
		}
361
		}
361
	}
362
	}
362
	if (type.fields != null) {
363
	FieldDeclaration[] fields = type.fields;
363
		for (int i = 0; i < type.fields.length; i++) {
364
	if (fields != null) {
364
			FieldDeclaration field = type.fields[i];
365
		for (int i = 0; i < fields.length; i++) {
366
			FieldDeclaration field = fields[i];
365
			if (field instanceof Initializer && field.declarationSourceStart <= cursorLocation && (cursorLocation <= field.declarationSourceEnd || field.declarationSourceEnd == 0)) {
367
			if (field instanceof Initializer && field.declarationSourceStart <= cursorLocation && (cursorLocation <= field.declarationSourceEnd || field.declarationSourceEnd == 0)) {
366
				return type;
368
				return type;
367
			}
369
			}
(-)src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSelectionTest.java (-6 / +8 lines)
Lines 161-169 Link Here
161
		parser.parseBlockStatements((AbstractMethodDeclaration)foundMethod, unit);
161
		parser.parseBlockStatements((AbstractMethodDeclaration)foundMethod, unit);
162
	} else {
162
	} else {
163
		TypeDeclaration type = (TypeDeclaration)foundMethod;
163
		TypeDeclaration type = (TypeDeclaration)foundMethod;
164
		if (type.fields != null) {
164
		FieldDeclaration[] fields = type.fields;
165
			for (int i = 0; i < type.fields.length; i++) {
165
		if (fields != null) {
166
				FieldDeclaration field = type.fields[i];
166
			for (int i = 0; i < fields.length; i++) {
167
				FieldDeclaration field = fields[i];
167
				if (field instanceof Initializer && field.sourceStart <= selectionStart && selectionStart <= field.sourceEnd) {
168
				if (field instanceof Initializer && field.sourceStart <= selectionStart && selectionStart <= field.sourceEnd) {
168
					parser.parseBlockStatements((Initializer)field, type, unit);
169
					parser.parseBlockStatements((Initializer)field, type, unit);
169
					break;
170
					break;
Lines 283-291 Link Here
283
			}
284
			}
284
		}
285
		}
285
	}
286
	}
286
	if (type.fields != null) {
287
	FieldDeclaration[] fields = type.fields;
287
		for (int i = 0; i < type.fields.length; i++) {
288
	if (fields != null) {
288
			FieldDeclaration field = type.fields[i];
289
		for (int i = 0; i < fields.length; i++) {
290
			FieldDeclaration field = fields[i];
289
			if (field instanceof Initializer) {
291
			if (field instanceof Initializer) {
290
				Initializer initializer = (Initializer)field;
292
				Initializer initializer = (Initializer)field;
291
				Block block = initializer.block;
293
				Block block = initializer.block;

Return to bug 328554