ide: fix goto line from find in files not working because results (code) mistaken...
authorRejean Loyer <redj@ecere.com>
Tue, 3 Jun 2014 15:51:19 +0000 (11:51 -0400)
committerJerome St-Louis <jerome@ecere.com>
Sun, 15 Feb 2015 18:50:09 +0000 (13:50 -0500)
 - improve go to file/line from output logs

ide/src/debugger/Debugger.ec
ide/src/ide.ec
ide/src/project/Project.ec
ide/src/project/Workspace.ec

index efaa9c2..ffb67e7 100644 (file)
@@ -1063,7 +1063,7 @@ class Debugger
       char relativeFilePath[MAX_LOCATION];
       _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::RunToCursor()");
       _ChangeUserAction(runToCursor);
-      WorkspaceGetRelativePath(absoluteFilePath, relativeFilePath, null);
+      ide.workspace.GetRelativePath(absoluteFilePath, relativeFilePath, null);
 
       if(bpRunToCursor && bpRunToCursor.inserted && symbols)
       {
@@ -1340,7 +1340,7 @@ class Debugger
          Project owner;
          char relativePath[MAX_LOCATION];
 
-         WorkspaceGetRelativePath(absolutePath, relativePath, &owner);
+         ide.workspace.GetRelativePath(absolutePath, relativePath, &owner);
 
          if(!owner && !FileExists(absolutePath))
          {
@@ -2100,7 +2100,7 @@ class Debugger
       GdbExecCommon();
       if(absoluteFilePath)
       {
-         WorkspaceGetRelativePath(absoluteFilePath, relativeFilePath, null);
+         ide.workspace.GetRelativePath(absoluteFilePath, relativeFilePath, null);
          if(!GdbCommand(0.1, true, "-exec-until %s:%d", relativeFilePath, lineNumber))
          {
             GetLastDirectory(relativeFilePath, relativeFilePath);
@@ -2126,7 +2126,7 @@ class Debugger
       GdbExecCommon();
       if(lineNumber)
       {
-         WorkspaceGetRelativePath(absoluteFilePathOrLocation, relativeFilePath, null);
+         ide.workspace.GetRelativePath(absoluteFilePathOrLocation, relativeFilePath, null);
          if(!GdbCommand(0.1, true, "advance %s:%d", relativeFilePath, lineNumber)) // should use -exec-advance -- GDB/MI implementation missing
          {
             GetLastDirectory(relativeFilePath, relativeFilePath);
@@ -4822,7 +4822,7 @@ class Breakpoint : struct
          {
             if(!strcmp(prjName, prj.name))
             {
-               if(ProjectGetAbsoluteFromRelativePath(prj, filePath, fullPath))
+               if(prj.GetAbsoluteFromRelativePath(filePath, fullPath))
                {
                   property::absoluteFilePath = fullPath;
                   project = prj;
@@ -4836,7 +4836,7 @@ class Breakpoint : struct
       else
       {
          Project prj = ide.project;
-         if(ProjectGetAbsoluteFromRelativePath(prj, filePath, fullPath))
+         if(prj.GetAbsoluteFromRelativePath(filePath, fullPath))
          {
             property::absoluteFilePath = fullPath;
             project = prj;
@@ -5047,101 +5047,3 @@ void GDBFallBack(Expression exp, String expString)
       exp.type = constantExp;
    }
 }
-
-static Project WorkspaceGetFileOwner(const char * absolutePath)
-{
-   Project owner = null;
-   for(prj : ide.workspace.projects)
-   {
-      if(prj.topNode.FindByFullPath(absolutePath, false))
-      {
-         owner = prj;
-         break;
-      }
-   }
-   if(!owner)
-      WorkspaceGetObjectFileNode(absolutePath, &owner);
-   return owner;
-}
-
-static ProjectNode WorkspaceGetObjectFileNode(const char * filePath, Project * project)
-{
-   ProjectNode node = null;
-   char ext[MAX_EXTENSION];
-   GetExtension(filePath, ext);
-   if(ext[0])
-   {
-      IntermediateFileType type = IntermediateFileType::FromExtension(ext);
-      if(type)
-      {
-         char fileName[MAX_FILENAME];
-         GetLastDirectory(filePath, fileName);
-         if(fileName[0])
-         {
-            DotMain dotMain = DotMain::FromFileName(fileName);
-            for(prj : ide.workspace.projects)
-            {
-               if((node = prj.FindNodeByObjectFileName(fileName, type, dotMain, null)))
-               {
-                  if(project)
-                     *project = prj;
-                  break;
-               }
-            }
-         }
-      }
-   }
-   return node;
-}
-
-static ProjectNode ProjectGetObjectFileNode(Project project, const char * filePath)
-{
-   ProjectNode node = null;
-   char ext[MAX_EXTENSION];
-   GetExtension(filePath, ext);
-   if(ext[0])
-   {
-      IntermediateFileType type = IntermediateFileType::FromExtension(ext);
-      if(type)
-      {
-         char fileName[MAX_FILENAME];
-         GetLastDirectory(filePath, fileName);
-         if(fileName[0])
-         {
-            DotMain dotMain = DotMain::FromFileName(fileName);
-            node = project.FindNodeByObjectFileName(fileName, type, dotMain, null);
-         }
-      }
-   }
-   return node;
-}
-
-static void WorkspaceGetRelativePath(const char * absolutePath, char * relativePath, Project * owner)
-{
-   Project prj = WorkspaceGetFileOwner(absolutePath);
-   if(owner)
-      *owner = prj;
-   if(!prj)
-      prj = ide.workspace.projects.firstIterator.data;
-   if(prj)
-   {
-      MakePathRelative(absolutePath, prj.topNode.path, relativePath);
-      MakeSlashPath(relativePath);
-   }
-   else
-      relativePath[0] = '\0';
-}
-
-static bool ProjectGetAbsoluteFromRelativePath(Project project, const char * relativePath, char * absolutePath)
-{
-   ProjectNode node = project.topNode.FindWithPath(relativePath, false);
-   if(!node)
-      node = ProjectGetObjectFileNode(project, relativePath);
-   if(node)
-   {
-      strcpy(absolutePath, node.project.topNode.path);
-      PathCat(absolutePath, relativePath);
-      MakeSlashPath(absolutePath);
-   }
-   return node != null;
-}
index 5c2239f..0f83e27 100644 (file)
@@ -2681,7 +2681,7 @@ class IDEWorkSpace : Window
       FileAttribs fileAttribs;
 
       // support for valgrind output
-      if((s = strstr(text, "==")) && (s = strstr(s+2, "==")) && (s = strstr(s+2, ":")) && (s = strstr(s+1, ":")))
+      if((s = strstr(text, "==")) && s == text && (s = strstr(s+2, "==")) && (s = strstr(s+2, ":")) && (s = strstr(s+1, ":")))
       {
          colon = s;
          for(; s>text; s--)
@@ -2791,10 +2791,11 @@ class IDEWorkSpace : Window
             }
             if(!done)
             {
+               Project project;
+               ProjectNode node;
                for(p : ide.workspace.projects)
                {
-                  ProjectNode node = p.topNode.Find(filePath, false);
-                  if(node)
+                  if((node = p.topNode.Find(filePath, false)))
                   {
                      node.GetFullFilePath(completePath);
                      if((fileAttribs = FileExists(completePath)).isFile)
@@ -2804,6 +2805,9 @@ class IDEWorkSpace : Window
                      }
                   }
                }
+               if(!node && (node = workspace.GetObjectFileNode(filePath, &project, completePath)) && project &&
+                     (fileAttribs = FileExists(completePath)).isFile)
+                  CodeLocationGoTo(completePath, fileAttribs, line, col);
             }
          }
       }
index 19d248a..013772f 100644 (file)
@@ -1349,6 +1349,42 @@ private:
    }
 
 #ifndef MAKEFILE_GENERATOR
+   ProjectNode GetObjectFileNode(const char * filePath)
+   {
+      ProjectNode node = null;
+      char ext[MAX_EXTENSION];
+      GetExtension(filePath, ext);
+      if(ext[0])
+      {
+         IntermediateFileType type = IntermediateFileType::FromExtension(ext);
+         if(type)
+         {
+            char fileName[MAX_FILENAME];
+            GetLastDirectory(filePath, fileName);
+            if(fileName[0])
+            {
+               DotMain dotMain = DotMain::FromFileName(fileName);
+               node = FindNodeByObjectFileName(fileName, type, dotMain, null);
+            }
+         }
+      }
+      return node;
+   }
+
+   bool GetAbsoluteFromRelativePath(const char * relativePath, char * absolutePath)
+   {
+      ProjectNode node = topNode.FindWithPath(relativePath, false);
+      if(!node)
+         node = GetObjectFileNode(relativePath);
+      if(node)
+      {
+         strcpy(absolutePath, node.project.topNode.path);
+         PathCat(absolutePath, relativePath);
+         MakeSlashPath(absolutePath);
+      }
+      return node != null;
+   }
+
    void MarkChanges(ProjectNode node)
    {
       for(cfg : topNode.configurations)
index bf868e4..b7f4710 100644 (file)
@@ -442,6 +442,81 @@ public:
       return nodes;
    }
 
+   Project GetFileOwner(const char * absolutePath)
+   {
+      Project owner = null;
+      for(prj : projects)
+      {
+         if(prj.topNode.FindByFullPath(absolutePath, false))
+         {
+            owner = prj;
+            break;
+         }
+      }
+      if(!owner)
+         GetObjectFileNode(absolutePath, &owner, null);
+      return owner;
+   }
+
+   void GetRelativePath(const char * absolutePath, char * relativePath, Project * owner)
+   {
+      Project prj = GetFileOwner(absolutePath);
+      if(owner)
+         *owner = prj;
+      if(!prj)
+         prj = projects.firstIterator.data;
+      if(prj)
+      {
+         MakePathRelative(absolutePath, prj.topNode.path, relativePath);
+         MakeSlashPath(relativePath);
+      }
+      else
+         relativePath[0] = '\0';
+   }
+
+   ProjectNode GetObjectFileNode(const char * filePath, Project * project, char * fullPath)
+   {
+      ProjectNode node = null;
+      char ext[MAX_EXTENSION];
+      GetExtension(filePath, ext);
+      if(ext[0])
+      {
+         IntermediateFileType type = IntermediateFileType::FromExtension(ext);
+         if(type)
+         {
+            char fileName[MAX_FILENAME];
+            GetLastDirectory(filePath, fileName);
+            if(fileName[0])
+            {
+               DotMain dotMain = DotMain::FromFileName(fileName);
+               for(prj : ide.workspace.projects)
+               {
+                  if((node = prj.FindNodeByObjectFileName(fileName, type, dotMain, null)))
+                  {
+                     if(project)
+                        *project = prj;
+                     if(fullPath)
+                     {
+                        const char * cfgName = prj.config ? prj.config.name : "";
+                        char name[MAX_FILENAME];
+                        CompilerConfig compiler = ideSettings.GetCompilerConfig(prj.lastBuildCompilerName);
+                        DirExpression objDir = prj.GetObjDir(compiler, prj.config, bitDepth);
+                        strcpy(fullPath, prj.topNode.path);
+                        PathCatSlash(fullPath, objDir.dir);
+                        node.GetObjectFileName(name, prj.configsNameCollisions[cfgName], type, dotMain);
+                        PathCatSlash(fullPath, name);
+                        delete objDir;
+                        delete compiler;
+                     }
+                     break;
+                  }
+               }
+            }
+         }
+      }
+      return node;
+   }
+
    OpenedFileInfo UpdateOpenedFileInfo(const char * fileName, OpenedFileState state)
    {
       char filePath[MAX_LOCATION];