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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterAST3Test.java (-9 / +19 lines)
Lines 14-20 Link Here
14
import java.util.*;
14
import java.util.*;
15
15
16
import junit.framework.Test;
16
import junit.framework.Test;
17
import junit.framework.TestSuite;
18
17
19
import org.eclipse.jdt.core.*;
18
import org.eclipse.jdt.core.*;
20
import org.eclipse.jdt.core.dom.*;
19
import org.eclipse.jdt.core.dom.*;
Lines 32-44 Link Here
32
		super(name);
31
		super(name);
33
	}
32
	}
34
33
34
	static {
35
//		TESTS_NUMBERS = new int[] { 356 };
36
	}
35
	public static Test suite() {
37
	public static Test suite() {
36
		if (true) {
38
		return buildTestSuite(ASTConverterAST3Test.class);
37
			return new Suite(ASTConverterAST3Test.class);		
38
		}
39
		TestSuite suite = new Suite(ASTConverterAST3Test.class.getName());
40
		suite.addTest(new ASTConverterAST3Test("test0001"));
41
		return suite;
42
	}
39
	}
43
		
40
		
44
	public void test0001() throws JavaModelException {
41
	public void test0001() throws JavaModelException {
Lines 8701-8714 Link Here
8701
		assertNotNull("No compilation unit", result); //$NON-NLS-1$
8698
		assertNotNull("No compilation unit", result); //$NON-NLS-1$
8702
		assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
8699
		assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
8703
		CompilationUnit compilationUnit = (CompilationUnit) result;
8700
		CompilationUnit compilationUnit = (CompilationUnit) result;
8704
		assertEquals("errors found", 2, compilationUnit.getMessages().length); //$NON-NLS-1$
8701
		assertEquals("errors found", 1, compilationUnit.getMessages().length); //$NON-NLS-1$
8705
		ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
8702
		ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
8706
		assertNotNull(node);
8703
		assertNotNull(node);
8707
		assertTrue("Not a variable declaration statement", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT); //$NON-NLS-1$
8704
		assertTrue("Not a variable declaration statement", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT); //$NON-NLS-1$
8708
		VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
8705
		VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
8709
		Type type = variableDeclarationStatement.getType();
8706
		Type type = variableDeclarationStatement.getType();
8710
		ITypeBinding binding = type.resolveBinding();
8707
		ITypeBinding binding = type.resolveBinding();
8711
		assertNull(binding);
8708
		assertNotNull("Binding should NOT be null for type: "+type, binding);
8709
8710
		// Verify that class instance creation has a null binding
8711
		List fragments = variableDeclarationStatement.fragments();
8712
		assertEquals("Expect only one fragment for VariableDeclarationStatement: "+variableDeclarationStatement, 1, fragments.size());
8713
		node = (ASTNode) fragments.get(0);
8714
		assertEquals("Not a variable declaration fragment", ASTNode.VARIABLE_DECLARATION_FRAGMENT, node.getNodeType()); //$NON-NLS-1$
8715
		VariableDeclarationFragment fragment = (VariableDeclarationFragment) node;
8716
		Expression initializer = fragment.getInitializer();
8717
		assertEquals("Expect a class instance creation for initializer: "+initializer, ASTNode.CLASS_INSTANCE_CREATION, initializer.getNodeType()); //$NON-NLS-1$
8718
		ClassInstanceCreation instanceCreation = (ClassInstanceCreation) initializer;
8719
		type = instanceCreation.getType();
8720
		binding = type.resolveBinding();
8721
		assertNull("Binding should BE null for type: "+type, binding);
8712
	}
8722
	}
8713
	
8723
	
8714
	/**
8724
	/**
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java (-9 / +6 lines)
Lines 14-20 Link Here
14
import java.util.*;
14
import java.util.*;
15
15
16
import junit.framework.Test;
16
import junit.framework.Test;
17
import junit.framework.TestSuite;
18
17
19
import org.eclipse.core.runtime.Preferences;
18
import org.eclipse.core.runtime.Preferences;
20
import org.eclipse.jdt.core.*;
19
import org.eclipse.jdt.core.*;
Lines 34-46 Link Here
34
		super(name);
33
		super(name);
35
	}
34
	}
36
35
36
	static {
37
//		TESTS_NUMBERS = new int[] { 356 };
38
	}
37
	public static Test suite() {
39
	public static Test suite() {
38
		if (true) {
40
		return buildTestSuite(ASTConverterTest.class);
39
			return new Suite(ASTConverterTest.class);		
40
		}
41
		TestSuite suite = new Suite(ASTConverterTest.class.getName());
42
		suite.addTest(new ASTConverterTest("test0206"));
43
		return suite;
44
	}
41
	}
45
		
42
		
46
	/** @deprecated using deprecated code */
43
	/** @deprecated using deprecated code */
Lines 8871-8884 Link Here
8871
		assertNotNull("No compilation unit", result); //$NON-NLS-1$
8868
		assertNotNull("No compilation unit", result); //$NON-NLS-1$
8872
		assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
8869
		assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
8873
		CompilationUnit compilationUnit = (CompilationUnit) result;
8870
		CompilationUnit compilationUnit = (CompilationUnit) result;
8874
		assertEquals("errors found", 2, compilationUnit.getMessages().length); //$NON-NLS-1$
8871
		assertEquals("errors found", 1, compilationUnit.getMessages().length); //$NON-NLS-1$
8875
		ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
8872
		ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
8876
		assertNotNull(node);
8873
		assertNotNull(node);
8877
		assertTrue("Not a variable declaration statement", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT); //$NON-NLS-1$
8874
		assertTrue("Not a variable declaration statement", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT); //$NON-NLS-1$
