Commit 1874319e authored by Bas Lijnse's avatar Bas Lijnse

Merge branch 'improve-filecollection' into 'master'

Improved file selection and referencing files without reading in FileCollection extension

See merge request !369
parents 977e1e4b 83218fca
Pipeline #35767 passed with stage
in 6 minutes and 45 seconds
......@@ -7,12 +7,24 @@ import iTasks
from Data.Map import :: Map
from System.FilePath import :: FilePath
//Determine if a path is part of the colleciton based on the relative path and whether it is a directory
:: FileFilter :== FilePath Bool -> Bool
/**
* Determine if a path is part of the collection based on the relative path
* The path is tested against est the path against a list of 'glob'-like rules.
* Return the decision for the first rule that matches.
* If none of the rules match, the default decision is to exclude the path
*/
:: FileFilter :== [(FileFilterRule,FileFilterDecision)]
:: FileFilterRule :== String
:: FileFilterDecision
= IncludeFile //The file is part of the managed collection
| ExcludeFile //The file is not part of the collection, do not touch it
| ReferenceFile //The file is part of the collection, but don't read or write its content
:: FileCollection :== Map String FileCollectionItem
:: FileCollectionItem
= FileContent String
| FileReference
| FileCollection FileCollection
derive class iTask FileCollectionItem
......@@ -22,10 +34,14 @@ derive class iTask FileCollectionItem
* It will ignore all files in the directory that don't match the filter
* @param The filter that specifies which files and directories are part of the collection
# @param Readonly flag: When this is true, the files are only read, never written
* @param Delete flag: When this is true, files on disk that are not in the collection, but match the filter are deleted during a write.
If it is false, entries on that are removed are only marked in a file called 'exclude.txt' but not deleted.
*/
fileCollection :: FileFilter Bool -> SDSSource FilePath FileCollection FileCollection
fileCollection :: FileFilter Bool Bool -> SDSSource FilePath FileCollection FileCollection
//Filter to ignore all hidden files (e.g. starting with a '.')
ignoreHiddenFiles :: FileFilter
//Access utilities:
getStringContent:: String FileCollection -> Maybe String
......@@ -35,6 +51,3 @@ getIntContent :: String FileCollection -> Maybe Int
setIntContent :: String Int FileCollection -> FileCollection
toPaths :: FileCollection -> [FilePath]
//Filter to ignore all hidden files (e.g. starting with a '.')
ignoreHiddenFiles :: FileFilter
......@@ -59,21 +59,21 @@ where
runInteractiveTests :: Task ()
runInteractiveTests
= ( (Title "Select test") @>> editSelectionWithShared [SelectMultiple False, SelectInTree fileCollectionToTree selectTest] tests (const []) @? tvHd
= ( (Title "Select test") @>> widthAttr FlexSize @>> editSelectionWithShared [SelectMultiple False, SelectInTree fileCollectionToTree selectTest] tests (const []) @? tvHd
>&> withSelection (viewInformation [] "Select a test") testInteractive ) <<@ ArrangeWithSideBar 0 LeftSide True @! ()
where
tests = sdsFocus INTERACTIVE_TESTS_PATH (fileCollection (\path isDirectory -> isDirectory || takeExtension path == "icl") False)
tests = sdsFocus INTERACTIVE_TESTS_PATH (fileCollection [("**/*.icl",ReferenceFile)] True False)
fileCollectionToTree collection = itemsToTree [] collection
where
itemsToTree prefix subCollection = map (itemToTree prefix) ('DM'.toList subCollection)
itemToTree prefix (name,FileContent _)
= {ChoiceNode|id = determineItemId (fileName [name:prefix]) collection, label = name
, expanded = False, icon = Nothing, children = []}
itemToTree prefix (name,FileCollection subCollection)
= {ChoiceNode|id = determineItemId (fileName [name:prefix]) collection, label = name
, expanded = False, icon = Nothing, children = itemsToTree [name:prefix] subCollection}
itemToTree prefix (name,_)
= {ChoiceNode|id = determineItemId (fileName [name:prefix]) collection, label = name
, expanded = False, icon = Nothing, children = []}
fileName path = join {OS_PATH_SEPARATOR} (reverse path)
......@@ -88,7 +88,7 @@ where
runUnitTests :: Task ()
runUnitTests = withShared 'DM'.newMap
\results ->
(( (((Title "Tests") @>> editSelectionWithShared
(( (((Title "Tests") @>> widthAttr FlexSize @>> editSelectionWithShared
[SelectMultiple False, SelectInTree toModuleSelectTree selectByIndex]
(sdsFocus UNIT_TESTS_PATH moduleList) (const []) @? tvHd)
)
......@@ -148,7 +148,7 @@ where
exploreCode :: Task ()
exploreCode
= (( (((Title "Modules") @>> editSelectionWithShared
= (( (((Title "Modules") @>> widthAttr FlexSize @>> editSelectionWithShared
[SelectMultiple False, SelectInTree toModuleSelectTree selectByIndex]
(sdsFocus LIBRARY_PATH moduleList) (const []) @? tvHd)
-|| viewQualityMetrics
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment