Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Problem using setDerived - how to clear derived mark from memory?
Problem using setDerived - how to clear derived mark from memory? [message #515891] Mon, 22 February 2010 01:41 Go to next message
Gerald Rosenberg is currently offline Gerald Rosenberg
Messages: 104
Registered: July 2009
Senior Member
Eclipse 3.5

Programmatically generating a series of ICompilationUnit's. Save and marking as derived works
fine.

Problem occurs when trying to save a subsequent re-generation of the file: get the standard popup
asking whether to save to a derived file.

Have tried first unsetting derived without success:

cu.getCorrespondingResource().setDerived(false);
cu.save(new NullProgressMonitor(), true);
cu.getCorrespondingResource().setDerived(true);

According to the setDerived JavaDoc, the derived mark is maintained in memory. Apparently, the
setDerived(false) is not effective/flushed to disk until the project is closed or entire workspace
is saved. Closing and reopening the project is not a practical option.

So, how do I silently save a cu to a prior saved, derive-marked file?

Thanks...
Re: Problem using setDerived - how to clear derived mark from memory? [message #516984 is a reply to message #515891] Thu, 25 February 2010 11:52 Go to previous messageGo to next message
Dani Megert is currently offline Dani Megert
Messages: 3801
Registered: July 2009
Senior Member
Gerald Rosenberg wrote:
> Eclipse 3.5
>
> Programmatically generating a series of ICompilationUnit's. Save and marking as derived works
> fine.
>
> Problem occurs when trying to save a subsequent re-generation of the file: get the standard popup
> asking whether to save to a derived file.
>
I assume you have the file open in an editor right? If so, it might be a
bug. I suggest you file a bug against Platform Text with an example
plug-in to reproduce the issue. As a workaround you could disable the
preference (see
org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPrefere nceConstants.EDITOR_WARN_IF_INPUT_DERIVED)
to warn when a derived file is changed.

HTH
Dani


> Have tried first unsetting derived without success:
>
> cu.getCorrespondingResource().setDerived(false);
> cu.save(new NullProgressMonitor(), true);
> cu.getCorrespondingResource().setDerived(true);
>
> According to the setDerived JavaDoc, the derived mark is maintained in memory. Apparently, the
> setDerived(false) is not effective/flushed to disk until the project is closed or entire workspace
> is saved. Closing and reopening the project is not a practical option.
>
> So, how do I silently save a cu to a prior saved, derive-marked file?
>
> Thanks...
>
Re: Problem using setDerived - how to clear derived mark from memory? [message #517433 is a reply to message #516984] Sat, 27 February 2010 17:03 Go to previous message
Gerald Rosenberg is currently offline Gerald Rosenberg
Messages: 104
Registered: July 2009
Senior Member
In article <hm69su$h3v$1@build.eclipse.org>, daniel_megert@ch.ibm.com
says...
>
> Gerald Rosenberg wrote:
> > Eclipse 3.5
> >
> > Programmatically generating a series of ICompilationUnit's. Save and marking as derived works
> > fine.
> >
> > Problem occurs when trying to save a subsequent re-generation of the file: get the standard popup
> > asking whether to save to a derived file.
> >
> I assume you have the file open in an editor right? If so, it might be a
> bug.

It was a bug, just not in Eclipse. Turned out that a method call
executed shortly before ".setDerived(false)" was, as a very obscure side
effect, touching the file. Bottom line, setDerived works as (I)
expected.

>
> HTH
> Dani
>

Thanks much,
Gerald
Previous Topic:How out of date is "Creating Eclipse Plugins" for Eclipse 3.5.2?
Next Topic:Formatting Eclipse console output
Goto Forum:
  


Current Time: Wed Jul 30 17:30:16 EDT 2014

Powered by FUDForum. Page generated in 0.01426 seconds