AST.parseCompilationUnit -> Unhandled exception caught in event loop [message #5616] |
Fri, 25 April 2003 15:10  |
Eclipse User |
|
|
|
Hi,
I have the following class:
public class Action implements IObjectActionDelegate {
private ISelection selection;
private ICompilationUnit getCompilationUnit() {
return (ICompilationUnit) ((IStructuredSelection)
this.selection)
.getFirstElement();
}
public void run(IAction action) {
ICompilationUnit unit = this.getCompilationUnit();
try {
System.out.println(unit.getSource());
} catch (JavaModelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (unit != null) {
System.out.println("Trying to parse: " + unit);
AST.parseCompilationUnit(unit, false);
System.out.println("Parsing done.");
//MyVisitor visitor = new MyVisitor();
//root.accept(visitor);
}
}
public void selectionChanged(IAction action, ISelection
selection) {
this.selection = selection;
}
public void setActivePart(IAction action, IWorkbenchPart
targetPart) {
// TODO Auto-generated method stub
}
}
It uses this extension point:
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
objectClass="org.eclipse.jdt.core.ICompilationUnit"
id="de.netbeyond.eclipse.ICompilationUnit">
<action
label="myproj"
tooltip="myproj Tool-Tip"
class="de.netbeyond.eclipse.myproj.Action"
enablesFor="1"
id="de.netbeyond.eclipse.myproj.Action">
</action>
</objectContribution>
</extension>
If I trigger the run() method in the Run-time Workbench I will get
everytime this error:
Trying to parse: HelloWorld.java [in [default] [in src [in test1]]]
class HelloWorld
static void main(String[])
Unhandled exception caught in event loop.
Reason:
java.lang.IllegalArgumentException
The statement
System.out.println("Trying to parse: " + unit);
prints the source code of my test class HelloWorld.java, so I think
the given Java element exists and its source string can be obtained.
Any ideas why the exceptions is be thrown?
Thanks for the help,
Martin
|
|
|
|
|
|
|
Re: AST.parseCompilationUnit -> Unhandled exception caught in event loop [message #6555 is a reply to message #6345] |
Sun, 27 April 2003 01:41  |
Eclipse User |
|
|
|
Originally posted by: bob.objfac.com
Seems odd that this is a problem. Is it not true in Java that true == (true)
== ((true))...?
Bob
"Martin Burger" <m@rtin-burger.de> wrote in message
news:b8c75f$nd7$1@rogue.oti.com...
> Martin Burger wrote:
>
> > prints the source code of my test class HelloWorld.java, so I think
> > the given Java element exists and its source string can be obtained.
>
> The error was induced by this line
>
> assert(true);
>
> in my HelloWorld class.
>
> assert is a key word, not a method. It has to be
>
> assert true;
>
> But I'm wondering because I was able to compile and run the program
> without any problems.
>
> Regards, Martin
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03687 seconds