ide: fix lack of support of variables in node path for find in files.
authorRejean Loyer <redj@ecere.com>
Wed, 28 Dec 2016 14:15:58 +0000 (09:15 -0500)
committerJerome St-Louis <jerome@ecere.com>
Wed, 28 Dec 2016 18:58:10 +0000 (13:58 -0500)
ide/src/debugger/Debugger.ec
ide/src/dialogs/FindInFilesDialog.ec
ide/src/dialogs/NodeProperties.ec
ide/src/ide.ec
ide/src/project/ProjectNode.ec
ide/src/project/ProjectView.ec
ide/src/project/Workspace.ec

index aaf0a65..17e6b3f 100644 (file)
@@ -1806,7 +1806,7 @@ class Debugger
                            {
                               char path[MAX_LOCATION];
                               char relative[MAX_LOCATION];
-                              node.GetFullFilePath(path, true);
+                              node.GetFullFilePath(path, true, true);
                               bp.absoluteFilePath = path;
                               MakePathRelative(path, prj.topNode.path, relative);
                               bp.relativeFilePath = relative;
index 335dbbe..5b558ca 100644 (file)
@@ -259,7 +259,7 @@ private:
                DataRow r = null;
                ProjectNode node = prj.topNode;
                char filePath[MAX_LOCATION];
-               prj.topNode.GetFullFilePath(filePath, true);
+               prj.topNode.GetFullFilePath(filePath, true, true);
                lastSelectionProject = CopyString(filePath);
                findWherePrjNode.Clear();
                ListProjectNodeFolders(node, null);
@@ -318,7 +318,7 @@ private:
             if(node)
             {
                char filePath[MAX_LOCATION];
-               node.GetFullFilePath(filePath, true);
+               node.GetFullFilePath(filePath, true, true);
                lastSelectionProjectNode = CopyString(filePath);
             }
          }
@@ -466,7 +466,7 @@ private:
                Project p = (Project)(intptr)row.tag;
                if(p)
                {
-                  p.topNode.GetFullFilePath(filePath, true);
+                  p.topNode.GetFullFilePath(filePath, true, true);
                   if(!fstrcmp(filePath, lastSelectionProject))
                      break;
                }
