Add support for test modules.

[DEVELOPMENT ENVIRONMENT]
* NEW: Add support for test modules.
This commit is contained in:
gambas 2020-02-22 15:58:32 +01:00
parent e584ba6713
commit 3adee3a411
16 changed files with 568 additions and 515 deletions

File diff suppressed because it is too large Load Diff

View File

@ -907,6 +907,10 @@ Private Sub GetModule(sClass As String) As Object
sPath = Project.FindPath(sClass & ".module")
If sPath Then Return Project.LoadFile(sPath)
If Project.HasTest Then
sPath = Project.FindPath(sClass & ".test")
If sPath Then Return Project.LoadFile(sPath)
Endif
For Each sFamily In CFamily.List
sPath = Project.FindPath(sClass & "." & sFamily)
If sPath Then Return Project.LoadFile(sPath)
@ -974,7 +978,7 @@ Public Sub ScanSingleClass(hPModule As FEditor) As Collection
cSymbol = New Collection(gb.IgnoreCase)
hPModule.Scan = cSymbol
ScanClass(hPModule, cSymbol, File.Ext(hPModule.Path) = "module", False)
ScanClass(hPModule, cSymbol, Project.IsModuleExt(hPModule.Path), False)
Return cSymbol
End
@ -1032,16 +1036,20 @@ Public Function GetClassSymbols(sClass As String, Optional sComponent As String)
Endif
sPath = Project.FindPath(sClass & ".module")
If Exist(sPath) Then hPModule = Project.LoadFile(sPath)
For Each sFamily In CFamily.List
sPath = Project.FindPath(sClass & "." & sFamily)
If Exist(sPath) Then
Try hPForm = Project.LoadFile(sPath)
Break
Endif
Next
sPath = Project.FindPath(sClass & ".class")
If Exist(sPath) Then hPClass = Project.LoadFile(sPath)
If Not Exist(sPath) Then sPath = Project.FindPath(sClass & ".test")
If Exist(sPath) Then
hPModule = Project.LoadFile(sPath)
Else
For Each sFamily In CFamily.List
sPath = Project.FindPath(sClass & "." & sFamily)
If Exist(sPath) Then
Try hPForm = Project.LoadFile(sPath)
Break
Endif
Next
sPath = Project.FindPath(sClass & ".class")
If Exist(sPath) Then hPClass = Project.LoadFile(sPath)
Endif
cSymbol = New Collection

View File

@ -18,12 +18,12 @@ Static Public Sub _init()
All = New Collection(gb.IgnoreCase)
For Each sModule In ["module", "class"]
For Each sModule In ["module", "test", "class"]
Picture["img/16" &/ sModule & ".png"] = Project.MakeModuleIcon(sModule, 16).Picture
Picture["img/32" &/ sModule & ".png"] = Project.MakeModuleIcon(sModule, 32).Picture
Next
Ext = ["module", "class"]
Ext = ["module", "test", "class"]
hModule = New CModule("form", ("Form"), ("Forms"), ("Gambas forms"))
hModule = New CModule("webpage", ("WebPage"), ("WebPages"), ("Gambas web pages"))

View File

@ -36,6 +36,8 @@ Public Sub fprInfo_Data()
Case "module"
sType = ("Gambas module")
Case "test"
sType = ("Gambas test module")
Case "class"
sType = ("Gambas class")
@ -161,6 +163,7 @@ Public Sub panStat_Arrange()
gvwStat.Columns.Count = 2
AddStat(("Modules"), Project.GetCount("module"))
If Project.HasTest Then AddStat(("Test modules"), Project.GetCount("test"))
AddStat(("Classes"), Project.GetCount("class"))
For Each hModule In CModule.All
If hModule.Used Then AddStat(hModule.NamePlural, Project.GetCount(hModule.Key))

View File

@ -377,7 +377,7 @@ Static Public Sub GetModeFromPath(sPath As String) As String
sMode = "gambas"
Case "html", "htm", "xml", "kml", "rss"
sMode = "html"
Case "module", "class"
Case "module", "test", "class"
If Project.IsSourcePath(sPath) Then sMode = "gambas"
If Project.IsHiddenPath(sPath) Then sMode = "gambas"
End Select

