diff options
author | Olivier Thomann | 2003-02-28 17:45:58 +0000 |
---|---|---|
committer | Olivier Thomann | 2003-02-28 17:45:58 +0000 |
commit | ba3ec3bd50437773ef57d3cde6acec4f55da6c0c (patch) | |
tree | 68ab5535855c06ad8544a500198234cdaaa5c61b | |
parent | 5e2e35137d7e738e06e446b495cd9e480911e356 (diff) | |
download | eclipse.jdt.core-ba3ec3bd50437773ef57d3cde6acec4f55da6c0c.tar.gz eclipse.jdt.core-ba3ec3bd50437773ef57d3cde6acec4f55da6c0c.tar.xz eclipse.jdt.core-ba3ec3bd50437773ef57d3cde6acec4f55da6c0c.zip |
Backport fix for 23054 to stream 2.0.x
Update for 31626
3 files changed, 76 insertions, 46 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java index 3f6d665174..e743ffb7df 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java @@ -133,8 +133,6 @@ public class ASTConverterTest extends AbstractJavaModelTests { } } - - /** * Check locally for the required JCL files, jclMin.jar and jclMinsrc.zip. * If not available, copy from the project resources. @@ -199,6 +197,49 @@ public class ASTConverterTest extends AbstractJavaModelTests { super.tearDown(); } + + private ASTNode getASTNodeToCompare(org.eclipse.jdt.core.dom.CompilationUnit unit) { + ExpressionStatement statement = (ExpressionStatement) getASTNode(unit, 0, 0, 0); + return (ASTNode) ((MethodInvocation) statement.getExpression()).arguments().get(0); + } + + private ASTNode getASTNode(org.eclipse.jdt.core.dom.CompilationUnit unit, int typeIndex, int bodyIndex, int statementIndex) { + BodyDeclaration bodyDeclaration = (BodyDeclaration)((TypeDeclaration)unit.types().get(typeIndex)).bodyDeclarations().get(bodyIndex); + if (bodyDeclaration instanceof MethodDeclaration) { + MethodDeclaration methodDeclaration = (MethodDeclaration) bodyDeclaration; + Block block = methodDeclaration.getBody(); + return (ASTNode) block.statements().get(statementIndex); + } else if (bodyDeclaration instanceof TypeDeclaration) { + TypeDeclaration typeDeclaration = (TypeDeclaration) bodyDeclaration; + return (ASTNode) typeDeclaration.bodyDeclarations().get(statementIndex); + } + return null; + } + + private ASTNode getASTNode(org.eclipse.jdt.core.dom.CompilationUnit unit, int typeIndex, int bodyIndex) { + return (ASTNode) ((TypeDeclaration)unit.types().get(typeIndex)).bodyDeclarations().get(bodyIndex); + } + + private ASTNode getASTNode(org.eclipse.jdt.core.dom.CompilationUnit unit, int typeIndex) { + return (ASTNode) (TypeDeclaration)unit.types().get(typeIndex); + } + + private void checkSourceRange(ASTNode node, String expectedContents, char[] source) { + assertNotNull("The node is null", node); + assertTrue("The node(" + node.getClass() + ").getLength() == 0", node.getLength() != 0); + assertTrue("The node.getStartPosition() == -1", node.getStartPosition() != -1); + int length = node.getLength(); + int start = node.getStartPosition(); + char[] actualContents = new char[length]; + System.arraycopy(source, start, actualContents, 0, length); + String actualContentsString = new String(actualContents); + assertTrue("The two strings are not equals\n---\nactualContents = >" + actualContentsString + "<\nexpectedContents = >" + expectedContents + "<\n----", expectedContents.equals(actualContentsString)); + } + + private boolean isMalformed(ASTNode node) { + return (node.getFlags() & ASTNode.MALFORMED) != 0; + } + public static Test suite() { TestSuite suite = new Suite(ASTConverterTest.class.getName()); @@ -8990,46 +9031,30 @@ public class ASTConverterTest extends AbstractJavaModelTests { checkSourceRange(node, "for (int i=0, j=0, k=0; i<10 ; i++, j++, k++) {}", source); //$NON-NLS-1$ } - private ASTNode getASTNodeToCompare(org.eclipse.jdt.core.dom.CompilationUnit unit) { - ExpressionStatement statement = (ExpressionStatement) getASTNode(unit, 0, 0, 0); - return (ASTNode) ((MethodInvocation) statement.getExpression()).arguments().get(0); - } - - private ASTNode getASTNode(org.eclipse.jdt.core.dom.CompilationUnit unit, int typeIndex, int bodyIndex, int statementIndex) { - BodyDeclaration bodyDeclaration = (BodyDeclaration)((TypeDeclaration)unit.types().get(typeIndex)).bodyDeclarations().get(bodyIndex); - if (bodyDeclaration instanceof MethodDeclaration) { - MethodDeclaration methodDeclaration = (MethodDeclaration) bodyDeclaration; - Block block = methodDeclaration.getBody(); - return (ASTNode) block.statements().get(statementIndex); - } else if (bodyDeclaration instanceof TypeDeclaration) { - TypeDeclaration typeDeclaration = (TypeDeclaration) bodyDeclaration; - return (ASTNode) typeDeclaration.bodyDeclarations().get(statementIndex); - } - return null; - } - - private ASTNode getASTNode(org.eclipse.jdt.core.dom.CompilationUnit unit, int typeIndex, int bodyIndex) { - return (ASTNode) ((TypeDeclaration)unit.types().get(typeIndex)).bodyDeclarations().get(bodyIndex); + /** + * http://dev.eclipse.org/bugs/show_bug.cgi?id=31626 + */ + public void test0358() throws JavaModelException { + ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0358", "A.java"); + char[] source = sourceUnit.getSource().toCharArray(); + ASTNode result = runConversion(sourceUnit, true); + assertNotNull("No compilation unit", result); + assertTrue("result is not a compilation unit", result instanceof CompilationUnit); + CompilationUnit compilationUnit = (CompilationUnit) result; + assertEquals("errors found", 0, compilationUnit.getMessages().length); + ASTNode node = getASTNode(compilationUnit, 0); + assertNotNull(node); + assertTrue("Not a type declaration", node.getNodeType() == ASTNode.TYPE_DECLARATION); + TypeDeclaration typeDeclaration = (TypeDeclaration) node; + Javadoc javadoc = typeDeclaration.getJavadoc(); + assertNull("Got a javadoc", javadoc); + node = getASTNode(compilationUnit, 0, 0); + assertNotNull(node); + assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); + MethodDeclaration methodDeclaration = (MethodDeclaration) node; + javadoc = methodDeclaration.getJavadoc(); + assertNotNull("No javadoc", javadoc); } - private ASTNode getASTNode(org.eclipse.jdt.core.dom.CompilationUnit unit, int typeIndex) { - return (ASTNode) (TypeDeclaration)unit.types().get(typeIndex); - } - - private void checkSourceRange(ASTNode node, String expectedContents, char[] source) { - assertNotNull("The node is null", node); - assertTrue("The node(" + node.getClass() + ").getLength() == 0", node.getLength() != 0); - assertTrue("The node.getStartPosition() == -1", node.getStartPosition() != -1); - int length = node.getLength(); - int start = node.getStartPosition(); - char[] actualContents = new char[length]; - System.arraycopy(source, start, actualContents, 0, length); - String actualContentsString = new String(actualContents); - assertTrue("The two strings are not equals\n---\nactualContents = >" + actualContentsString + "<\nexpectedContents = >" + expectedContents + "<\n----", expectedContents.equals(actualContentsString)); - } - - private boolean isMalformed(ASTNode node) { - return (node.getFlags() & ASTNode.MALFORMED) != 0; - } } diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0358/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0358/A.java index 76e0803b5f..c9cd249842 100644 --- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0358/A.java +++ b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0358/A.java @@ -1,6 +1,8 @@ package test0358; -class A { - public void mdd(int y){ - } +public class A { + /** + * Method comment. + */ + public void bar() {} }
\ No newline at end of file diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html index 5ab72b6532..d16bbaa86d 100644 --- a/org.eclipse.jdt.core/buildnotes_jdt-core.html +++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html @@ -20,13 +20,16 @@ What's new in this drop</h2> </li> </ul> <h3>Problem Reports Fixed</h3> -<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32690">32690</a> +<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23054">23054</a> +DOM - TypeDeclaration.getJavadoc() can find incorrect javadoc +<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32690">32690</a> Classpath error are not detected after a Check out <br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28625">28625</a> Huge number of warnings now generated by JDTCompilerAdapter <h3>Problem Reports Closed</h3> - +<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31626">31626</a> +getJavadoc() on TypeDeclaration returning incorrect comment <h1> Eclipse Platform Build Notes <br> |