ide; debugger; valgrind integration. gdb dialog command history. old valgrind launche...
[sdk] / ide / src / designer / CodeEditor.ec
index 1cad0f7..41a49ab 100644 (file)
@@ -229,9 +229,26 @@ void OutputType(File f, Type type, bool outputName)
             f.Printf("double");
             break;
          case classType:
-            // ADD CODE TO DECIDE WHETHER TO OUTPUT FULLY QUAlIFIED OR NOT:
-            f.Printf(type._class.shortName ? type._class.shortName : type._class.string);
+         {
+            if(type._class && !strcmp(type._class.string, "class"))
+            {
+               switch(type.classObjectType)
+               {
+                  case anyObject:
+                     f.Printf("any_object");
+                     break;
+                  default:
+                     f.Printf("typed_object");
+                     break;
+               }
+               if(type.byReference)
+                  f.Printf(" &");
+            }
+            else
+               // ADD CODE TO DECIDE WHETHER TO OUTPUT FULLY QUAlIFIED OR NOT:
+               f.Printf(type._class.shortName ? type._class.shortName : type._class.string);
             break;
+         }
          case structType:
             break;
          case unionType:
@@ -666,6 +683,10 @@ class CodeEditor : Window
 
    Designer designer { codeEditor = this, visible = false, saveDialog = codeEditorFormFileDialog };
 
+   bool noParsing;
+
+   property bool parsing { get { return editBox.syntaxHighlighting && !noParsing && !ide.noParsing; } };
+
    void ProcessCaretMove(EditBox editBox, int line, int charPos)
    {
       char temp[512];
@@ -769,7 +790,7 @@ class CodeEditor : Window
       ProjectView projectView = ide.projectView;
       if(projectView)
       {
-         ProjectNode node = projectView.GetNodeFromWindow(this, null);
+         ProjectNode node = projectView.GetNodeFromWindow(this, null, false);
          if(node)
          {
             node.modified = modifiedDocument;
@@ -784,7 +805,7 @@ class CodeEditor : Window
       textVertScroll = true, multiLine = true, /*lineNumbers = ideSettings.showLineNumbers,*/
       freeCaret = ideSettings.useFreeCaret, caretFollowsScrolling = ideSettings.caretFollowsScrolling, 
       tabKey = true, smartHome = true;
-      tabSelection = true, maxLineSize = 65536, parent = this, hasHorzScroll = true, hasVertScroll = true;
+      tabSelection = true, /*maxLineSize = 65536, */parent = this, hasHorzScroll = true, hasVertScroll = true;
       selectionColor = selectionColor, selectionText = selectionText,
       background = codeEditorBG, foreground = codeEditorFG, syntaxColorScheme = colorScheme,
       font = font, borderStyle = none;
@@ -1372,13 +1393,15 @@ class CodeEditor : Window
          {
             if(ide.projectView)
             {
-               ProjectNode node = ide.projectView.GetNodeFromWindow(this, null);
+               ProjectNode node = ide.projectView.GetNodeFromWindow(this, null, false);
+               if(!node)
+                  node = ide.projectView.GetNodeFromWindow(this, null, true);
                if(!node)
                {
                   char * s;
                   s = PrintString($"The ", fileName, $" file is not part of any project.\n", 
                      $"It can't be compiled.");
-                  MessageBox { type = ok, parent = ide, master = ide, text = $"File not in project error", contents = s }.Modal();
+                  MessageBox { type = ok, /*parent = ide, */master = ide, text = $"File not in project error", contents = s }.Modal();
                   delete s;
                   return false;
                }
@@ -1498,7 +1521,8 @@ class CodeEditor : Window
       bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
       {
          CodeEditor editor = (CodeEditor)master;
-         if(!active)
+         Window rw = previous ? previous.rootWindow : null;
+         if(!active && rw != editor.paramsList)
          {
             Destroy(0);
             editor.membersListShown = false;
@@ -1573,7 +1597,8 @@ class CodeEditor : Window
       bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
       {
          CodeEditor editor = (CodeEditor)master;
-         if(!active)
+         Window rw = previous ? previous.rootWindow : null;
+         if(!active && previous != editor.editBox && rw != editor.membersList)
          {
             Destroy(0);
             editor.membersListShown = false;
@@ -1658,7 +1683,7 @@ class CodeEditor : Window
             surface.WriteText(x, y, "(", 1);
             x += parW;
 
-            if(methodType && !methodType.staticMethod)
+            if(methodType && !methodType.staticMethod && methodType.methodClass)
             {
                int tw = 0, width;
 
@@ -1705,7 +1730,7 @@ class CodeEditor : Window
                id ++;
             }
 
-            if(!methodType || methodType.staticMethod || !type.params.first || ((Type)type.params.first).kind != voidType || type.params.count > 1)
+            if(!methodType || (methodType.staticMethod || !methodType.methodClass) || !type.params.first || ((Type)type.params.first).kind != voidType || type.params.count > 1)
             {
                for(param = type.params.first; param; param = param.next)
                {
@@ -1896,7 +1921,9 @@ class CodeEditor : Window
             {
                CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
                ProjectConfig config = projectView.project.config;
-               ide.debugger.RunToCursor(compiler, config, fileName, line, false);
+               int bitDepth = ide.workspace.bitDepth;
+               bool useValgrind = ide.workspace.useValgrind;
+               ide.debugger.RunToCursor(compiler, config, bitDepth, useValgrind, fileName, line, false, false);
                delete compiler;
             }
          }
@@ -1914,7 +1941,28 @@ class CodeEditor : Window
          {
             CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
             ProjectConfig config = projectView.project.config;
-            ide.debugger.RunToCursor(compiler, config, fileName, line, true);
+            int bitDepth = ide.workspace.bitDepth;
+            bool useValgrind = ide.workspace.useValgrind;
+            ide.debugger.RunToCursor(compiler, config, bitDepth, useValgrind, fileName, line, true, false);
+            delete compiler;
+         }
+         return true;
+      }
+   };
+   MenuItem debugSkipRunToCursorAtSameLevel
+   {
+      debugMenu, $"Run To Cursor At Same Level Skipping Breakpoints", u, Key { f10, alt = true };
+      bool NotifySelect(MenuItem selection, Modifiers mods)
+      {
+         ProjectView projectView = ide.projectView;
+         int line = editBox.lineNumber + 1;
+         if(projectView)
+         {
+            CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
+            ProjectConfig config = projectView.project.config;
+            int bitDepth = ide.workspace.bitDepth;
+            bool useValgrind = ide.workspace.useValgrind;
+            ide.debugger.RunToCursor(compiler, config, bitDepth, useValgrind, fileName, line, true, true);
             delete compiler;
          }
          return true;
@@ -2077,7 +2125,7 @@ class CodeEditor : Window
          ProjectView projectView = ide.projectView;
          if(projectView)
          {
-            ProjectNode node = projectView.GetNodeFromWindow(this, null);
+            ProjectNode node = projectView.GetNodeFromWindow(this, null, false);
             if(node && node.modified)
             {
                node.modified = false;
@@ -2096,6 +2144,7 @@ class CodeEditor : Window
       */
       if(active && directActivation)
       {
+         AdjustDebugMenus(ide.areDebugMenusUnavailable, ide.isBreakpointTogglingUnavailable, ide.isDebuggerExecuting);
          if(openedFileInfo)
             openedFileInfo.Activate();
          if(designer)
@@ -2339,16 +2388,20 @@ class CodeEditor : Window
       if(fileName)
       {
          GetExtension(fileName, ext);
-         if(!strcmpi(ext, "ec"))
+
+         if(!strcmpi(ext, "ec") || !strcmpi(ext, "eh") || !strcmpi(ext, "c") || !strcmpi(ext, "h") || !strcmpi(ext, "cpp") ||
+               !strcmpi(ext, "hpp") || !strcmpi(ext, "cxx") || !strcmpi(ext, "hxx") || !strcmpi(ext, "cc") || !strcmpi(ext, "hh") ||
+               !strcmpi(ext, "m") || !strcmpi(ext, "mm") || !strcmpi(ext, "cs") || !strcmpi(ext, "java") || !strcmpi(ext, "y") || !strcmpi(ext, "l"))
+            editBox.syntaxHighlighting = true;
+         else
+            editBox.syntaxHighlighting = false;
+
+         if(parsing && !strcmpi(ext, "ec"))
          {
             codeModified = true;
             EnsureUpToDate();
          }
 
-         if(!strcmpi(ext, "ec") || !strcmpi(ext, "c") || !strcmpi(ext, "cc") || !strcmpi(ext, "cpp") || !strcmpi(ext, "eh") || !strcmpi(ext, "hh") || !strcmpi(ext, "hpp") || !strcmpi(ext, "h") || !strcmpi(ext, "hxx") || !strcmpi(ext, "cxx"))
-            editBox.syntaxHighlighting = true;
-         else
-            editBox.syntaxHighlighting = false;
          {
             int spaceW;
             display.FontExtent(font.font, " ", 1, &spaceW, null);
@@ -2393,12 +2446,12 @@ class CodeEditor : Window
       return false;
    }
 
-   void DebugMenusDisabled()
+   void AdjustDebugMenus(bool unavailable, bool bpNoToggle, bool executing)
    {
-      bool debugMenusDisabled = ide.GetDebugMenusDisabled();
-      debugRunToCursor.disabled = debugMenusDisabled;
-      debugSkipRunToCursor.disabled = debugMenusDisabled;
-      debugToggleBreakpoint.disabled = debugMenusDisabled;
+      debugRunToCursor.disabled                = unavailable || executing;
+      debugSkipRunToCursor.disabled            = unavailable || executing;
+      debugSkipRunToCursorAtSameLevel.disabled = unavailable || executing;
+      debugToggleBreakpoint.disabled           = bpNoToggle;
    }
 
    CodeEditor()
@@ -2418,7 +2471,7 @@ class CodeEditor : Window
          designer.fileName = title;
       }
 
-      DebugMenusDisabled();
+      AdjustDebugMenus(ide.areDebugMenusUnavailable, ide.isBreakpointTogglingUnavailable, ide.isDebuggerExecuting);
 
       for(c = 0; c < CodeObjectType::enumSize; c++)
          icons[c] = BitmapResource { iconNames[c], window = this };
@@ -2448,18 +2501,20 @@ class CodeEditor : Window
    ****************************************************************************/
    void FreeParser()
    {
-      this.defines.Free(FreeModuleDefine);
-      this.imports.Free(FreeModuleImport);
-      
       if(ast != null)
       {
          FreeASTTree(ast);
          ast = null;
       }
+      this.defines.Free(FreeModuleDefine);
+      this.imports.Free(FreeModuleImport);   // Moved this after FreeAST because Debug printing causes ModuleImports to be created
+
       FreeExcludedSymbols(this.excludedSymbols);
       FreeContext(this.globalContext);
       FreeIncludeFiles();
       FreeGlobalData(&this.globalData);
+      FindCtx_Terminate();
+      FindParams_Terminate();
 
       if(GetGlobalContext() == globalContext)
       {
@@ -2496,6 +2551,7 @@ class CodeEditor : Window
       char * fileName;
       ImportedModule module;
       char extension[MAX_EXTENSION];
+      PathBackup pathBackup { };
 #ifdef _TIMINGS
       Time parseCodeStart = GetTime();
       Time startTime, startFindClass;
@@ -2539,8 +2595,8 @@ class CodeEditor : Window
 
       editBox.GetSelPos(&l1, &y1, &x1, &l2, &y2, &x2, false);
 
-      defines.Free(FreeModuleDefine);
-      imports.Free(FreeModuleImport);
+      FindCtx_Terminate();
+      FindParams_Terminate();
 
       SetGlobalData(&globalData);
       SetGlobalContext(globalContext);
@@ -2580,6 +2636,8 @@ class CodeEditor : Window
 
       // TOCHECK: COULDN'T WE CALL FreeParser here?
       // Clear everything
+      FreeType(this.functionType);
+      FreeType(this.instanceType);
       this.functionType = null;
       this.instanceType = null;
 
@@ -2645,6 +2703,8 @@ class CodeEditor : Window
          ast = null;
          //SetAST(null);
       }
+      defines.Free(FreeModuleDefine);
+      imports.Free(FreeModuleImport);
 
       FreeContext(this.globalContext);
       FreeExcludedSymbols(this.excludedSymbols);
@@ -2668,7 +2728,7 @@ class CodeEditor : Window
       if(ide.workspace)
       {
          CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
-         SetTargetBits(compiler.supportsBitDepth ? 32 : GetHostBits());
+         SetTargetBits(ide.workspace.bitDepth ? ide.workspace.bitDepth : GetHostBits());
          delete compiler;
       }
       this.privateModule = __ecere_COM_Initialize(false | ((GetTargetBits() == sizeof(uintptr) *8) ? 0 : GetTargetBits() == 64 ? 2 : 4), 1, null);
@@ -2722,8 +2782,11 @@ class CodeEditor : Window
       {
          CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
          ProjectConfig config = project.config;
-         DirExpression objDir = project.GetObjDir(compiler, config);
+         int bitDepth = ide.workspace.bitDepth;
+         DirExpression objDir = project.GetObjDir(compiler, config, bitDepth);
          SetSymbolsDir(objDir.dir);
+         ide.SetPath(true, compiler, config, bitDepth);
+
          delete objDir;
          delete compiler;
          // SetIncludeDirs(ide.projectView.project.config.includeDirs);
@@ -3145,7 +3208,7 @@ class CodeEditor : Window
                                                                   {
                                                                      curMember = thisMember;
                                                                      curClass = curMember._class;
-                                                                     memcpy(subMemberStack, _subMemberStack, sizeof(int) * _subMemberStackPos);
+                                                                     memcpy(subMemberStack, _subMemberStack, sizeof(DataMember) * _subMemberStackPos);
                                                                      subMemberStackPos = _subMemberStackPos;
                                                                      found = true;
                                                                   }
@@ -3476,6 +3539,8 @@ class CodeEditor : Window
 #endif
       if(inUseDebug && ide.projectView)
          ide.debugger.EvaluateWatches();
+
+      delete pathBackup;
    }
 
    void UpdateInstanceCodeClass(Class _class, ObjectInfo object, EditBoxStream f, Instance test, bool * prev, bool * lastIsMethod, DataMember * curMember, Class * curClass)
@@ -4363,7 +4428,8 @@ class CodeEditor : Window
    void UpdateFormCode()
    {
       if(!this) return;
-         
+      if(!parsing) return;
+
       updatingCode++;
       if(codeModified)
       {
@@ -5324,7 +5390,7 @@ class CodeEditor : Window
 
    void EnsureUpToDate()
    {
-      if(sheet && codeModified)
+      if(sheet && codeModified && parsing)
          ParseCode();
    }
 
@@ -5628,11 +5694,11 @@ class CodeEditor : Window
       }
    }
 
-   void ListClassPropertiesAndVirtual(Class whatClass)
+   void ListClassPropertiesAndVirtual(Class whatClass, String curString)
    {
       Class _class;
       bool isPrivate = false;
-      for(_class = whatClass; _class && _class.type != systemClass; _class = _class.base)
+      for(_class = whatClass; _class /*&& _class.type != systemClass*/; _class = _class.base)
       {
          Method method;
          Property prop;
@@ -5670,7 +5736,7 @@ class CodeEditor : Window
                      row.icon = icons[(member.memberAccess == publicAccess && !isPrivate) ? typeProperty : typePropertyPrivate];
                   }
                }
-               else if(member.name)
+               else if(member.name && (!curString || strcmp(curString, member.name)))
                {
                   DataRow row = membersList.AddString(member.name);
                
@@ -5752,7 +5818,7 @@ class CodeEditor : Window
          for(link = (BTNamedLink)nameSpace.classes.first; link; link = (BTNamedLink)((BTNode)link).next)
          {
             Class _class = link.data;
-            if(_class.type != systemClass)
+            if(_class.type != systemClass && !_class.templateClass)  // Omit templatized classes
             {
                DataRow row = membersList.AddString(_class.name);
                row.icon = (_class.type == unitClass || _class.type == enumClass) ? icons[typeDataType] : icons[typeClass];
@@ -5852,7 +5918,8 @@ class CodeEditor : Window
       for(link = (BTNamedLink)nameSpace.classes.first; link; link = (BTNamedLink)((BTNode)link).next)
       {
          Class _class = link.data;
-         if(_class.type == enumClass && (dest.kind != classType || !dest._class || dest._class.registered != _class))
+         if(_class.type == enumClass && (dest.kind != classType || ((!dest._class || !dest._class.registered || (dest._class.registered != _class && strcmp(dest._class.registered.dataTypeString, "char *"))) && !dest.classObjectType)) &&
+            dest.kind != pointerType && dest.kind != ellipsisType)
          {
             OldList conversions { };
             Type type { };
@@ -5954,7 +6021,7 @@ class CodeEditor : Window
          ListEnumValues(destType._class.registered);
 
          if(insideClass)
-            ListClassPropertiesAndVirtual(insideClass);
+            ListClassPropertiesAndVirtual(insideClass, null);
 
          listedEnums = true;
       }
@@ -5969,13 +6036,13 @@ class CodeEditor : Window
          }
 
          if(insideClass)
-            ListClassPropertiesAndVirtual(insideClass);
+            ListClassPropertiesAndVirtual(insideClass, null);
 
          listedEnums = true;
       }
       else if(insideClass && !enumOnly)
       {
-         ListClassPropertiesAndVirtual(insideClass);
+         ListClassPropertiesAndVirtual(insideClass, string);
       }
 
       if(listedEnums && string && string[0])
@@ -6231,6 +6298,7 @@ class CodeEditor : Window
       Expression memberExp = null;
       Identifier realIdentifier = null;
 
+      if(!parsing) return true;
       if(!privateModule) return !didOverride;
 
       insideFunction = null;
@@ -6605,6 +6673,8 @@ class CodeEditor : Window
       EditLine l1, l2;
       int x1,y1, x2,y2;
 
+      if(!parsing) return;
+
       charPos = editBox.charPos + 1;
       EnsureUpToDate();