Changeset 4296

Show
Ignore:
Timestamp:
07/19/08 10:02:07 (4 months ago)
Author:
ed
Message:

Took Nate's recent fix and went one step further: the Class Designer will check for syntax errors before you can save code when declaring imports. Also added an errorLog message when a syntax error is found in the _namespaceHacks() method; these can still arise if the developer edits the import declaration code outside of the Class Designer.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ide/ClassDesigner.py

    r4218 r4296  
    11531153        dlg = ImportEditDialog(None, BasePrefKey=self.BasePrefKey+".ImportEditDialog") 
    11541154        dlg.edtImport.Text = txt 
    1155         dlg.show() 
    1156         if dlg.Accepted: 
    1157             self._classImportDict[frm] = dlg.edtImport.Text 
     1155        showDialog = True 
     1156        while showDialog: 
     1157            dlg.show() 
     1158            showDialog = dlg.Accepted 
     1159            if showDialog: 
     1160                # Check the syntax before storing 
     1161                txt = dlg.edtImport.Text 
     1162                try: 
     1163                    compile(txt.strip(), "", "exec") 
     1164                    self._classImportDict[frm] = txt 
     1165                    showDialog = dlg.Accepted = False 
     1166                except SyntaxError, e: 
     1167                    errMsg = _("Syntax Error: %s") % e 
     1168                    dabo.ui.stop(errMsg, _("Error Compiling Import Declarations")) 
    11581169        dlg.release() 
    11591170 
  • trunk/ide/ClassDesignerEditor.py

    r4292 r4296  
    6565            try: 
    6666                exec imp in self._namespaces 
    67             except SyntaxError: 
    68                 pass #Just let namespace import fail. 
     67            except SyntaxError, e: 
     68                # Record the error so that the developer knows there is a problem. 
     69                dabo.errorLog.write(_("Compilation error found in import code: %s") % e) 
    6970 
    7071