Refactor messages sending

This commit is contained in:
Alexey Tsvetkov
2017-01-12 16:16:56 +03:00
parent e44cc43ada
commit 16352ff2e5
21 changed files with 411 additions and 401 deletions
@@ -22,7 +22,9 @@ import java.io.Serializable
open class CompilationOptions(
val compilerMode: CompileService.CompilerMode,
val targetPlatform: CompileService.TargetPlatform,
val reportingFilters: List<ReportingFilter>
val reportCategories: Array<Int>,
val reportSeverity: Int,
val requestedCompilationResults: Array<Int>
) : Serializable {
companion object {
const val serialVersionUID: Long = 0
@@ -38,8 +40,10 @@ class IncrementalCompilationOptions(
val customCacheVersion: Int,
compilerMode: CompileService.CompilerMode,
targetPlatform: CompileService.TargetPlatform,
reportingFilters: List<ReportingFilter>
) : CompilationOptions(compilerMode, targetPlatform, reportingFilters) {
reportedCategories: Array<Int>,
reportedSeverity: Int,
requestedCompilationResults: Array<Int>
) : CompilationOptions(compilerMode, targetPlatform, reportedCategories, reportedSeverity, requestedCompilationResults) {
companion object {
const val serialVersionUID: Long = 0
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,12 +17,14 @@
package org.jetbrains.kotlin.daemon.common
import java.io.Serializable
import java.rmi.Remote
import java.rmi.RemoteException
/**
* Allows daemon clients to specify report category and severities for that category that should be reported from daemon
*/
data class ReportingFilter(val category: ReportCategory, val severities: List<Int>) : Serializable {
companion object {
const val serialVersionUID: Long = 0
}
interface CompilationResultsStorage : Remote {
@Throws(RemoteException::class)
fun store(compilationResult: Int, value: Serializable)
}
enum class CompilationResult(val code: Int) {
IC_COMPILE_ITERATION(0)
}
@@ -138,7 +138,8 @@ interface CompileService : Remote {
sessionId: Int,
compilerArguments: CommonCompilerArguments,
compilationOptions: CompilationOptions,
servicesFacade: CompilerServicesFacadeBase
servicesFacade: CompilerServicesFacadeBase,
compilationResultsStorage: CompilationResultsStorage?
): CallResult<Int>
@Throws(RemoteException::class)
@@ -16,7 +16,8 @@
package org.jetbrains.kotlin.daemon.common
import java.io.File
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import java.io.Serializable
import java.rmi.Remote
import java.rmi.RemoteException
@@ -26,29 +27,43 @@ interface CompilerServicesFacadeBase : Remote {
* Reports different kind of diagnostic messages from compile daemon to compile daemon clients (jps, gradle, ...)
*/
@Throws(RemoteException::class)
fun report(category: ReportCategory, severity: Int, message: String?, attachment: Serializable?)
fun report(category: Int, severity: Int, message: String?, attachment: Serializable?)
}
interface IncrementalCompilerServicesFacade : CompilerServicesFacadeBase {
// AnnotationFileUpdater
@Throws(RemoteException::class)
fun hasAnnotationsFileUpdater(): Boolean
enum class ReportCategory(val code: Int) {
COMPILER_MESSAGE(0),
DAEMON_MESSAGE(1),
IC_MESSAGE(2),
OUTPUT_MESSAGE(3);
@Throws(RemoteException::class)
fun updateAnnotations(outdatedClassesJvmNames: Iterable<String>)
companion object {
fun fromCode(code: Int): ReportCategory? =
ReportCategory.values().firstOrNull { it.code == code }
@Throws(RemoteException::class)
fun revert()
// ChangesRegistry
@Throws(RemoteException::class)
fun registerChanges(timestamp: Long, dirtyData: SimpleDirtyData)
@Throws(RemoteException::class)
fun unknownChanges(timestamp: Long)
@Throws(RemoteException::class)
fun getChanges(artifact: File, sinceTS: Long): Iterable<SimpleDirtyData>?
}
}
interface JpsCompilerServicesFacade : CompilerServicesFacadeBase, CompilerCallbackServicesFacade
enum class ReportSeverity(val code: Int) {
ERROR(0),
WARNING(1),
INFO(2),
DEBUG(3);
companion object {
fun fromCode(code: Int): ReportSeverity? =
ReportSeverity.values().firstOrNull { it.code == code }
}
}
fun CompilerServicesFacadeBase.report(category: ReportCategory, severity: ReportSeverity, message: String? = null, attachment: Serializable? = null) {
report(category.code, severity.code, message, attachment)
}
data class CompilerMessageAttachment(
val severity: CompilerMessageSeverity,
val location: CompilerMessageLocation
) : Serializable {
companion object {
const val serialVersionUID = 0L
}
}
@@ -0,0 +1,42 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.daemon.common
import java.io.File
import java.rmi.RemoteException
interface IncrementalCompilerServicesFacade : CompilerServicesFacadeBase {
// AnnotationFileUpdater
@Throws(RemoteException::class)
fun hasAnnotationsFileUpdater(): Boolean
@Throws(RemoteException::class)
fun updateAnnotations(outdatedClassesJvmNames: Iterable<String>)
@Throws(RemoteException::class)
fun revert()
// ChangesRegistry
@Throws(RemoteException::class)
fun registerChanges(timestamp: Long, dirtyData: SimpleDirtyData)
@Throws(RemoteException::class)
fun unknownChanges(timestamp: Long)
@Throws(RemoteException::class)
fun getChanges(artifact: File, sinceTS: Long): Iterable<SimpleDirtyData>?
}
@@ -0,0 +1,19 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.daemon.common
interface JpsCompilerServicesFacade : CompilerServicesFacadeBase, CompilerCallbackServicesFacade
@@ -1,40 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.daemon.common
import java.io.Serializable
enum class ReportCategory : Serializable {
/**
* Messages from compiler
* For related severities see [org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity]
*/
COMPILER_MESSAGE,
/**
* Messages from compile daemon
* For related severities see [org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity]
*/
DAEMON_MESSAGE,
/**
* For related severities see [org.jetbrains.kotlin.daemon.incremental.IncrementalCompilationSeverity]
*/
INCREMENTAL_COMPILATION;
companion object {
const val serialVersionUID: Long = 0
}
}