All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.archguard.scanner.analyser.ScalaAnalyser.kt Maven / Gradle / Ivy

Go to download

ArchGuard is a architecture governance tool which can analysis architecture in container, component, code level, create architecture fitness functions, and anaysis system dependencies..

There is a newer version: 2.1.5
Show newest version
package org.archguard.scanner.analyser

import chapi.domain.core.CodeDataStruct
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.runBlocking
import org.archguard.scanner.core.sourcecode.LanguageSourceCodeAnalyser
import org.archguard.scanner.core.sourcecode.SourceCodeContext
import java.io.File

class ScalaAnalyser(override val context: SourceCodeContext) : LanguageSourceCodeAnalyser {
    private val client = context.client
    private val impl = chapi.ast.scalaast.ScalaAnalyser()

    override fun analyse(): List = runBlocking {
        getFilesByPath(context.path) {
            it.absolutePath.endsWith(".scala")
        }
            .map { async { analysisByFile(it) } }.awaitAll()
            .flatten()
            .also { client.saveDataStructure(it) }
    }

    private fun analysisByFile(file: File): List {
        val codeContainer = impl.analysis(file.readContent(), file.name)

        return codeContainer.DataStructures.map {
            it.apply {
                it.Imports = codeContainer.Imports
                it.FilePath = file.absolutePath
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy