Overview
Comment: | PackageLoader now attempts to parse and qualify first read module. Fails because loading dependant modules is not implemented yet. |
---|---|
Timelines: | family | ancestors | descendants | both | modules |
Files: | files | file ages | folders |
SHA3-256: |
19fdcbebbe0053d59abc2693196cfc55 |
User & Date: | robin.hansen on 2021-03-27 11:07:03 |
Other Links: | branch diff | manifest | tags |
Context
2021-03-28
| ||
09:45 | PackageLoader now provides Qualifier with information about available external modules. check-in: c20bd81f06 user: robin.hansen tags: modules | |
2021-03-27
| ||
11:07 | PackageLoader now attempts to parse and qualify first read module. Fails because loading dependant m... check-in: 19fdcbebbe user: robin.hansen tags: modules | |
2021-03-23
| ||
10:01 | PackageLoader now tries to read first exposed module of root project. check-in: ca528df21c user: robin.hansen tags: modules | |
Changes
Modified src/Play/PackageLoader.elm from [671559e63e] to [43234ba93c].
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 .. 36 37 38 39 40 41 42 43 44 45 46 47 48 49 .. 51 52 53 54 55 56 57 58 59 60 61 62 63 64 ... 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 ... 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
) import Dict exposing (Dict) import Json.Decode as Json import List.Extra as List import Play.Data.ModuleName as ModuleName exposing (ModuleName) import Play.Data.PackageMetadata as PackageMetadata exposing (PackageMetadata) import Play.Data.PackageName as PackageName import Play.Data.PackagePath as PackagePath exposing (PackagePath) import Play.Data.SemanticVersion as SemanticVersion exposing (SemanticVersion) import Play.Qualifier as Qualifier import Result.Extra as Result type Problem = InvalidPackageMetadata String String | UnknownMessageForState String ................................................................................ | Failed Problem type alias State = { rootPackage : PackageInfo , dependencies : Dict String SemanticVersion , dependentPackages : Dict String PackageInfo } type alias PackageInfo = { path : String , metadata : PackageMetadata , modules : List ModuleName ................................................................................ emptyState : PackageInfo -> State emptyState rootPackage = { rootPackage = rootPackage , dependencies = rootPackage.metadata.dependencies , dependentPackages = Dict.empty } type Msg = FileContents String String String | ResolvedDirectories String (List PackagePath) | ResolvedPackageModules String (List String) ................................................................................ Failed NoExposedModulesInRootProject firstExposedModule :: remModules -> if List.member firstExposedModule state.rootPackage.modules then let ( path, fileName ) = readModuleFromDisk state.rootPackage.path firstExposedModule in Compiling state remModules (ReadFile path fileName) else Failed (ModuleNotFound (ModuleName.toString firstExposedModule)) readModuleFromDisk : String -> ModuleName -> ( String, String ) readModuleFromDisk packagePath moduleName = ................................................................................ |> String.join "/" , name ++ ".play" ) _ -> ( "", "" ) in ( packagePath ++ "/src" ++ path , fileName ) compilingUpdate : Msg -> State -> List ModuleName -> Model compilingUpdate msg state remainingModules = Failed (InternalError "U") |
| > > > > > > > > > | | > > > > > > > > > > > > > > > > > > > < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 .. 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 .. 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 ... 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 ... 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
) import Dict exposing (Dict) import Json.Decode as Json import List.Extra as List import Play.Data.ModuleName as ModuleName exposing (ModuleName) import Play.Data.PackageMetadata as PackageMetadata exposing (PackageMetadata) import Play.Data.PackageName as PackageName exposing (PackageName) import Play.Data.PackagePath as PackagePath exposing (PackagePath) import Play.Data.SemanticVersion as SemanticVersion exposing (SemanticVersion) import Play.Parser as Parser import Play.Qualifier as Qualifier import Result.Extra as Result type Problem = InvalidPackageMetadata String String | UnknownMessageForState String ................................................................................ | Failed Problem type alias State = { rootPackage : PackageInfo , dependencies : Dict String SemanticVersion , dependentPackages : Dict String PackageInfo , filePathToModule : Dict String ( PackageName, ModuleName ) } type alias PackageInfo = { path : String , metadata : PackageMetadata , modules : List ModuleName ................................................................................ emptyState : PackageInfo -> State emptyState rootPackage = { rootPackage = rootPackage , dependencies = rootPackage.metadata.dependencies , dependentPackages = Dict.empty , filePathToModule = Dict.empty } type Msg = FileContents String String String | ResolvedDirectories String (List PackagePath) | ResolvedPackageModules String (List String) ................................................................................ Failed NoExposedModulesInRootProject firstExposedModule :: remModules -> if List.member firstExposedModule state.rootPackage.modules then let ( path, fileName ) = readModuleFromDisk state.rootPackage.path firstExposedModule pathsToModuleNames = List.foldl pathsOfModules Dict.empty (state.rootPackage :: Dict.values state.dependentPackages) in Compiling { state | filePathToModule = pathsToModuleNames } remModules (ReadFile path fileName) else Failed (ModuleNotFound (ModuleName.toString firstExposedModule)) readModuleFromDisk : String -> ModuleName -> ( String, String ) readModuleFromDisk packagePath moduleName = ................................................................................ |> String.join "/" , name ++ ".play" ) _ -> ( "", "" ) in ( [ packagePath, "src", path ] |> List.filter (not << String.isEmpty) |> String.join "/" , fileName ) pathsOfModules : PackageInfo -> Dict String ( PackageName, ModuleName ) -> Dict String ( PackageName, ModuleName ) pathsOfModules package acc = let modulePaths = List.map (\moduleName -> ( pathToModule moduleName, ( package.metadata.name, moduleName ) )) package.modules |> Dict.fromList pathToModule moduleName = let ( path, fileName ) = readModuleFromDisk package.path moduleName in path ++ "/" ++ fileName in Dict.union acc modulePaths compilingUpdate : Msg -> State -> List ModuleName -> Model compilingUpdate msg state remainingModules = case Debug.log "msg" msg of FileContents path fileName content -> let fullPath = path ++ "/" ++ fileName possibleModuleInfo = Debug.log fullPath (Dict.get fullPath state.filePathToModule) in case ( possibleModuleInfo, Parser.run content ) of ( _, Err parserError ) -> Failed <| InternalError <| "Parser error: " ++ Debug.toString parserError ( Just ( packageName, moduleName ), Ok parserAst ) -> let qualifierResult = Qualifier.run { packageName = PackageName.toString packageName , modulePath = ModuleName.toString moduleName , ast = parserAst , externalModules = Dict.empty } in Failed <| InternalError <| "U" ++ Debug.toString qualifierResult ( Nothing, _ ) -> Failed <| InternalError <| "Don't know why we read file: " ++ fullPath _ -> Failed <| InternalError <| "Unknown message for compile stage: " ++ Debug.toString msg |
Modified tests/Test/PackageLoader.elm from [21e035e507] to [11ea0f2ff1].
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
] } """ ) , ( "/project/src/mod1.play" , """ def: next-version : version/number 1 + """ ) , ( "/project/lib/template_strings/play.json" , """ { "name": "jarvis/template_strings", "version": "1.2.0", |
| |
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
] } """ ) , ( "/project/src/mod1.play" , """ def: next-version : /version/data/number 1 + """ ) , ( "/project/lib/template_strings/play.json" , """ { "name": "jarvis/template_strings", "version": "1.2.0", |