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

(-)src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java (-3 / +3 lines)
Lines 493-499 Link Here
493
	IType type = this.innerClasses.getClassFile("X$1.class").getType();
493
	IType type = this.innerClasses.getClassFile("X$1.class").getType();
494
	assertSourceEquals(
494
	assertSourceEquals(
495
		"Unexpected source",
495
		"Unexpected source",
496
		"X() {}",
496
		"new X() {}",
497
		type.getSource());
497
		type.getSource());
498
}
498
}
499
/*
499
/*
Lines 503-509 Link Here
503
	IType type = this.innerClasses.getClassFile("X$2.class").getType();
503
	IType type = this.innerClasses.getClassFile("X$2.class").getType();
504
	assertSourceEquals(
504
	assertSourceEquals(
505
		"Unexpected source",
505
		"Unexpected source",
506
		"Y() {\n" + 
506
		"new Y() {\n" + 
507
		"      class Z {}\n" + 
507
		"      class Z {}\n" + 
508
		"    }",
508
		"    }",
509
		type.getSource());
509
		type.getSource());
Lines 515-521 Link Here
515
	IType type = this.innerClasses.getClassFile("X$3.class").getType();
515
	IType type = this.innerClasses.getClassFile("X$3.class").getType();
516
	assertSourceEquals(
516
	assertSourceEquals(
517
		"Unexpected source",
517
		"Unexpected source",
518
		"W() {}",
518
		"new W() {}",
519
		type.getSource());
519
		type.getSource());
520
}
520
}
521
/*
521
/*
(-)src/org/eclipse/jdt/core/tests/model/GetSourceTests.java (+24 lines)
Lines 196-201 Link Here
196
	}
196
	}
197
	
197
	
198
	/*
198
	/*
199
	 * Ensures that the source range for an anonymous type is correct.
200
	 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=207775)
201
	 */
202
	public void testAnonymousSourceRange() throws CoreException {
203
		try {
204
			String cuSource = 
205
				"package p;\n" +
206
				"public class Y {\n" +
207
				"  void foo() {\n" +
208
				"    new Object() {};\n" +
209
				"  }\n" +
210
				"}";
211
			createFile("/P/p/Y.java", cuSource);
212
			IType type = getCompilationUnit("/P/p/Y.java").getType("Y").getMethod("foo", new String[0]).getType("", 1);
213
			assertSourceEquals(
214
				"Unexpected source'", 
215
				"new Object() {}",
216
				getSource(cuSource, type.getSourceRange()));
217
		} finally {
218
			deleteFile("/P/p/Y.java");
219
		}
220
	}
221
222
	/*
199
	 * Ensures that the name range for an annotation is correct.
223
	 * Ensures that the name range for an annotation is correct.
200
	 */
224
	 */
201
	public void testAnnotationNameRange1() throws CoreException {
225
	public void testAnnotationNameRange1() throws CoreException {
(-)model/org/eclipse/jdt/internal/compiler/SourceElementParser.java (-1 / +1 lines)
Lines 1390-1396 Link Here
1390
				superclassName = superclass != null ? CharOperation.concatWith(superclass.getParameterizedTypeName(), '.') : null;
1390
				superclassName = superclass != null ? CharOperation.concatWith(superclass.getParameterizedTypeName(), '.') : null;
1391
			}
1391
			}
1392
			ISourceElementRequestor.TypeInfo typeInfo = new ISourceElementRequestor.TypeInfo();
1392
			ISourceElementRequestor.TypeInfo typeInfo = new ISourceElementRequestor.TypeInfo();
1393
			typeInfo.declarationStart = typeDeclaration.declarationSourceStart;
1393
			typeInfo.declarationStart = typeDeclaration.allocation == null ? typeDeclaration.declarationSourceStart : typeDeclaration.allocation.sourceStart;
1394
			typeInfo.modifiers = deprecated ? (currentModifiers & ExtraCompilerModifiers.AccJustFlag) | ClassFileConstants.AccDeprecated : currentModifiers & ExtraCompilerModifiers.AccJustFlag;
1394
			typeInfo.modifiers = deprecated ? (currentModifiers & ExtraCompilerModifiers.AccJustFlag) | ClassFileConstants.AccDeprecated : currentModifiers & ExtraCompilerModifiers.AccJustFlag;
1395
			typeInfo.name = typeDeclaration.name;
1395
			typeInfo.name = typeDeclaration.name;
1396
			typeInfo.nameSourceStart = typeDeclaration.sourceStart;
1396
			typeInfo.nameSourceStart = typeDeclaration.sourceStart;

Return to bug 207775