Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » AST.parseCompilationUnit -> Unhandled exception caught in event loop
AST.parseCompilationUnit -> Unhandled exception caught in event loop [message #5616] Fri, 25 April 2003 15:10 Go to next message
Eclipse UserFriend
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 #5635 is a reply to message #5616] Fri, 25 April 2003 15:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: adam.kiezun.gmx.net.remove

why don't you simply debug it?

a.
--
eclipse.org
Re: AST.parseCompilationUnit -> Unhandled exception caught in event loop [message #5645 is a reply to message #5635] Fri, 25 April 2003 16:38 Go to previous messageGo to next message
Eclipse UserFriend
Adam Kiezun wrote:

> why don't you simply debug it?

I traced it until the first line

buildBodyDeclarations(typeDeclaration, typeDecl);

of method

buildBodyDeclarations(org.eclipse.jdt.internal.compiler.ast. TypeDeclaration
typeDeclaration, TypeDeclaration typeDecl)

in class

ASTConverter.

I don't understand what happens here but in this method

typeDecl.bodyDeclarations().add(convert(nextMethodDeclaratio n));

will be called (nextDeclarationType = 1) and then the exception will be
thrown.

If I use my plug-in with another .java it works...

Regards, Martin
Re: AST.parseCompilationUnit -> Unhandled exception caught in event loop [message #5649 is a reply to message #5645] Fri, 25 April 2003 16:39 Go to previous messageGo to next message
Eclipse UserFriend
Martin Burger wrote:

> I traced it until the first line
> buildBodyDeclarations(typeDeclaration, typeDecl);

Sorry:

MemberTypeDeclaration[] members = typeDeclaration.memberTypes;
Re: AST.parseCompilationUnit -> Unhandled exception caught in event loop [message #6345 is a reply to message #5616] Fri, 25 April 2003 16:53 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: AST.parseCompilationUnit -> Unhandled exception caught in event loop [message #6555 is a reply to message #6345] Sun, 27 April 2003 01:41 Go to previous message
Eclipse UserFriend
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
>
>
Previous Topic:[NEWBIE] How to determine the line-number of a code-fragment?
Next Topic:Looking for a good j2ee plugin - NOT LOMBOZ!!!
Goto Forum:
  


Current Time: Sun May 11 00:58:25 EDT 2025

Powered by FUDForum. Page generated in 0.03687 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top