@@ -844,6 +844,17 @@ private:
 
             for(frame = 1; frame && !abort && frame < stackSize-1;)
             {
+               bool relative = true; // would be option
+               char fileRelative[MAX_LOCATION];
+               char filePath[MAX_LOCATION];
+               filePath[0] = '\0';
+               fileRelative[0] = '\0';
+               if(stack[frame].type == file || stack[frame].type == folder || stack[frame].type == folderOpen)
+               {
+                  stack[frame].GetFullFilePath(filePath, true, true);
+                  //MakePathRelative(filePath, prj.topNode.path, fileRelative);
+                  MakePathRelative(filePath, prj.topNode.path, fileRelative);
+               }
                switch(stack[frame].type)
                {
                   case project:
@@ -857,16 +868,6 @@ private:
                      break;
                   case file:
                   {
-                     bool relative = true;
-                     char fileRelative[MAX_LOCATION];
-                     char filePath[MAX_LOCATION];
-                     filePath[0] = '\0';
-                     PathCat(filePath, prj.topNode.path);
-                     PathCat(filePath, stack[frame].path);
-                     PathCat(filePath, stack[frame].name);
-                     fileRelative[0] = '\0';
-                     PathCat(fileRelative, stack[frame].path);
-                     PathCat(fileRelative, stack[frame].name);
                      if(relative && mode == workspace && prj != ide.project)
                      {
                         char special[MAX_LOCATION];
@@ -913,14 +914,6 @@ private:
                   }
                   case folder:
                   {
-                     bool relative = true;
-                     char fileRelative[MAX_LOCATION];
-                     char filePath[MAX_LOCATION];
-                     filePath[0] = '\0';
-                     PathCat(filePath, prj.topNode.path);
-                     PathCat(filePath, stack[frame].path);
-                     fileRelative[0] = '\0';
-                     PathCat(fileRelative, stack[frame].path);
                      if(relative && mode == workspace && prj != ide.project)
                      {
                         char special[MAX_LOCATION];
index 4cc58dc..dd56f30 100644 (file)
@@ -183,7 +183,7 @@ class NodeProperties : Window
             {
                char filePath[MAX_LOCATION];
                Window document;
-               node.GetFullFilePath(filePath, true);
+               node.GetFullFilePath(filePath, true, true);
                if(FileExists(filePath))
                   ide.projectView.OpenNode(node, key.ctrl && key.shift);
                else
index 766f5a6..93bbe59 100644 (file)
@@ -2826,7 +2826,7 @@ class IDEWorkSpace : Window
                {
                   if((n = p.topNode.Find(filePath, false)))
                   {
-                     n.GetFullFilePath(selectedPath, true);
+                     n.GetFullFilePath(selectedPath, true, true);
                      if((fileAttribs = FileExists(selectedPath)).isFile)
                      {
                         if(node) *node = n;
@@ -2942,6 +2942,18 @@ class IDEWorkSpace : Window
          strcpy(filePath, path);
       }
 
+      if(filePath[0] && strstr(filePath, "$("))
+      {
+         DirExpression pathExp { };
+         CompilerConfig compiler = GetCompilerConfig();
+         ProjectConfig config = prj.config;
+         int bitDepth = GetBitDepth();
+         pathExp.Evaluate(filePath, prj, compiler, config, bitDepth);
+         PathCatSlash(filePath, pathExp.dir);
+         delete compiler;
+         delete pathExp;
+      }
+
       if((fileAttribs = GoToCodeSelectFile(filePath, dir, prj, null, completePath, objectFileExt)))
          CodeLocationGoTo(completePath, fileAttribs, line, col);
    }
index d6c478d..ac02163 100644 (file)
@@ -518,11 +518,13 @@ private:
       }
    }
 
-   char * GetFullFilePath(char * buffer, bool resolveVars)
+   char * GetFullFilePath(char * buffer, bool absolute, bool resolveVars)
    {
       if(buffer)
       {
-         strcpy(buffer, root.path);
+         *buffer = 0;
+         if(absolute)
+            strcpy(buffer, root.path);
          if(resolveVars)
          {
             if(path && path[0])
@@ -1137,7 +1139,7 @@ private:
                else if(child.name && !fstrcmp(lastDirName, child.name))
                {
                   char p[MAX_LOCATION];
-                  child.GetFullFilePath(p, true);
+                  child.GetFullFilePath(p, true, true);
                   if(!fstrcmp(p, path))
                   {
                      result = child;
@@ -2453,7 +2455,7 @@ private:
             if(!strcmpi(extension, &h2s))
             {
                char filePath[MAX_LOCATION];
-               GetFullFilePath(filePath, true);
+               GetFullFilePath(filePath, true, true);
                OutputLog($"No compilation required for header file "); OutputLog(filePath); OutputLog("\n");
                ChangeExtension(moduleName, h2s, moduleName);
                if(prj.topNode.Find(moduleName, false))
index e217a07..5690b2c 100644 (file)
@@ -1959,7 +1959,7 @@ class ProjectView : Window
    {
       char filePath[MAX_LOCATION];
       char ext[MAX_EXTENSION];
-      node.GetFullFilePath(filePath, true);
+      node.GetFullFilePath(filePath, true, true);
 
       GetExtension(filePath, ext);
       if(binaryDocExt.Find(ext))
@@ -2149,7 +2149,7 @@ class ProjectView : Window
          fileDialog.master = parent;
          while(node)
          {
-            node.GetFullFilePath(path, true);
+            node.GetFullFilePath(path, true, true);
             while(path[0])
             {
                StripLastDirectory(path, path);
index ba6c2b8..b696490 100644 (file)
@@ -370,7 +370,7 @@ public:
       }
       if(prj)
       {
-         node.GetFullFilePath(absolute, true);
+         node.GetFullFilePath(absolute, true, true);
          return CopyString(absolute);
       }