Menu

#17 Console: NullPointer on compile with Project Viewer

closed
None
5
2008-03-14
2008-02-14
No

The Console plugin throws a NullPointerException when asked to run a commando command (make.xml) when a project group is active in the ProjectViewer, but no project within that group is active.

Error is:

java.lang.NullPointerException: Attempt to invoke method getRootPath on null value
at bsh.Reflect.resolveExpectedJavaMethod(Reflect.java:377)
at bsh.Reflect.invokeObjectMethod(Reflect.java:77)
at bsh.BSHPrimarySuffix.doName(BSHPrimarySuffix.java:176)
...

The problem occurs because commando tries to get the root path for the active project, when no project is active.

The following workaround will change the behavior by finding the project root for the active buffer, regardless of which (if any) project is selected. (Note that this won't work properly if a file belongs to more than one project).

To apply workaround:

1) Open the commando script by right clicking the commando button and choosing "Customize"

2) Replacing the <DIR_ENTRY LABEL="Project Root" ... /> node with:

<DIR_ENTRY LABEL="Project Root"
VARNAME = "projectroot"
EVAL = 'iterator = projectviewer.ProjectManager.getInstance().getProjects();
while (iterator.hasNext()) {
project = iterator.next();
node = project.getChildNode(buffer.getPath());
if (node != null) {
return project.getRootPath();
}
}
return "";
' />

Discussion

  • Alan Ezust

    Alan Ezust - 2008-03-07

    Logged In: YES
    user_id=935841
    Originator: NO

    moving this to plugin patches.

     
  • Alan Ezust

    Alan Ezust - 2008-03-07
    • assigned_to: nobody --> ezust
     
  • Alan Ezust

    Alan Ezust - 2008-03-14
    • status: open --> closed
     
  • Alan Ezust

    Alan Ezust - 2008-03-14

    Logged In: YES
    user_id=935841
    Originator: NO

    I still like that it will try the current project of the active view first, and if that's not found only then will it search the nodes to see which project the buffer belongs. Sometimes I run make while my current buffer contains a file that's not in the project.
    But I applied a version of this patch to console 4.3.7. Thanks for the idea.

    --alan

     
  • Alan Ezust

    Alan Ezust - 2008-03-14

    Logged In: YES
    user_id=935841
    Originator: NO

    I still like that it will try the current project of the active view first, and if that's not found only then will it search the nodes to see which project the buffer belongs. Sometimes I run make while my current buffer contains a file that's not in the project.
    But I applied a version of this patch to console 4.3.7. Thanks for the idea.

    --alan

     

Log in to post a comment.