diff --git a/als-actions/shared/src/test/scala/org/mulesoft/als/actions/codeactions/BaseCodeActionTests.scala b/als-actions/shared/src/test/scala/org/mulesoft/als/actions/codeactions/BaseCodeActionTests.scala index 84134b490b..2580f693a5 100644 --- a/als-actions/shared/src/test/scala/org/mulesoft/als/actions/codeactions/BaseCodeActionTests.scala +++ b/als-actions/shared/src/test/scala/org/mulesoft/als/actions/codeactions/BaseCodeActionTests.scala @@ -169,7 +169,7 @@ trait BaseCodeActionTests extends AsyncFlatSpec with Matchers with FileAssertion } protected val dummyTelemetryProvider: TelemetryProvider = new TelemetryProvider { - override protected def addTimedMessage( + override def addTimedMessage( code: String, messageType: MessageTypes, msg: String, diff --git a/als-common/shared/src/main/scala/org/mulesoft/als/common/DirectoryResolver.scala b/als-common/shared/src/main/scala/org/mulesoft/als/common/DirectoryResolver.scala index 92e1ef8ccb..f13462dc81 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/als/common/DirectoryResolver.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/als/common/DirectoryResolver.scala @@ -1,11 +1,11 @@ package org.mulesoft.als.common -import amf.core.internal.remote.File +import amf.core.internal.unsafe.PlatformSecrets +import org.mulesoft.als.common.URIImplicits._ import scala.concurrent.Future -trait DirectoryResolver { - val FilePrefix = "file://" +trait DirectoryResolver extends PlatformSecrets { def exists(path: String): Future[Boolean] def readDir(path: String): Future[Seq[String]] @@ -13,6 +13,6 @@ trait DirectoryResolver { def isDirectory(path: String): Future[Boolean] def toPath(uri: String): String = - File.unapply(uri).getOrElse(uri) + uri.toPath(platform) } diff --git a/als-common/shared/src/main/scala/org/mulesoft/als/common/PlatformDirectoryResolver.scala b/als-common/shared/src/main/scala/org/mulesoft/als/common/PlatformDirectoryResolver.scala index 14ae2f6942..90c4097a5f 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/als/common/PlatformDirectoryResolver.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/als/common/PlatformDirectoryResolver.scala @@ -5,14 +5,12 @@ import amf.core.internal.remote.Platform import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Future -class PlatformDirectoryResolver(private val platform: Platform) extends DirectoryResolver { - override def exists(uri: String): Future[Boolean] = platform.fs.asyncFile(FileUtils.getPath(uri, platform)).exists +class PlatformDirectoryResolver(override val platform: Platform) extends DirectoryResolver { + override def exists(uri: String): Future[Boolean] = platform.fs.asyncFile(toPath(uri)).exists override def readDir(uri: String): Future[Seq[String]] = - platform.fs.asyncFile(FileUtils.getPath(uri, platform)).list.map(array => array.toSeq) + platform.fs.asyncFile(toPath(uri)).list.map(array => array.toSeq) override def isDirectory(uri: String): Future[Boolean] = platform.fs.asyncFile(FileUtils.getPath(uri, platform)).isDirectory - - override def toPath(uri: String): String = FileUtils.getPath(uri, platform) } diff --git a/als-common/shared/src/main/scala/org/mulesoft/als/logger/AbstractLogger.scala b/als-common/shared/src/main/scala/org/mulesoft/als/logger/AbstractLogger.scala index 2e2bcf6980..1de3ad80d1 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/als/logger/AbstractLogger.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/als/logger/AbstractLogger.scala @@ -27,7 +27,7 @@ trait AbstractLogger extends Logger { filtered.foreach(logMessage => { val toLog = - f" ${logMessage.severity} ${logMessage.component}:${logMessage.subComponent} ${logMessage.content}" + f"[${logMessage.severity}] - ${logMessage.component}:${logMessage.subComponent} - ${logMessage.content}" this.executeLogging(toLog, logMessage.severity) }) } diff --git a/als-common/shared/src/main/scala/org/mulesoft/als/logger/Logger.scala b/als-common/shared/src/main/scala/org/mulesoft/als/logger/Logger.scala index 027e89b313..68a11cc932 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/als/logger/Logger.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/als/logger/Logger.scala @@ -1,6 +1,8 @@ package org.mulesoft.als.logger import org.mulesoft.als.logger.MessageSeverity.MessageSeverity +import org.mulesoft.lsp.feature.telemetry.MessageTypes.MessageTypes +import org.mulesoft.lsp.feature.telemetry.TelemetryProvider import scala.scalajs.js.annotation.JSExportAll @@ -53,3 +55,48 @@ trait Logger { */ def error(message: String, component: String, subComponent: String): Unit } + +object Logger extends Logger with TelemetryProvider { + + var delegateLogger: Logger = PrintLnLogger + var delegateTelemetryProvider: Option[TelemetryProvider] = None + + def withLogger(logger: Logger): this.type = { + delegateLogger = logger + this + } + def withTelemetry(telemetry: TelemetryProvider): this.type = { + delegateTelemetryProvider = Some(telemetry) + this + } + + override def log(message: String, severity: MessageSeverity, component: String, subComponent: String): Unit = { + delegateLogger.log(message, severity, component, subComponent) + } + + override def debug(message: String, component: String, subComponent: String): Unit = { + delegateLogger.debug(message, component, subComponent) + } + + override def warning(message: String, component: String, subComponent: String): Unit = { + delegateLogger.warning(message, component, subComponent) + } + + override def error(message: String, component: String, subComponent: String): Unit = { + delegateLogger.error(message, component, subComponent) + } + + override def addTimedMessage( + code: String, + messageType: MessageTypes, + msg: String, + uri: String, + uuid: String + ): Unit = { + delegateTelemetryProvider.foreach(_.addTimedMessage(code, messageType, msg, uri, uuid)) + } + + override def addErrorMessage(code: String, msg: String, uri: String, uuid: String): Unit = { + delegateTelemetryProvider.foreach(_.addErrorMessage(code, msg, uri, uuid)) + } +} diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/EditorConfiguration.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/EditorConfiguration.scala index cfb0b7bf07..b2c98c9e8d 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/EditorConfiguration.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/EditorConfiguration.scala @@ -2,14 +2,7 @@ package org.mulesoft.amfintegration.amfconfiguration import amf.aml.client.scala.AMLConfiguration import amf.aml.client.scala.model.document.Dialect -import amf.apicontract.client.scala.{ - AMFConfiguration, - APIConfiguration, - AsyncAPIConfiguration, - OASConfiguration, - RAMLConfiguration -} -import amf.core.client.scala.AMFParseResult +import amf.apicontract.client.scala.{AsyncAPIConfiguration, OASConfiguration, RAMLConfiguration} import amf.core.client.scala.model.document.BaseUnit import amf.core.client.scala.parse.AMFSyntaxParsePlugin import amf.core.client.scala.resource.ResourceLoader @@ -18,7 +11,7 @@ import amf.core.internal.remote.Spec import amf.core.internal.unsafe.PlatformSecrets import amf.graphql.client.scala.GraphQLConfiguration import amf.shapes.client.scala.config.JsonSchemaConfiguration -import org.mulesoft.als.logger.{EmptyLogger, Logger} +import org.mulesoft.als.logger.Logger import org.mulesoft.amfintegration.AmfImplicits.DialectInstanceImp import org.mulesoft.amfintegration.dialect.integration.BaseAlsDialectProvider import org.mulesoft.amfintegration.vocabularies.integration.{ @@ -38,8 +31,7 @@ trait EditorConfigurationProvider { case class EditorConfiguration( resourceLoaders: Seq[ResourceLoader], syntaxPlugins: Seq[AMFSyntaxParsePlugin], - validationPlugin: Seq[AMFShapePayloadValidationPlugin], - logger: Logger + validationPlugin: Seq[AMFShapePayloadValidationPlugin] ) extends EditorConfigurationProvider { // todo: add hot reload val baseConfiguration: AMLConfiguration = AMLConfiguration @@ -116,14 +108,14 @@ case class EditorConfiguration( def withDialect(uri: String): EditorConfiguration = synchronized { dialects = uri +: dialects parsedDialects = parseDialects - logger.debug(s"New editor dialect: $uri", "EditorConfiguration", "indexDialect") + Logger.debug(s"New editor dialect: $uri", "EditorConfiguration", "indexDialect") this } def withProfile(uri: String): EditorConfiguration = synchronized { profiles = uri +: profiles parsedProfiles = parseProfiles - logger.debug(s"New editor validation profile: $uri", "EditorConfiguration", "indexProfile") + Logger.debug(s"New editor validation profile: $uri", "EditorConfiguration", "indexProfile") this } } @@ -154,14 +146,12 @@ object EditorConfigurationState { object EditorConfiguration extends PlatformSecrets { def apply(): EditorConfiguration = withPlatformLoaders(Seq.empty) - def apply(logger: Logger): EditorConfiguration = - EditorConfiguration(platform.loaders(), Seq.empty, Seq.empty, logger) def withPlatformLoaders(rls: Seq[ResourceLoader]): EditorConfiguration = - EditorConfiguration(rls ++ platform.loaders(), Seq.empty, Seq.empty, EmptyLogger) + EditorConfiguration(rls ++ platform.loaders(), Seq.empty, Seq.empty) def withoutPlatformLoaders(rls: Seq[ResourceLoader]): EditorConfiguration = - EditorConfiguration(rls, Seq.empty, Seq.empty, EmptyLogger) + EditorConfiguration(rls, Seq.empty, Seq.empty) } diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/visitors/links/FindLinks.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/visitors/links/FindLinks.scala index f9ce82b229..e9afe1d870 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/visitors/links/FindLinks.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/visitors/links/FindLinks.scala @@ -3,12 +3,11 @@ package org.mulesoft.amfintegration.visitors.links import amf.core.client.scala.model.document.BaseUnit import org.mulesoft.als.common.dtoTypes.PositionRange import org.mulesoft.als.convert.LspRangeConverter -import org.mulesoft.als.logger.{EmptyLogger, Logger} import org.mulesoft.amfintegration.AmfImplicits.AmfAnnotationsImp import org.mulesoft.lsp.feature.link.DocumentLink object FindLinks { - def getLinks(bu: BaseUnit, log: Logger = EmptyLogger): Seq[DocumentLink] = + def getLinks(bu: BaseUnit): Seq[DocumentLink] = bu.annotations .targets() .flatMap { case (targetLocation, originRange) => diff --git a/als-common/shared/src/test/scala/org/mulesoft/als/common/DirectoryResolverTest.scala b/als-common/shared/src/test/scala/org/mulesoft/als/common/DirectoryResolverTest.scala new file mode 100644 index 0000000000..7db5c45cd8 --- /dev/null +++ b/als-common/shared/src/test/scala/org/mulesoft/als/common/DirectoryResolverTest.scala @@ -0,0 +1,31 @@ +package org.mulesoft.als.common + +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers + +import scala.concurrent.Future + +class DirectoryResolverTest extends AnyFlatSpec with Matchers { + + private val dr = new DirectoryResolver { + override def exists(path: String): Future[Boolean] = ??? + + override def readDir(path: String): Future[Seq[String]] = ??? + + override def isDirectory(path: String): Future[Boolean] = ??? + } + + behavior of "Directory Resolver" + + it should "transform simple absolute URI to Path" in { + dr.toPath("file:///my/path") shouldBe "/my/path" + } + + it should "transform simple relative URI to Path" in { + dr.toPath("file://my/path") shouldBe "my/path" + } + + it should "transform URI with spaces to Path" in { + dr.toPath("file:///my/path%20with%20spaces") shouldBe "/my/path with spaces" + } +} diff --git a/als-lsp/shared/src/main/scala/org/mulesoft/lsp/feature/telemetry/TelemetryProvider.scala b/als-lsp/shared/src/main/scala/org/mulesoft/lsp/feature/telemetry/TelemetryProvider.scala index 7116a62d33..ee41fb232b 100644 --- a/als-lsp/shared/src/main/scala/org/mulesoft/lsp/feature/telemetry/TelemetryProvider.scala +++ b/als-lsp/shared/src/main/scala/org/mulesoft/lsp/feature/telemetry/TelemetryProvider.scala @@ -92,11 +92,23 @@ object MessageTypes extends Enumeration { val END_CUSTOM_DIAGNOSTIC = "END_CUSTOM_DIAGNOSTIC" val BEGIN_GET_WORKSPACE_CONFIGURATION = "BEGIN_GET_WORKSPACE_CONFIGURATION" val END_GET_WORKSPACE_CONFIGURATION = "END_GET_WORKSPACE_CONFIGURATION" + val BEGIN_EXCHANGE_CLIENT = "BEGIN_EXCHANGE_CLIENT" + val END_EXCHANGE_CLIENT = "END_EXCHANGE_CLIENT" + val BEGIN_GET_DEPENDENCY_MODEL = "BEGIN_GET_DEPENDENCY_MODEL" + val END_GET_DEPENDENCY_MODEL = "END_GET_DEPENDENCY_MODEL" + val BEGIN_GET_DESCRIPTOR = "BEGIN_GET_DESCRIPTOR" + val END_GET_DESCRIPTOR = "END_GET_DESCRIPTOR" + val BEGIN_SET_DESCRIPTOR = "BEGIN_SET_DESCRIPTOR" + val END_SET_DESCRIPTOR = "END_SET_DESCRIPTOR" + val BEGIN_GET_METADATA = "BEGIN_GET_METADATA" + val END_GET_METADATA = "END_GET_METADATA" + val BEGIN_GET_ASSET = "BEGIN_GET_ASSET" + val END_GET_ASSET = "END_GET_ASSET" } trait TelemetryProvider { - protected def addTimedMessage(code: String, messageType: MessageTypes, msg: String, uri: String, uuid: String): Unit + def addTimedMessage(code: String, messageType: MessageTypes, msg: String, uri: String, uuid: String): Unit def addErrorMessage(code: String, msg: String, uri: String, uuid: String): Unit final def timeProcess[T]( diff --git a/als-node-client/src/main/scala/org/mulesoft/als/nodeclient/Main.scala b/als-node-client/src/main/scala/org/mulesoft/als/nodeclient/Main.scala index e1d2f1ad36..7a63123348 100644 --- a/als-node-client/src/main/scala/org/mulesoft/als/nodeclient/Main.scala +++ b/als-node-client/src/main/scala/org/mulesoft/als/nodeclient/Main.scala @@ -39,7 +39,7 @@ object Main extends PlatformSecrets { val logger = JsPrintLnLogger() - val clientConnection = ClientNotifierFactory.createWithClientAware(logger) + val clientConnection = ClientNotifierFactory.createWithClientAware val serializationProps = JsSerializationProps(clientConnection) val languageServer = new AlsLanguageServerFactory(clientConnection) diff --git a/als-node-client/src/test/scala/org/mulesoft/als/server/modules/diagnostic/NodeJsCustomValidationByDirectoryTest.scala b/als-node-client/src/test/scala/org/mulesoft/als/server/modules/diagnostic/NodeJsCustomValidationByDirectoryTest.scala index e46202d0dd..91314ad770 100644 --- a/als-node-client/src/test/scala/org/mulesoft/als/server/modules/diagnostic/NodeJsCustomValidationByDirectoryTest.scala +++ b/als-node-client/src/test/scala/org/mulesoft/als/server/modules/diagnostic/NodeJsCustomValidationByDirectoryTest.scala @@ -3,6 +3,7 @@ package org.mulesoft.als.server.modules.diagnostic import amf.core.client.scala.AMFGraphConfiguration import amf.custom.validation.client.ProfileValidatorNodeBuilder import org.mulesoft.als.common.ByDirectoryTest +import org.mulesoft.als.logger.Logger import org.mulesoft.als.server.client.scala.LanguageServerBuilder import org.mulesoft.als.server.feature.diagnostic.CustomValidationClientCapabilities import org.mulesoft.als.server.modules.WorkspaceManagerFactoryBuilder @@ -24,7 +25,7 @@ import scala.concurrent.Future class NodeJsCustomValidationByDirectoryTest extends ByDirectoryTest with ChangesWorkspaceConfiguration { def rootPath: String = "custom-validation/byDirectory" - val logger: TestLogger = TestLogger() + Logger.withLogger(TestLogger()) override def fileExtensions: Seq[String] = Seq(".yaml") override def testFile(content: String, file: SyncFile, parent: String): Unit = { @@ -101,7 +102,7 @@ class NodeJsCustomValidationByDirectoryTest extends ByDirectoryTest with Changes } def buildServer(diagnosticNotifier: MockDiagnosticClientNotifier): LanguageServer = { - val builder = new WorkspaceManagerFactoryBuilder(diagnosticNotifier, logger, EditorConfiguration()) + val builder = new WorkspaceManagerFactoryBuilder(diagnosticNotifier, EditorConfiguration()) val dm = builder.buildDiagnosticManagers(Some(ProfileValidatorNodeBuilder)) val factory = builder.buildWorkspaceManagerFactory() val b = new LanguageServerBuilder( diff --git a/als-node-client/src/test/scala/org/mulesoft/als/server/modules/diagnostic/NodeJsCustomValidationTest.scala b/als-node-client/src/test/scala/org/mulesoft/als/server/modules/diagnostic/NodeJsCustomValidationTest.scala index bec8fe96c6..85d989c231 100644 --- a/als-node-client/src/test/scala/org/mulesoft/als/server/modules/diagnostic/NodeJsCustomValidationTest.scala +++ b/als-node-client/src/test/scala/org/mulesoft/als/server/modules/diagnostic/NodeJsCustomValidationTest.scala @@ -27,7 +27,7 @@ class NodeJsCustomValidationTest override def rootPath: String = "custom-validation" def buildServer(diagnosticNotifier: MockDiagnosticClientNotifier): LanguageServer = { - val builder = new WorkspaceManagerFactoryBuilder(diagnosticNotifier, logger, EditorConfiguration()) + val builder = new WorkspaceManagerFactoryBuilder(diagnosticNotifier, EditorConfiguration()) val dm = builder.buildDiagnosticManagers(Some(ProfileValidatorNodeBuilder)) val factory = builder.buildWorkspaceManagerFactory() val b = new LanguageServerBuilder( diff --git a/als-server/js/src/main/scala/org/mulesoft/als/server/ClientNotifierFactory.scala b/als-server/js/src/main/scala/org/mulesoft/als/server/ClientNotifierFactory.scala index 63206773b7..27c5bef6aa 100644 --- a/als-server/js/src/main/scala/org/mulesoft/als/server/ClientNotifierFactory.scala +++ b/als-server/js/src/main/scala/org/mulesoft/als/server/ClientNotifierFactory.scala @@ -10,8 +10,7 @@ import scala.scalajs.js.annotation.{JSExportAll, JSExportTopLevel} @JSExportAll @JSExportTopLevel("ClientNotifierFactory") object ClientNotifierFactory { - def createWithClientAware( - logger: JsClientLogger - ): ClientNotifier with LspLanguageClientAware with AlsClientNotifier[js.Any] with AlsLanguageClientAware[js.Any] = - ClientConnection[js.Any](ClientLoggerAdapter(logger)) + def createWithClientAware + : ClientNotifier with LspLanguageClientAware with AlsClientNotifier[js.Any] with AlsLanguageClientAware[js.Any] = + ClientConnection[js.Any]() } diff --git a/als-server/jvm/src/main/scala/org/mulesoft/als/server/lsp4j/Main.scala b/als-server/jvm/src/main/scala/org/mulesoft/als/server/lsp4j/Main.scala index 48cb7ec4b2..40daf30dde 100644 --- a/als-server/jvm/src/main/scala/org/mulesoft/als/server/lsp4j/Main.scala +++ b/als-server/jvm/src/main/scala/org/mulesoft/als/server/lsp4j/Main.scala @@ -1,7 +1,6 @@ package org.mulesoft.als.server.lsp4j import org.eclipse.lsp4j.jsonrpc.Launcher -import org.eclipse.lsp4j.services.LanguageClient import org.mulesoft.als.logger.{Logger, PrintLnLogger} import org.mulesoft.als.server.JvmSerializationProps import org.mulesoft.als.server.client.{AlsLanguageClientExtensions, AlsLanguageClientWrapper, platform} @@ -57,11 +56,12 @@ object Main { } val logger: Logger = PrintLnLogger - val clientConnection = platform.ClientConnection[StringWriter](logger) + val clientConnection = platform.ClientConnection[StringWriter]() logger.debug("Building LanguageServerImpl", "Main", "main") val server = new LanguageServerImpl( new AlsLanguageServerFactory(clientConnection) + .withLogger(logger) .withSerializationProps(JvmSerializationProps(clientConnection)) .build() ) diff --git a/als-server/jvm/src/test/scala/org/mulesoft/als/server/AMFValidatorTest.scala b/als-server/jvm/src/test/scala/org/mulesoft/als/server/AMFValidatorTest.scala index 202fdae7cc..3eedab586b 100644 --- a/als-server/jvm/src/test/scala/org/mulesoft/als/server/AMFValidatorTest.scala +++ b/als-server/jvm/src/test/scala/org/mulesoft/als/server/AMFValidatorTest.scala @@ -14,7 +14,7 @@ trait AMFValidatorTest extends LanguageServerBaseTest with PlatformSecrets { case class TestValidator(fn: () => Unit) extends AMFShapePayloadValidationPlugin { override def applies(element: ValidatePayloadRequest): Boolean = { fn() - logger.debug(s"Test validator called", "TestValidator", "applies") + logger.debug("Test validator called", "TestValidator", "applies") false } diff --git a/als-server/jvm/src/test/scala/org/mulesoft/als/server/lsp4j/Lsp4jLanguageServerDiagnosticImplTest.scala b/als-server/jvm/src/test/scala/org/mulesoft/als/server/lsp4j/Lsp4jLanguageServerDiagnosticImplTest.scala index fe92533e13..24de13c8f2 100644 --- a/als-server/jvm/src/test/scala/org/mulesoft/als/server/lsp4j/Lsp4jLanguageServerDiagnosticImplTest.scala +++ b/als-server/jvm/src/test/scala/org/mulesoft/als/server/lsp4j/Lsp4jLanguageServerDiagnosticImplTest.scala @@ -147,7 +147,8 @@ class Lsp4jLanguageServerDiagnosticImplTest extends LanguageServerBaseTest with } def buildServer(diagnosticsClient: MockDiagnosticClientNotifier): LanguageServer = { - val builder = new WorkspaceManagerFactoryBuilder(diagnosticsClient, logger) + + val builder = new WorkspaceManagerFactoryBuilder(diagnosticsClient) val dm = builder.buildDiagnosticManagers() val managers = builder.buildWorkspaceManagerFactory() diff --git a/als-server/jvm/src/test/scala/org/mulesoft/als/server/lsp4j/Lsp4jLanguageServerImplTest.scala b/als-server/jvm/src/test/scala/org/mulesoft/als/server/lsp4j/Lsp4jLanguageServerImplTest.scala index abde1eef9f..b359489044 100644 --- a/als-server/jvm/src/test/scala/org/mulesoft/als/server/lsp4j/Lsp4jLanguageServerImplTest.scala +++ b/als-server/jvm/src/test/scala/org/mulesoft/als/server/lsp4j/Lsp4jLanguageServerImplTest.scala @@ -47,7 +47,7 @@ class Lsp4jLanguageServerImplTest extends AMFValidatorTest with ChangesWorkspace val out = new ObjectOutputStream(baos) val logger: Logger = EmptyLogger - val clientConnection = ClientConnection(logger) + val clientConnection = ClientConnection() val notifier: AlsClientNotifier[StringWriter] = new MockAlsClientNotifier val server = new LanguageServerImpl( @@ -67,7 +67,7 @@ class Lsp4jLanguageServerImplTest extends AMFValidatorTest with ChangesWorkspace val out = new ObjectOutputStream(baos) val logger: Logger = EmptyLogger - val clientConnection = ClientConnection(logger) + val clientConnection = ClientConnection() val notifier: AlsClientNotifier[StringWriter] = new MockAlsClientNotifier val server = new LanguageServerImpl( new AlsLanguageServerFactory(clientConnection) @@ -140,14 +140,14 @@ class Lsp4jLanguageServerImplTest extends AMFValidatorTest with ChangesWorkspace class TestDidChangeConfigurationCommandExecutor( wsc: WorkspaceManager, fn: DidChangeConfigurationNotificationParams => Unit - ) extends DidChangeConfigurationCommandExecutor(EmptyLogger, wsc) { + ) extends DidChangeConfigurationCommandExecutor(wsc) { override protected def runCommand(param: DidChangeConfigurationNotificationParams): Future[Unit] = { fn(param) Future.unit } } - class DummyTelemetryProvider extends TelemetryManager(new DummyClientNotifier(), EmptyLogger) + class DummyTelemetryProvider extends TelemetryManager(new DummyClientNotifier()) class DummyClientNotifier extends ClientNotifier { override def notifyDiagnostic(params: PublishDiagnosticsParams): Unit = {} @@ -178,7 +178,6 @@ class Lsp4jLanguageServerImplTest extends AMFValidatorTest with ChangesWorkspace IgnoreProjectConfigurationAdapter, Nil, Nil, - EmptyLogger, buildWorkspaceManager.configurationManager ) { @@ -309,7 +308,7 @@ class Lsp4jLanguageServerImplTest extends AMFValidatorTest with ChangesWorkspace }) } - def buildWorkspaceManager = new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier, logger) + def buildWorkspaceManager = new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier) def buildServer(builder: WorkspaceManagerFactoryBuilder): (LanguageServer, WorkspaceManager) = { diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/LanguageServerImpl.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/LanguageServerImpl.scala index 61c1104604..810da064be 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/LanguageServerImpl.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/LanguageServerImpl.scala @@ -18,8 +18,7 @@ class LanguageServerImpl( val workspaceService: AlsWorkspaceService, protected val configuration: ConfigurationManager, protected val languageServerInitializer: LanguageServerInitializer, - protected val requestHandlerMap: RequestMap, - logger: Logger + protected val requestHandlerMap: RequestMap ) extends LanguageServer { override def initialize(params: AlsInitializeParams): Future[AlsInitializeResult] = { @@ -45,24 +44,24 @@ class LanguageServerImpl( workspaceService .initialize((workspaceFolders :+ WorkspaceFolder(root, None)).toList) .map(_ => { - logger.debug("Server initialized", "LanguageServerImpl", "initialize") + Logger.debug("Server initialized", "LanguageServerImpl", "initialize") p }) } } private def logParams(params: AlsInitializeParams): Unit = { - logger.debug(s"trace: ${params.trace}", "LanguageServerImpl", "logParams") - logger.debug(s"rootUri: ${params.rootUri}", "LanguageServerImpl", "logParams") - logger.debug(s"rootPath: ${params.rootPath}", "LanguageServerImpl", "logParams") - logger.debug(s"workspaceFolders: ${params.workspaceFolders.getOrElse(Seq())}", "LanguageServerImpl", "logParams") - logger.debug( + Logger.debug(s"trace: ${params.trace}", "LanguageServerImpl", "logParams") + Logger.debug(s"rootUri: ${params.rootUri}", "LanguageServerImpl", "logParams") + Logger.debug(s"rootPath: ${params.rootPath}", "LanguageServerImpl", "logParams") + Logger.debug(s"workspaceFolders: ${params.workspaceFolders.getOrElse(Seq())}", "LanguageServerImpl", "logParams") + Logger.debug( s"configuration: ${params.configuration.map(_.toString).getOrElse("")}", "LanguageServerImpl", "logParams" ) - logger.debug(s"capabilities: ${params.capabilities.toString}", "LanguageServerImpl", "logParams") - logger.debug(s"hotReload: ${params.hotReload}", "LanguageServerImpl", "logParams") + Logger.debug(s"capabilities: ${params.capabilities.toString}", "LanguageServerImpl", "logParams") + Logger.debug(s"hotReload: ${params.hotReload}", "LanguageServerImpl", "logParams") } /** if it is not a valid URI and a local file which we and AMF understand (file:), ignore it @@ -73,7 +72,7 @@ class LanguageServerImpl( if (rootUri.isValidFileUri) Some(rootUri) else { - logger.warning(s"Not recognized $rootUri as a valid Root URI", "LanguageServerImpl", "initialize") + Logger.warning(s"Not recognized $rootUri as a valid Root URI", "LanguageServerImpl", "initialize") None } diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/client/platform/ClientConnection.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/client/platform/ClientConnection.scala index 19154e39f6..81953a6f3d 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/client/platform/ClientConnection.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/client/platform/ClientConnection.scala @@ -8,7 +8,7 @@ import org.mulesoft.lsp.client.{LspLanguageClient, LspLanguageClientAware} import org.mulesoft.lsp.feature.diagnostic.PublishDiagnosticsParams import org.mulesoft.lsp.feature.telemetry.TelemetryMessage -case class ClientConnection[S](override protected val logger: Logger) extends AbstractClientConnection[S] +case class ClientConnection[S]() extends AbstractClientConnection[S] trait AbstractClientConnection[S] extends LspLanguageClientAware @@ -16,8 +16,6 @@ trait AbstractClientConnection[S] with ClientNotifier with AlsClientNotifier[S] { - protected val logger: Logger - var clientProxy: Option[LspLanguageClient] = None var alsClientProxy: Option[AlsLanguageClient[S]] = None @@ -35,13 +33,13 @@ trait AbstractClientConnection[S] private def applyToClient(fn: LspLanguageClient => Unit): Unit = if (clientProxy.isEmpty) - logger.warning("Client not connect", "ClientConnection", "applyToClient") + Logger.warning("Client not connect", "ClientConnection", "applyToClient") else fn(clientProxy.get) private def applyToAlsClient(fn: AlsLanguageClient[S] => Unit): Unit = if (alsClientProxy.isEmpty) - logger.warning("Als Client not connect", "ClientConnection", "applyToAlsClient") + Logger.warning("Als Client not connect", "ClientConnection", "applyToAlsClient") else fn(alsClientProxy.get) diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/client/scala/LanguageServerBuilder.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/client/scala/LanguageServerBuilder.scala index 958967a0f2..935398bf04 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/client/scala/LanguageServerBuilder.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/client/scala/LanguageServerBuilder.scala @@ -15,8 +15,7 @@ class LanguageServerBuilder( private val textDocumentSyncConsumer: AlsTextDocumentSyncConsumer, private val workspaceManager: WorkspaceManager, private val configurationManager: ConfigurationManager, - private val resolutionTaskManager: ResolutionTaskManager, - logger: Logger = EmptyLogger + private val resolutionTaskManager: ResolutionTaskManager ) { private val initializableModules = mutable.ListBuffer[InitializableModule[_, _]]() private val requestModules = mutable.ListBuffer[RequestModule[_, _]]() @@ -54,8 +53,7 @@ class LanguageServerBuilder( workspaceManager, configurationManager, new LanguageServerInitializer(configMap, allInitializables), - handlerMap, - logger + handlerMap ) } } diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/client/scala/LanguageServerFactory.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/client/scala/LanguageServerFactory.scala index 9ed505800c..33e0923361 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/client/scala/LanguageServerFactory.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/client/scala/LanguageServerFactory.scala @@ -6,7 +6,7 @@ import amf.core.client.scala.validation.payload.AMFShapePayloadValidationPlugin import amf.custom.validation.client.ProfileValidatorWebBuilder import amf.custom.validation.client.scala.{BaseProfileValidatorBuilder, CustomValidator, ProfileValidatorExecutor} import org.mulesoft.als.common.DirectoryResolver -import org.mulesoft.als.logger.{Logger, PrintLnLogger} +import org.mulesoft.als.logger.Logger import org.mulesoft.als.server.client.platform.ClientNotifier import org.mulesoft.als.server.modules.ast.WorkspaceContentListener import org.mulesoft.als.server.modules.diagnostic.{DiagnosticNotificationsKind, PARSING_BEFORE} @@ -24,7 +24,6 @@ class LanguageServerFactory( profileValidatorBuilder: BaseProfileValidatorBuilder = ProfileValidatorWebBuilder ) { protected var serialization: SerializationProps[_] = new EmptySerializationProps - protected var logger: Logger = PrintLnLogger protected var notificationsKind: DiagnosticNotificationsKind = PARSING_BEFORE protected var directoryResolver: Option[DirectoryResolver] = None protected var rl: Seq[ResourceLoader] = EditorConfiguration.platform.loaders() @@ -55,7 +54,7 @@ class LanguageServerFactory( } def withLogger(logger: Logger): this.type = { - this.logger = logger + Logger.withLogger(logger) this } @@ -102,11 +101,10 @@ class LanguageServerFactory( def build(): LanguageServer = { val resourceLoaders = if (rl.isEmpty) EditorConfiguration.platform.loaders() else rl - val editorConfiguration = new EditorConfiguration(resourceLoaders, Seq.empty, plugins, logger) + val editorConfiguration = new EditorConfiguration(resourceLoaders, Seq.empty, plugins) val factory = new WorkspaceManagerFactoryBuilder( clientNotifier, - logger, editorConfiguration, configurationProvider, textDocumentSyncBuilder @@ -140,8 +138,7 @@ class LanguageServerFactory( builders.documentManager, builders.workspaceManager, builders.configurationManager, - builders.resolutionTaskManager, - logger + builders.resolutionTaskManager ) .addInitializable(builders.workspaceManager) .addInitializable(builders.resolutionTaskManager) diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/ManagersFactory.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/ManagersFactory.scala index d4fce5a5de..93656cda4e 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/ManagersFactory.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/ManagersFactory.scala @@ -4,7 +4,6 @@ import amf.core.internal.unsafe.PlatformSecrets import amf.custom.validation.client.scala.BaseProfileValidatorBuilder import org.mulesoft.als.actions.codeactions.plugins.AllCodeActions import org.mulesoft.als.common.{DirectoryResolver, PlatformDirectoryResolver} -import org.mulesoft.als.logger.Logger import org.mulesoft.als.server.SerializationProps import org.mulesoft.als.server.client.platform.{AlsClientNotifier, ClientNotifier} import org.mulesoft.als.server.modules.actions._ @@ -35,7 +34,6 @@ import scala.collection.mutable.ListBuffer class WorkspaceManagerFactoryBuilder( clientNotifier: ClientNotifier, - logger: Logger, val editorConfiguration: EditorConfiguration = EditorConfiguration(), projectConfigurationProvider: Option[ProjectConfigurationProvider] = None, textDocumentSyncBuilder: Option[TextDocumentSyncBuilder] = None @@ -63,11 +61,11 @@ class WorkspaceManagerFactoryBuilder( ListBuffer() val telemetryManager: TelemetryManager = - new TelemetryManager(clientNotifier, logger) + new TelemetryManager(clientNotifier) def serializationManager[S](sp: SerializationProps[S]): SerializationManager[S] = { val s = - new SerializationManager(telemetryManager, editorConfiguration, configurationManager.getConfiguration, sp, logger) + new SerializationManager(telemetryManager, editorConfiguration, configurationManager.getConfiguration, sp) resolutionDependencies += s s } @@ -77,11 +75,11 @@ class WorkspaceManagerFactoryBuilder( ): Seq[BasicDiagnosticManager[_, _]] = { val gatherer = new ValidationGatherer(telemetryManager) val dm = - new ParseDiagnosticManager(telemetryManager, clientNotifier, logger, gatherer, notificationKind) - val pdm = new ProjectDiagnosticManager(telemetryManager, clientNotifier, logger, gatherer, notificationKind) - val rdm = new ResolutionDiagnosticManager(telemetryManager, clientNotifier, logger, gatherer) + new ParseDiagnosticManager(telemetryManager, clientNotifier, gatherer, notificationKind) + val pdm = new ProjectDiagnosticManager(telemetryManager, clientNotifier, gatherer, notificationKind) + val rdm = new ResolutionDiagnosticManager(telemetryManager, clientNotifier, gatherer) customValidationManager = customValidatorBuilder.map(validator => - new CustomValidationManager(telemetryManager, clientNotifier, logger, gatherer, validator) + new CustomValidationManager(telemetryManager, clientNotifier, gatherer, validator) ) customValidationManager.foreach(resolutionDependencies += _) projectDependencies += pdm @@ -98,14 +96,14 @@ class WorkspaceManagerFactoryBuilder( def profileNotificationConfigurationListener[S](sp: SerializationProps[S]): ProfileChangeListener[S] = { val pnl = - new ProfileChangeListener(sp, configurationManager.getConfiguration, logger) + new ProfileChangeListener(sp, configurationManager.getConfiguration) projectDependencies += pnl pnl } def dialectNotificationListener[S](sp: SerializationProps[S]): DialectChangeListener[S] = { val dcl = - new DialectChangeListener(sp, configurationManager.getConfiguration, logger) + new DialectChangeListener(sp, configurationManager.getConfiguration) projectDependencies += dcl dcl } @@ -119,7 +117,6 @@ class WorkspaceManagerFactoryBuilder( resolutionDependencies.toList, telemetryManager, directoryResolver, - logger, configurationManager, editorConfiguration, customValidationManager, @@ -133,7 +130,6 @@ case class WorkspaceManagerFactory( resolutionDependencies: List[ResolvedUnitListener], telemetryManager: TelemetryManager, directoryResolver: DirectoryResolver, - logger: Logger, configurationManager: ConfigurationManager, editorConfiguration: EditorConfiguration, customValidationManager: Option[CustomValidationManager], @@ -146,14 +142,12 @@ case class WorkspaceManagerFactory( lazy val cleanDiagnosticManager = new CleanDiagnosticTreeManager( telemetryManager, container, - logger, customValidationManager, workspaceConfigurationManager ) val resolutionTaskManager: ResolutionTaskManager = ResolutionTaskManager( telemetryManager, - logger, resolutionDependencies, resolutionDependencies.collect { case t: AccessUnits[AmfResolvedUnit] => t // is this being used? is it correct to mix subscribers with this dependencies? @@ -170,22 +164,20 @@ case class WorkspaceManagerFactory( projectConfigurationProvider.getOrElse( new DefaultProjectConfigurationProvider( container, - editorConfiguration, - logger + editorConfiguration ) ), dependencies, dependencies.collect { case t: AccessUnits[CompilableUnit] => t // is this being used? is it correct to mix subscribers with this dependencies? }, - logger, configurationManager ) lazy val documentManager: AlsTextDocumentSyncConsumer = textDocumentSyncBuilder .getOrElse(DefaultTextDocumentSyncBuilder) - .build(container, List(workspaceManager), logger) + .build(container, List(workspaceManager)) lazy val completionManager = new SuggestionsManager( @@ -193,59 +185,56 @@ case class WorkspaceManagerFactory( workspaceManager, telemetryManager, directoryResolver, - logger, configurationManager ) lazy val structureManager = - new StructureManager(workspaceManager, telemetryManager, logger) + new StructureManager(workspaceManager, telemetryManager) lazy val definitionManager = - new GoToDefinitionManager(workspaceManager, telemetryManager, logger) + new GoToDefinitionManager(workspaceManager, telemetryManager) lazy val implementationManager = - new GoToImplementationManager(workspaceManager, telemetryManager, logger) + new GoToImplementationManager(workspaceManager, telemetryManager) lazy val typeDefinitionManager = - new GoToTypeDefinitionManager(workspaceManager, telemetryManager, logger) + new GoToTypeDefinitionManager(workspaceManager, telemetryManager) lazy val hoverManager = new HoverManager(workspaceManager, telemetryManager) lazy val referenceManager = - new FindReferenceManager(workspaceManager, telemetryManager, logger) + new FindReferenceManager(workspaceManager, telemetryManager) lazy val fileUsageManager = - new FindFileUsageManager(workspaceManager, telemetryManager, logger) + new FindFileUsageManager(workspaceManager, telemetryManager) lazy val documentLinksManager = - new DocumentLinksManager(workspaceManager, telemetryManager, logger) + new DocumentLinksManager(workspaceManager, telemetryManager) lazy val renameManager = new RenameManager( workspaceManager, telemetryManager, - logger, configurationManager.getConfiguration, EditorConfiguration.platform ) lazy val conversionManager = - new ConversionManager(workspaceManager, telemetryManager, logger) + new ConversionManager(workspaceManager, telemetryManager) lazy val documentHighlightManager = - new DocumentHighlightManager(workspaceManager, telemetryManager, logger) + new DocumentHighlightManager(workspaceManager, telemetryManager) lazy val foldingRangeManager = - new FoldingRangeManager(workspaceManager, telemetryManager, logger) + new FoldingRangeManager(workspaceManager, telemetryManager) lazy val selectionRangeManager = - new SelectionRangeManager(workspaceManager, telemetryManager, logger) + new SelectionRangeManager(workspaceManager, telemetryManager) lazy val renameFileActionManager: RenameFileActionManager = new RenameFileActionManager( workspaceManager, telemetryManager, - logger, configurationManager.getConfiguration, EditorConfiguration.platform ) @@ -256,15 +245,14 @@ case class WorkspaceManagerFactory( workspaceManager, configurationManager.getConfiguration, telemetryManager, - logger, directoryResolver ) lazy val documentFormattingManager: DocumentFormattingManager = - new DocumentFormattingManager(workspaceManager, telemetryManager, logger) + new DocumentFormattingManager(workspaceManager, telemetryManager) lazy val documentRangeFormattingManager: DocumentRangeFormattingManager = - new DocumentRangeFormattingManager(workspaceManager, telemetryManager, logger) + new DocumentRangeFormattingManager(workspaceManager, telemetryManager) lazy val serializationManager: Option[SerializationManager[_]] = resolutionDependencies.collectFirst({ case s: SerializationManager[_] => @@ -273,6 +261,6 @@ case class WorkspaceManagerFactory( }) lazy val workspaceConfigurationManager: WorkspaceConfigurationManager = - new WorkspaceConfigurationManager(workspaceManager, telemetryManager, logger) + new WorkspaceConfigurationManager(workspaceManager, telemetryManager) } diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/CodeActionManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/CodeActionManager.scala index 186a0aa132..e747064c15 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/CodeActionManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/CodeActionManager.scala @@ -22,7 +22,6 @@ class CodeActionManager( workspaceManager: WorkspaceManager, configuration: AlsConfigurationReader, telemetryProvider: TelemetryProvider, - private val logger: Logger, directoryResolver: DirectoryResolver ) extends RequestModule[CodeActionCapabilities, CodeActionOptions] { @@ -67,8 +66,8 @@ class CodeActionManager( .map(ca => ca.run(requestParams) .recoverWith { case e: Exception => - logger.debug(s"CodeAction: ${ca.getClass}", "CodeActionManager", "task") - logger.error(s"Error executing CodeAction: ${e.getMessage}", "CodeActionManager", "task") + Logger.debug(s"CodeAction: ${ca.getClass}", "CodeActionManager", "task") + Logger.error(s"Error executing CodeAction: ${e.getMessage}", "CodeActionManager", "task") Future.successful(Seq.empty) } ) @@ -126,9 +125,9 @@ class CodeActionManager( .filter(a => c.codeActionLiteralSupport.forall(_.codeActionKind.valueSet.contains(a.kind))) case None => usedActions = allActions } - logger.debug(s"actions to be used:\n${usedActions.map(_.title).mkString("\n")}", "CodeActionManager", "applyConfig") - logger.debug( - s"supports documentChanges: ${configuration.supportsDocumentChanges}", + Logger.debug(s"Actions to be used: ${usedActions.map(_.title).mkString("\n")}", "CodeActionManager", "applyConfig") + Logger.debug( + s"Supports documentChanges: ${configuration.supportsDocumentChanges}", "CodeActionManager", "applyConfig" ) diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/DocumentFormattingManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/DocumentFormattingManager.scala index 3bb7db5037..eb0d34e5c9 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/DocumentFormattingManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/DocumentFormattingManager.scala @@ -24,8 +24,7 @@ import scala.concurrent.Future class DocumentFormattingManager( val workspace: WorkspaceManager, - private val telemetryProvider: TelemetryProvider, - private val logger: Logger + private val telemetryProvider: TelemetryProvider ) extends RequestModule[DocumentFormattingClientCapabilities, Either[Boolean, WorkDoneProgressOptions]] with FormattingManager { @@ -64,7 +63,7 @@ class DocumentFormattingManager( def onDocumentFormatting(params: DocumentFormattingParams): Future[Seq[TextEdit]] = { val uuid = UUID.randomUUID().toString val isJson = params.textDocument.uri.endsWith(".json") - logger.debug( + Logger.debug( "Document formatting for " + params.textDocument.uri, "DocumentFormattingManager", "onDocumentFormatting" diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/DocumentHighlightManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/DocumentHighlightManager.scala index b2d77838b3..8e75d0c284 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/DocumentHighlightManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/DocumentHighlightManager.scala @@ -3,7 +3,6 @@ package org.mulesoft.als.server.modules.actions import org.mulesoft.als.actions.references.FindReferences import org.mulesoft.als.common.dtoTypes.Position import org.mulesoft.als.server.RequestModule -import org.mulesoft.als.logger.Logger import org.mulesoft.als.server.workspace.WorkspaceManager import org.mulesoft.lsp.ConfigType import org.mulesoft.lsp.feature.TelemeteredRequestHandler @@ -17,8 +16,7 @@ import scala.concurrent.Future class DocumentHighlightManager( val workspace: WorkspaceManager, - private val telemetryProvider: TelemetryProvider, - private val logger: Logger + private val telemetryProvider: TelemetryProvider ) extends RequestModule[DocumentHighlightCapabilities, Boolean] { override val `type`: ConfigType[DocumentHighlightCapabilities, Boolean] = diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/DocumentLinksManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/DocumentLinksManager.scala index ef93293443..69ae539805 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/DocumentLinksManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/DocumentLinksManager.scala @@ -13,8 +13,7 @@ import scala.concurrent.Future class DocumentLinksManager( val workspaceManager: UnitWorkspaceManager, - private val telemetryProvider: TelemetryProvider, - private val logger: Logger + private val telemetryProvider: TelemetryProvider ) extends RequestModule[DocumentLinkClientCapabilities, DocumentLinkOptions] { override val `type`: ConfigType[DocumentLinkClientCapabilities, DocumentLinkOptions] = diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/DocumentRangeFormattingManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/DocumentRangeFormattingManager.scala index a7e62aaa11..d784ef258a 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/DocumentRangeFormattingManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/DocumentRangeFormattingManager.scala @@ -29,8 +29,7 @@ import scala.concurrent.Future class DocumentRangeFormattingManager( val workspace: WorkspaceManager, - private val telemetryProvider: TelemetryProvider, - private val logger: Logger + private val telemetryProvider: TelemetryProvider ) extends RequestModule[DocumentRangeFormattingClientCapabilities, Either[Boolean, WorkDoneProgressOptions]] with FormattingManager { @@ -69,7 +68,7 @@ class DocumentRangeFormattingManager( def onDocumentRangeFormatting(params: DocumentRangeFormattingParams): Future[Seq[TextEdit]] = { val uuid = UUID.randomUUID().toString val isJson = params.textDocument.uri.endsWith(".json") - logger.debug( + Logger.debug( "Document formatting for " + params.textDocument.uri + " range: " + params.range, "DocumentRangeFormattingManager", "onDocumentRangeFormatting" diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/FindReferenceManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/FindReferenceManager.scala index d9dd93af79..d3eda90065 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/FindReferenceManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/FindReferenceManager.scala @@ -23,8 +23,7 @@ import scala.concurrent.Future class FindReferenceManager( val workspace: WorkspaceManager, - private val telemetryProvider: TelemetryProvider, - private val logger: Logger + private val telemetryProvider: TelemetryProvider ) extends RequestModule[ReferenceClientCapabilities, Either[Boolean, WorkDoneProgressOptions]] { private var conf: Option[ReferenceClientCapabilities] = None diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/FoldingRangeManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/FoldingRangeManager.scala index afcef5c687..f0d084aab2 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/FoldingRangeManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/FoldingRangeManager.scala @@ -16,8 +16,7 @@ import scala.concurrent.Future class FoldingRangeManager( val workspace: WorkspaceManager, - private val telemetryProvider: TelemetryProvider, - private val logger: Logger + private val telemetryProvider: TelemetryProvider ) extends RequestModule[FoldingRangeCapabilities, Boolean] { private var active = false diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/GoToDefinitionManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/GoToDefinitionManager.scala index b5f7fe896b..a4e0f2996e 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/GoToDefinitionManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/GoToDefinitionManager.scala @@ -24,8 +24,7 @@ import scala.concurrent.Future class GoToDefinitionManager( val workspace: WorkspaceManager, - private val telemetryProvider: TelemetryProvider, - private val logger: Logger + private val telemetryProvider: TelemetryProvider ) extends RequestModule[DefinitionClientCapabilities, Either[Boolean, WorkDoneProgressOptions]] { private var conf: Option[DefinitionClientCapabilities] = None diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/GoToImplementationManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/GoToImplementationManager.scala index c13a58970f..a6a8b5a1ab 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/GoToImplementationManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/GoToImplementationManager.scala @@ -25,8 +25,7 @@ import scala.concurrent.Future class GoToImplementationManager( val workspace: WorkspaceManager, - private val telemetryProvider: TelemetryProvider, - private val logger: Logger + private val telemetryProvider: TelemetryProvider ) extends RequestModule[ImplementationClientCapabilities, Either[Boolean, WorkDoneProgressOptions]] { private var conf: Option[ImplementationClientCapabilities] = None diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/GoToTypeDefinitionManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/GoToTypeDefinitionManager.scala index 1f8d93498c..0cd0e03fee 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/GoToTypeDefinitionManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/GoToTypeDefinitionManager.scala @@ -25,8 +25,7 @@ import scala.concurrent.Future class GoToTypeDefinitionManager( val workspace: WorkspaceManager, - private val telemetryProvider: TelemetryProvider, - private val logger: Logger + private val telemetryProvider: TelemetryProvider ) extends RequestModule[TypeDefinitionClientCapabilities, Either[Boolean, WorkDoneProgressOptions]] { private var conf: Option[TypeDefinitionClientCapabilities] = None diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/RenameFileActionManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/RenameFileActionManager.scala index 175df23325..f0e2331e58 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/RenameFileActionManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/RenameFileActionManager.scala @@ -3,9 +3,9 @@ package org.mulesoft.als.server.modules.actions import amf.core.internal.remote.Platform import org.mulesoft.als.actions.renamefile.RenameFileAction import org.mulesoft.als.configuration.AlsConfigurationReader +import org.mulesoft.als.logger.Logger import org.mulesoft.als.server.RequestModule import org.mulesoft.als.server.feature.renamefile._ -import org.mulesoft.als.logger.Logger import org.mulesoft.als.server.workspace.WorkspaceManager import org.mulesoft.lsp.ConfigType import org.mulesoft.lsp.feature.common.TextDocumentIdentifier @@ -20,7 +20,6 @@ import scala.concurrent.Future class RenameFileActionManager( val workspace: WorkspaceManager, private val telemetryProvider: TelemetryProvider, - private val logger: Logger, private val configReader: AlsConfigurationReader, private val platform: Platform ) extends RequestModule[RenameFileActionClientCapabilities, RenameFileActionOptions] { @@ -69,10 +68,10 @@ class RenameFileActionManager( for { links <- workspace.getAllDocumentLinks(oldDocument.uri, uuid) } yield { - logger.debug("got the following document links", "RenameFileActionManager", "rename") + Logger.debug("Got the following document links", "RenameFileActionManager", "rename") links.toSeq.foreach { tuple => tuple._2.map(_.target).foreach { target => - logger.debug(s"${tuple._1} - $target", "RenameFileActionManager", "rename") + Logger.debug(s"${tuple._1} - $target", "RenameFileActionManager", "rename") } } diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/SelectionRangeManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/SelectionRangeManager.scala index 57120133a3..c5b55e2617 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/SelectionRangeManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/SelectionRangeManager.scala @@ -18,8 +18,7 @@ import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Future class SelectionRangeManager( val workspace: WorkspaceManager, - private val telemetryProvider: TelemetryProvider, - private val logger: Logger + private val telemetryProvider: TelemetryProvider ) extends RequestModule[SelectionRangeCapabilities, Either[Boolean, WorkDoneProgressOptions]] { override val `type`: ConfigType[SelectionRangeCapabilities, Either[Boolean, WorkDoneProgressOptions]] = diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/fileusage/FindFileUsageManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/fileusage/FindFileUsageManager.scala index 3708ae98bf..5962196658 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/fileusage/FindFileUsageManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/fileusage/FindFileUsageManager.scala @@ -13,8 +13,7 @@ import scala.concurrent.Future class FindFileUsageManager( val workspace: WorkspaceManager, - private val telemetryProvider: TelemetryProvider, - private val logger: Logger + private val telemetryProvider: TelemetryProvider ) extends RequestModule[FileUsageClientCapabilities, FileUsageOptions] { private var enabled: Boolean = true diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/rename/RenameHandler.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/rename/RenameHandler.scala index 5174d92251..dd522e2544 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/rename/RenameHandler.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/rename/RenameHandler.scala @@ -23,7 +23,6 @@ class RenameHandler( telemetryProvider: TelemetryProvider, workspace: WorkspaceManager, configurationReader: AlsConfigurationReader, - logger: Logger, platform: Platform ) extends TelemeteredRequestHandler[RenameParams, WorkspaceEdit] with RenameTools { @@ -104,9 +103,9 @@ class RenameHandler( links <- workspaceManager.getDocumentLinks(uri, uuid) allLinks <- workspaceManager.getAllDocumentLinks(uri, uuid) } yield { - logger.debug("got the following document links", "RenameFileActionManager", "rename") + Logger.debug("Got the following document links", "RenameFileActionManager", "rename") links.foreach { l => - logger.debug(s"${l.target}", "RenameFileActionManager", "rename") + Logger.debug(s"-> link: ${l.target}", "RenameFileActionManager", "rename") } links .find(l => PositionRange(l.range).contains(position)) diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/rename/RenameManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/rename/RenameManager.scala index af04c1c16b..5cce3ba443 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/rename/RenameManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/actions/rename/RenameManager.scala @@ -15,7 +15,6 @@ import scala.concurrent.Future class RenameManager( val workspace: WorkspaceManager, private val telemetryProvider: TelemetryProvider, - private val logger: Logger, private val configurationReader: AlsConfigurationReader, private val platform: Platform ) extends RequestModule[RenameClientCapabilities, RenameOptions] { @@ -26,7 +25,7 @@ class RenameManager( RenameConfigType override val getRequestHandlers: Seq[TelemeteredRequestHandler[_, _]] = Seq( - new RenameHandler(telemetryProvider, workspace, configurationReader, logger, platform), + new RenameHandler(telemetryProvider, workspace, configurationReader, platform), new PrepareRenameHandler(telemetryProvider, workspace) ) diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/ast/ResolvedUnitListener.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/ast/ResolvedUnitListener.scala index eff30c7880..3b0bba70a2 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/ast/ResolvedUnitListener.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/ast/ResolvedUnitListener.scala @@ -11,7 +11,6 @@ import scala.util.{Failure, Success} trait ResolvedUnitListener extends AstListener[AmfResolvedUnit] with AccessUnits[AmfResolvedUnit] { type RunType <: Runnable[Unit] - protected val logger: Logger protected def runnable(ast: AmfResolvedUnit, uuid: String): RunType diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/completion/SuggestionsManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/completion/SuggestionsManager.scala index 52f8c80e22..b3ffdc1aba 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/completion/SuggestionsManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/completion/SuggestionsManager.scala @@ -26,7 +26,6 @@ class SuggestionsManager( val workspace: WorkspaceManager, private val telemetryProvider: TelemetryProvider, val directoryResolver: DirectoryResolver, - private val logger: Logger, private val configurationProvider: ConfigurationProvider ) extends RequestModule[CompletionClientCapabilities, CompletionOptions] { @@ -91,7 +90,7 @@ class SuggestionsManager( position: Position, telemetryUUID: String ): Future[Seq[CompletionItem]] = { - logger.debug( + Logger.debug( s"Disable Templates: ${configurationProvider.getConfiguration.getTemplateType}", "SuggestionsManager", "onDocumentCompletion" diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/configuration/WorkspaceConfigurationManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/configuration/WorkspaceConfigurationManager.scala index a3c04e4dc7..57edd82bcb 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/configuration/WorkspaceConfigurationManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/configuration/WorkspaceConfigurationManager.scala @@ -19,8 +19,7 @@ import scala.concurrent.Future class WorkspaceConfigurationManager( val workspaceManager: WorkspaceManager, - private val telemetryProvider: TelemetryProvider, - private val logger: Logger + private val telemetryProvider: TelemetryProvider ) extends RequestModule[WorkspaceConfigurationClientCapabilities, WorkspaceConfigurationOptions] with WorkspaceConfigurationProvider { diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/CleanDiagnosticTreeManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/CleanDiagnosticTreeManager.scala index a4a3a5982b..3292dd1b6f 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/CleanDiagnosticTreeManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/CleanDiagnosticTreeManager.scala @@ -27,7 +27,6 @@ import scala.concurrent.Future class CleanDiagnosticTreeManager( telemetryProvider: TelemetryProvider, environmentProvider: EnvironmentProvider, - logger: Logger, customValidationManager: Option[CustomValidationManager], workspaceConfigProvider: WorkspaceConfigurationProvider ) extends RequestModule[CleanDiagnosticTreeClientCapabilities, CleanDiagnosticTreeOptions] { @@ -89,7 +88,7 @@ class CleanDiagnosticTreeManager( .map(t => (t._1, t._2.map(new AlsValidationResult(_)))) val merged = list.map(uri => uri -> (ge.getOrElse(uri, Nil) ++ grouped.getOrElse(uri, Nil))).toMap - logger.debug(s"Report conforms: ${report.conforms}", "CleanDiagnosticTreeManager", "validate") + Logger.debug(s"Report conforms: ${report.conforms}", "CleanDiagnosticTreeManager", "validate") DiagnosticConverters.buildIssueResults(merged, Map.empty, profile).map(_.publishDiagnosticsParams) @@ -107,7 +106,7 @@ class CleanDiagnosticTreeManager( .map(new AmfResultWrap(_)) helper <- Future(alsConfigurationState.configForUnit(pr.result.baseUnit)) resolved <- Future({ - logger.debug(s"About to report: $refinedUri", "CleanDiagnosticTreeManager", "validate") + Logger.debug(s"About to report: $refinedUri", "CleanDiagnosticTreeManager", "validate") helper.fullResolution(pr.result.baseUnit) }) result <- helper.report(resolved.baseUnit).map(r => CleanValidationPartialResult(pr, r, resolved)) diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/DiagnosticConverters.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/DiagnosticConverters.scala index 595035692b..553c2aeb1c 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/DiagnosticConverters.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/DiagnosticConverters.scala @@ -11,8 +11,8 @@ import org.mulesoft.lsp.feature.common.{Location, Range} import org.mulesoft.lsp.feature.diagnostic.DiagnosticRelatedInformation import org.mulesoft.lsp.feature.link.DocumentLink +import scala.collection.mutable import scala.collection.mutable.ListBuffer -import scala.collection.{AbstractSeq, LinearSeq, SeqProxy, SeqViewLike, immutable, mutable} object DiagnosticConverters { diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/DiagnosticManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/DiagnosticManager.scala index 240467da4d..07634d064d 100755 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/DiagnosticManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/DiagnosticManager.scala @@ -38,7 +38,7 @@ trait BasicDiagnosticManager[C, S] extends ClientNotifierModule[C, S] { protected val telemetryProvider: TelemetryProvider protected val optimizationKind: DiagnosticNotificationsKind = ALL_TOGETHER protected val notifyParsing: Boolean = optimizationKind == PARSING_BEFORE - protected val logger: Logger + override def initialize(): Future[Unit] = Future.successful() protected def profileName(baseUnit: BaseUnit): ProfileName = @@ -57,7 +57,7 @@ trait BasicDiagnosticManager[C, S] extends ClientNotifierModule[C, S] { ): Future[AMFValidationReport] = { val msg = s"DiagnosticManager suffered an unexpected error while validating: $e" - logger.warning(msg, "DiagnosticManager", "report") + Logger.warning(msg, "DiagnosticManager", "report") Future.successful(failedReportDiagnostic(msg, baseUnit)) } @@ -87,8 +87,8 @@ trait BasicDiagnosticManager[C, S] extends ClientNotifierModule[C, S] { baseUnit +: baseUnit.flatRefs ).map(bu => bu.identifier -> bu.isInstanceOf[ExternalFragment]).toMap ) - logger.debug( - s"Number of ${step.name} errors is:\n" + errors.flatMap(_.issues).length, + Logger.debug( + s"Number of ${step.name} errors is: $errors.flatMap(_.issues).length", "ValidationManager", "newASTAvailable" ) diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/ParseDiagnosticManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/ParseDiagnosticManager.scala index 5f9b24ed8b..71806f6807 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/ParseDiagnosticManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/ParseDiagnosticManager.scala @@ -4,8 +4,8 @@ import amf.core.client.common.validation.{ProfileName, ProfileNames} import org.mulesoft.als.logger.Logger import org.mulesoft.als.server.client.platform.ClientNotifier import org.mulesoft.als.server.modules.ast._ -import org.mulesoft.lsp.feature.link.DocumentLink import org.mulesoft.amfintegration.amfconfiguration.AmfParseResult +import org.mulesoft.lsp.feature.link.DocumentLink import org.mulesoft.lsp.feature.telemetry.{MessageTypes, TelemetryProvider} import scala.concurrent.ExecutionContext.Implicits.global @@ -14,7 +14,6 @@ import scala.concurrent.Future class ParseDiagnosticManager( override protected val telemetryProvider: TelemetryProvider, override protected val clientNotifier: ClientNotifier, - override protected val logger: Logger, override protected val validationGatherer: ValidationGatherer, override protected val optimizationKind: DiagnosticNotificationsKind ) extends BaseUnitListener @@ -36,7 +35,7 @@ class ParseDiagnosticManager( else Map.empty) ++ params.locationLinks - logger.debug("Got new AST:\n" + parsedResult.result.baseUnit.id, "ParseDiagnosticManager", "newASTAvailable") + Logger.debug(s"Got new AST: ${parsedResult.result.baseUnit.id}", "ParseDiagnosticManager", "newASTAvailable") val uri = parsedResult.location telemetryProvider.timeProcess( "Start report", @@ -56,7 +55,7 @@ class ParseDiagnosticManager( uri: String )() = gatherValidationErrors(parsedResult, references, uuid) recoverWith { case exception: Exception => - logger.error("Error on validation: " + exception.toString, "ParseDiagnosticManager", "newASTAvailable") + Logger.error("Error on validation: " + exception.getMessage, "ParseDiagnosticManager", "newASTAvailable") Future { clientNotifier.notifyDiagnostic(ValidationReport(uri, Set.empty, ProfileNames.AMF).publishDiagnosticsParams) } diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/ProjectDiagnosticManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/ProjectDiagnosticManager.scala index 20d53daaee..4a4d5ae731 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/ProjectDiagnosticManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/ProjectDiagnosticManager.scala @@ -16,7 +16,6 @@ import scala.concurrent.Future class ProjectDiagnosticManager( override protected val telemetryProvider: TelemetryProvider, override protected val clientNotifier: ClientNotifier, - override protected val logger: Logger, override protected val validationGatherer: ValidationGatherer, override protected val optimizationKind: DiagnosticNotificationsKind ) extends NewConfigurationListener diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/ResolutionDiagnosticManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/ResolutionDiagnosticManager.scala index fc59e9e831..faedaeb66c 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/ResolutionDiagnosticManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/ResolutionDiagnosticManager.scala @@ -19,27 +19,26 @@ import scala.util.{Failure, Success} class ResolutionDiagnosticManager( override protected val telemetryProvider: TelemetryProvider, override protected val clientNotifier: ClientNotifier, - override protected val logger: Logger, override protected val validationGatherer: ValidationGatherer ) extends ResolvedUnitListener with DiagnosticManager { type RunType = ValidationRunnable override val managerName: DiagnosticManagerKind = ResolutionDiagnosticKind protected override def runnable(ast: AmfResolvedUnit, uuid: String): ValidationRunnable = { - logger.debug(s"Add runnable ${ast.baseUnit.identifier}", "ResolutionDiagnosticManager", "runnable") + Logger.debug(s"Add runnable ${ast.baseUnit.identifier}", "ResolutionDiagnosticManager", "runnable") new ValidationRunnable(ast.baseUnit.identifier, ast, uuid) } protected override def onNewAstPreprocess(resolved: AmfResolvedUnit, uuid: String): Unit = - logger.debug("Got new AST:\n" + resolved.baseUnit.id, "ResolutionDiagnosticManager", "newASTAvailable") + Logger.debug("Got new AST: " + resolved.baseUnit.id, "ResolutionDiagnosticManager", "newASTAvailable") protected override def onFailure(uuid: String, uri: String, exception: Throwable): Unit = { - logger.error(s"Error on validation: ${exception.toString}", "ResolutionDiagnosticManager", "newASTAvailable") + Logger.error(s"Error on validation: ${exception.getMessage}", "ResolutionDiagnosticManager", "newASTAvailable") clientNotifier.notifyDiagnostic(ValidationReport(uri, Set.empty, ProfileNames.AMF).publishDiagnosticsParams) } protected override def onSuccess(uuid: String, uri: String): Unit = - logger.debug(s"End report: $uuid", "ResolutionDiagnosticManager", "newASTAvailable") + Logger.debug(s"End report: $uuid", "ResolutionDiagnosticManager", "newASTAvailable") private def gatherValidationErrors( uri: String, @@ -62,7 +61,7 @@ class ResolutionDiagnosticManager( ) notifyReport(uri, resolved.baseUnit, refs, managerName, profile) - this.logger.debug( + Logger.debug( s"It took ${endTime - startTime} milliseconds to validate", "ResolutionDiagnosticManager", "gatherValidationErrors" @@ -102,24 +101,24 @@ class ResolutionDiagnosticManager( profile: ProfileName )() = try { - logger.debug("starting", "ResolutionDiagnosticManager", "tryValidationReport") + Logger.debug("Starting...", "ResolutionDiagnosticManager", "tryValidationReport") resolved.getLast.flatMap { r => r.resolvedUnit .flatMap { result => r.configuration .report(result.baseUnit) .map(rep => { - logger.debug("finishing", "ResolutionDiagnosticManager", "tryValidationReport") + Logger.debug("...finishing.", "ResolutionDiagnosticManager", "tryValidationReport") AMFValidationReport(rep.model, rep.profile, rep.results ++ result.results) }) } } recoverWith { case e: Exception => - logger.debug(s"recovering from: ${e.getMessage}", "ResolutionDiagnosticManager", "tryValidationReport") + Logger.debug(s"Recovering from: ${e.getMessage}", "ResolutionDiagnosticManager", "tryValidationReport") sendFailedClone(uri, telemetryProvider, resolved.baseUnit, uuid, e.getMessage) } } catch { case e: Exception => - logger.debug(s"failed with: ${e.getMessage}", "ResolutionDiagnosticManager", "tryValidationReport") + Logger.debug(s"Failed with: ${e.getMessage}", "ResolutionDiagnosticManager", "tryValidationReport") sendFailedClone(uri, telemetryProvider, resolved.baseUnit, uuid, e.getMessage) } @@ -136,7 +135,7 @@ class ResolutionDiagnosticManager( def run(): Promise[Unit] = { val promise = Promise[Unit]() - logger.debug("Running", "ResolutionDiagnosticManager", "run") + Logger.debug("Running", "ResolutionDiagnosticManager", "run") def innerRunGather(): Future[Unit] = gatherValidationErrors(ast.baseUnit.identifier, ast, ast.documentLinks, uuid) andThen { diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/custom/CustomValidationManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/custom/CustomValidationManager.scala index cb19e8ea81..c95070bdcd 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/custom/CustomValidationManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/custom/CustomValidationManager.scala @@ -17,8 +17,8 @@ import org.mulesoft.als.server.modules.ast.ResolvedUnitListener import org.mulesoft.als.server.modules.common.reconciler.Runnable import org.mulesoft.als.server.modules.diagnostic._ import org.mulesoft.amfintegration.AmfImplicits.BaseUnitImp -import org.mulesoft.amfintegration.amfconfiguration.AMLSpecificConfiguration import org.mulesoft.amfintegration.AmfResolvedUnit +import org.mulesoft.amfintegration.amfconfiguration.AMLSpecificConfiguration import org.mulesoft.lsp.ConfigType import org.mulesoft.lsp.feature.link.DocumentLink import org.mulesoft.lsp.feature.telemetry.{MessageTypes, TelemetryProvider} @@ -30,7 +30,6 @@ import scala.util.{Failure, Success} class CustomValidationManager( override protected val telemetryProvider: TelemetryProvider, override protected val clientNotifier: ClientNotifier, - override protected val logger: Logger, override protected val validationGatherer: ValidationGatherer, val validatorBuilder: BaseProfileValidatorBuilder ) extends BasicDiagnosticManager[CustomValidationClientCapabilities, CustomValidationOptions] @@ -46,7 +45,7 @@ class CustomValidationManager( override def applyConfig(config: Option[CustomValidationClientCapabilities]): CustomValidationOptions = { enabled = config.exists(_.enabled) - logger.debug(s"Custom validation manager enabled? $enabled", "CustomValidationManager", "applyConfig") + Logger.debug(s"Custom validation manager enabled? $enabled", "CustomValidationManager", "applyConfig") CustomValidationOptions(enabled) } @@ -71,7 +70,7 @@ class CustomValidationManager( .indexNewReport(ErrorsWithTree(uri, results, Some(tree(resolved.baseUnit))), managerName, uuid) notifyReport(uri, resolved.baseUnit, references, managerName, ProfileName("CustomValidation")) val endTime = System.currentTimeMillis() - this.logger.debug( + Logger.debug( s"It took ${endTime - startTime} milliseconds to validate with Go env", "CustomValidationManager", "gatherValidationErrors" @@ -98,7 +97,7 @@ class CustomValidationManager( for { serialized <- serializeUnit(unit, config) result <- { - logger.debug("about to get results", "CustomValidationManager", "validate") + Logger.debug("About to get results", "CustomValidationManager", "validate") Future .sequence(getResults(uri, profiles, serialized)) .map(_.flatten) @@ -108,7 +107,7 @@ class CustomValidationManager( private def getResults(uri: String, profiles: Seq[DialectInstance], serialized: String) = profiles .map(profile => { - logger.debug(s"Validate with profile: ${profile.identifier}", "CustomValidationManager", "validateWithProfile") + Logger.debug(s"Validate with profile: ${profile.identifier}", "CustomValidationManager", "validateWithProfile") validateWithProfile(profile, uri, serialized) }) @@ -137,7 +136,7 @@ class CustomValidationManager( }) }) .recoverWith { case e => - logger.error(e.getMessage, "CustomValidationManager", "validateWithProfile") + Logger.error(e.getMessage, "CustomValidationManager", "validateWithProfile") throw e } @@ -184,13 +183,13 @@ class CustomValidationManager( new CustomValidationRunnable(ast.baseUnit.identifier, ast, uuid) protected override def onFailure(uuid: String, uri: String, exception: Throwable): Unit = { - logger.error(s"Error on validation: ${exception.toString}", "CustomValidationManager", "newASTAvailable") + Logger.error(s"Error on validation: ${exception.getMessage}", "CustomValidationManager", "newASTAvailable") exception.printStackTrace() clientNotifier.notifyDiagnostic(ValidationReport(uri, Set.empty, ProfileNames.AMF).publishDiagnosticsParams) } protected override def onSuccess(uuid: String, uri: String): Unit = - logger.debug(s"End report: $uuid", "CustomValidationRunnable", "newASTAvailable") + Logger.debug(s"End report: $uuid", "CustomValidationRunnable", "newASTAvailable") /** Meant just for logging * @@ -198,8 +197,8 @@ class CustomValidationManager( * @param uuid */ override protected def onNewAstPreprocess(resolved: AmfResolvedUnit, uuid: String): Unit = - logger.debug( - "Running custom validations on:\n" + resolved.baseUnit.id, + Logger.debug( + "Running custom validations on: " + resolved.baseUnit.id, "CustomValidationManager", "newASTAvailable" ) diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/project/DialectChangeListener.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/project/DialectChangeListener.scala index eeb23bc227..5c15761b13 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/project/DialectChangeListener.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/project/DialectChangeListener.scala @@ -14,9 +14,8 @@ import scala.concurrent.Future class DialectChangeListener[S]( props: SerializationProps[S], - configurationReader: AlsConfigurationReader, - logger: Logger -) extends BaseSerializationNotifier[S](props, configurationReader, logger) + configurationReader: AlsConfigurationReader +) extends BaseSerializationNotifier[S](props, configurationReader) with NewConfigurationListener { override val `type`: SerializationConfigType.type = SerializationConfigType diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/project/ProfileChangeListener.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/project/ProfileChangeListener.scala index 0df91abe74..bbfa31130c 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/project/ProfileChangeListener.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/project/ProfileChangeListener.scala @@ -14,9 +14,8 @@ import scala.concurrent.Future class ProfileChangeListener[S]( props: SerializationProps[S], - configurationReader: AlsConfigurationReader, - logger: Logger -) extends BaseSerializationNotifier[S](props, configurationReader, logger) + configurationReader: AlsConfigurationReader +) extends BaseSerializationNotifier[S](props, configurationReader) with NewConfigurationListener { override val `type`: SerializationConfigType.type = SerializationConfigType diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/serialization/BaseSerializationNotifier.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/serialization/BaseSerializationNotifier.scala index 58a0e113a7..822fcbf432 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/serialization/BaseSerializationNotifier.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/serialization/BaseSerializationNotifier.scala @@ -15,8 +15,7 @@ import org.mulesoft.amfintegration.amfconfiguration.AMLSpecificConfiguration abstract class BaseSerializationNotifier[S]( props: SerializationProps[S], - configurationReader: AlsConfigurationReader, - logger: Logger + configurationReader: AlsConfigurationReader ) extends ClientNotifierModule[SerializationClientCapabilities, SerializationServerOptions] { protected def enabled: Boolean = BaseSerializationNotifierState.enabled @@ -32,7 +31,7 @@ abstract class BaseSerializationNotifier[S]( override def applyConfig(config: Option[SerializationClientCapabilities]): SerializationServerOptions = { config.foreach(c => BaseSerializationNotifierState.enabled = c.acceptsNotification) - logger.debug(s"Serialization manager enabled: $enabled", "SerializationManager", "applyConfig") + Logger.debug(s"Serialization manager enabled: $enabled", "SerializationManager", "applyConfig") SerializationServerOptions(true) } } diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/serialization/ConversionManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/serialization/ConversionManager.scala index 2b65520853..a95182acb9 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/serialization/ConversionManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/serialization/ConversionManager.scala @@ -17,8 +17,7 @@ import scala.concurrent.Future class ConversionManager( unitAccessor: UnitAccessor[CompilableUnit], - telemetryProvider: TelemetryProvider, - logger: Logger + telemetryProvider: TelemetryProvider ) extends RequestModule[ConversionClientCapabilities, ConversionRequestOptions] { private var enabled = false @@ -28,7 +27,7 @@ class ConversionManager( override def `type`: ConversionRequestType.type = ConversionRequestType override def task(params: ConversionParams): Future[SerializedDocument] = { - if (!enabled) logger.warning("Request conversion with manager disabled", "ConversionManager", "convert") + if (!enabled) Logger.warning("Request conversion with manager disabled", "ConversionManager", "convert") onSerializationRequest(params.uri, params.target, params.syntax) } diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/serialization/SerializationManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/serialization/SerializationManager.scala index dd57dba9e1..01559aadd8 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/serialization/SerializationManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/serialization/SerializationManager.scala @@ -25,9 +25,8 @@ class SerializationManager[S]( telemetryProvider: TelemetryProvider, editorConfiguration: EditorConfiguration, configurationReader: AlsConfigurationReader, - props: SerializationProps[S], - override val logger: Logger -) extends BaseSerializationNotifier[S](props, configurationReader, logger) + props: SerializationProps[S] +) extends BaseSerializationNotifier[S](props, configurationReader) with ResolvedUnitListener with RequestModule[SerializationClientCapabilities, SerializationServerOptions] { type RunType = SerializationRunnable @@ -58,18 +57,18 @@ class SerializationManager[S]( case Some(ua) => ua.getLastUnit(uri, UUID.randomUUID().toString) .flatMap { r => - logger.debug(s"Serialization uri: $uri", "SerializationManager", "processRequest") + Logger.debug(s"Serialization uri: $uri", "SerializationManager", "processRequest") if (r.baseUnit.isInstanceOf[Extension] || r.baseUnit.isInstanceOf[Overlay]) r.latestBU.map(bu => (bu, r.configuration.config)) else r.latestBU.map(bu => (getUnitFromResolved(bu, uri), r.configuration.config)) } .recoverWith { case e: Exception => - logger.warning(e.getMessage, "SerializationManager", "RequestSerialization") + Logger.warning(e.getMessage, "SerializationManager", "RequestSerialization") Future.successful((Document().withId("error"), AMLConfiguration.predefined())) } case _ => - logger.warning("Unit accessor not configured", "SerializationManager", "RequestSerialization") + Logger.warning("Unit accessor not configured", "SerializationManager", "RequestSerialization") Future.successful((Document().withId("error"), AMLConfiguration.predefined())) } result.map(r => serialize(r._1, r._2)) @@ -102,13 +101,13 @@ class SerializationManager[S]( ) override protected def onSuccess(uuid: String, uri: String): Unit = - logger.debug(s"Scheduled success $uuid", "SerializationManager", "onSuccess") + Logger.debug(s"Scheduled success $uuid", "SerializationManager", "onSuccess") override protected def onFailure(uuid: String, uri: String, t: Throwable): Unit = - logger.warning(s"${t.getMessage} - uuid: $uuid", "SerializationManager", "onFailure") + Logger.warning(s"${t.getMessage} - uuid: $uuid", "SerializationManager", "onFailure") override protected def onNewAstPreprocess(resolved: AmfResolvedUnit, uuid: String): Unit = - logger.debug(s"onNewAst serialization manager $uuid", "SerializationManager", "onNewAstPreprocess") + Logger.debug(s"onNewAst serialization manager $uuid", "SerializationManager", "onNewAstPreprocess") class SerializationRunnable(var uri: String, ast: AmfResolvedUnit, uuid: String) extends Runnable[Unit] { private var canceled = false diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/structure/StructureManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/structure/StructureManager.scala index b4c83801a4..323468b6bb 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/structure/StructureManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/structure/StructureManager.scala @@ -19,8 +19,7 @@ import scala.concurrent.Future class StructureManager( val unitAccesor: UnitAccessor[CompilableUnit], - private val telemetryProvider: TelemetryProvider, - private val logger: Logger + private val telemetryProvider: TelemetryProvider ) extends RequestModule[DocumentSymbolClientCapabilities, Either[Boolean, WorkDoneProgressOptions]] { override val `type`: ConfigType[DocumentSymbolClientCapabilities, Either[Boolean, WorkDoneProgressOptions]] = @@ -77,7 +76,7 @@ class StructureManager( .flatMap(_.getLast) .map(cu => { val r = getStructureFromAST(cu, telemetryUUID) // todo: if isn't resolved yet map future - logger + Logger .debug(s"Got result for url $uri of size ${r.size}", "StructureManager", "onDocumentStructure") r }) diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/telemetry/TelemetryManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/telemetry/TelemetryManager.scala index d97a27c0f1..ebf54dc0fe 100755 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/telemetry/TelemetryManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/telemetry/TelemetryManager.scala @@ -14,7 +14,7 @@ import org.mulesoft.lsp.feature.telemetry.{ import scala.concurrent.Future -class TelemetryManager(private val clientNotifier: ClientNotifier, private val logger: Logger) +class TelemetryManager(private val clientNotifier: ClientNotifier) extends ClientNotifierModule[TelemetryClientCapabilities, Unit] with TelemetryProvider { @@ -27,7 +27,7 @@ class TelemetryManager(private val clientNotifier: ClientNotifier, private val l override def initialize(): Future[Unit] = Future.successful() - override protected def addTimedMessage( + override def addTimedMessage( code: String, messageType: MessageTypes, msg: String, diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/DefaultProjectConfigurationProvider.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/DefaultProjectConfigurationProvider.scala index 9fae4e3959..d9d06a7d0b 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/DefaultProjectConfigurationProvider.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/DefaultProjectConfigurationProvider.scala @@ -44,8 +44,7 @@ sealed class ConfigurationMap { class DefaultProjectConfigurationProvider( environmentProvider: EnvironmentProvider, - editorConfiguration: EditorConfigurationProvider, - logger: Logger + editorConfiguration: EditorConfigurationProvider ) extends ProjectConfigurationProvider { val configurationMap = new ConfigurationMap @@ -78,8 +77,7 @@ class DefaultProjectConfigurationProvider( projectConfiguration, environmentProvider, Seq.empty, // todo: add projects errors such as "file.yaml" is not a profile - editorConfiguration, - logger + editorConfiguration ) } configurationMap.update(c, projectConfiguration) @@ -113,12 +111,12 @@ class DefaultProjectConfigurationProvider( .map(e => { if (e.isValidUri) e // full URI received else { - logger.warning(s"Invalid dialect uri: $e", "DefaultProjectConfigurationProvider", "parseDialects") + Logger.warning(s"Invalid dialect uri: $e", "DefaultProjectConfigurationProvider", "parseDialects") e } }) newDialects.foreach(e => - logger + Logger .debug(s"Parsing & registering $e as dialect", "DefaultProjectConfigurationProvider", "registerNewDialects") ) Future @@ -131,7 +129,7 @@ class DefaultProjectConfigurationProvider( case d: Dialect => Some((d, r)) case b => - logger.error( + Logger.error( s"The following dialect: ${b.identifier} is not valid", "DefaultProjectConfigurationProvider", "registerNewDialects" @@ -157,7 +155,7 @@ class DefaultProjectConfigurationProvider( // updateUnit(uuid, r, isDependency = true) //todo: cache r._1.dialectInstance match { case instance: DialectInstance => - logger.debug( + Logger.debug( "Adding validation profile: " + instance.identifier, "DefaultProjectConfigurationProvider", "registerNewValidationProfiles" @@ -166,7 +164,7 @@ class DefaultProjectConfigurationProvider( case _ => None } } else { - logger.error( + Logger.error( s"The following validation profile: ${r._1.baseUnit.identifier} is not valid", "DefaultProjectConfigurationProvider", "registerNewValidationProfiles" @@ -195,12 +193,11 @@ case class DefaultProjectConfiguration( override val config: ProjectConfiguration, private val environmentProvider: EnvironmentProvider, override val projectErrors: Seq[AMFValidationResult], - private val editorConfiguration: EditorConfigurationProvider, - private val logger: Logger + private val editorConfiguration: EditorConfigurationProvider ) extends ProjectConfigurationState { val cacheBuilder: CacheBuilder = - new CacheBuilder(config.folder, config.designDependency, environmentProvider, editorConfiguration, logger) + new CacheBuilder(config.folder, config.designDependency, environmentProvider, editorConfiguration) override def cache: UnitCache = cacheBuilder.buildUnitCache override val resourceLoaders: Seq[ResourceLoader] = Nil @@ -210,8 +207,7 @@ class CacheBuilder( folder: String, cacheables: Set[String], private val environmentProvider: EnvironmentProvider, - private val editorConfiguration: EditorConfigurationProvider, - logger: Logger + private val editorConfiguration: EditorConfigurationProvider ) { private val cache: mutable.Map[String, BaseUnit] = mutable.Map.empty @@ -263,10 +259,10 @@ class CacheBuilder( .report(resolved.baseUnit) .map { r => if (r.conforms) { - logger.debug(s"Caching ${bu.identifier}", "CacheBuilder", "cache") + Logger.debug(s"Caching ${bu.identifier}", "CacheBuilder", "cache") cache.put(bu.identifier, resolved.baseUnit) } else { - logger.debug(s"Skipping ${bu.identifier} from cache as it does not conform", "CacheBuilder", "cache") + Logger.debug(s"Skipping ${bu.identifier} from cache as it does not conform", "CacheBuilder", "cache") } Unit } @@ -274,8 +270,8 @@ class CacheBuilder( }) eventualUnit .recoverWith { case e: Throwable => // ignore - logger.error( - s"Error while resolving cachable unit: ${bu.identifier}. Message ${e.getMessage} at $folder", + Logger.error( + s"Error while resolving cacheable unit: ${bu.identifier}. Message ${e.getMessage} at $folder", "CacheBuilder", "Cache unit" ) diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/MainFileTreeBuilder.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/MainFileTreeBuilder.scala index 5cbb172e1d..0285f02b01 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/MainFileTreeBuilder.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/MainFileTreeBuilder.scala @@ -81,10 +81,9 @@ object ParsedMainFileTree { object MainFileTreeBuilder { def build( amfParseResult: AmfParseResult, - visitors: AmfElementVisitors, - logger: Logger + visitors: AmfElementVisitors ): Future[ParsedMainFileTree] = Future { - handleVisit(visitors, logger, amfParseResult.result.baseUnit, amfParseResult.context) + handleVisit(visitors, amfParseResult.result.baseUnit, amfParseResult.context) val tree = ParsedMainFileTree( amfParseResult.result, visitors.getRelationshipsFromVisitors, @@ -99,7 +98,6 @@ object MainFileTreeBuilder { private def handleVisit( visitors: AmfElementVisitors, - logger: Logger, unit: BaseUnit, context: AmfParseContext ): Unit = { @@ -107,7 +105,7 @@ object MainFileTreeBuilder { visitors.applyAmfVisitors(unit, context) } catch { case e: Throwable => - logger.error(e.getMessage, "MainFileTreeBuilder", "Handle Visitors") + Logger.error(s"Exception: ${e.getMessage}", "MainFileTreeBuilder", "Handle Visitors") } } } diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/ProjectConfigurationAdapter.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/ProjectConfigurationAdapter.scala index 51c15cc855..56b5062f7b 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/ProjectConfigurationAdapter.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/ProjectConfigurationAdapter.scala @@ -16,8 +16,7 @@ class ProjectConfigurationAdapter( private val projectConfigurationProvider: ProjectConfigurationProvider, editorConfiguration: EditorConfiguration, val environmentProvider: EnvironmentProvider, - subscribers: List[BaseUnitListener], - logger: Logger + subscribers: List[BaseUnitListener] ) { var repository: Option[WorkspaceParserRepository] = None @@ -56,7 +55,7 @@ class ProjectConfigurationAdapter( .map(_.config) def newProjectConfiguration(projectConfiguration: ProjectConfiguration): Future[ProjectConfigurationState] = { - logger.debug( + Logger.debug( s"New configuration for $folder: $projectConfiguration", "ProjectConfigurationAdapter", "newProjectConfiguration" @@ -70,7 +69,7 @@ class ProjectConfigurationAdapter( for { s <- getConfigurationState } yield { - logger.debug( + Logger.debug( "Notifying subscribers of dependencies parsing results", "ProjectConfigurationAdapter", "notifyUnits" diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/StagingArea.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/StagingArea.scala index ac410e2747..c10dba4ead 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/StagingArea.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/StagingArea.scala @@ -35,18 +35,17 @@ trait StagingArea[Parameter] extends SyncFunction { class ResolverStagingArea extends StagingArea[BaseUnitListenerParams] -class ParserStagingArea(environmentProvider: EnvironmentProvider, logger: Logger) - extends StagingArea[NotificationKind] { +class ParserStagingArea(environmentProvider: EnvironmentProvider) extends StagingArea[NotificationKind] { override def enqueue(file: String, kind: NotificationKind): Unit = sync(() => { - logger.debug(s"enqueueing [${kind.kind} - $file]", "ParserStagingArea", "enqueue") + Logger.debug(s"enqueueing [${kind.kind} - $file]", "ParserStagingArea", "enqueue") pending.get(file) match { case Some(CHANGE_FILE) if kind == OPEN_FILE => - logger.warning(s"file opened without closing $file", "ParserStagingArea", "enqueue") + Logger.warning(s"file opened without closing $file", "ParserStagingArea", "enqueue") super.enqueue(file, kind) case Some(CLOSE_FILE) if kind == CHANGE_FILE => - logger.warning(s"file changed after closing $file", "ParserStagingArea", "enqueue") + Logger.warning(s"file changed after closing $file", "ParserStagingArea", "enqueue") super.enqueue(file, kind) case Some(CLOSE_FILE) if kind == OPEN_FILE => super.enqueue(file, CHANGE_FILE) diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/TaskManagerState.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/TaskManagerState.scala index 970adb6a72..18c709e218 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/TaskManagerState.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/TaskManagerState.scala @@ -1,6 +1,8 @@ package org.mulesoft.als.server.modules.workspace -sealed abstract class TaskManagerState(val state: String) +sealed abstract class TaskManagerState(val state: String) { + override def toString: String = state +} object Idle extends TaskManagerState("IDLE") object ProcessingProject extends TaskManagerState("PROCESSING_PROJECT") diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/WorkspaceContentManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/WorkspaceContentManager.scala index 0db8b903c7..077ac7b3e5 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/WorkspaceContentManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/WorkspaceContentManager.scala @@ -23,7 +23,6 @@ class WorkspaceContentManager private ( val folderUri: String, environmentProvider: EnvironmentProvider, val telemetryProvider: TelemetryProvider, - logger: Logger, subscribers: () => List[WorkspaceContentListener[_]], override val repository: WorkspaceParserRepository, val projectConfigAdapter: ProjectConfigurationAdapter, @@ -46,7 +45,7 @@ class WorkspaceContentManager private ( super .init() .map(_ => - logger.debug(s"Finished initialization for workspace at '$folderUri'", "WorkspaceContentManager", "init") + Logger.debug(s"Finished initialization for workspace at '$folderUri'", "WorkspaceContentManager", "init") ) }) @@ -93,7 +92,7 @@ class WorkspaceContentManager private ( private def trailSlash(f: String): String = if (f.endsWith("/")) f else s"$f/" - override protected val stagingArea: ParserStagingArea = new ParserStagingArea(environmentProvider, logger) + override protected val stagingArea: ParserStagingArea = new ParserStagingArea(environmentProvider) override protected def toResult(uri: String, pu: ParsedUnit): CompilableUnit = pu.toCU( @@ -126,8 +125,8 @@ class WorkspaceContentManager private ( val (treeUnits, isolated) = snapshot.files.partition(u => u._2 == CHANGE_CONFIG || isInMainTree(u._1.toAmfUri) ) // what if a new file is added between the partition and the override down - treeUnits.map(_._1).foreach(tu => logger.debug(s"Tree unit: $tu", "WorkspaceContentManager", "processTask")) - isolated.map(_._1).foreach(iu => logger.debug(s"Isolated unit: $iu", "WorkspaceContentManager", "processTask")) + treeUnits.map(_._1).foreach(tu => Logger.debug(s"Tree unit: $tu", "WorkspaceContentManager", "processTask")) + isolated.map(_._1).foreach(iu => Logger.debug(s"Isolated unit: $iu", "WorkspaceContentManager", "processTask")) val future: Future[Future[Unit]] = for { mf <- mainFile currentConfigurationState <- projectConfigAdapter.getConfigurationState @@ -141,11 +140,11 @@ class WorkspaceContentManager private ( tu._2 == CLOSE_FILE || (tu._2 == FOCUS_FILE && shouldParseOnFocus(tu._1, mf, currentConfigurationState)) ) - logger.debug(s"units for main file: ${mf.getOrElse("[no main file]")}", "WorkspaceContentManager", "processTask") + Logger.debug(s"units for main file: ${mf.getOrElse("[no main file]")}", "WorkspaceContentManager", "processTask") if (hasChangedConfigFile(snapshot)) processChangeConfigChanges(snapshot) else if (changedTreeUnits.nonEmpty) processMFChanges(mf.get, snapshot).recoverWith { case e: Exception => - logger.error(s"Error on parse: ${e.getMessage}", "WorkspaceContentManager", "processMFChanges") + Logger.error(s"Error on parse: ${e.getMessage}", "WorkspaceContentManager", "processMFChanges") Future.unit } else @@ -181,13 +180,13 @@ class WorkspaceContentManager private ( private def updateUnit(uuid: String, result: AmfParseResult, isDependency: Boolean): Future[Unit] = { repository.updateUnit(result) projectConfigAdapter.getConfigurationState.map(state => { - logger.debug(s"sending new AST from $folderUri", "WorkspaceContentManager", "processIsolated") + Logger.debug(s"Sending new AST from $folderUri", "WorkspaceContentManager", "processIsolated") baseUnitSubscribers.foreach(s => try { s.onNewAst(BaseUnitListenerParams(result, Map.empty, tree = false, folderUri, isDependency), uuid) } catch { case e: Exception => - logger.error(s"subscriber $s threw ${e.getMessage}", "processIsolated", "WorkspaceContentManager") + Logger.error(s"Subscriber $s threw ${e.getMessage}", "processIsolated", "WorkspaceContentManager") } ) }) @@ -254,7 +253,7 @@ class WorkspaceContentManager private ( private def processChangeConfigChanges(snapshot: Snapshot): Future[Unit] = { changeState(ProcessingProject) - logger.debug(s"Processing Config Changes", "WorkspaceContentManager", "processChangeConfigChanges") + Logger.debug(s"Processing Config Changes", "WorkspaceContentManager", "processChangeConfigChanges") stagingArea.enqueue(snapshot.files.filterNot(t => t._2 == CHANGE_CONFIG)) (for { c <- projectConfigAdapter.getConfigurationState @@ -270,6 +269,11 @@ class WorkspaceContentManager private ( snapshot: Snapshot, mainFileUri: Option[String] ): Future[Unit] = { + Logger.debug( + s"\'MainFileUri\' received is: ${mainFileUri.getOrElse("Empty")}", + "WorkspaceContentManager", + "processChangeConfig" + ) val uuid = UUID.randomUUID().toString configSubscribers.foreach(_.onNewAst(config, uuid)) (mainFileUri match { @@ -294,7 +298,7 @@ class WorkspaceContentManager private ( else None }) .foreach(uri => { - logger.debug( + Logger.debug( s"Enqueuing isolated file ($uri) because of changes on validation profiles", "WorkspaceContentManager", "processNewValidationProfiles" @@ -309,7 +313,11 @@ class WorkspaceContentManager private ( uuid: String = UUID.randomUUID().toString ): Future[Unit] = { changeState(ProcessingProject) - logger.debug(s"Processing Tree changes", "WorkspaceContentManager", "processMFChanges") + Logger.debug( + s"Processing Tree changes with new \'mainFile\': $mainFile", + "WorkspaceContentManager", + "processMFChanges" + ) for { u <- parse( s"${if (folderUri != "" && !mainFile.contains(folderUri)) @@ -321,7 +329,7 @@ class WorkspaceContentManager private ( } yield { stagingArea.enqueue(snapshot.files.filterNot(_._2 == CHANGE_CONFIG).filter(t => !isInMainTree(t._1))) baseUnitSubscribers.foreach(s => { - logger.debug( + Logger.debug( s"Sending new AST from ${u.result.baseUnit.location().getOrElse(folderUri)}", "WorkspaceContentManager", "processMFChanges" @@ -345,7 +353,7 @@ class WorkspaceContentManager private ( private def innerParse(uri: String)(): Future[AmfParseResult] = { val decodedUri = uri.toAmfDecodedUri - logger.debug(s"sent uri: $decodedUri", "WorkspaceContentManager", "innerParse") + Logger.debug(s"Sent uri: $decodedUri", "WorkspaceContentManager", "innerParse") (for { state <- projectConfigAdapter.getConfigurationState r <- state.parse(decodedUri) @@ -362,10 +370,10 @@ class WorkspaceContentManager private ( } yield { r.result.baseUnit match { case _: Dialect if hotReload => - logger.debug(s"Hot registering as dialect uri: $decodedUri", "WorkspaceContentManager", "innerParse") + Logger.debug(s"Hot registering as dialect uri: $decodedUri", "WorkspaceContentManager", "innerParse") withConfiguration(newConfig).map(_ => r) case _ => - logger.debug(s"done with uri: $decodedUri", "WorkspaceContentManager", "innerParse") + Logger.debug(s"Done with uri: $decodedUri", "WorkspaceContentManager", "innerParse") Future(r) } }).flatten @@ -375,14 +383,14 @@ class WorkspaceContentManager private ( getUnit(uri) .flatMap(_.getLast) .map(u => { - logger.debug(s"getting relationships for ${u.uri}", "WorkspaceContentManager", "getRelationships") + Logger.debug(s"Getting relationships for ${u.uri}", "WorkspaceContentManager", "getRelationships") Relationships(repository, u) }) override protected def log(msg: String, isError: Boolean = false): Unit = if (isError) - logger.error(msg, "WorkspaceContentManager", "Processing request") - else logger.debug(msg, "WorkspaceContentManager", "Processing request") + Logger.error(msg, "WorkspaceContentManager", "Processing request") + else Logger.debug(msg, "WorkspaceContentManager", "Processing request") override protected def disableTasks(): Future[Unit] = Future { baseUnitSubscribers.map(d => repository.getAllFilesUris.map(_.toAmfUri).foreach(d.onRemoveFile)) @@ -394,17 +402,15 @@ object WorkspaceContentManager { folderUri: String, environmentProvider: EnvironmentProvider, telemetryProvider: TelemetryProvider, - logger: Logger, subscribers: () => List[WorkspaceContentListener[_]], projectConfigAdapter: ProjectConfigurationAdapter, hotReload: Boolean = false ): Future[WorkspaceContentManager] = { - val repository = new WorkspaceParserRepository(logger) + val repository = new WorkspaceParserRepository() val wcm = new WorkspaceContentManager( folderUri, environmentProvider, telemetryProvider, - logger, subscribers, repository, projectConfigAdapter.withRepository(repository), diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/WorkspaceParserRepository.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/WorkspaceParserRepository.scala index 216f59e45f..9d6e444c33 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/WorkspaceParserRepository.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/WorkspaceParserRepository.scala @@ -11,7 +11,7 @@ import org.mulesoft.lsp.feature.link.DocumentLink import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Future -class WorkspaceParserRepository(logger: Logger) extends Repository[ParsedUnit] { +class WorkspaceParserRepository() extends Repository[ParsedUnit] { private def visitors(bu: BaseUnit) = AmfElementDefaultVisitors.build(bu) @@ -40,18 +40,23 @@ class WorkspaceParserRepository(logger: Logger) extends Repository[ParsedUnit] { def treeUnits(): Iterable[ParsedUnit] = tree.parsedUnits.values def updateUnit(result: AmfParseResult): Unit = { - logger.debug(s"updating ${result.result.baseUnit.location()}", "WorkspaceParserRepository", "updateUnit") + Logger.debug(s"Updating ${result.result.baseUnit.location()}", "WorkspaceParserRepository", "updateUnit") if (tree.contains(result.result.baseUnit.identifier)) throw new Exception("Cannot update an unit from the tree") val unit = ParsedUnit(result, inTree = false, result.definedBy) updateUnit(result.result.baseUnit.identifier, unit) } - def cleanTree(): Unit = tree = EmptyFileTree + def cleanTree(): Unit = tree = { + Logger.debug("Start cleaning Tree...", "WorkspaceParserRepository", "cleanTree") + val emptyFileTree = EmptyFileTree + Logger.debug("... cleaning Tree Finish", "WorkspaceParserRepository", "cleanTree") + emptyFileTree + } def newTree(result: AmfParseResult): Future[MainFileTree] = synchronized { cleanTree() MainFileTreeBuilder - .build(result, visitors(result.result.baseUnit), logger) + .build(result, visitors(result.result.baseUnit)) .map { nt => tree = nt nt.parsedUnits.keys.foreach { removeUnit } diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/resolution/ResolutionTaskManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/resolution/ResolutionTaskManager.scala index 469b1b4c61..162eb34550 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/resolution/ResolutionTaskManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/workspace/resolution/ResolutionTaskManager.scala @@ -19,7 +19,6 @@ import scala.util.Failure class ResolutionTaskManager private ( telemetryProvider: TelemetryProvider, - logger: Logger, private val allSubscribers: List[ResolvedUnitListener], override val dependencies: List[AccessUnits[AmfResolvedUnit]] ) extends UnitTaskManager[AmfResolvedUnit, AmfResolvedUnit, BaseUnitListenerParams] @@ -37,8 +36,8 @@ class ResolutionTaskManager private ( override protected def log(msg: String, isError: Boolean = false): Unit = if (isError) - logger.error(msg, "ResolutionTaskManager", "Processing request") - else logger.debug(msg, "ResolutionTaskManager", "Processing request") + Logger.error(msg, "ResolutionTaskManager", "Processing request") + else Logger.debug(msg, "ResolutionTaskManager", "Processing request") override protected def disableTasks(): Future[Unit] = Future.unit @@ -56,14 +55,14 @@ class ResolutionTaskManager private ( isInMainTree(uri).map { isMainTree => if (isMainTree) { params.parseResult.tree.foreach { u => - logger.debug(s"Replacing $u with unit resolved from $uri", "ResolutionTaskManager", "processTask") + Logger.debug(s"Replacing $u with unit resolved from $uri", "ResolutionTaskManager", "processTask") repository .updateUnit(u, resolvedInstance) // every dependency should be updated } } addProfileIfNotPresent(params.parseResult.context.state) addDialectIfNotPresent(params.parseResult.context.state) - logger.debug(s"Updating $uri unit", "ResolutionTaskManager", "processTask") + Logger.debug(s"Updating $uri unit", "ResolutionTaskManager", "processTask") repository.updateUnit(uri, resolvedInstance) // prevents notifying diagnostics on dependencies if (!params.isDependency) subscribers.foreach(_.onNewAst(resolvedInstance, uuid)) @@ -114,8 +113,8 @@ class ResolutionTaskManager private ( getUnit(uri, uuid).flatMap(_.getLast) ) // double check after resolved that last is still ua's last? .andThen { case Failure(value) => - logger.error( - Option(value).flatMap(v => Option(v.getMessage)).getOrElse(s"error while getting unit $uri"), + Logger.error( + Option(value).flatMap(v => Option(v.getMessage)).getOrElse(s"Error while getting unit $uri"), "ResolutionTaskManager", "getLastUnit" ) @@ -125,9 +124,9 @@ class ResolutionTaskManager private ( } override def onNewAst(ast: BaseUnitListenerParams, uuid: String): Future[Unit] = synchronized { - logger.debug(s"Got new AST: ${ast.parseResult.result.baseUnit.identifier}", "ResolutionTaskManager", "onNewAst") - logger.debug(s"state: $state", "ResolutionTaskManager", "onNewAst") - logger.debug(s"pending: ${stagingArea.hasPending}", "ResolutionTaskManager", "onNewAst") + Logger.debug(s"Got new AST: ${ast.parseResult.result.baseUnit.identifier}", "ResolutionTaskManager", "onNewAst") + Logger.debug(s"state: ${state.toString}", "ResolutionTaskManager", "onNewAst") + Logger.debug(s"pending: ${stagingArea.hasPending}", "ResolutionTaskManager", "onNewAst") stage(ast.parseResult.location, ast) } @@ -186,12 +185,11 @@ class ResolutionTaskManager private ( object ResolutionTaskManager { def apply( telemetryProvider: TelemetryProvider, - logger: Logger, allSubscribers: List[ResolvedUnitListener], dependencies: List[AccessUnits[AmfResolvedUnit]] ): ResolutionTaskManager = { val manager = - new ResolutionTaskManager(telemetryProvider, logger, allSubscribers, dependencies) + new ResolutionTaskManager(telemetryProvider, allSubscribers, dependencies) manager.init() manager } diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/textsync/TextDocumentManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/textsync/TextDocumentManager.scala index ad5b1155d3..82071b7021 100755 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/textsync/TextDocumentManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/textsync/TextDocumentManager.scala @@ -14,8 +14,7 @@ import scala.language.experimental.macros class TextDocumentManager( override val uriToEditor: TextDocumentContainer, - val dependencies: List[TextListener], - protected val logger: Logger + val dependencies: List[TextListener] ) extends AlsTextDocumentSyncConsumer { implicit private val platform: Platform = this.uriToEditor.platform @@ -26,7 +25,7 @@ class TextDocumentManager( override def applyConfig( config: Option[SynchronizationClientCapabilities] ): Either[TextDocumentSyncKind, TextDocumentSyncOptions] = { - logger.debug("Config applied", "TextDocumentManager", "applyConfig") + Logger.debug("Config applied", "TextDocumentManager", "applyConfig") Right( TextDocumentSyncOptions( @@ -41,7 +40,7 @@ class TextDocumentManager( def onOpenDocument(document: OpenedDocument): Future[Unit] = { - logger.debug(s"Document is opened ${document.uri}", "EditorManager", "onOpenDocument") + Logger.debug(s"Document is opened ${document.uri}", "EditorManager", "onOpenDocument") val syntax = determineSyntax(document.uri, document.text) @@ -51,7 +50,7 @@ class TextDocumentManager( } def documentWasChanged(document: ChangedDocument): Future[Unit] = { - logger.debug(s"Document is changed ${document.uri}", "EditorManager", "onChangeDocument") + Logger.debug(s"Document is changed ${document.uri}", "EditorManager", "onChangeDocument") uriToEditor .get(document.uri) @@ -60,14 +59,14 @@ class TextDocumentManager( val currentText = current.text if (currentVersion == document.version) - this.logger.debug( + Logger.debug( s"Version of the reported change is equal to the previous one at ${document.uri}", "EditorManager", "onChangeDocument" ) if (document.version < currentVersion && document.text.contains(currentText)) - this.logger.debug(s"No changes detected for ${document.uri}", "EditorManager", "onChangeDocument") + Logger.debug(s"No changes detected for ${document.uri}", "EditorManager", "onChangeDocument") }) @@ -79,7 +78,7 @@ class TextDocumentManager( } def onCloseDocument(uri: String): Future[Unit] = { - logger.debug(s"Document closed $uri", "EditorManager", "onCloseDocument") + Logger.debug(s"Document closed $uri", "EditorManager", "onCloseDocument") uriToEditor.remove(uri) Future.sequence(this.dependencies.map(_.notify(uri, CLOSE_FILE))).flatMap(_ => Future.unit) } @@ -90,7 +89,7 @@ class TextDocumentManager( override def didOpen(params: DidOpenTextDocumentParams): Future[Unit] = { val uri = params.textDocument.uri if (!uri.isValidFileUri) - logger.warning(s"Adding invalid URI file to manager: $uri", "TextDocumentManager", "didOpen") + Logger.warning(s"Adding invalid URI file to manager: $uri", "TextDocumentManager", "didOpen") onOpenDocument(OpenedDocument(uri.toAmfUri, params.textDocument.version, params.textDocument.text)) } @@ -100,7 +99,7 @@ class TextDocumentManager( val text = params.contentChanges.headOption.map(_.text) val uri = document.uri if (!uri.isValidFileUri) - logger.warning(s"Editing invalid URI file to manager: $uri", "TextDocumentManager", "didChange") + Logger.warning(s"Editing invalid URI file to manager: $uri", "TextDocumentManager", "didChange") documentWasChanged(ChangedDocument(uri.toAmfUri, version, text, None)) } @@ -108,7 +107,7 @@ class TextDocumentManager( override def didClose(params: DidCloseTextDocumentParams): Future[Unit] = { val uri = params.textDocument.uri if (!uri.isValidFileUri) - logger.warning(s"Removing invalid URI file to manager: $uri", "TextDocumentManager", "didClose") + Logger.warning(s"Removing invalid URI file to manager: $uri", "TextDocumentManager", "didClose") onCloseDocument(uri.toAmfUri) } diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/textsync/TextDocumentSyncBuilder.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/textsync/TextDocumentSyncBuilder.scala index 260f1a202a..b52816e954 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/textsync/TextDocumentSyncBuilder.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/textsync/TextDocumentSyncBuilder.scala @@ -7,16 +7,14 @@ import org.mulesoft.als.server.protocol.textsync.AlsTextDocumentSyncConsumer trait TextDocumentSyncBuilder { def build( container: TextDocumentContainer, - dependencies: List[TextListener], - logger: Logger + dependencies: List[TextListener] ): AlsTextDocumentSyncConsumer } object DefaultTextDocumentSyncBuilder extends TextDocumentSyncBuilder { override def build( container: TextDocumentContainer, - dependencies: List[TextListener], - logger: Logger + dependencies: List[TextListener] ): AlsTextDocumentSyncConsumer = - new TextDocumentManager(container, dependencies, logger) + new TextDocumentManager(container, dependencies) } diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/UnitTaskManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/UnitTaskManager.scala index de2f33c093..a1bbe086aa 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/UnitTaskManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/UnitTaskManager.scala @@ -1,6 +1,7 @@ package org.mulesoft.als.server.workspace import org.mulesoft.als.common.SyncFunction +import org.mulesoft.als.logger.Logger import org.mulesoft.als.server.modules.workspace._ import org.mulesoft.amfintegration.UnitWithNextReference @@ -72,8 +73,11 @@ trait UnitTaskManager[UnitType, ResultUnit <: UnitWithNextReference, StagingArea def shutdown(): Future[Unit] = isDisabled.future protected def changeState(newState: TaskManagerState): Unit = synchronized { - if (state == NotAvailable) throw new UnavailableTaskManagerException - log(s"changeState: ${newState.state}") + if (state == NotAvailable) { + Logger.error(s"Couldn't change because state is: ${NotAvailable.toString}", "UnitTaskManager", "changeState") + throw new UnavailableTaskManagerException + } + log(s"ChangeState to: ${newState.state}") state = newState } diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/WorkspaceManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/WorkspaceManager.scala index 1ee17b3fc4..fa06003602 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/WorkspaceManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/WorkspaceManager.scala @@ -27,7 +27,6 @@ class WorkspaceManager protected ( projectConfigurationProvider: ProjectConfigurationProvider, val allSubscribers: List[WorkspaceContentListener[_]], override val dependencies: List[AccessUnits[CompilableUnit]], - logger: Logger, configurationProvider: ConfigurationProvider ) extends TextListener with UnitWorkspaceManager @@ -46,7 +45,6 @@ class WorkspaceManager protected ( editorConfiguration, telemetryProvider, subscribers, - logger, configurationProvider ) def allWorkspaces(): Seq[WorkspaceContentManager] = workspaces.allWorkspaces() @@ -73,7 +71,7 @@ class WorkspaceManager protected ( override def didChangeWatchedFiles(params: DidChangeWatchedFilesParams): Future[Unit] = { params.changes.foreach { f => - logger.debug(s"${f.`type`} : ${f.uri}", "WorkspaceManager", "didChangeWatchedFiles") + Logger.debug(s"${f.`type`} : ${f.uri}", "WorkspaceManager", "didChangeWatchedFiles") f.`type` match { case org.mulesoft.lsp.workspace.FileChangeType.Created => // nothing case org.mulesoft.lsp.workspace.FileChangeType.Changed => environmentProvider.filesInMemory @@ -91,14 +89,14 @@ class WorkspaceManager protected ( case Some(exe) => exe.runCommand(params) case _ => - logger.error(s"Command [${params.command}] not recognized", "WorkspaceManager", "executeCommand") + Logger.error(s"Command [${params.command}] not recognized", "WorkspaceManager", "executeCommand") Future.successful(Unit) // future failed? } private val commandExecutors: Map[String, CommandExecutor[_, _]] = Map( - Commands.DID_FOCUS_CHANGE_COMMAND -> new DidFocusCommandExecutor(logger, this), - Commands.DID_CHANGE_CONFIGURATION -> new DidChangeConfigurationCommandExecutor(logger, this), - Commands.INDEX_DIALECT -> new IndexDialectCommandExecutor(logger, this) + Commands.DID_FOCUS_CHANGE_COMMAND -> new DidFocusCommandExecutor(this), + Commands.DID_CHANGE_CONFIGURATION -> new DidChangeConfigurationCommandExecutor(this), + Commands.INDEX_DIALECT -> new IndexDialectCommandExecutor(this) ) override def getProjectRootOf(uri: String): Future[Option[String]] = @@ -171,7 +169,6 @@ class WorkspaceList( editorConfiguration: EditorConfiguration, telemetryProvider: TelemetryProvider, subscribers: () => List[WorkspaceContentListener[_]], - logger: Logger, configurationProvider: ConfigurationProvider ) { @@ -184,12 +181,11 @@ class WorkspaceList( buildDefaultWorkspaceManager() def buildDefaultWorkspaceManager(): Future[WorkspaceContentManager] = { - logger.debug(s"created default WorkspaceContentManager", "WorkspaceList", "buildWorkspaceAt") + Logger.debug(s"Default WorkspaceContentManager created", "WorkspaceList", "buildWorkspaceAt") WorkspaceContentManager( "", environmentProvider, telemetryProvider, - logger, subscribers, buildConfigurationAdapter("", IgnoreProjectConfigurationAdapter), configurationProvider.getHotReloadDialects @@ -203,7 +199,7 @@ class WorkspaceList( def changeWorkspaces(added: List[String], deleted: List[String]): Future[Unit] = synchronized { Future.sequence(workspaces.map(_.initialized)).flatMap { _ => - logger.debug(s"Changing workspaces, added: $added, deleted: $deleted", "WorkspaceList", "changeWorkspace") + Logger.debug(s"Changing workspaces, added: $added, deleted: $deleted", "WorkspaceList", "changeWorkspace") val newWorkspaces = added.filterNot(uri => workspaces.exists(_.folderUri == uri)).map(getOrCreateWorkspaceAt) val oldWorkspaces = workspaces.filter(wcm => deleted.contains(wcm.folderUri)) ++ workspaces.collect({ @@ -240,14 +236,13 @@ class WorkspaceList( uri, environmentProvider, telemetryProvider, - logger, subscribers, buildConfigurationAdapter(uri, projectConfigurationProvider), configurationProvider.getHotReloadDialects ) _ <- Future.sequence(applicableFiles.map(wcm.stage(_, OPEN_FILE))) } yield { - logger.debug(s"created WorkspaceContentManager for $uri", "WorkspaceList", "buildWorkspaceAt") + Logger.debug(s"WorkspaceContentManager created for $uri", "WorkspaceList", "buildWorkspaceAt") wcm } } @@ -262,8 +257,7 @@ class WorkspaceList( pcp, editorConfiguration, environmentProvider, - buListenerSubscribers, - logger + buListenerSubscribers ) def findWorkspace(uri: String): Future[WorkspaceContentManager] = @@ -274,7 +268,7 @@ class WorkspaceList( .sequence(workspaces.map(ws => ws.containsFile(uri).map((ws, _)))) .map(set => set.find(t => t._2).map(_._1)) wcm <- wcmCandidate.map(Future(_)).getOrElse { - logger.debug(s"Getting default workspace ($uri)", "WorkspaceList", "findWorkspace") + Logger.debug(s"Getting default workspace ($uri)", "WorkspaceList", "findWorkspace") defaultWorkspace } } yield wcm @@ -304,7 +298,6 @@ object WorkspaceManager { projectConfigurationProvider: ProjectConfigurationProvider, allSubscribers: List[WorkspaceContentListener[_]], dependencies: List[AccessUnits[CompilableUnit]], - logger: Logger, configurationProvider: ConfigurationProvider ): WorkspaceManager = { val wm = new WorkspaceManager( @@ -314,7 +307,6 @@ object WorkspaceManager { projectConfigurationProvider, allSubscribers, dependencies, - logger, configurationProvider ) wm.dependencies.foreach(d => d.withUnitAccessor(wm)) diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/command/CommandExecutor.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/command/CommandExecutor.scala index 0a5279d6d6..a76a4f8631 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/command/CommandExecutor.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/command/CommandExecutor.scala @@ -14,8 +14,6 @@ trait CommandExecutor[P, R] { protected def runCommand(param: P): Future[R] - protected val logger: Logger - private def buildParam(arguments: List[String]): Option[P] = { val maybeNode: Option[YNode] = arguments.headOption .map(c => JsonParser(c).parse(false)) @@ -28,13 +26,13 @@ trait CommandExecutor[P, R] { def runCommand(params: ExecuteCommandParams): Future[Option[R]] = { val className = "org.mulesoft.als.server.workspace.command.CommandExecutor" - logger.debug(params.toString, className, "executeCommand") + Logger.debug(params.toString, className, "executeCommand") buildParam(treatParams(params.arguments)) match { case Some(parsedParam) => - logger.debug(parsedParam.toString, className, "executeCommand") + Logger.debug(parsedParam.toString, className, "executeCommand") runCommand(parsedParam).map(c => Some(c)) case _ => - logger.error( + Logger.error( s"Cannot build params for ${params.command}: ${params.arguments.toString()}", className, "executeCommand" diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/command/DidChangeConfigurationCommandExecutor.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/command/DidChangeConfigurationCommandExecutor.scala index 94f112f9bf..dea6ddb55c 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/command/DidChangeConfigurationCommandExecutor.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/command/DidChangeConfigurationCommandExecutor.scala @@ -11,7 +11,7 @@ import org.yaml.model.{YMap, YMapEntry, YScalar, YSequence} import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Future -class DidChangeConfigurationCommandExecutor(val logger: Logger, wsc: WorkspaceManager) +class DidChangeConfigurationCommandExecutor(wsc: WorkspaceManager) extends CommandExecutor[DidChangeConfigurationNotificationParams, Unit] { override protected def treatParams(arguments: List[String]): List[String] = @@ -30,7 +30,7 @@ class DidChangeConfigurationCommandExecutor(val logger: Logger, wsc: WorkspaceMa .flatMap(e => e.value.toOption[String]) .orElse(mainPath) .getOrElse({ - logger.error( + Logger.error( "Change configuration command with no folder value or mainPath", "DidChangeConfigurationCommandExecutor", "buildParamFromMap" @@ -67,7 +67,7 @@ class DidChangeConfigurationCommandExecutor(val logger: Logger, wsc: WorkspaceMa override protected def runCommand(param: DidChangeConfigurationNotificationParams): Future[Unit] = wsc.getWorkspace(param.folder).flatMap { manager => - logger.debug( + Logger.debug( s"DidChangeConfiguration for workspace @ ${manager.folderUri} (folder: ${param.folder}, mainPath:${param.mainPath})", "DidChangeConfigurationCommandExecutor", "runCommand" @@ -87,7 +87,7 @@ class DidChangeConfigurationCommandExecutor(val logger: Logger, wsc: WorkspaceMa extractPerScope(param, SEMANTIC_EXTENSION), extractPerScope(param, DIALECT) ) - logger.debug( + Logger.debug( s"Workspace '${projectConfiguration.folder}' new configuration { mainFile: ${projectConfiguration.mainFile}, dependencies: ${projectConfiguration.designDependency}, profiles: ${projectConfiguration.validationDependency} }", "WorkspaceManager", "contentManagerConfiguration" diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/command/DidFocusCommandExecutor.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/command/DidFocusCommandExecutor.scala index 2666b1b2d8..e72ab91cf6 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/command/DidFocusCommandExecutor.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/command/DidFocusCommandExecutor.scala @@ -10,7 +10,7 @@ import org.mulesoft.als.server.protocol.textsync.DidFocusParams import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Future -class DidFocusCommandExecutor(val logger: Logger, wsc: WorkspaceManager) extends CommandExecutor[DidFocusParams, Unit] { +class DidFocusCommandExecutor(wsc: WorkspaceManager) extends CommandExecutor[DidFocusParams, Unit] { override protected def buildParamFromMap(m: YMap): Option[DidFocusParams] = { val version: Int = m.key("version").flatMap(e => e.value.toOption[Int]).getOrElse(1) m.key("uri").map { n => diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/command/IndexDialectCommandExecutor.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/command/IndexDialectCommandExecutor.scala index 9e0c00b28e..d7981cff88 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/command/IndexDialectCommandExecutor.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/workspace/command/IndexDialectCommandExecutor.scala @@ -13,10 +13,10 @@ import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Future /** This will index at workspace level - * @param logger + * @param Logger * @param amfConfiguration */ -class IndexDialectCommandExecutor(val logger: Logger, workspaceManager: WorkspaceManager) +class IndexDialectCommandExecutor(workspaceManager: WorkspaceManager) extends CommandExecutor[IndexDialectParams, Unit] with PlatformSecrets { override protected def buildParamFromMap(ast: YMap): Option[IndexDialectParams] = { diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/FailedLogs.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/FailedLogs.scala index 4ac99a97f2..8424d30b18 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/FailedLogs.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/FailedLogs.scala @@ -2,6 +2,7 @@ package org.mulesoft.als.server import org.mulesoft.als.logger.Logger import org.mulesoft.als.logger.MessageSeverity.MessageSeverity +import org.mulesoft.als.server.TestLogger.newLine import org.scalatest.CompleteLastly.complete import org.scalatest.{FutureOutcome, TestData} @@ -28,6 +29,8 @@ case class TestLogger() extends Logger { val logList: mutable.Queue[String] = mutable.Queue[String]() + def cleanLogList(): Unit = logList.clear() + /** Logs a message * * @param message @@ -40,7 +43,7 @@ case class TestLogger() extends Logger { * \- sub-component name */ override def log(message: String, severity: MessageSeverity, component: String, subComponent: String): Unit = - synchronized(logList += s"log\n\t$message\n\t$severity\n\t$component\n\t$subComponent") + synchronized(logList += s"log$newLine$message$newLine$severity$newLine$component$newLine$subComponent") /** Logs a DEBUG severity message. * @@ -52,7 +55,7 @@ case class TestLogger() extends Logger { * \- sub-component name */ override def debug(message: String, component: String, subComponent: String): Unit = - synchronized(logList += s"debug\n\t$message\n\t$component\n\t$subComponent") + synchronized(logList += s"debug$newLine$message$newLine$component$newLine$subComponent") /** Logs a WARNING severity message. * @@ -64,7 +67,7 @@ case class TestLogger() extends Logger { * \- sub-component name */ override def warning(message: String, component: String, subComponent: String): Unit = - synchronized(logList += s"warning\n\t$message\n\t$component\n\t$subComponent") + synchronized(logList += s"warning$newLine$message$newLine$component$newLine$subComponent") /** Logs an ERROR severity message. * @@ -76,5 +79,9 @@ case class TestLogger() extends Logger { * \- sub-component name */ override def error(message: String, component: String, subComponent: String): Unit = - synchronized(logList += s"error\n\t$message\n\t$component\n\t$subComponent") + synchronized(logList += s"error$newLine$message$newLine$component$newLine$subComponent") +} + +object TestLogger { + val newLine: String = "\n\t" } diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/LanguageServerBaseTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/LanguageServerBaseTest.scala index be943e4ae7..8bc82c997d 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/LanguageServerBaseTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/LanguageServerBaseTest.scala @@ -4,6 +4,7 @@ import amf.aml.client.scala.model.document.DialectInstance import amf.core.internal.unsafe.PlatformSecrets import amf.custom.validation.client.scala.{BaseProfileValidatorBuilder, ProfileValidatorExecutor} import amf.custom.validation.internal.DummyValidatorExecutor +import org.mulesoft.als.logger.Logger import org.mulesoft.als.server.FailedLogs.loggerFixture import org.mulesoft.als.server.Flaky.flakyFixture import org.mulesoft.als.server.feature.diagnostic.{CleanDiagnosticTreeParams, CleanDiagnosticTreeRequestType} @@ -25,13 +26,7 @@ import org.mulesoft.lsp.feature.documentsymbol.{ import org.mulesoft.lsp.feature.telemetry.TelemetryMessage import org.mulesoft.lsp.textsync._ import org.mulesoft.lsp.workspace.FileChangeType.FileChangeType -import org.mulesoft.lsp.workspace.{ - DidChangeWatchedFilesParams, - DidChangeWorkspaceFoldersParams, - ExecuteCommandParams, - FileEvent, - WorkspaceFoldersChangeEvent -} +import org.mulesoft.lsp.workspace._ import org.scalatest.funsuite.AsyncFunSuite import org.scalatest.matchers.should.Matchers import org.scalatest.{FutureOutcome, OptionValues} @@ -48,9 +43,12 @@ abstract class LanguageServerBaseTest with ChangesWorkspaceConfiguration { implicit val logger: TestLogger = TestLogger() + Logger.withLogger(logger) override def withFixture(test: NoArgAsyncTest): FutureOutcome = - loggerFixture(test)(flakyFixture(_)(super.withFixture)) + loggerFixture(test) { + flakyFixture(_)(super.withFixture) + } object DummyProfileValidator extends BaseProfileValidatorBuilder { diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/LanguageServerImplTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/LanguageServerImplTest.scala index 1bc079c5e7..a2a683c21f 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/LanguageServerImplTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/LanguageServerImplTest.scala @@ -1,6 +1,5 @@ package org.mulesoft.als.server -import org.mulesoft.als.logger.Logger import org.mulesoft.als.server.client.scala.LanguageServerBuilder import org.mulesoft.als.server.modules.ast.TextListener import org.mulesoft.als.server.modules.{WorkspaceManagerFactory, WorkspaceManagerFactoryBuilder} @@ -23,7 +22,7 @@ class LanguageServerImplTest extends LanguageServerBaseTest { test("LanguageServer will open files") { val factory = - new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier, logger).buildWorkspaceManagerFactory() + new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier).buildWorkspaceManagerFactory() val editorFiles = factory.container withServer[Assertion](buildServer(factory)) { server => for { @@ -51,11 +50,9 @@ class LanguageServerImplTest extends LanguageServerBaseTest { test("LanguageServer with custom document sync open file") { val factory = new WorkspaceManagerFactoryBuilder( new MockDiagnosticClientNotifier, - logger, - textDocumentSyncBuilder = - Some((container: TextDocumentContainer, dependencies: List[TextListener], logger: Logger) => - new CustomTextDocumentSync(container, dependencies, logger) - ) + textDocumentSyncBuilder = Some((container: TextDocumentContainer, dependencies: List[TextListener]) => + new CustomTextDocumentSync(container, dependencies) + ) ).buildWorkspaceManagerFactory() val editorFiles = factory.container @@ -112,26 +109,26 @@ class LanguageServerImplTest extends LanguageServerBaseTest { // } // } - def buildServer(factory: WorkspaceManagerFactory): LanguageServer = + def buildServer(factory: WorkspaceManagerFactory): LanguageServer = { new LanguageServerBuilder( factory.documentManager, factory.workspaceManager, factory.configurationManager, factory.resolutionTaskManager ).build() + } override def rootPath: String = "" } class CustomTextDocumentSync( override val uriToEditor: TextDocumentContainer, - val dependencies: List[TextListener], - protected val logger: Logger + val dependencies: List[TextListener] ) extends AlsTextDocumentSyncConsumer { override val `type`: TextDocumentSyncConfigType.type = TextDocumentSyncConfigType - val internal = new TextDocumentManager(uriToEditor, dependencies, logger) + val internal = new TextDocumentManager(uriToEditor, dependencies) override def didOpen(params: DidOpenTextDocumentParams): Future[Unit] = if (params.textDocument.uri.contains("exchange.json")) { Future.successful() diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/LoggerTestConfiguration.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/LoggerTestConfiguration.scala new file mode 100644 index 0000000000..32a8a60399 --- /dev/null +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/LoggerTestConfiguration.scala @@ -0,0 +1,20 @@ +package org.mulesoft.als.server + +import org.mulesoft.als.logger.Logger +import org.scalatest.BeforeAndAfterEach +import org.scalatest.funsuite.AsyncFunSuite + +trait LoggerTestConfiguration extends AsyncFunSuite with BeforeAndAfterEach { + + val logger: TestLogger = TestLogger() + + override def beforeEach(): Unit = { + super.beforeEach() + Logger.withLogger(logger) + } + + override def afterEach(): Unit = { + super.afterEach() + logger.cleanLogList() + } +} diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/errorhandler/ErrorHandlingTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/errorhandler/ErrorHandlingTest.scala index 2840b7009d..d9e9b3c0ad 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/errorhandler/ErrorHandlingTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/errorhandler/ErrorHandlingTest.scala @@ -1,6 +1,7 @@ package org.mulesoft.als.server.errorhandler import org.mulesoft.als.common.URIImplicits.StringUriImplicits +import org.mulesoft.als.logger.Logger import org.mulesoft.als.server.client.scala.LanguageServerBuilder import org.mulesoft.als.server.modules.workspace.UnitNotFoundException import org.mulesoft.als.server.modules.{WorkspaceManagerFactory, WorkspaceManagerFactoryBuilder} @@ -16,19 +17,29 @@ import org.mulesoft.lsp.textsync.{ DidOpenTextDocumentParams, TextDocumentContentChangeEvent } +import org.scalatest.BeforeAndAfterEach import scala.concurrent.{ExecutionContext, Future} -class ErrorHandlingTest extends LanguageServerBaseTest { +class ErrorHandlingTest extends LanguageServerBaseTest with BeforeAndAfterEach { override implicit val executionContext: ExecutionContext = ExecutionContext.Implicits.global override def rootPath: String = "" // apis or golden files should not be necessary private val telemetryNotifier = new MockTelemetryClientNotifier(5000, false) + override def beforeEach(): Unit = { + Logger.withLogger(logger) + super.beforeEach() + } + override def afterEach(): Unit = { + super.afterEach() + logger.cleanLogList() + } + def buildServer(): (LanguageServer, WorkspaceManagerFactory) = { val factory: WorkspaceManagerFactory = - new WorkspaceManagerFactoryBuilder(telemetryNotifier, logger).buildWorkspaceManagerFactory() + new WorkspaceManagerFactoryBuilder(telemetryNotifier).buildWorkspaceManagerFactory() ( new LanguageServerBuilder( factory.documentManager, diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/codeactions/CodeActionsWithGoldenTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/codeactions/CodeActionsWithGoldenTest.scala index 00210cb312..fb058725e6 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/codeactions/CodeActionsWithGoldenTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/codeactions/CodeActionsWithGoldenTest.scala @@ -139,7 +139,7 @@ class CodeActionsWithGoldenTest extends ServerWithMarkerTest[Seq[CodeAction]] wi def buildServer(): LanguageServer = { val factory = - new WorkspaceManagerFactoryBuilder(notifier, logger).buildWorkspaceManagerFactory() + new WorkspaceManagerFactoryBuilder(notifier).buildWorkspaceManagerFactory() new LanguageServerBuilder( factory.documentManager, factory.workspaceManager, diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/codeactions/CodeActionsWithPositionMarkerTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/codeactions/CodeActionsWithPositionMarkerTest.scala index 13e853c3a1..e1c17c6c68 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/codeactions/CodeActionsWithPositionMarkerTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/codeactions/CodeActionsWithPositionMarkerTest.scala @@ -24,14 +24,13 @@ class CodeActionsWithPositionMarkerTest extends ServerWithMarkerTest[Seq[CodeAct def buildServer(): LanguageServer = { val factory = - new WorkspaceManagerFactoryBuilder(notifier, logger).buildWorkspaceManagerFactory() + new WorkspaceManagerFactoryBuilder(notifier).buildWorkspaceManagerFactory() val codeActionManager = new CodeActionManager( AllCodeActions.all :+ TestCodeAction, factory.workspaceManager, factory.configurationManager.getConfiguration, factory.telemetryManager, - logger, factory.directoryResolver ) new LanguageServerBuilder( diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/completion/ServerSuggestionsTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/completion/ServerSuggestionsTest.scala index ecc1a009a0..45aea37862 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/completion/ServerSuggestionsTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/completion/ServerSuggestionsTest.scala @@ -21,9 +21,8 @@ import scala.concurrent.Future abstract class ServerSuggestionsTest extends LanguageServerBaseTest with EitherValues with MarkerFinderTest { def buildServer(): LanguageServer = { - val factory = - new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier, logger).buildWorkspaceManagerFactory() + new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier).buildWorkspaceManagerFactory() new LanguageServerBuilder( factory.documentManager, factory.workspaceManager, diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/completion/raml/DifferentEncodingTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/completion/raml/DifferentEncodingTest.scala index 2246e8f4b7..4a502b4446 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/completion/raml/DifferentEncodingTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/completion/raml/DifferentEncodingTest.scala @@ -3,18 +3,18 @@ package org.mulesoft.als.server.modules.completion.raml import amf.core.client.common.remote.Content import amf.core.client.scala.resource.ResourceLoader import org.mulesoft.als.common.DirectoryResolver +import org.mulesoft.als.common.URIImplicits._ +import org.mulesoft.als.server.MockDiagnosticClientNotifier +import org.mulesoft.als.server.client.scala.LanguageServerBuilder import org.mulesoft.als.server.modules.WorkspaceManagerFactoryBuilder import org.mulesoft.als.server.protocol.LanguageServer import org.mulesoft.als.server.protocol.configuration.AlsInitializeParams import org.mulesoft.als.server.workspace.WorkspaceManager -import org.mulesoft.als.server.MockDiagnosticClientNotifier +import org.mulesoft.amfintegration.amfconfiguration.EditorConfiguration import org.mulesoft.lsp.configuration.TraceKind import org.mulesoft.lsp.feature.common.{Position, TextDocumentIdentifier, TextDocumentItem} import org.mulesoft.lsp.feature.completion.{CompletionParams, CompletionRequestType} import org.mulesoft.lsp.textsync.DidOpenTextDocumentParams -import org.mulesoft.als.common.URIImplicits._ -import org.mulesoft.als.server.client.scala.LanguageServerBuilder -import org.mulesoft.amfintegration.amfconfiguration.EditorConfiguration import scala.concurrent.{ExecutionContext, Future} @@ -60,7 +60,7 @@ class DifferentEncodingTest extends RAMLSuggestionTestServer { } val global = EditorConfiguration.withPlatformLoaders(Seq(rs)) val factory = - new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier, logger, global) + new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier, global) .withDirectoryResolver(dr) .buildWorkspaceManagerFactory() val workspaceManager: WorkspaceManager = factory.workspaceManager diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/completion/raml/IncludeCacheTests.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/completion/raml/IncludeCacheTests.scala index 05c1a15e21..82687e135a 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/completion/raml/IncludeCacheTests.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/completion/raml/IncludeCacheTests.scala @@ -44,7 +44,6 @@ class IncludeCacheTests extends RAMLSuggestionTestServer { def buildServer(rl: ResourceLoader): LanguageServer = { val factory = new WorkspaceManagerFactoryBuilder( new MockDiagnosticClientNotifier, - logger, EditorConfiguration.withPlatformLoaders(Seq(rl)) ) .buildWorkspaceManagerFactory() diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/definition/ServerDefinitionTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/definition/ServerDefinitionTest.scala index 62fe04828a..779bdee053 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/definition/ServerDefinitionTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/definition/ServerDefinitionTest.scala @@ -23,7 +23,7 @@ trait ServerDefinitionTest extends LanguageServerBaseTest with MarkerFinderTest def buildServer(): LanguageServer = { val factory = - new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier, logger).buildWorkspaceManagerFactory() + new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier).buildWorkspaceManagerFactory() new LanguageServerBuilder( factory.documentManager, factory.workspaceManager, diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/CleanDiagnosticTreeTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/CleanDiagnosticTreeTest.scala index f59da8bba7..9bfdcb102f 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/CleanDiagnosticTreeTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/CleanDiagnosticTreeTest.scala @@ -3,7 +3,6 @@ package org.mulesoft.als.server.modules.diagnostic import amf.core.client.scala.resource.ResourceLoader import org.mulesoft.als.common.AmfConfigurationPatcher import org.mulesoft.als.configuration.ProjectConfiguration -import org.mulesoft.als.logger.EmptyLogger import org.mulesoft.als.server.client.platform.ClientNotifier import org.mulesoft.als.server.modules.configuration.WorkspaceConfigurationProvider import org.mulesoft.als.server.modules.diagnostic.custom.CustomValidationManager @@ -70,8 +69,7 @@ class CleanDiagnosticTreeTest extends AsyncFlatSpec { for { state <- new DefaultProjectConfigurationProvider( DummyEnvironmentProvider, - configuration, - EmptyLogger + configuration ) .newProjectConfiguration( new ProjectConfiguration("file:///", Some(mainPath), Set.empty, Set.empty, Set(dialectUri), Set.empty) @@ -96,8 +94,7 @@ class CleanDiagnosticTreeTest extends AsyncFlatSpec { for { state <- new DefaultProjectConfigurationProvider( DummyEnvironmentProvider, - configuration, - EmptyLogger + configuration ) .newProjectConfiguration( new ProjectConfiguration("file:///", Some(mainPath), Set.empty, Set(profileUri), Set.empty, Set.empty) @@ -132,7 +129,6 @@ class CleanDiagnosticTreeTest extends AsyncFlatSpec { ) extends CleanDiagnosticTreeManager( DummyTelemetryProvider, DummyEnvironmentProvider, - EmptyLogger, customValidationManager, DummyConfigProvider ) { @@ -157,7 +153,7 @@ class CleanDiagnosticTreeTest extends AsyncFlatSpec { fail("getConfigurationState should not be called from Dummy manager") } - object DummyTelemetryProvider extends TelemetryManager(DummyClientNotifier, EmptyLogger) + object DummyTelemetryProvider extends TelemetryManager(DummyClientNotifier) object DummyClientNotifier extends ClientNotifier { override def notifyDiagnostic(params: PublishDiagnosticsParams): Unit = {} diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/CustomValidationManagerTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/CustomValidationManagerTest.scala index c906c924b7..c7cd5f7013 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/CustomValidationManagerTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/CustomValidationManagerTest.scala @@ -62,7 +62,7 @@ class CustomValidationManagerTest diagnosticNotifier: MockDiagnosticClientNotifier, validator: BaseProfileValidatorBuilder ): LanguageServer = { - val builder = new WorkspaceManagerFactoryBuilder(diagnosticNotifier, logger, EditorConfiguration()) + val builder = new WorkspaceManagerFactoryBuilder(diagnosticNotifier, EditorConfiguration()) val dm = builder.buildDiagnosticManagers(Some(validator)) val factory = builder.buildWorkspaceManagerFactory() val b = new LanguageServerBuilder( @@ -80,7 +80,7 @@ class CustomValidationManagerTest validator: BaseProfileValidatorBuilder, s: SerializationProps[_] ): LanguageServer = { - val builder = new WorkspaceManagerFactoryBuilder(diagnosticNotifier, logger, EditorConfiguration()) + val builder = new WorkspaceManagerFactoryBuilder(diagnosticNotifier, EditorConfiguration()) val dm = builder.buildDiagnosticManagers(Some(validator)) val sm = builder.serializationManager(s) val factory = builder.buildWorkspaceManagerFactory() @@ -271,7 +271,7 @@ class CustomValidationManagerTest diagnostics.diagnostics.find(d => d.range == range) if (firstDiagnostic.isEmpty) { logger.error( - s"Couldn't find first diagnostic:\n ${diagnostics.write}", + s"Couldn't find first diagnostic: ${diagnostics.write}", "CustomValidationManagerTest", "Should notify errors" ) @@ -311,7 +311,7 @@ class CustomValidationManagerTest diagnostics.diagnostics.find(d => d.range == range) if (firstDiagnostic.isEmpty) { logger.error( - s"Couldn't find first diagnostic:\n ${diagnostics.write}", + s"Couldn't find first diagnostic: ${diagnostics.write}", "CustomValidationManagerTest", "Should notify errors" ) @@ -351,7 +351,7 @@ class CustomValidationManagerTest diagnostics.diagnostics.find(_.message == "Min length must be less than max length must match in scalar") if (firstDiagnostic.isEmpty) { logger.error( - s"Couldn't find first diagnostic:\n ${diagnostics.write}", + s"Couldn't find first diagnostic: ${diagnostics.write}", "CustomValidationManagerTest", "Should notify errors" ) @@ -434,7 +434,7 @@ class CustomValidationManagerTest diagnostics.diagnostics.find(d => d.range == range) if (firstDiagnostic.isEmpty) { logger.error( - s"Couldn't find first diagnostic:\n ${diagnostics.write}", + s"Couldn't find first diagnostic: ${diagnostics.write}", "CustomValidationManagerTest", "Should notify errors" ) @@ -476,7 +476,7 @@ class CustomValidationManagerTest diagnostics.diagnostics.find(d => d.range == range) if (firstDiagnostic.isEmpty) { logger.error( - s"Couldn't find first diagnostic:\n ${diagnostics.write}", + s"Couldn't find first diagnostic: ${diagnostics.write}", "CustomValidationManagerTest", "Should notify errors" ) @@ -520,7 +520,7 @@ class CustomValidationManagerTest diagnostics.diagnostics.find(d => d.range == range) if (firstDiagnostic.isEmpty) { logger.error( - s"Couldn't find first diagnostic:\n ${diagnostics.write}", + s"Couldn't find first diagnostic: ${diagnostics.write}", "CustomValidationManagerTest", "Should notify errors" ) diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/CustomValidationPluginTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/CustomValidationPluginTest.scala index d8113e71a9..a25787df0c 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/CustomValidationPluginTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/CustomValidationPluginTest.scala @@ -1,8 +1,8 @@ package org.mulesoft.als.server.modules.diagnostic -import amf.core.client.common.{NormalPriority, PluginPriority} import amf.core.client.common.remote.Content import amf.core.client.common.validation.{ProfileNames, ValidationMode} +import amf.core.client.common.{NormalPriority, PluginPriority} import amf.core.client.scala.model.document.PayloadFragment import amf.core.client.scala.model.domain.Shape import amf.core.client.scala.resource.ResourceLoader @@ -67,9 +67,9 @@ class CustomValidationPluginTest extends LanguageServerBaseTest { } def buildServer(diagnosticNotifier: MockDiagnosticClientNotifier): LanguageServer = { - val editorConfiguration = EditorConfiguration(rl +: platform.loaders(), Seq.empty, Seq(plugin), logger) + val editorConfiguration = EditorConfiguration(rl +: platform.loaders(), Seq.empty, Seq(plugin)) val builder = - new WorkspaceManagerFactoryBuilder(diagnosticNotifier, logger, editorConfiguration) + new WorkspaceManagerFactoryBuilder(diagnosticNotifier, editorConfiguration) val dm = builder.buildDiagnosticManagers() val factory = builder.buildWorkspaceManagerFactory() val b = new LanguageServerBuilder( diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/DiagnosticServerImpl.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/DiagnosticServerImpl.scala index 7440d16867..77745a544d 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/DiagnosticServerImpl.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/DiagnosticServerImpl.scala @@ -82,11 +82,11 @@ class DiagnosticServerImpl extends LanguageServerBaseTest with DiagnosticServer } def buildServer( - diagnosticNotifier: MockDiagnosticClientNotifier, - validator: Option[BaseProfileValidatorBuilder] = None - ): LanguageServer = { + diagnosticNotifier: MockDiagnosticClientNotifier, + validator: Option[BaseProfileValidatorBuilder] = None + ): LanguageServer = { val global = EditorConfiguration.withPlatformLoaders(Seq(rl)) - val builder = new WorkspaceManagerFactoryBuilder(diagnosticNotifier, logger, global) + val builder = new WorkspaceManagerFactoryBuilder(diagnosticNotifier, global) val dm = builder.buildDiagnosticManagers(validator) val factory = builder.buildWorkspaceManagerFactory() val b = new LanguageServerBuilder( diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/ProjectDiagnosticTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/ProjectDiagnosticTest.scala index 9e5d4a10a1..abdef41659 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/ProjectDiagnosticTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/ProjectDiagnosticTest.scala @@ -42,7 +42,6 @@ class ProjectDiagnosticTest extends LanguageServerBaseTest { val builder = new WorkspaceManagerFactoryBuilder( diagnosticNotifier, - logger, editorConfig, projectConfigurationProvider = Some(provider) ) diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/ProjectErrorConfigurationProvider.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/ProjectErrorConfigurationProvider.scala index 83da07a5ea..4ee872259c 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/ProjectErrorConfigurationProvider.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/ProjectErrorConfigurationProvider.scala @@ -14,8 +14,7 @@ class ProjectErrorConfigurationProvider( error: AMFValidationResult ) extends DefaultProjectConfigurationProvider( DummyEnvironmentProvider, - editorConfiguration, - logger + editorConfiguration ) { private var reportError = true @@ -32,8 +31,7 @@ class ProjectErrorConfigurationProvider( state.config, DummyEnvironmentProvider, if (reportError) Seq(error) else Seq(), - editorConfiguration, - logger + editorConfiguration ) })) } diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/ServerDiagnosticTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/ServerDiagnosticTest.scala index 588f6f7a6d..2e652c2fc3 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/ServerDiagnosticTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/ServerDiagnosticTest.scala @@ -34,7 +34,7 @@ class ServerDiagnosticTest extends LanguageServerBaseTest { override def rootPath: String = "" def buildServer(diagnosticNotifier: MockDiagnosticClientNotifier): LanguageServer = { - val builder = new WorkspaceManagerFactoryBuilder(diagnosticNotifier, logger, EditorConfiguration()) + val builder = new WorkspaceManagerFactoryBuilder(diagnosticNotifier, EditorConfiguration()) val dm = builder.buildDiagnosticManagers() val factory = builder.buildWorkspaceManagerFactory() val b = new LanguageServerBuilder( @@ -211,7 +211,7 @@ class ServerDiagnosticTest extends LanguageServerBaseTest { override def location(): Option[String] = Some("location") } val diagnosticNotifier: MockDiagnosticClientNotifier = new MockDiagnosticClientNotifier(7000) - val builder = new WorkspaceManagerFactoryBuilder(diagnosticNotifier, logger, EditorConfiguration()) + val builder = new WorkspaceManagerFactoryBuilder(diagnosticNotifier, EditorConfiguration()) builder .buildDiagnosticManagers() val factory = builder.buildWorkspaceManagerFactory() @@ -333,7 +333,6 @@ class ServerDiagnosticTest extends LanguageServerBaseTest { val builder = new WorkspaceManagerFactoryBuilder( diagnosticNotifier, - logger, EditorConfiguration.withoutPlatformLoaders(Seq(CustomResourceLoader())) ) val dm = builder.buildDiagnosticManagers() diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/ServerParsingBeforeDiagnosticTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/ServerParsingBeforeDiagnosticTest.scala index 86c8e863bb..5631b79d23 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/ServerParsingBeforeDiagnosticTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/ServerParsingBeforeDiagnosticTest.scala @@ -12,7 +12,7 @@ class ServerParsingBeforeDiagnosticTest extends LanguageServerBaseTest { override implicit val executionContext: ExecutionContext = ExecutionContext.Implicits.global def buildServer(clientNotifier: MockDiagnosticClientNotifier): LanguageServer = { - val builder = new WorkspaceManagerFactoryBuilder(clientNotifier, logger) + val builder = new WorkspaceManagerFactoryBuilder(clientNotifier) .withNotificationKind(PARSING_BEFORE) val dm = builder.buildDiagnosticManagers() diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/foldings/FoldingRangeTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/foldings/FoldingRangeTest.scala index c68e4b54c8..ca78131b6f 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/foldings/FoldingRangeTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/foldings/FoldingRangeTest.scala @@ -2,7 +2,6 @@ package org.mulesoft.als.server.modules.foldings import amf.core.client.common.remote.Content import amf.core.client.scala.resource.ResourceLoader -import org.mulesoft.als.logger.EmptyLogger import org.mulesoft.als.server.MockDiagnosticClientNotifier import org.mulesoft.als.server.client.scala.LanguageServerBuilder import org.mulesoft.als.server.modules.WorkspaceManagerFactoryBuilder @@ -126,7 +125,7 @@ class FoldingRangeTest extends AsyncFreeSpecLike { } val editorConfiguration = EditorConfiguration.withPlatformLoaders(Seq(rs)) val factory = - new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier, EmptyLogger, editorConfiguration) + new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier, editorConfiguration) .buildWorkspaceManagerFactory() val workspaceManager: WorkspaceManager = factory.workspaceManager val server = diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/formatting/DocumentFormattingTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/formatting/DocumentFormattingTest.scala index 705ec76822..5704bd972c 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/formatting/DocumentFormattingTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/formatting/DocumentFormattingTest.scala @@ -5,7 +5,6 @@ import org.mulesoft.als.common.diff.{FileAssertionTest, WorkspaceEditsTest} import org.mulesoft.als.server.client.scala.LanguageServerBuilder import org.mulesoft.als.server.modules.WorkspaceManagerFactoryBuilder import org.mulesoft.als.server.protocol.LanguageServer -import org.mulesoft.als.server.protocol.configuration.AlsInitializeParams import org.mulesoft.als.server.{LanguageServerBaseTest, MockDiagnosticClientNotifier} import org.mulesoft.lsp.configuration.FormattingOptions import org.mulesoft.lsp.edit.{TextEdit, WorkspaceEdit} @@ -25,7 +24,7 @@ class DocumentFormattingTest extends LanguageServerBaseTest with FileAssertionTe def buildServer(): LanguageServer = { val factory = - new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier, logger).buildWorkspaceManagerFactory() + new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier).buildWorkspaceManagerFactory() new LanguageServerBuilder( factory.documentManager, factory.workspaceManager, diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/formatting/DocumentRangeFormattingTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/formatting/DocumentRangeFormattingTest.scala index ed3ec38acc..282f6637dc 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/formatting/DocumentRangeFormattingTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/formatting/DocumentRangeFormattingTest.scala @@ -33,7 +33,7 @@ class DocumentRangeFormattingTest def buildServer(): LanguageServer = { val factory = - new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier, logger).buildWorkspaceManagerFactory() + new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier).buildWorkspaceManagerFactory() new LanguageServerBuilder( factory.documentManager, factory.workspaceManager, diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/hover/HoverTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/hover/HoverTest.scala index 54400f255f..3dac094a87 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/hover/HoverTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/hover/HoverTest.scala @@ -23,7 +23,7 @@ class HoverTest extends ServerWithMarkerTest[PositionedHover] with BaseHoverTest def buildServer(): LanguageServer = { val factory = - new WorkspaceManagerFactoryBuilder(notifier, logger).buildWorkspaceManagerFactory() + new WorkspaceManagerFactoryBuilder(notifier).buildWorkspaceManagerFactory() new LanguageServerBuilder( factory.documentManager, factory.workspaceManager, diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/links/FindLinksTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/links/FindLinksTest.scala index dc3b5907b3..3d1b1a0e64 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/links/FindLinksTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/links/FindLinksTest.scala @@ -20,7 +20,7 @@ trait FindLinksTest extends LanguageServerBaseTest with MarkerFinderTest { def buildServer(): LanguageServer = { val managers = - new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier, logger).buildWorkspaceManagerFactory() + new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier).buildWorkspaceManagerFactory() new LanguageServerBuilder( managers.documentManager, managers.workspaceManager, diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/project/ProfileChangeListenerTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/project/ProfileChangeListenerTest.scala index 3a5c5d79f0..6942d5955c 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/project/ProfileChangeListenerTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/project/ProfileChangeListenerTest.scala @@ -61,7 +61,7 @@ class ProfileChangeListenerTest withDiagnostics: Boolean = false ): LanguageServer = { val factoryBuilder: WorkspaceManagerFactoryBuilder = - new WorkspaceManagerFactoryBuilder(notifier, logger, EditorConfiguration()) + new WorkspaceManagerFactoryBuilder(notifier, EditorConfiguration()) val dm = factoryBuilder.buildDiagnosticManagers(Some(DummyProfileValidator)) val serializationManager: SerializationManager[StringWriter] = factoryBuilder.serializationManager(serializationProps) diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/reference/ServerReferencesTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/reference/ServerReferencesTest.scala index b1b61c224c..fac7010466 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/reference/ServerReferencesTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/reference/ServerReferencesTest.scala @@ -25,7 +25,7 @@ trait ServerReferencesTest extends ServerWithMarkerTest[Seq[Location]] with Mark def buildServer(): LanguageServer = { val factory = - new WorkspaceManagerFactoryBuilder(notifier, logger).buildWorkspaceManagerFactory() + new WorkspaceManagerFactoryBuilder(notifier).buildWorkspaceManagerFactory() new LanguageServerBuilder( factory.documentManager, factory.workspaceManager, diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/rename/ServerRenameTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/rename/ServerRenameTest.scala index 4a67cfab52..89f3cec03d 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/rename/ServerRenameTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/rename/ServerRenameTest.scala @@ -21,7 +21,7 @@ abstract class ServerRenameTest extends LanguageServerBaseTest with WorkspaceEdi def buildServer(): LanguageServer = { val factory = - new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier, logger).buildWorkspaceManagerFactory() + new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier).buildWorkspaceManagerFactory() new LanguageServerBuilder( factory.documentManager, factory.workspaceManager, diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/renameFile/RenameFileTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/renameFile/RenameFileTest.scala index 0068717b98..e7ca448123 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/renameFile/RenameFileTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/renameFile/RenameFileTest.scala @@ -27,7 +27,7 @@ class RenameFileTest extends LanguageServerBaseTest { def buildServer(): LanguageServer = { val factory = - new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier, logger).buildWorkspaceManagerFactory() + new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier).buildWorkspaceManagerFactory() factory.configurationManager.updateDocumentChangesSupport(true) new LanguageServerBuilder( factory.documentManager, diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/selection/SelectionRangeTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/selection/SelectionRangeTest.scala index b14981cebc..6011e0c2ab 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/selection/SelectionRangeTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/selection/SelectionRangeTest.scala @@ -20,7 +20,7 @@ class SelectionRangeTest extends LanguageServerBaseTest { def buildServer(): LanguageServer = { val factory = - new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier, logger).buildWorkspaceManagerFactory() + new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier).buildWorkspaceManagerFactory() new LanguageServerBuilder( factory.documentManager, factory.workspaceManager, diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/serialization/ConversionRequestTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/serialization/ConversionRequestTest.scala index 59a01baca3..b7228339ef 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/serialization/ConversionRequestTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/serialization/ConversionRequestTest.scala @@ -20,7 +20,7 @@ class ConversionRequestTest extends LanguageServerBaseTest with ChangesWorkspace scala.concurrent.ExecutionContext.Implicits.global def buildServer(): LanguageServer = { val factory = - new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier, logger).buildWorkspaceManagerFactory() + new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier).buildWorkspaceManagerFactory() new LanguageServerBuilder( factory.documentManager, diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/serialization/SerializationTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/serialization/SerializationTest.scala index dc150f93b6..d907da310a 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/serialization/SerializationTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/serialization/SerializationTest.scala @@ -680,7 +680,7 @@ class SerializationTest extends LanguageServerBaseTest with ChangesWorkspaceConf withDiagnostics: Boolean = false ): LanguageServer = { val factoryBuilder: WorkspaceManagerFactoryBuilder = - new WorkspaceManagerFactoryBuilder(notifier, logger, EditorConfiguration()) + new WorkspaceManagerFactoryBuilder(notifier, EditorConfiguration()) val dm = factoryBuilder.buildDiagnosticManagers(Some(DummyProfileValidator)) val serializationManager: SerializationManager[StringWriter] = factoryBuilder.serializationManager(serializationProps) diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/telemetry/ServerTelemetryTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/telemetry/ServerTelemetryTest.scala index 60804ab869..361767ac09 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/telemetry/ServerTelemetryTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/telemetry/ServerTelemetryTest.scala @@ -1,8 +1,8 @@ package org.mulesoft.als.server.modules.telemetry import org.mulesoft.als.server.client.scala.LanguageServerBuilder -import org.mulesoft.als.server.protocol.LanguageServer import org.mulesoft.als.server.modules.WorkspaceManagerFactoryBuilder +import org.mulesoft.als.server.protocol.LanguageServer import org.mulesoft.als.server.{LanguageServerBaseTest, MockTelemetryClientNotifier} import org.mulesoft.lsp.feature.telemetry.{MessageTypes, TelemetryMessage} @@ -16,7 +16,7 @@ class ServerTelemetryTest extends LanguageServerBaseTest { private val mockTelemetryClientNotifier = new MockTelemetryClientNotifier def buildServer(): LanguageServer = { - val builder = new WorkspaceManagerFactoryBuilder(mockTelemetryClientNotifier, logger) + val builder = new WorkspaceManagerFactoryBuilder(mockTelemetryClientNotifier) val dm = builder.buildDiagnosticManagers() val factory = builder.buildWorkspaceManagerFactory() diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/workspace/FilesInProjectNotificationTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/workspace/FilesInProjectNotificationTest.scala index c5f8bb2b56..0d004a1110 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/workspace/FilesInProjectNotificationTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/workspace/FilesInProjectNotificationTest.scala @@ -17,7 +17,7 @@ class FilesInProjectNotificationTest extends LanguageServerBaseTest { def buildServer(alsClient: MockFilesInClientNotifier): LanguageServer = { val factoryBuilder: WorkspaceManagerFactoryBuilder = - new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier, logger) + new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier) val filesInProjectManager = factoryBuilder.filesInProjectManager(alsClient) val factory: WorkspaceManagerFactory = factoryBuilder.buildWorkspaceManagerFactory() diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/stagingarea/parser/ParserStagingAreaTests.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/stagingarea/parser/ParserStagingAreaTests.scala index a7cf324c2f..4a65b0a86b 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/stagingarea/parser/ParserStagingAreaTests.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/stagingarea/parser/ParserStagingAreaTests.scala @@ -3,17 +3,19 @@ package org.mulesoft.als.server.stagingarea.parser import amf.core.client.common.remote.Content import amf.core.client.scala.resource.ResourceLoader import org.mulesoft.als.logger.Logger -import org.mulesoft.als.logger.MessageSeverity.MessageSeverity +import org.mulesoft.als.server.TestLogger +import org.mulesoft.als.server.TestLogger.newLine import org.mulesoft.als.server.modules.ast.{CHANGE_FILE, CLOSE_FILE, NotificationKind, OPEN_FILE} import org.mulesoft.als.server.modules.workspace.ParserStagingArea import org.mulesoft.als.server.textsync.{EnvironmentProvider, TextDocument} +import org.scalatest.BeforeAndAfterEach import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers import scala.collection.mutable.ListBuffer import scala.concurrent.Future -class ParserStagingAreaTests extends AnyFlatSpec with Matchers { +class ParserStagingAreaTests extends AnyFlatSpec with Matchers with BeforeAndAfterEach { private val dummyEnvironmentProvider = new EnvironmentProvider { override def getResourceLoader: ResourceLoader = new ResourceLoader { @@ -29,18 +31,29 @@ class ParserStagingAreaTests extends AnyFlatSpec with Matchers { override def filesInMemory: Map[String, TextDocument] = ??? } + private val logger: TestLogger = new TestLogger() + override def beforeEach(): Unit = { + super.beforeEach() + Logger.withLogger(logger) + } + + override def afterEach(): Unit = { + super.afterEach() + logger.cleanLogList() + } + behavior of "ParserStagingArea simple file operation" private val uritest = "file://uritest.yaml" it should "enqueue a new notification" in { - val psa = new ParserStagingArea(dummyEnvironmentProvider, new TestLogger) + val psa = new ParserStagingArea(dummyEnvironmentProvider) psa.hasPending should be(false) psa.enqueue(uritest, OPEN_FILE) psa.contains(uritest) should be(true) } it should "enqueue many new notifications" in { - val psa = new ParserStagingArea(dummyEnvironmentProvider, new TestLogger) + val psa = new ParserStagingArea(dummyEnvironmentProvider) val input = Set( (uritest, OPEN_FILE), ("file://uritest1.yaml", CLOSE_FILE), @@ -55,7 +68,7 @@ class ParserStagingAreaTests extends AnyFlatSpec with Matchers { } it should "dequeue a notification" in { - val psa = new ParserStagingArea(dummyEnvironmentProvider, new TestLogger) + val psa = new ParserStagingArea(dummyEnvironmentProvider) val input = ("file://test.yaml", OPEN_FILE) psa.enqueue(input._1, input._2) psa.hasPending should be(true) @@ -65,7 +78,7 @@ class ParserStagingAreaTests extends AnyFlatSpec with Matchers { behavior of "ParserStagingArea snapshot generation" it should "dequeue all" in { - val psa = new ParserStagingArea(dummyEnvironmentProvider, new TestLogger) + val psa = new ParserStagingArea(dummyEnvironmentProvider) val input = Set( (uritest, OPEN_FILE), ("file://uritest1.yaml", CLOSE_FILE), @@ -78,7 +91,7 @@ class ParserStagingAreaTests extends AnyFlatSpec with Matchers { } it should "have the same elements that were on the queue" in { - val psa = new ParserStagingArea(dummyEnvironmentProvider, new TestLogger) + val psa = new ParserStagingArea(dummyEnvironmentProvider) val input = Set( (uritest, OPEN_FILE), ("file://uritest1.yaml", CLOSE_FILE), @@ -91,7 +104,7 @@ class ParserStagingAreaTests extends AnyFlatSpec with Matchers { } it should "remove all notifications for a URI but the last if it is CloseNotification" in { - val psa = new ParserStagingArea(dummyEnvironmentProvider, new TestLogger) + val psa = new ParserStagingArea(dummyEnvironmentProvider) val lastTuple = (uritest, CLOSE_FILE) val otherTuple = ("file://uritest1.yaml", OPEN_FILE) val input = List( @@ -109,7 +122,7 @@ class ParserStagingAreaTests extends AnyFlatSpec with Matchers { } it should "remove all notifications for a URI but the last if it is ChangeNotification" in { - val psa = new ParserStagingArea(dummyEnvironmentProvider, new TestLogger) + val psa = new ParserStagingArea(dummyEnvironmentProvider) val lastTuple = (uritest, CHANGE_FILE) val otherTuple = ("file://uritest1.yaml", OPEN_FILE) val input = List( @@ -127,7 +140,7 @@ class ParserStagingAreaTests extends AnyFlatSpec with Matchers { } it should "merge a CloseNotification with the OpenNotification as a ChangeNotification" in { - val psa = new ParserStagingArea(dummyEnvironmentProvider, new TestLogger) + val psa = new ParserStagingArea(dummyEnvironmentProvider) val input = List( (uritest, CLOSE_FILE), (uritest, OPEN_FILE) @@ -139,9 +152,9 @@ class ParserStagingAreaTests extends AnyFlatSpec with Matchers { } it should "log a warning if MergeNotification is followed by OpenNotification, but keep the last one" in { - val logger = new TestLogger - val psa = new ParserStagingArea(dummyEnvironmentProvider, logger) + val psa = new ParserStagingArea(dummyEnvironmentProvider) val lastTuple = (uritest, OPEN_FILE) + val message = s"warning${newLine}file opened without closing ${lastTuple._1}" val input = List( (uritest, CHANGE_FILE), lastTuple @@ -149,13 +162,13 @@ class ParserStagingAreaTests extends AnyFlatSpec with Matchers { psa.enqueue(input) val snapshot = psa.snapshot() snapshot.files.contains(lastTuple) should be(true) - logger.logs.contains(("warning", s"file opened without closing ${lastTuple._1}")) should be(true) + logger.logList.exists(_.startsWith(message)) should be(true) } it should "log a warning if CloseNotification is followed by ChangeNotification, but keep the last one" in { - val logger = new TestLogger - val psa = new ParserStagingArea(dummyEnvironmentProvider, logger) - val lastTuple = (uritest, CHANGE_FILE) + val psa = new ParserStagingArea(dummyEnvironmentProvider) + val lastTuple = (uritest, CHANGE_FILE) + val messageLogged = s"warning${newLine}file changed after closing ${lastTuple._1}" val input = List( (uritest, CLOSE_FILE), lastTuple @@ -163,17 +176,6 @@ class ParserStagingAreaTests extends AnyFlatSpec with Matchers { psa.enqueue(input) val snapshot = psa.snapshot() snapshot.files.contains(lastTuple) should be(true) - logger.logs.contains(("warning", s"file changed after closing ${lastTuple._1}")) should be(true) - } - - class TestLogger extends Logger { - private val list = ListBuffer[(String, String)]() - def logs: Seq[(String, String)] = list - override def log(message: String, severity: MessageSeverity, component: String, subComponent: String): Unit = ??? - override def debug(message: String, component: String, subComponent: String): Unit = - list.append(("debug", message)) - override def warning(message: String, component: String, subComponent: String): Unit = - list.append(("warning", message)) - override def error(message: String, component: String, subComponent: String): Unit = ??? + logger.logList.exists(_.startsWith(messageLogged)) should be(true) } } diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/textsync/DialectRegistryTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/textsync/DialectRegistryTest.scala index 47ee603a05..f4cc3ed47b 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/textsync/DialectRegistryTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/textsync/DialectRegistryTest.scala @@ -40,7 +40,6 @@ class DialectRegistryTest extends LanguageServerBaseTest { val factory = new WorkspaceManagerFactoryBuilder( diagnosticNotifier, - logger, EditorConfiguration.withPlatformLoaders( Seq(AmfConfigurationPatcher.resourceLoaderForFile(extraDialectPath, extraDialectContent)) ) diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/textsync/ServerTextDocumentManagerTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/textsync/ServerTextDocumentManagerTest.scala index 1c93fdbe1a..38eec40713 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/textsync/ServerTextDocumentManagerTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/textsync/ServerTextDocumentManagerTest.scala @@ -18,7 +18,7 @@ class ServerTextDocumentManagerTest extends LanguageServerBaseTest { def buildServer(): LanguageServer = { val factory = - new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier, logger).buildWorkspaceManagerFactory() + new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier).buildWorkspaceManagerFactory() new LanguageServerBuilder( factory.documentManager, factory.workspaceManager, diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/DefaultProjectConfigurationProviderTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/DefaultProjectConfigurationProviderTest.scala index 414831d7bf..5724594bf8 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/DefaultProjectConfigurationProviderTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/DefaultProjectConfigurationProviderTest.scala @@ -5,14 +5,14 @@ import org.mulesoft.als.configuration.ProjectConfiguration import org.mulesoft.als.server.LanguageServerBaseTest import org.mulesoft.als.server.modules.workspace.{DefaultProjectConfigurationProvider, MainFileTreeBuilder} import org.mulesoft.als.server.textsync.TextDocumentContainer -import org.mulesoft.amfintegration.AmfImplicits.AmfAnnotationsImp +import org.mulesoft.amfintegration.AmfImplicits._ import org.mulesoft.amfintegration.amfconfiguration.{ ALSConfigurationState, EditorConfiguration, EmptyProjectConfigurationState } import org.mulesoft.amfintegration.visitors.AmfElementVisitors -import org.mulesoft.amfintegration.AmfImplicits._ + import scala.concurrent.{ExecutionContext, Future} class DefaultProjectConfigurationProviderTest extends LanguageServerBaseTest { @@ -32,7 +32,7 @@ class DefaultProjectConfigurationProviderTest extends LanguageServerBaseTest { def buildConfigurationProvider(): ProjectConfigurationProvider = { val container = TextDocumentContainer() val editorConfiguration = EditorConfiguration() - new DefaultProjectConfigurationProvider(container, editorConfiguration, logger) + new DefaultProjectConfigurationProvider(container, editorConfiguration) } test("Project configuration provider will hold multiple configurations") { @@ -159,8 +159,7 @@ class DefaultProjectConfigurationProviderTest extends LanguageServerBaseTest { parseResult <- ALSConfigurationState(editorConfig, p1, None).parse(api) tree <- MainFileTreeBuilder.build( parseResult, - new AmfElementVisitors(Seq.empty), - logger + new AmfElementVisitors(Seq.empty) ) _ <- provider.afterNewTree(ws1, tree) c2 <- provider.newProjectConfiguration( diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/IndexGlobalDialectTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/IndexGlobalDialectTest.scala index 1c76695b5e..249ac47dd1 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/IndexGlobalDialectTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/IndexGlobalDialectTest.scala @@ -209,7 +209,7 @@ trait IndexGlobalDialectTest extends ServerIndexGlobalDialectCommand { } def buildServer(diagnosticNotifier: MockDiagnosticClientNotifier): (LanguageServer, WorkspaceManager) = { - val builder = new WorkspaceManagerFactoryBuilder(diagnosticNotifier, logger, EditorConfiguration()) + val builder = new WorkspaceManagerFactoryBuilder(diagnosticNotifier, EditorConfiguration()) val dm = builder.buildDiagnosticManagers() val factory = builder.buildWorkspaceManagerFactory() val b = new LanguageServerBuilder( diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceCacheTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceCacheTest.scala index 0ccca7a2cf..e352f13743 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceCacheTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceCacheTest.scala @@ -5,7 +5,6 @@ import amf.core.client.platform.resource.ResourceNotFound import amf.core.client.scala.resource.ResourceLoader import amf.core.internal.unsafe.PlatformSecrets import org.mulesoft.als.configuration.ProjectConfiguration -import org.mulesoft.als.logger.EmptyLogger import org.mulesoft.als.server.client.platform.ClientNotifier import org.mulesoft.als.server.modules.ast.CHANGE_FILE import org.mulesoft.als.server.modules.telemetry.TelemetryManager @@ -69,8 +68,8 @@ class WorkspaceCacheTest extends AsyncFunSuite with Matchers with PlatformSecret val env = TextDocumentContainer() for { configAdapter <- newConfigurationAdapter(folderUri, env, rl) - ws <- WorkspaceContentManager(folderUri, env, DummyTelemetryProvider, EmptyLogger, () => Nil, configAdapter) - _ <- ws.initialized + ws <- WorkspaceContentManager(folderUri, env, DummyTelemetryProvider, () => Nil, configAdapter) + _ <- ws.initialized _ <- ws .withConfiguration(ProjectConfiguration(folderUri, mainApiName, cacheUris)) counter1 <- ws.getUnit(mainApiUri).flatMap(l => l.getLast).map { _ => @@ -132,8 +131,8 @@ class WorkspaceCacheTest extends AsyncFunSuite with Matchers with PlatformSecret val env = TextDocumentContainer() for { configAdapter <- newConfigurationAdapter(folderUri, env, rl) - ws <- WorkspaceContentManager(folderUri, env, DummyTelemetryProvider, EmptyLogger, () => Nil, configAdapter) - _ <- ws.initialized + ws <- WorkspaceContentManager(folderUri, env, DummyTelemetryProvider, () => Nil, configAdapter) + _ <- ws.initialized _ <- ws .withConfiguration(ProjectConfiguration(folderUri, mainApiName, cacheUris)) counter1 <- ws.getUnit(mainApiUri).flatMap(l => l.getLast).map { _ => @@ -186,8 +185,8 @@ class WorkspaceCacheTest extends AsyncFunSuite with Matchers with PlatformSecret val env = TextDocumentContainer() for { configAdapter <- newConfigurationAdapter(folderUri, env, rl) - ws <- WorkspaceContentManager(folderUri, env, DummyTelemetryProvider, EmptyLogger, () => Nil, configAdapter) - _ <- ws.initialized + ws <- WorkspaceContentManager(folderUri, env, DummyTelemetryProvider, () => Nil, configAdapter) + _ <- ws.initialized _ <- ws .withConfiguration(ProjectConfiguration(folderUri, mainApiName)) counter1 <- ws.getUnit(mainApiUri).flatMap(l => l.getLast).map { _ => @@ -241,8 +240,8 @@ class WorkspaceCacheTest extends AsyncFunSuite with Matchers with PlatformSecret val env = TextDocumentContainer() for { configAdapter <- newConfigurationAdapter(folderUri, env, rl) - ws <- WorkspaceContentManager(folderUri, env, DummyTelemetryProvider, EmptyLogger, () => Nil, configAdapter) - _ <- ws.initialized + ws <- WorkspaceContentManager(folderUri, env, DummyTelemetryProvider, () => Nil, configAdapter) + _ <- ws.initialized _ <- ws .withConfiguration(ProjectConfiguration(folderUri, mainApiName, cacheUris)) counter1 <- ws.getUnit(mainApiUri).flatMap(l => l.getLast).map { _ => @@ -265,14 +264,13 @@ class WorkspaceCacheTest extends AsyncFunSuite with Matchers with PlatformSecret ): Future[ProjectConfigurationAdapter] = Future { val editorConfig = EditorConfiguration.withPlatformLoaders(Seq(rl)) val defaultProjectConfigurationProvider = - new DefaultProjectConfigurationProvider(env, editorConfig, EmptyLogger) + new DefaultProjectConfigurationProvider(env, editorConfig) new ProjectConfigurationAdapter( folder, defaultProjectConfigurationProvider, editorConfig, env, - List.empty, - EmptyLogger + List.empty ) } @@ -313,8 +311,8 @@ class WorkspaceCacheTest extends AsyncFunSuite with Matchers with PlatformSecret val env = TextDocumentContainer() for { configAdapter <- newConfigurationAdapter(folderUri, env, rl) - ws <- WorkspaceContentManager(folderUri, env, DummyTelemetryProvider, EmptyLogger, () => Nil, configAdapter) - _ <- ws.initialized + ws <- WorkspaceContentManager(folderUri, env, DummyTelemetryProvider, () => Nil, configAdapter) + _ <- ws.initialized _ <- ws .withConfiguration(ProjectConfiguration(folderUri, mainApiName, cacheUris)) counter1 <- ws.getUnit(mainApiUri).flatMap(l => l.getLast).map { _ => @@ -354,7 +352,7 @@ class WorkspaceCacheTest extends AsyncFunSuite with Matchers with PlatformSecret } } - object DummyTelemetryProvider extends TelemetryManager(DummyClientNotifier, EmptyLogger) + object DummyTelemetryProvider extends TelemetryManager(DummyClientNotifier) object DummyClientNotifier extends ClientNotifier { override def notifyDiagnostic(params: PublishDiagnosticsParams): Unit = {} diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceDocumentLinksTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceDocumentLinksTest.scala index 854d66d1db..1a5f722b9c 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceDocumentLinksTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceDocumentLinksTest.scala @@ -22,7 +22,7 @@ class WorkspaceDocumentLinksTest extends LanguageServerBaseTest { override implicit val executionContext: ExecutionContext = ExecutionContext.Implicits.global private val factory = - new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier(), logger, EditorConfiguration()) + new WorkspaceManagerFactoryBuilder(new MockDiagnosticClientNotifier(), EditorConfiguration()) .buildWorkspaceManagerFactory() private val workspaceFile = "ws/sub/type.raml" private val workspaceIncludedFilePath = filePath("ws/includes/type.json") @@ -97,7 +97,7 @@ class WorkspaceDocumentLinksTest extends LanguageServerBaseTest { class WorkspaceLinkHandler(rootFolder: String, mainFile: Option[String]) { val clientNotifier = new MockDiagnosticClientNotifier() - val telemetryManager: TelemetryManager = new TelemetryManager(clientNotifier, logger) + val telemetryManager: TelemetryManager = new TelemetryManager(clientNotifier) val workspaceManager: WorkspaceManager = { val editorConfiguration = EditorConfiguration() @@ -105,8 +105,7 @@ class WorkspaceDocumentLinksTest extends LanguageServerBaseTest { val defaultProjectConfigurationProvider = new DefaultProjectConfigurationProvider( container, - editorConfiguration, - logger + editorConfiguration ) WorkspaceManager( container, @@ -115,13 +114,12 @@ class WorkspaceDocumentLinksTest extends LanguageServerBaseTest { defaultProjectConfigurationProvider, Nil, Nil, - logger, factory.configurationManager ) } val documentLinksManager: DocumentLinksManager = - new DocumentLinksManager(workspaceManager, telemetryManager, logger) + new DocumentLinksManager(workspaceManager, telemetryManager) def init(): Future[Unit] = workspaceManager diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceManagerSymbolTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceManagerSymbolTest.scala index 16876f53d3..e345787bdf 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceManagerSymbolTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceManagerSymbolTest.scala @@ -43,7 +43,7 @@ class WorkspaceManagerSymbolTest extends LanguageServerBaseTest { val diagnosticClientNotifier = new MockDiagnosticClientNotifier val factory: WorkspaceManagerFactory = - new WorkspaceManagerFactoryBuilder(diagnosticClientNotifier, logger) + new WorkspaceManagerFactoryBuilder(diagnosticClientNotifier) .buildWorkspaceManagerFactory() withServer[Assertion](buildServer(factory)) { server => testStructureForFile(server, s"${filePath("ws1")}/api.raml") @@ -55,7 +55,7 @@ class WorkspaceManagerSymbolTest extends LanguageServerBaseTest { val diagnosticClientNotifier = new MockDiagnosticClientNotifier val factory: WorkspaceManagerFactory = - new WorkspaceManagerFactoryBuilder(diagnosticClientNotifier, logger) + new WorkspaceManagerFactoryBuilder(diagnosticClientNotifier) .buildWorkspaceManagerFactory() withServer[Assertion](buildServer(factory)) { server => testStructureForFile(server, s"${filePath("ws1")}/sub/type.raml") @@ -67,7 +67,7 @@ class WorkspaceManagerSymbolTest extends LanguageServerBaseTest { val diagnosticClientNotifier = new MockDiagnosticClientNotifier val factory: WorkspaceManagerFactory = - new WorkspaceManagerFactoryBuilder(diagnosticClientNotifier, logger) + new WorkspaceManagerFactoryBuilder(diagnosticClientNotifier) .buildWorkspaceManagerFactory() withServer[Assertion](buildServer(factory)) { server => testStructureForFile(server, s"${filePath("ws1")}/independent.raml") diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceManagerTelemetryTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceManagerTelemetryTest.scala index 2e0edc5b65..79c6aa2719 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceManagerTelemetryTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceManagerTelemetryTest.scala @@ -200,7 +200,7 @@ class WorkspaceManagerTelemetryTest extends LanguageServerBaseTest { } def buildServer(notifier: ClientNotifier): LanguageServer = { - val builder = new WorkspaceManagerFactoryBuilder(notifier, logger) + val builder = new WorkspaceManagerFactoryBuilder(notifier) val dm = builder.buildDiagnosticManagers() val factory = builder.buildWorkspaceManagerFactory() val b = new LanguageServerBuilder( diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceManagerTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceManagerTest.scala index 22d3c6850d..646cfdadc6 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceManagerTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceManagerTest.scala @@ -38,7 +38,6 @@ class WorkspaceManagerTest extends LanguageServerBaseTest { val builder = new WorkspaceManagerFactoryBuilder( diagnosticClientNotifier, - logger, EditorConfiguration.withPlatformLoaders(Seq(fakeRl)) ) diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceManagerWithoutDiagnosticsTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceManagerWithoutDiagnosticsTest.scala index a637c99236..e8750027df 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceManagerWithoutDiagnosticsTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceManagerWithoutDiagnosticsTest.scala @@ -22,7 +22,7 @@ class WorkspaceManagerWithoutDiagnosticsTest extends LanguageServerBaseTest with val diagnosticClientNotifier = new MockDiagnosticClientNotifier val factory: WorkspaceManagerFactory = - new WorkspaceManagerFactoryBuilder(diagnosticClientNotifier, logger).buildWorkspaceManagerFactory() + new WorkspaceManagerFactoryBuilder(diagnosticClientNotifier).buildWorkspaceManagerFactory() val changedFragment = """#%RAML 1.0 DataType diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceParserRepositoryTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceParserRepositoryTest.scala index 74c1548d4c..f99fb71ba2 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceParserRepositoryTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/WorkspaceParserRepositoryTest.scala @@ -3,7 +3,6 @@ package org.mulesoft.als.server.workspace import amf.core.client.scala.AMFResult import amf.core.client.scala.model.document.BaseUnit import amf.core.internal.unsafe.PlatformSecrets -import org.mulesoft.als.logger.EmptyLogger import org.mulesoft.als.server.modules.workspace.{ParsedUnit, WorkspaceParserRepository} import org.mulesoft.amfintegration.amfconfiguration.{ ALSConfigurationState, @@ -134,7 +133,7 @@ class WorkspaceParserRepositoryTest extends AsyncFunSuite with Matchers with Pla for { aLSConfigurationState <- configWithRL(files) repository <- Future { - val r = new WorkspaceParserRepository(EmptyLogger) + val r = new WorkspaceParserRepository() r } r <- Future @@ -154,7 +153,7 @@ class WorkspaceParserRepositoryTest extends AsyncFunSuite with Matchers with Pla def makeRepositoryTree(files: Set[MockFile], mainFile: MockFile): Future[WorkspaceParserRepository] = { for { globalConfiguration <- configWithRL(files) - repository <- Future { new WorkspaceParserRepository(EmptyLogger) } + repository <- Future { new WorkspaceParserRepository() } _ <- globalConfiguration .parse(mainFile.uri) .flatMap(bu => repository.newTree(bu)) diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/codeactions/CodeActionsTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/codeactions/CodeActionsTest.scala index bfb14fd73c..ffc4668ebd 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/codeactions/CodeActionsTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/codeactions/CodeActionsTest.scala @@ -38,7 +38,6 @@ trait CodeActionsTest extends LanguageServerBaseTest { val factory = new WorkspaceManagerFactoryBuilder( new MockDiagnosticClientNotifier, - logger, EditorConfiguration.withPlatformLoaders(Seq(rs)) ) .buildWorkspaceManagerFactory() diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/fileusage/ServerFileUsageTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/fileusage/ServerFileUsageTest.scala index 764e60216e..fba3d9e7bb 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/fileusage/ServerFileUsageTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/fileusage/ServerFileUsageTest.scala @@ -40,7 +40,6 @@ trait ServerFileUsageTest extends LanguageServerBaseTest { val factory = new WorkspaceManagerFactoryBuilder( new MockDiagnosticClientNotifier, - logger, EditorConfiguration.withPlatformLoaders(Seq(rs)) ) .buildWorkspaceManagerFactory() diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/highlights/DocumentHighlightTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/highlights/DocumentHighlightTest.scala index 838c0f218d..779278dc0f 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/highlights/DocumentHighlightTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/highlights/DocumentHighlightTest.scala @@ -2,7 +2,6 @@ package org.mulesoft.als.server.workspace.highlights import amf.core.client.common.remote.Content import amf.core.client.scala.resource.ResourceLoader -import org.mulesoft.als.logger.EmptyLogger import org.mulesoft.als.server.MockDiagnosticClientNotifier import org.mulesoft.als.server.client.scala.LanguageServerBuilder import org.mulesoft.als.server.modules.WorkspaceManagerFactoryBuilder @@ -252,7 +251,6 @@ class DocumentHighlightTest extends AsyncFreeSpecLike { val factory = new WorkspaceManagerFactoryBuilder( new MockDiagnosticClientNotifier, - EmptyLogger, EditorConfiguration.withPlatformLoaders(Seq(rs)) ) .buildWorkspaceManagerFactory() diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/rename/RenameFileReferencesTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/rename/RenameFileReferencesTest.scala index 8d0c6c4b7a..81f757345e 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/rename/RenameFileReferencesTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/workspace/rename/RenameFileReferencesTest.scala @@ -129,7 +129,6 @@ class RenameFileReferencesTest extends LanguageServerBaseTest { val factory = new WorkspaceManagerFactoryBuilder( new MockDiagnosticClientNotifier, - logger, EditorConfiguration.withPlatformLoaders(Seq(rl)) ) .buildWorkspaceManagerFactory() diff --git a/dependencies.properties b/dependencies.properties index d9c1753cb3..bdb1ebd977 100644 --- a/dependencies.properties +++ b/dependencies.properties @@ -1,5 +1,5 @@ -version=6.0.0 -amf=5.4.1 +version=6.0.1 +amf=5.4.2 amf.custom-validator.js=1.4.0 -amf.custom-validator-scalajs=0.5.1 +amf.custom-validator-scalajs=0.5.2 amf-antlr-parsers=0.7.25