View File

@ -165,7 +165,7 @@ Public Sub tvwProject_Activate()
tvwProject[sKey].Expanded = True
If CanEdit(sKey) Then
If $bCtrl Then
If Project.IsSourcePath(sKey) And If File.Ext(sKey) <> "module" Then
If Project.IsSourcePath(sKey) And If Not Project.IsModuleExt(sKey) Then
sKeyClass = File.SetExt(sKey, "class")
If Project.IsSourcePath(sKeyClass) Then sKey = sKeyClass
Endif
@ -423,7 +423,7 @@ Public Sub mnuPopup_Show()
mnuDeleteFile.Visible = mnuDeleteFile.Visible And CanDelete(sCurrent) And Not Project.Running
mnuEditFile.Visible = mnuEditFile.Visible And CanEdit(sCurrent)
mnuEditClass.Visible = mnuEditFile.Visible And Project.IsFormPath(sCurrent)
mnuEditClass.Visible = mnuEditFile.Visible And Project.IsFormExt(sCurrent)
mnuStartup.Visible = mnuEditFile.Visible
If mnuStartup.Visible Then
@ -483,6 +483,7 @@ Public Sub mnuPopup_Show()
Next
mnuNewClass.Show
mnuNewModule.Show
mnuNewTest.Visible = Project.HasTest
Endif
@ -553,6 +554,7 @@ Public Sub mnuPopup_Show()
Next
mnuNewClass.Hide
mnuNewModule.Hide
mnuNewTest.Hide
Endif

View File

