View | Details | Raw Unified | Return to bug 307337
Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredField.java (-3 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 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 207-214 Link Here
207
					TypeDeclaration anonymousType = recoveredType.updatedTypeDeclaration(depth + 1, knownTypes);
207
					TypeDeclaration anonymousType = recoveredType.updatedTypeDeclaration(depth + 1, knownTypes);
208
					if (anonymousType != null) {
208
					if (anonymousType != null) {
209
						this.fieldDeclaration.initialization = anonymousType.allocation;
209
						this.fieldDeclaration.initialization = anonymousType.allocation;
210
						if(this.fieldDeclaration.declarationSourceEnd == 0) {
210
						int end = anonymousType.declarationSourceEnd;
211
							int end = anonymousType.declarationSourceEnd;
211
						if (end > this.fieldDeclaration.declarationSourceEnd) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=307337
212
							this.fieldDeclaration.declarationSourceEnd = end;
212
							this.fieldDeclaration.declarationSourceEnd = end;
213
							this.fieldDeclaration.declarationEnd = end;
213
							this.fieldDeclaration.declarationEnd = end;
214
						}
214
						}
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests.java (+27 lines)
Lines 20947-20950 Link Here
20947
			"this[KEYWORD]{this, null, null, this, null, replace[" + start1 + ", " + end1 +"], token[" + start1 + ", " + end1 + "], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED) + "}",
20947
			"this[KEYWORD]{this, null, null, this, null, replace[" + start1 + ", " + end1 +"], token[" + start1 + ", " + end1 + "], " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE+ R_NON_RESTRICTED) + "}",
20948
			requestor.getResults());
20948
			requestor.getResults());
20949
}
20949
}
20950
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=307337
20951
public void testBug307337() throws JavaModelException {
20952
	this.workingCopies = new ICompilationUnit[1];
20953
	this.workingCopies[0] = getWorkingCopy(
20954
		"/Completion/src/test/TestBug307337.java",
20955
		"package test;\n" +
20956
		"public class TestBug307337 {\n" +
20957
		"    Object obj = new Object() {\n" +
20958
		"    TestBug307337\n" + 	
20959
		"     };\n" +
20960
		"}\n");
20961
20962
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, true, true, true, true);
20963
	requestor.allowAllRequiredProposals();
20964
	requestor.setRequireExtendedContext(true);
20965
	requestor.setComputeEnclosingElement(true);
20966
	String str = this.workingCopies[0].getSource();
20967
	String completeBehind = "TestBug307337";
20968
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
20969
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
20970
	
20971
	assertResults(
20972
			"expectedTypesSignatures=null\n" +
20973
			"expectedTypesKeys=null\n" +
20974
			"enclosingElement=<anonymous #1> {key=Ltest/TestBug307337$64;} [in obj [in TestBug307337 [in [Working copy] TestBug307337.java [in test [in src [in Completion]]]]]]",
20975
			requestor.getContext());
20976
}
20950
}
20977
}

Return to bug 307337