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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java (+29 lines)
Lines 7735-7738 Link Here
7735
				workingCopy.discardWorkingCopy();
7735
				workingCopy.discardWorkingCopy();
7736
		}
7736
		}
7737
	}
7737
	}
7738
	
7739
	/**
7740
	 * http://dev.eclipse.org/bugs/show_bug.cgi?id=136972
7741
	 */
7742
	public void test0646() throws JavaModelException {
7743
		ICompilationUnit workingCopy = null;
7744
		try {
7745
			String contents =
7746
				"public class X {\n" + 
7747
				"        static {\n" + 
7748
				"                class A\n" + 
7749
				"                Object o = new Object(){\n" + 
7750
				"                        void test(){\n" + 
7751
				"                        }\n" + 
7752
				"                };\n" + 
7753
				"        }\n" + 
7754
				"}";
7755
			workingCopy = getWorkingCopy("/Converter/src/X.java", true/*resolve*/);
7756
			ASTNode node = buildAST(
7757
				contents,
7758
				workingCopy,
7759
				false,
7760
				true);
7761
			assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
7762
		} finally {
7763
			if (workingCopy != null)
7764
				workingCopy.discardWorkingCopy();
7765
		}
7766
	}
7738
}
7767
}
(-)compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredField.java (-1 / +7 lines)
Lines 121-127 Link Here
121
					typeDeclaration.bodyEnd = this.fieldDeclaration.declarationSourceEnd;
121
					typeDeclaration.bodyEnd = this.fieldDeclaration.declarationSourceEnd;
122
				}
122
				}
123
				if (recoveredType.preserveContent){
123
				if (recoveredType.preserveContent){
124
					fieldDeclaration.initialization = recoveredType.updatedTypeDeclaration().allocation;
124
					TypeDeclaration anonymousType = recoveredType.updatedTypeDeclaration();
125
					fieldDeclaration.initialization = anonymousType.allocation;
126
					if(this.fieldDeclaration.declarationSourceEnd == 0) {
127
						int end = anonymousType.declarationSourceEnd;
128
						this.fieldDeclaration.declarationSourceEnd = end;
129
						this.fieldDeclaration.declarationEnd = end;
130
					}
125
				}
131
				}
126
			}
132
			}
127
			if (this.anonymousTypeCount > 0) fieldDeclaration.bits |= ASTNode.HasLocalType;
133
			if (this.anonymousTypeCount > 0) fieldDeclaration.bits |= ASTNode.HasLocalType;

Return to bug 136972