Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dynamic Languages Toolkit (DLTK) » Deleted source file remains in navigator and model(Delete file in source folder, navigator is not always updated.)
Deleted source file remains in navigator and model [message #1087857] Fri, 16 August 2013 07:32 Go to next message
Kevin Hagel is currently offline Kevin HagelFriend
Messages: 26
Registered: December 2012
Junior Member
When I delete a file from a source folder in the ScriptNavigator it doesn't always delete from the view. This is an inconsistent problem, sometimes it works and sometimes it doesn't.

Further, the source file that was deleted is still sent as source during project builds.

The file is deleted from the file system.

If after deleting from the source folder (Select File right-click Delete), when it does not delete, I can refresh the project. The deleted file appears to move from the source folder into the project root. I can select this file now, the delete option does not appear.

If I delete the file when in the Resource Navigator the file does delete, and disappears from the resource navigator view. When I switch back to the Script Navigator view the problem still exists.

It seems this inconsistent problem is not removing the deleted file from the model.
I don't see this problem occurring in Tcl, Python, or Javascript DLTK ides.

Update: If the file is opened in the editor, all the deletion processes work as expected. If the file is not opened, it is simply deleted in the explorer, this is when it happens.

[Updated on: Fri, 16 August 2013 08:24]

Report message to a moderator

Re: Deleted source file remains in navigator and model [message #1088183 is a reply to message #1087857] Fri, 16 August 2013 18:11 Go to previous messageGo to next message
Kevin Hagel is currently offline Kevin HagelFriend
Messages: 26
Registered: December 2012
Junior Member
I found a way to remove the now-nonexistent source modules from the navigator - implement IModelContentProvider and remove these from the children list in
provideModelChanges(Object parentElement, List children, ITreeContentProvider iTreecontentProvider)

This still does not remove these files from the model however, they are still sent to the builder as if they exist.

Why this problem doesn't happen when the file is open in the editor I can't figure out, stepping through the debugger it appears the exact same things are done.
Re: Deleted source file remains in navigator and model [message #1088717 is a reply to message #1088183] Sat, 17 August 2013 14:34 Go to previous messageGo to next message
Kevin Hagel is currently offline Kevin HagelFriend
Messages: 26
Registered: December 2012
Junior Member
I'm sure this is a horrible kludge, but I could not find out why DLTK was not removing the SourceModule from the parent info in the delta processor and model updater.

This only happens in our custom language, it does not happen in python, tcl, ruby, or javascript.

It does not matter if the project has source in project root or source in separate folder(s).

Delete a file in the Script Explorer that is open in the editor. All is well.
Delete a file in the Script Explorer that is *not* open in the editor - the SourceModule is not removed from the parent folder's info. It is not removed from the explorer, it is not removed from the model.
It is still passed to the builder as if it still existed.
I refresh the project in the explorer, and somehow the file moves into the project root (has parent <default>). If I select Go Into in the explorer (after refresh) then come back out, it disappears from the explorer and from the model.

I wrote this kludge (renamed to protect the innocent)

public class MyModelContentProvider implements IModelContentProvider {
    @Override
    public void provideModelChanges(
        Object parentElement,
        @SuppressWarnings("rawtypes") List children,
        ITreeContentProvider iTreeContentProvider)
    {
        for (int i = 0; i < children.size(); i++)
        {
            Object child = children.get(i);
            if (child instanceof IModelElement)
            {
                IModelElement modelElement = (IModelElement)child;
                boolean exists = modelElement.exists();
                if (!exists)
                {
                    if (child instanceof ISourceModule)
                    {
                        ISourceModule sourceModule = (ISourceModule)child;
                        try
                        {
                            Openable parent =
                                (Openable)sourceModule.getParent();
                            if (parent != null)
                            {
                                ModelElementInfo info =
                                    (ModelElementInfo)parent.getElementInfo();
                                if (info != null)
                                    info.removeChild(sourceModule);
                            }
                        }
                        catch (ModelException e)
                        {
                            e.printStackTrace();
                        }
                    }
                    children.remove(child);
                }
            }
        }
    }
}


This 'fixed' my problem.

[Updated on: Sat, 17 August 2013 14:36]

Report message to a moderator

Re: Deleted source file remains in navigator and model [message #1092725 is a reply to message #1088717] Fri, 23 August 2013 06:11 Go to previous message
Alex Panchenko is currently offline Alex PanchenkoFriend
Messages: 342
Registered: July 2009
Senior Member
Hi Kevin,

I would say, that if it can't be reproduced with other languages - then
it makes sense to verify your model/resource listeners and content
providers if they always work correctly, etc. Perhaps something is
called when it should not, or an exception is thrown, etc.

Regards,
Alex
Previous Topic:DLTK vs XTEXT
Next Topic:Ruby code completion on existing files not working?
Goto Forum:
  


Current Time: Wed Dec 04 10:25:38 GMT 2024

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

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

Back to the top