kotlin speedup: specify return type for public/protected APIs

This commit is contained in:
Sergey Ignatov
2018-05-24 19:18:52 +03:00
parent fe90aaa71d
commit 326e27212e
57 changed files with 202 additions and 207 deletions
@@ -149,7 +149,7 @@ abstract class BaseRepositoryManager(protected val dir: Path) : RepositoryManage
protected abstract fun deleteFromIndex(path: String, isFile: Boolean)
override fun has(path: String) = lock.read { dir.resolve(path).exists() }
override fun has(path: String): Boolean = lock.read { dir.resolve(path).exists() }
}
var conflictResolver: ((files: List<VirtualFile>, mergeProvider: MergeProvider2) -> Unit)? = null
@@ -180,13 +180,13 @@ class RepositoryVirtualFile(private val path: String) : LightVirtualFile(PathUti
var byteContent: ByteArray? = null
private set
override fun getPath() = path
override fun getPath(): String = path
override fun setBinaryContent(content: ByteArray, newModificationStamp: Long, newTimeStamp: Long, requestor: Any?) {
this.byteContent = content
}
override fun getOutputStream(requestor: Any?, newModificationStamp: Long, newTimeStamp: Long) = throw IllegalStateException("You must use setBinaryContent")
override fun getOutputStream(requestor: Any?, newModificationStamp: Long, newTimeStamp: Long): Nothing = throw IllegalStateException("You must use setBinaryContent")
override fun setContent(requestor: Any?, content: CharSequence, fireEvent: Boolean) = throw IllegalStateException("You must use setBinaryContent")
override fun setContent(requestor: Any?, content: CharSequence, fireEvent: Boolean): Nothing = throw IllegalStateException("You must use setBinaryContent")
}
@@ -11,7 +11,7 @@ import com.intellij.ide.passwordSafe.PasswordSafe
* Also, if you remove password from keychain, ssh-agent will continue to use cached password.
*/
class IcsCredentialsStore {
fun get(host: String?, sshKeyFile: String?, accountName: String?) = CredentialAttributes(host, sshKeyFile, accountName)?.let { PasswordSafe.instance.get(it) }
fun get(host: String?, sshKeyFile: String?, accountName: String?): Credentials? = CredentialAttributes(host, sshKeyFile, accountName)?.let { PasswordSafe.instance.get(it) }
fun set(host: String?, sshKeyFile: String?, credentials: Credentials?) {
CredentialAttributes(host, sshKeyFile, credentials?.userName)?.let { PasswordSafe.instance.set(it, credentials) }
@@ -37,13 +37,13 @@ internal val icsManager by lazy(LazyThreadSafetyMode.NONE) {
}
class IcsManager @JvmOverloads constructor(dir: Path, val schemeManagerFactory: Lazy<SchemeManagerFactoryBase> = lazy { (SchemeManagerFactory.getInstance() as SchemeManagerFactoryBase) }) {
val credentialsStore = lazy { IcsCredentialsStore() }
val credentialsStore: Lazy<IcsCredentialsStore> = lazy { IcsCredentialsStore() }
val settingsFile: Path = dir.resolve("config.json")
val settings: IcsSettings
val repositoryManager: RepositoryManager = GitRepositoryManager(credentialsStore, dir.resolve("repository"))
val readOnlySourcesManager = ReadOnlySourceManager(this, dir)
val readOnlySourcesManager: ReadOnlySourceManager = ReadOnlySourceManager(this, dir)
init {
settings = try {
@@ -67,7 +67,7 @@ class IcsManager @JvmOverloads constructor(dir: Path, val schemeManagerFactory:
private @Volatile var autoCommitEnabled = true
@Volatile var repositoryActive = false
@Volatile var repositoryActive: Boolean = false
val active: Boolean
get() = repositoryActive || readOnlySourcesManager.repositories.isNotEmpty()
@@ -111,7 +111,7 @@ class IcsManager @JvmOverloads constructor(dir: Path, val schemeManagerFactory:
// }
// }
fun sync(syncType: SyncType, project: Project? = null, localRepositoryInitializer: (() -> Unit)? = null) = syncManager.sync(syncType, project, localRepositoryInitializer)
fun sync(syncType: SyncType, project: Project? = null, localRepositoryInitializer: (() -> Unit)? = null): Boolean = syncManager.sync(syncType, project, localRepositoryInitializer)
private fun cancelAndDisableAutoCommit() {
if (autoCommitEnabled) {
@@ -196,9 +196,9 @@ class IcsManager @JvmOverloads constructor(dir: Path, val schemeManagerFactory:
}
}
fun doSave(fileSpec: String, content: ByteArray, size: Int, roamingType: RoamingType) = repositoryManager.write(toRepositoryPath(fileSpec, roamingType, projectId), content, size)
fun doSave(fileSpec: String, content: ByteArray, size: Int, roamingType: RoamingType): Boolean = repositoryManager.write(toRepositoryPath(fileSpec, roamingType, projectId), content, size)
protected open fun isAutoCommit(fileSpec: String, roamingType: RoamingType) = true
protected open fun isAutoCommit(fileSpec: String, roamingType: RoamingType): Boolean = true
override fun read(fileSpec: String, roamingType: RoamingType, consumer: (InputStream?) -> Unit): Boolean {
if (!repositoryActive) {
@@ -37,7 +37,7 @@ class MyPrettyPrinter : DefaultPrettyPrinter() {
_arrayIndenter = DefaultPrettyPrinter.NopIndenter.instance
}
override fun createInstance() = MyPrettyPrinter()
override fun createInstance(): MyPrettyPrinter = MyPrettyPrinter()
override fun writeObjectFieldValueSeparator(jg: JsonGenerator) {
jg.writeRaw(": ")
@@ -86,12 +86,12 @@ fun loadSettings(settingsFile: Path): IcsSettings {
@JsonInclude(value = JsonInclude.Include.NON_DEFAULT)
@JsonIgnoreProperties(ignoreUnknown = true)
class IcsSettings {
var shareProjectWorkspace = false
var commitDelay = DEFAULT_COMMIT_DELAY
var doNoAskMapProject = false
var shareProjectWorkspace: Boolean = false
var commitDelay: Int = DEFAULT_COMMIT_DELAY
var doNoAskMapProject: Boolean = false
var readOnlySources: List<ReadonlySource> = SmartList()
var autoSync = true
var autoSync: Boolean = true
}
@JsonInclude(value = JsonInclude.Include.NON_DEFAULT)
@@ -88,15 +88,15 @@ interface UpdateResult {
val deleted: Collection<String>
}
val EMPTY_UPDATE_RESULT = ImmutableUpdateResult(Collections.emptySet(), Collections.emptySet())
val EMPTY_UPDATE_RESULT: ImmutableUpdateResult = ImmutableUpdateResult(Collections.emptySet(), Collections.emptySet())
data class ImmutableUpdateResult(override val changed: Collection<String>, override val deleted: Collection<String>) : UpdateResult {
fun toMutable(): MutableUpdateResult = MutableUpdateResult(changed, deleted)
}
class MutableUpdateResult(changed: Collection<String>, deleted: Collection<String>) : UpdateResult {
override val changed = THashSet(changed)
override val deleted = THashSet(deleted)
override val changed: THashSet<String> = THashSet(changed)
override val deleted: THashSet<String> = THashSet(deleted)
fun add(result: UpdateResult?): MutableUpdateResult {
if (result != null) {
@@ -66,14 +66,14 @@ class CommitToIcsAction : CommonCheckinFilesAction() {
}
}
override fun getActionName(dataContext: VcsContext) = icsMessage("action.CommitToIcs.text")
override fun getActionName(dataContext: VcsContext): String = icsMessage("action.CommitToIcs.text")
override fun isApplicableRoot(file: VirtualFile, status: FileStatus, dataContext: VcsContext): Boolean {
val project = dataContext.project
return project is ProjectEx && project.stateStore.storageScheme == StorageScheme.DIRECTORY_BASED && super.isApplicableRoot(file, status, dataContext) && !file.isDirectory && isProjectConfigFile(file, dataContext.project!!)
}
override fun prepareRootsForCommit(roots: Array<FilePath>, project: Project) = roots
override fun prepareRootsForCommit(roots: Array<FilePath>, project: Project): Array<FilePath> = roots
override fun performCheckIn(context: VcsContext, project: Project, roots: Array<out FilePath>) {
val projectId = getProjectId(project) ?: return
@@ -30,11 +30,11 @@ interface CommitMessageFormatter {
}
class IdeaCommitMessageFormatter : CommitMessageFormatter {
override fun message(text: String) = StringBuilder().appendCommitOwnerInfo().append(text).toString()
override fun message(text: String): String = StringBuilder().appendCommitOwnerInfo().append(text).toString()
override fun prependMessage(builder: StringBuilder) = builder.appendCommitOwnerInfo()
override fun prependMessage(builder: StringBuilder): StringBuilder = builder.appendCommitOwnerInfo()
override fun mergeMessage(refsToMerge: List<Ref>, target: Ref) = StringBuilder().appendCommitOwnerInfo().append(super.mergeMessage(refsToMerge, target)).toString()
override fun mergeMessage(refsToMerge: List<Ref>, target: Ref): String = StringBuilder().appendCommitOwnerInfo().append(super.mergeMessage(refsToMerge, target)).toString()
fun StringBuilder.appendCommitOwnerInfo(avoidAppInfoInstantiation: Boolean = false): StringBuilder {
if (avoidAppInfoInstantiation) {
+2 -2
View File
@@ -183,7 +183,7 @@ fun cloneBare(uri: String, dir: Path, credentialsStore: Lazy<IcsCredentialsStore
config.save()
}
val commit = RevWalk(repository).use { it.parseCommit(head!!.objectId) }
val commit = RevWalk(repository).use { it.parseCommit(head.objectId) }
val u = repository.updateRef(Constants.HEAD, !head.name.startsWith(Constants.R_HEADS))
u.setNewObjectId(commit.id)
u.forceUpdate()
@@ -376,7 +376,7 @@ fun buildRepository(workTree: Path? = null, bare: Boolean = false, gitDir: Path?
}
}
fun buildBareRepository(gitDir: Path) = buildRepository(bare = true, gitDir = gitDir)
fun buildBareRepository(gitDir: Path): Repository = buildRepository(bare = true, gitDir = gitDir)
fun createBareRepository(dir: Path): Repository {
val repository = buildRepository(bare = true, gitDir = dir)
@@ -87,7 +87,7 @@ class GitRepositoryManager(private val credentialsStore: Lazy<IcsCredentialsStor
}
}
override fun getUpstream() = repository.upstream
override fun getUpstream(): String? = repository.upstream
override fun setUpstream(url: String?, branch: String?) {
repository.setUpstream(url, branch ?: Constants.MASTER)
@@ -103,7 +103,7 @@ class GitRepositoryManager(private val credentialsStore: Lazy<IcsCredentialsStor
}
}
override fun hasUpstream() = getUpstream() != null
override fun hasUpstream(): Boolean = getUpstream() != null
override fun addToIndex(file: Path, path: String, content: ByteArray, size: Int) {
repository.edit(AddLoadedFile(path, content, size, file.lastModified().toMillis()))
@@ -149,7 +149,7 @@ class GitRepositoryManager(private val credentialsStore: Lazy<IcsCredentialsStor
}
}
override fun getAheadCommitsCount() = repository.getAheadCommitsCount()
override fun getAheadCommitsCount(): Int = repository.getAheadCommitsCount()
override fun push(indicator: ProgressIndicator?) {
LOG.debug("Push")
@@ -218,13 +218,13 @@ class GitRepositoryManager(private val credentialsStore: Lazy<IcsCredentialsStor
}
}
override fun pull(indicator: ProgressIndicator?) = Pull(this, indicator).pull()
override fun pull(indicator: ProgressIndicator?): UpdateResult? = Pull(this, indicator).pull()
override fun resetToTheirs(indicator: ProgressIndicator) = Reset(this, indicator).reset(true)
override fun resetToTheirs(indicator: ProgressIndicator): UpdateResult = Reset(this, indicator).reset(true)
override fun resetToMy(indicator: ProgressIndicator, localRepositoryInitializer: (() -> Unit)?) = Reset(this, indicator).reset(false, localRepositoryInitializer)
override fun resetToMy(indicator: ProgressIndicator, localRepositoryInitializer: (() -> Unit)?): UpdateResult = Reset(this, indicator).reset(false, localRepositoryInitializer)
override fun canCommit() = repository.repositoryState.canCommit()
override fun canCommit(): Boolean = repository.repositoryState.canCommit()
fun renameDirectory(pairs: Map<String, String?>, commitMessage: String): Boolean {
var addCommand: AddCommand? = null
@@ -283,7 +283,7 @@ class GitRepositoryManager(private val credentialsStore: Lazy<IcsCredentialsStor
val file = dir.resolve(Constants.DOT_GIT_IGNORE)
if (file.exists()) {
node = IgnoreNode()
file.inputStream().use { node!!.parse(it) }
file.inputStream().use { node.parse(it) }
ignoreRules = node
}
}
@@ -40,7 +40,7 @@ class JGitCredentialsProvider(private val credentialsStore: Lazy<IcsCredentialsS
override fun load(it: URIish) = getCredentialsUsingGit(it, repository) ?: Credentials(null)
})
override fun isInteractive() = true
override fun isInteractive(): Boolean = true
override fun supports(vararg items: CredentialItem): Boolean {
for (item in items) {
@@ -62,7 +62,7 @@ class JGitMergeProvider<T>(private val repository: Repository, private val confl
repository.writePath(file.path, bytes, size)
}
override fun isBinary(file: VirtualFile) = file.fileType.isBinary
override fun isBinary(file: VirtualFile): Boolean = file.fileType.isBinary
override fun loadRevisions(file: VirtualFile): MergeData {
val path = file.path
@@ -20,7 +20,7 @@ import com.intellij.openapi.progress.ProgressIndicator
import org.eclipse.jgit.lib.NullProgressMonitor
import org.eclipse.jgit.lib.ProgressMonitor
fun ProgressIndicator?.asProgressMonitor() = if (this == null || this is EmptyProgressIndicator) NullProgressMonitor.INSTANCE else JGitProgressMonitor(this)
fun ProgressIndicator?.asProgressMonitor(): ProgressMonitor = if (this == null || this is EmptyProgressIndicator) NullProgressMonitor.INSTANCE else JGitProgressMonitor(this)
private class JGitProgressMonitor(private val indicator: ProgressIndicator) : ProgressMonitor {
override fun start(totalTasks: Int) {
@@ -184,15 +184,15 @@ class AddLoadedFile(path: String, private val content: ByteArray, private val si
}
}
fun DeleteFile(path: String) = DeleteFile(encodePath(path))
fun DeleteFile(path: String): DeleteFile = DeleteFile(encodePath(path))
class DeleteFile(path: ByteArray) : PathEditBase(path) {
override fun apply(entry: DirCacheEntry, repository: Repository) = throw UnsupportedOperationException(JGitText.get().noApplyInDelete)
override fun apply(entry: DirCacheEntry, repository: Repository): Nothing = throw UnsupportedOperationException(JGitText.get().noApplyInDelete)
}
class DeleteDirectory(entryPath: String) : PathEditBase(
encodePath(if (entryPath.endsWith('/') || entryPath.isEmpty()) entryPath else "$entryPath/")) {
override fun apply(entry: DirCacheEntry, repository: Repository) = throw UnsupportedOperationException(JGitText.get().noApplyInDelete)
override fun apply(entry: DirCacheEntry, repository: Repository): Nothing = throw UnsupportedOperationException(JGitText.get().noApplyInDelete)
}
fun Repository.edit(edit: PathEdit) {
@@ -28,19 +28,19 @@ typealias IgnoredFeatureInfo = Set<String>
object FeatureUtils {
const val UNDEFINED = "UNDEFINED"
const val INVALID_CACHE = "INVALID_CACHE"
const val UNDEFINED: String = "UNDEFINED"
const val INVALID_CACHE: String = "INVALID_CACHE"
const val OTHER = "OTHER"
const val NONE = "NONE"
const val OTHER: String = "OTHER"
const val NONE: String = "NONE"
const val ML_RANK = "ml_rank"
const val BEFORE_ORDER = "before_rerank_order"
const val ML_RANK: String = "ml_rank"
const val BEFORE_ORDER: String = "before_rerank_order"
const val DEFAULT = "default"
const val DEFAULT: String = "default"
fun getOtherCategoryFeatureName(name: String) = "$name=$OTHER"
fun getUndefinedFeatureName(name: String) = "$name=$UNDEFINED"
fun getOtherCategoryFeatureName(name: String): String = "$name=$OTHER"
fun getUndefinedFeatureName(name: String): String = "$name=$UNDEFINED"
fun prepareRevelanceMap(relevance: List<Pair<String, Any?>>, position: Int, prefixLength: Int, elementLength: Int)
: Map<String, Any> {
@@ -22,8 +22,8 @@ class ElementPositionHistory(history: List<StagePosition>) {
private val history = history.toMutableList()
fun add(position: StagePosition) = history.add(position)
fun history() = history
fun add(position: StagePosition): Boolean = history.add(position)
fun history(): List<StagePosition> = history
}
@@ -28,11 +28,11 @@ abstract class LogEvent(
@Transient var actionType: Action
) {
@Transient var recorderId = "completion-stats"
@Transient var recorderVersion = "4"
@Transient var timestamp = System.currentTimeMillis()
@Transient var bucket = "-1"
var validationStatus = ValidationStatus.UNKNOWN
@Transient var recorderId: String = "completion-stats"
@Transient var recorderVersion: String = "4"
@Transient var timestamp: Long = System.currentTimeMillis()
@Transient var bucket: String = "-1"
var validationStatus: ValidationStatus = ValidationStatus.UNKNOWN
abstract fun accept(visitor: LogEventVisitor)
}
@@ -23,15 +23,15 @@ import org.jetbrains.annotations.TestOnly
class CompletionValidationState(event: CompletionStartedEvent) : LogEventVisitor() {
val allCompletionItemIds: MutableList<Int> = event.newCompletionListItems.map { it.id }.toMutableList()
var currentPosition = event.currentPosition
var completionList = event.completionListIds
var currentId = getSafeCurrentId(completionList, currentPosition)
var currentPosition: Int = event.currentPosition
var completionList: List<Int> = event.completionListIds
var currentId: Int = getSafeCurrentId(completionList, currentPosition)
private var isValid = true
private var isFinished = false
private var errorMessage = ""
var events = mutableListOf<LogEvent>(event)
private var events = mutableListOf<LogEvent>(event)
private fun updateState(nextEvent: LookupStateLogData) {
currentPosition = nextEvent.currentPosition
@@ -36,8 +36,8 @@ class InvocationCountEnhancingContributor : CompletionContributor() {
companion object {
private const val MAX_INVOCATION_COUNT = 5
var RUN_COMPLETION_AFTER_CHARS = 2
var isEnabledInTests = false
var RUN_COMPLETION_AFTER_CHARS: Int = 2
var isEnabledInTests: Boolean = false
}
override fun fillCompletionVariants(parameters: CompletionParameters, result: CompletionResultSet) {
@@ -61,10 +61,10 @@ class ContributorsTimeStatistics : PersistentStateComponent<CompletionTimeStats>
}
}
fun languages() = (completionIntervals.keys + secondCompletionIntervals.keys).toList()
fun languages(): List<Language> = (completionIntervals.keys + secondCompletionIntervals.keys).toList()
fun intervals(languge: Language) = completionIntervals[languge]
fun secondCompletionIntervals(languge: Language) = secondCompletionIntervals[languge]
fun intervals(languge: Language): IntervalCounter? = completionIntervals[languge]
fun secondCompletionIntervals(languge: Language): IntervalCounter? = secondCompletionIntervals[languge]
fun registerCompletionContributorsTime(languge: Language, timeTaken: Long) {
val interval = completionIntervals[languge] ?: IntervalCounter(MIN_POWER, MAX_POWER, EXPONENT)
@@ -83,7 +83,7 @@ class ContributorsTimeStatistics : PersistentStateComponent<CompletionTimeStats>
private val MAX_POWER = 17
private val EXPONENT = 2.0
fun getInstance() = service<ContributorsTimeStatistics>()
fun getInstance(): ContributorsTimeStatistics = service<ContributorsTimeStatistics>()
}
}
@@ -44,7 +44,7 @@ class UserDataLookupElementPositionTracker : LookupElementPositionTracker {
companion object {
private val KEY = Key.create<MutableMap<String, ElementPositionHistory>>("lookup.element.position.history")
fun history(lookup: LookupImpl) = lookup.getUserData(KEY)
fun history(lookup: LookupImpl): MutableMap<String, ElementPositionHistory>? = lookup.getUserData(KEY)
fun addElementPosition(lookup: LookupImpl, element: LookupElement, stagePosition: StagePosition) {
lookup.putUserDataIfAbsent(KEY, mutableMapOf())
@@ -24,8 +24,8 @@ import com.intellij.stats.completion.StagePosition
class PositionTrackingListener(private val lookup: LookupImpl): PrefixChangeListener {
private var stage = 0
override fun beforeAppend(c: Char) = update()
override fun beforeTruncate() = update()
override fun beforeAppend(c: Char): Unit = update()
override fun beforeTruncate(): Unit = update()
private fun update() {
lookup.items.forEachIndexed { index, lookupElement ->
@@ -18,7 +18,7 @@ package com.intellij.reporting
import com.intellij.openapi.application.ApplicationManager
class AllowedOnlyInEAP : DataSendPermission {
override fun isDataSendAllowed() = ApplicationManager.getApplication().isEAP
override fun isDataSendAllowed(): Boolean = ApplicationManager.getApplication().isEAP
}
fun isSendAllowed(): Boolean {
@@ -53,9 +53,9 @@ class TimingStatState {
}
@JvmField val totalSortsByTime = MutableList(size, { 0 })
@JvmField val avgSortingTimeByN = MutableList(size, { 0.0 })
@JvmField val totalSortsByN = MutableList(size, { 0 })
@JvmField val totalSortsByTime: MutableList<Int> = MutableList(size, { 0 })
@JvmField val avgSortingTimeByN: MutableList<Double> = MutableList(size, { 0.0 })
@JvmField val totalSortsByN: MutableList<Int> = MutableList(size, { 0 })
fun registerSortTiming(elementsSorted: Int, timeSpentMillis: Long) {
@@ -23,7 +23,7 @@ abstract class CompletionLoggerProvider {
abstract fun newCompletionLogger(): CompletionLogger
open fun dispose() = Unit
open fun dispose(): Unit = Unit
companion object {
fun getInstance(): CompletionLoggerProvider = ServiceManager.getService(CompletionLoggerProvider::class.java)
@@ -26,12 +26,12 @@ interface CompletionPopupListener {
fun beforeCharTyped(c: Char)
class Adapter: CompletionPopupListener {
override fun beforeDownPressed() = Unit
override fun downPressed() = Unit
override fun beforeUpPressed() = Unit
override fun upPressed() = Unit
override fun afterBackspacePressed() = Unit
override fun beforeBackspacePressed() = Unit
override fun beforeCharTyped(c: Char) = Unit
override fun beforeDownPressed(): Unit = Unit
override fun downPressed(): Unit = Unit
override fun beforeUpPressed(): Unit = Unit
override fun upPressed(): Unit = Unit
override fun afterBackspacePressed(): Unit = Unit
override fun beforeBackspacePressed(): Unit = Unit
override fun beforeCharTyped(c: Char): Unit = Unit
}
}
@@ -37,7 +37,7 @@ class CompletionTrackerInitializer(experimentHelper: WebServiceStatus): Applicat
companion object {
// Log only 10% of all completion sessions
private const val SKIP_SESSIONS_BEFORE_LOG_IN_EAP = 10
var isEnabledInTests = false
var isEnabledInTests: Boolean = false
}
private var loggingStrategy: LoggingStrategy = if (isEAP()) LogEachN(SKIP_SESSIONS_BEFORE_LOG_IN_EAP) else LogAllSessions
@@ -23,5 +23,5 @@ interface InstallationIdProvider {
}
class PermanentInstallationIdProvider: InstallationIdProvider {
override fun installationId() = PermanentInstallationID.get()
override fun installationId(): String = PermanentInstallationID.get()
}
@@ -32,8 +32,8 @@ class TimeBetweenTypingTracker(private val project: Project) : PrefixChangeListe
private var lastTypingTime: Long = -1L
override fun beforeAppend(c: Char) = prefixChanged()
override fun beforeTruncate() = prefixChanged()
override fun beforeAppend(c: Char): Unit = prefixChanged()
override fun beforeTruncate(): Unit = prefixChanged()
private fun prefixChanged() {
if (lastTypingTime == -1L) {
@@ -29,7 +29,7 @@ class WebServiceStatusProvider(
): WebServiceStatus {
companion object {
val STATUS_URL = "https://www.jetbrains.com/config/features-service-status.json"
val STATUS_URL: String = "https://www.jetbrains.com/config/features-service-status.json"
private val GSON = Gson()
@@ -46,7 +46,7 @@ class WebServiceStatusProvider(
override fun dataServerUrl(): String = dataServerUrl
override fun isExperimentGoingOnNow() = info.performExperiment
override fun isExperimentGoingOnNow(): Boolean = info.performExperiment
override fun isServerOk(): Boolean = serverStatus.equals("ok", ignoreCase = true)
@@ -101,7 +101,7 @@ class SimpleRequestService: RequestService() {
data class ResponseData(val code: Int, val text: String = "") {
fun isOK() = code in 200..299
fun isOK(): Boolean = code in 200..299
}
@@ -25,14 +25,14 @@ import com.jetbrains.completion.feature.DoubleFeature
* @author Vitaliy.Bibaev
*/
object UserFactorDescriptions {
val COMPLETION_TYPE = Descriptor("completionType", ::CompletionTypeUpdater, ::CompletionTypeReader)
val COMPLETION_FINISH_TYPE =
val COMPLETION_TYPE: Descriptor<CompletionTypeUpdater, CompletionTypeReader> = Descriptor("completionType", ::CompletionTypeUpdater, ::CompletionTypeReader)
val COMPLETION_FINISH_TYPE: Descriptor<CompletionFinishTypeUpdater, CompletionFinishTypeReader> =
Descriptor("completionFinishedType", ::CompletionFinishTypeUpdater, ::CompletionFinishTypeReader)
val COMPLETION_USAGE = Descriptor("completionUsage", ::CompletionUsageUpdater, ::CompletionUsageReader)
val PREFIX_LENGTH_ON_COMPLETION = Descriptor("prefixLength", ::PrefixLengthUpdater, ::PrefixLengthReader)
val SELECTED_ITEM_POSITION = Descriptor("itemPosition", ::ItemPositionUpdater, ::ItemPositionReader)
val TIME_BETWEEN_TYPING = Descriptor("timeBetweenTyping", ::TimeBetweenTypingUpdater, ::TimeBetweenTypingReader)
val MNEMONICS_USAGE = Descriptor("mnemonicsUsage", ::MnemonicsUsageUpdater, ::MnemonicsUsageReader)
val COMPLETION_USAGE: Descriptor<CompletionUsageUpdater, CompletionUsageReader> = Descriptor("completionUsage", ::CompletionUsageUpdater, ::CompletionUsageReader)
val PREFIX_LENGTH_ON_COMPLETION: Descriptor<PrefixLengthUpdater, PrefixLengthReader> = Descriptor("prefixLength", ::PrefixLengthUpdater, ::PrefixLengthReader)
val SELECTED_ITEM_POSITION: Descriptor<ItemPositionUpdater, ItemPositionReader> = Descriptor("itemPosition", ::ItemPositionUpdater, ::ItemPositionReader)
val TIME_BETWEEN_TYPING: Descriptor<TimeBetweenTypingUpdater, TimeBetweenTypingReader> = Descriptor("timeBetweenTyping", ::TimeBetweenTypingUpdater, ::TimeBetweenTypingReader)
val MNEMONICS_USAGE: Descriptor<MnemonicsUsageUpdater, MnemonicsUsageReader> = Descriptor("mnemonicsUsage", ::MnemonicsUsageUpdater, ::MnemonicsUsageReader)
fun binaryFeatureDescriptor(feature: BinaryFeature): Descriptor<BinaryFeatureUpdater, BinaryFeatureReader> {
return Descriptor("binaryFeature:${feature.name}", ::BinaryFeatureUpdater, ::BinaryFeatureReader)
@@ -24,7 +24,7 @@ import com.intellij.openapi.util.Key
*/
interface UserFactorsManager {
companion object {
val USER_FACTORS_KEY = Key.create<Map<String, String?>>("com.intellij.stats.personalization.userFactors")
val USER_FACTORS_KEY: Key<Map<String, String?>> = Key.create<Map<String, String?>>("com.intellij.stats.personalization.userFactors")
fun getInstance(project: Project): UserFactorsManager = project.getComponent(UserFactorsManager::class.java)
}
@@ -33,9 +33,9 @@ class CompletionFinishTypeReader(private val factor: DailyAggregatedDoubleFactor
}
class CompletionFinishTypeUpdater(private val factor: MutableDoubleFactor) : FactorUpdater {
fun fireExplicitCompletionPerformed() = factor.incrementOnToday(explicitSelectKey)
fun fireTypedSelectPerformed() = factor.incrementOnToday(typedSelectKey)
fun fireLookupCancelled() = factor.incrementOnToday(cancelledKey)
fun fireExplicitCompletionPerformed(): Boolean = factor.incrementOnToday(explicitSelectKey)
fun fireTypedSelectPerformed(): Boolean = factor.incrementOnToday(typedSelectKey)
fun fireLookupCancelled(): Boolean = factor.incrementOnToday(cancelledKey)
}
@@ -23,9 +23,7 @@ import org.jdom.Element
import java.text.DecimalFormat
import java.util.*
abstract class UserFactorStorageBase
: UserFactorStorage, PersistentStateComponent<Element> {
abstract class UserFactorStorageBase : UserFactorStorage, PersistentStateComponent<Element> {
private companion object {
val DOUBLE_VALUE_FORMATTER = DecimalFormat().apply {
maximumFractionDigits = 6
@@ -88,7 +86,7 @@ abstract class UserFactorStorageBase
}
companion object {
const val DAYS_LIMIT = 10
private const val DAYS_LIMIT = 10
fun restore(element: Element): DailyAggregateFactor? {
val data = sortedMapOf<Day, DailyData>()
@@ -20,7 +20,7 @@ import java.util.*
* @author Vitaliy.Bibaev
*/
object LambdaToAnonymousTransformer : PsiElementTransformer.Base() {
val LOG = Logger.getInstance("#" + LambdaToAnonymousTransformer::class.java.name)
private val LOG = Logger.getInstance("#" + LambdaToAnonymousTransformer::class.java.name)
override val visitor: PsiElementVisitor
get() = object : JavaRecursiveElementVisitor() {
@@ -22,7 +22,7 @@ import java.util.*
*/
abstract class TraceExpressionBuilderBase(protected val dsl: Dsl, private val handlerFactory: HandlerFactory)
: TraceExpressionBuilder {
protected val resultVariableName = "myRes"
protected val resultVariableName: String = "myRes"
override fun createTraceExpression(chain: StreamChain): String {
val intermediateHandlers = chain.intermediateCalls.mapIndexedTo(ArrayList(), handlerFactory::getForIntermediate)
@@ -1,10 +1,7 @@
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.debugger.streams.trace.impl.handler.unified
import com.intellij.debugger.streams.trace.dsl.CodeBlock
import com.intellij.debugger.streams.trace.dsl.Dsl
import com.intellij.debugger.streams.trace.dsl.Expression
import com.intellij.debugger.streams.trace.dsl.VariableDeclaration
import com.intellij.debugger.streams.trace.dsl.*
import com.intellij.debugger.streams.trace.dsl.impl.TextExpression
import com.intellij.debugger.streams.trace.impl.handler.type.GenericType
import com.intellij.debugger.streams.wrapper.IntermediateStreamCall
@@ -14,8 +11,8 @@ import com.intellij.debugger.streams.wrapper.IntermediateStreamCall
*/
open class PeekTraceHandler(num: Int, callName: String, private val myTypeBefore: GenericType, typeAfter: GenericType, dsl: Dsl)
: HandlerBase.Intermediate(dsl) {
val beforeMap = dsl.linkedMap(dsl.types.INT, myTypeBefore, "${callName}Peek${num}Before")
val afterMap = dsl.linkedMap(dsl.types.INT, typeAfter, "${callName}Peek${num}After")
val beforeMap: MapVariable = dsl.linkedMap(dsl.types.INT, myTypeBefore, "${callName}Peek${num}Before")
val afterMap: MapVariable = dsl.linkedMap(dsl.types.INT, typeAfter, "${callName}Peek${num}After")
override fun additionalVariablesDeclaration(): List<VariableDeclaration> =
listOf(beforeMap.defaultDeclaration(), afterMap.defaultDeclaration())
@@ -22,7 +22,7 @@ open class PositionsAwareCollectionView(tree: CollectionTree,
})
}
fun addValuesPositionsListener(listener: ValuesPositionsListener) = myDispatcher.addListener(listener)
fun addValuesPositionsListener(listener: ValuesPositionsListener): Unit = myDispatcher.addListener(listener)
private fun updateValues() {
var changed = false
@@ -9,9 +9,9 @@ import com.intellij.debugger.streams.ui.ValueWithPosition
*/
data class ValueWithPositionImpl(override val traceElement: TraceElement) : ValueWithPosition {
companion object {
val INVALID_POSITION = Int.MIN_VALUE
val DEFAULT_VISIBLE_VALUE = false
val DEFAULT_HIGHLIGHTING_VALUE = false
val INVALID_POSITION: Int = Int.MIN_VALUE
val DEFAULT_VISIBLE_VALUE: Boolean = false
val DEFAULT_HIGHLIGHTING_VALUE: Boolean = false
}
private var myPosition: Int = INVALID_POSITION
@@ -36,7 +36,7 @@ data class ValueWithPositionImpl(override val traceElement: TraceElement) : Valu
fun updateToInvalid(): Boolean =
updateProperties(INVALID_POSITION, DEFAULT_VISIBLE_VALUE, DEFAULT_HIGHLIGHTING_VALUE)
fun setInvalid() =
fun setInvalid(): Unit =
setProperties(INVALID_POSITION, DEFAULT_VISIBLE_VALUE, DEFAULT_HIGHLIGHTING_VALUE)
fun updateProperties(position: Int, isVisible: Boolean, isHighlighted: Boolean): Boolean {
@@ -50,7 +50,7 @@ class IdeaSVNConfigFile(private val myPath: Path) {
return result
}
val defaultGroup get() = DefaultProxyGroup(myDefaultProperties)
val defaultGroup: DefaultProxyGroup get() = DefaultProxyGroup(myDefaultProperties)
@JvmOverloads
fun updateGroups(force: Boolean = false) {
@@ -112,7 +112,7 @@ class IdeaSVNConfigFile(private val myPath: Path) {
addProperties(name, addOrModify)
}
fun save() = try {
fun save(): Unit = try {
_configFile.store(myPath.toFile())
updateGroups(true)
}
@@ -122,14 +122,14 @@ class IdeaSVNConfigFile(private val myPath: Path) {
companion object {
@JvmField
val SERVERS_FILE_NAME = "servers"
val SERVERS_FILE_NAME: String = "servers"
@JvmField
val CONFIG_FILE_NAME = "config"
val CONFIG_FILE_NAME: String = "config"
@JvmField
val DEFAULT_GROUP_NAME = "global"
val DEFAULT_GROUP_NAME: String = "global"
@JvmField
val GROUPS_GROUP_NAME = "groups"
val GROUPS_GROUP_NAME: String = "groups"
@JvmStatic
fun getNewGroupName(host: String, configFile: IdeaSVNConfigFile): String {
@@ -194,10 +194,10 @@ class IdeaSVNConfigFile(private val myPath: Path) {
}
@JvmStatic
fun isTurned(value: String?) = value == null || "yes".equals(value, true) || "on".equals(value, true) || "true".equals(value, true)
fun isTurned(value: String?): Boolean = value == null || "yes".equals(value, true) || "on".equals(value, true) || "true".equals(value, true)
@JvmStatic
fun getValue(files: Couple<IdeaSVNConfigFile>, groupName: String, propertyName: String) =
fun getValue(files: Couple<IdeaSVNConfigFile>, groupName: String, propertyName: String): String? =
files.second.getValue(groupName, propertyName) ?: files.first.getValue(groupName, propertyName)
@JvmStatic
@@ -216,7 +216,7 @@ private class MyIniBuilder(ini: Ini) : IniBuilder() {
setIni(ini)
}
private var isAfterComment = false;
private var isAfterComment = false
override fun startSection(sectionName: String) {
super.startSection(sectionName)
@@ -17,11 +17,11 @@ enum class ErrorCategory(val code: Int) {
AUTHN(19),
AUTHZ(20);
val start = ERROR_BASE + code * ERROR_CATEGORY_SIZE
val start: Int = ERROR_BASE + code * ERROR_CATEGORY_SIZE
companion object {
@JvmStatic
fun categoryCodeOf(errorCode: Int) = (errorCode - ERROR_BASE) / ERROR_CATEGORY_SIZE
fun categoryCodeOf(errorCode: Int): Int = (errorCode - ERROR_BASE) / ERROR_CATEGORY_SIZE
}
}
@@ -54,5 +54,5 @@ enum class ErrorCode(val category: ErrorCategory, val index: Int) {
PROPERTY_NOT_FOUND(MISC, 17),
MERGE_INFO_PARSE_ERROR(MISC, 20);
val code = category.start + index
val code: Int = category.start + index
}
@@ -18,8 +18,8 @@ class Revision private constructor(private val order: Int, val keyword: String?
keyword?.let { ourKeywordRevisions[keyword] = this }
}
val isValid get() = this !== UNDEFINED
val isLocal get() = this === BASE || this === WORKING
val isValid: Boolean get() = this !== UNDEFINED
val isLocal: Boolean get() = this === BASE || this === WORKING
override fun equals(other: Any?): Boolean {
if (this === other) return true
@@ -56,21 +56,21 @@ class Revision private constructor(private val order: Int, val keyword: String?
companion object {
private val ourKeywordRevisions = newHashMap<String, Revision>()
@JvmField val BASE = Revision(2, "BASE")
@JvmField val COMMITTED = Revision(3, "COMMITTED")
@JvmField val HEAD = Revision(0, "HEAD")
@JvmField val PREV = Revision(4, "PREV")
@JvmField val BASE: Revision = Revision(2, "BASE")
@JvmField val COMMITTED: Revision = Revision(3, "COMMITTED")
@JvmField val HEAD: Revision = Revision(0, "HEAD")
@JvmField val PREV: Revision = Revision(4, "PREV")
// TODO: This one should likely be removed - not in the least of svn revision keywords
@JvmField val WORKING = Revision(1, "WORKING")
@JvmField val UNDEFINED = Revision(30, "UNDEFINED")
@JvmField val WORKING: Revision = Revision(1, "WORKING")
@JvmField val UNDEFINED: Revision = Revision(30, "UNDEFINED")
@JvmField val GENERAL_ORDER: Comparator<Revision> = compareByDescending { it.order }
@JvmStatic
fun of(number: Long) = if (number < 0) UNDEFINED else Revision(10, number = number)
fun of(number: Long): Revision = if (number < 0) UNDEFINED else Revision(10, number = number)
@JvmStatic
fun of(date: Date) = Revision(20, date = date)
fun of(date: Date): Revision = Revision(20, date = date)
@JvmStatic
fun parse(value: String?): Revision {
@@ -4,21 +4,21 @@ package org.jetbrains.idea.svn.api
import java.io.File
class Target private constructor(val url: Url?, val file: File?, pegRevision: Revision?) {
val pegRevision = pegRevision ?: Revision.UNDEFINED
val pegRevision: Revision = pegRevision ?: Revision.UNDEFINED
val path: String get() = if (isFile()) file!!.path else url!!.toString()
fun isFile() = file != null
fun isUrl() = url != null
fun isFile(): Boolean = file != null
fun isUrl(): Boolean = url != null
override fun toString() = path + '@' + pegRevision
override fun toString(): String = path + '@' + pegRevision
companion object {
@JvmStatic
@JvmOverloads
fun on(url: Url, pegRevision: Revision? = null) = Target(url, null, pegRevision)
fun on(url: Url, pegRevision: Revision? = null): Target = Target(url, null, pegRevision)
@JvmStatic
@JvmOverloads
fun on(file: File, pegRevision: Revision? = null) = Target(null, file, pegRevision)
fun on(file: File, pegRevision: Revision? = null): Target = Target(null, file, pegRevision)
}
}
@@ -13,13 +13,13 @@ private const val FILE_URL_PREFIX = "file:/"
class Url private constructor(innerUri: URI) {
private val uri = fixDefaultPort(innerUri)
val protocol = uri.scheme.orEmpty()
val host = uri.host.orEmpty()
val port = uri.port
val protocol: String = uri.scheme.orEmpty()
val host: String = uri.host.orEmpty()
val port: Int = uri.port
val userInfo: String? = uri.userInfo
val path = uri.path.orEmpty().removeSuffix("/")
val path: String = uri.path.orEmpty().removeSuffix("/")
val tail get() = path.substringAfterLast('/')
val tail: String get() = path.substringAfterLast('/')
fun commonAncestorWith(url: Url): Url? {
if (protocol != url.protocol || host != url.host || port != url.port || userInfo != url.userInfo) return null
@@ -34,11 +34,11 @@ class Url private constructor(innerUri: URI) {
}
@Throws(SvnBindException::class)
fun appendPath(path: String, encoded: Boolean = true) =
fun appendPath(path: String, encoded: Boolean = true): Url =
if (path.isEmpty() || path == "/") this else wrap { uri.resolve(URI(prepareUri(path.removePrefix("/"), encoded))) }
@Throws(SvnBindException::class)
fun setUserInfo(userInfo: String?) = wrap { URI(uri.scheme, userInfo, uri.host, uri.port, uri.path, uri.query, uri.fragment) }
fun setUserInfo(userInfo: String?): Url = wrap { URI(uri.scheme, userInfo, uri.host, uri.port, uri.path, uri.query, uri.fragment) }
override fun equals(other: Any?): Boolean {
if (this === other) return true
@@ -47,10 +47,10 @@ class Url private constructor(innerUri: URI) {
return uri == other.uri
}
override fun hashCode() = uri.hashCode()
override fun hashCode(): Int = uri.hashCode()
override fun toString() = fixFileUrlToString(uri.toASCIIString().removeSuffix("/"))
fun toDecodedString() = URLUtil.unescapePercentSequences(toString())
override fun toString(): String = fixFileUrlToString(uri.toASCIIString().removeSuffix("/"))
fun toDecodedString(): String = URLUtil.unescapePercentSequences(toString())
private fun fixFileUrlToString(url: String) = if (url.startsWith(FILE_URL_PREFIX) && !url.startsWith(
"$FILE_URL_PREFIX/")) "$FILE_URL_PREFIX//${url.substring(FILE_URL_PREFIX.length)}"
@@ -58,9 +58,9 @@ class Url private constructor(innerUri: URI) {
companion object {
@JvmField
val EMPTY = Url(URI(""))
val EMPTY: Url = Url(URI(""))
@JvmField
val DEFAULT_PORTS = mapOf("http" to 80, "https" to 443, "svn" to 3690, "svn+ssh" to 22)
val DEFAULT_PORTS: Map<String, Int> = mapOf("http" to 80, "https" to 443, "svn" to 3690, "svn+ssh" to 22)
@JvmStatic
@Throws(SvnBindException::class)
@@ -75,10 +75,10 @@ class Url private constructor(innerUri: URI) {
}
@JvmStatic
fun tail(url: String) = url.removeSuffix("/").substringAfterLast('/')
fun tail(url: String): String = url.removeSuffix("/").substringAfterLast('/')
@JvmStatic
fun removeTail(url: String) = url.removeSuffix("/").substringBeforeLast('/', "")
fun removeTail(url: String): String = url.removeSuffix("/").substringBeforeLast('/', "")
@JvmStatic
fun append(url1: String, url2: String): String {
@@ -98,11 +98,11 @@ class Url private constructor(innerUri: URI) {
}
@JvmStatic
fun isAncestor(parent: String, child: String) = parent.isEmpty() || child.startsWith(
fun isAncestor(parent: String, child: String): Boolean = parent.isEmpty() || child.startsWith(
parent) && (parent.last() == '/' || child.getOrElse(parent.length, { '/' }) == '/')
@JvmStatic
fun getCommonAncestor(url1: String, url2: String) = (url1.splitToSequence('/') zip url2.splitToSequence('/'))
fun getCommonAncestor(url1: String, url2: String): String = (url1.splitToSequence('/') zip url2.splitToSequence('/'))
.takeWhile { it.first == it.second }
.joinToString("/") { it.first }
@@ -7,6 +7,6 @@ class CertificateAuthenticationData(val certificate: Credentials, isStorageAllow
constructor(certificatePath: String, certificatePassword: CharArray?, isStorageAllowed: Boolean) : this(
Credentials(certificatePath, certificatePassword), isStorageAllowed)
val certificatePath = certificate.userName.orEmpty()
val certificatePassword = certificate.getPasswordAsString().orEmpty()
val certificatePath: String = certificate.userName.orEmpty()
val certificatePassword: String = certificate.getPasswordAsString().orEmpty()
}
@@ -6,6 +6,6 @@ import com.intellij.credentialStore.Credentials
class PasswordAuthenticationData(val credentials: Credentials, isStorageAllowed: Boolean) : AuthenticationData(isStorageAllowed) {
constructor(userName: String, password: String, isStorageAllowed: Boolean) : this(Credentials(userName, password), isStorageAllowed)
val userName = credentials.userName.orEmpty()
val password = credentials.getPasswordAsString().orEmpty()
val userName: String = credentials.userName.orEmpty()
val password: String = credentials.getPasswordAsString().orEmpty()
}
@@ -2,9 +2,9 @@
package org.jetbrains.idea.svn.branchConfig
class InfoStorage<T>(value: T, infoReliability: InfoReliability) {
var value = value
var value: T = value
private set
var infoReliability = infoReliability
var infoReliability: InfoReliability = infoReliability
private set
fun accept(infoStorage: InfoStorage<T>): Boolean {
@@ -21,16 +21,16 @@ class InfoStorage<T>(value: T, infoReliability: InfoReliability) {
enum class InfoReliability {
empty {
override val overriddenBy get() = arrayOf(defaultValues, setByUser)
override val overriddenBy: Array<InfoReliability> get() = arrayOf(defaultValues, setByUser)
},
defaultValues {
override val overriddenBy get() = arrayOf(setByUser)
override val overriddenBy: Array<InfoReliability> get() = arrayOf(setByUser)
},
setByUser {
override val overriddenBy get() = arrayOf(setByUser)
override val overriddenBy: Array<InfoReliability> get() = arrayOf(setByUser)
};
protected abstract val overriddenBy: Array<InfoReliability>
fun shouldOverride(other: InfoReliability) = this in other.overriddenBy
fun shouldOverride(other: InfoReliability): Boolean = this in other.overriddenBy
}
@@ -16,9 +16,9 @@ class NewRootBunch(private val myProject: Project, private val myBranchesLoader:
private val myLock = Any()
private val myMap = mutableMapOf<VirtualFile, InfoStorage<SvnBranchConfigurationNew>>()
val mapCopy get() = synchronized(myLock) { myMap.mapValues { it.value.value } }
val mapCopy: Map<VirtualFile, SvnBranchConfigurationNew> get() = synchronized(myLock) { myMap.mapValues { it.value.value } }
fun updateForRoot(root: VirtualFile, config: InfoStorage<SvnBranchConfigurationNew>, reload: Boolean) = synchronized(myLock) {
fun updateForRoot(root: VirtualFile, config: InfoStorage<SvnBranchConfigurationNew>, reload: Boolean): Unit = synchronized(myLock) {
val previous: SvnBranchConfigurationNew?
val override: Boolean
val existing = myMap[root]
@@ -38,7 +38,7 @@ class NewRootBunch(private val myProject: Project, private val myBranchesLoader:
}
}
fun updateBranches(root: VirtualFile, branchesParent: Url, items: InfoStorage<List<SvnBranchItem>>) = synchronized(myLock) {
fun updateBranches(root: VirtualFile, branchesParent: Url, items: InfoStorage<List<SvnBranchItem>>): Unit = synchronized(myLock) {
val existing = myMap[root]
if (existing == null) {
LOG.info("cannot update branches, branches parent not found: ${branchesParent.toDecodedString()}")
@@ -48,7 +48,7 @@ class NewRootBunch(private val myProject: Project, private val myBranchesLoader:
}
}
fun getConfig(root: VirtualFile) = synchronized(myLock) {
fun getConfig(root: VirtualFile): SvnBranchConfigurationNew = synchronized(myLock) {
val value = myMap[root]
val result: SvnBranchConfigurationNew
if (value == null) {
@@ -80,6 +80,6 @@ class NewRootBunch(private val myProject: Project, private val myBranchesLoader:
}
}
fun reloadBranches(root: VirtualFile, branchLocation: Url, reliability: InfoReliability, passive: Boolean) =
fun reloadBranches(root: VirtualFile, branchLocation: Url, reliability: InfoReliability, passive: Boolean): Unit =
BranchesLoader(myProject, this, branchLocation, reliability, root, passive).run()
}
@@ -31,10 +31,10 @@ class SvnBranchConfigurationManager(private val myProject: Project,
private val myStorage: SvnLoadedBranchesStorage) : PersistentStateComponent<SvnBranchConfigurationManager.ConfigurationBean> {
private val myVcsManager = vcsManager as ProjectLevelVcsManagerImpl
private val myBranchesLoader = ProgressManagerQueue(myProject, "Subversion Branches Preloader")
val svnBranchConfigManager = NewRootBunch(myProject, myBranchesLoader)
val svnBranchConfigManager: NewRootBunch = NewRootBunch(myProject, myBranchesLoader)
private var myIsInitialized = false
val supportValue get() = myConfigurationBean.myVersion
val supportValue: Long? get() = myConfigurationBean.myVersion
private var myConfigurationBean = ConfigurationBean()
init {
@@ -59,7 +59,7 @@ class SvnBranchConfigurationManager(private val myProject: Project,
var myVersion: Long? = null
}
fun get(vcsRoot: VirtualFile) = svnBranchConfigManager.getConfig(vcsRoot)
fun get(vcsRoot: VirtualFile): SvnBranchConfigurationNew = svnBranchConfigManager.getConfig(vcsRoot)
fun setConfiguration(vcsRoot: VirtualFile, configuration: SvnBranchConfigurationNew) {
svnBranchConfigManager.updateForRoot(vcsRoot, InfoStorage(configuration, InfoReliability.setByUser), true)
@@ -69,7 +69,7 @@ class SvnBranchConfigurationManager(private val myProject: Project,
myProject, vcsRoot)
}
override fun getState() = ConfigurationBean().apply {
override fun getState(): ConfigurationBean = ConfigurationBean().apply {
myVersion = myConfigurationBean.myVersion
for (root in svnBranchConfigManager.mapCopy.keys) {
@@ -182,7 +182,7 @@ class SvnBranchConfigurationManager(private val myProject: Project,
companion object {
@JvmStatic
fun getInstance(project: Project) =
fun getInstance(project: Project): SvnBranchConfigurationManager =
ServiceManager.getService(project, SvnBranchConfigurationManager::class.java)!!.apply { initialize() }
}
}
@@ -26,8 +26,8 @@ class SvnBranchConfigurationNew {
private val myBranchMap: MutableMap<Url, InfoStorage<List<SvnBranchItem>>> = mutableMapOf()
var isUserInfoInUrl: Boolean = false
val branchLocations get() = myBranchMap.keys.sortedBy { it.toDecodedString() }
val branchMap get() = myBranchMap
val branchLocations: List<Url> get() = myBranchMap.keys.sortedBy { it.toDecodedString() }
val branchMap: MutableMap<Url, InfoStorage<List<SvnBranchItem>>> get() = myBranchMap
fun addBranches(branchLocation: Url, items: InfoStorage<List<SvnBranchItem>>) {
val current = myBranchMap[branchLocation]
@@ -47,7 +47,7 @@ class SvnBranchConfigurationNew {
current.accept(items)
}
fun getBranches(branchLocation: Url) = myBranchMap[branchLocation]?.value ?: emptyList()
fun getBranches(branchLocation: Url): List<SvnBranchItem> = myBranchMap[branchLocation]?.value ?: emptyList()
fun copy(): SvnBranchConfigurationNew {
val result = SvnBranchConfigurationNew()
@@ -74,14 +74,14 @@ class SvnBranchConfigurationNew {
}
@Deprecated("use getBaseName(Url)")
fun getBaseName(url: String) = getBaseName(createUrl(url, false))
fun getBaseName(url: String): String? = getBaseName(createUrl(url, false))
fun getBaseName(url: Url) = getBaseUrl(url)?.tail
fun getBaseName(url: Url): String? = getBaseUrl(url)?.tail
fun getRelativeUrl(url: Url) = getBaseUrl(url)?.let { SvnUtil.getRelativeUrl(it, url) }
fun getRelativeUrl(url: Url): String? = getBaseUrl(url)?.let { SvnUtil.getRelativeUrl(it, url) }
@Throws(SvnBindException::class)
fun getWorkingBranch(url: Url) = getBaseUrl(url)
fun getWorkingBranch(url: Url): Url? = getBaseUrl(url)
// to retrieve mappings between existing in the project working copies and their URLs
fun getUrl2FileMappings(project: Project, root: VirtualFile): Map<Url, File> {
@@ -4,5 +4,5 @@ package org.jetbrains.idea.svn.branchConfig
import org.jetbrains.idea.svn.api.Url
class SvnBranchItem(val url: Url, val creationDateMillis: Long, val revision: Long) : Comparable<SvnBranchItem> {
override fun compareTo(other: SvnBranchItem) = other.creationDateMillis.compareTo(creationDateMillis)
override fun compareTo(other: SvnBranchItem): Int = other.creationDateMillis.compareTo(creationDateMillis)
}
@@ -27,11 +27,11 @@ class SvnLoadedBranchesStorage(private val myProject: Project) {
myFile = File(file, myProject.locationHash)
}
operator fun get(url: Url) = synchronized(myLock) {
operator fun get(url: Url): Collection<SvnBranchItem>? = synchronized(myLock) {
myState?.get("")?.get(url)
}
fun activate() = synchronized(myLock) {
fun activate(): Unit = synchronized(myLock) {
myState = SmallMapSerializer(myFile, EnumeratorStringDescriptor.INSTANCE, createExternalizer())
}
@@ -11,7 +11,7 @@ import java.io.IOException
class UrlDescriptor(val isEncoded: Boolean) : KeyDescriptor<Url> {
@Throws(IOException::class)
override fun save(out: DataOutput, value: Url) = out.writeUTF(if (isEncoded) value.toString() else value.toDecodedString())
override fun save(out: DataOutput, value: Url): Unit = out.writeUTF(if (isEncoded) value.toString() else value.toDecodedString())
@Throws(IOException::class)
override fun read(`in`: DataInput): Url {
@@ -25,14 +25,14 @@ class UrlDescriptor(val isEncoded: Boolean) : KeyDescriptor<Url> {
}
}
override fun getHashCode(value: Url) = value.hashCode()
override fun getHashCode(value: Url): Int = value.hashCode()
override fun isEqual(val1: Url, val2: Url) = val1 == val2
override fun isEqual(val1: Url, val2: Url): Boolean = val1 == val2
companion object {
@JvmField
val ENCODED_URL_DESCRIPTOR = UrlDescriptor(true)
val ENCODED_URL_DESCRIPTOR: UrlDescriptor = UrlDescriptor(true)
@JvmField
val DECODED_URL_DESCRIPTOR = UrlDescriptor(false)
val DECODED_URL_DESCRIPTOR: UrlDescriptor = UrlDescriptor(false)
}
}
@@ -67,7 +67,7 @@ class SvnDiffSettingsHolder : PersistentStateComponent<SvnDiffSettingsHolder.Sta
var PLACES_MAP: TreeMap<String, PlaceSettings> = TreeMap()
@JvmField
var SHARED_SETTINGS = SharedSettings()
var SHARED_SETTINGS: SharedSettings = SharedSettings()
}
private var myState: State = State()
@@ -2,5 +2,5 @@
package org.jetbrains.idea.svn.mergeinfo
data class MergeRange(override val start: Long, override val endInclusive: Long, val isInheritable: Boolean = true) : ClosedRange<Long> {
val revisions get() = start..endInclusive
val revisions: LongRange get() = start..endInclusive
}
@@ -8,7 +8,7 @@ data class MergeRangeList(val ranges: Set<MergeRange>) {
companion object {
@JvmStatic
@Throws(SvnBindException::class)
fun parseMergeInfo(value: String) = value.lineSequence().map { parseLine(it) }.toMap()
fun parseMergeInfo(value: String): Map<String, MergeRangeList> = value.lineSequence().map { parseLine(it) }.toMap()
@Throws(SvnBindException::class)
fun parseRange(value: String): MergeRange {
@@ -71,15 +71,15 @@ class TerminalOptionsProvider : PersistentStateComponent<TerminalOptionsProvider
class State {
var myShellPath: String? = null
var myTabName = "Local"
var myCloseSessionOnLogout = true
var myReportMouse = true
var mySoundBell = true
var myCopyOnSelection = true
var myPasteOnMiddleMouseButton = true
var myOverrideIdeShortcuts = true
var myShellIntegration = true
var myHighlightHyperlinks = true
var myTabName: String = "Local"
var myCloseSessionOnLogout: Boolean = true
var myReportMouse: Boolean = true
var mySoundBell: Boolean = true
var myCopyOnSelection: Boolean = true
var myPasteOnMiddleMouseButton: Boolean = true
var myOverrideIdeShortcuts: Boolean = true
var myShellIntegration: Boolean = true
var myHighlightHyperlinks: Boolean = true
}
fun setCloseSessionOnLogout(closeSessionOnLogout: Boolean) {