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

(-)dom/org/eclipse/jdt/core/dom/ASTConverter.java (-1 / +3 lines)
Lines 696-703 Link Here
696
		return infixExpression;
696
		return infixExpression;
697
	}
697
	}
698
698
699
	public AnnotationTypeDeclaration convertToAnnotationDeclaration(org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration) {
699
	private AnnotationTypeDeclaration convertToAnnotationDeclaration(org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration) {
700
		checkCanceled();
700
		checkCanceled();
701
		if (this.scanner.sourceLevel < ClassFileConstants.JDK1_5) return null;
701
		AnnotationTypeDeclaration typeDecl = this.ast.newAnnotationTypeDeclaration();
702
		AnnotationTypeDeclaration typeDecl = this.ast.newAnnotationTypeDeclaration();
702
		setModifiers(typeDecl, typeDeclaration);
703
		setModifiers(typeDecl, typeDeclaration);
703
		final SimpleName typeName = new SimpleName(this.ast);
704
		final SimpleName typeName = new SimpleName(this.ast);
Lines 2871-2876 Link Here
2871
2872
2872
	private EnumDeclaration convertToEnumDeclaration(org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration) {
2873
	private EnumDeclaration convertToEnumDeclaration(org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration) {
2873
		checkCanceled();
2874
		checkCanceled();
2875
		// enum declaration cannot be built if the source is not >= 1.5, since enum is then seen as an identifier
2874
		final EnumDeclaration enumDeclaration2 = new EnumDeclaration(this.ast);
2876
		final EnumDeclaration enumDeclaration2 = new EnumDeclaration(this.ast);
2875
		setModifiers(enumDeclaration2, typeDeclaration);
2877
		setModifiers(enumDeclaration2, typeDeclaration);
2876
		final SimpleName typeName = new SimpleName(this.ast);
2878
		final SimpleName typeName = new SimpleName(this.ast);
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java (-1 / +51 lines)
Lines 122-128 Link Here
122
	static {
122
	static {
123
//		TESTS_NAMES = new String[] {"test0602"};
123
//		TESTS_NAMES = new String[] {"test0602"};
124
//		TESTS_RANGE = new int[] { 670, -1 };
124
//		TESTS_RANGE = new int[] { 670, -1 };
125
//		TESTS_NUMBERS =  new int[] { 693, 694 };
125
//		TESTS_NUMBERS =  new int[] { 695, 696 };
126
	}
126
	}
127
	public static Test suite() {
127
	public static Test suite() {
128
		return buildModelTestSuite(ASTConverterTestAST3_2.class);
128
		return buildModelTestSuite(ASTConverterTestAST3_2.class);
Lines 9872-9875 Link Here
9872
			assertFalse("Should not get there", true);
9872
			assertFalse("Should not get there", true);
9873
		}
9873
		}
9874
	}
9874
	}
9875
	/**
9876
	 * http://dev.eclipse.org/bugs/show_bug.cgi?id=245348
9877
	 */
9878
	public void test0695() throws JavaModelException {
9879
		ICompilationUnit unit = getCompilationUnit("Converter" , "src", "test0695", "X.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
9880
9881
		ASTParser parser = ASTParser.newParser(AST.JLS3);
9882
		parser.setKind(ASTParser.K_COMPILATION_UNIT);
9883
		parser.setSource(unit.getSource().toCharArray());
9884
		Map options = JavaCore.getOptions();
9885
		options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3);
9886
		options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
9887
		options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2);
9888
		parser.setCompilerOptions(options);
9889
9890
		CompilationUnit astRoot = (CompilationUnit) parser.createAST(null);
9891
		ASTVisitor visitor = new ASTVisitor() {
9892
			public boolean visit(EnumDeclaration node) {
9893
				assertFalse("Should not be there", true);
9894
				return false;
9895
			}
9896
		};
9897
		astRoot.accept(visitor);
9898
		assertEquals("No problem found", 1, astRoot.getProblems().length);
9899
	}
9900
	/**
9901
	 * http://dev.eclipse.org/bugs/show_bug.cgi?id=245348
9902
	 */
9903
	public void test0696() throws JavaModelException {
9904
		ICompilationUnit unit = getCompilationUnit("Converter" , "src", "test0696", "X.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
9905
9906
		ASTParser parser = ASTParser.newParser(AST.JLS3);
9907
		parser.setKind(ASTParser.K_COMPILATION_UNIT);
9908
		parser.setSource(unit.getSource().toCharArray());
9909
		Map options = JavaCore.getOptions();
9910
		options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3);
9911
		options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
9912
		options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2);
9913
		parser.setCompilerOptions(options);
9914
9915
		CompilationUnit astRoot = (CompilationUnit) parser.createAST(null);
9916
		ASTVisitor visitor = new ASTVisitor() {
9917
			public boolean visit(AnnotationTypeDeclaration node) {
9918
				assertFalse("Should not be there", true);
9919
				return false;
9920
			}
9921
		};
9922
		astRoot.accept(visitor);
9923
		assertEquals("No problem found", 1, astRoot.getProblems().length);
9924
	}
9875
}
9925
}
(-)workspace/Converter/src/test0696/X.java (+4 lines)
Added Link Here
1
package test0696;
2
3
public @interface X {
4
}
(-)workspace/Converter/src/test0695/X.java (+4 lines)
Added Link Here
1
package test0695;
2
3
public enum X {
4
}

Return to bug 245348