Be ready for symlinks and check root from the cannonical path as well
authorJaroslav Tulach <jtulach@netbeans.org>
Wed, 02 Apr 2014 17:29:29 +0200
changeset 18185aa6f18bf0172
parent 18184 883cb8658e60
child 18186 9dce58fcc8d5
Be ready for symlinks and check root from the cannonical path as well
dew4nb/src/org/netbeans/modules/dew4nb/services/debugger/ActiveSessions.java
     1.1 --- a/dew4nb/src/org/netbeans/modules/dew4nb/services/debugger/ActiveSessions.java	Tue Apr 01 15:19:10 2014 +0200
     1.2 +++ b/dew4nb/src/org/netbeans/modules/dew4nb/services/debugger/ActiveSessions.java	Wed Apr 02 17:29:29 2014 +0200
     1.3 @@ -47,6 +47,7 @@
     1.4  import java.beans.PropertyChangeEvent;
     1.5  import java.beans.PropertyChangeListener;
     1.6  import java.io.File;
     1.7 +import java.io.IOException;
     1.8  import java.util.List;
     1.9  import java.util.concurrent.ConcurrentHashMap;
    1.10  import java.util.concurrent.ConcurrentMap;
    1.11 @@ -75,6 +76,7 @@
    1.12  import org.openide.filesystems.FileObject;
    1.13  import org.openide.filesystems.FileUtil;
    1.14  import org.openide.filesystems.URLMapper;
    1.15 +import org.openide.util.Exceptions;
    1.16  import org.openide.util.Parameters;
    1.17  
    1.18  /**
    1.19 @@ -282,6 +284,15 @@
    1.20                      throw new IllegalStateException("No workspace resolver.");  //NOI18N
    1.21                  }
    1.22                  final FileObject root = wr.resolveFile(ctx);
    1.23 +                FileObject cannonRoot = null;
    1.24 +                File rootF = FileUtil.toFile(root);
    1.25 +                if (rootF != null) {
    1.26 +                    try {
    1.27 +                        cannonRoot = FileUtil.toFileObject(rootF.getCanonicalFile());
    1.28 +                    } catch (IOException ex) {
    1.29 +                        Exceptions.printStackTrace(ex);
    1.30 +                    }
    1.31 +                }
    1.32                  for (CallStackFrame csf : callStack) {
    1.33                      String relativePath;
    1.34                      try {
    1.35 @@ -289,12 +300,24 @@
    1.36                      } catch (AbsentInformationException e) {
    1.37                          relativePath = "<unknown>";
    1.38                      }
    1.39 -                    final String surl = sourcePath.getURL (relativePath, true);
    1.40 +                    String surl = sourcePath.getURL (relativePath, true);
    1.41 +                    if (surl == null) {
    1.42 +                        try {
    1.43 +                            String sn = csf.getSourceName(null);
    1.44 +                            if (sn.startsWith("file:/")) {
    1.45 +                                surl = sn;
    1.46 +                            }
    1.47 +                        } catch (AbsentInformationException ex) {
    1.48 +                            Exceptions.printStackTrace(ex);
    1.49 +                        }
    1.50 +                    }
    1.51                      if (surl != null) {
    1.52                          try {
    1.53                             final FileObject fo = URLMapper.findFileObject(new java.net.URL(surl));
    1.54                             if (root != null && fo != null && FileUtil.isParentOf(root, fo)) {
    1.55                                 relativePath = FileUtil.getRelativePath(root, fo);
    1.56 +                           } else if (cannonRoot != null && fo != null && FileUtil.isParentOf(cannonRoot, fo)) {
    1.57 +                               relativePath = FileUtil.getRelativePath(cannonRoot, fo);
    1.58                             }
    1.59                          } catch (java.net.MalformedURLException muex) {
    1.60                              LOG.log(