@ -501,6 +501,12 @@
Picture = Picture["img/module/module.png"]
Tag = "module"
}
{ mnuNewTest Menu mnuNewFile
Name = "mnuNewTest"
Text = ("Test module") & "..."
Picture = Picture["img/module/test.png"]
Tag = "test"
}
{ mnuNewClass Menu mnuNewFile
Name = "mnuNewClass"
Text = ("Class") & "..."
@ -1298,13 +1304,6 @@
MoveScaled(86,8,0,9)
Visible = False
}
{ btnWorkspaceProject ToolButton
MoveScaled(22,1,4,4)
Visible = False
ToolTip = ("Show project tree")
Ignore = True
Picture = Picture["icon:/small/view-tree"]
}
{ btnWorkspaceProperty ToolButton
MoveScaled(27,1,4,4)
Visible = False
@ -1312,6 +1311,13 @@
Ignore = True
Picture = Picture["icon:/small/properties"]
}
{ btnWorkspaceProject ToolButton
MoveScaled(22,1,4,4)
Visible = False
ToolTip = ("Show project tree")
Ignore = True
Picture = Picture["icon:/small/view-tree"]
}
}
{ panDebug SidePanel
MoveScaled(3,37,81,14)
@ -1366,13 +1372,6 @@
Text = ("Hierarchy")
Index = 0
}
{ btnPropertyToolbar ToolButton
MoveScaled(0,0,4,4)
Visible = False
ToolTip = ("Show controls")
Ignore = True
Picture = Picture["img/16/control.png"]
}
{ btnPropertyHelp ToolButton
MoveScaled(4,0,4,4)
Visible = False
@ -1380,6 +1379,13 @@
Ignore = True
Picture = Picture["icon:/small/help"]
}
{ btnPropertyToolbar ToolButton
MoveScaled(0,0,4,4)
Visible = False
ToolTip = ("Show controls")
Ignore = True
Picture = Picture["img/16/control.png"]
}
}
{ panTool SidePanel
MoveScaled(5,49,21,37)

View File

@ -219,6 +219,9 @@ Public UseInheritance As Boolean
Private $bFileIsUnknown As Boolean
' If 'gb.test' is checked
Public HasTest As Boolean
' If GetFileIcon() has been called on an added file
'Private $bLastAdded As Boolean
@ -1971,7 +1974,7 @@ Public Function LoadFile(sPath As String, Optional bNoErrorIfUnknown As Boolean)
Select Case sType
Case "module", "class"
Case "module", "test", "class"
hForm = New FEditor(sPath)
Case "form", "report", "webform", "termform"
@ -2003,7 +2006,7 @@ Public Function LoadFile(sPath As String, Optional bNoErrorIfUnknown As Boolean)
Case "png", "gif", "jpg", "jpeg", "bmp", "xpm"
hForm = New FImageEditor(sPath)
Case "module", "class"
Case "module", "test", "class"
hForm = New FEditor(sPath)
Case Else
@ -3080,14 +3083,12 @@ Public Function GetClasses(Optional bFullPath As Boolean) As String[]
Dim sPath As String
Dim aClass As New String[]
Dim sExt As String
If Not Path Then Return aClass
For Each sPath In Tree.Sources
sExt = File.Ext(sPath)
If sExt = "class" Or If sExt = "module" Then
If IsModuleExt(sPath) Or If sPath Ends ".class" Then
If bFullPath Then
aClass.Add(sPath)
Else
@ -4669,8 +4670,10 @@ Public Sub RefreshComponents(Optional bForce As Boolean)
$aOldRefreshComponents = aLib
HasTest = Components.Exist("gb.test")
Endif
End
Public Function IsSourceDir(sDir As String) As Boolean
@ -4696,22 +4699,33 @@ Public Function IsSourcePath(sPath As String, Optional bAllowDir As Boolean) As
End
Public Function IsFormPath(sPath As String) As Boolean
If Not IsSourcePath(sPath) Then Return
Public Function IsFormExt(sPath As String) As Boolean
If File.Ext(sPath) = "class" Then Return
Return Exist(File.SetExt(sPath, "class"))
End
Public Function IsFormPath(sPath As String) As Boolean
If Not IsSourcePath(sPath) Then Return
Return IsFormExt(sPath)
End
Public Function IsModuleExt(sPath As String) As Boolean
Dim sExt As String = File.Ext(sPath)
If sExt = "module" Or If sExt = "test" Then Return True
End
Public Sub IsProjectPath(sPath As String) As Boolean
Return sPath Begins Project.Dir &/ "/"
End
Public Function IsImagePath(sPath As String) As Boolean
Return IMAGE_EXT.Exist(File.Ext(sPath))
@ -5468,10 +5482,8 @@ Public Sub IsExported(sPath As String) As Boolean
Dim hFile As File
Dim sLine As String
Dim sExt As String
sExt = File.Ext(sPath)
If sExt <> "module" And If sExt <> "class" Then sPath = File.SetExt(sPath, "class")
If Not IsModuleExt(sPath) Then sPath = File.SetExt(sPath, "class")
If Not Exist(sPath) Then Return
Try hFile = Open sPath
@ -6402,7 +6414,7 @@ Public Sub IsModified(sPath As String, Optional bNoClass As Boolean) As Boolean
If HasFlag(sPath, FLAG_MODIFIED) Then Return True
If Not IsSourcePath(sPath) Then Return
If Not IsFormPath(sPath) Then Return
If Not IsFormExt(sPath) Then Return
If bNoClass Then Return
Return HasFlag(File.SetExt(sPath, "class"), FLAG_MODIFIED)
@ -6443,7 +6455,6 @@ Private Sub RenamePaths(sOld As String, sNew As String)
Dim hForm As Object
Dim sCheck As String
Dim sNewFormPath As String
Dim sExt As String
' Rename DoNotTranslate
@ -6492,8 +6503,7 @@ Private Sub RenamePaths(sOld As String, sNew As String)
' Rename breakpoints
If IsSourcePath(sOld) Then
sExt = File.Ext(sOld)
If sExt = "class" Or If sExt = "module" Then
If IsModuleExt(sOld) Or If sOld Ends ".class" Then
Design.RenameClass(File.BaseName(sOld), File.BaseName(sNew))
Endif
Endif

View File

@ -165,10 +165,10 @@ Private Sub AddFile(sDir As String, sFile As String, Optional bAfter As Boolean,
' 'sParent = hModule.TreeKey
' 'If Not hModule.Used Then bIgnore = True
' sParent = sDir
Else If sExt <> "module" Then
'If Not HasModule(sExt) Then
' bIgnore = True
'Endif
' Else If sExt <> "module" Then
' 'If Not HasModule(sExt) Then
' ' bIgnore = True
' 'Endif
Endif
If Not sParent Then sParent = sDir
@ -418,6 +418,9 @@ Public Function FindPath(sClass As String) As String
sPath = Sources[sClass & ".module"]
If sPath Then Return sPath
sPath = Sources[sClass & ".test"]
If sPath Then Return sPath
End
Public Sub FindKey(sClass As String) As String
@ -570,7 +573,7 @@ Public Sub GetFileIcon(sPath As String, Optional iSize As Integer, hStat As Stat
sExt = File.Ext(sPath)
Select Case sExt
Case "form", "class", "module", "webpage", "report", "webform", "termform"
Case "form", "class", "module", "test", "webpage", "report", "webform", "termform"
If IsSourcePath(sPath) Then
sModule = sExt
sIcon = sExt
@ -982,6 +985,7 @@ Public Sub ExistClass(sClass As String) As Boolean
If Sources.Exist(sClass & ".class") Then Return True
If Sources.Exist(sClass & ".module") Then Return True
If Sources.Exist(sClass & ".test") Then Return True
End

View File

@ -157,6 +157,12 @@ Private Sub CreateFile() As Boolean
Project.InsertSource(sName, sType, $sDir, sTemp)
Case "test"
sTemp = "' Gambas test module file\n\n"
Project.InsertSource(sName, sType, $sDir, sTemp)
Case "class"
sTemp = "' Gambas class file\n\n"

View File

@ -1,7 +1,7 @@
# Gambas Form File 3.0
{ Form Form
MoveScaled(0,0,63,74)
MoveScaled(0,0,64,74)
Text = ("New file")
Icon = Picture["icon:/small/new"]
Resizable = False

View File

@ -21,6 +21,7 @@ Private Sub InitFilter()
If Project.IsSourceDir($sDir) Then
aFilter = ["*.module", ("Gambas modules"), "*.class", ("Gambas classes")]
If Project.HasTest Then aFilter.Insert(["*.test", ("Gambas test modules")])
For Each hModule In CModule.All
If Not hModule.Used Then Continue
aFilter.Add("*." & hModule.Key)
@ -131,13 +132,17 @@ Private Sub ImportFile() As Boolean
Select Case sExt
Case "module"
Case "module", "test", "class"
sName = File.BaseName(Project.GetUniqueSourceName(sName))
Project.InsertSource(sName, "module", $sDir, sTemp,,, chkLink.Value)
Project.InsertSource(sName, sExt, $sDir, sTemp,,, chkLink.Value)
Case "class"
sName = File.BaseName(Project.GetUniqueSourceName(sName))
Project.InsertSource(sName, "class", $sDir, sTemp,,, chkLink.Value)
' Case "test"
' sName = File.BaseName(Project.GetUniqueSourceName(sName))
' Project.InsertSource(sName, "test", $sDir, sTemp,,, chkLink.Value)
'
' Case "class"
' sName = File.BaseName(Project.GetUniqueSourceName(sName))
' Project.InsertSource(sName, "class", $sDir, sTemp,,, chkLink.Value)
Case "form", "report", "webform", "termform"
sName = File.BaseName(Project.GetUniqueSourceName(sName))

View File

@ -939,6 +939,7 @@ Private Sub UpdateStat()
gvwStat.Rows.Count = 0
AddStat(("Modules"), CStr(Project.GetCount("module")))
If Project.HasTest Then AddStat(("Test modules"), CStr(Project.GetCount("test")))
AddStat(("Classes"), CStr(Project.GetCount("class")))
For Each hModule In CModule.All

View File

@ -107,7 +107,7 @@ Private Sub GetFileType() As Integer
Select Case LCase(File.Ext($sPath))
Case "class", "module", "form", "text", "txt", "html", "css", "svg", "desktop", "inf"
Case "class", "module", "test", "form", "text", "txt", "html", "css", "svg", "desktop", "inf"
Return TYPE_TEXT
Case "jpg", "jpeg", "png", "gif", "xpm", "bmp"

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B