Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » CompilationUnit Clone
CompilationUnit Clone [message #254121] Sat, 21 June 2008 02:03 Go to next message
Eclipse UserFriend
Hi,

I would like to make a clone/copy of a compilationunit before it goes
through the resolve() method. Later I would use the copied/cloned version
for future work. Ideally this copy should not have any information that
has been changed during the resolve phase of the original unit. I require
to call the resolve method.


Could you pleas help.

Thanks in advance
Amritam
MS student
Re: CompilationUnit Clone [message #254135 is a reply to message #254121] Sat, 21 June 2008 21:08 Go to previous messageGo to next message
Eclipse UserFriend
"Amritam" <amritamsarcar@yahoo.co.in> wrote in message
news:2bebbb4a1e823431aa43633102928672$1@www.eclipse.org...
> Hi,
>
> I would like to make a clone/copy of a compilationunit before it goes
> through the resolve() method. Later I would use the copied/cloned version
> for future work. Ideally this copy should not have any information that
> has been changed during the resolve phase of the original unit. I require
> to call the resolve method.

Hi, Amritam.

I *think* your answer might have something to do with creating a new working
copy with a non-default owner, but it's hard to tell, because I don't know
what your question is or what the problem you're trying to solve is. Given
that only one instance at a time of a type can be in the typesystem, what
sort of interactions (or what sort of isolation) are you expecting for this
compilation unit? What approaches have you considered so far, and what
problems did you encounter?

You may want to peruse http://catb.org/%7Eesr/faqs/smart-questions.html -
it's a bit snarky in places, but nonetheless it contains some good advice on
how to help people to help you.
Re: CompilationUnit Clone [message #254157 is a reply to message #254135] Sun, 22 June 2008 22:35 Go to previous messageGo to next message
Eclipse UserFriend
What I am trying to do is runtime assertion checking. For this I am
generating RAC after the resolve(type checking phase). After the
generation of RAC code (in source code format) I am now sending this code
for scanning and parsing and also type binding. What I do here is actually
parse only this new code(RAC) and then I mutate with the original AST.
After this I call the resolve (type check) on this modified AST and I
should be getting the code to work properly.

Hence during the first round I require typechecked parse tree however in
the second round when I mutate I require only the parsetree. My experience
says that if I mutate on the typechecked tree, it gives some compile time
error (since my guess, which I am pretty much sure, is this resolve phase
expects untyped parse tree).

Presently, to test whether this actually works, I have actually generated
RAC before typechecking (which should not be the case), and it works fine.
However when generate RAC code after typechecking, I get some errors. They
are basically errors of statements which have already been typechecked.

Please help. I was also thinking whether I can clone the AST and then form
a new CU.
Re: CompilationUnit Clone [message #254231 is a reply to message #254157] Wed, 25 June 2008 00:41 Go to previous messageGo to next message
Eclipse UserFriend
"Amritam" <amritamsarcar@yahoo.co.in> wrote in message
news:a9d38b36a49e6af77d192e91d47cdc14$1@www.eclipse.org...
> What I am trying to do is runtime assertion checking. For this I am
> generating RAC after the resolve(type checking phase). After the
> generation of RAC code (in source code format) I am now sending this code
> for scanning and parsing and also type binding. What I do here is actually
> parse only this new code(RAC) and then I mutate with the original AST.
> After this I call the resolve (type check) on this modified AST and I
> should be getting the code to work properly.
> Hence during the first round I require typechecked parse tree however in
> the second round when I mutate I require only the parsetree. My experience
> says that if I mutate on the typechecked tree, it gives some compile time
> error (since my guess, which I am pretty much sure, is this resolve phase
> expects untyped parse tree).
> Presently, to test whether this actually works, I have actually generated
> RAC before typechecking (which should not be the case), and it works fine.
> However when generate RAC code after typechecking, I get some errors. They
> are basically errors of statements which have already been typechecked.
> Please help. I was also thinking whether I can clone the AST and then form
> a new CU.


I'm afraid you're a bit over my head here. Perhaps someone else from JDT
will respond?

My thought would be to treat it like refactoring does - create a new
WorkingCopyOwner, and open the compilation units into that owner for the
sake of temporarily modifying them without colliding with the rest of the
typesystem. So, you might want to take a detailed look at the refactoring
code in JDT, e.g. the org.eclipse.jdt.internal.corext.refactoring package.
Re: CompilationUnit Clone [message #254247 is a reply to message #254231] Thu, 26 June 2008 03:13 Go to previous message
Eclipse UserFriend
When typechecking(resolve) phase was implemented I presume it was done
with this in mind , that this method would be called once ie. for each
compilation unit, only once it would be called

Is it also true that the typechecking phase assumes that the input to this
phase is (untype-checked) AST.

However can I send an AST (or CU) where some of the methods and the CU
itself has been typechecked while some of them have not. Would these
methods which are not typechecked be currectly processed.
Previous Topic:ability to move/shift a breakpoint
Next Topic:Automatic cast after if
Goto Forum:
  


Current Time: Mon Jul 14 22:22:53 EDT 2025

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

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

Back to the top