Community
Participate
Working Groups
Eclipse 3.1M5 I'm using the org.eclipse.jdt.core.dom.ASTParser to parse my source files, see code below: ASTParser parser = ASTParser.newParser(AST.JLS2); parser.setSource(...); ASTNode node = parser.createAST(null); MyJavadocVisitor visitor = new MyJavadocVisitor(); node.accept(visitor); When I use the ASTParser to parse the following Java file, my visitor is telling me that there's a TypeDeclaration called "is" in the file. However, there isn't. I believe the problem is that inside the javadoc section for the interface, there's a line... * <p>This interface is not intended to be implemented by clients.</p> ASTParser thought the word "interface" in this case is an interface declaration (instead of part of the javadoc). Therefore, the word following it ("is") is the name of the interface. /****************************************************************************** * * Copyright (c) 2003, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - Initial API and implementation ******************************************************************************* / package org.eclipse.wst.server.core; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; /** * A runtime target handler is used to apply some properties to a project * this is being targeted to a given runtime. For instance, the handler * might update the classpath of a Java project to include the runtime's * classes, add validation for the given runtime, or restrict the type of * resources that can be created. * * <p>This interface is not intended to be implemented by clients.</p> * * @since 1.0 */ public interface IRuntimeTargetHandler extends IAdaptable { /** * Returns the id of this runtime target handler. * Each known runtime target handler has a distinct id. * Ids are intended to be used internally as keys; they are not * intended to be shown to end users. * * @return the runtime target handler id */ public String getId(); /** * Returns <code>true</code> if this runtime target handler supports * (can work with) the given runtime. * * @param runtimeType a runtime type * @return <code>true</code> if the handler can accept the given runtime type, * and <code>false</code> otherwise */ public boolean supportsRuntimeType(IRuntimeType runtimeType); /** * Set the runtime target on the given project. * * @param project the project to set the runtime on * @param runtime the target runtime * @param monitor a progress monitor, or <code>null</code> if progress * reporting and cancellation are not desired * @throws CoreException thrown if there is a problem setting the runtime */ public void setRuntimeTarget(IProject project, IRuntime runtime, IProgressMonitor monitor) throws CoreException; /** * Remove the runtime target from the given project. This method will undo * all changes made in setRuntimeTarget(). * * @param project the project to remove the runtime from * @param runtime the target runtime * @param monitor a progress monitor, or <code>null</code> if progress * reporting and cancellation are not desired * @throws CoreException thrown if there is a problem removing the runtime */ public void removeRuntimeTarget(IProject project, IRuntime runtime, IProgressMonitor monitor) throws CoreException; }
Can you make a try using ASTView 1.0.4 and let us know if the TypeDeclaration is also incorrect in this view? You can find this utility on following page: http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/jdt-ui-home/main.html Thx
In fact ASTView page location is: http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/jdt-ui-home/plugins/org.eclipse.jdt.astview/index.html
Type declaration seems to be correct using ASTView.
Perhaps a problem with your visitor? Can you attach it to this bug?
Here's my visitor (inner class): private class MyJavadocVisitor extends ASTVisitor { public MyJavadocVisitor(String pkg) { } public boolean visit(TypeDeclaration node) { String name = node.getName().getFullyQualifiedName(); Javadoc javadoc = node.getJavadoc(); if (javadoc != null) System.out.println(name + " has javadoc"); else System.out.println("Warning! " + name + " does not have any javadoc!!!"); return true; } public boolean visit(MethodDeclaration node) { return true; } } The console output: Warning! IOptionalTask does not have any javadoc!!! For some reason, the blank line trick no longer work. But in any event, I removed all the field declaration and the javadocs for the field. Rerun my visistor, and here's the console output: IOptionalTask has javadoc
IOptionalTask!!!??? I cannot se it in sample provided in comment 0... Are you sure of your test case? Cannot reproduce with your visitor *and* sample of comment 0. I get following output: IRuntimeTargetHandler has javadoc Warning! IRuntime does not have any javadoc!!! Warning! IRuntimeType does not have any javadoc!!! Two last lines are due to the fact that I've added two lines to your sample to avoid compiler errors: interface IRuntime {} interface IRuntimeType {} Please verify your test case and reopen when sure of the error, thanks
Sorry, I realized that IOptionalTask comes from bug 88206...
However, I still cannot reproduce neither this bug nor bug 88206. With IOptionalTask, I get: IOptionalTask has javadoc Warning! ITask does not have any javadoc!!! (I've also added interface ITask {} at the end of your sample to avoid compiler error) Does your project is a plugin with dependency on org.eclipse.jdt.core?
Please reopen while provindg requested info and if you find a reproduceable test case, thanks