ASTParser Help [message #240639] |
Sun, 11 February 2007 09:32  |
Eclipse User |
|
|
|
Originally posted by: nitrousfiz.googlemail.com
Hello,
Can I use Eclipse's ASTParser to parse java source code from a standalone
application (i.e. without the null pointed exception)?
If yes, which version should I use?
If not, what alternatives are there for parsing java code?
Here is what I need to do-
Use a parser to create an AST and extract the names of the methods, its
parameters & its parameter types. I also need to extract variable names &
variable types from a given set of statements.
Please help me out to get this done.
Thanks for your help in advance.
Regards,
Fayezin
|
|
|
|
Re: ASTParser Help [message #240648 is a reply to message #240643] |
Sun, 11 February 2007 14:06   |
Eclipse User |
|
|
|
Originally posted by: nitrousfiz.googlemail.com
Hello,
This is the program I am trying to run:
import java.io.*;
import org.eclipse.jdt.core.dom.*;
public class ParseJava {
public static void main(String[] args) {
ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setSource(code.toCharArray());
parser.setKind(ASTParser.K_EXPRESSION);
ASTNode node = parser.createAST(null);
if (node.getNodeType() == ASTNode.METHOD_INVOCATION) {
MethodInvocation methodInvocation = (MethodInvocation) node;
System.out.println("Invoking method : "+methodInvocation.getName());
}
}
}
I get this error during compilation (maybe its asking for the runtime?)-
The type org.eclipse.core.runtime.IProgressMonitor cannot be resolved. It is
indirectly referenced from required .class files
I am using the org.eclipse.jdt.core_3.2.1.v_677_r32x.jar in my buildpath.
If its the wrong one, please advise which one to use?
Can you please help me solve this problem?
Thanks,
Fayezin
"Ed Merks" <merks@ca.ibm.com> wrote in message
news:eqn9rs$ql$1@utils.eclipse.org...
> Fayezin,
>
> I believe this should be possible. Perhaps if you show what you've tried
> and show the exception stack trace someone, will know what you need to do
> to avoid it.
>
>
> Fayezin Islam wrote:
>> Hello,
>>
>> Can I use Eclipse's ASTParser to parse java source code from a standalone
>> application (i.e. without the null pointed exception)?
>>
>> If yes, which version should I use?
>> If not, what alternatives are there for parsing java code?
>>
>> Here is what I need to do-
>> Use a parser to create an AST and extract the names of the methods, its
>> parameters & its parameter types. I also need to extract variable names &
>> variable types from a given set of statements.
>>
>> Please help me out to get this done.
>>
>> Thanks for your help in advance.
>>
>> Regards,
>>
>> Fayezin
>>
>>
>>
>>
|
|
|
Re: ASTParser Help [message #240663 is a reply to message #240648] |
Sun, 11 February 2007 16:43   |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
This is a multi-part message in MIME format.
--------------070606070704050207030907
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Fayezin,
It sounds like you still need to put all of jdt's dependencies on the
classpath. E.g., IProgressMonitor is in org.eclips.equinox.common_*.jar.
Fayezin Islam wrote:
> Hello,
>
> This is the program I am trying to run:
>
> import java.io.*;
> import org.eclipse.jdt.core.dom.*;
>
> public class ParseJava {
>
> public static void main(String[] args) {
> ASTParser parser = ASTParser.newParser(AST.JLS3);
> parser.setSource(code.toCharArray());
> parser.setKind(ASTParser.K_EXPRESSION);
> ASTNode node = parser.createAST(null);
>
> if (node.getNodeType() == ASTNode.METHOD_INVOCATION) {
> MethodInvocation methodInvocation = (MethodInvocation) node;
> System.out.println("Invoking method : "+methodInvocation.getName());
> }
> }
> }
>
> I get this error during compilation (maybe its asking for the runtime?)-
> The type org.eclipse.core.runtime.IProgressMonitor cannot be resolved. It is
> indirectly referenced from required .class files
>
> I am using the org.eclipse.jdt.core_3.2.1.v_677_r32x.jar in my buildpath.
> If its the wrong one, please advise which one to use?
>
> Can you please help me solve this problem?
>
> Thanks,
>
> Fayezin
>
> "Ed Merks" <merks@ca.ibm.com> wrote in message
> news:eqn9rs$ql$1@utils.eclipse.org...
>
>> Fayezin,
>>
>> I believe this should be possible. Perhaps if you show what you've tried
>> and show the exception stack trace someone, will know what you need to do
>> to avoid it.
>>
>>
>> Fayezin Islam wrote:
>>
>>> Hello,
>>>
>>> Can I use Eclipse's ASTParser to parse java source code from a standalone
>>> application (i.e. without the null pointed exception)?
>>>
>>> If yes, which version should I use?
>>> If not, what alternatives are there for parsing java code?
>>>
>>> Here is what I need to do-
>>> Use a parser to create an AST and extract the names of the methods, its
>>> parameters & its parameter types. I also need to extract variable names &
>>> variable types from a given set of statements.
>>>
>>> Please help me out to get this done.
>>>
>>> Thanks for your help in advance.
>>>
>>> Regards,
>>>
>>> Fayezin
>>>
>>>
>>>
>>>
>>>
>
>
>
--------------070606070704050207030907
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Fayezin,<br>
<br>
It sounds like you still need to put all of jdt's dependencies on the
classpath. E.g., IProgressMonitor is in
org.eclips.equinox.common_*.jar.<br>
<br>
<br>
Fayezin Islam wrote:
<blockquote cite="mideqnpfi$t4g$1@utils.eclipse.org" type="cite">
<pre wrap="">Hello,
This is the program I am trying to run:
import java.io.*;
import org.eclipse.jdt.core.dom.*;
public class ParseJava {
public static void main(String[] args) {
ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setSource(code.toCharArray());
parser.setKind(ASTParser.K_EXPRESSION);
ASTNode node = parser.createAST(null);
if (node.getNodeType() == ASTNode.METHOD_INVOCATION) {
MethodInvocation methodInvocation = (MethodInvocation) node;
System.out.println("Invoking method : "+methodInvocation.getName());
}
}
}
I get this error during compilation (maybe its asking for the runtime?)-
The type org.eclipse.core.runtime.IProgressMonitor cannot be resolved. It is
indirectly referenced from required .class files
I am using the org.eclipse.jdt.core_3.2.1.v_677_r32x.jar in my buildpath.
If its the wrong one, please advise which one to use?
Can you please help me solve this problem?
Thanks,
Fayezin
"Ed Merks" <a class="moz-txt-link-rfc2396E" href="mailto:merks@ca.ibm.com"><merks@ca.ibm.com></a> wrote in message
<a class="moz-txt-link-freetext" href="news:eqn9rs$ql$1@utils.eclipse.org">news:eqn9rs$ql$1@utils.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">Fayezin,
I believe this should be possible. Perhaps if you show what you've tried
and show the exception stack trace someone, will know what you need to do
to avoid it.
Fayezin Islam wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hello,
Can I use Eclipse's ASTParser to parse java source code from a standalone
application (i.e. without the null pointed exception)?
If yes, which version should I use?
If not, what alternatives are there for parsing java code?
Here is what I need to do-
Use a parser to create an AST and extract the names of the methods, its
parameters & its parameter types. I also need to extract variable names &
variable types from a given set of statements.
Please help me out to get this done.
Thanks for your help in advance.
Regards,
Fayezin
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
<br>
</body>
</html>
--------------070606070704050207030907--
|
|
|
|
|
|
|
|
|
Re: ASTParser Help [message #246170 is a reply to message #246161] |
Wed, 25 July 2007 15:19  |
Eclipse User |
|
|
|
Originally posted by: chengt.uwm.edu
Cheng Thao wrote:
> Olivier Thomann wrote:
>> Cheng Thao a écrit :
>>> Exception in thread "main" java.lang.NoClassDefFoundError:
>>> org/eclipse/core/runtime/Plugin
>>> at java.lang.ClassLoader.defineClass1(Native Method)
>>> at java.lang.ClassLoader.defineClass(Unknown Source)
>>> at java.security.SecureClassLoader.defineClass(Unknown Source)
>>> at java.net.URLClassLoader.defineClass(Unknown Source)
>>> at java.net.URLClassLoader.access$000(Unknown Source)
>>> at java.net.URLClassLoader$1.run(Unknown Source)
>>> at java.security.AccessController.doPrivileged(Native Method)
>>> at java.net.URLClassLoader.findClass(Unknown Source)
>>> at java.lang.ClassLoader.loadClass(Unknown Source)
>>> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>>> at java.lang.ClassLoader.loadClass(Unknown Source)
>>> at java.lang.ClassLoader.loadClassInternal(Unknown Source)
>>> at
>>> org.eclipse.jdt.core.dom.ASTParser.initializeDefaults(ASTPar ser.java:230)
>>>
>>> at org.eclipse.jdt.core.dom.ASTParser.<init>(ASTParser.java:212)
>>> at org.eclipse.jdt.core.dom.ASTParser.newParser(ASTParser.java: 112)
>>> at test.Test.main(Test.java:23)
>> You can get this if you don't have all the required jars on your
>> classpath.
>> --
>> Olivier
>
> org/eclipse/core/runtime/content/IContentTypeManager$IConten tTypeChangeListener
>
> at java.lang.ClassLoader.defineClass1(Native Method)
>
> I added many more jar files. Now it needs the IContentTypeManager which
> I can't seem to find the jar that has it. I assume it is in the
> org.eclipse.core.runtime.jar. I tried that, but it didn't work. I look
> at the source code in org.eclipse.core.runtime.content, but there is no
> IContentTypeManager.
>
> I'm using Eclipse 3.2.2.
OK, this is fixed. I had to include the following jar files.
org.eclipse.core.contenttype.jar
org.eclipse.core.jobs.jar
org.eclipse.core.resources.jar
org.eclipse.runtime.jar
org.eclipse.equinox.common.jar
org.eclipse.equinox.preferences.jar
org.eclipse.jdt.core.jar
org.eclipse.osgi.jar
|
|
|
Powered by
FUDForum. Page generated in 0.04948 seconds