8878
		VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
8875
		VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
8879
		Type type = variableDeclarationStatement.getType();
8876
		Type type = variableDeclarationStatement.getType();
8880
		ITypeBinding binding = type.resolveBinding();
8877
		ITypeBinding binding = type.resolveBinding();
8881
		assertNull(binding);
8878
		assertNotNull("Binding should NOT be null for type: "+type, binding);
8882
	}
8879
	}
8883
	
8880
	
8884
	/**
8881
	/**
(-)src/org/eclipse/jdt/core/tests/model/ClassNameTests.java (-14 / +80 lines)
Lines 11-26 Link Here
11
package org.eclipse.jdt.core.tests.model;
11
package org.eclipse.jdt.core.tests.model;
12
12
13
import junit.framework.Test;
13
import junit.framework.Test;
14
import junit.framework.TestSuite;
15
14
16
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.resources.IFile;
17
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.NullProgressMonitor;
17
import org.eclipse.core.runtime.NullProgressMonitor;
19
import org.eclipse.jdt.core.IClasspathEntry;
18
import org.eclipse.jdt.core.*;
20
import org.eclipse.jdt.core.IJavaProject;
19
21
import org.eclipse.jdt.core.IType;
20
22
import org.eclipse.jdt.core.JavaCore;
23
import org.eclipse.jdt.core.JavaModelException;
24
/**
21
/**
25
 * Test retrieving types by their name.
22
 * Test retrieving types by their name.
26
 */
23
 */
Lines 30-36 Link Here
30
	public ClassNameTests(String name) {
27
	public ClassNameTests(String name) {
31
		super(name);
28
		super(name);
32
	}
29
	}
33
	
30
31
	static {
32
//		TESTS_NAMES = new String[] { "testFindSecondaryType02" };
33
//		TESTS_PREFIX = "testFindSecondaryType";
34
	}
35
	public static Test suite() {
36
		return buildTestSuite(ClassNameTests.class);
37
	}
38
34
	/**
39
	/**
35
	 * Tests that a type in a jar with a name ending with $ can be retrieved.
40
	 * Tests that a type in a jar with a name ending with $ can be retrieved.
36
	 */
41
	 */
Lines 945-957 Link Here
945
		}
950
		}
946
	}
951
	}
947
952
948
	public static Test suite() {
953
	/**
949
		TestSuite suite = new Suite(ClassNameTests.class.getName());
954
	 * Bug 36032: JavaProject.findType() fails to find second type in source file
950
		suite.addTest(new ClassNameTests("testClassNameWithDollar"));
955
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=36032"
951
		suite.addTest(new ClassNameTests("testFindTypeWithDot"));
956
	 */
952
		suite.addTest(new ClassNameTests("testSearchTypeNameInJars"));
957
	public void testFindSecondaryType01() throws JavaModelException, CoreException {
953
		return suite;
958
		try {
959
			IJavaProject javaProject = createJavaProject("P", new String[] {""}, "");
960
			createFolder("/P/test");
961
			createFile(
962
				"/P/test/Foo.java", 
963
				"package test;\n" +
964
				"public class Foo {\n" +
965
				"}\n" +
966
				"class Bar {\n" +
967
				"}\n"
968
			);
969
			IType type = javaProject.findType("test.Foo");
970
			assertTrue("type Foo should exist!", type != null && type.exists());
971
			assertEquals("Expected type 'Foo' NOT found!",
972
				"class Foo [in Foo.java [in test [in <project root> [in P]]]]",
973
				type.toString()
974
			);
975
			type = javaProject.findType("test.Bar");
976
			assertTrue("type Bar should exist!", type != null && type.exists());
977
			assertEquals("Expected type 'Bar' NOT found!",
978
				"class Bar [in Foo.java [in test [in <project root> [in P]]]]",
979
				type.toString()
980
			);
981
		} finally {
982
			deleteProject("P");
983
		}
984
	}
985
	// duplicate bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=72179
986
	public void testFindSecondaryType02() throws JavaModelException, CoreException {
987
		try {
988
			IJavaProject javaProject = createJavaProject("P", new String[] {""}, "");
989
			createFolder("/P/p1");
990
			createFile(
991
				"/P/p1/jc.java", 
992
				"package p1;\n" +
993
				"class jc008{}\n" +
994
				"class jc009{}\n" +
995
				"class jc010 extends jc009 {\n" +
996
				"	jc008 a;\n" +
997
				"}\n"
998
			);
999
			IType type = javaProject.findType("p1", "jc008");
1000
			assertTrue("type 'jc008' should exist!", type != null && type.exists());
1001
			assertEquals("Expected type 'jc008' NOT found!",
1002
				"class jc008 [in jc.java [in p1 [in <project root> [in P]]]]",
1003
				type.toString()
1004
			);
1005
			type = javaProject.findType("p1", "jc009");
1006
			assertTrue("type 'jc009' should exist!", type != null && type.exists());
1007
			assertEquals("Expected type 'jc009' NOT found!",
1008
				"class jc009 [in jc.java [in p1 [in <project root> [in P]]]]",
1009
				type.toString()
1010
			);
1011
			type = javaProject.findType("p1", "jc010");
1012
			assertTrue("type 'jc010' should exist!", type != null && type.exists());
1013
			assertEquals("Expected type 'jc010' NOT found!",
1014
				"class jc010 [in jc.java [in p1 [in <project root> [in P]]]]\n" +
1015
				"  jc008 a",
1016
				type.toString()
1017
			);
1018
		} finally {
1019
			deleteProject("P");
1020
		}
954
	}
1021
	}
955
956
1022
957
}
1023
}

Return to bug 36032