content
stringlengths
0
13M
path
stringlengths
4
263
contentHash
stringlengths
1
10
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.feedback.productivityMetric.dialog import com.intellij.feedback.FeedbackRequestData import com.intellij.feedback.common.FEEDBACK_REPORT_ID_KEY import com.intellij.feedback.common.FeedbackRequestType import com.intellij.feedback.common.dialog.COMMON_FEEDBACK_SYSTEM_INFO_VERSION import com.intellij.feedback.common.dialog.CommonFeedbackSystemInfoData import com.intellij.feedback.common.dialog.showFeedbackSystemInfoDialog import com.intellij.feedback.common.feedbackAgreement import com.intellij.feedback.new_ui.CancelFeedbackNotification import com.intellij.feedback.productivityMetric.bundle.ProductivityFeedbackBundle import com.intellij.feedback.submitFeedback import com.intellij.openapi.application.ex.ApplicationInfoEx import com.intellij.openapi.observable.properties.PropertyGraph import com.intellij.openapi.project.Project import com.intellij.openapi.ui.DialogWrapper import com.intellij.openapi.ui.panel.ComponentPanelBuilder import com.intellij.ui.dsl.builder.* import com.intellij.ui.dsl.gridLayout.Gaps import com.intellij.util.ui.JBEmptyBorder import com.intellij.util.ui.JBFont import com.intellij.util.ui.JBUI import kotlinx.serialization.json.* import javax.swing.Action import javax.swing.JComponent import javax.swing.SwingConstants class ProductivityFeedbackDialog( private val project: Project?, private val forTest: Boolean ) : DialogWrapper(project) { /** Increase the additional number when feedback format is changed */ private val FEEDBACK_JSON_VERSION = COMMON_FEEDBACK_SYSTEM_INFO_VERSION private val FEEDBACK_REPORT_ID_VALUE = "productivity_metric_feedback" private val FEEDBACK_PRIVACY_CONSENT_TYPE_VALUE = "productivity_metric_feedback_consent" private val systemInfoData: Lazy<CommonFeedbackSystemInfoData> = lazy { CommonFeedbackSystemInfoData.getCurrentData() } private val digitRegexp: Regex = Regex("\\d") private val applicationName: String = run { val fullAppName: String = ApplicationInfoEx.getInstanceEx().fullApplicationName val range: IntRange? = digitRegexp.find(fullAppName)?.range if (range != null) { fullAppName.substring(0, range.first).trim() } else { fullAppName } } private val propertyGraph = PropertyGraph() private val productivityProperty = propertyGraph.property(0) private val proficiencyProperty = propertyGraph.property(0) private val usingExperience = propertyGraph.property("") private val jsonConverter = Json { prettyPrint = true } init { init() title = ProductivityFeedbackBundle.message("dialog.top.title") isResizable = false } override fun doOKAction() { super.doOKAction() val feedbackData = FeedbackRequestData(FEEDBACK_REPORT_ID_VALUE, createCollectedDataJsonString(), FEEDBACK_PRIVACY_CONSENT_TYPE_VALUE) submitFeedback(project, feedbackData, { }, { }, if (forTest) FeedbackRequestType.TEST_REQUEST else FeedbackRequestType.PRODUCTION_REQUEST) } override fun doCancelAction() { super.doCancelAction() CancelFeedbackNotification().notify(project) } private fun createCollectedDataJsonString(): JsonObject { val collectedData = buildJsonObject { put(FEEDBACK_REPORT_ID_KEY, FEEDBACK_REPORT_ID_VALUE) put("format_version", FEEDBACK_JSON_VERSION) put("productivity_influence", productivityProperty.get()) put("proficiency_level", proficiencyProperty.get()) put("using_experience", usingExperience.get()) put("system_info", jsonConverter.encodeToJsonElement(systemInfoData.value)) } return collectedData } override fun createCenterPanel(): JComponent { val productivitySegmentedButtonPanel = panel { row { label(ProductivityFeedbackBundle.message("dialog.segmentedButton.1.label", applicationName)) .customize(Gaps(top = IntelliJSpacingConfiguration().verticalComponentGap)) .bold() }.bottomGap(BottomGap.SMALL).topGap(TopGap.MEDIUM) row { segmentedButton(List(9) { it + 1 }) { it.toString() } .apply { maxButtonsCount(9) }.customize(Gaps(top = IntelliJSpacingConfiguration().verticalComponentGap)) .whenItemSelected { productivityProperty.set(it) } .align(Align.FILL) } row { label(ProductivityFeedbackBundle.message("dialog.segmentedButton.1.left.label")) .applyToComponent { font = ComponentPanelBuilder.getCommentFont(font) } .widthGroup("Group1") label(ProductivityFeedbackBundle.message("dialog.segmentedButton.1.middle.label")) .applyToComponent { font = ComponentPanelBuilder.getCommentFont(font) } .align(AlignX.CENTER) .resizableColumn() label(ProductivityFeedbackBundle.message("dialog.segmentedButton.1.right.label")) .applyToComponent { font = ComponentPanelBuilder.getCommentFont(font) horizontalAlignment = SwingConstants.RIGHT } .widthGroup("Group1") } } val proficiencySegmentedButtonPanel = panel { row { label(ProductivityFeedbackBundle.message("dialog.segmentedButton.2.label", applicationName)) .customize(Gaps(top = IntelliJSpacingConfiguration().verticalComponentGap)) .bold() }.bottomGap(BottomGap.SMALL).topGap(TopGap.MEDIUM) row { segmentedButton(List(9) { it + 1 }) { it.toString() } .apply { maxButtonsCount(9) }.customize(Gaps(top = IntelliJSpacingConfiguration().verticalComponentGap)) .whenItemSelected { proficiencyProperty.set(it) } .align(Align.FILL) } row { label(ProductivityFeedbackBundle.message("dialog.segmentedButton.2.left.label")) .applyToComponent { font = ComponentPanelBuilder.getCommentFont(font) } .widthGroup("Group2") .resizableColumn() label(ProductivityFeedbackBundle.message("dialog.segmentedButton.2.right.label")) .applyToComponent { font = ComponentPanelBuilder.getCommentFont(font) horizontalAlignment = SwingConstants.RIGHT } .widthGroup("Group2") } } val mainPanel = panel { row { label(ProductivityFeedbackBundle.message("dialog.title")) .applyToComponent { font = JBFont.h1() } } row { cell(productivitySegmentedButtonPanel) .align(Align.FILL) } row { cell(proficiencySegmentedButtonPanel) .align(Align.FILL) } row { label(ProductivityFeedbackBundle.message("dialog.combobox.label", applicationName)) .customize(Gaps(top = IntelliJSpacingConfiguration().verticalComponentGap)) .bold() }.bottomGap(BottomGap.SMALL).topGap(TopGap.MEDIUM) row { comboBox(List(8) { ProductivityFeedbackBundle.message("dialog.combobox.item.${it + 1}") }) .applyToComponent { usingExperience.set(selectedItem?.toString() ?: "null") columns(COLUMNS_MEDIUM) }.whenItemSelectedFromUi { usingExperience.set(it) } }.bottomGap(BottomGap.MEDIUM) row { feedbackAgreement(project) { showFeedbackSystemInfoDialog(project, systemInfoData.value) } }.bottomGap(BottomGap.SMALL) }.also { dialog -> dialog.border = JBEmptyBorder(JBUI.scale(15), JBUI.scale(10), JBUI.scale(0), JBUI.scale(10)) } return mainPanel } override fun createActions(): Array<Action> { return arrayOf(cancelAction, okAction) } override fun getOKAction(): Action { return object : OkAction() { init { putValue(NAME, ProductivityFeedbackBundle.message("dialog.ok.label")) } } } override fun getCancelAction(): Action { val cancelAction = super.getCancelAction() cancelAction.putValue(Action.NAME, ProductivityFeedbackBundle.message("dialog.cancel.label")) return cancelAction } }
platform/feedback/src/com/intellij/feedback/productivityMetric/dialog/ProductivityFeedbackDialog.kt
308005021
/* * * Copyright 2019: Brad Newman * * 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 io.github.resilience4j.kotlin.retry import io.github.resilience4j.retry.Retry import kotlinx.coroutines.delay /** * Decorates and executes the given suspend function [block]. * * Between attempts, suspends based on the configured interval function. */ suspend fun <T> Retry.executeSuspendFunction(block: suspend () -> T): T { val retryContext = asyncContext<T>() while (true) { try { val result = block() val delayMs = retryContext.onResult(result) if (delayMs < 1) { retryContext.onComplete() return result } else { delay(delayMs) } } catch (e: Exception) { val delayMs = retryContext.onError(e) if (delayMs < 1) { throw e } else { delay(delayMs) } } } } /** * Decorates the given function [block] and returns it. * * Between attempts, suspends based on the configured interval function. */ fun <T> Retry.decorateSuspendFunction(block: suspend () -> T): suspend () -> T = { executeSuspendFunction(block) } /** * Decorates the given function [block] and returns it. * * Between attempts, suspends based on the configured interval function. */ fun <T> Retry.decorateFunction(block: () -> T): () -> T = { executeFunction(block) } /** * Decorates and executes the given function [block]. * * Between attempts, suspends based on the configured interval function. */ fun <T> Retry.executeFunction(block: () -> T): T { return this.executeCallable(block) }
resilience4j-kotlin/src/main/kotlin/io/github/resilience4j/kotlin/retry/Retry.kt
2643745405
package org.stepik.android.presentation.filter import io.reactivex.Completable import io.reactivex.Scheduler import io.reactivex.Single import io.reactivex.rxkotlin.plusAssign import io.reactivex.rxkotlin.subscribeBy import io.reactivex.subjects.PublishSubject import org.stepic.droid.analytic.Analytic import org.stepic.droid.di.qualifiers.BackgroundScheduler import org.stepic.droid.di.qualifiers.MainScheduler import org.stepic.droid.model.StepikFilter import org.stepic.droid.preferences.SharedPreferenceHelper import org.stepik.android.domain.filter.analytic.ContenLanguageChangedAnalyticEvent import ru.nobird.android.domain.rx.emptyOnErrorStub import org.stepik.android.view.injection.catalog.FiltersBus import ru.nobird.android.presentation.base.PresenterBase import java.util.EnumSet import javax.inject.Inject class FiltersPresenter @Inject constructor( private val analytic: Analytic, @BackgroundScheduler private val backgroundScheduler: Scheduler, @MainScheduler private val mainScheduler: Scheduler, private val sharedPreferenceHelper: SharedPreferenceHelper, @FiltersBus private val filtersPublisher: PublishSubject<EnumSet<StepikFilter>> ) : PresenterBase<FiltersView>() { private var state: FiltersView.State = FiltersView.State.Idle set(value) { field = value view?.setState(value) } init { onNeedFilters() } override fun attachView(view: FiltersView) { super.attachView(view) view.setState(state) } private fun onNeedFilters(forceUpdate: Boolean = false) { if (state != FiltersView.State.Idle && !forceUpdate) return compositeDisposable += Single.fromCallable { sharedPreferenceHelper.filterForFeatured } .subscribeOn(backgroundScheduler) .observeOn(mainScheduler) .subscribeBy( onSuccess = { state = FiltersView.State.FiltersLoaded(it) }, onError = { state = FiltersView.State.Empty } ) } fun onFilterChanged(newAppliedFilters: EnumSet<StepikFilter>) { val newLanguage = newAppliedFilters.firstOrNull()?.language if (newLanguage != null) { analytic.report(ContenLanguageChangedAnalyticEvent(newLanguage, ContenLanguageChangedAnalyticEvent.Source.SETTINGS)) } compositeDisposable += Completable.fromCallable { sharedPreferenceHelper.saveFilterForFeatured(newAppliedFilters) } .subscribeOn(backgroundScheduler) .observeOn(mainScheduler) .subscribeBy( onComplete = { filtersPublisher.onNext(newAppliedFilters) onNeedFilters(forceUpdate = true) }, onError = emptyOnErrorStub ) } }
app/src/main/java/org/stepik/android/presentation/filter/FiltersPresenter.kt
54284738
package com.jetbrains.packagesearch.intellij.plugin.ui.toolwindow.completion import com.intellij.ide.plugins.newui.SearchPopupCallback import com.intellij.openapi.ui.popup.JBPopup import com.intellij.openapi.ui.popup.JBPopupFactory import com.intellij.openapi.ui.popup.JBPopupListener import com.intellij.openapi.ui.popup.LightweightWindowEvent import com.intellij.ui.ColoredListCellRenderer import com.intellij.ui.SearchTextField import com.intellij.ui.components.JBList import com.intellij.util.Consumer import com.intellij.util.ui.JBUI import com.intellij.util.ui.UIUtil import com.jetbrains.packagesearch.intellij.plugin.api.query.SearchQueryCompletionModel import java.awt.Component import java.awt.Point import java.awt.event.ComponentAdapter import java.awt.event.ComponentEvent import javax.swing.JList import javax.swing.SwingUtilities import javax.swing.event.CaretEvent import javax.swing.event.CaretListener import javax.swing.text.BadLocationException class SearchCompletionPopup( private val searchField: SearchTextField, private val completionModel: SearchQueryCompletionModel, private val popupListener: JBPopupListener ) : ComponentAdapter(), CaretListener { private var skipCaretEvent: Boolean = false private var searchPopupCallback: SearchPopupCallback? = null private var jbPopup: JBPopup? = null private var windowEvent: LightweightWindowEvent? = null private var dialogComponent: Component? = null var itemsList: JList<String>? = null @Suppress("DEPRECATION") fun createAndShow(callback: Consumer<in String>, renderer: ColoredListCellRenderer<in String>, async: Boolean) { if (callback is SearchPopupCallback) { searchPopupCallback = callback } val ipad = renderer.ipad ipad.right = getXOffset() ipad.left = ipad.right renderer.font = searchField.textEditor.font val completionData = mutableListOf<String>() if (!completionModel.values.isNullOrEmpty()) { completionData.addAll(completionModel.values) } else if (!completionModel.attributes.isNullOrEmpty()) { completionData.addAll(completionModel.attributes) } val list = JBList(completionData) val popup = JBPopupFactory.getInstance().createListPopupBuilder(list) .setMovable(false) .setResizable(false) .setRequestFocus(false) .setItemChosenCallback(callback) .setFont(searchField.textEditor.font) .setRenderer(renderer) .createPopup() itemsList = list jbPopup = popup windowEvent = LightweightWindowEvent(popup) skipCaretEvent = true popup.addListener(popupListener) searchField.textEditor.addCaretListener(this) dialogComponent = searchField.textEditor.rootPane.parent dialogComponent?.addComponentListener(this) if (async) { SwingUtilities.invokeLater { this.show() } } else { show() } } private fun getXOffset(): Int { val i = if (UIUtil.isUnderWin10LookAndFeel()) 5 else UIUtil.getListCellHPadding() return JBUI.scale(i) } private fun getPopupLocation(): Point { val location = try { val view = searchField.textEditor.modelToView(completionModel.caretPosition) Point(view.maxX.toInt(), view.maxY.toInt()) } catch (ignore: BadLocationException) { searchField.textEditor.caret.magicCaretPosition } SwingUtilities.convertPointToScreen(location, searchField.textEditor) location.x -= getXOffset() + JBUI.scale(2) location.y += 2 return location } private fun isValid(): Boolean { val popup = jbPopup return popup != null && popup.isVisible && popup.content.parent != null } private fun update() { skipCaretEvent = true jbPopup?.setLocation(getPopupLocation()) jbPopup?.pack(true, true) } private fun show() { if (jbPopup != null) { itemsList?.clearSelection() jbPopup?.showInScreenCoordinates(searchField.textEditor, getPopupLocation()) } } fun hide() { searchField.textEditor.removeCaretListener(this) dialogComponent?.removeComponentListener(this) dialogComponent = null jbPopup?.cancel() jbPopup = null } override fun caretUpdate(e: CaretEvent) { if (skipCaretEvent) { skipCaretEvent = false } else { hide() popupListener.onClosed(windowEvent!!) } } override fun componentMoved(e: ComponentEvent?) { if (jbPopup != null && isValid()) { update() } } override fun componentResized(e: ComponentEvent?) { componentMoved(e) } }
plugins/package-search/src/com/jetbrains/packagesearch/intellij/plugin/ui/toolwindow/completion/SearchCompletionPopup.kt
4046574952
// Copyright 2000-2020 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 org.intellij.plugins.markdown.lang.formatter.settings import com.intellij.psi.codeStyle.CodeStyleSettings import com.intellij.psi.codeStyle.CustomCodeStyleSettings import org.intellij.plugins.markdown.lang.MarkdownLanguage @Suppress("PropertyName") class MarkdownCustomCodeStyleSettings(settings: CodeStyleSettings) : CustomCodeStyleSettings(MarkdownLanguage.INSTANCE.id, settings) { //BLANK LINES @JvmField var MAX_LINES_AROUND_HEADER: Int = 1 @JvmField var MIN_LINES_AROUND_HEADER: Int = 1 @JvmField var MAX_LINES_AROUND_BLOCK_ELEMENTS: Int = 1 @JvmField var MIN_LINES_AROUND_BLOCK_ELEMENTS: Int = 1 @JvmField var MAX_LINES_BETWEEN_PARAGRAPHS: Int = 1 @JvmField var MIN_LINES_BETWEEN_PARAGRAPHS: Int = 1 //SPACES @JvmField var FORCE_ONE_SPACE_BETWEEN_WORDS: Boolean = true @JvmField var FORCE_ONE_SPACE_AFTER_HEADER_SYMBOL: Boolean = true @JvmField var FORCE_ONE_SPACE_AFTER_LIST_BULLET: Boolean = true @JvmField var FORCE_ONE_SPACE_AFTER_BLOCKQUOTE_SYMBOL: Boolean = true }
plugins/markdown/src/org/intellij/plugins/markdown/lang/formatter/settings/MarkdownCustomCodeStyleSettings.kt
2732219351
/* * Copyright 2021 The Android Open Source Project * * 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 * * https://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 com.example.android.wearable.timetext import android.app.Activity class TestActivity : Activity()
TimeText/timetexttestsupport/src/main/java/com/example/android/wearable/timetext/TestActivity.kt
3344868665
// Copyright 2000-2020 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.internal import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.KeyboardShortcut import com.intellij.openapi.fileChooser.FileChooserFactory import com.intellij.openapi.fileChooser.FileSaverDescriptor import com.intellij.openapi.keymap.KeymapManager class KeymapToCsvAction : AnAction() { override fun actionPerformed(e: AnActionEvent) { val allShortcuts = linkedMapOf<String, MutableMap<String, MutableList<String>>>() val seenModifierSets = mutableSetOf<String>() val columns = mutableListOf("", "shift", "ctrl", "alt", "meta") for (key in 'A'..'Z') { allShortcuts[key.toString()] = hashMapOf() } for (key in '0'..'9') { allShortcuts[key.toString()] = hashMapOf() } for (key in 1..12) { allShortcuts["F$key"] = hashMapOf() } val keymap = KeymapManager.getInstance().activeKeymap for (actionId in keymap.actionIdList) { val shortcuts = keymap.getShortcuts(actionId).filterIsInstance<KeyboardShortcut>() for (shortcut in shortcuts) { val keyStroke = shortcut.firstKeyStroke val str = keyStroke.toString() val keyName = str.substringAfterLast(' ', str) val modifiers = str.substringBeforeLast(' ').replace("pressed", "").trim() seenModifierSets += modifiers val forKey = allShortcuts.getOrPut(keyName) { hashMapOf() } val actionIds = forKey.getOrPut(modifiers) { mutableListOf() } actionIds.add(actionId) } } for (seenModifierSet in seenModifierSets) { if (seenModifierSet !in columns) { columns.add(seenModifierSet) } } val result = buildString { appendln("key," + columns.joinToString(",")) for ((key, shortcutsForKey) in allShortcuts) { append(key) for (column in columns) { append(",") val actionsForShortcut = shortcutsForKey[column] ?: emptyList<String>() append(actionsForShortcut.joinToString("|")) } appendln() } } val dialog = FileChooserFactory.getInstance().createSaveFileDialog( FileSaverDescriptor("Export Keymap to .csv", "Select file to save to:", "csv"), e.project) val virtualFileWrapper = dialog.save(null) virtualFileWrapper?.file?.writeText(result.replace("\n", "\r\n")) } }
platform/platform-impl/src/com/intellij/internal/KeymapToCsvAction.kt
1413356002
package io.fluidsonic.json.annotationprocessor import com.squareup.kotlinpoet.* internal object KotlinpoetTypeNames { val any = ANY val boolean = ClassName("kotlin", "Boolean") val byte = ClassName("kotlin", "Byte") val char = ClassName("kotlin", "Char") val double = ClassName("kotlin", "Double") val float = ClassName("kotlin", "Float") val int = ClassName("kotlin", "Int") val long = ClassName("kotlin", "Long") val short = ClassName("kotlin", "Short") val string = ClassName("kotlin", "String") val nullableAny = any.copy(nullable = true) val basic = setOf( boolean, byte, char, double, float, int, long, short ) } internal val TypeName.isPrimitive get() = KotlinpoetTypeNames.basic.contains(this)
annotation-processor/sources-jvm/utility/KotlinpoetTypeNames.kt
4113624245
package com.rightfromleftsw.weather.data.executor import com.rightfromleftsw.weather.domain.executor.ThreadExecutor import java.util.concurrent.LinkedBlockingQueue import java.util.concurrent.ThreadFactory import java.util.concurrent.ThreadPoolExecutor import java.util.concurrent.TimeUnit import javax.inject.Inject /** * Decorated [ThreadPoolExecutor] */ open class JobExecutor @Inject constructor(): ThreadExecutor { private val workQueue: LinkedBlockingQueue<Runnable> private val threadPoolExecutor: ThreadPoolExecutor private val threadFactory: ThreadFactory init { this.workQueue = LinkedBlockingQueue() this.threadFactory = JobThreadFactory() this.threadPoolExecutor = ThreadPoolExecutor(INITIAL_POOL_SIZE, MAX_POOL_SIZE, KEEP_ALIVE_TIME.toLong(), KEEP_ALIVE_TIME_UNIT, this.workQueue, this.threadFactory) } override fun execute(runnable: Runnable?) { if (runnable == null) { throw IllegalArgumentException("Runnable to execute cannot be null") } this.threadPoolExecutor.execute(runnable) } private class JobThreadFactory : ThreadFactory { private var counter = 0 override fun newThread(runnable: Runnable): Thread { return Thread(runnable, THREAD_NAME + counter++) } companion object { private val THREAD_NAME = "android_" } } companion object { private val INITIAL_POOL_SIZE = 3 private val MAX_POOL_SIZE = 5 // Sets the amount of time an idle thread waits before terminating private val KEEP_ALIVE_TIME = 10 // Sets the Time Unit to seconds private val KEEP_ALIVE_TIME_UNIT = TimeUnit.SECONDS } }
data/src/main/java/com/rightfromleftsw/weather/data/executor/JobExecutor.kt
3085637924
package com.jetbrains.packagesearch.intellij.plugin.ui.toolwindow.panels.management.packages.columns.renderers import com.intellij.ide.ui.AntialiasingType import com.intellij.util.ui.EmptyIcon import com.intellij.util.ui.GraphicsUtil import com.jetbrains.packagesearch.intellij.plugin.ui.toolwindow.panels.management.packages.columns.TableColors import icons.PackageSearchIcons import java.awt.Component import javax.accessibility.AccessibleContext import javax.accessibility.AccessibleRole import javax.accessibility.AccessibleState import javax.accessibility.AccessibleStateSet import javax.swing.DefaultListCellRenderer import javax.swing.JLabel import javax.swing.JList internal class PopupMenuListItemCellRenderer<T>( private val selectedValue: T?, private val colors: TableColors, private val itemLabelRenderer: (T) -> String = { it.toString() } ) : DefaultListCellRenderer() { private val selectedIcon = PackageSearchIcons.Checkmark private val emptyIcon = EmptyIcon.create(selectedIcon.iconWidth) private var currentItemIsSelected = false override fun getListCellRendererComponent(list: JList<*>, value: Any, index: Int, isSelected: Boolean, cellHasFocus: Boolean): Component { @Suppress("UNCHECKED_CAST") // It's ok to crash if this isn't true val item = value as T val itemLabel = itemLabelRenderer(item) + " " // The spaces are to compensate for the lack of padding in the label (yes, I know, it's a hack) val label = super.getListCellRendererComponent(list, itemLabel, index, isSelected, cellHasFocus) as JLabel label.font = list.font colors.applyTo(label, isSelected) currentItemIsSelected = item === selectedValue label.icon = if (currentItemIsSelected) selectedIcon else emptyIcon GraphicsUtil.setAntialiasingType(label, AntialiasingType.getAAHintForSwingComponent()) return label } override fun getAccessibleContext(): AccessibleContext { if (accessibleContext == null) { accessibleContext = AccessibleRenderer(currentItemIsSelected) } return accessibleContext } private inner class AccessibleRenderer( private val isSelected: Boolean ) : AccessibleJLabel() { override fun getAccessibleRole(): AccessibleRole = AccessibleRole.CHECK_BOX override fun getAccessibleStateSet(): AccessibleStateSet { val set = super.getAccessibleStateSet() if (isSelected) { set.add(AccessibleState.CHECKED) } return set } } }
plugins/package-search/src/com/jetbrains/packagesearch/intellij/plugin/ui/toolwindow/panels/management/packages/columns/renderers/PopupMenuListItemCellRenderer.kt
440465365
/** * <slate_header> * url: www.slatekit.com * git: www.github.com/code-helix/slatekit * org: www.codehelix.co * author: Kishore Reddy * copyright: 2016 CodeHelix Solutions Inc. * license: refer to website and/or github * about: A tool-kit, utility library and server-backend * mantra: Simplicity above all else * </slate_header> */ package slatekit.integration.mods import slatekit.entities.Entities import slatekit.entities.EntityRepo import slatekit.entities.EntityService class ModService(entities: Entities, repo: EntityRepo<Long, Mod>) : EntityService<Long, Mod>(repo)
src/lib/kotlin/slatekit-integration/src/main/kotlin/slatekit/integration/mods/ModService.kt
2055930969
package com.dbflow5.sql.language import com.dbflow5.BaseUnitTest import com.dbflow5.assertEquals import com.dbflow5.models.SimpleModel import com.dbflow5.models.SimpleModel_Table.name import com.dbflow5.models.TwoColumnModel_Table.id import com.dbflow5.query.set import com.dbflow5.query.update import org.junit.Test class SetTest : BaseUnitTest() { @Test fun validateSetWithConditions() { "UPDATE `SimpleModel` SET `name`='name'".assertEquals(update<SimpleModel>() set name.`is`("name")) } @Test fun validateMultipleConditions() { "UPDATE `SimpleModel` SET `name`='name', `id`=0".assertEquals(update<SimpleModel>() set name.eq("name") and id.eq(0)) } }
tests/src/androidTest/java/com/dbflow5/sql/language/SetTest.kt
2730742753
package slatekit.telemetry import slatekit.common.Identity import slatekit.common.Provider /** * Used for metrics internal to SlateKit * Simple interface to metrics with ( current ) dependency on Micrometer. * * NOTES: * 1. Standardization on the tags * 2. Not currently sure whether to go w/ Drop-Wizard or Micrometer. * 3. Basic counters, timer.record are enough for most INTERNAL Slate Kit metrics gathering */ interface Metrics : Provider { val id: Identity val source:String val settings: MetricsSettings fun total(name: String): Double fun count(name: String, tags:List<String>?) fun time(name: String, tags: List<String>?, call:() -> Unit ) fun <T> gauge(name: String, value:T) where T: kotlin.Number fun <T> gauge(name: String, call: () -> T, tags: List<Tag>?) where T: kotlin.Number }
src/lib/kotlin/slatekit-telemetry/src/main/kotlin/slatekit/telemetry/Metrics.kt
1009538102
// Copyright 2000-2019 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 org.jetbrains.plugins.github import com.intellij.openapi.util.Pair import junit.framework.TestCase import org.jetbrains.plugins.github.api.GHRepositoryPath import org.jetbrains.plugins.github.util.GithubUrlUtil.* import java.util.* class GithubUrlUtilTest : TestCase() { private class TestCase<T> { val tests: MutableList<Pair<String, T>> = ArrayList() fun add(`in`: String, out: T?) { tests.add(Pair.create(`in`, out)) } } private fun <T> runTestCase(tests: TestCase<T>, func: (String) -> T) { for (test in tests.tests) { assertEquals(test.getFirst(), test.getSecond(), func(test.getFirst())) } } fun testRemoveTrailingSlash() { val tests = TestCase<String>() tests.add("http://github.com/", "http://github.com") tests.add("http://github.com", "http://github.com") tests.add("http://github.com/user/repo/", "http://github.com/user/repo") tests.add("http://github.com/user/repo", "http://github.com/user/repo") runTestCase(tests) { `in` -> removeTrailingSlash(`in`) } } fun testRemoveProtocolPrefix() { val tests = TestCase<String>() tests.add("github.com/user/repo/", "github.com/user/repo/") tests.add("api.github.com/user/repo/", "api.github.com/user/repo/") tests.add("http://github.com/user/repo/", "github.com/user/repo/") tests.add("https://github.com/user/repo/", "github.com/user/repo/") tests.add("git://github.com/user/repo/", "github.com/user/repo/") tests.add("[email protected]:user/repo/", "github.com/user/repo/") tests.add("[email protected]:username/repo/", "github.com/username/repo/") tests.add("https://username:[email protected]/user/repo/", "github.com/user/repo/") tests.add("https://[email protected]/user/repo/", "github.com/user/repo/") tests.add("https://github.com:2233/user/repo/", "github.com:2233/user/repo/") tests.add("HTTP://GITHUB.com/user/repo/", "GITHUB.com/user/repo/") tests.add("HttP://GitHub.com/user/repo/", "GitHub.com/user/repo/") runTestCase(tests) { `in` -> removeProtocolPrefix(`in`) } } fun testRemovePort() { val tests = TestCase<String>() tests.add("github.com/user/repo/", "github.com/user/repo/") tests.add("github.com", "github.com") tests.add("github.com/", "github.com/") tests.add("github.com:80/user/repo/", "github.com/user/repo/") tests.add("github.com:80/user/repo", "github.com/user/repo") tests.add("github.com:80/user", "github.com/user") tests.add("github.com:80", "github.com") runTestCase(tests) { `in` -> removePort(`in`) } } fun testGetUserAndRepositoryFromRemoteUrl() { val tests = TestCase<GHRepositoryPath?>() tests.add("http://github.com/username/reponame/", GHRepositoryPath("username", "reponame")) tests.add("https://github.com/username/reponame/", GHRepositoryPath("username", "reponame")) tests.add("git://github.com/username/reponame/", GHRepositoryPath("username", "reponame")) tests.add("[email protected]:username/reponame/", GHRepositoryPath("username", "reponame")) tests.add("https://github.com/username/reponame", GHRepositoryPath("username", "reponame")) tests.add("https://github.com/username/reponame.git", GHRepositoryPath("username", "reponame")) tests.add("https://github.com/username/reponame.git/", GHRepositoryPath("username", "reponame")) tests.add("[email protected]:username/reponame.git/", GHRepositoryPath("username", "reponame")) tests.add("http://login:[email protected]/username/reponame/", GHRepositoryPath("username", "reponame")) tests.add("HTTPS://GitHub.com/username/reponame/", GHRepositoryPath("username", "reponame")) tests.add("https://github.com/UserName/RepoName/", GHRepositoryPath("UserName", "RepoName")) tests.add("https://github.com/RepoName/", null) tests.add("[email protected]:user/", null) tests.add("https://user:[email protected]/", null) runTestCase(tests) { `in` -> getUserAndRepositoryFromRemoteUrl(`in`) } } fun testMakeGithubRepoFromRemoteUrl() { val tests = TestCase<String?>() tests.add("http://github.com/username/reponame/", "https://github.com/username/reponame") tests.add("https://github.com/username/reponame/", "https://github.com/username/reponame") tests.add("git://github.com/username/reponame/", "https://github.com/username/reponame") tests.add("[email protected]:username/reponame/", "https://github.com/username/reponame") tests.add("https://github.com/username/reponame", "https://github.com/username/reponame") tests.add("https://github.com/username/reponame.git", "https://github.com/username/reponame") tests.add("https://github.com/username/reponame.git/", "https://github.com/username/reponame") tests.add("[email protected]:username/reponame.git/", "https://github.com/username/reponame") tests.add("[email protected]:username/reponame/", "https://github.com/username/reponame") tests.add("http://login:[email protected]/username/reponame/", "https://github.com/username/reponame") tests.add("HTTPS://GitHub.com/username/reponame/", "https://github.com/username/reponame") tests.add("https://github.com/UserName/RepoName/", "https://github.com/UserName/RepoName") tests.add("https://github.com/RepoName/", null) tests.add("[email protected]:user/", null) tests.add("https://user:[email protected]/", null) runTestCase(tests) { `in` -> makeGithubRepoUrlFromRemoteUrl(`in`, "https://github.com") } } fun testGetHostFromUrl() { val tests = TestCase<String>() tests.add("github.com", "github.com") tests.add("api.github.com", "api.github.com") tests.add("github.com/", "github.com") tests.add("api.github.com/", "api.github.com") tests.add("github.com/user/repo/", "github.com") tests.add("api.github.com/user/repo/", "api.github.com") tests.add("http://github.com/user/repo/", "github.com") tests.add("https://github.com/user/repo/", "github.com") tests.add("git://github.com/user/repo/", "github.com") tests.add("[email protected]:user/repo/", "github.com") tests.add("[email protected]:username/repo/", "github.com") tests.add("https://username:[email protected]/user/repo/", "github.com") tests.add("https://[email protected]/user/repo/", "github.com") tests.add("https://github.com:2233/user/repo/", "github.com") tests.add("HTTP://GITHUB.com/user/repo/", "GITHUB.com") tests.add("HttP://GitHub.com/user/repo/", "GitHub.com") runTestCase(tests) { `in` -> getHostFromUrl(`in`) } } fun testGetApiUrl() { val tests = TestCase<String>() tests.add("github.com", "https://api.github.com") tests.add("https://github.com/", "https://api.github.com") tests.add("https://my.site.com/", "https://my.site.com/api/v3") tests.add("https://api.site.com/", "https://api.site.com/api/v3") tests.add("https://url.github.com/", "https://url.github.com/api/v3") tests.add("my.site.com/", "https://my.site.com/api/v3") tests.add("api.site.com/", "https://api.site.com/api/v3") tests.add("url.github.com/", "https://url.github.com/api/v3") tests.add("http://my.site.com/", "http://my.site.com/api/v3") tests.add("http://api.site.com/", "http://api.site.com/api/v3") tests.add("http://url.github.com/", "http://url.github.com/api/v3") tests.add("HTTP://GITHUB.com", "http://api.github.com") tests.add("HttP://GitHub.com/", "http://api.github.com") tests.add("https://ghe.com/suffix", "https://ghe.com/suffix/api/v3") tests.add("https://ghe.com/suFFix", "https://ghe.com/suFFix/api/v3") runTestCase(tests) { `in` -> getApiUrl(`in`) } } }
plugins/github/test/org/jetbrains/plugins/github/GithubUrlUtilTest.kt
734434506
// Copyright 2000-2021 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.internal.statistic.actions import com.intellij.icons.AllIcons import com.intellij.idea.ActionsBundle import com.intellij.internal.statistic.StatisticsBundle import com.intellij.internal.statistic.StatisticsDevKitUtil import com.intellij.internal.statistic.actions.OpenEventsSchemeFileAction.Companion.openFileInEditor import com.intellij.internal.statistic.eventLog.validator.storage.persistence.EventLogTestMetadataPersistence import com.intellij.internal.statistic.utils.StatisticsRecorderUtil import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.DumbAwareAction private class OpenEventsTestSchemeFileAction(private val myRecorderId: String = StatisticsDevKitUtil.DEFAULT_RECORDER) : DumbAwareAction(StatisticsBundle.message("stats.open.0.test.scheme.file", myRecorderId), ActionsBundle.message("group.OpenEventsTestSchemeFileAction.description"), AllIcons.FileTypes.Any_type) { override fun update(event: AnActionEvent) { event.presentation.isEnabled = StatisticsRecorderUtil.isTestModeEnabled(myRecorderId) } override fun actionPerformed(e: AnActionEvent) { val project = e.project ?: return val file = EventLogTestMetadataPersistence(myRecorderId).eventsTestSchemeFile openFileInEditor(file, project) } }
platform/statistics/devkit/src/com/intellij/internal/statistic/actions/OpenEventsTestSchemeFileAction.kt
191226921
// Auto-generated by GenerateInRangeExpressionTestData. Do not edit! // WITH_RUNTIME val intArray = intArrayOf(1, 2, 3) val objectArray = arrayOf(1, 2, 3) val emptyIntArray = intArrayOf() val emptyObjectArray = arrayOf<Any>() val range0 = intArray.indices val range1 = objectArray.indices val range2 = emptyIntArray.indices val range3 = emptyObjectArray.indices val element0 = (-1).toByte() val element1 = (-1).toShort() val element2 = (-1) val element3 = (-1).toLong() val element4 = (-1).toFloat() val element5 = (-1).toDouble() val element6 = 0.toByte() val element7 = 0.toShort() val element8 = 0 val element9 = 0.toLong() val element10 = 0.toFloat() val element11 = 0.toDouble() val element12 = 1.toByte() val element13 = 1.toShort() val element14 = 1 val element15 = 1.toLong() val element16 = 1.toFloat() val element17 = 1.toDouble() val element18 = 2.toByte() val element19 = 2.toShort() val element20 = 2 val element21 = 2.toLong() val element22 = 2.toFloat() val element23 = 2.toDouble() val element24 = 3.toByte() val element25 = 3.toShort() val element26 = 3 val element27 = 3.toLong() val element28 = 3.toFloat() val element29 = 3.toDouble() val element30 = 4.toByte() val element31 = 4.toShort() val element32 = 4 val element33 = 4.toLong() val element34 = 4.toFloat() val element35 = 4.toDouble() fun box(): String { testR0xE0() testR0xE1() testR0xE2() testR0xE3() testR0xE4() testR0xE5() testR0xE6() testR0xE7() testR0xE8() testR0xE9() testR0xE10() testR0xE11() testR0xE12() testR0xE13() testR0xE14() testR0xE15() testR0xE16() testR0xE17() testR0xE18() testR0xE19() testR0xE20() testR0xE21() testR0xE22() testR0xE23() testR0xE24() testR0xE25() testR0xE26() testR0xE27() testR0xE28() testR0xE29() testR0xE30() testR0xE31() testR0xE32() testR0xE33() testR0xE34() testR0xE35() testR1xE0() testR1xE1() testR1xE2() testR1xE3() testR1xE4() testR1xE5() testR1xE6() testR1xE7() testR1xE8() testR1xE9() testR1xE10() testR1xE11() testR1xE12() testR1xE13() testR1xE14() testR1xE15() testR1xE16() testR1xE17() testR1xE18() testR1xE19() testR1xE20() testR1xE21() testR1xE22() testR1xE23() testR1xE24() testR1xE25() testR1xE26() testR1xE27() testR1xE28() testR1xE29() testR1xE30() testR1xE31() testR1xE32() testR1xE33() testR1xE34() testR1xE35() testR2xE0() testR2xE1() testR2xE2() testR2xE3() testR2xE4() testR2xE5() testR2xE6() testR2xE7() testR2xE8() testR2xE9() testR2xE10() testR2xE11() testR2xE12() testR2xE13() testR2xE14() testR2xE15() testR2xE16() testR2xE17() testR2xE18() testR2xE19() testR2xE20() testR2xE21() testR2xE22() testR2xE23() testR2xE24() testR2xE25() testR2xE26() testR2xE27() testR2xE28() testR2xE29() testR2xE30() testR2xE31() testR2xE32() testR2xE33() testR2xE34() testR2xE35() testR3xE0() testR3xE1() testR3xE2() testR3xE3() testR3xE4() testR3xE5() testR3xE6() testR3xE7() testR3xE8() testR3xE9() testR3xE10() testR3xE11() testR3xE12() testR3xE13() testR3xE14() testR3xE15() testR3xE16() testR3xE17() testR3xE18() testR3xE19() testR3xE20() testR3xE21() testR3xE22() testR3xE23() testR3xE24() testR3xE25() testR3xE26() testR3xE27() testR3xE28() testR3xE29() testR3xE30() testR3xE31() testR3xE32() testR3xE33() testR3xE34() testR3xE35() return "OK" } fun testR0xE0() { // with possible local optimizations if ((-1).toByte() in intArray.indices != range0.contains((-1).toByte())) throw AssertionError() if ((-1).toByte() !in intArray.indices != !range0.contains((-1).toByte())) throw AssertionError() if (!((-1).toByte() in intArray.indices) != !range0.contains((-1).toByte())) throw AssertionError() if (!((-1).toByte() !in intArray.indices) != range0.contains((-1).toByte())) throw AssertionError() // no local optimizations if (element0 in intArray.indices != range0.contains(element0)) throw AssertionError() if (element0 !in intArray.indices != !range0.contains(element0)) throw AssertionError() if (!(element0 in intArray.indices) != !range0.contains(element0)) throw AssertionError() if (!(element0 !in intArray.indices) != range0.contains(element0)) throw AssertionError() } fun testR0xE1() { // with possible local optimizations if ((-1).toShort() in intArray.indices != range0.contains((-1).toShort())) throw AssertionError() if ((-1).toShort() !in intArray.indices != !range0.contains((-1).toShort())) throw AssertionError() if (!((-1).toShort() in intArray.indices) != !range0.contains((-1).toShort())) throw AssertionError() if (!((-1).toShort() !in intArray.indices) != range0.contains((-1).toShort())) throw AssertionError() // no local optimizations if (element1 in intArray.indices != range0.contains(element1)) throw AssertionError() if (element1 !in intArray.indices != !range0.contains(element1)) throw AssertionError() if (!(element1 in intArray.indices) != !range0.contains(element1)) throw AssertionError() if (!(element1 !in intArray.indices) != range0.contains(element1)) throw AssertionError() } fun testR0xE2() { // with possible local optimizations if ((-1) in intArray.indices != range0.contains((-1))) throw AssertionError() if ((-1) !in intArray.indices != !range0.contains((-1))) throw AssertionError() if (!((-1) in intArray.indices) != !range0.contains((-1))) throw AssertionError() if (!((-1) !in intArray.indices) != range0.contains((-1))) throw AssertionError() // no local optimizations if (element2 in intArray.indices != range0.contains(element2)) throw AssertionError() if (element2 !in intArray.indices != !range0.contains(element2)) throw AssertionError() if (!(element2 in intArray.indices) != !range0.contains(element2)) throw AssertionError() if (!(element2 !in intArray.indices) != range0.contains(element2)) throw AssertionError() } fun testR0xE3() { // with possible local optimizations if ((-1).toLong() in intArray.indices != range0.contains((-1).toLong())) throw AssertionError() if ((-1).toLong() !in intArray.indices != !range0.contains((-1).toLong())) throw AssertionError() if (!((-1).toLong() in intArray.indices) != !range0.contains((-1).toLong())) throw AssertionError() if (!((-1).toLong() !in intArray.indices) != range0.contains((-1).toLong())) throw AssertionError() // no local optimizations if (element3 in intArray.indices != range0.contains(element3)) throw AssertionError() if (element3 !in intArray.indices != !range0.contains(element3)) throw AssertionError() if (!(element3 in intArray.indices) != !range0.contains(element3)) throw AssertionError() if (!(element3 !in intArray.indices) != range0.contains(element3)) throw AssertionError() } fun testR0xE4() { // with possible local optimizations if ((-1).toFloat() in intArray.indices != range0.contains((-1).toFloat())) throw AssertionError() if ((-1).toFloat() !in intArray.indices != !range0.contains((-1).toFloat())) throw AssertionError() if (!((-1).toFloat() in intArray.indices) != !range0.contains((-1).toFloat())) throw AssertionError() if (!((-1).toFloat() !in intArray.indices) != range0.contains((-1).toFloat())) throw AssertionError() // no local optimizations if (element4 in intArray.indices != range0.contains(element4)) throw AssertionError() if (element4 !in intArray.indices != !range0.contains(element4)) throw AssertionError() if (!(element4 in intArray.indices) != !range0.contains(element4)) throw AssertionError() if (!(element4 !in intArray.indices) != range0.contains(element4)) throw AssertionError() } fun testR0xE5() { // with possible local optimizations if ((-1).toDouble() in intArray.indices != range0.contains((-1).toDouble())) throw AssertionError() if ((-1).toDouble() !in intArray.indices != !range0.contains((-1).toDouble())) throw AssertionError() if (!((-1).toDouble() in intArray.indices) != !range0.contains((-1).toDouble())) throw AssertionError() if (!((-1).toDouble() !in intArray.indices) != range0.contains((-1).toDouble())) throw AssertionError() // no local optimizations if (element5 in intArray.indices != range0.contains(element5)) throw AssertionError() if (element5 !in intArray.indices != !range0.contains(element5)) throw AssertionError() if (!(element5 in intArray.indices) != !range0.contains(element5)) throw AssertionError() if (!(element5 !in intArray.indices) != range0.contains(element5)) throw AssertionError() } fun testR0xE6() { // with possible local optimizations if (0.toByte() in intArray.indices != range0.contains(0.toByte())) throw AssertionError() if (0.toByte() !in intArray.indices != !range0.contains(0.toByte())) throw AssertionError() if (!(0.toByte() in intArray.indices) != !range0.contains(0.toByte())) throw AssertionError() if (!(0.toByte() !in intArray.indices) != range0.contains(0.toByte())) throw AssertionError() // no local optimizations if (element6 in intArray.indices != range0.contains(element6)) throw AssertionError() if (element6 !in intArray.indices != !range0.contains(element6)) throw AssertionError() if (!(element6 in intArray.indices) != !range0.contains(element6)) throw AssertionError() if (!(element6 !in intArray.indices) != range0.contains(element6)) throw AssertionError() } fun testR0xE7() { // with possible local optimizations if (0.toShort() in intArray.indices != range0.contains(0.toShort())) throw AssertionError() if (0.toShort() !in intArray.indices != !range0.contains(0.toShort())) throw AssertionError() if (!(0.toShort() in intArray.indices) != !range0.contains(0.toShort())) throw AssertionError() if (!(0.toShort() !in intArray.indices) != range0.contains(0.toShort())) throw AssertionError() // no local optimizations if (element7 in intArray.indices != range0.contains(element7)) throw AssertionError() if (element7 !in intArray.indices != !range0.contains(element7)) throw AssertionError() if (!(element7 in intArray.indices) != !range0.contains(element7)) throw AssertionError() if (!(element7 !in intArray.indices) != range0.contains(element7)) throw AssertionError() } fun testR0xE8() { // with possible local optimizations if (0 in intArray.indices != range0.contains(0)) throw AssertionError() if (0 !in intArray.indices != !range0.contains(0)) throw AssertionError() if (!(0 in intArray.indices) != !range0.contains(0)) throw AssertionError() if (!(0 !in intArray.indices) != range0.contains(0)) throw AssertionError() // no local optimizations if (element8 in intArray.indices != range0.contains(element8)) throw AssertionError() if (element8 !in intArray.indices != !range0.contains(element8)) throw AssertionError() if (!(element8 in intArray.indices) != !range0.contains(element8)) throw AssertionError() if (!(element8 !in intArray.indices) != range0.contains(element8)) throw AssertionError() } fun testR0xE9() { // with possible local optimizations if (0.toLong() in intArray.indices != range0.contains(0.toLong())) throw AssertionError() if (0.toLong() !in intArray.indices != !range0.contains(0.toLong())) throw AssertionError() if (!(0.toLong() in intArray.indices) != !range0.contains(0.toLong())) throw AssertionError() if (!(0.toLong() !in intArray.indices) != range0.contains(0.toLong())) throw AssertionError() // no local optimizations if (element9 in intArray.indices != range0.contains(element9)) throw AssertionError() if (element9 !in intArray.indices != !range0.contains(element9)) throw AssertionError() if (!(element9 in intArray.indices) != !range0.contains(element9)) throw AssertionError() if (!(element9 !in intArray.indices) != range0.contains(element9)) throw AssertionError() } fun testR0xE10() { // with possible local optimizations if (0.toFloat() in intArray.indices != range0.contains(0.toFloat())) throw AssertionError() if (0.toFloat() !in intArray.indices != !range0.contains(0.toFloat())) throw AssertionError() if (!(0.toFloat() in intArray.indices) != !range0.contains(0.toFloat())) throw AssertionError() if (!(0.toFloat() !in intArray.indices) != range0.contains(0.toFloat())) throw AssertionError() // no local optimizations if (element10 in intArray.indices != range0.contains(element10)) throw AssertionError() if (element10 !in intArray.indices != !range0.contains(element10)) throw AssertionError() if (!(element10 in intArray.indices) != !range0.contains(element10)) throw AssertionError() if (!(element10 !in intArray.indices) != range0.contains(element10)) throw AssertionError() } fun testR0xE11() { // with possible local optimizations if (0.toDouble() in intArray.indices != range0.contains(0.toDouble())) throw AssertionError() if (0.toDouble() !in intArray.indices != !range0.contains(0.toDouble())) throw AssertionError() if (!(0.toDouble() in intArray.indices) != !range0.contains(0.toDouble())) throw AssertionError() if (!(0.toDouble() !in intArray.indices) != range0.contains(0.toDouble())) throw AssertionError() // no local optimizations if (element11 in intArray.indices != range0.contains(element11)) throw AssertionError() if (element11 !in intArray.indices != !range0.contains(element11)) throw AssertionError() if (!(element11 in intArray.indices) != !range0.contains(element11)) throw AssertionError() if (!(element11 !in intArray.indices) != range0.contains(element11)) throw AssertionError() } fun testR0xE12() { // with possible local optimizations if (1.toByte() in intArray.indices != range0.contains(1.toByte())) throw AssertionError() if (1.toByte() !in intArray.indices != !range0.contains(1.toByte())) throw AssertionError() if (!(1.toByte() in intArray.indices) != !range0.contains(1.toByte())) throw AssertionError() if (!(1.toByte() !in intArray.indices) != range0.contains(1.toByte())) throw AssertionError() // no local optimizations if (element12 in intArray.indices != range0.contains(element12)) throw AssertionError() if (element12 !in intArray.indices != !range0.contains(element12)) throw AssertionError() if (!(element12 in intArray.indices) != !range0.contains(element12)) throw AssertionError() if (!(element12 !in intArray.indices) != range0.contains(element12)) throw AssertionError() } fun testR0xE13() { // with possible local optimizations if (1.toShort() in intArray.indices != range0.contains(1.toShort())) throw AssertionError() if (1.toShort() !in intArray.indices != !range0.contains(1.toShort())) throw AssertionError() if (!(1.toShort() in intArray.indices) != !range0.contains(1.toShort())) throw AssertionError() if (!(1.toShort() !in intArray.indices) != range0.contains(1.toShort())) throw AssertionError() // no local optimizations if (element13 in intArray.indices != range0.contains(element13)) throw AssertionError() if (element13 !in intArray.indices != !range0.contains(element13)) throw AssertionError() if (!(element13 in intArray.indices) != !range0.contains(element13)) throw AssertionError() if (!(element13 !in intArray.indices) != range0.contains(element13)) throw AssertionError() } fun testR0xE14() { // with possible local optimizations if (1 in intArray.indices != range0.contains(1)) throw AssertionError() if (1 !in intArray.indices != !range0.contains(1)) throw AssertionError() if (!(1 in intArray.indices) != !range0.contains(1)) throw AssertionError() if (!(1 !in intArray.indices) != range0.contains(1)) throw AssertionError() // no local optimizations if (element14 in intArray.indices != range0.contains(element14)) throw AssertionError() if (element14 !in intArray.indices != !range0.contains(element14)) throw AssertionError() if (!(element14 in intArray.indices) != !range0.contains(element14)) throw AssertionError() if (!(element14 !in intArray.indices) != range0.contains(element14)) throw AssertionError() } fun testR0xE15() { // with possible local optimizations if (1.toLong() in intArray.indices != range0.contains(1.toLong())) throw AssertionError() if (1.toLong() !in intArray.indices != !range0.contains(1.toLong())) throw AssertionError() if (!(1.toLong() in intArray.indices) != !range0.contains(1.toLong())) throw AssertionError() if (!(1.toLong() !in intArray.indices) != range0.contains(1.toLong())) throw AssertionError() // no local optimizations if (element15 in intArray.indices != range0.contains(element15)) throw AssertionError() if (element15 !in intArray.indices != !range0.contains(element15)) throw AssertionError() if (!(element15 in intArray.indices) != !range0.contains(element15)) throw AssertionError() if (!(element15 !in intArray.indices) != range0.contains(element15)) throw AssertionError() } fun testR0xE16() { // with possible local optimizations if (1.toFloat() in intArray.indices != range0.contains(1.toFloat())) throw AssertionError() if (1.toFloat() !in intArray.indices != !range0.contains(1.toFloat())) throw AssertionError() if (!(1.toFloat() in intArray.indices) != !range0.contains(1.toFloat())) throw AssertionError() if (!(1.toFloat() !in intArray.indices) != range0.contains(1.toFloat())) throw AssertionError() // no local optimizations if (element16 in intArray.indices != range0.contains(element16)) throw AssertionError() if (element16 !in intArray.indices != !range0.contains(element16)) throw AssertionError() if (!(element16 in intArray.indices) != !range0.contains(element16)) throw AssertionError() if (!(element16 !in intArray.indices) != range0.contains(element16)) throw AssertionError() } fun testR0xE17() { // with possible local optimizations if (1.toDouble() in intArray.indices != range0.contains(1.toDouble())) throw AssertionError() if (1.toDouble() !in intArray.indices != !range0.contains(1.toDouble())) throw AssertionError() if (!(1.toDouble() in intArray.indices) != !range0.contains(1.toDouble())) throw AssertionError() if (!(1.toDouble() !in intArray.indices) != range0.contains(1.toDouble())) throw AssertionError() // no local optimizations if (element17 in intArray.indices != range0.contains(element17)) throw AssertionError() if (element17 !in intArray.indices != !range0.contains(element17)) throw AssertionError() if (!(element17 in intArray.indices) != !range0.contains(element17)) throw AssertionError() if (!(element17 !in intArray.indices) != range0.contains(element17)) throw AssertionError() } fun testR0xE18() { // with possible local optimizations if (2.toByte() in intArray.indices != range0.contains(2.toByte())) throw AssertionError() if (2.toByte() !in intArray.indices != !range0.contains(2.toByte())) throw AssertionError() if (!(2.toByte() in intArray.indices) != !range0.contains(2.toByte())) throw AssertionError() if (!(2.toByte() !in intArray.indices) != range0.contains(2.toByte())) throw AssertionError() // no local optimizations if (element18 in intArray.indices != range0.contains(element18)) throw AssertionError() if (element18 !in intArray.indices != !range0.contains(element18)) throw AssertionError() if (!(element18 in intArray.indices) != !range0.contains(element18)) throw AssertionError() if (!(element18 !in intArray.indices) != range0.contains(element18)) throw AssertionError() } fun testR0xE19() { // with possible local optimizations if (2.toShort() in intArray.indices != range0.contains(2.toShort())) throw AssertionError() if (2.toShort() !in intArray.indices != !range0.contains(2.toShort())) throw AssertionError() if (!(2.toShort() in intArray.indices) != !range0.contains(2.toShort())) throw AssertionError() if (!(2.toShort() !in intArray.indices) != range0.contains(2.toShort())) throw AssertionError() // no local optimizations if (element19 in intArray.indices != range0.contains(element19)) throw AssertionError() if (element19 !in intArray.indices != !range0.contains(element19)) throw AssertionError() if (!(element19 in intArray.indices) != !range0.contains(element19)) throw AssertionError() if (!(element19 !in intArray.indices) != range0.contains(element19)) throw AssertionError() } fun testR0xE20() { // with possible local optimizations if (2 in intArray.indices != range0.contains(2)) throw AssertionError() if (2 !in intArray.indices != !range0.contains(2)) throw AssertionError() if (!(2 in intArray.indices) != !range0.contains(2)) throw AssertionError() if (!(2 !in intArray.indices) != range0.contains(2)) throw AssertionError() // no local optimizations if (element20 in intArray.indices != range0.contains(element20)) throw AssertionError() if (element20 !in intArray.indices != !range0.contains(element20)) throw AssertionError() if (!(element20 in intArray.indices) != !range0.contains(element20)) throw AssertionError() if (!(element20 !in intArray.indices) != range0.contains(element20)) throw AssertionError() } fun testR0xE21() { // with possible local optimizations if (2.toLong() in intArray.indices != range0.contains(2.toLong())) throw AssertionError() if (2.toLong() !in intArray.indices != !range0.contains(2.toLong())) throw AssertionError() if (!(2.toLong() in intArray.indices) != !range0.contains(2.toLong())) throw AssertionError() if (!(2.toLong() !in intArray.indices) != range0.contains(2.toLong())) throw AssertionError() // no local optimizations if (element21 in intArray.indices != range0.contains(element21)) throw AssertionError() if (element21 !in intArray.indices != !range0.contains(element21)) throw AssertionError() if (!(element21 in intArray.indices) != !range0.contains(element21)) throw AssertionError() if (!(element21 !in intArray.indices) != range0.contains(element21)) throw AssertionError() } fun testR0xE22() { // with possible local optimizations if (2.toFloat() in intArray.indices != range0.contains(2.toFloat())) throw AssertionError() if (2.toFloat() !in intArray.indices != !range0.contains(2.toFloat())) throw AssertionError() if (!(2.toFloat() in intArray.indices) != !range0.contains(2.toFloat())) throw AssertionError() if (!(2.toFloat() !in intArray.indices) != range0.contains(2.toFloat())) throw AssertionError() // no local optimizations if (element22 in intArray.indices != range0.contains(element22)) throw AssertionError() if (element22 !in intArray.indices != !range0.contains(element22)) throw AssertionError() if (!(element22 in intArray.indices) != !range0.contains(element22)) throw AssertionError() if (!(element22 !in intArray.indices) != range0.contains(element22)) throw AssertionError() } fun testR0xE23() { // with possible local optimizations if (2.toDouble() in intArray.indices != range0.contains(2.toDouble())) throw AssertionError() if (2.toDouble() !in intArray.indices != !range0.contains(2.toDouble())) throw AssertionError() if (!(2.toDouble() in intArray.indices) != !range0.contains(2.toDouble())) throw AssertionError() if (!(2.toDouble() !in intArray.indices) != range0.contains(2.toDouble())) throw AssertionError() // no local optimizations if (element23 in intArray.indices != range0.contains(element23)) throw AssertionError() if (element23 !in intArray.indices != !range0.contains(element23)) throw AssertionError() if (!(element23 in intArray.indices) != !range0.contains(element23)) throw AssertionError() if (!(element23 !in intArray.indices) != range0.contains(element23)) throw AssertionError() } fun testR0xE24() { // with possible local optimizations if (3.toByte() in intArray.indices != range0.contains(3.toByte())) throw AssertionError() if (3.toByte() !in intArray.indices != !range0.contains(3.toByte())) throw AssertionError() if (!(3.toByte() in intArray.indices) != !range0.contains(3.toByte())) throw AssertionError() if (!(3.toByte() !in intArray.indices) != range0.contains(3.toByte())) throw AssertionError() // no local optimizations if (element24 in intArray.indices != range0.contains(element24)) throw AssertionError() if (element24 !in intArray.indices != !range0.contains(element24)) throw AssertionError() if (!(element24 in intArray.indices) != !range0.contains(element24)) throw AssertionError() if (!(element24 !in intArray.indices) != range0.contains(element24)) throw AssertionError() } fun testR0xE25() { // with possible local optimizations if (3.toShort() in intArray.indices != range0.contains(3.toShort())) throw AssertionError() if (3.toShort() !in intArray.indices != !range0.contains(3.toShort())) throw AssertionError() if (!(3.toShort() in intArray.indices) != !range0.contains(3.toShort())) throw AssertionError() if (!(3.toShort() !in intArray.indices) != range0.contains(3.toShort())) throw AssertionError() // no local optimizations if (element25 in intArray.indices != range0.contains(element25)) throw AssertionError() if (element25 !in intArray.indices != !range0.contains(element25)) throw AssertionError() if (!(element25 in intArray.indices) != !range0.contains(element25)) throw AssertionError() if (!(element25 !in intArray.indices) != range0.contains(element25)) throw AssertionError() } fun testR0xE26() { // with possible local optimizations if (3 in intArray.indices != range0.contains(3)) throw AssertionError() if (3 !in intArray.indices != !range0.contains(3)) throw AssertionError() if (!(3 in intArray.indices) != !range0.contains(3)) throw AssertionError() if (!(3 !in intArray.indices) != range0.contains(3)) throw AssertionError() // no local optimizations if (element26 in intArray.indices != range0.contains(element26)) throw AssertionError() if (element26 !in intArray.indices != !range0.contains(element26)) throw AssertionError() if (!(element26 in intArray.indices) != !range0.contains(element26)) throw AssertionError() if (!(element26 !in intArray.indices) != range0.contains(element26)) throw AssertionError() } fun testR0xE27() { // with possible local optimizations if (3.toLong() in intArray.indices != range0.contains(3.toLong())) throw AssertionError() if (3.toLong() !in intArray.indices != !range0.contains(3.toLong())) throw AssertionError() if (!(3.toLong() in intArray.indices) != !range0.contains(3.toLong())) throw AssertionError() if (!(3.toLong() !in intArray.indices) != range0.contains(3.toLong())) throw AssertionError() // no local optimizations if (element27 in intArray.indices != range0.contains(element27)) throw AssertionError() if (element27 !in intArray.indices != !range0.contains(element27)) throw AssertionError() if (!(element27 in intArray.indices) != !range0.contains(element27)) throw AssertionError() if (!(element27 !in intArray.indices) != range0.contains(element27)) throw AssertionError() } fun testR0xE28() { // with possible local optimizations if (3.toFloat() in intArray.indices != range0.contains(3.toFloat())) throw AssertionError() if (3.toFloat() !in intArray.indices != !range0.contains(3.toFloat())) throw AssertionError() if (!(3.toFloat() in intArray.indices) != !range0.contains(3.toFloat())) throw AssertionError() if (!(3.toFloat() !in intArray.indices) != range0.contains(3.toFloat())) throw AssertionError() // no local optimizations if (element28 in intArray.indices != range0.contains(element28)) throw AssertionError() if (element28 !in intArray.indices != !range0.contains(element28)) throw AssertionError() if (!(element28 in intArray.indices) != !range0.contains(element28)) throw AssertionError() if (!(element28 !in intArray.indices) != range0.contains(element28)) throw AssertionError() } fun testR0xE29() { // with possible local optimizations if (3.toDouble() in intArray.indices != range0.contains(3.toDouble())) throw AssertionError() if (3.toDouble() !in intArray.indices != !range0.contains(3.toDouble())) throw AssertionError() if (!(3.toDouble() in intArray.indices) != !range0.contains(3.toDouble())) throw AssertionError() if (!(3.toDouble() !in intArray.indices) != range0.contains(3.toDouble())) throw AssertionError() // no local optimizations if (element29 in intArray.indices != range0.contains(element29)) throw AssertionError() if (element29 !in intArray.indices != !range0.contains(element29)) throw AssertionError() if (!(element29 in intArray.indices) != !range0.contains(element29)) throw AssertionError() if (!(element29 !in intArray.indices) != range0.contains(element29)) throw AssertionError() } fun testR0xE30() { // with possible local optimizations if (4.toByte() in intArray.indices != range0.contains(4.toByte())) throw AssertionError() if (4.toByte() !in intArray.indices != !range0.contains(4.toByte())) throw AssertionError() if (!(4.toByte() in intArray.indices) != !range0.contains(4.toByte())) throw AssertionError() if (!(4.toByte() !in intArray.indices) != range0.contains(4.toByte())) throw AssertionError() // no local optimizations if (element30 in intArray.indices != range0.contains(element30)) throw AssertionError() if (element30 !in intArray.indices != !range0.contains(element30)) throw AssertionError() if (!(element30 in intArray.indices) != !range0.contains(element30)) throw AssertionError() if (!(element30 !in intArray.indices) != range0.contains(element30)) throw AssertionError() } fun testR0xE31() { // with possible local optimizations if (4.toShort() in intArray.indices != range0.contains(4.toShort())) throw AssertionError() if (4.toShort() !in intArray.indices != !range0.contains(4.toShort())) throw AssertionError() if (!(4.toShort() in intArray.indices) != !range0.contains(4.toShort())) throw AssertionError() if (!(4.toShort() !in intArray.indices) != range0.contains(4.toShort())) throw AssertionError() // no local optimizations if (element31 in intArray.indices != range0.contains(element31)) throw AssertionError() if (element31 !in intArray.indices != !range0.contains(element31)) throw AssertionError() if (!(element31 in intArray.indices) != !range0.contains(element31)) throw AssertionError() if (!(element31 !in intArray.indices) != range0.contains(element31)) throw AssertionError() } fun testR0xE32() { // with possible local optimizations if (4 in intArray.indices != range0.contains(4)) throw AssertionError() if (4 !in intArray.indices != !range0.contains(4)) throw AssertionError() if (!(4 in intArray.indices) != !range0.contains(4)) throw AssertionError() if (!(4 !in intArray.indices) != range0.contains(4)) throw AssertionError() // no local optimizations if (element32 in intArray.indices != range0.contains(element32)) throw AssertionError() if (element32 !in intArray.indices != !range0.contains(element32)) throw AssertionError() if (!(element32 in intArray.indices) != !range0.contains(element32)) throw AssertionError() if (!(element32 !in intArray.indices) != range0.contains(element32)) throw AssertionError() } fun testR0xE33() { // with possible local optimizations if (4.toLong() in intArray.indices != range0.contains(4.toLong())) throw AssertionError() if (4.toLong() !in intArray.indices != !range0.contains(4.toLong())) throw AssertionError() if (!(4.toLong() in intArray.indices) != !range0.contains(4.toLong())) throw AssertionError() if (!(4.toLong() !in intArray.indices) != range0.contains(4.toLong())) throw AssertionError() // no local optimizations if (element33 in intArray.indices != range0.contains(element33)) throw AssertionError() if (element33 !in intArray.indices != !range0.contains(element33)) throw AssertionError() if (!(element33 in intArray.indices) != !range0.contains(element33)) throw AssertionError() if (!(element33 !in intArray.indices) != range0.contains(element33)) throw AssertionError() } fun testR0xE34() { // with possible local optimizations if (4.toFloat() in intArray.indices != range0.contains(4.toFloat())) throw AssertionError() if (4.toFloat() !in intArray.indices != !range0.contains(4.toFloat())) throw AssertionError() if (!(4.toFloat() in intArray.indices) != !range0.contains(4.toFloat())) throw AssertionError() if (!(4.toFloat() !in intArray.indices) != range0.contains(4.toFloat())) throw AssertionError() // no local optimizations if (element34 in intArray.indices != range0.contains(element34)) throw AssertionError() if (element34 !in intArray.indices != !range0.contains(element34)) throw AssertionError() if (!(element34 in intArray.indices) != !range0.contains(element34)) throw AssertionError() if (!(element34 !in intArray.indices) != range0.contains(element34)) throw AssertionError() } fun testR0xE35() { // with possible local optimizations if (4.toDouble() in intArray.indices != range0.contains(4.toDouble())) throw AssertionError() if (4.toDouble() !in intArray.indices != !range0.contains(4.toDouble())) throw AssertionError() if (!(4.toDouble() in intArray.indices) != !range0.contains(4.toDouble())) throw AssertionError() if (!(4.toDouble() !in intArray.indices) != range0.contains(4.toDouble())) throw AssertionError() // no local optimizations if (element35 in intArray.indices != range0.contains(element35)) throw AssertionError() if (element35 !in intArray.indices != !range0.contains(element35)) throw AssertionError() if (!(element35 in intArray.indices) != !range0.contains(element35)) throw AssertionError() if (!(element35 !in intArray.indices) != range0.contains(element35)) throw AssertionError() } fun testR1xE0() { // with possible local optimizations if ((-1).toByte() in objectArray.indices != range1.contains((-1).toByte())) throw AssertionError() if ((-1).toByte() !in objectArray.indices != !range1.contains((-1).toByte())) throw AssertionError() if (!((-1).toByte() in objectArray.indices) != !range1.contains((-1).toByte())) throw AssertionError() if (!((-1).toByte() !in objectArray.indices) != range1.contains((-1).toByte())) throw AssertionError() // no local optimizations if (element0 in objectArray.indices != range1.contains(element0)) throw AssertionError() if (element0 !in objectArray.indices != !range1.contains(element0)) throw AssertionError() if (!(element0 in objectArray.indices) != !range1.contains(element0)) throw AssertionError() if (!(element0 !in objectArray.indices) != range1.contains(element0)) throw AssertionError() } fun testR1xE1() { // with possible local optimizations if ((-1).toShort() in objectArray.indices != range1.contains((-1).toShort())) throw AssertionError() if ((-1).toShort() !in objectArray.indices != !range1.contains((-1).toShort())) throw AssertionError() if (!((-1).toShort() in objectArray.indices) != !range1.contains((-1).toShort())) throw AssertionError() if (!((-1).toShort() !in objectArray.indices) != range1.contains((-1).toShort())) throw AssertionError() // no local optimizations if (element1 in objectArray.indices != range1.contains(element1)) throw AssertionError() if (element1 !in objectArray.indices != !range1.contains(element1)) throw AssertionError() if (!(element1 in objectArray.indices) != !range1.contains(element1)) throw AssertionError() if (!(element1 !in objectArray.indices) != range1.contains(element1)) throw AssertionError() } fun testR1xE2() { // with possible local optimizations if ((-1) in objectArray.indices != range1.contains((-1))) throw AssertionError() if ((-1) !in objectArray.indices != !range1.contains((-1))) throw AssertionError() if (!((-1) in objectArray.indices) != !range1.contains((-1))) throw AssertionError() if (!((-1) !in objectArray.indices) != range1.contains((-1))) throw AssertionError() // no local optimizations if (element2 in objectArray.indices != range1.contains(element2)) throw AssertionError() if (element2 !in objectArray.indices != !range1.contains(element2)) throw AssertionError() if (!(element2 in objectArray.indices) != !range1.contains(element2)) throw AssertionError() if (!(element2 !in objectArray.indices) != range1.contains(element2)) throw AssertionError() } fun testR1xE3() { // with possible local optimizations if ((-1).toLong() in objectArray.indices != range1.contains((-1).toLong())) throw AssertionError() if ((-1).toLong() !in objectArray.indices != !range1.contains((-1).toLong())) throw AssertionError() if (!((-1).toLong() in objectArray.indices) != !range1.contains((-1).toLong())) throw AssertionError() if (!((-1).toLong() !in objectArray.indices) != range1.contains((-1).toLong())) throw AssertionError() // no local optimizations if (element3 in objectArray.indices != range1.contains(element3)) throw AssertionError() if (element3 !in objectArray.indices != !range1.contains(element3)) throw AssertionError() if (!(element3 in objectArray.indices) != !range1.contains(element3)) throw AssertionError() if (!(element3 !in objectArray.indices) != range1.contains(element3)) throw AssertionError() } fun testR1xE4() { // with possible local optimizations if ((-1).toFloat() in objectArray.indices != range1.contains((-1).toFloat())) throw AssertionError() if ((-1).toFloat() !in objectArray.indices != !range1.contains((-1).toFloat())) throw AssertionError() if (!((-1).toFloat() in objectArray.indices) != !range1.contains((-1).toFloat())) throw AssertionError() if (!((-1).toFloat() !in objectArray.indices) != range1.contains((-1).toFloat())) throw AssertionError() // no local optimizations if (element4 in objectArray.indices != range1.contains(element4)) throw AssertionError() if (element4 !in objectArray.indices != !range1.contains(element4)) throw AssertionError() if (!(element4 in objectArray.indices) != !range1.contains(element4)) throw AssertionError() if (!(element4 !in objectArray.indices) != range1.contains(element4)) throw AssertionError() } fun testR1xE5() { // with possible local optimizations if ((-1).toDouble() in objectArray.indices != range1.contains((-1).toDouble())) throw AssertionError() if ((-1).toDouble() !in objectArray.indices != !range1.contains((-1).toDouble())) throw AssertionError() if (!((-1).toDouble() in objectArray.indices) != !range1.contains((-1).toDouble())) throw AssertionError() if (!((-1).toDouble() !in objectArray.indices) != range1.contains((-1).toDouble())) throw AssertionError() // no local optimizations if (element5 in objectArray.indices != range1.contains(element5)) throw AssertionError() if (element5 !in objectArray.indices != !range1.contains(element5)) throw AssertionError() if (!(element5 in objectArray.indices) != !range1.contains(element5)) throw AssertionError() if (!(element5 !in objectArray.indices) != range1.contains(element5)) throw AssertionError() } fun testR1xE6() { // with possible local optimizations if (0.toByte() in objectArray.indices != range1.contains(0.toByte())) throw AssertionError() if (0.toByte() !in objectArray.indices != !range1.contains(0.toByte())) throw AssertionError() if (!(0.toByte() in objectArray.indices) != !range1.contains(0.toByte())) throw AssertionError() if (!(0.toByte() !in objectArray.indices) != range1.contains(0.toByte())) throw AssertionError() // no local optimizations if (element6 in objectArray.indices != range1.contains(element6)) throw AssertionError() if (element6 !in objectArray.indices != !range1.contains(element6)) throw AssertionError() if (!(element6 in objectArray.indices) != !range1.contains(element6)) throw AssertionError() if (!(element6 !in objectArray.indices) != range1.contains(element6)) throw AssertionError() } fun testR1xE7() { // with possible local optimizations if (0.toShort() in objectArray.indices != range1.contains(0.toShort())) throw AssertionError() if (0.toShort() !in objectArray.indices != !range1.contains(0.toShort())) throw AssertionError() if (!(0.toShort() in objectArray.indices) != !range1.contains(0.toShort())) throw AssertionError() if (!(0.toShort() !in objectArray.indices) != range1.contains(0.toShort())) throw AssertionError() // no local optimizations if (element7 in objectArray.indices != range1.contains(element7)) throw AssertionError() if (element7 !in objectArray.indices != !range1.contains(element7)) throw AssertionError() if (!(element7 in objectArray.indices) != !range1.contains(element7)) throw AssertionError() if (!(element7 !in objectArray.indices) != range1.contains(element7)) throw AssertionError() } fun testR1xE8() { // with possible local optimizations if (0 in objectArray.indices != range1.contains(0)) throw AssertionError() if (0 !in objectArray.indices != !range1.contains(0)) throw AssertionError() if (!(0 in objectArray.indices) != !range1.contains(0)) throw AssertionError() if (!(0 !in objectArray.indices) != range1.contains(0)) throw AssertionError() // no local optimizations if (element8 in objectArray.indices != range1.contains(element8)) throw AssertionError() if (element8 !in objectArray.indices != !range1.contains(element8)) throw AssertionError() if (!(element8 in objectArray.indices) != !range1.contains(element8)) throw AssertionError() if (!(element8 !in objectArray.indices) != range1.contains(element8)) throw AssertionError() } fun testR1xE9() { // with possible local optimizations if (0.toLong() in objectArray.indices != range1.contains(0.toLong())) throw AssertionError() if (0.toLong() !in objectArray.indices != !range1.contains(0.toLong())) throw AssertionError() if (!(0.toLong() in objectArray.indices) != !range1.contains(0.toLong())) throw AssertionError() if (!(0.toLong() !in objectArray.indices) != range1.contains(0.toLong())) throw AssertionError() // no local optimizations if (element9 in objectArray.indices != range1.contains(element9)) throw AssertionError() if (element9 !in objectArray.indices != !range1.contains(element9)) throw AssertionError() if (!(element9 in objectArray.indices) != !range1.contains(element9)) throw AssertionError() if (!(element9 !in objectArray.indices) != range1.contains(element9)) throw AssertionError() } fun testR1xE10() { // with possible local optimizations if (0.toFloat() in objectArray.indices != range1.contains(0.toFloat())) throw AssertionError() if (0.toFloat() !in objectArray.indices != !range1.contains(0.toFloat())) throw AssertionError() if (!(0.toFloat() in objectArray.indices) != !range1.contains(0.toFloat())) throw AssertionError() if (!(0.toFloat() !in objectArray.indices) != range1.contains(0.toFloat())) throw AssertionError() // no local optimizations if (element10 in objectArray.indices != range1.contains(element10)) throw AssertionError() if (element10 !in objectArray.indices != !range1.contains(element10)) throw AssertionError() if (!(element10 in objectArray.indices) != !range1.contains(element10)) throw AssertionError() if (!(element10 !in objectArray.indices) != range1.contains(element10)) throw AssertionError() } fun testR1xE11() { // with possible local optimizations if (0.toDouble() in objectArray.indices != range1.contains(0.toDouble())) throw AssertionError() if (0.toDouble() !in objectArray.indices != !range1.contains(0.toDouble())) throw AssertionError() if (!(0.toDouble() in objectArray.indices) != !range1.contains(0.toDouble())) throw AssertionError() if (!(0.toDouble() !in objectArray.indices) != range1.contains(0.toDouble())) throw AssertionError() // no local optimizations if (element11 in objectArray.indices != range1.contains(element11)) throw AssertionError() if (element11 !in objectArray.indices != !range1.contains(element11)) throw AssertionError() if (!(element11 in objectArray.indices) != !range1.contains(element11)) throw AssertionError() if (!(element11 !in objectArray.indices) != range1.contains(element11)) throw AssertionError() } fun testR1xE12() { // with possible local optimizations if (1.toByte() in objectArray.indices != range1.contains(1.toByte())) throw AssertionError() if (1.toByte() !in objectArray.indices != !range1.contains(1.toByte())) throw AssertionError() if (!(1.toByte() in objectArray.indices) != !range1.contains(1.toByte())) throw AssertionError() if (!(1.toByte() !in objectArray.indices) != range1.contains(1.toByte())) throw AssertionError() // no local optimizations if (element12 in objectArray.indices != range1.contains(element12)) throw AssertionError() if (element12 !in objectArray.indices != !range1.contains(element12)) throw AssertionError() if (!(element12 in objectArray.indices) != !range1.contains(element12)) throw AssertionError() if (!(element12 !in objectArray.indices) != range1.contains(element12)) throw AssertionError() } fun testR1xE13() { // with possible local optimizations if (1.toShort() in objectArray.indices != range1.contains(1.toShort())) throw AssertionError() if (1.toShort() !in objectArray.indices != !range1.contains(1.toShort())) throw AssertionError() if (!(1.toShort() in objectArray.indices) != !range1.contains(1.toShort())) throw AssertionError() if (!(1.toShort() !in objectArray.indices) != range1.contains(1.toShort())) throw AssertionError() // no local optimizations if (element13 in objectArray.indices != range1.contains(element13)) throw AssertionError() if (element13 !in objectArray.indices != !range1.contains(element13)) throw AssertionError() if (!(element13 in objectArray.indices) != !range1.contains(element13)) throw AssertionError() if (!(element13 !in objectArray.indices) != range1.contains(element13)) throw AssertionError() } fun testR1xE14() { // with possible local optimizations if (1 in objectArray.indices != range1.contains(1)) throw AssertionError() if (1 !in objectArray.indices != !range1.contains(1)) throw AssertionError() if (!(1 in objectArray.indices) != !range1.contains(1)) throw AssertionError() if (!(1 !in objectArray.indices) != range1.contains(1)) throw AssertionError() // no local optimizations if (element14 in objectArray.indices != range1.contains(element14)) throw AssertionError() if (element14 !in objectArray.indices != !range1.contains(element14)) throw AssertionError() if (!(element14 in objectArray.indices) != !range1.contains(element14)) throw AssertionError() if (!(element14 !in objectArray.indices) != range1.contains(element14)) throw AssertionError() } fun testR1xE15() { // with possible local optimizations if (1.toLong() in objectArray.indices != range1.contains(1.toLong())) throw AssertionError() if (1.toLong() !in objectArray.indices != !range1.contains(1.toLong())) throw AssertionError() if (!(1.toLong() in objectArray.indices) != !range1.contains(1.toLong())) throw AssertionError() if (!(1.toLong() !in objectArray.indices) != range1.contains(1.toLong())) throw AssertionError() // no local optimizations if (element15 in objectArray.indices != range1.contains(element15)) throw AssertionError() if (element15 !in objectArray.indices != !range1.contains(element15)) throw AssertionError() if (!(element15 in objectArray.indices) != !range1.contains(element15)) throw AssertionError() if (!(element15 !in objectArray.indices) != range1.contains(element15)) throw AssertionError() } fun testR1xE16() { // with possible local optimizations if (1.toFloat() in objectArray.indices != range1.contains(1.toFloat())) throw AssertionError() if (1.toFloat() !in objectArray.indices != !range1.contains(1.toFloat())) throw AssertionError() if (!(1.toFloat() in objectArray.indices) != !range1.contains(1.toFloat())) throw AssertionError() if (!(1.toFloat() !in objectArray.indices) != range1.contains(1.toFloat())) throw AssertionError() // no local optimizations if (element16 in objectArray.indices != range1.contains(element16)) throw AssertionError() if (element16 !in objectArray.indices != !range1.contains(element16)) throw AssertionError() if (!(element16 in objectArray.indices) != !range1.contains(element16)) throw AssertionError() if (!(element16 !in objectArray.indices) != range1.contains(element16)) throw AssertionError() } fun testR1xE17() { // with possible local optimizations if (1.toDouble() in objectArray.indices != range1.contains(1.toDouble())) throw AssertionError() if (1.toDouble() !in objectArray.indices != !range1.contains(1.toDouble())) throw AssertionError() if (!(1.toDouble() in objectArray.indices) != !range1.contains(1.toDouble())) throw AssertionError() if (!(1.toDouble() !in objectArray.indices) != range1.contains(1.toDouble())) throw AssertionError() // no local optimizations if (element17 in objectArray.indices != range1.contains(element17)) throw AssertionError() if (element17 !in objectArray.indices != !range1.contains(element17)) throw AssertionError() if (!(element17 in objectArray.indices) != !range1.contains(element17)) throw AssertionError() if (!(element17 !in objectArray.indices) != range1.contains(element17)) throw AssertionError() } fun testR1xE18() { // with possible local optimizations if (2.toByte() in objectArray.indices != range1.contains(2.toByte())) throw AssertionError() if (2.toByte() !in objectArray.indices != !range1.contains(2.toByte())) throw AssertionError() if (!(2.toByte() in objectArray.indices) != !range1.contains(2.toByte())) throw AssertionError() if (!(2.toByte() !in objectArray.indices) != range1.contains(2.toByte())) throw AssertionError() // no local optimizations if (element18 in objectArray.indices != range1.contains(element18)) throw AssertionError() if (element18 !in objectArray.indices != !range1.contains(element18)) throw AssertionError() if (!(element18 in objectArray.indices) != !range1.contains(element18)) throw AssertionError() if (!(element18 !in objectArray.indices) != range1.contains(element18)) throw AssertionError() } fun testR1xE19() { // with possible local optimizations if (2.toShort() in objectArray.indices != range1.contains(2.toShort())) throw AssertionError() if (2.toShort() !in objectArray.indices != !range1.contains(2.toShort())) throw AssertionError() if (!(2.toShort() in objectArray.indices) != !range1.contains(2.toShort())) throw AssertionError() if (!(2.toShort() !in objectArray.indices) != range1.contains(2.toShort())) throw AssertionError() // no local optimizations if (element19 in objectArray.indices != range1.contains(element19)) throw AssertionError() if (element19 !in objectArray.indices != !range1.contains(element19)) throw AssertionError() if (!(element19 in objectArray.indices) != !range1.contains(element19)) throw AssertionError() if (!(element19 !in objectArray.indices) != range1.contains(element19)) throw AssertionError() } fun testR1xE20() { // with possible local optimizations if (2 in objectArray.indices != range1.contains(2)) throw AssertionError() if (2 !in objectArray.indices != !range1.contains(2)) throw AssertionError() if (!(2 in objectArray.indices) != !range1.contains(2)) throw AssertionError() if (!(2 !in objectArray.indices) != range1.contains(2)) throw AssertionError() // no local optimizations if (element20 in objectArray.indices != range1.contains(element20)) throw AssertionError() if (element20 !in objectArray.indices != !range1.contains(element20)) throw AssertionError() if (!(element20 in objectArray.indices) != !range1.contains(element20)) throw AssertionError() if (!(element20 !in objectArray.indices) != range1.contains(element20)) throw AssertionError() } fun testR1xE21() { // with possible local optimizations if (2.toLong() in objectArray.indices != range1.contains(2.toLong())) throw AssertionError() if (2.toLong() !in objectArray.indices != !range1.contains(2.toLong())) throw AssertionError() if (!(2.toLong() in objectArray.indices) != !range1.contains(2.toLong())) throw AssertionError() if (!(2.toLong() !in objectArray.indices) != range1.contains(2.toLong())) throw AssertionError() // no local optimizations if (element21 in objectArray.indices != range1.contains(element21)) throw AssertionError() if (element21 !in objectArray.indices != !range1.contains(element21)) throw AssertionError() if (!(element21 in objectArray.indices) != !range1.contains(element21)) throw AssertionError() if (!(element21 !in objectArray.indices) != range1.contains(element21)) throw AssertionError() } fun testR1xE22() { // with possible local optimizations if (2.toFloat() in objectArray.indices != range1.contains(2.toFloat())) throw AssertionError() if (2.toFloat() !in objectArray.indices != !range1.contains(2.toFloat())) throw AssertionError() if (!(2.toFloat() in objectArray.indices) != !range1.contains(2.toFloat())) throw AssertionError() if (!(2.toFloat() !in objectArray.indices) != range1.contains(2.toFloat())) throw AssertionError() // no local optimizations if (element22 in objectArray.indices != range1.contains(element22)) throw AssertionError() if (element22 !in objectArray.indices != !range1.contains(element22)) throw AssertionError() if (!(element22 in objectArray.indices) != !range1.contains(element22)) throw AssertionError() if (!(element22 !in objectArray.indices) != range1.contains(element22)) throw AssertionError() } fun testR1xE23() { // with possible local optimizations if (2.toDouble() in objectArray.indices != range1.contains(2.toDouble())) throw AssertionError() if (2.toDouble() !in objectArray.indices != !range1.contains(2.toDouble())) throw AssertionError() if (!(2.toDouble() in objectArray.indices) != !range1.contains(2.toDouble())) throw AssertionError() if (!(2.toDouble() !in objectArray.indices) != range1.contains(2.toDouble())) throw AssertionError() // no local optimizations if (element23 in objectArray.indices != range1.contains(element23)) throw AssertionError() if (element23 !in objectArray.indices != !range1.contains(element23)) throw AssertionError() if (!(element23 in objectArray.indices) != !range1.contains(element23)) throw AssertionError() if (!(element23 !in objectArray.indices) != range1.contains(element23)) throw AssertionError() } fun testR1xE24() { // with possible local optimizations if (3.toByte() in objectArray.indices != range1.contains(3.toByte())) throw AssertionError() if (3.toByte() !in objectArray.indices != !range1.contains(3.toByte())) throw AssertionError() if (!(3.toByte() in objectArray.indices) != !range1.contains(3.toByte())) throw AssertionError() if (!(3.toByte() !in objectArray.indices) != range1.contains(3.toByte())) throw AssertionError() // no local optimizations if (element24 in objectArray.indices != range1.contains(element24)) throw AssertionError() if (element24 !in objectArray.indices != !range1.contains(element24)) throw AssertionError() if (!(element24 in objectArray.indices) != !range1.contains(element24)) throw AssertionError() if (!(element24 !in objectArray.indices) != range1.contains(element24)) throw AssertionError() } fun testR1xE25() { // with possible local optimizations if (3.toShort() in objectArray.indices != range1.contains(3.toShort())) throw AssertionError() if (3.toShort() !in objectArray.indices != !range1.contains(3.toShort())) throw AssertionError() if (!(3.toShort() in objectArray.indices) != !range1.contains(3.toShort())) throw AssertionError() if (!(3.toShort() !in objectArray.indices) != range1.contains(3.toShort())) throw AssertionError() // no local optimizations if (element25 in objectArray.indices != range1.contains(element25)) throw AssertionError() if (element25 !in objectArray.indices != !range1.contains(element25)) throw AssertionError() if (!(element25 in objectArray.indices) != !range1.contains(element25)) throw AssertionError() if (!(element25 !in objectArray.indices) != range1.contains(element25)) throw AssertionError() } fun testR1xE26() { // with possible local optimizations if (3 in objectArray.indices != range1.contains(3)) throw AssertionError() if (3 !in objectArray.indices != !range1.contains(3)) throw AssertionError() if (!(3 in objectArray.indices) != !range1.contains(3)) throw AssertionError() if (!(3 !in objectArray.indices) != range1.contains(3)) throw AssertionError() // no local optimizations if (element26 in objectArray.indices != range1.contains(element26)) throw AssertionError() if (element26 !in objectArray.indices != !range1.contains(element26)) throw AssertionError() if (!(element26 in objectArray.indices) != !range1.contains(element26)) throw AssertionError() if (!(element26 !in objectArray.indices) != range1.contains(element26)) throw AssertionError() } fun testR1xE27() { // with possible local optimizations if (3.toLong() in objectArray.indices != range1.contains(3.toLong())) throw AssertionError() if (3.toLong() !in objectArray.indices != !range1.contains(3.toLong())) throw AssertionError() if (!(3.toLong() in objectArray.indices) != !range1.contains(3.toLong())) throw AssertionError() if (!(3.toLong() !in objectArray.indices) != range1.contains(3.toLong())) throw AssertionError() // no local optimizations if (element27 in objectArray.indices != range1.contains(element27)) throw AssertionError() if (element27 !in objectArray.indices != !range1.contains(element27)) throw AssertionError() if (!(element27 in objectArray.indices) != !range1.contains(element27)) throw AssertionError() if (!(element27 !in objectArray.indices) != range1.contains(element27)) throw AssertionError() } fun testR1xE28() { // with possible local optimizations if (3.toFloat() in objectArray.indices != range1.contains(3.toFloat())) throw AssertionError() if (3.toFloat() !in objectArray.indices != !range1.contains(3.toFloat())) throw AssertionError() if (!(3.toFloat() in objectArray.indices) != !range1.contains(3.toFloat())) throw AssertionError() if (!(3.toFloat() !in objectArray.indices) != range1.contains(3.toFloat())) throw AssertionError() // no local optimizations if (element28 in objectArray.indices != range1.contains(element28)) throw AssertionError() if (element28 !in objectArray.indices != !range1.contains(element28)) throw AssertionError() if (!(element28 in objectArray.indices) != !range1.contains(element28)) throw AssertionError() if (!(element28 !in objectArray.indices) != range1.contains(element28)) throw AssertionError() } fun testR1xE29() { // with possible local optimizations if (3.toDouble() in objectArray.indices != range1.contains(3.toDouble())) throw AssertionError() if (3.toDouble() !in objectArray.indices != !range1.contains(3.toDouble())) throw AssertionError() if (!(3.toDouble() in objectArray.indices) != !range1.contains(3.toDouble())) throw AssertionError() if (!(3.toDouble() !in objectArray.indices) != range1.contains(3.toDouble())) throw AssertionError() // no local optimizations if (element29 in objectArray.indices != range1.contains(element29)) throw AssertionError() if (element29 !in objectArray.indices != !range1.contains(element29)) throw AssertionError() if (!(element29 in objectArray.indices) != !range1.contains(element29)) throw AssertionError() if (!(element29 !in objectArray.indices) != range1.contains(element29)) throw AssertionError() } fun testR1xE30() { // with possible local optimizations if (4.toByte() in objectArray.indices != range1.contains(4.toByte())) throw AssertionError() if (4.toByte() !in objectArray.indices != !range1.contains(4.toByte())) throw AssertionError() if (!(4.toByte() in objectArray.indices) != !range1.contains(4.toByte())) throw AssertionError() if (!(4.toByte() !in objectArray.indices) != range1.contains(4.toByte())) throw AssertionError() // no local optimizations if (element30 in objectArray.indices != range1.contains(element30)) throw AssertionError() if (element30 !in objectArray.indices != !range1.contains(element30)) throw AssertionError() if (!(element30 in objectArray.indices) != !range1.contains(element30)) throw AssertionError() if (!(element30 !in objectArray.indices) != range1.contains(element30)) throw AssertionError() } fun testR1xE31() { // with possible local optimizations if (4.toShort() in objectArray.indices != range1.contains(4.toShort())) throw AssertionError() if (4.toShort() !in objectArray.indices != !range1.contains(4.toShort())) throw AssertionError() if (!(4.toShort() in objectArray.indices) != !range1.contains(4.toShort())) throw AssertionError() if (!(4.toShort() !in objectArray.indices) != range1.contains(4.toShort())) throw AssertionError() // no local optimizations if (element31 in objectArray.indices != range1.contains(element31)) throw AssertionError() if (element31 !in objectArray.indices != !range1.contains(element31)) throw AssertionError() if (!(element31 in objectArray.indices) != !range1.contains(element31)) throw AssertionError() if (!(element31 !in objectArray.indices) != range1.contains(element31)) throw AssertionError() } fun testR1xE32() { // with possible local optimizations if (4 in objectArray.indices != range1.contains(4)) throw AssertionError() if (4 !in objectArray.indices != !range1.contains(4)) throw AssertionError() if (!(4 in objectArray.indices) != !range1.contains(4)) throw AssertionError() if (!(4 !in objectArray.indices) != range1.contains(4)) throw AssertionError() // no local optimizations if (element32 in objectArray.indices != range1.contains(element32)) throw AssertionError() if (element32 !in objectArray.indices != !range1.contains(element32)) throw AssertionError() if (!(element32 in objectArray.indices) != !range1.contains(element32)) throw AssertionError() if (!(element32 !in objectArray.indices) != range1.contains(element32)) throw AssertionError() } fun testR1xE33() { // with possible local optimizations if (4.toLong() in objectArray.indices != range1.contains(4.toLong())) throw AssertionError() if (4.toLong() !in objectArray.indices != !range1.contains(4.toLong())) throw AssertionError() if (!(4.toLong() in objectArray.indices) != !range1.contains(4.toLong())) throw AssertionError() if (!(4.toLong() !in objectArray.indices) != range1.contains(4.toLong())) throw AssertionError() // no local optimizations if (element33 in objectArray.indices != range1.contains(element33)) throw AssertionError() if (element33 !in objectArray.indices != !range1.contains(element33)) throw AssertionError() if (!(element33 in objectArray.indices) != !range1.contains(element33)) throw AssertionError() if (!(element33 !in objectArray.indices) != range1.contains(element33)) throw AssertionError() } fun testR1xE34() { // with possible local optimizations if (4.toFloat() in objectArray.indices != range1.contains(4.toFloat())) throw AssertionError() if (4.toFloat() !in objectArray.indices != !range1.contains(4.toFloat())) throw AssertionError() if (!(4.toFloat() in objectArray.indices) != !range1.contains(4.toFloat())) throw AssertionError() if (!(4.toFloat() !in objectArray.indices) != range1.contains(4.toFloat())) throw AssertionError() // no local optimizations if (element34 in objectArray.indices != range1.contains(element34)) throw AssertionError() if (element34 !in objectArray.indices != !range1.contains(element34)) throw AssertionError() if (!(element34 in objectArray.indices) != !range1.contains(element34)) throw AssertionError() if (!(element34 !in objectArray.indices) != range1.contains(element34)) throw AssertionError() } fun testR1xE35() { // with possible local optimizations if (4.toDouble() in objectArray.indices != range1.contains(4.toDouble())) throw AssertionError() if (4.toDouble() !in objectArray.indices != !range1.contains(4.toDouble())) throw AssertionError() if (!(4.toDouble() in objectArray.indices) != !range1.contains(4.toDouble())) throw AssertionError() if (!(4.toDouble() !in objectArray.indices) != range1.contains(4.toDouble())) throw AssertionError() // no local optimizations if (element35 in objectArray.indices != range1.contains(element35)) throw AssertionError() if (element35 !in objectArray.indices != !range1.contains(element35)) throw AssertionError() if (!(element35 in objectArray.indices) != !range1.contains(element35)) throw AssertionError() if (!(element35 !in objectArray.indices) != range1.contains(element35)) throw AssertionError() } fun testR2xE0() { // with possible local optimizations if ((-1).toByte() in emptyIntArray.indices != range2.contains((-1).toByte())) throw AssertionError() if ((-1).toByte() !in emptyIntArray.indices != !range2.contains((-1).toByte())) throw AssertionError() if (!((-1).toByte() in emptyIntArray.indices) != !range2.contains((-1).toByte())) throw AssertionError() if (!((-1).toByte() !in emptyIntArray.indices) != range2.contains((-1).toByte())) throw AssertionError() // no local optimizations if (element0 in emptyIntArray.indices != range2.contains(element0)) throw AssertionError() if (element0 !in emptyIntArray.indices != !range2.contains(element0)) throw AssertionError() if (!(element0 in emptyIntArray.indices) != !range2.contains(element0)) throw AssertionError() if (!(element0 !in emptyIntArray.indices) != range2.contains(element0)) throw AssertionError() } fun testR2xE1() { // with possible local optimizations if ((-1).toShort() in emptyIntArray.indices != range2.contains((-1).toShort())) throw AssertionError() if ((-1).toShort() !in emptyIntArray.indices != !range2.contains((-1).toShort())) throw AssertionError() if (!((-1).toShort() in emptyIntArray.indices) != !range2.contains((-1).toShort())) throw AssertionError() if (!((-1).toShort() !in emptyIntArray.indices) != range2.contains((-1).toShort())) throw AssertionError() // no local optimizations if (element1 in emptyIntArray.indices != range2.contains(element1)) throw AssertionError() if (element1 !in emptyIntArray.indices != !range2.contains(element1)) throw AssertionError() if (!(element1 in emptyIntArray.indices) != !range2.contains(element1)) throw AssertionError() if (!(element1 !in emptyIntArray.indices) != range2.contains(element1)) throw AssertionError() } fun testR2xE2() { // with possible local optimizations if ((-1) in emptyIntArray.indices != range2.contains((-1))) throw AssertionError() if ((-1) !in emptyIntArray.indices != !range2.contains((-1))) throw AssertionError() if (!((-1) in emptyIntArray.indices) != !range2.contains((-1))) throw AssertionError() if (!((-1) !in emptyIntArray.indices) != range2.contains((-1))) throw AssertionError() // no local optimizations if (element2 in emptyIntArray.indices != range2.contains(element2)) throw AssertionError() if (element2 !in emptyIntArray.indices != !range2.contains(element2)) throw AssertionError() if (!(element2 in emptyIntArray.indices) != !range2.contains(element2)) throw AssertionError() if (!(element2 !in emptyIntArray.indices) != range2.contains(element2)) throw AssertionError() } fun testR2xE3() { // with possible local optimizations if ((-1).toLong() in emptyIntArray.indices != range2.contains((-1).toLong())) throw AssertionError() if ((-1).toLong() !in emptyIntArray.indices != !range2.contains((-1).toLong())) throw AssertionError() if (!((-1).toLong() in emptyIntArray.indices) != !range2.contains((-1).toLong())) throw AssertionError() if (!((-1).toLong() !in emptyIntArray.indices) != range2.contains((-1).toLong())) throw AssertionError() // no local optimizations if (element3 in emptyIntArray.indices != range2.contains(element3)) throw AssertionError() if (element3 !in emptyIntArray.indices != !range2.contains(element3)) throw AssertionError() if (!(element3 in emptyIntArray.indices) != !range2.contains(element3)) throw AssertionError() if (!(element3 !in emptyIntArray.indices) != range2.contains(element3)) throw AssertionError() } fun testR2xE4() { // with possible local optimizations if ((-1).toFloat() in emptyIntArray.indices != range2.contains((-1).toFloat())) throw AssertionError() if ((-1).toFloat() !in emptyIntArray.indices != !range2.contains((-1).toFloat())) throw AssertionError() if (!((-1).toFloat() in emptyIntArray.indices) != !range2.contains((-1).toFloat())) throw AssertionError() if (!((-1).toFloat() !in emptyIntArray.indices) != range2.contains((-1).toFloat())) throw AssertionError() // no local optimizations if (element4 in emptyIntArray.indices != range2.contains(element4)) throw AssertionError() if (element4 !in emptyIntArray.indices != !range2.contains(element4)) throw AssertionError() if (!(element4 in emptyIntArray.indices) != !range2.contains(element4)) throw AssertionError() if (!(element4 !in emptyIntArray.indices) != range2.contains(element4)) throw AssertionError() } fun testR2xE5() { // with possible local optimizations if ((-1).toDouble() in emptyIntArray.indices != range2.contains((-1).toDouble())) throw AssertionError() if ((-1).toDouble() !in emptyIntArray.indices != !range2.contains((-1).toDouble())) throw AssertionError() if (!((-1).toDouble() in emptyIntArray.indices) != !range2.contains((-1).toDouble())) throw AssertionError() if (!((-1).toDouble() !in emptyIntArray.indices) != range2.contains((-1).toDouble())) throw AssertionError() // no local optimizations if (element5 in emptyIntArray.indices != range2.contains(element5)) throw AssertionError() if (element5 !in emptyIntArray.indices != !range2.contains(element5)) throw AssertionError() if (!(element5 in emptyIntArray.indices) != !range2.contains(element5)) throw AssertionError() if (!(element5 !in emptyIntArray.indices) != range2.contains(element5)) throw AssertionError() } fun testR2xE6() { // with possible local optimizations if (0.toByte() in emptyIntArray.indices != range2.contains(0.toByte())) throw AssertionError() if (0.toByte() !in emptyIntArray.indices != !range2.contains(0.toByte())) throw AssertionError() if (!(0.toByte() in emptyIntArray.indices) != !range2.contains(0.toByte())) throw AssertionError() if (!(0.toByte() !in emptyIntArray.indices) != range2.contains(0.toByte())) throw AssertionError() // no local optimizations if (element6 in emptyIntArray.indices != range2.contains(element6)) throw AssertionError() if (element6 !in emptyIntArray.indices != !range2.contains(element6)) throw AssertionError() if (!(element6 in emptyIntArray.indices) != !range2.contains(element6)) throw AssertionError() if (!(element6 !in emptyIntArray.indices) != range2.contains(element6)) throw AssertionError() } fun testR2xE7() { // with possible local optimizations if (0.toShort() in emptyIntArray.indices != range2.contains(0.toShort())) throw AssertionError() if (0.toShort() !in emptyIntArray.indices != !range2.contains(0.toShort())) throw AssertionError() if (!(0.toShort() in emptyIntArray.indices) != !range2.contains(0.toShort())) throw AssertionError() if (!(0.toShort() !in emptyIntArray.indices) != range2.contains(0.toShort())) throw AssertionError() // no local optimizations if (element7 in emptyIntArray.indices != range2.contains(element7)) throw AssertionError() if (element7 !in emptyIntArray.indices != !range2.contains(element7)) throw AssertionError() if (!(element7 in emptyIntArray.indices) != !range2.contains(element7)) throw AssertionError() if (!(element7 !in emptyIntArray.indices) != range2.contains(element7)) throw AssertionError() } fun testR2xE8() { // with possible local optimizations if (0 in emptyIntArray.indices != range2.contains(0)) throw AssertionError() if (0 !in emptyIntArray.indices != !range2.contains(0)) throw AssertionError() if (!(0 in emptyIntArray.indices) != !range2.contains(0)) throw AssertionError() if (!(0 !in emptyIntArray.indices) != range2.contains(0)) throw AssertionError() // no local optimizations if (element8 in emptyIntArray.indices != range2.contains(element8)) throw AssertionError() if (element8 !in emptyIntArray.indices != !range2.contains(element8)) throw AssertionError() if (!(element8 in emptyIntArray.indices) != !range2.contains(element8)) throw AssertionError() if (!(element8 !in emptyIntArray.indices) != range2.contains(element8)) throw AssertionError() } fun testR2xE9() { // with possible local optimizations if (0.toLong() in emptyIntArray.indices != range2.contains(0.toLong())) throw AssertionError() if (0.toLong() !in emptyIntArray.indices != !range2.contains(0.toLong())) throw AssertionError() if (!(0.toLong() in emptyIntArray.indices) != !range2.contains(0.toLong())) throw AssertionError() if (!(0.toLong() !in emptyIntArray.indices) != range2.contains(0.toLong())) throw AssertionError() // no local optimizations if (element9 in emptyIntArray.indices != range2.contains(element9)) throw AssertionError() if (element9 !in emptyIntArray.indices != !range2.contains(element9)) throw AssertionError() if (!(element9 in emptyIntArray.indices) != !range2.contains(element9)) throw AssertionError() if (!(element9 !in emptyIntArray.indices) != range2.contains(element9)) throw AssertionError() } fun testR2xE10() { // with possible local optimizations if (0.toFloat() in emptyIntArray.indices != range2.contains(0.toFloat())) throw AssertionError() if (0.toFloat() !in emptyIntArray.indices != !range2.contains(0.toFloat())) throw AssertionError() if (!(0.toFloat() in emptyIntArray.indices) != !range2.contains(0.toFloat())) throw AssertionError() if (!(0.toFloat() !in emptyIntArray.indices) != range2.contains(0.toFloat())) throw AssertionError() // no local optimizations if (element10 in emptyIntArray.indices != range2.contains(element10)) throw AssertionError() if (element10 !in emptyIntArray.indices != !range2.contains(element10)) throw AssertionError() if (!(element10 in emptyIntArray.indices) != !range2.contains(element10)) throw AssertionError() if (!(element10 !in emptyIntArray.indices) != range2.contains(element10)) throw AssertionError() } fun testR2xE11() { // with possible local optimizations if (0.toDouble() in emptyIntArray.indices != range2.contains(0.toDouble())) throw AssertionError() if (0.toDouble() !in emptyIntArray.indices != !range2.contains(0.toDouble())) throw AssertionError() if (!(0.toDouble() in emptyIntArray.indices) != !range2.contains(0.toDouble())) throw AssertionError() if (!(0.toDouble() !in emptyIntArray.indices) != range2.contains(0.toDouble())) throw AssertionError() // no local optimizations if (element11 in emptyIntArray.indices != range2.contains(element11)) throw AssertionError() if (element11 !in emptyIntArray.indices != !range2.contains(element11)) throw AssertionError() if (!(element11 in emptyIntArray.indices) != !range2.contains(element11)) throw AssertionError() if (!(element11 !in emptyIntArray.indices) != range2.contains(element11)) throw AssertionError() } fun testR2xE12() { // with possible local optimizations if (1.toByte() in emptyIntArray.indices != range2.contains(1.toByte())) throw AssertionError() if (1.toByte() !in emptyIntArray.indices != !range2.contains(1.toByte())) throw AssertionError() if (!(1.toByte() in emptyIntArray.indices) != !range2.contains(1.toByte())) throw AssertionError() if (!(1.toByte() !in emptyIntArray.indices) != range2.contains(1.toByte())) throw AssertionError() // no local optimizations if (element12 in emptyIntArray.indices != range2.contains(element12)) throw AssertionError() if (element12 !in emptyIntArray.indices != !range2.contains(element12)) throw AssertionError() if (!(element12 in emptyIntArray.indices) != !range2.contains(element12)) throw AssertionError() if (!(element12 !in emptyIntArray.indices) != range2.contains(element12)) throw AssertionError() } fun testR2xE13() { // with possible local optimizations if (1.toShort() in emptyIntArray.indices != range2.contains(1.toShort())) throw AssertionError() if (1.toShort() !in emptyIntArray.indices != !range2.contains(1.toShort())) throw AssertionError() if (!(1.toShort() in emptyIntArray.indices) != !range2.contains(1.toShort())) throw AssertionError() if (!(1.toShort() !in emptyIntArray.indices) != range2.contains(1.toShort())) throw AssertionError() // no local optimizations if (element13 in emptyIntArray.indices != range2.contains(element13)) throw AssertionError() if (element13 !in emptyIntArray.indices != !range2.contains(element13)) throw AssertionError() if (!(element13 in emptyIntArray.indices) != !range2.contains(element13)) throw AssertionError() if (!(element13 !in emptyIntArray.indices) != range2.contains(element13)) throw AssertionError() } fun testR2xE14() { // with possible local optimizations if (1 in emptyIntArray.indices != range2.contains(1)) throw AssertionError() if (1 !in emptyIntArray.indices != !range2.contains(1)) throw AssertionError() if (!(1 in emptyIntArray.indices) != !range2.contains(1)) throw AssertionError() if (!(1 !in emptyIntArray.indices) != range2.contains(1)) throw AssertionError() // no local optimizations if (element14 in emptyIntArray.indices != range2.contains(element14)) throw AssertionError() if (element14 !in emptyIntArray.indices != !range2.contains(element14)) throw AssertionError() if (!(element14 in emptyIntArray.indices) != !range2.contains(element14)) throw AssertionError() if (!(element14 !in emptyIntArray.indices) != range2.contains(element14)) throw AssertionError() } fun testR2xE15() { // with possible local optimizations if (1.toLong() in emptyIntArray.indices != range2.contains(1.toLong())) throw AssertionError() if (1.toLong() !in emptyIntArray.indices != !range2.contains(1.toLong())) throw AssertionError() if (!(1.toLong() in emptyIntArray.indices) != !range2.contains(1.toLong())) throw AssertionError() if (!(1.toLong() !in emptyIntArray.indices) != range2.contains(1.toLong())) throw AssertionError() // no local optimizations if (element15 in emptyIntArray.indices != range2.contains(element15)) throw AssertionError() if (element15 !in emptyIntArray.indices != !range2.contains(element15)) throw AssertionError() if (!(element15 in emptyIntArray.indices) != !range2.contains(element15)) throw AssertionError() if (!(element15 !in emptyIntArray.indices) != range2.contains(element15)) throw AssertionError() } fun testR2xE16() { // with possible local optimizations if (1.toFloat() in emptyIntArray.indices != range2.contains(1.toFloat())) throw AssertionError() if (1.toFloat() !in emptyIntArray.indices != !range2.contains(1.toFloat())) throw AssertionError() if (!(1.toFloat() in emptyIntArray.indices) != !range2.contains(1.toFloat())) throw AssertionError() if (!(1.toFloat() !in emptyIntArray.indices) != range2.contains(1.toFloat())) throw AssertionError() // no local optimizations if (element16 in emptyIntArray.indices != range2.contains(element16)) throw AssertionError() if (element16 !in emptyIntArray.indices != !range2.contains(element16)) throw AssertionError() if (!(element16 in emptyIntArray.indices) != !range2.contains(element16)) throw AssertionError() if (!(element16 !in emptyIntArray.indices) != range2.contains(element16)) throw AssertionError() } fun testR2xE17() { // with possible local optimizations if (1.toDouble() in emptyIntArray.indices != range2.contains(1.toDouble())) throw AssertionError() if (1.toDouble() !in emptyIntArray.indices != !range2.contains(1.toDouble())) throw AssertionError() if (!(1.toDouble() in emptyIntArray.indices) != !range2.contains(1.toDouble())) throw AssertionError() if (!(1.toDouble() !in emptyIntArray.indices) != range2.contains(1.toDouble())) throw AssertionError() // no local optimizations if (element17 in emptyIntArray.indices != range2.contains(element17)) throw AssertionError() if (element17 !in emptyIntArray.indices != !range2.contains(element17)) throw AssertionError() if (!(element17 in emptyIntArray.indices) != !range2.contains(element17)) throw AssertionError() if (!(element17 !in emptyIntArray.indices) != range2.contains(element17)) throw AssertionError() } fun testR2xE18() { // with possible local optimizations if (2.toByte() in emptyIntArray.indices != range2.contains(2.toByte())) throw AssertionError() if (2.toByte() !in emptyIntArray.indices != !range2.contains(2.toByte())) throw AssertionError() if (!(2.toByte() in emptyIntArray.indices) != !range2.contains(2.toByte())) throw AssertionError() if (!(2.toByte() !in emptyIntArray.indices) != range2.contains(2.toByte())) throw AssertionError() // no local optimizations if (element18 in emptyIntArray.indices != range2.contains(element18)) throw AssertionError() if (element18 !in emptyIntArray.indices != !range2.contains(element18)) throw AssertionError() if (!(element18 in emptyIntArray.indices) != !range2.contains(element18)) throw AssertionError() if (!(element18 !in emptyIntArray.indices) != range2.contains(element18)) throw AssertionError() } fun testR2xE19() { // with possible local optimizations if (2.toShort() in emptyIntArray.indices != range2.contains(2.toShort())) throw AssertionError() if (2.toShort() !in emptyIntArray.indices != !range2.contains(2.toShort())) throw AssertionError() if (!(2.toShort() in emptyIntArray.indices) != !range2.contains(2.toShort())) throw AssertionError() if (!(2.toShort() !in emptyIntArray.indices) != range2.contains(2.toShort())) throw AssertionError() // no local optimizations if (element19 in emptyIntArray.indices != range2.contains(element19)) throw AssertionError() if (element19 !in emptyIntArray.indices != !range2.contains(element19)) throw AssertionError() if (!(element19 in emptyIntArray.indices) != !range2.contains(element19)) throw AssertionError() if (!(element19 !in emptyIntArray.indices) != range2.contains(element19)) throw AssertionError() } fun testR2xE20() { // with possible local optimizations if (2 in emptyIntArray.indices != range2.contains(2)) throw AssertionError() if (2 !in emptyIntArray.indices != !range2.contains(2)) throw AssertionError() if (!(2 in emptyIntArray.indices) != !range2.contains(2)) throw AssertionError() if (!(2 !in emptyIntArray.indices) != range2.contains(2)) throw AssertionError() // no local optimizations if (element20 in emptyIntArray.indices != range2.contains(element20)) throw AssertionError() if (element20 !in emptyIntArray.indices != !range2.contains(element20)) throw AssertionError() if (!(element20 in emptyIntArray.indices) != !range2.contains(element20)) throw AssertionError() if (!(element20 !in emptyIntArray.indices) != range2.contains(element20)) throw AssertionError() } fun testR2xE21() { // with possible local optimizations if (2.toLong() in emptyIntArray.indices != range2.contains(2.toLong())) throw AssertionError() if (2.toLong() !in emptyIntArray.indices != !range2.contains(2.toLong())) throw AssertionError() if (!(2.toLong() in emptyIntArray.indices) != !range2.contains(2.toLong())) throw AssertionError() if (!(2.toLong() !in emptyIntArray.indices) != range2.contains(2.toLong())) throw AssertionError() // no local optimizations if (element21 in emptyIntArray.indices != range2.contains(element21)) throw AssertionError() if (element21 !in emptyIntArray.indices != !range2.contains(element21)) throw AssertionError() if (!(element21 in emptyIntArray.indices) != !range2.contains(element21)) throw AssertionError() if (!(element21 !in emptyIntArray.indices) != range2.contains(element21)) throw AssertionError() } fun testR2xE22() { // with possible local optimizations if (2.toFloat() in emptyIntArray.indices != range2.contains(2.toFloat())) throw AssertionError() if (2.toFloat() !in emptyIntArray.indices != !range2.contains(2.toFloat())) throw AssertionError() if (!(2.toFloat() in emptyIntArray.indices) != !range2.contains(2.toFloat())) throw AssertionError() if (!(2.toFloat() !in emptyIntArray.indices) != range2.contains(2.toFloat())) throw AssertionError() // no local optimizations if (element22 in emptyIntArray.indices != range2.contains(element22)) throw AssertionError() if (element22 !in emptyIntArray.indices != !range2.contains(element22)) throw AssertionError() if (!(element22 in emptyIntArray.indices) != !range2.contains(element22)) throw AssertionError() if (!(element22 !in emptyIntArray.indices) != range2.contains(element22)) throw AssertionError() } fun testR2xE23() { // with possible local optimizations if (2.toDouble() in emptyIntArray.indices != range2.contains(2.toDouble())) throw AssertionError() if (2.toDouble() !in emptyIntArray.indices != !range2.contains(2.toDouble())) throw AssertionError() if (!(2.toDouble() in emptyIntArray.indices) != !range2.contains(2.toDouble())) throw AssertionError() if (!(2.toDouble() !in emptyIntArray.indices) != range2.contains(2.toDouble())) throw AssertionError() // no local optimizations if (element23 in emptyIntArray.indices != range2.contains(element23)) throw AssertionError() if (element23 !in emptyIntArray.indices != !range2.contains(element23)) throw AssertionError() if (!(element23 in emptyIntArray.indices) != !range2.contains(element23)) throw AssertionError() if (!(element23 !in emptyIntArray.indices) != range2.contains(element23)) throw AssertionError() } fun testR2xE24() { // with possible local optimizations if (3.toByte() in emptyIntArray.indices != range2.contains(3.toByte())) throw AssertionError() if (3.toByte() !in emptyIntArray.indices != !range2.contains(3.toByte())) throw AssertionError() if (!(3.toByte() in emptyIntArray.indices) != !range2.contains(3.toByte())) throw AssertionError() if (!(3.toByte() !in emptyIntArray.indices) != range2.contains(3.toByte())) throw AssertionError() // no local optimizations if (element24 in emptyIntArray.indices != range2.contains(element24)) throw AssertionError() if (element24 !in emptyIntArray.indices != !range2.contains(element24)) throw AssertionError() if (!(element24 in emptyIntArray.indices) != !range2.contains(element24)) throw AssertionError() if (!(element24 !in emptyIntArray.indices) != range2.contains(element24)) throw AssertionError() } fun testR2xE25() { // with possible local optimizations if (3.toShort() in emptyIntArray.indices != range2.contains(3.toShort())) throw AssertionError() if (3.toShort() !in emptyIntArray.indices != !range2.contains(3.toShort())) throw AssertionError() if (!(3.toShort() in emptyIntArray.indices) != !range2.contains(3.toShort())) throw AssertionError() if (!(3.toShort() !in emptyIntArray.indices) != range2.contains(3.toShort())) throw AssertionError() // no local optimizations if (element25 in emptyIntArray.indices != range2.contains(element25)) throw AssertionError() if (element25 !in emptyIntArray.indices != !range2.contains(element25)) throw AssertionError() if (!(element25 in emptyIntArray.indices) != !range2.contains(element25)) throw AssertionError() if (!(element25 !in emptyIntArray.indices) != range2.contains(element25)) throw AssertionError() } fun testR2xE26() { // with possible local optimizations if (3 in emptyIntArray.indices != range2.contains(3)) throw AssertionError() if (3 !in emptyIntArray.indices != !range2.contains(3)) throw AssertionError() if (!(3 in emptyIntArray.indices) != !range2.contains(3)) throw AssertionError() if (!(3 !in emptyIntArray.indices) != range2.contains(3)) throw AssertionError() // no local optimizations if (element26 in emptyIntArray.indices != range2.contains(element26)) throw AssertionError() if (element26 !in emptyIntArray.indices != !range2.contains(element26)) throw AssertionError() if (!(element26 in emptyIntArray.indices) != !range2.contains(element26)) throw AssertionError() if (!(element26 !in emptyIntArray.indices) != range2.contains(element26)) throw AssertionError() } fun testR2xE27() { // with possible local optimizations if (3.toLong() in emptyIntArray.indices != range2.contains(3.toLong())) throw AssertionError() if (3.toLong() !in emptyIntArray.indices != !range2.contains(3.toLong())) throw AssertionError() if (!(3.toLong() in emptyIntArray.indices) != !range2.contains(3.toLong())) throw AssertionError() if (!(3.toLong() !in emptyIntArray.indices) != range2.contains(3.toLong())) throw AssertionError() // no local optimizations if (element27 in emptyIntArray.indices != range2.contains(element27)) throw AssertionError() if (element27 !in emptyIntArray.indices != !range2.contains(element27)) throw AssertionError() if (!(element27 in emptyIntArray.indices) != !range2.contains(element27)) throw AssertionError() if (!(element27 !in emptyIntArray.indices) != range2.contains(element27)) throw AssertionError() } fun testR2xE28() { // with possible local optimizations if (3.toFloat() in emptyIntArray.indices != range2.contains(3.toFloat())) throw AssertionError() if (3.toFloat() !in emptyIntArray.indices != !range2.contains(3.toFloat())) throw AssertionError() if (!(3.toFloat() in emptyIntArray.indices) != !range2.contains(3.toFloat())) throw AssertionError() if (!(3.toFloat() !in emptyIntArray.indices) != range2.contains(3.toFloat())) throw AssertionError() // no local optimizations if (element28 in emptyIntArray.indices != range2.contains(element28)) throw AssertionError() if (element28 !in emptyIntArray.indices != !range2.contains(element28)) throw AssertionError() if (!(element28 in emptyIntArray.indices) != !range2.contains(element28)) throw AssertionError() if (!(element28 !in emptyIntArray.indices) != range2.contains(element28)) throw AssertionError() } fun testR2xE29() { // with possible local optimizations if (3.toDouble() in emptyIntArray.indices != range2.contains(3.toDouble())) throw AssertionError() if (3.toDouble() !in emptyIntArray.indices != !range2.contains(3.toDouble())) throw AssertionError() if (!(3.toDouble() in emptyIntArray.indices) != !range2.contains(3.toDouble())) throw AssertionError() if (!(3.toDouble() !in emptyIntArray.indices) != range2.contains(3.toDouble())) throw AssertionError() // no local optimizations if (element29 in emptyIntArray.indices != range2.contains(element29)) throw AssertionError() if (element29 !in emptyIntArray.indices != !range2.contains(element29)) throw AssertionError() if (!(element29 in emptyIntArray.indices) != !range2.contains(element29)) throw AssertionError() if (!(element29 !in emptyIntArray.indices) != range2.contains(element29)) throw AssertionError() } fun testR2xE30() { // with possible local optimizations if (4.toByte() in emptyIntArray.indices != range2.contains(4.toByte())) throw AssertionError() if (4.toByte() !in emptyIntArray.indices != !range2.contains(4.toByte())) throw AssertionError() if (!(4.toByte() in emptyIntArray.indices) != !range2.contains(4.toByte())) throw AssertionError() if (!(4.toByte() !in emptyIntArray.indices) != range2.contains(4.toByte())) throw AssertionError() // no local optimizations if (element30 in emptyIntArray.indices != range2.contains(element30)) throw AssertionError() if (element30 !in emptyIntArray.indices != !range2.contains(element30)) throw AssertionError() if (!(element30 in emptyIntArray.indices) != !range2.contains(element30)) throw AssertionError() if (!(element30 !in emptyIntArray.indices) != range2.contains(element30)) throw AssertionError() } fun testR2xE31() { // with possible local optimizations if (4.toShort() in emptyIntArray.indices != range2.contains(4.toShort())) throw AssertionError() if (4.toShort() !in emptyIntArray.indices != !range2.contains(4.toShort())) throw AssertionError() if (!(4.toShort() in emptyIntArray.indices) != !range2.contains(4.toShort())) throw AssertionError() if (!(4.toShort() !in emptyIntArray.indices) != range2.contains(4.toShort())) throw AssertionError() // no local optimizations if (element31 in emptyIntArray.indices != range2.contains(element31)) throw AssertionError() if (element31 !in emptyIntArray.indices != !range2.contains(element31)) throw AssertionError() if (!(element31 in emptyIntArray.indices) != !range2.contains(element31)) throw AssertionError() if (!(element31 !in emptyIntArray.indices) != range2.contains(element31)) throw AssertionError() } fun testR2xE32() { // with possible local optimizations if (4 in emptyIntArray.indices != range2.contains(4)) throw AssertionError() if (4 !in emptyIntArray.indices != !range2.contains(4)) throw AssertionError() if (!(4 in emptyIntArray.indices) != !range2.contains(4)) throw AssertionError() if (!(4 !in emptyIntArray.indices) != range2.contains(4)) throw AssertionError() // no local optimizations if (element32 in emptyIntArray.indices != range2.contains(element32)) throw AssertionError() if (element32 !in emptyIntArray.indices != !range2.contains(element32)) throw AssertionError() if (!(element32 in emptyIntArray.indices) != !range2.contains(element32)) throw AssertionError() if (!(element32 !in emptyIntArray.indices) != range2.contains(element32)) throw AssertionError() } fun testR2xE33() { // with possible local optimizations if (4.toLong() in emptyIntArray.indices != range2.contains(4.toLong())) throw AssertionError() if (4.toLong() !in emptyIntArray.indices != !range2.contains(4.toLong())) throw AssertionError() if (!(4.toLong() in emptyIntArray.indices) != !range2.contains(4.toLong())) throw AssertionError() if (!(4.toLong() !in emptyIntArray.indices) != range2.contains(4.toLong())) throw AssertionError() // no local optimizations if (element33 in emptyIntArray.indices != range2.contains(element33)) throw AssertionError() if (element33 !in emptyIntArray.indices != !range2.contains(element33)) throw AssertionError() if (!(element33 in emptyIntArray.indices) != !range2.contains(element33)) throw AssertionError() if (!(element33 !in emptyIntArray.indices) != range2.contains(element33)) throw AssertionError() } fun testR2xE34() { // with possible local optimizations if (4.toFloat() in emptyIntArray.indices != range2.contains(4.toFloat())) throw AssertionError() if (4.toFloat() !in emptyIntArray.indices != !range2.contains(4.toFloat())) throw AssertionError() if (!(4.toFloat() in emptyIntArray.indices) != !range2.contains(4.toFloat())) throw AssertionError() if (!(4.toFloat() !in emptyIntArray.indices) != range2.contains(4.toFloat())) throw AssertionError() // no local optimizations if (element34 in emptyIntArray.indices != range2.contains(element34)) throw AssertionError() if (element34 !in emptyIntArray.indices != !range2.contains(element34)) throw AssertionError() if (!(element34 in emptyIntArray.indices) != !range2.contains(element34)) throw AssertionError() if (!(element34 !in emptyIntArray.indices) != range2.contains(element34)) throw AssertionError() } fun testR2xE35() { // with possible local optimizations if (4.toDouble() in emptyIntArray.indices != range2.contains(4.toDouble())) throw AssertionError() if (4.toDouble() !in emptyIntArray.indices != !range2.contains(4.toDouble())) throw AssertionError() if (!(4.toDouble() in emptyIntArray.indices) != !range2.contains(4.toDouble())) throw AssertionError() if (!(4.toDouble() !in emptyIntArray.indices) != range2.contains(4.toDouble())) throw AssertionError() // no local optimizations if (element35 in emptyIntArray.indices != range2.contains(element35)) throw AssertionError() if (element35 !in emptyIntArray.indices != !range2.contains(element35)) throw AssertionError() if (!(element35 in emptyIntArray.indices) != !range2.contains(element35)) throw AssertionError() if (!(element35 !in emptyIntArray.indices) != range2.contains(element35)) throw AssertionError() } fun testR3xE0() { // with possible local optimizations if ((-1).toByte() in emptyObjectArray.indices != range3.contains((-1).toByte())) throw AssertionError() if ((-1).toByte() !in emptyObjectArray.indices != !range3.contains((-1).toByte())) throw AssertionError() if (!((-1).toByte() in emptyObjectArray.indices) != !range3.contains((-1).toByte())) throw AssertionError() if (!((-1).toByte() !in emptyObjectArray.indices) != range3.contains((-1).toByte())) throw AssertionError() // no local optimizations if (element0 in emptyObjectArray.indices != range3.contains(element0)) throw AssertionError() if (element0 !in emptyObjectArray.indices != !range3.contains(element0)) throw AssertionError() if (!(element0 in emptyObjectArray.indices) != !range3.contains(element0)) throw AssertionError() if (!(element0 !in emptyObjectArray.indices) != range3.contains(element0)) throw AssertionError() } fun testR3xE1() { // with possible local optimizations if ((-1).toShort() in emptyObjectArray.indices != range3.contains((-1).toShort())) throw AssertionError() if ((-1).toShort() !in emptyObjectArray.indices != !range3.contains((-1).toShort())) throw AssertionError() if (!((-1).toShort() in emptyObjectArray.indices) != !range3.contains((-1).toShort())) throw AssertionError() if (!((-1).toShort() !in emptyObjectArray.indices) != range3.contains((-1).toShort())) throw AssertionError() // no local optimizations if (element1 in emptyObjectArray.indices != range3.contains(element1)) throw AssertionError() if (element1 !in emptyObjectArray.indices != !range3.contains(element1)) throw AssertionError() if (!(element1 in emptyObjectArray.indices) != !range3.contains(element1)) throw AssertionError() if (!(element1 !in emptyObjectArray.indices) != range3.contains(element1)) throw AssertionError() } fun testR3xE2() { // with possible local optimizations if ((-1) in emptyObjectArray.indices != range3.contains((-1))) throw AssertionError() if ((-1) !in emptyObjectArray.indices != !range3.contains((-1))) throw AssertionError() if (!((-1) in emptyObjectArray.indices) != !range3.contains((-1))) throw AssertionError() if (!((-1) !in emptyObjectArray.indices) != range3.contains((-1))) throw AssertionError() // no local optimizations if (element2 in emptyObjectArray.indices != range3.contains(element2)) throw AssertionError() if (element2 !in emptyObjectArray.indices != !range3.contains(element2)) throw AssertionError() if (!(element2 in emptyObjectArray.indices) != !range3.contains(element2)) throw AssertionError() if (!(element2 !in emptyObjectArray.indices) != range3.contains(element2)) throw AssertionError() } fun testR3xE3() { // with possible local optimizations if ((-1).toLong() in emptyObjectArray.indices != range3.contains((-1).toLong())) throw AssertionError() if ((-1).toLong() !in emptyObjectArray.indices != !range3.contains((-1).toLong())) throw AssertionError() if (!((-1).toLong() in emptyObjectArray.indices) != !range3.contains((-1).toLong())) throw AssertionError() if (!((-1).toLong() !in emptyObjectArray.indices) != range3.contains((-1).toLong())) throw AssertionError() // no local optimizations if (element3 in emptyObjectArray.indices != range3.contains(element3)) throw AssertionError() if (element3 !in emptyObjectArray.indices != !range3.contains(element3)) throw AssertionError() if (!(element3 in emptyObjectArray.indices) != !range3.contains(element3)) throw AssertionError() if (!(element3 !in emptyObjectArray.indices) != range3.contains(element3)) throw AssertionError() } fun testR3xE4() { // with possible local optimizations if ((-1).toFloat() in emptyObjectArray.indices != range3.contains((-1).toFloat())) throw AssertionError() if ((-1).toFloat() !in emptyObjectArray.indices != !range3.contains((-1).toFloat())) throw AssertionError() if (!((-1).toFloat() in emptyObjectArray.indices) != !range3.contains((-1).toFloat())) throw AssertionError() if (!((-1).toFloat() !in emptyObjectArray.indices) != range3.contains((-1).toFloat())) throw AssertionError() // no local optimizations if (element4 in emptyObjectArray.indices != range3.contains(element4)) throw AssertionError() if (element4 !in emptyObjectArray.indices != !range3.contains(element4)) throw AssertionError() if (!(element4 in emptyObjectArray.indices) != !range3.contains(element4)) throw AssertionError() if (!(element4 !in emptyObjectArray.indices) != range3.contains(element4)) throw AssertionError() } fun testR3xE5() { // with possible local optimizations if ((-1).toDouble() in emptyObjectArray.indices != range3.contains((-1).toDouble())) throw AssertionError() if ((-1).toDouble() !in emptyObjectArray.indices != !range3.contains((-1).toDouble())) throw AssertionError() if (!((-1).toDouble() in emptyObjectArray.indices) != !range3.contains((-1).toDouble())) throw AssertionError() if (!((-1).toDouble() !in emptyObjectArray.indices) != range3.contains((-1).toDouble())) throw AssertionError() // no local optimizations if (element5 in emptyObjectArray.indices != range3.contains(element5)) throw AssertionError() if (element5 !in emptyObjectArray.indices != !range3.contains(element5)) throw AssertionError() if (!(element5 in emptyObjectArray.indices) != !range3.contains(element5)) throw AssertionError() if (!(element5 !in emptyObjectArray.indices) != range3.contains(element5)) throw AssertionError() } fun testR3xE6() { // with possible local optimizations if (0.toByte() in emptyObjectArray.indices != range3.contains(0.toByte())) throw AssertionError() if (0.toByte() !in emptyObjectArray.indices != !range3.contains(0.toByte())) throw AssertionError() if (!(0.toByte() in emptyObjectArray.indices) != !range3.contains(0.toByte())) throw AssertionError() if (!(0.toByte() !in emptyObjectArray.indices) != range3.contains(0.toByte())) throw AssertionError() // no local optimizations if (element6 in emptyObjectArray.indices != range3.contains(element6)) throw AssertionError() if (element6 !in emptyObjectArray.indices != !range3.contains(element6)) throw AssertionError() if (!(element6 in emptyObjectArray.indices) != !range3.contains(element6)) throw AssertionError() if (!(element6 !in emptyObjectArray.indices) != range3.contains(element6)) throw AssertionError() } fun testR3xE7() { // with possible local optimizations if (0.toShort() in emptyObjectArray.indices != range3.contains(0.toShort())) throw AssertionError() if (0.toShort() !in emptyObjectArray.indices != !range3.contains(0.toShort())) throw AssertionError() if (!(0.toShort() in emptyObjectArray.indices) != !range3.contains(0.toShort())) throw AssertionError() if (!(0.toShort() !in emptyObjectArray.indices) != range3.contains(0.toShort())) throw AssertionError() // no local optimizations if (element7 in emptyObjectArray.indices != range3.contains(element7)) throw AssertionError() if (element7 !in emptyObjectArray.indices != !range3.contains(element7)) throw AssertionError() if (!(element7 in emptyObjectArray.indices) != !range3.contains(element7)) throw AssertionError() if (!(element7 !in emptyObjectArray.indices) != range3.contains(element7)) throw AssertionError() } fun testR3xE8() { // with possible local optimizations if (0 in emptyObjectArray.indices != range3.contains(0)) throw AssertionError() if (0 !in emptyObjectArray.indices != !range3.contains(0)) throw AssertionError() if (!(0 in emptyObjectArray.indices) != !range3.contains(0)) throw AssertionError() if (!(0 !in emptyObjectArray.indices) != range3.contains(0)) throw AssertionError() // no local optimizations if (element8 in emptyObjectArray.indices != range3.contains(element8)) throw AssertionError() if (element8 !in emptyObjectArray.indices != !range3.contains(element8)) throw AssertionError() if (!(element8 in emptyObjectArray.indices) != !range3.contains(element8)) throw AssertionError() if (!(element8 !in emptyObjectArray.indices) != range3.contains(element8)) throw AssertionError() } fun testR3xE9() { // with possible local optimizations if (0.toLong() in emptyObjectArray.indices != range3.contains(0.toLong())) throw AssertionError() if (0.toLong() !in emptyObjectArray.indices != !range3.contains(0.toLong())) throw AssertionError() if (!(0.toLong() in emptyObjectArray.indices) != !range3.contains(0.toLong())) throw AssertionError() if (!(0.toLong() !in emptyObjectArray.indices) != range3.contains(0.toLong())) throw AssertionError() // no local optimizations if (element9 in emptyObjectArray.indices != range3.contains(element9)) throw AssertionError() if (element9 !in emptyObjectArray.indices != !range3.contains(element9)) throw AssertionError() if (!(element9 in emptyObjectArray.indices) != !range3.contains(element9)) throw AssertionError() if (!(element9 !in emptyObjectArray.indices) != range3.contains(element9)) throw AssertionError() } fun testR3xE10() { // with possible local optimizations if (0.toFloat() in emptyObjectArray.indices != range3.contains(0.toFloat())) throw AssertionError() if (0.toFloat() !in emptyObjectArray.indices != !range3.contains(0.toFloat())) throw AssertionError() if (!(0.toFloat() in emptyObjectArray.indices) != !range3.contains(0.toFloat())) throw AssertionError() if (!(0.toFloat() !in emptyObjectArray.indices) != range3.contains(0.toFloat())) throw AssertionError() // no local optimizations if (element10 in emptyObjectArray.indices != range3.contains(element10)) throw AssertionError() if (element10 !in emptyObjectArray.indices != !range3.contains(element10)) throw AssertionError() if (!(element10 in emptyObjectArray.indices) != !range3.contains(element10)) throw AssertionError() if (!(element10 !in emptyObjectArray.indices) != range3.contains(element10)) throw AssertionError() } fun testR3xE11() { // with possible local optimizations if (0.toDouble() in emptyObjectArray.indices != range3.contains(0.toDouble())) throw AssertionError() if (0.toDouble() !in emptyObjectArray.indices != !range3.contains(0.toDouble())) throw AssertionError() if (!(0.toDouble() in emptyObjectArray.indices) != !range3.contains(0.toDouble())) throw AssertionError() if (!(0.toDouble() !in emptyObjectArray.indices) != range3.contains(0.toDouble())) throw AssertionError() // no local optimizations if (element11 in emptyObjectArray.indices != range3.contains(element11)) throw AssertionError() if (element11 !in emptyObjectArray.indices != !range3.contains(element11)) throw AssertionError() if (!(element11 in emptyObjectArray.indices) != !range3.contains(element11)) throw AssertionError() if (!(element11 !in emptyObjectArray.indices) != range3.contains(element11)) throw AssertionError() } fun testR3xE12() { // with possible local optimizations if (1.toByte() in emptyObjectArray.indices != range3.contains(1.toByte())) throw AssertionError() if (1.toByte() !in emptyObjectArray.indices != !range3.contains(1.toByte())) throw AssertionError() if (!(1.toByte() in emptyObjectArray.indices) != !range3.contains(1.toByte())) throw AssertionError() if (!(1.toByte() !in emptyObjectArray.indices) != range3.contains(1.toByte())) throw AssertionError() // no local optimizations if (element12 in emptyObjectArray.indices != range3.contains(element12)) throw AssertionError() if (element12 !in emptyObjectArray.indices != !range3.contains(element12)) throw AssertionError() if (!(element12 in emptyObjectArray.indices) != !range3.contains(element12)) throw AssertionError() if (!(element12 !in emptyObjectArray.indices) != range3.contains(element12)) throw AssertionError() } fun testR3xE13() { // with possible local optimizations if (1.toShort() in emptyObjectArray.indices != range3.contains(1.toShort())) throw AssertionError() if (1.toShort() !in emptyObjectArray.indices != !range3.contains(1.toShort())) throw AssertionError() if (!(1.toShort() in emptyObjectArray.indices) != !range3.contains(1.toShort())) throw AssertionError() if (!(1.toShort() !in emptyObjectArray.indices) != range3.contains(1.toShort())) throw AssertionError() // no local optimizations if (element13 in emptyObjectArray.indices != range3.contains(element13)) throw AssertionError() if (element13 !in emptyObjectArray.indices != !range3.contains(element13)) throw AssertionError() if (!(element13 in emptyObjectArray.indices) != !range3.contains(element13)) throw AssertionError() if (!(element13 !in emptyObjectArray.indices) != range3.contains(element13)) throw AssertionError() } fun testR3xE14() { // with possible local optimizations if (1 in emptyObjectArray.indices != range3.contains(1)) throw AssertionError() if (1 !in emptyObjectArray.indices != !range3.contains(1)) throw AssertionError() if (!(1 in emptyObjectArray.indices) != !range3.contains(1)) throw AssertionError() if (!(1 !in emptyObjectArray.indices) != range3.contains(1)) throw AssertionError() // no local optimizations if (element14 in emptyObjectArray.indices != range3.contains(element14)) throw AssertionError() if (element14 !in emptyObjectArray.indices != !range3.contains(element14)) throw AssertionError() if (!(element14 in emptyObjectArray.indices) != !range3.contains(element14)) throw AssertionError() if (!(element14 !in emptyObjectArray.indices) != range3.contains(element14)) throw AssertionError() } fun testR3xE15() { // with possible local optimizations if (1.toLong() in emptyObjectArray.indices != range3.contains(1.toLong())) throw AssertionError() if (1.toLong() !in emptyObjectArray.indices != !range3.contains(1.toLong())) throw AssertionError() if (!(1.toLong() in emptyObjectArray.indices) != !range3.contains(1.toLong())) throw AssertionError() if (!(1.toLong() !in emptyObjectArray.indices) != range3.contains(1.toLong())) throw AssertionError() // no local optimizations if (element15 in emptyObjectArray.indices != range3.contains(element15)) throw AssertionError() if (element15 !in emptyObjectArray.indices != !range3.contains(element15)) throw AssertionError() if (!(element15 in emptyObjectArray.indices) != !range3.contains(element15)) throw AssertionError() if (!(element15 !in emptyObjectArray.indices) != range3.contains(element15)) throw AssertionError() } fun testR3xE16() { // with possible local optimizations if (1.toFloat() in emptyObjectArray.indices != range3.contains(1.toFloat())) throw AssertionError() if (1.toFloat() !in emptyObjectArray.indices != !range3.contains(1.toFloat())) throw AssertionError() if (!(1.toFloat() in emptyObjectArray.indices) != !range3.contains(1.toFloat())) throw AssertionError() if (!(1.toFloat() !in emptyObjectArray.indices) != range3.contains(1.toFloat())) throw AssertionError() // no local optimizations if (element16 in emptyObjectArray.indices != range3.contains(element16)) throw AssertionError() if (element16 !in emptyObjectArray.indices != !range3.contains(element16)) throw AssertionError() if (!(element16 in emptyObjectArray.indices) != !range3.contains(element16)) throw AssertionError() if (!(element16 !in emptyObjectArray.indices) != range3.contains(element16)) throw AssertionError() } fun testR3xE17() { // with possible local optimizations if (1.toDouble() in emptyObjectArray.indices != range3.contains(1.toDouble())) throw AssertionError() if (1.toDouble() !in emptyObjectArray.indices != !range3.contains(1.toDouble())) throw AssertionError() if (!(1.toDouble() in emptyObjectArray.indices) != !range3.contains(1.toDouble())) throw AssertionError() if (!(1.toDouble() !in emptyObjectArray.indices) != range3.contains(1.toDouble())) throw AssertionError() // no local optimizations if (element17 in emptyObjectArray.indices != range3.contains(element17)) throw AssertionError() if (element17 !in emptyObjectArray.indices != !range3.contains(element17)) throw AssertionError() if (!(element17 in emptyObjectArray.indices) != !range3.contains(element17)) throw AssertionError() if (!(element17 !in emptyObjectArray.indices) != range3.contains(element17)) throw AssertionError() } fun testR3xE18() { // with possible local optimizations if (2.toByte() in emptyObjectArray.indices != range3.contains(2.toByte())) throw AssertionError() if (2.toByte() !in emptyObjectArray.indices != !range3.contains(2.toByte())) throw AssertionError() if (!(2.toByte() in emptyObjectArray.indices) != !range3.contains(2.toByte())) throw AssertionError() if (!(2.toByte() !in emptyObjectArray.indices) != range3.contains(2.toByte())) throw AssertionError() // no local optimizations if (element18 in emptyObjectArray.indices != range3.contains(element18)) throw AssertionError() if (element18 !in emptyObjectArray.indices != !range3.contains(element18)) throw AssertionError() if (!(element18 in emptyObjectArray.indices) != !range3.contains(element18)) throw AssertionError() if (!(element18 !in emptyObjectArray.indices) != range3.contains(element18)) throw AssertionError() } fun testR3xE19() { // with possible local optimizations if (2.toShort() in emptyObjectArray.indices != range3.contains(2.toShort())) throw AssertionError() if (2.toShort() !in emptyObjectArray.indices != !range3.contains(2.toShort())) throw AssertionError() if (!(2.toShort() in emptyObjectArray.indices) != !range3.contains(2.toShort())) throw AssertionError() if (!(2.toShort() !in emptyObjectArray.indices) != range3.contains(2.toShort())) throw AssertionError() // no local optimizations if (element19 in emptyObjectArray.indices != range3.contains(element19)) throw AssertionError() if (element19 !in emptyObjectArray.indices != !range3.contains(element19)) throw AssertionError() if (!(element19 in emptyObjectArray.indices) != !range3.contains(element19)) throw AssertionError() if (!(element19 !in emptyObjectArray.indices) != range3.contains(element19)) throw AssertionError() } fun testR3xE20() { // with possible local optimizations if (2 in emptyObjectArray.indices != range3.contains(2)) throw AssertionError() if (2 !in emptyObjectArray.indices != !range3.contains(2)) throw AssertionError() if (!(2 in emptyObjectArray.indices) != !range3.contains(2)) throw AssertionError() if (!(2 !in emptyObjectArray.indices) != range3.contains(2)) throw AssertionError() // no local optimizations if (element20 in emptyObjectArray.indices != range3.contains(element20)) throw AssertionError() if (element20 !in emptyObjectArray.indices != !range3.contains(element20)) throw AssertionError() if (!(element20 in emptyObjectArray.indices) != !range3.contains(element20)) throw AssertionError() if (!(element20 !in emptyObjectArray.indices) != range3.contains(element20)) throw AssertionError() } fun testR3xE21() { // with possible local optimizations if (2.toLong() in emptyObjectArray.indices != range3.contains(2.toLong())) throw AssertionError() if (2.toLong() !in emptyObjectArray.indices != !range3.contains(2.toLong())) throw AssertionError() if (!(2.toLong() in emptyObjectArray.indices) != !range3.contains(2.toLong())) throw AssertionError() if (!(2.toLong() !in emptyObjectArray.indices) != range3.contains(2.toLong())) throw AssertionError() // no local optimizations if (element21 in emptyObjectArray.indices != range3.contains(element21)) throw AssertionError() if (element21 !in emptyObjectArray.indices != !range3.contains(element21)) throw AssertionError() if (!(element21 in emptyObjectArray.indices) != !range3.contains(element21)) throw AssertionError() if (!(element21 !in emptyObjectArray.indices) != range3.contains(element21)) throw AssertionError() } fun testR3xE22() { // with possible local optimizations if (2.toFloat() in emptyObjectArray.indices != range3.contains(2.toFloat())) throw AssertionError() if (2.toFloat() !in emptyObjectArray.indices != !range3.contains(2.toFloat())) throw AssertionError() if (!(2.toFloat() in emptyObjectArray.indices) != !range3.contains(2.toFloat())) throw AssertionError() if (!(2.toFloat() !in emptyObjectArray.indices) != range3.contains(2.toFloat())) throw AssertionError() // no local optimizations if (element22 in emptyObjectArray.indices != range3.contains(element22)) throw AssertionError() if (element22 !in emptyObjectArray.indices != !range3.contains(element22)) throw AssertionError() if (!(element22 in emptyObjectArray.indices) != !range3.contains(element22)) throw AssertionError() if (!(element22 !in emptyObjectArray.indices) != range3.contains(element22)) throw AssertionError() } fun testR3xE23() { // with possible local optimizations if (2.toDouble() in emptyObjectArray.indices != range3.contains(2.toDouble())) throw AssertionError() if (2.toDouble() !in emptyObjectArray.indices != !range3.contains(2.toDouble())) throw AssertionError() if (!(2.toDouble() in emptyObjectArray.indices) != !range3.contains(2.toDouble())) throw AssertionError() if (!(2.toDouble() !in emptyObjectArray.indices) != range3.contains(2.toDouble())) throw AssertionError() // no local optimizations if (element23 in emptyObjectArray.indices != range3.contains(element23)) throw AssertionError() if (element23 !in emptyObjectArray.indices != !range3.contains(element23)) throw AssertionError() if (!(element23 in emptyObjectArray.indices) != !range3.contains(element23)) throw AssertionError() if (!(element23 !in emptyObjectArray.indices) != range3.contains(element23)) throw AssertionError() } fun testR3xE24() { // with possible local optimizations if (3.toByte() in emptyObjectArray.indices != range3.contains(3.toByte())) throw AssertionError() if (3.toByte() !in emptyObjectArray.indices != !range3.contains(3.toByte())) throw AssertionError() if (!(3.toByte() in emptyObjectArray.indices) != !range3.contains(3.toByte())) throw AssertionError() if (!(3.toByte() !in emptyObjectArray.indices) != range3.contains(3.toByte())) throw AssertionError() // no local optimizations if (element24 in emptyObjectArray.indices != range3.contains(element24)) throw AssertionError() if (element24 !in emptyObjectArray.indices != !range3.contains(element24)) throw AssertionError() if (!(element24 in emptyObjectArray.indices) != !range3.contains(element24)) throw AssertionError() if (!(element24 !in emptyObjectArray.indices) != range3.contains(element24)) throw AssertionError() } fun testR3xE25() { // with possible local optimizations if (3.toShort() in emptyObjectArray.indices != range3.contains(3.toShort())) throw AssertionError() if (3.toShort() !in emptyObjectArray.indices != !range3.contains(3.toShort())) throw AssertionError() if (!(3.toShort() in emptyObjectArray.indices) != !range3.contains(3.toShort())) throw AssertionError() if (!(3.toShort() !in emptyObjectArray.indices) != range3.contains(3.toShort())) throw AssertionError() // no local optimizations if (element25 in emptyObjectArray.indices != range3.contains(element25)) throw AssertionError() if (element25 !in emptyObjectArray.indices != !range3.contains(element25)) throw AssertionError() if (!(element25 in emptyObjectArray.indices) != !range3.contains(element25)) throw AssertionError() if (!(element25 !in emptyObjectArray.indices) != range3.contains(element25)) throw AssertionError() } fun testR3xE26() { // with possible local optimizations if (3 in emptyObjectArray.indices != range3.contains(3)) throw AssertionError() if (3 !in emptyObjectArray.indices != !range3.contains(3)) throw AssertionError() if (!(3 in emptyObjectArray.indices) != !range3.contains(3)) throw AssertionError() if (!(3 !in emptyObjectArray.indices) != range3.contains(3)) throw AssertionError() // no local optimizations if (element26 in emptyObjectArray.indices != range3.contains(element26)) throw AssertionError() if (element26 !in emptyObjectArray.indices != !range3.contains(element26)) throw AssertionError() if (!(element26 in emptyObjectArray.indices) != !range3.contains(element26)) throw AssertionError() if (!(element26 !in emptyObjectArray.indices) != range3.contains(element26)) throw AssertionError() } fun testR3xE27() { // with possible local optimizations if (3.toLong() in emptyObjectArray.indices != range3.contains(3.toLong())) throw AssertionError() if (3.toLong() !in emptyObjectArray.indices != !range3.contains(3.toLong())) throw AssertionError() if (!(3.toLong() in emptyObjectArray.indices) != !range3.contains(3.toLong())) throw AssertionError() if (!(3.toLong() !in emptyObjectArray.indices) != range3.contains(3.toLong())) throw AssertionError() // no local optimizations if (element27 in emptyObjectArray.indices != range3.contains(element27)) throw AssertionError() if (element27 !in emptyObjectArray.indices != !range3.contains(element27)) throw AssertionError() if (!(element27 in emptyObjectArray.indices) != !range3.contains(element27)) throw AssertionError() if (!(element27 !in emptyObjectArray.indices) != range3.contains(element27)) throw AssertionError() } fun testR3xE28() { // with possible local optimizations if (3.toFloat() in emptyObjectArray.indices != range3.contains(3.toFloat())) throw AssertionError() if (3.toFloat() !in emptyObjectArray.indices != !range3.contains(3.toFloat())) throw AssertionError() if (!(3.toFloat() in emptyObjectArray.indices) != !range3.contains(3.toFloat())) throw AssertionError() if (!(3.toFloat() !in emptyObjectArray.indices) != range3.contains(3.toFloat())) throw AssertionError() // no local optimizations if (element28 in emptyObjectArray.indices != range3.contains(element28)) throw AssertionError() if (element28 !in emptyObjectArray.indices != !range3.contains(element28)) throw AssertionError() if (!(element28 in emptyObjectArray.indices) != !range3.contains(element28)) throw AssertionError() if (!(element28 !in emptyObjectArray.indices) != range3.contains(element28)) throw AssertionError() } fun testR3xE29() { // with possible local optimizations if (3.toDouble() in emptyObjectArray.indices != range3.contains(3.toDouble())) throw AssertionError() if (3.toDouble() !in emptyObjectArray.indices != !range3.contains(3.toDouble())) throw AssertionError() if (!(3.toDouble() in emptyObjectArray.indices) != !range3.contains(3.toDouble())) throw AssertionError() if (!(3.toDouble() !in emptyObjectArray.indices) != range3.contains(3.toDouble())) throw AssertionError() // no local optimizations if (element29 in emptyObjectArray.indices != range3.contains(element29)) throw AssertionError() if (element29 !in emptyObjectArray.indices != !range3.contains(element29)) throw AssertionError() if (!(element29 in emptyObjectArray.indices) != !range3.contains(element29)) throw AssertionError() if (!(element29 !in emptyObjectArray.indices) != range3.contains(element29)) throw AssertionError() } fun testR3xE30() { // with possible local optimizations if (4.toByte() in emptyObjectArray.indices != range3.contains(4.toByte())) throw AssertionError() if (4.toByte() !in emptyObjectArray.indices != !range3.contains(4.toByte())) throw AssertionError() if (!(4.toByte() in emptyObjectArray.indices) != !range3.contains(4.toByte())) throw AssertionError() if (!(4.toByte() !in emptyObjectArray.indices) != range3.contains(4.toByte())) throw AssertionError() // no local optimizations if (element30 in emptyObjectArray.indices != range3.contains(element30)) throw AssertionError() if (element30 !in emptyObjectArray.indices != !range3.contains(element30)) throw AssertionError() if (!(element30 in emptyObjectArray.indices) != !range3.contains(element30)) throw AssertionError() if (!(element30 !in emptyObjectArray.indices) != range3.contains(element30)) throw AssertionError() } fun testR3xE31() { // with possible local optimizations if (4.toShort() in emptyObjectArray.indices != range3.contains(4.toShort())) throw AssertionError() if (4.toShort() !in emptyObjectArray.indices != !range3.contains(4.toShort())) throw AssertionError() if (!(4.toShort() in emptyObjectArray.indices) != !range3.contains(4.toShort())) throw AssertionError() if (!(4.toShort() !in emptyObjectArray.indices) != range3.contains(4.toShort())) throw AssertionError() // no local optimizations if (element31 in emptyObjectArray.indices != range3.contains(element31)) throw AssertionError() if (element31 !in emptyObjectArray.indices != !range3.contains(element31)) throw AssertionError() if (!(element31 in emptyObjectArray.indices) != !range3.contains(element31)) throw AssertionError() if (!(element31 !in emptyObjectArray.indices) != range3.contains(element31)) throw AssertionError() } fun testR3xE32() { // with possible local optimizations if (4 in emptyObjectArray.indices != range3.contains(4)) throw AssertionError() if (4 !in emptyObjectArray.indices != !range3.contains(4)) throw AssertionError() if (!(4 in emptyObjectArray.indices) != !range3.contains(4)) throw AssertionError() if (!(4 !in emptyObjectArray.indices) != range3.contains(4)) throw AssertionError() // no local optimizations if (element32 in emptyObjectArray.indices != range3.contains(element32)) throw AssertionError() if (element32 !in emptyObjectArray.indices != !range3.contains(element32)) throw AssertionError() if (!(element32 in emptyObjectArray.indices) != !range3.contains(element32)) throw AssertionError() if (!(element32 !in emptyObjectArray.indices) != range3.contains(element32)) throw AssertionError() } fun testR3xE33() { // with possible local optimizations if (4.toLong() in emptyObjectArray.indices != range3.contains(4.toLong())) throw AssertionError() if (4.toLong() !in emptyObjectArray.indices != !range3.contains(4.toLong())) throw AssertionError() if (!(4.toLong() in emptyObjectArray.indices) != !range3.contains(4.toLong())) throw AssertionError() if (!(4.toLong() !in emptyObjectArray.indices) != range3.contains(4.toLong())) throw AssertionError() // no local optimizations if (element33 in emptyObjectArray.indices != range3.contains(element33)) throw AssertionError() if (element33 !in emptyObjectArray.indices != !range3.contains(element33)) throw AssertionError() if (!(element33 in emptyObjectArray.indices) != !range3.contains(element33)) throw AssertionError() if (!(element33 !in emptyObjectArray.indices) != range3.contains(element33)) throw AssertionError() } fun testR3xE34() { // with possible local optimizations if (4.toFloat() in emptyObjectArray.indices != range3.contains(4.toFloat())) throw AssertionError() if (4.toFloat() !in emptyObjectArray.indices != !range3.contains(4.toFloat())) throw AssertionError() if (!(4.toFloat() in emptyObjectArray.indices) != !range3.contains(4.toFloat())) throw AssertionError() if (!(4.toFloat() !in emptyObjectArray.indices) != range3.contains(4.toFloat())) throw AssertionError() // no local optimizations if (element34 in emptyObjectArray.indices != range3.contains(element34)) throw AssertionError() if (element34 !in emptyObjectArray.indices != !range3.contains(element34)) throw AssertionError() if (!(element34 in emptyObjectArray.indices) != !range3.contains(element34)) throw AssertionError() if (!(element34 !in emptyObjectArray.indices) != range3.contains(element34)) throw AssertionError() } fun testR3xE35() { // with possible local optimizations if (4.toDouble() in emptyObjectArray.indices != range3.contains(4.toDouble())) throw AssertionError() if (4.toDouble() !in emptyObjectArray.indices != !range3.contains(4.toDouble())) throw AssertionError() if (!(4.toDouble() in emptyObjectArray.indices) != !range3.contains(4.toDouble())) throw AssertionError() if (!(4.toDouble() !in emptyObjectArray.indices) != range3.contains(4.toDouble())) throw AssertionError() // no local optimizations if (element35 in emptyObjectArray.indices != range3.contains(element35)) throw AssertionError() if (element35 !in emptyObjectArray.indices != !range3.contains(element35)) throw AssertionError() if (!(element35 in emptyObjectArray.indices) != !range3.contains(element35)) throw AssertionError() if (!(element35 !in emptyObjectArray.indices) != range3.contains(element35)) throw AssertionError() }
backend.native/tests/external/codegen/box/ranges/contains/generated/arrayIndices.kt
4055695908
package codegen.kclass.kclass1 import kotlin.test.* // FILE: main.kt @Test fun runTest() { App(testQualified = true) } // FILE: app.kt // Taken from: // https://github.com/SalomonBrys/kmffkn/blob/master/shared/main/kotlin/com/github/salomonbrys/kmffkn/app.kt @DslMarker annotation class MyDsl @MyDsl class DslMain { fun <T: Any> kClass(block: KClassDsl.() -> T): T = KClassDsl().block() } @MyDsl class KClassDsl { inline fun <reified T: Any> of() = T::class } fun <T: Any> dsl(block: DslMain.() -> T): T = DslMain().block() class TestClass class App(testQualified: Boolean) { @Volatile // This could be noop in Kotlin Native, or the equivalent of volatile in C. var type = dsl { kClass { //kClass { } // This should error if uncommented because of `@DslMarker`. of<TestClass>() } } init { assert(type.simpleName == "TestClass") if (testQualified) assert(type.qualifiedName == "codegen.kclass.kclass1.TestClass") // This is not really necessary, but always better :). assert(String::class == String::class) assert(String::class != Int::class) assert(TestClass()::class == TestClass()::class) assert(TestClass()::class == TestClass::class) println("OK :D") } }
backend.native/tests/codegen/kclass/kclass1.kt
1357163311
package com.sothree.slidinguppanel.positionhelper.impl import android.view.View import android.widget.ScrollView open class ScrollViewScrollPositionHelper : AbstractScrollPositionHelper<ScrollView>() { override fun isSupport(view: View): Boolean { return view is ScrollView } override fun getPosition(view: ScrollView, isSlidingUp: Boolean): Int { return if (isSlidingUp) { view.scrollY } else { val child = view.getChildAt(0) child.bottom - (view.height + view.scrollY) } } }
library/src/main/java/com/sothree/slidinguppanel/positionhelper/impl/ScrollViewScrollPositionHelper.kt
2296993224
package de.reiss.bible2net.theword.note.export sealed class NoteExportStatus { object NoPermission : NoteExportStatus() object NoNotes : NoteExportStatus() class ExportError(val fileName: String) : NoteExportStatus() class ExportSuccess(val fileName: String) : NoteExportStatus() object Exporting : NoteExportStatus() }
app/src/main/java/de/reiss/bible2net/theword/note/export/NoteExportStatus.kt
223959123
/* * This file is part of MythicDrops, licensed under the MIT License. * * Copyright (C) 2020 Richard Harrah * * Permission is hereby granted, free of charge, * to any person obtaining a copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation the rights to use, * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package com.tealcube.minecraft.bukkit.mythicdrops.armor import com.tealcube.minecraft.bukkit.mythicdrops.api.events.MythicDropsCancellableEvent import org.bukkit.entity.Player import org.bukkit.event.HandlerList import org.bukkit.inventory.ItemStack /** * Modified version of ArmorEquipEvent from ArmorEquipEvent. * * https://github.com/Arnuh/ArmorEquipEvent */ class ArmorEquipEvent( val player: Player, val equipMethod: EquipMethod, val armorType: ArmorType, val oldArmorPiece: ItemStack?, val newArmorPiece: ItemStack? ) : MythicDropsCancellableEvent() { companion object { @JvmStatic val handlerList = HandlerList() } enum class EquipMethod { /** * When shift clicking an item to the slot from the inventory */ SHIFT_CLICK, /** * When picking up and putting an item into an armor slot */ CLICK, /** * When interacting with AIR with armor in hand and no armor in target slot */ HOTBAR_INTERACT, /** * When pressing the hotbar key while hovering over a target slot */ HOTBAR_SWAP, /** * When dispenser shoots armor onto player */ DISPENSER, /** * When an armor piece breaks */ BROKE, /** * When player dies */ DEATH } override fun getHandlers(): HandlerList = handlerList }
src/main/kotlin/com/tealcube/minecraft/bukkit/mythicdrops/armor/ArmorEquipEvent.kt
3633561536
package expo.modules.haptics.arguments object HapticsImpactType { private val types = mapOf( "light" to HapticsVibrationType( longArrayOf(0, 50), intArrayOf(0, 110), longArrayOf(0, 20) ), "medium" to HapticsVibrationType( longArrayOf(0, 43), intArrayOf(0, 180), longArrayOf(0, 43) ), "heavy" to HapticsVibrationType( longArrayOf(0, 60), intArrayOf(0, 255), longArrayOf(0, 61) ) ) @Throws(HapticsInvalidArgumentException::class) fun fromString(style: String): HapticsVibrationType = types.getOrElse(style) { throw HapticsInvalidArgumentException("'style' must be one of ['light', 'medium', 'heavy']. Obtained $style'.") } }
packages/expo-haptics/android/src/main/java/expo/modules/haptics/arguments/HapticsImpactType.kt
3505154201
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.kotlin.idea.maven.inspections import com.intellij.codeInspection.LocalQuickFix import com.intellij.codeInspection.ProblemDescriptor import com.intellij.ide.highlighter.JavaFileType import com.intellij.lang.annotation.HighlightSeverity import com.intellij.openapi.module.Module import com.intellij.openapi.project.Project import com.intellij.psi.search.FileTypeIndex import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.xml.XmlFile import com.intellij.util.xml.DomFileElement import com.intellij.util.xml.highlighting.DomElementAnnotationHolder import com.intellij.util.xml.highlighting.DomElementsInspection import org.jetbrains.idea.maven.dom.model.MavenDomGoal import org.jetbrains.idea.maven.dom.model.MavenDomPlugin import org.jetbrains.idea.maven.dom.model.MavenDomPluginExecution import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel import org.jetbrains.idea.maven.model.MavenId import org.jetbrains.idea.maven.model.MavenPlugin import org.jetbrains.idea.maven.project.MavenProjectsManager import org.jetbrains.idea.maven.utils.MavenArtifactScope import org.jetbrains.kotlin.idea.maven.KotlinMavenBundle import org.jetbrains.kotlin.idea.maven.PomFile import org.jetbrains.kotlin.idea.maven.configuration.KotlinMavenConfigurator import org.jetbrains.kotlin.idea.platform.tooling import org.jetbrains.kotlin.idea.versions.MAVEN_JS_STDLIB_ID import org.jetbrains.kotlin.idea.versions.MAVEN_STDLIB_ID import org.jetbrains.kotlin.platform.impl.JvmIdePlatformKind import org.jetbrains.kotlin.psi.psiUtil.createSmartPointer import java.util.* class KotlinMavenPluginPhaseInspection : DomElementsInspection<MavenDomProjectModel>(MavenDomProjectModel::class.java) { companion object { private val JVM_STDLIB_IDS = JvmIdePlatformKind.tooling .mavenLibraryIds.map { MavenId(KotlinMavenConfigurator.GROUP_ID, it, null) } private val JS_STDLIB_MAVEN_ID = MavenId(KotlinMavenConfigurator.GROUP_ID, MAVEN_JS_STDLIB_ID, null) } override fun getStaticDescription() = KotlinMavenBundle.message("inspection.description") override fun checkFileElement(domFileElement: DomFileElement<MavenDomProjectModel>?, holder: DomElementAnnotationHolder?) { if (domFileElement == null || holder == null) { return } val module = domFileElement.module ?: return val manager = MavenProjectsManager.getInstance(module.project) val mavenProject = manager.findProject(module) ?: return val pom = PomFile.forFileOrNull(domFileElement.file) ?: return val hasJavaFiles = module.hasJavaFiles() // all executions including inherited val executions = mavenProject.plugins .filter { it.isKotlinMavenPlugin() } .flatMap { it.executions } val allGoalsSet: Set<String> = executions.flatMapTo(HashSet()) { it.goals } val hasJvmExecution = PomFile.KotlinGoals.Compile in allGoalsSet || PomFile.KotlinGoals.TestCompile in allGoalsSet val hasJsExecution = PomFile.KotlinGoals.Js in allGoalsSet || PomFile.KotlinGoals.TestJs in allGoalsSet val pomKotlinPlugins = pom.findKotlinPlugins() for (kotlinPlugin in pomKotlinPlugins) { if (PomFile.KotlinGoals.Compile !in allGoalsSet && PomFile.KotlinGoals.Js !in allGoalsSet) { val fixes = if (hasJavaFiles) { arrayOf(AddExecutionLocalFix(domFileElement.file, module, kotlinPlugin, PomFile.KotlinGoals.Compile)) } else { arrayOf( AddExecutionLocalFix(domFileElement.file, module, kotlinPlugin, PomFile.KotlinGoals.Compile), AddExecutionLocalFix(domFileElement.file, module, kotlinPlugin, PomFile.KotlinGoals.Js) ) } holder.createProblem( kotlinPlugin.artifactId.createStableCopy(), HighlightSeverity.WARNING, KotlinMavenBundle.message("inspection.no.executions"), *fixes ) } else { if (hasJavaFiles) { pom.findExecutions(kotlinPlugin, PomFile.KotlinGoals.Compile).notAtPhase(PomFile.DefaultPhases.ProcessSources) .forEach { badExecution -> val javacPlugin = mavenProject.findPlugin("org.apache.maven.plugins", "maven-compiler-plugin") val existingJavac = pom.domModel.build.plugins.plugins.firstOrNull { it.groupId.stringValue == "org.apache.maven.plugins" && it.artifactId.stringValue == "maven-compiler-plugin" } if (existingJavac == null || !pom.isPluginAfter(existingJavac, kotlinPlugin) || pom.isExecutionEnabled(javacPlugin, "default-compile") || pom.isExecutionEnabled(javacPlugin, "default-testCompile") || pom.isPluginExecutionMissing(javacPlugin, "default-compile", "compile") || pom.isPluginExecutionMissing(javacPlugin, "default-testCompile", "testCompile") ) { holder.createProblem( badExecution.phase.createStableCopy(), HighlightSeverity.WARNING, KotlinMavenBundle.message("inspection.should.run.before.javac"), FixExecutionPhaseLocalFix(badExecution, PomFile.DefaultPhases.ProcessSources), AddJavaExecutionsLocalFix(module, domFileElement.file, kotlinPlugin) ) } } pom.findExecutions(kotlinPlugin, PomFile.KotlinGoals.Js, PomFile.KotlinGoals.TestJs).forEach { badExecution -> holder.createProblem( badExecution.goals.goals.first { it.isJsGoal() }.createStableCopy(), HighlightSeverity.WARNING, KotlinMavenBundle.message("inspection.javascript.in.java.module") ) } } if (hasJvmExecution && pom.findDependencies(JVM_STDLIB_IDS).isEmpty()) { val stdlibDependencies = mavenProject.findDependencies(KotlinMavenConfigurator.GROUP_ID, MAVEN_STDLIB_ID) if (stdlibDependencies.isEmpty()) { holder.createProblem( kotlinPlugin.artifactId.createStableCopy(), HighlightSeverity.WARNING, KotlinMavenBundle.message("inspection.jvm.no.stdlib.dependency", MAVEN_STDLIB_ID), FixAddStdlibLocalFix(domFileElement.file, MAVEN_STDLIB_ID, kotlinPlugin.version.rawText) ) } } if (hasJsExecution && pom.findDependencies(JVM_STDLIB_IDS).isEmpty()) { val jsDependencies = mavenProject.findDependencies(KotlinMavenConfigurator.GROUP_ID, MAVEN_JS_STDLIB_ID) if (jsDependencies.isEmpty()) { holder.createProblem( kotlinPlugin.artifactId.createStableCopy(), HighlightSeverity.WARNING, KotlinMavenBundle.message("inspection.javascript.no.stdlib.dependency", MAVEN_JS_STDLIB_ID), FixAddStdlibLocalFix(domFileElement.file, MAVEN_JS_STDLIB_ID, kotlinPlugin.version.rawText) ) } } } } val jvmStdlibDependencies = pom.findDependencies(JVM_STDLIB_IDS) if (!hasJvmExecution && jvmStdlibDependencies.isNotEmpty()) { jvmStdlibDependencies.forEach { dep -> holder.createProblem( dep.artifactId.createStableCopy(), HighlightSeverity.WARNING, KotlinMavenBundle.message("inspection.configured.no.execution", dep.artifactId), ConfigurePluginExecutionLocalFix(module, domFileElement.file, PomFile.KotlinGoals.Compile, dep.version.rawText) ) } } val stdlibJsDependencies = pom.findDependencies(JS_STDLIB_MAVEN_ID) if (!hasJsExecution && stdlibJsDependencies.isNotEmpty()) { stdlibJsDependencies.forEach { dep -> holder.createProblem( dep.artifactId.createStableCopy(), HighlightSeverity.WARNING, KotlinMavenBundle.message("inspection.configured.no.execution", dep.artifactId), ConfigurePluginExecutionLocalFix(module, domFileElement.file, PomFile.KotlinGoals.Js, dep.version.rawText) ) } } pom.findKotlinExecutions().filter { it.goals.goals.any { goal -> goal.rawText == PomFile.KotlinGoals.Compile || goal.rawText == PomFile.KotlinGoals.Js } && it.goals.goals.any { goal -> goal.rawText == PomFile.KotlinGoals.TestCompile || goal.rawText == PomFile.KotlinGoals.TestJs } }.forEach { badExecution -> holder.createProblem( badExecution.goals.createStableCopy(), HighlightSeverity.WEAK_WARNING, KotlinMavenBundle.message("inspection.same.execution.compile.test") ) } } private class AddExecutionLocalFix( file: XmlFile, val module: Module, val kotlinPlugin: MavenDomPlugin, val goal: String ) : LocalQuickFix { private val pointer = file.createSmartPointer() override fun getName() = KotlinMavenBundle.message("fix.add.execution.name", goal) override fun getFamilyName() = KotlinMavenBundle.message("fix.add.execution.family") override fun applyFix(project: Project, descriptor: ProblemDescriptor) { val file = pointer.element ?: return PomFile.forFileOrNull(file) ?.addKotlinExecution(module, kotlinPlugin, goal, PomFile.getPhase(module.hasJavaFiles(), false), false, listOf(goal)) } } private class FixExecutionPhaseLocalFix(val execution: MavenDomPluginExecution, val newPhase: String) : LocalQuickFix { override fun getName() = KotlinMavenBundle.message("fix.execution.phase.name", newPhase) override fun getFamilyName() = KotlinMavenBundle.message("fix.execution.phase.family") override fun applyFix(project: Project, descriptor: ProblemDescriptor) { execution.phase.value = newPhase } } private class AddJavaExecutionsLocalFix(val module: Module, file: XmlFile, val kotlinPlugin: MavenDomPlugin) : LocalQuickFix { private val pointer = file.createSmartPointer() override fun getName() = KotlinMavenBundle.message("fix.add.java.executions.name") override fun getFamilyName() = name override fun applyFix(project: Project, descriptor: ProblemDescriptor) { val file = pointer.element ?: return PomFile.forFileOrNull(file)?.addJavacExecutions(module, kotlinPlugin) } } private class FixAddStdlibLocalFix(pomFile: XmlFile, val id: String, val version: String?) : LocalQuickFix { private val pointer = pomFile.createSmartPointer() override fun getName() = KotlinMavenBundle.message("fix.add.stdlib.name", id) override fun getFamilyName() = KotlinMavenBundle.message("fix.add.stdlib.family") override fun applyFix(project: Project, descriptor: ProblemDescriptor) { val file = pointer.element ?: return PomFile.forFileOrNull(file)?.addDependency(MavenId(KotlinMavenConfigurator.GROUP_ID, id, version), MavenArtifactScope.COMPILE) } } private class ConfigurePluginExecutionLocalFix( val module: Module, xmlFile: XmlFile, val goal: String, val version: String? ) : LocalQuickFix { private val pointer = xmlFile.createSmartPointer() override fun getName() = KotlinMavenBundle.message("fix.configure.plugin.execution.name", goal) override fun getFamilyName() = KotlinMavenBundle.message("fix.configure.plugin.execution.family") override fun applyFix(project: Project, descriptor: ProblemDescriptor) { val file = pointer.element ?: return PomFile.forFileOrNull(file)?.let { pom -> val plugin = pom.addKotlinPlugin(version) pom.addKotlinExecution(module, plugin, "compile", PomFile.getPhase(module.hasJavaFiles(), false), false, listOf(goal)) } } } } fun Module.hasJavaFiles(): Boolean { return FileTypeIndex.containsFileOfType(JavaFileType.INSTANCE, GlobalSearchScope.moduleScope(this)) } private fun MavenPlugin.isKotlinMavenPlugin() = groupId == KotlinMavenConfigurator.GROUP_ID && artifactId == KotlinMavenConfigurator.MAVEN_PLUGIN_ID private fun MavenDomGoal.isJsGoal() = rawText == PomFile.KotlinGoals.Js || rawText == PomFile.KotlinGoals.TestJs private fun List<MavenDomPluginExecution>.notAtPhase(phase: String) = filter { it.phase.stringValue != phase }
plugins/kotlin/maven/src/org/jetbrains/kotlin/idea/maven/inspections/KotlinMavenPluginPhaseInspection.kt
2566129622
package test import org.junit.Rule class PrivateRule { @kotlin.jvm.JvmField @Rule var x = 0 }
jvm/jvm-analysis-kotlin-tests/testData/codeInspection/junitrule/RuleQf.after.kt
1007574378
fun main(args: Array<String>) { val b: Base = Derived() <caret>val a = 1 } open class Base { } class Derived: Base() { } fun Derived.funExtDerived() { } fun Base.funExtBase() { } // INVOCATION_COUNT: 1 // EXIST: funExtBase, funExtDerived // NOTHING_ELSE // RUNTIME_TYPE: Derived
plugins/kotlin/completion/tests/testData/basic/codeFragments/runtimeType/extensionMethod.kt
3673753879
class Test { val str: Int = 10 fun test() { val str: String = "" <caret> } }
plugins/kotlin/j2k/new/tests/testData/copyPastePlainText/LocalAndMemberConflict.to.kt
547788500
fun foo(){ println("<selection>\n\nhello</selection>") }
plugins/kotlin/idea/tests/testData/copyPaste/literal/UnescapeFullSelection.kt
3001110856
// "Create annotation 'bar'" "true" // ERROR: Unresolved reference: foo @[foo(1, "2", <caret>bar("3"))] fun test() { }
plugins/kotlin/idea/tests/testData/quickfix/createFromUsage/createClass/callExpression/singleArgCallInAnnotationEntry.kt
1929070095
open class Base { private val x: Long = 0 protected open fun foo(): Long = 1 } class Derived : Base() { private val x: String = "" override fun foo(): Long = 2 } fun <T> block(block: () -> T): T { return block() } fun main() { val b = Base() val d = Derived() //Breakpoint! val f = 0 } // EXPRESSION: block { d.foo() } // RESULT: 2: J // EXPRESSION: block { (d as Base).foo() } // RESULT: 2: J // EXPRESSION: block { b.foo() } // RESULT: 1: J // EXPRESSION: block { b.foo() } // RESULT: 1: J // EXPRESSION: block { b.x } // RESULT: 0: J // EXPRESSION: block { d.x } // RESULT: "": Ljava/lang/String; // EXPRESSION: block { (d as Base).x } // RESULT: 0: J
plugins/kotlin/jvm-debugger/test/testData/evaluation/singleBreakpoint/compilingEvaluator/inaccessibleMembers/superMembers.kt
4151396695
/* * Copyright 2020 Appmattus Limited * * 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 com.appmattus.layercache /* Workaround for "Cannot call abstract real method on java object". See https://github.com/nhaarman/mockito-kotlin/issues/41 */ abstract class AbstractCache<Key : Any, Value : Any> : Cache<Key, Value>
testutils/src/main/kotlin/com/appmattus/layercache/AbstractCache.kt
866611070
package io.trewartha.positional.ui.utils import android.view.View import androidx.annotation.StringRes import androidx.coordinatorlayout.widget.CoordinatorLayout import com.google.android.material.snackbar.Snackbar fun CoordinatorLayout.showSnackbar( @StringRes resId: Int, duration: Int = Snackbar.LENGTH_LONG, @StringRes actionResId: Int? = null, listener: ((View) -> Unit)? = null ) { var builder = Snackbar.make(this, resId, duration) if (actionResId != null) builder = builder.setAction(actionResId, listener) builder.show() } fun CoordinatorLayout.showSnackbar( text: String, duration: Int = Snackbar.LENGTH_LONG, actionText: String?, listener: ((View) -> Unit)? = null ) { var builder = Snackbar.make(this, text, duration) if (actionText != null) builder = builder.setAction(actionText, listener) builder.show() } fun CoordinatorLayout.showSnackbar( text: String, duration: Int = Snackbar.LENGTH_LONG, @StringRes actionResId: Int? = null, listener: ((View) -> Unit)? = null ) { var builder = Snackbar.make(this, text, duration) if (actionResId != null) builder = builder.setAction(actionResId, listener) builder.show() } fun CoordinatorLayout.showSnackbar( @StringRes resId: Int, duration: Int = Snackbar.LENGTH_LONG, actionText: String?, listener: ((View) -> Unit)? = null ) { var builder = Snackbar.make(this, resId, duration) if (actionText != null) builder = builder.setAction(actionText, listener) builder.show() }
app/src/main/kotlin/io/trewartha/positional/ui/utils/CoordinatorLayoutExtensions.kt
4282498501
// Copyright 2000-2020 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.workspaceModel.storage import com.intellij.openapi.util.Ref import com.intellij.workspaceModel.storage.entities.ModifiableSampleEntity import com.intellij.workspaceModel.storage.entities.ModifiableSecondSampleEntity import com.intellij.workspaceModel.storage.entities.SampleEntity import com.intellij.workspaceModel.storage.entities.addSampleEntity import com.intellij.workspaceModel.storage.impl.url.VirtualFileUrlManagerImpl import com.intellij.workspaceModel.storage.url.VirtualFileUrlManager import org.junit.Assert.* import org.junit.Before import org.junit.Test internal fun WorkspaceEntityStorage.singleSampleEntity() = entities(SampleEntity::class.java).single() class SimplePropertiesInStorageTest { private lateinit var virtualFileManager: VirtualFileUrlManager @Before fun setUp() { virtualFileManager = VirtualFileUrlManagerImpl() } @Test fun `add entity`() { val builder = createEmptyBuilder() val source = SampleEntitySource("test") val entity = builder.addSampleEntity("hello", source, true, mutableListOf("one", "two")) assertTrue(entity.booleanProperty) assertEquals("hello", entity.stringProperty) assertEquals(listOf("one", "two"), entity.stringListProperty) assertEquals(entity, builder.singleSampleEntity()) assertEquals(source, entity.entitySource) } @Test fun `remove entity`() { val builder = createEmptyBuilder() val entity = builder.addSampleEntity("hello") builder.removeEntity(entity) assertTrue(builder.entities(SampleEntity::class.java).toList().isEmpty()) } @Test fun `modify entity`() { val builder = createEmptyBuilder() val original = builder.addSampleEntity("hello") val modified = builder.modifyEntity(ModifiableSampleEntity::class.java, original) { stringProperty = "foo" stringListProperty = stringListProperty + "first" booleanProperty = true fileProperty = virtualFileManager.fromUrl("file:///xxx") } assertEquals("hello", original.stringProperty) assertEquals(emptyList<String>(), original.stringListProperty) assertEquals("foo", modified.stringProperty) assertEquals(listOf("first"), modified.stringListProperty) assertTrue(modified.booleanProperty) assertEquals("file:///xxx", modified.fileProperty.url) } @Test fun `builder from storage`() { val storage = createEmptyBuilder().apply { addSampleEntity("hello") }.toStorage() assertEquals("hello", storage.singleSampleEntity().stringProperty) val builder = createBuilderFrom(storage) assertEquals("hello", builder.singleSampleEntity().stringProperty) builder.modifyEntity(ModifiableSampleEntity::class.java, builder.singleSampleEntity()) { stringProperty = "good bye" } assertEquals("hello", storage.singleSampleEntity().stringProperty) assertEquals("good bye", builder.singleSampleEntity().stringProperty) } @Test fun `snapshot from builder`() { val builder = createEmptyBuilder() builder.addSampleEntity("hello") val snapshot = builder.toStorage() assertEquals("hello", builder.singleSampleEntity().stringProperty) assertEquals("hello", snapshot.singleSampleEntity().stringProperty) builder.modifyEntity(ModifiableSampleEntity::class.java, builder.singleSampleEntity()) { stringProperty = "good bye" } assertEquals("hello", snapshot.singleSampleEntity().stringProperty) assertEquals("good bye", builder.singleSampleEntity().stringProperty) } @Test fun `different entities with same properties`() { val builder = createEmptyBuilder() val foo1 = builder.addSampleEntity("foo1", virtualFileManager = virtualFileManager) val foo2 = builder.addSampleEntity("foo1", virtualFileManager = virtualFileManager) val bar = builder.addSampleEntity("bar", virtualFileManager = virtualFileManager) assertFalse(foo1 == foo2) assertTrue(foo1.hasEqualProperties(foo1)) assertTrue(foo1.hasEqualProperties(foo2)) assertFalse(foo1.hasEqualProperties(bar)) val builder2 = createEmptyBuilder() val foo1a = builder2.addSampleEntity("foo1", virtualFileManager = virtualFileManager) assertTrue(foo1.hasEqualProperties(foo1a)) val bar2 = builder.modifyEntity(ModifiableSampleEntity::class.java, bar) { stringProperty = "bar2" } assertTrue(bar == bar2) assertFalse(bar.hasEqualProperties(bar2)) val foo2a = builder.modifyEntity(ModifiableSampleEntity::class.java, foo2) { stringProperty = "foo2" } assertFalse(foo1.hasEqualProperties(foo2a)) } @Test fun `change source`() { val builder = createEmptyBuilder() val source1 = SampleEntitySource("1") val source2 = SampleEntitySource("2") val foo = builder.addSampleEntity("foo", source1) val foo2 = builder.changeSource(foo, source2) assertEquals(source1, foo.entitySource) assertEquals(source2, foo2.entitySource) assertEquals(source2, builder.singleSampleEntity().entitySource) assertEquals(foo2, builder.entitiesBySource { it == source2 }.values.flatMap { it.values.flatten() }.single()) assertTrue(builder.entitiesBySource { it == source1 }.values.all { it.isEmpty() }) } @Test(expected = IllegalStateException::class) fun `modifications are allowed inside special methods only`() { val thief = Ref.create<ModifiableSecondSampleEntity>() val builder = createEmptyBuilder() builder.addEntity(ModifiableSecondSampleEntity::class.java, SampleEntitySource("test")) { thief.set(this) intProperty = 10 } thief.get().intProperty = 30 } @Test(expected = IllegalStateException::class) fun `test trying to modify non-existing entity`() { val builder = createEmptyBuilder() val sampleEntity = builder.addSampleEntity("Prop") val anotherBuilder = createEmptyBuilder() anotherBuilder.modifyEntity(ModifiableSampleEntity::class.java, sampleEntity) { this.stringProperty = "Another prop" } } }
platform/workspaceModel/storage/tests/testSrc/com/intellij/workspaceModel/storage/SimplePropertiesInStorageTest.kt
2434472370
// IS_APPLICABLE: false class A { fun foo() {} } fun test() { val a = A() a.foo() <caret>1 + 1 a.foo() }
plugins/kotlin/idea/tests/testData/intentions/convertToScope/convertToApply/binaryExpression5.kt
2943539495
package testing open class C { open fun <caret>f() { } } class A : C() class B : C() { override fun f() { } } // REF: (in testing.B).f()
plugins/kotlin/idea/tests/testData/navigation/implementations/FakeOverride.kt
1012747083
/* * Copyright (C) 2017 - 2018 Mitchell Skaggs, Keturah Gadson, Ethan Holtgrieve, Nathan Skelton, Pattonville School District * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.pattonvillecs.pattonvilleapp.view.ui.directory.detail.single import android.content.Context import android.content.Intent import android.os.Bundle import android.support.v7.widget.SearchView import android.text.InputType import android.util.Log import android.view.Menu import android.view.View import android.view.inputmethod.EditorInfo import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.common.FlexibleItemDecoration import eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager import kotlinx.android.synthetic.main.activity_directory_single_datasource_detail.* import org.jetbrains.anko.appcompat.v7.coroutines.onQueryTextListener import org.pattonvillecs.pattonvilleapp.R import org.pattonvillecs.pattonvilleapp.service.model.DataSource import org.pattonvillecs.pattonvilleapp.view.adapter.directory.FacultyAdapter import org.pattonvillecs.pattonvilleapp.view.ui.directory.detail.AbstractDirectoryDetailActivity import org.pattonvillecs.pattonvilleapp.viewmodel.directory.detail.single.SingleDataSourceDirectoryDetailActivityViewModel import org.pattonvillecs.pattonvilleapp.viewmodel.getViewModel /** * Created by Mitchell Skaggs on 12/10/2017. */ class SingleDataSourceDirectoryDetailActivity : AbstractDirectoryDetailActivity() { lateinit var viewModel: SingleDataSourceDirectoryDetailActivityViewModel override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_directory_single_datasource_detail) viewModel = getViewModel() viewModel.setDataSource(intent.getSerializableExtra("datasource") as DataSource) viewModel.directoryRepository = directoryRepository viewModel.title.observe(this::getLifecycle) { title = it } val facultyAdapter = FacultyAdapter(stableIds = true) faculty_recyclerview.adapter = facultyAdapter faculty_recyclerview.layoutManager = SmoothScrollLinearLayoutManager(this) faculty_recyclerview.addItemDecoration( FlexibleItemDecoration(this) .withDefaultDivider() .withDrawDividerOnLastItem(true)) fast_scroller.setViewsToUse( R.layout.small_fast_scroller_layout, R.id.fast_scroller_bubble, R.id.fast_scroller_handle) facultyAdapter.fastScroller = fast_scroller viewModel.facultyItems.observe(this::getLifecycle) { Log.i(TAG, "Visible from update!") progress_bar.visibility = View.VISIBLE facultyAdapter.updateDataSet(it) facultyAdapter.filterItems(100L) } viewModel.searchText.observe(this::getLifecycle) { facultyAdapter.setFilter(it.orEmpty()) if (facultyAdapter.hasFilter()) { Log.i(TAG, "Visible from search with text $it!") progress_bar.visibility = View.VISIBLE } facultyAdapter.filterItems(100L) } facultyAdapter.addListener(FlexibleAdapter.OnUpdateListener { Log.i(TAG, "Count=$it") progress_bar.visibility = View.GONE Log.i(TAG, "Gone!") }) } override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.search_icon_menu, menu) initSearchView(menu) return true } /** * Method to setup the search functionality of the list * * @param menu Menu object of current options menu */ private fun initSearchView(menu: Menu) { val searchItem = menu.findItem(R.id.menu_search) if (searchItem != null) { val searchView = searchItem.actionView as SearchView searchView.inputType = InputType.TYPE_TEXT_VARIATION_FILTER searchView.imeOptions = EditorInfo.IME_ACTION_DONE or EditorInfo.IME_FLAG_NO_FULLSCREEN searchView.queryHint = getString(R.string.action_search) searchView.onQueryTextListener { onQueryTextChange { viewModel.setSearchText(it) true } } } } companion object { const val TAG: String = "SingleDataSourceDirecto" fun createIntent(context: Context, dataSource: DataSource): Intent = Intent(context, SingleDataSourceDirectoryDetailActivity::class.java).putExtra("datasource", dataSource) } }
app/src/main/java/org/pattonvillecs/pattonvilleapp/view/ui/directory/detail/single/SingleDataSourceDirectoryDetailActivity.kt
632874736
package com.cout970.modeler.controller.usecases import com.cout970.modeler.api.model.IModel import com.cout970.modeler.api.model.material.IMaterial import com.cout970.modeler.api.model.material.IMaterialRef import com.cout970.modeler.api.model.selection.SelectionTarget import com.cout970.modeler.api.model.selection.SelectionType import com.cout970.modeler.controller.tasks.* import com.cout970.modeler.core.config.colorToHex import com.cout970.modeler.core.model.material.ColoredMaterial import com.cout970.modeler.core.model.material.MaterialNone import com.cout970.modeler.core.model.material.MaterialRefNone import com.cout970.modeler.core.model.material.TexturedMaterial import com.cout970.modeler.core.model.objects import com.cout970.modeler.core.model.selection.Selection import com.cout970.modeler.core.project.IProgramState import com.cout970.modeler.core.project.ProjectManager import com.cout970.modeler.gui.GuiState import com.cout970.modeler.input.dialogs.FileDialogs import com.cout970.modeler.input.dialogs.MessageDialogs import com.cout970.modeler.util.asNullable import com.cout970.modeler.util.getOr import com.cout970.modeler.util.toResourcePath import com.cout970.vector.extensions.vec3Of import org.liquidengine.legui.component.Component import java.awt.Color import java.io.File /** * Created by cout970 on 2017/07/20. */ @UseCase("material.view.apply") private fun applyMaterial(component: Component, programState: IProgramState): ITask { val model = programState.model programState.modelSelection.ifNotNull { selection -> component.asNullable() .map { it.metadata["ref"] } .flatMap { it as? IMaterialRef } .map { ref -> val newModel = model.modifyObjects(selection.objects.toSet()) { _, obj -> obj.withMaterial(ref) } return TaskUpdateModel(oldModel = model, newModel = newModel) } } return TaskNone } @UseCase("material.view.load") private fun loadMaterial(component: Component, projectManager: ProjectManager): ITask { val ref = component.metadata["ref"] ?: return TaskNone val materialRef = ref as? IMaterialRef ?: return TaskNone return if (materialRef == MaterialRefNone) { importMaterial() } else { showLoadMaterialMenu(materialRef, projectManager) } } private fun showLoadMaterialMenu(ref: IMaterialRef, projectManager: ProjectManager): ITask = TaskAsync { returnFunc -> val path = FileDialogs.openFile( title = "Import Texture", description = "PNG texture (*.png)", filters = listOf("*.png") ) if (path != null) { val archive = File(path) val material = TexturedMaterial(archive.nameWithoutExtension, archive.toResourcePath(), ref.materialId) returnFunc(TaskUpdateMaterial( oldMaterial = projectManager.loadedMaterials[ref]!!, newMaterial = material )) } } @UseCase("material.view.import") private fun importMaterial(): ITask = TaskAsync { returnFunc -> val file = FileDialogs.openFile( title = "Import Texture", description = "PNG texture (*.png)", filters = listOf("*.png") ) if (file != null) { val archive = File(file) val material = TexturedMaterial(archive.nameWithoutExtension, archive.toResourcePath()) returnFunc(TaskImportMaterial(material)) } } @UseCase("material.new.colored") private fun newColoredMaterial(): ITask = TaskAsync { returnFunc -> val c = Color.getHSBColor(Math.random().toFloat(), 0.5f, 1.0f) val color = vec3Of(c.red / 255f, c.green / 255f, c.blue / 255f) val name = "Color #${colorToHex(color)}" returnFunc(TaskImportMaterial(ColoredMaterial(name, color))) } @UseCase("material.view.select") private fun selectMaterial(component: Component): ITask { return component.asNullable() .map { it.metadata["ref"] } .flatMap { it as? IMaterialRef } .map { TaskUpdateMaterialSelection(it) as ITask } .getOr(TaskNone) } @UseCase("material.view.duplicate") private fun duplicateMaterial(component: Component, access: IProgramState): ITask { return component.asNullable() .flatMap { it.metadata["ref"] } .flatMap { it as? IMaterialRef } .map { access.model.getMaterial(it) } .filterIsInstance<TexturedMaterial>() .map { TaskImportMaterial(it.copy(name = "${it.name} copy")) as ITask } .getOr(TaskNone) } @UseCase("material.view.remove") private fun removeMaterial(guiState: GuiState, projectManager: ProjectManager): ITask { val matRef = guiState.selectedMaterial val model = projectManager.model val material = model.getMaterial(matRef) if (material == MaterialNone) return TaskNone val used = model.objects.any { it.material == matRef } if (used) { //ask return TaskAsync { returnFunc -> val result = MessageDialogs.warningBoolean( title = "Remove material", message = "Are you sure you want to remove this material?", default = false ) if (result) { returnFunc(removeMaterialTask(model, matRef, material)) } } } return removeMaterialTask(model, matRef, material) } private fun removeMaterialTask(model: IModel, ref: IMaterialRef, material: IMaterial): ITask { val newModel = model.modifyObjects({ true }) { _, obj -> if (obj.material == ref) obj.withMaterial(MaterialRefNone) else obj } return TaskChain(listOf( TaskUpdateModel(oldModel = model, newModel = newModel), TaskRemoveMaterial(ref, material) )) } @UseCase("material.view.inverse_select") private fun selectByMaterial(guiState: GuiState, programState: IProgramState): ITask { val matRef = guiState.selectedMaterial val model = programState.model val objs = model.objectMap.entries .filter { it.value.material == matRef } .map { it.key } return TaskUpdateModelSelection( newSelection = Selection(SelectionTarget.MODEL, SelectionType.OBJECT, objs).asNullable(), oldSelection = programState.modelSelection ) }
src/main/kotlin/com/cout970/modeler/controller/usecases/MaterialList.kt
3607777684
@JvmOverloads fun <caret>foo(a: Int, b: Int, c: Int = 1, d: Int = 2) { } fun test() { foo(a = 1, b = 2, c = 3, d = 4) foo(a = 1, b = 2, c = 3) foo(b = 1, c = 2, a = 3) foo(a = 1, b = 2) foo(b = 1, a = 2) }
plugins/kotlin/idea/tests/testData/refactoring/changeSignature/JvmOverloadedRenameParameterBefore.kt
587472021
package com.telerik.metadata.security.filtering import com.telerik.metadata.security.filtering.input.PatternEntry import java.util.* data class MetadataFilterResult(val isAllowed: Boolean, val matchedPatternEntry: Optional<PatternEntry> = Optional.empty())
test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/security/filtering/MetadataFilterResult.kt
2495291531
// Copyright 2000-2019 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.openapi.externalSystem.autoimport import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.externalSystem.autoimport.ProjectStatus.ModificationType.INTERNAL import com.intellij.openapi.externalSystem.autoimport.ProjectStatus.ProjectEvent.* import com.intellij.openapi.externalSystem.autoimport.ProjectStatus.ProjectState.* import java.util.concurrent.atomic.AtomicReference import kotlin.math.max class ProjectStatus(private val debugName: String? = null) { private val LOG = Logger.getInstance("#com.intellij.openapi.externalSystem.autoimport") private var state = AtomicReference(Synchronized(-1) as ProjectState) fun isDirty() = state.get() is Dirty fun isUpToDate() = when (state.get()) { is Modified, is Dirty -> false is Synchronized, is Reverted -> true } fun getModificationType() = when (val state = state.get()) { is Dirty -> state.type is Modified -> state.type is Synchronized, is Reverted -> null } fun markDirty(stamp: Long, type: ModificationType = INTERNAL): ProjectState { return update(Invalidate(stamp, type)) } fun markModified(stamp: Long, type: ModificationType = INTERNAL): ProjectState { return update(Modify(stamp, type)) } fun markReverted(stamp: Long): ProjectState { return update(Revert(stamp)) } fun markSynchronized(stamp: Long): ProjectState { return update(Synchronize(stamp)) } fun update(event: ProjectEvent): ProjectState { if (LOG.isDebugEnabled) { val debugPrefix = if (debugName == null) "" else "$debugName: " val eventName = event::class.simpleName val state = state.get() val stateName = state::class.java.simpleName LOG.debug("${debugPrefix}Event $eventName is happened at ${event.stamp}. Current state $stateName is changed at ${state.stamp}") } val newState = state.updateAndGet { currentState -> when (currentState) { is Synchronized -> when (event) { is Synchronize -> event.withFuture(currentState, ::Synchronized) is Invalidate -> event.ifFuture(currentState) { Dirty(it, event.type) } is Modify -> event.ifFuture(currentState) { Modified(it, event.type) } is Revert -> event.ifFuture(currentState, ::Reverted) } is Dirty -> when (event) { is Synchronize -> event.ifFuture(currentState, ::Synchronized) is Invalidate -> event.withFuture(currentState) { Dirty(it, currentState.type.merge(event.type)) } is Modify -> event.withFuture(currentState) { Dirty(it, currentState.type.merge(event.type)) } is Revert -> event.withFuture(currentState) { Dirty(it, currentState.type) } } is Modified -> when (event) { is Synchronize -> event.ifFuture(currentState, ::Synchronized) is Invalidate -> event.withFuture(currentState) { Dirty(it, currentState.type.merge(event.type)) } is Modify -> event.withFuture(currentState) { Modified(it, currentState.type.merge(event.type)) } is Revert -> event.ifFuture(currentState, ::Reverted) } is Reverted -> when (event) { is Synchronize -> event.ifFuture(currentState, ::Synchronized) is Invalidate -> event.withFuture(currentState) { Dirty(it, event.type) } is Modify -> event.ifFuture(currentState) { Modified(it, event.type) } is Revert -> event.withFuture(currentState, ::Reverted) } } } if (LOG.isDebugEnabled) { val debugPrefix = if (debugName == null) "" else "$debugName: " val eventName = event::class.simpleName val state = state.get() val stateName = state::class.java.simpleName LOG.debug("${debugPrefix}State is $stateName at ${state.stamp} after event $eventName that happen at ${event.stamp}.") } return newState } private fun ProjectEvent.withFuture(state: ProjectState, action: (Long) -> ProjectState): ProjectState { return action(max(stamp, state.stamp)) } private fun ProjectEvent.ifFuture(state: ProjectState, action: (Long) -> ProjectState): ProjectState { return if (stamp > state.stamp) action(stamp) else state } enum class ModificationType { EXTERNAL, INTERNAL; fun merge(other: ModificationType): ModificationType { return when (this) { INTERNAL -> INTERNAL EXTERNAL -> other } } } sealed class ProjectEvent(val stamp: Long) { class Synchronize(stamp: Long) : ProjectEvent(stamp) class Invalidate(stamp: Long, val type: ModificationType) : ProjectEvent(stamp) class Modify(stamp: Long, val type: ModificationType) : ProjectEvent(stamp) class Revert(stamp: Long) : ProjectEvent(stamp) } sealed class ProjectState(val stamp: Long) { class Synchronized(stamp: Long) : ProjectState(stamp) class Dirty(stamp: Long, val type: ModificationType) : ProjectState(stamp) class Modified(stamp: Long, val type: ModificationType) : ProjectState(stamp) class Reverted(stamp: Long) : ProjectState(stamp) } }
platform/external-system-impl/src/com/intellij/openapi/externalSystem/autoimport/ProjectStatus.kt
2315661799
package com.zeke.network.interceptor import android.text.TextUtils import okhttp3.* import okio.Buffer import java.io.IOException /** * author:ZekeWang * date:2021/6/5 * description: * 公共接口参数网络配置拦截器 * 支持Params和Header全局添加 * 使用Builder模式(Kotlin) */ @Suppress("unused") class CommonParamsInterceptor private constructor() : Interceptor { // 添加到 URL 末尾,Get Post 方法都使用 var queryParamsMap: HashMap<String, String> = HashMap() // 添加到公共参数到消息体,适用 Post 请求 var postParamsMap: HashMap<String, String> = HashMap() // 公共 Headers 添加 var headerParamsMap: HashMap<String, String> = HashMap() // 消息头 集合形式,一次添加一行 var headerLinesList: MutableList<String> = ArrayList() override fun intercept(chain: Interceptor.Chain): Response { var request: Request = chain.request() val requestBuilder = request.newBuilder() val headerBuilder: Headers.Builder = request.headers().newBuilder() injectHeaderParams(headerBuilder, requestBuilder) injectQueryParmas(request, requestBuilder) injectPostBodyParmas(request, requestBuilder) request = requestBuilder.build() return chain.proceed(request) } /** * Post模式下添加Body参数 */ private fun injectPostBodyParmas(request: Request, requestBuilder: Request.Builder) { if (postParamsMap.isNotEmpty()) { if (canInjectIntoBody(request)) { val formBodyBuilder = FormBody.Builder() for ((key, value) in postParamsMap) { formBodyBuilder.add(key, value) } val formBody: RequestBody = formBodyBuilder.build() var postBodyString: String = bodyToString(request.body()) val prefex = if (postBodyString.isNotEmpty()) "&" else "" postBodyString += prefex + bodyToString(formBody) requestBuilder.post( RequestBody.create( MediaType.parse("application/x-www-form-urlencoded;charset=UTF-8"), postBodyString ) ) } } } /** * 添加消息头 */ private fun injectHeaderParams( headerBuilder: Headers.Builder, requestBuilder: Request.Builder ) { // 以 Entry 添加消息头 if (headerParamsMap.isNotEmpty()) { val iterator: Iterator<*> = headerParamsMap.entries.iterator() while (iterator.hasNext()) { val entry = iterator.next() as Map.Entry<*, *> headerBuilder.add(entry.key as String, entry.value as String) } requestBuilder.headers(headerBuilder.build()) } // 以 String 形式添加消息头 if (headerLinesList.isNotEmpty()) { for (line in headerLinesList) { headerBuilder.add(line) } requestBuilder.headers(headerBuilder.build()) } } //添加查询参数 Get|Post private fun injectQueryParmas(request: Request?, requestBuilder: Request.Builder) { if (queryParamsMap.isNotEmpty()) { injectParamsIntoUrl( request!!.url().newBuilder(), requestBuilder, queryParamsMap ) } } /** * 注入公共参数到Url中,储存在requestBuilder中 */ private fun injectParamsIntoUrl( httpUrlBuilder: HttpUrl.Builder, requestBuilder: Request.Builder, paramsMap: Map<String, String> ){ if (paramsMap.isNotEmpty()) { val iterator: Iterator<*> = paramsMap.entries.iterator() while (iterator.hasNext()) { val entry = iterator.next() as Map.Entry<*, *> httpUrlBuilder.addQueryParameter( entry.key as String, entry.value as String ) } requestBuilder.url(httpUrlBuilder.build()) } } /** * 确认是否是 post 请求 * @param request 发出的请求 * @return true 需要注入公共参数 */ private fun canInjectIntoBody(request: Request?): Boolean { if (request == null) { return false } if (!TextUtils.equals(request.method(), "POST")) { return false } val body = request.body() ?: return false val mediaType = body.contentType() ?: return false return TextUtils.equals(mediaType.subtype(), "x-www-form-urlencoded") } private fun bodyToString(request: RequestBody?): String { return try { val buffer = Buffer() request?.writeTo(buffer) buffer.readUtf8() } catch (e: IOException) { "did not work" } } // <editor-fold defaultstate="collapsed" desc="对外提供的Builder构造器"> class Builder { private var interceptor: CommonParamsInterceptor = CommonParamsInterceptor() // <editor-fold defaultstate="collapsed" desc="添加公共参数到 post 消息体"> fun addPostParam(key: String, value: String): Builder { interceptor.postParamsMap[key] = value return this } fun addPostParamsMap(paramsMap: Map<String, String>): Builder { interceptor.postParamsMap.putAll(paramsMap) return this } // </editor-fold> // <editor-fold defaultstate="collapsed" desc="添加公共参数到消息头"> fun addHeaderParam(key: String?,value: String?): Builder { interceptor.headerParamsMap[key!!] = value!! return this } fun addHeaderParamsMap(headerParamsMap: Map<String, String>) : Builder { interceptor.headerParamsMap.putAll(headerParamsMap) return this } fun addHeaderLine(headerLine: String): Builder { val index = headerLine.indexOf(":") require(index != -1) { "Unexpected header: $headerLine" } interceptor.headerLinesList.add(headerLine) return this } fun addHeaderLinesList(headerLinesList: List<String>): Builder { for (headerLine in headerLinesList) { val index = headerLine.indexOf(":") require(index != -1) { "Unexpected header: $headerLine" } interceptor.headerLinesList.add(headerLine) } return this } // </editor-fold> // <editor-fold defaultstate="collapsed" desc="添加公共参数到URL"> fun addQueryParam(key: String, value: String): Builder { interceptor.queryParamsMap[key] = value return this } fun addQueryParamsMap( queryParamsMap: Map<String, String>): Builder { interceptor.queryParamsMap.putAll(queryParamsMap) return this } // </editor-fold> fun build(): CommonParamsInterceptor { return interceptor } } // </editor-fold> }
library/network/src/main/java/com/zeke/network/interceptor/CommonParamsInterceptor.kt
2999915664
// WITH_RUNTIME // INTENTION_TEXT: "Replace with 'filter{}.map{}'" // INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.map{}.toList()'" import java.util.ArrayList fun foo(list: List<String>): List<Int> { val result = ArrayList<Int>() <caret>for (s in list) { if (s.length > 0) { val h = s.hashCode() result.add(h) } } return result }
plugins/kotlin/idea/tests/testData/intentions/loopToCallChain/map/assignMap2.kt
3460588771
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.kotlin.idea.stubindex import com.intellij.openapi.project.Project import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.stubs.StringStubIndexExtension import com.intellij.psi.stubs.StubIndex import com.intellij.psi.stubs.StubIndexKey import org.jetbrains.kotlin.psi.KtTypeAlias class KotlinTopLevelTypeAliasFqNameIndex : StringStubIndexExtension<KtTypeAlias>() { override fun getKey(): StubIndexKey<String, KtTypeAlias> = KEY override fun get(s: String, project: Project, scope: GlobalSearchScope): Collection<KtTypeAlias> = StubIndex.getElements<String, KtTypeAlias>( KEY, s, project, scope, KtTypeAlias::class.java ) companion object { val KEY = KotlinIndexUtil.createIndexKey(KotlinTopLevelTypeAliasFqNameIndex::class.java) val INSTANCE = KotlinTopLevelTypeAliasFqNameIndex() @JvmStatic fun getInstance() = INSTANCE } }
plugins/kotlin/analysis/src/org/jetbrains/kotlin/idea/stubindex/KotlinTopLevelTypeAliasFqNameIndex.kt
258982355
// Copyright 2000-2021 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.codeInspection.apiUsage import com.intellij.lang.java.JavaLanguage import com.intellij.psi.* import com.intellij.psi.util.PsiTreeUtil import com.intellij.psi.util.PsiUtil import com.intellij.uast.UastVisitorAdapter import org.jetbrains.annotations.ApiStatus import org.jetbrains.uast.* import org.jetbrains.uast.visitor.AbstractUastNonRecursiveVisitor /** * Non-recursive UAST visitor that detects usages of APIs in source code of UAST-supporting languages * and reports them via [ApiUsageProcessor] interface. */ @ApiStatus.Experimental open class ApiUsageUastVisitor(private val apiUsageProcessor: ApiUsageProcessor) : AbstractUastNonRecursiveVisitor() { companion object { @JvmStatic fun createPsiElementVisitor(apiUsageProcessor: ApiUsageProcessor): PsiElementVisitor = UastVisitorAdapter(ApiUsageUastVisitor(apiUsageProcessor), true) } override fun visitSimpleNameReferenceExpression(node: USimpleNameReferenceExpression): Boolean { if (maybeProcessReferenceInsideImportStatement(node)) { return true } if (maybeProcessJavaModuleReference(node)) { return true } if (isMethodReferenceOfCallExpression(node) || isNewArrayClassReference(node) || isMethodReferenceOfCallableReferenceExpression(node) || isSelectorOfQualifiedReference(node) ) { return true } if (isSuperOrThisCall(node)) { return true } val resolved = node.resolve() if (resolved is PsiMethod) { if (isClassReferenceInConstructorInvocation(node) || isClassReferenceInKotlinSuperClassConstructor(node)) { /* Suppose a code: ``` object : SomeClass(42) { } or new SomeClass(42) ``` with USimpleNameReferenceExpression pointing to `SomeClass`. We want ApiUsageProcessor to notice two events: 1) reference to `SomeClass` and 2) reference to `SomeClass(int)` constructor. But Kotlin UAST resolves this simple reference to the PSI constructor of the class SomeClass. So we resolve it manually to the class because the constructor will be handled separately in "visitObjectLiteralExpression" or "visitCallExpression". */ val resolvedClass = resolved.containingClass if (resolvedClass != null) { apiUsageProcessor.processReference(node, resolvedClass, null) } return true } } if (resolved is PsiModifierListOwner) { apiUsageProcessor.processReference(node, resolved, null) return true } if (resolved == null) { /* * KT-30522 UAST for Kotlin: reference to annotation parameter resolves to null. */ val psiReferences = node.sourcePsi?.references.orEmpty() for (psiReference in psiReferences) { val target = psiReference.resolve()?.toUElement()?.javaPsi as? PsiAnnotationMethod if (target != null) { apiUsageProcessor.processReference(node, target, null) return true } } } return true } override fun visitQualifiedReferenceExpression(node: UQualifiedReferenceExpression): Boolean { if (maybeProcessReferenceInsideImportStatement(node)) { return true } if (node.sourcePsi is PsiMethodCallExpression || node.selector is UCallExpression) { //UAST for Java produces UQualifiedReferenceExpression for both PsiMethodCallExpression and PsiReferenceExpression inside it //UAST for Kotlin produces UQualifiedReferenceExpression with UCallExpression as selector return true } var resolved = node.resolve() if (resolved == null) { resolved = node.selector.tryResolve() } if (resolved is PsiModifierListOwner) { apiUsageProcessor.processReference(node.selector, resolved, node.receiver) } return true } private fun isKotlin(node: UElement): Boolean { val sourcePsi = node.sourcePsi ?: return false return sourcePsi.language.id.contains("kotlin", true) } override fun visitCallableReferenceExpression(node: UCallableReferenceExpression): Boolean { /* * KT-31181: Kotlin UAST: UCallableReferenceExpression.referenceNameElement is always null. */ fun workaroundKotlinGetReferenceNameElement(node: UCallableReferenceExpression): UElement? { if (isKotlin(node)) { val sourcePsi = node.sourcePsi if (sourcePsi != null) { val children = sourcePsi.children if (children.size == 2) { return children[1].toUElement() } } } return null } val resolve = node.resolve() if (resolve is PsiModifierListOwner) { val sourceNode = node.referenceNameElement ?: workaroundKotlinGetReferenceNameElement(node) ?: node apiUsageProcessor.processReference(sourceNode, resolve, node.qualifierExpression) //todo support this for other JVM languages val javaMethodReference = node.sourcePsi as? PsiMethodReferenceExpression if (javaMethodReference != null) { //a reference to the functional interface will be added by compiler val resolved = PsiUtil.resolveGenericsClassInType(javaMethodReference.functionalInterfaceType).element if (resolved != null) { apiUsageProcessor.processReference(node, resolved, null) } } } return true } override fun visitCallExpression(node: UCallExpression): Boolean { if (node.sourcePsi is PsiExpressionStatement) { //UAST for Java generates UCallExpression for PsiExpressionStatement and PsiMethodCallExpression inside it. return true } val psiMethod = node.resolve() val sourceNode = node.methodIdentifier ?: node.classReference?.referenceNameElement ?: node.classReference ?: node if (psiMethod != null) { val containingClass = psiMethod.containingClass if (psiMethod.isConstructor) { if (containingClass != null) { apiUsageProcessor.processConstructorInvocation(sourceNode, containingClass, psiMethod, null) } } else { apiUsageProcessor.processReference(sourceNode, psiMethod, node.receiver) } return true } if (node.kind == UastCallKind.CONSTRUCTOR_CALL) { //Java does not resolve constructor for subclass constructor's "super()" statement // if the superclass has the default constructor, which is not declared in source code and lacks PsiMethod. val superClass = node.getContainingUClass()?.javaPsi?.superClass ?: return true apiUsageProcessor.processConstructorInvocation(sourceNode, superClass, null, null) return true } val classReference = node.classReference if (classReference != null) { val resolvedClass = classReference.resolve() as? PsiClass if (resolvedClass != null) { if (node.kind == UastCallKind.CONSTRUCTOR_CALL) { val emptyConstructor = resolvedClass.constructors.find { it.parameterList.isEmpty } apiUsageProcessor.processConstructorInvocation(sourceNode, resolvedClass, emptyConstructor, null) } else { apiUsageProcessor.processReference(sourceNode, resolvedClass, node.receiver) } } return true } return true } override fun visitObjectLiteralExpression(node: UObjectLiteralExpression): Boolean { val psiMethod = node.resolve() val sourceNode = node.methodIdentifier ?: node.classReference?.referenceNameElement ?: node.classReference ?: node.declaration.uastSuperTypes.firstOrNull() ?: node if (psiMethod != null) { val containingClass = psiMethod.containingClass if (psiMethod.isConstructor) { if (containingClass != null) { apiUsageProcessor.processConstructorInvocation(sourceNode, containingClass, psiMethod, node.declaration) } } } else { maybeProcessImplicitConstructorInvocationAtSubclassDeclaration(sourceNode, node.declaration) } return true } override fun visitElement(node: UElement): Boolean { if (node is UNamedExpression) { //IDEA-209279: UAstVisitor lacks a hook for UNamedExpression //KT-30522: Kotlin does not generate UNamedExpression for annotation's parameters. processNamedExpression(node) return true } return super.visitElement(node) } override fun visitClass(node: UClass): Boolean { val uastAnchor = node.uastAnchor if (uastAnchor == null || node is UAnonymousClass || node.javaPsi is PsiTypeParameter) { return true } maybeProcessImplicitConstructorInvocationAtSubclassDeclaration(uastAnchor, node) return true } override fun visitMethod(node: UMethod): Boolean { if (node.isConstructor) { checkImplicitCallOfSuperEmptyConstructor(node) } else { checkMethodOverriding(node) } return true } override fun visitLambdaExpression(node: ULambdaExpression): Boolean { val explicitClassReference = (node.uastParent as? UCallExpression)?.classReference if (explicitClassReference == null) { //a reference to the functional interface will be added by compiler val resolved = PsiUtil.resolveGenericsClassInType(node.functionalInterfaceType).element if (resolved != null) { apiUsageProcessor.processReference(node, resolved, null) } } return true } private fun maybeProcessJavaModuleReference(node: UElement): Boolean { val sourcePsi = node.sourcePsi if (sourcePsi is PsiJavaModuleReferenceElement) { val reference = sourcePsi.reference val target = reference?.resolve() if (target != null) { apiUsageProcessor.processJavaModuleReference(reference, target) } return true } return false } private fun maybeProcessReferenceInsideImportStatement(node: UReferenceExpression): Boolean { if (isInsideImportStatement(node)) { if (isKotlin(node)) { /* UAST for Kotlin 1.3.30 import statements have bugs. KT-30546: some references resolve to nulls. KT-30957: simple references for members resolve incorrectly to class declaration, not to the member declaration Therefore, we have to fallback to base PSI for Kotlin references. */ val resolved = node.sourcePsi?.reference?.resolve() val target = (resolved?.toUElement()?.javaPsi ?: resolved) as? PsiModifierListOwner if (target != null) { apiUsageProcessor.processImportReference(node, target) } } else { val resolved = node.resolve() as? PsiModifierListOwner if (resolved != null) { apiUsageProcessor.processImportReference(node.referenceNameElement ?: node, resolved) } } return true } return false } private fun isInsideImportStatement(node: UElement): Boolean { val sourcePsi = node.sourcePsi if (sourcePsi != null && sourcePsi.language == JavaLanguage.INSTANCE) { return PsiTreeUtil.getParentOfType(sourcePsi, PsiImportStatementBase::class.java) != null } return sourcePsi.findContaining(UImportStatement::class.java) != null } private fun maybeProcessImplicitConstructorInvocationAtSubclassDeclaration(sourceNode: UElement, subclassDeclaration: UClass) { val instantiatedClass = subclassDeclaration.javaPsi.superClass ?: return val subclassHasExplicitConstructor = subclassDeclaration.methods.any { it.isConstructor } val emptyConstructor = instantiatedClass.constructors.find { it.parameterList.isEmpty } if (subclassDeclaration is UAnonymousClass || !subclassHasExplicitConstructor) { apiUsageProcessor.processConstructorInvocation(sourceNode, instantiatedClass, emptyConstructor, subclassDeclaration) } } private fun processNamedExpression(node: UNamedExpression) { val sourcePsi = node.sourcePsi val annotationMethod = sourcePsi?.reference?.resolve() as? PsiAnnotationMethod if (annotationMethod != null) { val sourceNode = (sourcePsi as? PsiNameValuePair)?.nameIdentifier?.toUElement() ?: node apiUsageProcessor.processReference(sourceNode, annotationMethod, null) } } private fun checkImplicitCallOfSuperEmptyConstructor(constructor: UMethod) { val containingUClass = constructor.getContainingUClass() ?: return val superClass = containingUClass.javaPsi.superClass ?: return val uastBody = constructor.uastBody val uastAnchor = constructor.uastAnchor if (uastAnchor != null && isImplicitCallOfSuperEmptyConstructorFromSubclassConstructorBody(uastBody)) { val emptyConstructor = superClass.constructors.find { it.parameterList.isEmpty } apiUsageProcessor.processConstructorInvocation(uastAnchor, superClass, emptyConstructor, null) } } private fun isImplicitCallOfSuperEmptyConstructorFromSubclassConstructorBody(constructorBody: UExpression?): Boolean { if (constructorBody == null || constructorBody is UBlockExpression && constructorBody.expressions.isEmpty()) { //Empty constructor body => implicit super() call. return true } val firstExpression = (constructorBody as? UBlockExpression)?.expressions?.firstOrNull() ?: constructorBody if (firstExpression !is UCallExpression) { //First expression is not super() => the super() is implicit. return true } if (firstExpression.valueArgumentCount > 0) { //Invocation of non-empty super(args) constructor. return false } val methodName = firstExpression.methodIdentifier?.name ?: firstExpression.methodName return methodName != "super" && methodName != "this" } private fun checkMethodOverriding(node: UMethod) { val method = node.javaPsi val superMethods = method.findSuperMethods(true) for (superMethod in superMethods) { apiUsageProcessor.processMethodOverriding(node, superMethod) } } /** * UAST for Kotlin generates UAST tree with "UnknownKotlinExpression (CONSTRUCTOR_CALLEE)" for the following expressions: * 1) an object literal expression: `object : BaseClass() { ... }` * 2) a super class constructor invocation `class Derived : BaseClass(42) { ... }` * * * ``` * UObjectLiteralExpression * UnknownKotlinExpression (CONSTRUCTOR_CALLEE) * UTypeReferenceExpression (BaseClass) * USimpleNameReferenceExpression (BaseClass) * ``` * * and * * ``` * UCallExpression (kind = CONSTRUCTOR_CALL) * UnknownKotlinExpression (CONSTRUCTOR_CALLEE) * UTypeReferenceExpression (BaseClass) * USimpleNameReferenceExpression (BaseClass) * ``` * * This method checks if the given simple reference points to the `BaseClass` part, * which is treated by Kotlin UAST as a reference to `BaseClass'` constructor, not to the `BaseClass` itself. */ private fun isClassReferenceInKotlinSuperClassConstructor(expression: USimpleNameReferenceExpression): Boolean { val parent1 = expression.uastParent val parent2 = parent1?.uastParent val parent3 = parent2?.uastParent return parent1 is UTypeReferenceExpression && parent2 != null && parent2.asLogString().contains("CONSTRUCTOR_CALLEE") && (parent3 is UObjectLiteralExpression || parent3 is UCallExpression && parent3.kind == UastCallKind.CONSTRUCTOR_CALL) } private fun isSelectorOfQualifiedReference(expression: USimpleNameReferenceExpression): Boolean { val qualifiedReference = expression.uastParent as? UQualifiedReferenceExpression ?: return false return haveSameSourceElement(expression, qualifiedReference.selector) } private fun isNewArrayClassReference(simpleReference: USimpleNameReferenceExpression): Boolean { val callExpression = simpleReference.uastParent as? UCallExpression ?: return false return callExpression.kind == UastCallKind.NEW_ARRAY_WITH_DIMENSIONS } private fun isSuperOrThisCall(simpleReference: USimpleNameReferenceExpression): Boolean { val callExpression = simpleReference.uastParent as? UCallExpression ?: return false return callExpression.kind == UastCallKind.CONSTRUCTOR_CALL && (callExpression.methodIdentifier?.name == "super" || callExpression.methodIdentifier?.name == "this") } private fun isClassReferenceInConstructorInvocation(simpleReference: USimpleNameReferenceExpression): Boolean { if (isSuperOrThisCall(simpleReference)) { return false } val callExpression = simpleReference.uastParent as? UCallExpression ?: return false if (callExpression.kind != UastCallKind.CONSTRUCTOR_CALL) { return false } val classReferenceNameElement = callExpression.classReference?.referenceNameElement if (classReferenceNameElement != null) { return haveSameSourceElement(classReferenceNameElement, simpleReference.referenceNameElement) } return callExpression.resolve()?.name == simpleReference.resolvedName } private fun isMethodReferenceOfCallExpression(expression: USimpleNameReferenceExpression): Boolean { val callExpression = expression.uastParent as? UCallExpression ?: return false if (callExpression.kind != UastCallKind.METHOD_CALL) { return false } val expressionNameElement = expression.referenceNameElement val methodIdentifier = callExpression.methodIdentifier return methodIdentifier != null && haveSameSourceElement(expressionNameElement, methodIdentifier) } private fun isMethodReferenceOfCallableReferenceExpression(expression: USimpleNameReferenceExpression): Boolean { val callableReferenceExpression = expression.uastParent as? UCallableReferenceExpression ?: return false if (haveSameSourceElement(callableReferenceExpression.referenceNameElement, expression)) { return true } return expression.identifier == callableReferenceExpression.callableName } private fun haveSameSourceElement(element1: UElement?, element2: UElement?): Boolean { if (element1 == null || element2 == null) return false val sourcePsi1 = element1.sourcePsi return sourcePsi1 != null && sourcePsi1 == element2.sourcePsi } }
java/java-analysis-impl/src/com/intellij/codeInspection/apiUsage/ApiUsageUastVisitor.kt
1227900216
package test fun dummyFunction() { }
plugins/kotlin/jps/jps-plugin/tests/testData/incremental/pureKotlin/suspendWithStateMachine/other.kt
2033280659
/* * Copyright 2021 Michael Rozumyanskiy * * 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 io.michaelrocks.grip import io.michaelrocks.grip.mirrors.FieldMirror import io.michaelrocks.mockito.given import io.michaelrocks.mockito.mock import org.junit.Test class FieldInitializerMatchersTest { private val stringValueField = mock<FieldMirror>().apply { given(value).thenReturn("String") } private val intValueField = mock<FieldMirror>().apply { given(value).thenReturn(42) } private val nullValueField = mock<FieldMirror>() @Test fun testWithFieldInitializerTrue() = stringValueField.testFieldInitializer(true) { withFieldInitializer { _, _ -> true } } @Test fun testWithFieldInitializerFalse() = stringValueField.testFieldInitializer(false) { withFieldInitializer { _, _ -> false } } @Test fun testWithFieldInitializerStringTrue() = stringValueField.testFieldInitializer(true) { withFieldInitializer<String>() } @Test fun testWithFieldInitializerStringFalse() = nullValueField.testFieldInitializer(false) { withFieldInitializer<String>() } @Test fun testWithFieldInitializerIntTrue() = intValueField.testFieldInitializer(true) { withFieldInitializer<Int>() } @Test fun testWithFieldInitializerIntFalse() = stringValueField.testFieldInitializer(false) { withFieldInitializer<Int>() } @Test fun testHasFieldInitializerTrue() = stringValueField.testFieldInitializer(true) { hasFieldInitializer() } @Test fun testHasFieldInitializerFalse() = nullValueField.testFieldInitializer(false) { hasFieldInitializer() } private inline fun FieldMirror.testFieldInitializer(condition: Boolean, body: () -> ((Grip, FieldMirror) -> Boolean)) = assertAndVerify(condition, body) { value } }
library/src/test/java/io/michaelrocks/grip/FieldInitializerMatchersTest.kt
879282923
val paramTest = 12 fun small(paramFirst: Int, paramSecond: Int) { } fun test() = small(param<caret>First = 12) // EXIST: "paramFirst =" // EXIST: "paramSecond =" // EXIST: paramTest // NOTHING_ELSE
plugins/kotlin/completion/tests/testData/basic/common/namedArguments/WithParameterExpression.kt
4112113989
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass import com.intellij.psi.util.findParentOfType import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.idea.caches.resolve.analyzeAndGetResult import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.TypeInfo import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypeAndBranch import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.calls.util.getResolvedCall import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeIntersector import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.utils.ifEmpty import java.util.* object CreateClassFromTypeReferenceActionFactory : CreateClassFromUsageFactory<KtUserType>() { override fun getElementOfInterest(diagnostic: Diagnostic): KtUserType? { return diagnostic.psiElement.findParentOfType(strict = false) } override fun getPossibleClassKinds(element: KtUserType, diagnostic: Diagnostic): List<ClassKind> { val typeRefParent = element.parent.parent if (typeRefParent is KtConstructorCalleeExpression) return Collections.emptyList() val isQualifier = (element.parent as? KtUserType)?.let { it.qualifier == element } ?: false val typeReference = element.parent as? KtTypeReference val isUpperBound = typeReference?.getParentOfTypeAndBranch<KtTypeParameter> { extendsBound } != null || typeReference?.getParentOfTypeAndBranch<KtTypeConstraint> { boundTypeReference } != null return when (typeRefParent) { is KtSuperTypeEntry -> listOfNotNull( ClassKind.INTERFACE, if (typeRefParent.classExpected()) ClassKind.PLAIN_CLASS else null ) else -> ClassKind.values().filter { val noTypeArguments = element.typeArgumentsAsTypes.isEmpty() when (it) { ClassKind.OBJECT -> noTypeArguments && isQualifier ClassKind.ANNOTATION_CLASS -> noTypeArguments && !isQualifier && !isUpperBound ClassKind.ENUM_ENTRY -> false ClassKind.ENUM_CLASS -> noTypeArguments && !isUpperBound else -> true } } } } private fun KtSuperTypeEntry.classExpected(): Boolean { val containingClass = getStrictParentOfType<KtClass>() ?: return false return !containingClass.hasModifier(KtTokens.ANNOTATION_KEYWORD) && !containingClass.hasModifier(KtTokens.ENUM_KEYWORD) && !containingClass.hasModifier(KtTokens.INLINE_KEYWORD) } private fun getExpectedUpperBound(element: KtUserType, context: BindingContext): KotlinType? { val projection = (element.parent as? KtTypeReference)?.parent as? KtTypeProjection ?: return null val argumentList = projection.parent as? KtTypeArgumentList ?: return null val index = argumentList.arguments.indexOf(projection) val callElement = argumentList.parent as? KtCallElement ?: return null val resolvedCall = callElement.getResolvedCall(context) ?: return null val typeParameterDescriptor = resolvedCall.candidateDescriptor.typeParameters.getOrNull(index) ?: return null if (typeParameterDescriptor.upperBounds.isEmpty()) return null return TypeIntersector.getUpperBoundsAsType(typeParameterDescriptor) } override fun extractFixData(element: KtUserType, diagnostic: Diagnostic): ClassInfo? { val name = element.referenceExpression?.getReferencedName() ?: return null val typeRefParent = element.parent.parent if (typeRefParent is KtConstructorCalleeExpression) return null val (context, module) = element.analyzeAndGetResult() val qualifier = element.qualifier?.referenceExpression val qualifierDescriptor = qualifier?.let { context[BindingContext.REFERENCE_TARGET, it] } val targetParents = getTargetParentsByQualifier(element, qualifier != null, qualifierDescriptor).ifEmpty { return null } val expectedUpperBound = getExpectedUpperBound(element, context) val anyType = module.builtIns.anyType return ClassInfo( name = name, targetParents = targetParents, expectedTypeInfo = expectedUpperBound?.let { TypeInfo.ByType(it, Variance.INVARIANT) } ?: TypeInfo.Empty, open = typeRefParent is KtSuperTypeEntry && typeRefParent.classExpected(), typeArguments = element.typeArgumentsAsTypes.map { if (it != null) TypeInfo(it, Variance.INVARIANT) else TypeInfo(anyType, Variance.INVARIANT) } ) } }
plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromTypeReferenceActionFactory.kt
1674559440
package org.penella.index.bstree import org.penella.index.IndexType import org.penella.messages.IndexResultSet import org.penella.structures.triples.HashTriple import org.penella.structures.triples.TripleType /** * 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. * * Created by alisle on 11/29/16. */ class SubjectPropertyObjectBSTreeIndex() : BSTreeIndex(IndexType.SPO) { override fun add(triple: HashTriple) = addTriple(triple.hashSubject, triple.hashProperty, triple.hashObj) override fun get(first: TripleType, second: TripleType, firstValue: Long, secondValue: Long) : IndexResultSet = if(first == TripleType.SUBJECT && second == TripleType.PROPERTY) getResults(firstValue, secondValue) else throw IncorrectIndexRequest() override fun get(first: TripleType, value: Long ) : IndexResultSet = if(first == TripleType.SUBJECT) getResults(value) else throw IncorrectIndexRequest() }
src/main/java/org/penella/index/bstree/SubjectPropertyObjectBSTreeIndex.kt
2352708788
package org.testb.java.altimeter.view interface BasePresenter { fun attachView() fun detachView() }
app/src/main/java/org/testb/java/altimeter/view/BasePresenter.kt
3654285146
package com.github.vhromada.catalog.facade import com.github.vhromada.catalog.common.entity.Page import com.github.vhromada.catalog.common.exception.InputException import com.github.vhromada.catalog.common.filter.PagingFilter import com.github.vhromada.catalog.entity.ChangeSeasonRequest import com.github.vhromada.catalog.entity.Season /** * An interface represents facade for seasons. * * @author Vladimir Hromada */ interface SeasonFacade { /** * Returns page of seasons by show's UUID and filter. * * @param show show's UUID * @param filter filter * @return page of seasons by show's UUID and filter * @throws InputException if show doesn't exist in data storage */ fun findAll(show: String, filter: PagingFilter): Page<Season> /** * Returns season. * * @param show show's UUID * @param uuid season's UUID * @return season * @throws InputException if show doesn't exist in data storage * or season doesn't exist in data storage */ fun get(show: String, uuid: String): Season /** * Adds season. * <br></br> * Validation errors: * * * Number of season is null * * Number of season isn't positive number * * Starting year is null * * Starting year isn't between 1940 and current year * * Ending year is null * * Ending year isn't between 1940 and current year * * Starting year is greater than ending year * * Language is null * * Subtitles are null * * Subtitles contain null value * * Language doesn't exist in data storage * * Subtitles doesn't exist in data storage * * @param show show's UUID * @param request request for changing season * @return created season * @throws InputException if show doesn't exist in data storage * or request for changing season isn't valid */ fun add(show: String, request: ChangeSeasonRequest): Season /** * Updates season. * <br></br> * Validation errors: * * * Number of season is null * * Number of season isn't positive number * * Starting year is null * * Starting year isn't between 1940 and current year * * Ending year is null * * Ending year isn't between 1940 and current year * * Starting year is greater than ending year * * Language is null * * Subtitles are null * * Subtitles contain null value * * Language doesn't exist in data storage * * Subtitles doesn't exist in data storage * * Season doesn't exist in data storage * * @param show show's UUID * @param uuid season's UUID * @param request request for changing season * @return updated season * @throws InputException if show doesn't exist in data storage * or request for changing season isn't valid */ fun update(show: String, uuid: String, request: ChangeSeasonRequest): Season /** * Removes season. * * @param show show's UUID * @param uuid season's UUID * @throws InputException if show doesn't exist in data storage * or season doesn't exist in data storage */ fun remove(show: String, uuid: String) /** * Duplicates data. * * @param show show's UUID * @param uuid season's UUID * @return created duplicated season * @throws InputException if show doesn't exist in data storage * or season doesn't exist in data storage */ fun duplicate(show: String, uuid: String): Season }
core/src/main/kotlin/com/github/vhromada/catalog/facade/SeasonFacade.kt
3718930060
/* 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 com.klinker.android.link_builder import android.os.Handler import android.text.style.ClickableSpan import android.view.View abstract class TouchableBaseSpan : ClickableSpan() { var isTouched = false /** * This TouchableSpan has been clicked. * @param widget TextView containing the touchable span */ override fun onClick(widget: View) { Handler().postDelayed({ TouchableMovementMethod.touched = false }, 500) } /** * This TouchableSpan has been long clicked. * @param widget TextView containing the touchable span */ open fun onLongClick(widget: View) { Handler().postDelayed({ TouchableMovementMethod.touched = false }, 500) } }
library/src/main/java/com/klinker/android/link_builder/TouchableBaseSpan.kt
1942718375
package domain.recommendation import java.util.Date data class DomainRecommendationUser( val bio: String?, val distanceMiles: Int, val commonFriends: Iterable<DomainRecommendationCommonFriend>, val commonFriendCount: Int, val commonLikes: Iterable<DomainRecommendationLike>, val commonLikeCount: Int, val id: String, val birthDate: Date?, val name: String, val instagram: DomainRecommendationInstagram?, val teaser: DomainRecommendationTeaser, val spotifyThemeTrack: DomainRecommendationSpotifyThemeTrack?, val gender: Int, val birthDateInfo: String, val contentHash: String, val groupMatched: Boolean, val sNumber: Long, val liked: Boolean = false, // Recommendations are not liked by default var matched: Boolean = false, // Nor matched by default val photos: Iterable<DomainRecommendationPhoto>, val jobs: Iterable<DomainRecommendationJob>, val schools: Iterable<DomainRecommendationSchool>, val teasers: Iterable<DomainRecommendationTeaser>)
domain/src/main/kotlin/domain/recommendation/DomainRecommendationUser.kt
3509281722
/* * Copyright 2019 The Android Open Source Project * * 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 androidx.compose.ui.text import androidx.compose.runtime.Immutable import androidx.compose.runtime.Stable import androidx.compose.ui.text.style.Hyphens import androidx.compose.ui.text.style.LineBreak import androidx.compose.ui.text.style.LineHeightStyle import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextDirection import androidx.compose.ui.text.style.TextIndent import androidx.compose.ui.text.style.lerp import androidx.compose.ui.unit.LayoutDirection import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.isUnspecified private val DefaultLineHeight = TextUnit.Unspecified /** * Paragraph styling configuration for a paragraph. The difference between [SpanStyle] and * `ParagraphStyle` is that, `ParagraphStyle` can be applied to a whole [Paragraph] while * [SpanStyle] can be applied at the character level. * Once a portion of the text is marked with a `ParagraphStyle`, that portion will be separated from * the remaining as if a line feed character was added. * * @sample androidx.compose.ui.text.samples.ParagraphStyleSample * @sample androidx.compose.ui.text.samples.ParagraphStyleAnnotatedStringsSample * * @param textAlign The alignment of the text within the lines of the paragraph. * @param textDirection The algorithm to be used to resolve the final text direction: * Left To Right or Right To Left. * @param lineHeight Line height for the [Paragraph] in [TextUnit] unit, e.g. SP or EM. * @param textIndent The indentation of the paragraph. * @param platformStyle Platform specific [ParagraphStyle] parameters. * @param lineHeightStyle the configuration for line height such as vertical alignment of the * line, whether to apply additional space as a result of line height to top of first line top and * bottom of last line. The configuration is applied only when a [lineHeight] is defined. * When null, [LineHeightStyle.Default] is used. * @param lineBreak The line breaking configuration for the text. * @param hyphens The configuration of hyphenation. * * @see Paragraph * @see AnnotatedString * @see SpanStyle * @see TextStyle */ @Immutable class ParagraphStyle @ExperimentalTextApi constructor( val textAlign: TextAlign? = null, val textDirection: TextDirection? = null, val lineHeight: TextUnit = TextUnit.Unspecified, val textIndent: TextIndent? = null, val platformStyle: PlatformParagraphStyle? = null, val lineHeightStyle: LineHeightStyle? = null, @Suppress("OPT_IN_MARKER_ON_WRONG_TARGET") @get:ExperimentalTextApi @property:ExperimentalTextApi val lineBreak: LineBreak? = null, @Suppress("OPT_IN_MARKER_ON_WRONG_TARGET") @get:ExperimentalTextApi @property:ExperimentalTextApi val hyphens: Hyphens? = null ) { /** * Paragraph styling configuration for a paragraph. The difference between [SpanStyle] and * `ParagraphStyle` is that, `ParagraphStyle` can be applied to a whole [Paragraph] while * [SpanStyle] can be applied at the character level. * Once a portion of the text is marked with a `ParagraphStyle`, that portion will be separated from * the remaining as if a line feed character was added. * * @sample androidx.compose.ui.text.samples.ParagraphStyleSample * @sample androidx.compose.ui.text.samples.ParagraphStyleAnnotatedStringsSample * * @param textAlign The alignment of the text within the lines of the paragraph. * @param textDirection The algorithm to be used to resolve the final text direction: * Left To Right or Right To Left. * @param lineHeight Line height for the [Paragraph] in [TextUnit] unit, e.g. SP or EM. * @param textIndent The indentation of the paragraph. * * @see Paragraph * @see AnnotatedString * @see SpanStyle * @see TextStyle */ constructor( textAlign: TextAlign? = null, textDirection: TextDirection? = null, lineHeight: TextUnit = TextUnit.Unspecified, textIndent: TextIndent? = null ) : this( textAlign = textAlign, textDirection = textDirection, lineHeight = lineHeight, textIndent = textIndent, platformStyle = null, lineHeightStyle = null ) /** * Paragraph styling configuration for a paragraph. The difference between [SpanStyle] and * `ParagraphStyle` is that, `ParagraphStyle` can be applied to a whole [Paragraph] while * [SpanStyle] can be applied at the character level. * Once a portion of the text is marked with a `ParagraphStyle`, that portion will be separated from * the remaining as if a line feed character was added. * * @sample androidx.compose.ui.text.samples.ParagraphStyleSample * @sample androidx.compose.ui.text.samples.ParagraphStyleAnnotatedStringsSample * * @param textAlign The alignment of the text within the lines of the paragraph. * @param textDirection The algorithm to be used to resolve the final text direction: * Left To Right or Right To Left. * @param lineHeight Line height for the [Paragraph] in [TextUnit] unit, e.g. SP or EM. * @param textIndent The indentation of the paragraph. * @param platformStyle Platform specific [ParagraphStyle] parameters. * @param lineHeightStyle the configuration for line height such as vertical alignment of the * line, whether to apply additional space as a result of line height to top of first line top and * bottom of last line. The configuration is applied only when a [lineHeight] is defined. * When null, [LineHeightStyle.Default] is used. * * @see Paragraph * @see AnnotatedString * @see SpanStyle * @see TextStyle */ // TODO(b/245939557, b/246715337): Deprecate this when LineBreak and Hyphens are stable @OptIn(ExperimentalTextApi::class) constructor( textAlign: TextAlign? = null, textDirection: TextDirection? = null, lineHeight: TextUnit = TextUnit.Unspecified, textIndent: TextIndent? = null, platformStyle: PlatformParagraphStyle? = null, lineHeightStyle: LineHeightStyle? = null ) : this( textAlign = textAlign, textDirection = textDirection, lineHeight = lineHeight, textIndent = textIndent, platformStyle = platformStyle, lineHeightStyle = lineHeightStyle, lineBreak = null, hyphens = null ) init { if (lineHeight != TextUnit.Unspecified) { // Since we are checking if it's negative, no need to convert Sp into Px at this point. check(lineHeight.value >= 0f) { "lineHeight can't be negative (${lineHeight.value})" } } } /** * Returns a new paragraph style that is a combination of this style and the given [other] * style. * * If the given paragraph style is null, returns this paragraph style. */ @OptIn(ExperimentalTextApi::class) @Stable fun merge(other: ParagraphStyle? = null): ParagraphStyle { if (other == null) return this return ParagraphStyle( lineHeight = if (other.lineHeight.isUnspecified) { this.lineHeight } else { other.lineHeight }, textIndent = other.textIndent ?: this.textIndent, textAlign = other.textAlign ?: this.textAlign, textDirection = other.textDirection ?: this.textDirection, platformStyle = mergePlatformStyle(other.platformStyle), lineHeightStyle = other.lineHeightStyle ?: this.lineHeightStyle, lineBreak = other.lineBreak ?: this.lineBreak, hyphens = other.hyphens ?: this.hyphens ) } private fun mergePlatformStyle(other: PlatformParagraphStyle?): PlatformParagraphStyle? { if (platformStyle == null) return other if (other == null) return platformStyle return platformStyle.merge(other) } /** * Plus operator overload that applies a [merge]. */ @Stable operator fun plus(other: ParagraphStyle): ParagraphStyle = this.merge(other) @OptIn(ExperimentalTextApi::class) fun copy( textAlign: TextAlign? = this.textAlign, textDirection: TextDirection? = this.textDirection, lineHeight: TextUnit = this.lineHeight, textIndent: TextIndent? = this.textIndent ): ParagraphStyle { return ParagraphStyle( textAlign = textAlign, textDirection = textDirection, lineHeight = lineHeight, textIndent = textIndent, platformStyle = this.platformStyle, lineHeightStyle = this.lineHeightStyle, lineBreak = this.lineBreak, hyphens = this.hyphens ) } // TODO(b/246715337, b/245939557): Deprecate this when Hyphens and LineBreak are stable @OptIn(ExperimentalTextApi::class) fun copy( textAlign: TextAlign? = this.textAlign, textDirection: TextDirection? = this.textDirection, lineHeight: TextUnit = this.lineHeight, textIndent: TextIndent? = this.textIndent, platformStyle: PlatformParagraphStyle? = this.platformStyle, lineHeightStyle: LineHeightStyle? = this.lineHeightStyle ): ParagraphStyle { return ParagraphStyle( textAlign = textAlign, textDirection = textDirection, lineHeight = lineHeight, textIndent = textIndent, platformStyle = platformStyle, lineHeightStyle = lineHeightStyle, lineBreak = this.lineBreak, hyphens = this.hyphens ) } @ExperimentalTextApi fun copy( textAlign: TextAlign? = this.textAlign, textDirection: TextDirection? = this.textDirection, lineHeight: TextUnit = this.lineHeight, textIndent: TextIndent? = this.textIndent, platformStyle: PlatformParagraphStyle? = this.platformStyle, lineHeightStyle: LineHeightStyle? = this.lineHeightStyle, lineBreak: LineBreak? = this.lineBreak, hyphens: Hyphens? = this.hyphens ): ParagraphStyle { return ParagraphStyle( textAlign = textAlign, textDirection = textDirection, lineHeight = lineHeight, textIndent = textIndent, platformStyle = platformStyle, lineHeightStyle = lineHeightStyle, lineBreak = lineBreak, hyphens = hyphens ) } @OptIn(ExperimentalTextApi::class) override fun equals(other: Any?): Boolean { if (this === other) return true if (other !is ParagraphStyle) return false if (textAlign != other.textAlign) return false if (textDirection != other.textDirection) return false if (lineHeight != other.lineHeight) return false if (textIndent != other.textIndent) return false if (platformStyle != other.platformStyle) return false if (lineHeightStyle != other.lineHeightStyle) return false if (lineBreak != other.lineBreak) return false if (hyphens != other.hyphens) return false return true } @OptIn(ExperimentalTextApi::class) override fun hashCode(): Int { var result = textAlign?.hashCode() ?: 0 result = 31 * result + (textDirection?.hashCode() ?: 0) result = 31 * result + lineHeight.hashCode() result = 31 * result + (textIndent?.hashCode() ?: 0) result = 31 * result + (platformStyle?.hashCode() ?: 0) result = 31 * result + (lineHeightStyle?.hashCode() ?: 0) result = 31 * result + (lineBreak?.hashCode() ?: 0) result = 31 * result + (hyphens?.hashCode() ?: 0) return result } @OptIn(ExperimentalTextApi::class) override fun toString(): String { return "ParagraphStyle(" + "textAlign=$textAlign, " + "textDirection=$textDirection, " + "lineHeight=$lineHeight, " + "textIndent=$textIndent, " + "platformStyle=$platformStyle, " + "lineHeightStyle=$lineHeightStyle, " + "lineBreak=$lineBreak, " + "hyphens=$hyphens" + ")" } } /** * Interpolate between two [ParagraphStyle]s. * * This will not work well if the styles don't set the same fields. * * The [fraction] argument represents position on the timeline, with 0.0 meaning * that the interpolation has not started, returning [start] (or something * equivalent to [start]), 1.0 meaning that the interpolation has finished, * returning [stop] (or something equivalent to [stop]), and values in between * meaning that the interpolation is at the relevant point on the timeline * between [start] and [stop]. The interpolation can be extrapolated beyond 0.0 and * 1.0, so negative values and values greater than 1.0 are valid. */ @OptIn(ExperimentalTextApi::class) @Stable fun lerp(start: ParagraphStyle, stop: ParagraphStyle, fraction: Float): ParagraphStyle { return ParagraphStyle( textAlign = lerpDiscrete(start.textAlign, stop.textAlign, fraction), textDirection = lerpDiscrete( start.textDirection, stop.textDirection, fraction ), lineHeight = lerpTextUnitInheritable(start.lineHeight, stop.lineHeight, fraction), textIndent = lerp( start.textIndent ?: TextIndent.None, stop.textIndent ?: TextIndent.None, fraction ), platformStyle = lerpPlatformStyle(start.platformStyle, stop.platformStyle, fraction), lineHeightStyle = lerpDiscrete( start.lineHeightStyle, stop.lineHeightStyle, fraction ), lineBreak = lerpDiscrete(start.lineBreak, stop.lineBreak, fraction), hyphens = lerpDiscrete(start.hyphens, stop.hyphens, fraction) ) } private fun lerpPlatformStyle( start: PlatformParagraphStyle?, stop: PlatformParagraphStyle?, fraction: Float ): PlatformParagraphStyle? { if (start == null && stop == null) return null val startNonNull = start ?: PlatformParagraphStyle.Default val stopNonNull = stop ?: PlatformParagraphStyle.Default return lerp(startNonNull, stopNonNull, fraction) } @OptIn(ExperimentalTextApi::class) internal fun resolveParagraphStyleDefaults( style: ParagraphStyle, direction: LayoutDirection ) = ParagraphStyle( textAlign = style.textAlign ?: TextAlign.Start, textDirection = resolveTextDirection(direction, style.textDirection), lineHeight = if (style.lineHeight.isUnspecified) DefaultLineHeight else style.lineHeight, textIndent = style.textIndent ?: TextIndent.None, platformStyle = style.platformStyle, lineHeightStyle = style.lineHeightStyle, lineBreak = style.lineBreak ?: LineBreak.Simple, hyphens = style.hyphens ?: Hyphens.None )
compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/ParagraphStyle.kt
2695940853
package org.thoughtcrime.securesms.conversation.drafts import android.content.Context import android.net.Uri import android.text.Spannable import android.text.SpannableString import io.reactivex.rxjava3.core.Single import io.reactivex.rxjava3.schedulers.Schedulers import org.signal.core.util.concurrent.SignalExecutors import org.thoughtcrime.securesms.components.mention.MentionAnnotation import org.thoughtcrime.securesms.database.DraftDatabase import org.thoughtcrime.securesms.database.DraftDatabase.Drafts import org.thoughtcrime.securesms.database.MentionUtil import org.thoughtcrime.securesms.database.MmsSmsColumns import org.thoughtcrime.securesms.database.SignalDatabase import org.thoughtcrime.securesms.database.ThreadDatabase import org.thoughtcrime.securesms.dependencies.ApplicationDependencies import org.thoughtcrime.securesms.providers.BlobProvider import org.thoughtcrime.securesms.recipients.Recipient import org.thoughtcrime.securesms.util.Base64 import org.thoughtcrime.securesms.util.concurrent.SerialMonoLifoExecutor import java.util.concurrent.Executor class DraftRepository( private val context: Context = ApplicationDependencies.getApplication(), private val threadDatabase: ThreadDatabase = SignalDatabase.threads, private val draftDatabase: DraftDatabase = SignalDatabase.drafts, private val saveDraftsExecutor: Executor = SerialMonoLifoExecutor(SignalExecutors.BOUNDED) ) { fun deleteVoiceNoteDraftData(draft: DraftDatabase.Draft?) { if (draft != null) { SignalExecutors.BOUNDED.execute { BlobProvider.getInstance().delete(context, Uri.parse(draft.value).buildUpon().clearQuery().build()) } } } fun saveDrafts(recipient: Recipient, threadId: Long, distributionType: Int, drafts: Drafts) { saveDraftsExecutor.execute { if (drafts.isNotEmpty()) { val actualThreadId = if (threadId == -1L) { threadDatabase.getOrCreateThreadIdFor(recipient, distributionType) } else { threadId } draftDatabase.replaceDrafts(actualThreadId, drafts) threadDatabase.updateSnippet(actualThreadId, drafts.getSnippet(context), drafts.uriSnippet, System.currentTimeMillis(), MmsSmsColumns.Types.BASE_DRAFT_TYPE, true) } else if (threadId > 0) { threadDatabase.update(threadId, false) draftDatabase.clearDrafts(threadId) } } } fun loadDrafts(threadId: Long): Single<DatabaseDraft> { return Single.fromCallable { val drafts: Drafts = draftDatabase.getDrafts(threadId) val mentionsDraft = drafts.getDraftOfType(DraftDatabase.Draft.MENTION) var updatedText: Spannable? = null if (mentionsDraft != null) { val text = drafts.getDraftOfType(DraftDatabase.Draft.TEXT)!!.value val mentions = MentionUtil.bodyRangeListToMentions(context, Base64.decodeOrThrow(mentionsDraft.value)) val updated = MentionUtil.updateBodyAndMentionsWithDisplayNames(context, text, mentions) updatedText = SpannableString(updated.body) MentionAnnotation.setMentionAnnotations(updatedText, updated.mentions) } DatabaseDraft(drafts, updatedText) }.subscribeOn(Schedulers.io()) } data class DatabaseDraft(val drafts: Drafts, val updatedText: CharSequence?) }
app/src/main/java/org/thoughtcrime/securesms/conversation/drafts/DraftRepository.kt
4063259166
package org.jetbrains.completion.full.line.python.formatters import com.intellij.psi.PsiElement import com.jetbrains.python.psi.PyArgumentList import com.jetbrains.python.psi.PyClass import com.jetbrains.python.psi.PyExpression import org.jetbrains.completion.full.line.language.ElementFormatter class ArgumentListFormatter : ElementFormatter { override fun condition(element: PsiElement): Boolean = element is PyArgumentList override fun filter(element: PsiElement): Boolean? = element is PyArgumentList override fun format(element: PsiElement): String { element as PyArgumentList return if (element.arguments.isEmpty()) { if (element.parent is PyClass) { "" } else { element.text } } else { handlePyArgumentList(element.arguments, element.text.last() == ',', element.closingParen != null) } } companion object { fun handlePyArgumentList(arguments: Array<PyExpression>, lastComma: Boolean = false, closed: Boolean = true): String { val text = StringBuilder("(") arguments.forEach { text.append(it.text).append(", ") } if (!lastComma) { text.delete(text.length - 2, text.length) } else { text.delete(text.length - 1, text.length) } if (closed) { text.append(")") } return text.toString() } } }
plugins/full-line/python/src/org/jetbrains/completion/full/line/python/formatters/ArgumentListFormatter.kt
569745205
package com.intellij.workspaceModel.storage.entities.test.api import com.intellij.workspaceModel.storage.EntityInformation import com.intellij.workspaceModel.storage.EntitySource import com.intellij.workspaceModel.storage.EntityStorage import com.intellij.workspaceModel.storage.GeneratedCodeApiVersion import com.intellij.workspaceModel.storage.GeneratedCodeImplVersion import com.intellij.workspaceModel.storage.MutableEntityStorage import com.intellij.workspaceModel.storage.WorkspaceEntity import com.intellij.workspaceModel.storage.impl.ConnectionId import com.intellij.workspaceModel.storage.impl.ModifiableWorkspaceEntityBase import com.intellij.workspaceModel.storage.impl.UsedClassesCollector import com.intellij.workspaceModel.storage.impl.WorkspaceEntityBase import com.intellij.workspaceModel.storage.impl.WorkspaceEntityData import org.jetbrains.deft.ObjBuilder import org.jetbrains.deft.Type import org.jetbrains.deft.annotations.Child @GeneratedCodeApiVersion(1) @GeneratedCodeImplVersion(1) open class AttachedEntityParentListImpl(val dataSource: AttachedEntityParentListData) : AttachedEntityParentList, WorkspaceEntityBase() { companion object { val connections = listOf<ConnectionId>( ) } override val data: String get() = dataSource.data override val entitySource: EntitySource get() = dataSource.entitySource override fun connectionIdList(): List<ConnectionId> { return connections } class Builder(result: AttachedEntityParentListData?) : ModifiableWorkspaceEntityBase<AttachedEntityParentList, AttachedEntityParentListData>( result), AttachedEntityParentList.Builder { constructor() : this(AttachedEntityParentListData()) override fun applyToBuilder(builder: MutableEntityStorage) { if (this.diff != null) { if (existsInBuilder(builder)) { this.diff = builder return } else { error("Entity AttachedEntityParentList is already created in a different builder") } } this.diff = builder this.snapshot = builder addToBuilder() this.id = getEntityData().createEntityId() // After adding entity data to the builder, we need to unbind it and move the control over entity data to builder // Builder may switch to snapshot at any moment and lock entity data to modification this.currentEntityData = null // Process linked entities that are connected without a builder processLinkedEntities(builder) checkInitialization() // TODO uncomment and check failed tests } fun checkInitialization() { val _diff = diff if (!getEntityData().isEntitySourceInitialized()) { error("Field WorkspaceEntity#entitySource should be initialized") } if (!getEntityData().isDataInitialized()) { error("Field AttachedEntityParentList#data should be initialized") } } override fun connectionIdList(): List<ConnectionId> { return connections } // Relabeling code, move information from dataSource to this builder override fun relabel(dataSource: WorkspaceEntity, parents: Set<WorkspaceEntity>?) { dataSource as AttachedEntityParentList if (this.entitySource != dataSource.entitySource) this.entitySource = dataSource.entitySource if (this.data != dataSource.data) this.data = dataSource.data if (parents != null) { } } override var entitySource: EntitySource get() = getEntityData().entitySource set(value) { checkModificationAllowed() getEntityData(true).entitySource = value changedProperty.add("entitySource") } override var data: String get() = getEntityData().data set(value) { checkModificationAllowed() getEntityData(true).data = value changedProperty.add("data") } override fun getEntityClass(): Class<AttachedEntityParentList> = AttachedEntityParentList::class.java } } class AttachedEntityParentListData : WorkspaceEntityData<AttachedEntityParentList>() { lateinit var data: String fun isDataInitialized(): Boolean = ::data.isInitialized override fun wrapAsModifiable(diff: MutableEntityStorage): WorkspaceEntity.Builder<AttachedEntityParentList> { val modifiable = AttachedEntityParentListImpl.Builder(null) modifiable.diff = diff modifiable.snapshot = diff modifiable.id = createEntityId() return modifiable } override fun createEntity(snapshot: EntityStorage): AttachedEntityParentList { return getCached(snapshot) { val entity = AttachedEntityParentListImpl(this) entity.snapshot = snapshot entity.id = createEntityId() entity } } override fun getEntityInterface(): Class<out WorkspaceEntity> { return AttachedEntityParentList::class.java } override fun serialize(ser: EntityInformation.Serializer) { } override fun deserialize(de: EntityInformation.Deserializer) { } override fun createDetachedEntity(parents: List<WorkspaceEntity>): WorkspaceEntity { return AttachedEntityParentList(data, entitySource) { } } override fun getRequiredParents(): List<Class<out WorkspaceEntity>> { val res = mutableListOf<Class<out WorkspaceEntity>>() return res } override fun equals(other: Any?): Boolean { if (other == null) return false if (this.javaClass != other.javaClass) return false other as AttachedEntityParentListData if (this.entitySource != other.entitySource) return false if (this.data != other.data) return false return true } override fun equalsIgnoringEntitySource(other: Any?): Boolean { if (other == null) return false if (this.javaClass != other.javaClass) return false other as AttachedEntityParentListData if (this.data != other.data) return false return true } override fun hashCode(): Int { var result = entitySource.hashCode() result = 31 * result + data.hashCode() return result } override fun hashCodeIgnoringEntitySource(): Int { var result = javaClass.hashCode() result = 31 * result + data.hashCode() return result } override fun collectClassUsagesData(collector: UsedClassesCollector) { collector.sameForAllEntities = true } }
platform/workspaceModel/storage/testEntities/gen/com/intellij/workspaceModel/storage/entities/test/api/AttachedEntityParentListImpl.kt
3383799777
package org.intellij.plugins.markdown.extensions.common.highlighter import com.intellij.diagnostic.LoadingState import com.intellij.ide.ui.LafManager import com.intellij.ide.ui.LafManagerListener import com.intellij.openapi.components.Service import com.intellij.openapi.components.service import com.intellij.openapi.components.serviceIfCreated import com.intellij.openapi.project.Project import com.intellij.openapi.project.processOpenedProjects import com.intellij.util.application import org.intellij.plugins.markdown.ui.preview.html.MarkdownUtil import java.lang.ref.SoftReference import java.util.concurrent.ConcurrentHashMap @Service internal class HtmlCacheManager { private data class CachedHtmlResult(val html: SoftReference<String>, var expires: Long) { data class HtmlResult(val html: String, val expires: Long) fun resolve(): HtmlResult? { return html.get()?.let { HtmlResult(it, expires) } } } private val values = ConcurrentHashMap<String, CachedHtmlResult>() fun obtainCacheKey(content: String, language: String): String { return MarkdownUtil.md5(content, language) } fun obtainCachedHtml(key: String): String? { val entry = values[key] val resolved = entry?.resolve() if (resolved != null) { entry.expires += expiration return resolved.html } cleanup() return null } fun cacheHtml(key: String, html: String) { val expires = System.currentTimeMillis() + expiration values[key] = CachedHtmlResult(SoftReference(html), expires) } fun cleanup() { val time = System.currentTimeMillis() val expired = values.filter { it.value.expires < time }.keys for (key in expired) { values.remove(key) } } fun invalidate() { values.clear() } internal class InvalidateHtmlCacheLafListener: LafManagerListener { override fun lookAndFeelChanged(source: LafManager) { if (!LoadingState.APP_STARTED.isOccurred) { return } application.serviceIfCreated<HtmlCacheManager>()?.invalidate() processOpenedProjects { project -> project.serviceIfCreated<HtmlCacheManager>()?.invalidate() } } } companion object { private const val expiration = 5 * 60 * 1000 fun getInstance(project: Project? = null): HtmlCacheManager { return when (project) { null -> service() else -> project.service() } } } }
plugins/markdown/core/src/org/intellij/plugins/markdown/extensions/common/highlighter/HtmlCacheManager.kt
3414131724
package testing enum class E { BAR }
plugins/kotlin/idea/tests/testData/refactoring/rename/renameKotlinEnumEntry/after/RenameKotlinEnumEntry.kt
2558451670
// COMPILER_ARGUMENTS: -XXLanguage:+GenericInlineClassParameter
plugins/kotlin/idea/tests/testData/multiModuleQuickFix/createActual/valueClassWithGenerics/jvm/IC.kt
4105226041
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.kotlin.nj2k.conversions import org.jetbrains.kotlin.nj2k.NewJ2kConverterContext import org.jetbrains.kotlin.nj2k.RecursiveApplicableConversionBase import org.jetbrains.kotlin.nj2k.tree.JKImportList import org.jetbrains.kotlin.nj2k.tree.JKTreeElement class FilterImportsConversion(context: NewJ2kConverterContext) : RecursiveApplicableConversionBase(context) { override fun applyToElement(element: JKTreeElement): JKTreeElement { if (element !is JKImportList) return recurse(element) element.imports = element.imports.filter { import -> context.importStorage.isImportNeeded(import.name.value, allowSingleIdentifierImport = true) } return recurse(element) } }
plugins/kotlin/j2k/new/src/org/jetbrains/kotlin/nj2k/conversions/FilterImportsConversion.kt
1967933703
/******************************************************************************* * Copyright 2000-2022 JetBrains s.r.o. and contributors. * * 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 * * https://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 com.jetbrains.packagesearch.intellij.plugin.data import com.jetbrains.packagesearch.intellij.plugin.ui.toolwindow.models.PackagesToUpgrade internal data class PackageUpgradeCandidates( val allUpgrades: PackagesToUpgrade ) { fun getPackagesToUpgrade(onlyStable: Boolean) = if (onlyStable) PackagesToUpgrade( allUpgrades.upgradesByModule.mapValues { it.value.filter { it.targetVersion.isStable }.toSet() } ) else allUpgrades companion object { val EMPTY = PackageUpgradeCandidates(PackagesToUpgrade.EMPTY) } }
plugins/package-search/src/com/jetbrains/packagesearch/intellij/plugin/data/PackageUpgradeCandidates.kt
706835274
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.intellij.plugins.markdown.editor.tables.actions.column import com.intellij.openapi.actionSystem.ActionUpdateThread import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.CommonDataKeys import com.intellij.openapi.editor.Document import com.intellij.openapi.editor.Editor import com.intellij.psi.PsiFile import org.intellij.plugins.markdown.editor.tables.TableUtils import org.intellij.plugins.markdown.editor.tables.actions.TableActionKeys import org.intellij.plugins.markdown.lang.MarkdownLanguage import org.intellij.plugins.markdown.lang.MarkdownLanguageUtils.isMarkdownLanguage import org.intellij.plugins.markdown.lang.psi.impl.MarkdownTable /** * Base class for actions operating on a single column. * * Implementations should override performAction and update methods which take current editor, table and column index. * * Could be invoked from two contexts: normally from the editor or from the table inlay toolbar. * In the latter case current column index, and it's parent table are taken from the event's data context (see [TableActionKeys]). * If table and column index are not found in even's data context, then we consider that action was invoked normally * (e.g. from search everywhere) and compute column index and table element based on the position of current caret. * * See [ColumnBasedTableAction.Companion.findTableAndIndex]. */ internal abstract class ColumnBasedTableAction: AnAction() { override fun actionPerformed(event: AnActionEvent) { val editor = event.getRequiredData(CommonDataKeys.EDITOR) val file = event.getRequiredData(CommonDataKeys.PSI_FILE) val offset = event.getRequiredData(CommonDataKeys.CARET).offset val document = editor.document val (table, columnIndex) = findTableAndIndex(event, file, document, offset) requireNotNull(table) requireNotNull(columnIndex) performAction(editor, table, columnIndex) } @Suppress("DuplicatedCode") override fun update(event: AnActionEvent) { val project = event.getData(CommonDataKeys.PROJECT) val editor = event.getData(CommonDataKeys.EDITOR) val file = event.getData(CommonDataKeys.PSI_FILE) val offset = event.getData(CommonDataKeys.CARET)?.offset if (project == null || editor == null || file == null || offset == null || !file.language.isMarkdownLanguage()) { event.presentation.isEnabledAndVisible = false return } val document = editor.document val (table, columnIndex) = findTableAndIndex(event, file, document, offset) event.presentation.isEnabledAndVisible = table != null && columnIndex != null update(event, table, columnIndex) } override fun getActionUpdateThread(): ActionUpdateThread { return ActionUpdateThread.BGT } protected abstract fun performAction(editor: Editor, table: MarkdownTable, columnIndex: Int) protected open fun update(event: AnActionEvent, table: MarkdownTable?, columnIndex: Int?) = Unit private fun findTableAndIndex(event: AnActionEvent, file: PsiFile, document: Document, offset: Int): Pair<MarkdownTable?, Int?> { return findTableAndIndex(event, file, document, offset, ::findTable, ::findColumnIndex) } protected open fun findTable(file: PsiFile, document: Document, offset: Int): MarkdownTable? { return TableUtils.findTable(file, offset) } protected open fun findColumnIndex(file: PsiFile, document: Document, offset: Int): Int? { return TableUtils.findCellIndex(file, offset) } companion object { fun findTableAndIndex( event: AnActionEvent, file: PsiFile, document: Document, offset: Int, tableGetter: (PsiFile, Document, Int) -> MarkdownTable?, columnIndexGetter: (PsiFile, Document, Int) -> Int? ): Pair<MarkdownTable?, Int?> { val tableFromEvent = event.getData(TableActionKeys.ELEMENT)?.get() as? MarkdownTable val indexFromEvent = event.getData(TableActionKeys.COLUMN_INDEX) if (tableFromEvent != null && indexFromEvent != null) { return tableFromEvent to indexFromEvent } val table = tableGetter(file, document, offset)?.takeIf { it.isValid } val index = columnIndexGetter(file, document, offset) return table to index } fun findTableAndIndex(event: AnActionEvent, file: PsiFile, document: Document, offset: Int): Pair<MarkdownTable?, Int?> { return findTableAndIndex( event, file, document, offset, tableGetter = { file, document, offset -> TableUtils.findTable(file, offset) }, columnIndexGetter = { file, document, offset -> TableUtils.findCellIndex(file, offset) } ) } } }
plugins/markdown/core/src/org/intellij/plugins/markdown/editor/tables/actions/column/ColumnBasedTableAction.kt
438761013
fun bar(i: Int, x: String?) { var str: String? = null <caret>if (i == 1) { str = null } else if (i == 2) { str = "2" } else { str = x } }
plugins/kotlin/idea/tests/testData/inspectionsLocal/liftOut/ifToAssignment/hasNull6.kt
3285419768
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.kotlin.idea.quickfix import com.intellij.codeInsight.intention.IntentionAction import com.intellij.psi.util.parentOfTypes import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.lexer.KtModifierKeywordToken import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.visibilityModifierType import org.jetbrains.kotlin.utils.addToStdlib.safeAs object CallFromPublicInlineFactory : KotlinIntentionActionsFactory() { override fun doCreateActions(diagnostic: Diagnostic): List<IntentionAction> { val fixes = mutableListOf<IntentionAction>() val element = diagnostic.psiElement.safeAs<KtExpression>() ?: return fixes val (containingDeclaration, containingDeclarationName) = element.containingDeclaration() ?: return fixes when (diagnostic.factory) { Errors.NON_PUBLIC_CALL_FROM_PUBLIC_INLINE, Errors.PROTECTED_CALL_FROM_PUBLIC_INLINE.warningFactory, Errors.PROTECTED_CALL_FROM_PUBLIC_INLINE.errorFactory -> { val (declaration, declarationName, declarationVisibility) = element.referenceDeclaration() ?: return fixes fixes.add(ChangeVisibilityFix(containingDeclaration, containingDeclarationName, declarationVisibility)) fixes.add(ChangeVisibilityFix(declaration, declarationName, KtTokens.PUBLIC_KEYWORD)) if (!containingDeclaration.hasReifiedTypeParameter()) { fixes.add(RemoveModifierFix(containingDeclaration, KtTokens.INLINE_KEYWORD, isRedundant = false)) } } Errors.SUPER_CALL_FROM_PUBLIC_INLINE.warningFactory, Errors.SUPER_CALL_FROM_PUBLIC_INLINE.errorFactory -> { fixes.add(ChangeVisibilityFix(containingDeclaration, containingDeclarationName, KtTokens.INTERNAL_KEYWORD)) fixes.add(ChangeVisibilityFix(containingDeclaration, containingDeclarationName, KtTokens.PRIVATE_KEYWORD)) if (!containingDeclaration.hasReifiedTypeParameter()) { fixes.add(RemoveModifierFix(containingDeclaration, KtTokens.INLINE_KEYWORD, isRedundant = false)) } } } return fixes } private fun KtExpression.containingDeclaration(): Pair<KtCallableDeclaration, String>? { val declaration = parentOfTypes(KtNamedFunction::class, KtProperty::class) ?.safeAs<KtCallableDeclaration>() ?.takeIf { it.hasModifier(KtTokens.INLINE_KEYWORD) } ?: return null val name = declaration.name ?: return null return declaration to name } private fun KtExpression.referenceDeclaration(): Triple<KtDeclaration, String, KtModifierKeywordToken>? { val declaration = safeAs<KtNameReferenceExpression>()?.mainReference?.resolve().safeAs<KtDeclaration>() ?: return null val name = declaration.name ?: return null val visibility = declaration.visibilityModifierType() ?: return null return Triple(declaration, name, visibility) } private fun KtCallableDeclaration.hasReifiedTypeParameter() = typeParameters.any { it.hasModifier(KtTokens.REIFIED_KEYWORD) } }
plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/CallFromPublicInlineFactory.kt
1318540443
// WITH_RUNTIME //DISABLE-ERRORS enum class E(n: Int) { A(1), B(2), C(3); abstract val <caret>foo: Int }
plugins/kotlin/idea/tests/testData/intentions/implementAbstractMember/property/enumEntriesWithArgs.kt
3470570012
/* * The MIT License (MIT) * * Copyright 2017 Alexander Orlov <[email protected]>. All rights reserved. * Copyright (c) [2016] [ <ether.camp> ] * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ package org.ethereum.net.eth.handler import org.ethereum.net.eth.EthVersion import org.springframework.beans.factory.annotation.Autowired import org.springframework.context.ApplicationContext import org.springframework.stereotype.Component /** * Default factory implementation * @author Mikhail Kalinin * * * @since 20.08.2015 */ @Component open class EthHandlerFactoryImpl : EthHandlerFactory { @Autowired private val ctx: ApplicationContext? = null override fun create(version: EthVersion): EthHandler { when (version) { EthVersion.V62 -> return ctx!!.getBean("Eth62") as EthHandler EthVersion.V63 -> return ctx!!.getBean("Eth63") as EthHandler else -> throw IllegalArgumentException("Eth $version is not supported") } } }
free-ethereum-core/src/main/java/org/ethereum/net/eth/handler/EthHandlerFactoryImpl.kt
1926547475
/* * Copyright 2010-2018 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 codegen.inline.defaultArgs import kotlin.test.* class Z inline fun Z.foo(x: Int = 42, y: Int = x) { println(y) } @Test fun runTest() { val z = Z() z.foo() }
backend.native/tests/codegen/inline/defaultArgs.kt
1650067498
// "Add 'actual' modifier" "false" // ACTION: Create test // ACTION: Do not show return expression hints // ACTION: Rename file to Foo.kt // KTIJ-19789 No diagnostic "actual is missing" on top-level class/function/property in IDE class <caret>Foo
plugins/kotlin/idea/tests/testData/multiModuleQuickFix/other/addActualToClass/jvm/jvm.kt
2404091142
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.kotlin.idea.perf.whole import com.intellij.codeInsight.daemon.impl.HighlightInfo import com.intellij.openapi.module.Module import com.intellij.openapi.module.impl.ProjectLoadingErrorsHeadlessNotifier import com.intellij.openapi.roots.ProjectFileIndex import com.intellij.openapi.vfs.VirtualFile import com.intellij.psi.search.FileTypeIndex import com.intellij.psi.search.GlobalSearchScope import com.intellij.testFramework.UsefulTestCase import org.jetbrains.kotlin.idea.KotlinFileType import org.jetbrains.kotlin.idea.base.util.runReadActionInSmartMode import org.jetbrains.kotlin.idea.perf.suite.DefaultProfile import org.jetbrains.kotlin.idea.perf.suite.EmptyProfile import org.jetbrains.kotlin.idea.perf.suite.suite import org.jetbrains.kotlin.idea.perf.util.* import org.jetbrains.kotlin.idea.performance.tests.utils.logMessage import org.jetbrains.kotlin.idea.search.usagesSearch.ExpressionsOfTypeProcessor import org.jetbrains.kotlin.idea.performance.tests.utils.relativePath import org.jetbrains.kotlin.idea.test.JUnit3RunnerWithInners import org.junit.runner.RunWith import java.io.File import java.nio.file.Files @RunWith(JUnit3RunnerWithInners::class) class HighlightWholeProjectPerformanceTest : UsefulTestCase() { override fun setUp() { val allowedErrorDescription = setOf( "Unknown artifact type: war", "Unknown artifact type: exploded-war" ) ProjectLoadingErrorsHeadlessNotifier.setErrorHandler(testRootDisposable) { errorDescription -> val description = errorDescription.description if (description !in allowedErrorDescription) { throw RuntimeException(description) } else { logMessage { "project loading error: '$description' at '${errorDescription.elementName}'" } } } } fun testHighlightAllKtFilesInProject() { val emptyProfile = System.getProperty("emptyProfile", "false")!!.toBoolean() val percentOfFiles = System.getProperty("files.percentOfFiles", "10")!!.toInt() val maxFilesPerPart = System.getProperty("files.maxFilesPerPart", "300")!!.toInt() val minFileSize = System.getProperty("files.minFileSize", "300")!!.toInt() val warmUpIterations = System.getProperty("iterations.warmup", "1")!!.toInt() val numberOfIterations = System.getProperty("iterations.number", "10")!!.toInt() val clearPsiCaches = System.getProperty("caches.clearPsi", "true")!!.toBoolean() val projectSpecs = projectSpecs() logMessage { "projectSpecs: $projectSpecs" } for (projectSpec in projectSpecs) { val projectName = projectSpec.name val projectPath = projectSpec.path val suiteName = listOfNotNull("allKtFilesIn", "emptyProfile".takeIf { emptyProfile }, projectName) .joinToString(separator = "-") suite(suiteName = suiteName) { app { ExpressionsOfTypeProcessor.prodMode() warmUpProject() with(config) { warmup = warmUpIterations iterations = numberOfIterations fastIterations = true } try { project(ExternalProject.autoOpenProject(projectPath), refresh = true) { profile(if (emptyProfile) EmptyProfile else DefaultProfile) val ktFiles = mutableSetOf<VirtualFile>() project.runReadActionInSmartMode { val projectFileIndex = ProjectFileIndex.getInstance(project) val modules = mutableSetOf<Module>() val ktFileProcessor = { ktFile: VirtualFile -> if (projectFileIndex.isInSourceContent(ktFile)) { ktFiles.add(ktFile) } true } FileTypeIndex.processFiles( KotlinFileType.INSTANCE, ktFileProcessor, GlobalSearchScope.projectScope(project) ) modules } logStatValue("number of kt files", ktFiles.size) val filesToProcess = limitedFiles( ktFiles, percentOfFiles = percentOfFiles, maxFilesPerPart = maxFilesPerPart, minFileSize = minFileSize ) logStatValue("limited number of kt files", filesToProcess.size) filesToProcess.forEach { logMessage { "${project.relativePath(it)} fileSize: ${Files.size(it.toNioPath())}" } } filesToProcess.forEachIndexed { idx, file -> logMessage { "${idx + 1} / ${filesToProcess.size} : ${project.relativePath(file)} fileSize: ${Files.size(file.toNioPath())}" } try { fixture(file).use { measure<List<HighlightInfo>>(it.fileName, clearCaches = clearPsiCaches) { test = { it.highlight() } } } } catch (e: Exception) { // nothing as it is already caught by perfTest } } } } catch (e: Exception) { e.printStackTrace() // nothing as it is already caught by perfTest } } } } } private fun limitedFiles( ktFiles: Collection<VirtualFile>, percentOfFiles: Int, maxFilesPerPart: Int, minFileSize: Int ): Collection<VirtualFile> { val sortedBySize = ktFiles .filter { Files.size(it.toNioPath()) > minFileSize } .map { it to Files.size(it.toNioPath()) }.sortedByDescending { it.second } val numberOfFiles = minOf((sortedBySize.size * percentOfFiles) / 100, maxFilesPerPart) val topFiles = sortedBySize.take(numberOfFiles).map { it.first } val midFiles = sortedBySize.take(sortedBySize.size / 2 + numberOfFiles / 2).takeLast(numberOfFiles).map { it.first } val lastFiles = sortedBySize.takeLast(numberOfFiles).map { it.first } return LinkedHashSet(topFiles + midFiles + lastFiles) } private fun projectSpecs(): List<ProjectSpec> { val projects = System.getProperty("performanceProjects") val specs = projects?.split(",")?.map { val idx = it.indexOf("=") if (idx <= 0) ProjectSpec(it, "../$it") else ProjectSpec(it.substring(0, idx), it.substring(idx + 1)) } ?: emptyList() specs.forEach { val path = File(it.path) check(path.exists() && path.isDirectory) { "Project `${it.name}` path ${path.absolutePath} does not exist or it is not a directory" } } return specs.takeIf { it.isNotEmpty() } ?: error("No projects specified, use `-DperformanceProjects=projectName`") } private data class ProjectSpec(val name: String, val path: String) }
plugins/kotlin/performance-tests/test/org/jetbrains/kotlin/idea/perf/whole/HighlightWholeProjectPerformanceTest.kt
2610188715
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.intellij.build.impl /** * Describes additional resources which should be included into a plugin or the platform distribution. This isn't related to files from * 'resources roots' of a module, such files are automatically included into the plugin JAR files. */ internal data class ModuleResourceData( /** Name of the module resources will be taken from */ val moduleName: String, /** Path to resource file or directory relative to the module content root */ val resourcePath: String, /** Target path relative to the plugin root directory */ val relativeOutputPath: String, /** If {@code true} resource will be packed into zip archive */ val packToZip: Boolean = false, )
platform/build-scripts/src/org/jetbrains/intellij/build/impl/ModuleResourceData.kt
277004737
package com.jetbrains.packagesearch.intellij.plugin.gradle import com.intellij.openapi.Disposable import com.intellij.openapi.components.Service import com.intellij.openapi.components.Service.Level import com.intellij.openapi.components.service import com.intellij.openapi.externalSystem.model.DataNode import com.intellij.openapi.externalSystem.model.Key import com.intellij.openapi.externalSystem.model.project.ModuleData import com.intellij.openapi.externalSystem.model.project.ProjectData import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider import com.intellij.openapi.externalSystem.service.project.manage.AbstractProjectDataService import com.intellij.openapi.project.Project import com.intellij.openapi.project.getProjectDataPath import com.intellij.util.io.createDirectories import com.intellij.util.io.exists import com.intellij.util.io.readBytes import com.jetbrains.packagesearch.intellij.plugin.gradle.GradleConfigurationReportNodeProcessor.Companion.ESM_REPORTS_KEY import com.jetbrains.packagesearch.intellij.plugin.gradle.tooling.GradleConfigurationModelBuilder import com.jetbrains.packagesearch.intellij.plugin.gradle.tooling.GradleConfigurationReportModel import com.jetbrains.packagesearch.intellij.plugin.util.logDebug import kotlinx.serialization.Serializable import kotlinx.serialization.decodeFromByteArray import kotlinx.serialization.encodeToByteArray import kotlinx.serialization.protobuf.ProtoBuf import org.gradle.tooling.model.idea.IdeaModule import org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension import kotlin.io.path.absolutePathString import kotlin.io.path.writeBytes class GradleConfigurationResolver : AbstractProjectResolverExtension() { override fun getExtraProjectModelClasses(): Set<Class<*>> = setOf(GradleConfigurationReportModel::class.java) override fun getToolingExtensionsClasses(): Set<Class<*>> = setOf(GradleConfigurationModelBuilder::class.java) private inline fun <reified T> IdeaModule.getExtraProject(): T? = resolverCtx.getExtraProject(this@getExtraProject, T::class.java) override fun populateModuleExtraModels(gradleModule: IdeaModule, ideModule: DataNode<ModuleData>) { gradleModule.getExtraProject<GradleConfigurationReportModel>() ?.also { ideModule.createChild(ESM_REPORTS_KEY, it.toPublic()) } super.populateModuleExtraModels(gradleModule, ideModule) } } class GradleConfigurationReportNodeProcessor : AbstractProjectDataService<PublicGradleConfigurationReportModel, Unit>() { companion object { internal val ESM_REPORTS_KEY: Key<PublicGradleConfigurationReportModel> = Key.create(PublicGradleConfigurationReportModel::class.java, 100) } @Service(Level.PROJECT) class Cache(private val project: Project) : Disposable { private val cacheFile get() = project.getProjectDataPath("pkgs") .also { if (!it.exists()) it.createDirectories() } .resolve("gradle.proto.bin") var state = load() internal set private fun load(): Map<String, PublicGradleConfigurationReportModel> = cacheFile.takeIf { it.exists() } ?.runCatching { ProtoBuf.decodeFromByteArray<Map<String, PublicGradleConfigurationReportModel>>(readBytes()) } ?.onFailure { logDebug(this::class.qualifiedName+"#load()", it) { "Error while decoding ${cacheFile.absolutePathString()}" } } ?.getOrNull() ?.let { emptyMap() } ?: emptyMap() override fun dispose() { cacheFile.writeBytes(ProtoBuf.encodeToByteArray(state)) } } override fun getTargetDataKey() = ESM_REPORTS_KEY override fun importData( toImport: Collection<DataNode<PublicGradleConfigurationReportModel>>, projectData: ProjectData?, project: Project, modelsProvider: IdeModifiableModelsProvider ) { project.service<Cache>().state = toImport.associate { it.data.projectDir to it.data } super.importData(toImport, projectData, project, modelsProvider) } } @Serializable data class PublicGradleConfigurationReportModel( val projectDir: String, val configurations: List<Configuration> ) { @Serializable data class Configuration( val name: String, val dependencies: List<Dependency> ) @Serializable data class Dependency( val groupId: String, val artifactId: String, val version: String ) } private fun GradleConfigurationReportModel.toPublic() = PublicGradleConfigurationReportModel(projectDir, configurations.toPublic()) @JvmName("toPublicGradleConfigurationReportModelConfiguration") private fun List<GradleConfigurationReportModel.Configuration>.toPublic() = map { PublicGradleConfigurationReportModel.Configuration(it.name, it.dependencies.toPublic()) } @JvmName("toPublicGradleConfigurationReportModelDependency") private fun List<GradleConfigurationReportModel.Dependency>.toPublic() = map { PublicGradleConfigurationReportModel.Dependency(it.groupId, it.artifactId, it.version) }
plugins/package-search/gradle/src/com/jetbrains/packagesearch/intellij/plugin/gradle/GradleConfigurationResolver.kt
3755625891
/* NestedKt */fun foo() { block /* NestedKt$foo$1 */{ block /* NestedKt$foo$1$1 */{ block /* NestedKt$foo$1$1$1 */{ block /* NestedKt$foo$1$1$1$1 */{ block /* NestedKt$foo$1$1$1$1$1 */{ block /* NestedKt$foo$1$1$1$1$1$1 */{ block /* NestedKt$foo$1$1$1$1$1$1$1 */{ print("foo") } } } } block /* NestedKt$foo$1$1$1$2 */{ block /* NestedKt$foo$1$1$1$2$1 */{ print("bar") } } } block /* NestedKt$foo$1$1$2 */{ print("baz") } } } } fun block(block: () -> Unit) { block() }
plugins/kotlin/jvm-debugger/test/testData/classNameCalculator/nested.kt
942108409
fun main(args : Array<String>) { println(<caret>) foo() }
plugins/kotlin/live-templates/tests/testData/sout_BeforeCallSpace.exp.kt
810244805
package com.jetbrains.packagesearch.intellij.plugin.kotlin import com.intellij.openapi.util.TextRange import com.intellij.psi.PsiElement import com.intellij.psi.PsiReference import com.jetbrains.packagesearch.intellij.plugin.intentions.PackageSearchUnresolvedReferenceQuickFixProvider class KotlinPackageSearchUnresolvedReferenceQuickFixProvider : PackageSearchUnresolvedReferenceQuickFixProvider<PsiReference>() { @Suppress("UNCHECKED_CAST") // We need to return a raw PsiReference as it's the common supertype override fun getReferenceClass(): Class<PsiReference> = try { Class.forName("org.jetbrains.kotlin.idea.references.KtSimpleNameReference") as Class<PsiReference> } catch (e: ClassNotFoundException) { // If for whatever reason we can't find the KtSimpleNameReference class, which is on the Kotlin plugin classpath DummyPsiReference::class.java as Class<PsiReference> } private class DummyPsiReference : PsiReference { override fun getElement(): PsiElement { TODO("This is a fakeReference") } override fun getRangeInElement(): TextRange { TODO("This is a fakeReference") } override fun resolve(): PsiElement? { TODO("This is a fakeReference") } override fun getCanonicalText(): String { TODO("This is a fakeReference") } override fun handleElementRename(newElementName: String): PsiElement { TODO("This is a fakeReference") } override fun bindToElement(element: PsiElement): PsiElement { TODO("This is a fakeReference") } override fun isReferenceTo(element: PsiElement): Boolean { TODO("This is a fakeReference") } override fun isSoft(): Boolean { TODO("This is a fakeReference") } } }
plugins/package-search/src/com/jetbrains/packagesearch/intellij/plugin/kotlin/KotlinPackageSearchUnresolvedReferenceQuickFixProvider.kt
691683561
class A { } fun A.foo(a: Int, <caret>b: String, c: Any) { } class B { fun bar(a: A) { a.foo(1, "1", "!") } }
plugins/kotlin/idea/tests/testData/refactoring/safeDelete/deleteValueParameter/kotlinValueParameter/safeUsagesExt2.kt
1853813805
package io.fotoapparat.parameter /** * A camera setting. */ interface Parameter
fotoapparat/src/main/java/io/fotoapparat/parameter/Parameter.kt
2301374410
class Wrapper(val f: () -> String) class Test { fun f(): String = "Hello" fun reference() = ::f val foo = Wrapper(referen<caret>ce()) }
plugins/kotlin/idea/tests/testData/refactoring/inline/namedFunction/methodReference.kt
4096220189
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.kotlin.idea.codeInliner import org.jetbrains.kotlin.idea.references.ReferenceAccess import org.jetbrains.kotlin.idea.references.readWriteAccess import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtReferenceExpression class PropertyUsageReplacementStrategy(readReplacement: CodeToInline?, writeReplacement: CodeToInline?) : UsageReplacementStrategy { private val readReplacementStrategy = readReplacement?.let { CallableUsageReplacementStrategy(it, inlineSetter = false) } private val writeReplacementStrategy = writeReplacement?.let { CallableUsageReplacementStrategy(it, inlineSetter = true) } override fun createReplacer(usage: KtReferenceExpression): (() -> KtElement?)? { return when (usage.readWriteAccess(useResolveForReadWrite = true)) { ReferenceAccess.READ -> readReplacementStrategy?.createReplacer(usage) ReferenceAccess.WRITE -> writeReplacementStrategy?.createReplacer(usage) ReferenceAccess.READ_WRITE -> null } } }
plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/codeInliner/PropertyUsageReplacementStrategy.kt
992550849
// EXTRACTION_TARGET: property with getter fun foo(n: Int): Int { return {<selection>n + 1</selection>}() }
plugins/kotlin/idea/tests/testData/refactoring/introduceProperty/extractToFunction.kt
903633080
// WITH_STDLIB // PROBLEM: none @JvmName("fooForJava") fun <caret>foo() {} fun test() { foo() }
plugins/kotlin/idea/tests/testData/inspectionsLocal/unusedSymbol/withJvmNameUsedFromKotlin.kt
3965944216
// "Remove 'suspend' modifier from all functions in hierarchy" "true" open class A { open fun foo() { } open fun foo(n: Int) { } } open class B : A() { override fun foo() { } override fun foo(n: Int) { } } open class B1 : A() { override fun foo(n: Int) { } } open class C : B() { override suspend fun <caret>foo() { } override fun foo(n: Int) { } } open class C1 : B() { override fun foo() { } override fun foo(n: Int) { } }
plugins/kotlin/idea/tests/testData/quickfix/removeSuspend/fakeOverride.kt
341629291
fun foo() { myFor@ for (i in 1..10) { while (x()) { fun localFun(a: Int) { if (a > 0) { br<caret> } } } } } // NUMBER: 0
plugins/kotlin/completion/tests/testData/keywords/NoBreak1.kt
1771742201
// IMPORT: dependency.MyObject.someFun // NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS: 1 fun foo() { someFun() }
plugins/kotlin/idea/tests/testData/addImport/ImportFromObject.kt
1092307773
class MainClass { class NestedClass { object A { class B { object F<caret> } } } }
plugins/kotlin/refIndex/tests/testData/compilerIndex/classOrObject/nestedObject/MainClass.kt
3096157913
package p1 fun test(s: String, i: Int) { p2.foo(<caret>) fun foo(i: Int) = i // EXIST: s
plugins/kotlin/completion/tests/testData/smartMultiFile/FunctionFromAnotherPackage/FunctionFromAnotherPackage.kt
4060913164
package pl.pw.mgr.lightsensor.common import pl.pw.mgr.lightsensor.regression.LinearRegression internal class Calibrator { private val x = mutableListOf<Double>() private val y = mutableListOf<Double>() fun setPoints(collection: Collection<Pair<Float, Float>>) { x.clear() y.clear() collection.forEach { x.add(it.first.toDouble()) y.add(it.second.toDouble()) } } fun compute(value: Float) = when (x.size) { 0 -> value 1 -> trimNegative(value - (x[0] - y[0]).toFloat()) else -> trimNegative(LinearRegression(x.toDoubleArray(), y.toDoubleArray()).compute(value).toFloat()) } private fun trimNegative(value: Float) = if (value < 0) 0f else value }
app/src/main/java/pl/pw/mgr/lightsensor/common/Calibrator.kt
189792113
package com.xmartlabs.bigbang.core.module import android.content.Context import com.squareup.picasso.OkHttp3Downloader import com.squareup.picasso.Picasso import com.xmartlabs.bigbang.core.log.LoggerTree import dagger.Module import dagger.Provides import okhttp3.OkHttpClient import timber.log.Timber import java.util.HashMap import javax.inject.Named import javax.inject.Singleton @Module open class PicassoModule { companion object { private const val LOGGER_KEY_URL = "url" private const val LOGGER_KEY_MESSAGE = "message" } @Provides @Singleton open fun providePicasso(picassoBuilder: Picasso.Builder): Picasso { val providePicasso = picassoBuilder.build() try { Picasso.setSingletonInstance(providePicasso) } catch (illegalStateException: IllegalStateException) { Timber.w(illegalStateException) } return providePicasso } @Provides @Singleton open fun providePicassoBuilder(loggerTree: LoggerTree, context: Context, downloader: OkHttp3Downloader) = Picasso.Builder(context) .downloader(downloader) .listener(getPicassoListener(loggerTree)) private fun getPicassoListener(loggerTree: LoggerTree) = Picasso.Listener { _, uri, exception -> val data = HashMap<String, String>() uri?.let { data.put(LOGGER_KEY_URL, it.toString()) } data.put(LOGGER_KEY_MESSAGE, "Picasso image load failed") loggerTree.log(data, exception) } @Provides @Singleton open fun provideOkHttpDownloader(@Named(OkHttpModule.Companion.CLIENT_PICASSO) client: OkHttpClient) = OkHttp3Downloader(client) }
core/src/main/java/com/xmartlabs/bigbang/core/module/PicassoModule.kt
4076008798
package net.simno.dmach.playback import android.app.Application import android.content.Context import android.media.AudioManager import android.os.Build import androidx.core.content.getSystemService import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.delay import kotlinx.coroutines.flow.take import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith import org.robolectric.Shadows import org.robolectric.annotation.Config @RunWith(AndroidJUnit4::class) @Config(sdk = [Build.VERSION_CODES.P]) class AudioFocusTests { private val audioManager = ApplicationProvider.getApplicationContext<Application>() .getSystemService<AudioManager>()!! private val prefs = ApplicationProvider.getApplicationContext<Application>() .getSharedPreferences("dmach.test", Context.MODE_PRIVATE) @Test fun requestAudioFocusGranted() = runBlocking { val shadowAudioManager = Shadows.shadowOf(audioManager) shadowAudioManager.setNextFocusRequestResponse(AudioManager.AUDIOFOCUS_REQUEST_GRANTED) val audioFocus = AudioFocus(audioManager, prefs) audioFocus.toggleFocus() val expected = listOf(AudioManager.AUDIOFOCUS_GAIN) val actual = audioFocus.audioFocus().take(expected.size).toList() assertThat(actual).isEqualTo(expected) } @Test fun requestAudioFocusDelayed() = runBlocking { val shadowAudioManager = Shadows.shadowOf(audioManager) shadowAudioManager.setNextFocusRequestResponse(AudioManager.AUDIOFOCUS_REQUEST_DELAYED) val audioFocus = AudioFocus(audioManager, prefs) audioFocus.toggleFocus() val expected = listOf(AudioManager.AUDIOFOCUS_LOSS) val actual = audioFocus.audioFocus().take(expected.size).toList() assertThat(actual).isEqualTo(expected) } @Test fun requestAudioFocusFailed() = runBlocking { val shadowAudioManager = Shadows.shadowOf(audioManager) shadowAudioManager.setNextFocusRequestResponse(AudioManager.AUDIOFOCUS_REQUEST_FAILED) val audioFocus = AudioFocus(audioManager, prefs) audioFocus.toggleFocus() val expected = listOf(AudioManager.AUDIOFOCUS_LOSS) val actual = audioFocus.audioFocus().take(expected.size).toList() assertThat(actual).isEqualTo(expected) } @Suppress("UNCHECKED_CAST") @Test fun abandonAudioFocus() = runBlocking { val shadowAudioManager = Shadows.shadowOf(audioManager) shadowAudioManager.setNextFocusRequestResponse(AudioManager.AUDIOFOCUS_REQUEST_GRANTED) val audioFocus = AudioFocus(audioManager, prefs) val expected = listOf( AudioManager.AUDIOFOCUS_NONE, AudioManager.AUDIOFOCUS_GAIN, AudioManager.AUDIOFOCUS_LOSS ) val actual = listOf( async { audioFocus.audioFocus().take(expected.size).toList() }, async { audioFocus.toggleFocus() delay(10L) audioFocus.toggleFocus() } ).awaitAll().first() as List<Int> assertThat(actual).isEqualTo(expected) } @Test fun ignoreAudioFocus() = runBlocking { val shadowAudioManager = Shadows.shadowOf(audioManager) shadowAudioManager.setNextFocusRequestResponse(AudioManager.AUDIOFOCUS_REQUEST_FAILED) val audioFocus = AudioFocus(audioManager, prefs) audioFocus.setIgnoreAudioFocus(true) audioFocus.toggleFocus() val expected = listOf(AudioManager.AUDIOFOCUS_GAIN) val actual = audioFocus.audioFocus().take(expected.size).toList() assertThat(actual).isEqualTo(expected) assertThat(shadowAudioManager.lastAudioFocusRequest).isNull() assertThat(audioFocus.isIgnoreAudioFocus()).isTrue() } }
app/src/test/java/net/simno/dmach/playback/AudioFocusTests.kt
427045276
package com.xmartlabs.bigbang.core.model /** Defines a set of useful information about the current build. */ interface BuildInfo { /** Checks whether or not the current build is in debug mode. */ val isDebug: Boolean /** Checks whether or not the current environment is staging. */ val isStaging: Boolean /** Checks whether or not the current environment is production. */ val isProduction: Boolean }
core/src/main/java/com/xmartlabs/bigbang/core/model/BuildInfo.kt
3492832279
/* * Copyright [2017] [NIRVANA PRIVATE LIMITED] * * 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 com.zwq65.unity.ui.presenter import com.zwq65.unity.data.DataManager import com.zwq65.unity.ui._base.BasePresenter import com.zwq65.unity.ui.contract.TestContract import javax.inject.Inject /** * ================================================ * * Created by NIRVANA on 2017/09/13 * Contact with <[email protected]> * ================================================ */ class TestPresenter<V : TestContract.View> @Inject internal constructor(dataManager: DataManager) : BasePresenter<V>(dataManager), TestContract.Presenter<V> { /** * 加载图片资源 */ override fun loadImages() { dataManager .getRandomImages() .apiSubscribe({ it?.let { mvpView?.loadData(it.data!!) } }, null, true) } override fun test() { } }
app/src/main/java/com/zwq65/unity/ui/presenter/TestPresenter.kt
3761497096
package com.gallery.ui.material.finder import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.AdapterView import android.widget.BaseAdapter import android.widget.FrameLayout import androidx.appcompat.widget.AppCompatTextView import androidx.appcompat.widget.ListPopupWindow import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleEventObserver import androidx.lifecycle.LifecycleOwner import com.gallery.compat.activity.GalleryCompatActivity import com.gallery.compat.finder.GalleryFinderAdapter import com.gallery.core.entity.ScanEntity import com.gallery.ui.material.args.MaterialGalleryBundle import com.gallery.ui.material.databinding.MaterialGalleryItemFinderBinding class MaterialFinderAdapter( private val activity: GalleryCompatActivity, private val viewAnchor: View, private val uiGalleryBundle: MaterialGalleryBundle, private val finderListener: GalleryFinderAdapter.AdapterFinderListener ) : GalleryFinderAdapter, AdapterView.OnItemClickListener { private val finderAdapter: FinderAdapter = FinderAdapter(uiGalleryBundle) { finderEntity, container -> finderListener.onGalleryFinderThumbnails(finderEntity, container) } private val popupWindow: ListPopupWindow = ListPopupWindow(activity).apply { this.anchorView = viewAnchor this.width = uiGalleryBundle.listPopupWidth this.horizontalOffset = uiGalleryBundle.listPopupHorizontalOffset this.verticalOffset = uiGalleryBundle.listPopupVerticalOffset this.isModal = true this.setOnItemClickListener(this@MaterialFinderAdapter) this.setAdapter(finderAdapter) } init { activity.lifecycle.addObserver(object : LifecycleEventObserver { override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) { if (source.lifecycle.currentState == Lifecycle.State.DESTROYED) { activity.lifecycle.removeObserver(this) if (popupWindow.isShowing) { popupWindow.dismiss() } } } }) } override fun show() { popupWindow.show() popupWindow.listView?.setBackgroundColor(uiGalleryBundle.finderItemBackground) } override fun hide() { popupWindow.dismiss() } override fun finderUpdate(finderList: ArrayList<ScanEntity>) { finderAdapter.updateFinder(finderList) } override fun onItemClick(parent: AdapterView<*>, view: View, position: Int, id: Long) { finderListener.onGalleryAdapterItemClick(view, position, finderAdapter.getItem(position)) } private class FinderAdapter( private val uiGalleryBundle: MaterialGalleryBundle, private val displayFinder: (finderEntity: ScanEntity, container: FrameLayout) -> Unit ) : BaseAdapter() { private val list: ArrayList<ScanEntity> = arrayListOf() override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { val finderEntity: ScanEntity = getItem(position) val rootView: View = convertView ?: MaterialGalleryItemFinderBinding.inflate( LayoutInflater.from(parent.context), parent, false ).apply { this.root.tag = ViewHolder(this) }.root val viewHolder: ViewHolder = rootView.tag as ViewHolder viewHolder.appCompatTextView.setTextColor(uiGalleryBundle.finderItemTextColor) viewHolder.appCompatTextView.text = "%s".format(finderEntity.bucketDisplayName) viewHolder.appCompatTextViewCount.setTextColor(uiGalleryBundle.finderItemTextCountColor) viewHolder.appCompatTextViewCount.text = "%s".format(finderEntity.count.toString()) displayFinder.invoke(finderEntity, viewHolder.frameLayout) return rootView } override fun getItem(position: Int): ScanEntity = list[position] override fun getItemId(position: Int): Long = position.toLong() override fun getCount(): Int = list.size fun updateFinder(entities: ArrayList<ScanEntity>) { list.clear() list.addAll(entities) notifyDataSetChanged() } private class ViewHolder(viewBinding: MaterialGalleryItemFinderBinding) { val frameLayout: FrameLayout = viewBinding.ivGalleryFinderIcon val appCompatTextView: AppCompatTextView = viewBinding.tvGalleryFinderName val appCompatTextViewCount: AppCompatTextView = viewBinding.tvGalleryFinderFileCount } } }
material/src/main/java/com/gallery/ui/material/finder/MaterialFinderAdapter.kt
3514102915
package ch.rmy.favicongrabber.grabbers import ch.rmy.favicongrabber.models.IconResult import ch.rmy.favicongrabber.models.ManifestRoot import ch.rmy.favicongrabber.utils.HTMLUtil import ch.rmy.favicongrabber.utils.HttpUtil import ch.rmy.favicongrabber.utils.createComparator import com.google.gson.Gson import com.google.gson.JsonParseException import com.google.gson.JsonSyntaxException import okhttp3.HttpUrl class ManifestGrabber( private val httpUtil: HttpUtil, ) : Grabber { override suspend fun grabIconsFrom(pageUrl: HttpUrl, preferredSize: Int): List<IconResult> { val pageContent = httpUtil.downloadIntoString(pageUrl) ?: return emptyList() val iconUrls = getManifestIcons(pageUrl, pageContent) ?.sortedWith( createComparator(preferredSize) { size } ) ?.mapNotNull { icon -> pageUrl.resolve(icon.src) } ?: return emptyList() val results = mutableListOf<IconResult>() for (iconUrl in iconUrls) { val file = httpUtil.downloadIntoFile(iconUrl) if (file != null) { results.add(IconResult(file)) if (results.size >= PREFERRED_NUMBER_OF_RESULTS) { break } } } return results } private fun getManifestIcons(pageUrl: HttpUrl, pageContent: String) = HTMLUtil.findLinkTags(pageContent, MANIFEST_REL_VALUES) .firstOrNull() ?.href ?.let(pageUrl::resolve) ?.let(httpUtil::downloadIntoString) ?.let(::parseManifest) ?.icons ?.filter { icon -> icon.type !in UNSUPPORTED_ICON_TYPES && icon.purpose !in UNSUPPORTED_ICON_PURPOSES } companion object { private val MANIFEST_REL_VALUES = setOf("manifest") private val UNSUPPORTED_ICON_TYPES = setOf("image/svg+xml") private val UNSUPPORTED_ICON_PURPOSES = setOf("monochrome") private const val PREFERRED_NUMBER_OF_RESULTS = 2 private fun parseManifest(manifestString: String): ManifestRoot? = try { Gson().fromJson(manifestString, ManifestRoot::class.java) } catch (e: JsonSyntaxException) { null } catch (e: JsonParseException) { null } } }
HTTPShortcuts/favicon_grabber/src/main/kotlin/ch/rmy/favicongrabber/grabbers/ManifestGrabber.kt
6288595
// Copyright 2010 Google Inc. // // 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 com.google.android.stardroid.touch import android.util.Log import com.google.android.stardroid.util.MiscUtil.getTag import java.util.concurrent.Executors import java.util.concurrent.ScheduledExecutorService import java.util.concurrent.ScheduledFuture import java.util.concurrent.TimeUnit /** * Given a flung motion event, this class pumps new Motion events out * to simulate an underlying object with some inertia. */ class Flinger(private val listener: (Float, Float) -> Unit) { private val updatesPerSecond = 20 private val timeIntervalMillis = 1000 / updatesPerSecond private val executor: ScheduledExecutorService private var flingTask: ScheduledFuture<*>? = null fun fling(velocityX: Float, velocityY: Float) { Log.d(TAG, "Doing the fling") class PositionUpdater(private var myVelocityX: Float, private var myVelocityY: Float) : Runnable { private val decelFactor = 1.1f private val TOL = 10f override fun run() { if (myVelocityX * myVelocityX + myVelocityY * myVelocityY < TOL) { stop() } listener( myVelocityX / updatesPerSecond, myVelocityY / updatesPerSecond ) myVelocityX /= decelFactor myVelocityY /= decelFactor } } flingTask = executor.scheduleAtFixedRate( PositionUpdater(velocityX, velocityY), 0, timeIntervalMillis.toLong(), TimeUnit.MILLISECONDS ) } /** * Brings the flinger to a dead stop. */ fun stop() { flingTask?.cancel(true) Log.d(TAG, "Fling stopped") } companion object { private val TAG = getTag(Flinger::class.java) } init { executor = Executors.newScheduledThreadPool(1) } }
app/src/main/java/com/google/android/stardroid/touch/Flinger.kt
1159102364
package com.github.kerubistan.kerub.planner.steps.storage.lvm.unallocate import com.github.kerubistan.kerub.data.dynamic.VirtualStorageDeviceDynamicDao import com.github.kerubistan.kerub.host.HostCommandExecutor import com.github.kerubistan.kerub.model.dynamic.VirtualStorageLvmAllocation import com.github.kerubistan.kerub.planner.steps.base.AbstractUnAllocateExecutor import com.github.kerubistan.kerub.utils.junix.storagemanager.lvm.LvmLv class UnAllocateLvExecutor( private val hostExecutor: HostCommandExecutor, override val vssDynDao: VirtualStorageDeviceDynamicDao ) : AbstractUnAllocateExecutor<UnAllocateLv, VirtualStorageLvmAllocation>() { override fun perform(step: UnAllocateLv) { hostExecutor.execute(step.host) { clientSession -> LvmLv.remove(session = clientSession, path = step.allocation.path) } } }
src/main/kotlin/com/github/kerubistan/kerub/planner/steps/storage/lvm/unallocate/UnAllocateLvExecutor.kt
793837243
/* * MIT License * * Copyright (c) 2017 atlarge-research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.atlarge.opendc.model.odc.integration.jpa.schema import com.atlarge.opendc.simulator.Instant import com.atlarge.opendc.simulator.instrumentation.lerp import javax.persistence.Entity /** * The state of a [Machine]. * * @property id The unique identifier of the state. * @property machine The machine of the state. * @property experiment The experiment the machine is running in. * @property time The current moment in time. * @property temperature The temperature of the machine. * @property memoryUsage The memory usage of the machine. * @property load The load of the machine. * @author Fabian Mastenbroek ([email protected]) */ @Entity data class MachineState( val id: Int?, val machine: Machine, val experiment: Experiment, val time: Instant, val temperature: Double, val memoryUsage: Int, val load: Double ) { companion object { /** * A linear interpolator for [MachineState] instances. */ val Interpolator: (Double, MachineState, MachineState) -> MachineState = { f, a, b -> a.copy( id = null, time = lerp(a.time, b.time, f), temperature = lerp(a.temperature, b.temperature, f), memoryUsage = lerp(a.memoryUsage, b.memoryUsage, f), load = lerp(a.load, b.load, f) ) } } }
opendc-model-odc/jpa/src/main/kotlin/com/atlarge/opendc/model/odc/integration/jpa/schema/MachineState.kt
3141528820
/* * Copyright (C) 2022 The Dagger Authors. * * 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 dagger.hilt.android.plugin.util import com.android.build.api.instrumentation.AsmClassVisitorFactory import com.android.build.api.instrumentation.FramesComputationMode import com.android.build.api.instrumentation.InstrumentationParameters import com.android.build.api.instrumentation.InstrumentationScope import com.android.build.api.variant.Component internal class ComponentCompatApi72Impl(private val component: Component) : ComponentCompat() { override val name: String get() = component.name @Suppress("UnstableApiUsage") override fun <ParamT : InstrumentationParameters> transformClassesWith( classVisitorFactoryImplClass: Class<out AsmClassVisitorFactory<ParamT>>, scope: InstrumentationScope, instrumentationParamsConfig: (ParamT) -> Unit ) { component.instrumentation.transformClassesWith( classVisitorFactoryImplClass, scope, instrumentationParamsConfig ) } @Suppress("UnstableApiUsage") override fun setAsmFramesComputationMode(mode: FramesComputationMode) { component.instrumentation.setAsmFramesComputationMode(mode) } }
java/dagger/hilt/android/plugin/agp-wrapper-7-2/src/main/kotlin/dagger/hilt/android/plugin/util/ComponentCompatApi72Impl.kt
1383265786
/* * Copyright (C) 2017 Wiktor Nizio * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * If you like this program, consider donating bitcoin: bc1qncxh5xs6erq6w4qz3a7xl7f50agrgn3w58dsfp */ package pl.org.seva.navigator.navigation import android.Manifest import android.annotation.SuppressLint import android.app.Dialog import android.content.Intent import android.content.pm.PackageManager import android.net.Uri import android.os.Bundle import android.preference.PreferenceManager import android.provider.Settings import android.view.* import android.webkit.WebView import android.widget.Button import androidx.core.content.ContextCompat import androidx.core.content.edit import androidx.fragment.app.Fragment import com.google.android.material.snackbar.Snackbar import kotlinx.android.synthetic.main.fr_navigation.* import pl.org.seva.navigator.R import pl.org.seva.navigator.contact.* import pl.org.seva.navigator.main.data.fb.fbWriter import pl.org.seva.navigator.main.* import pl.org.seva.navigator.main.data.db.contactDao import pl.org.seva.navigator.main.extension.* import pl.org.seva.navigator.main.data.* import pl.org.seva.navigator.main.init.APP_VERSION import pl.org.seva.navigator.main.init.instance import pl.org.seva.navigator.profile.* class NavigationFragment : Fragment(R.layout.fr_navigation) { private val versionName by instance<String>(APP_VERSION) private var isLocationPermissionGranted = false private var dialog: Dialog? = null private var snackbar: Snackbar? = null private lateinit var mapHolder: MapHolder private val navigatorModel by viewModel<NavigatorViewModel>() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setHasOptionsMenu(true) } override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) @SuppressLint("CommitPrefEdits") fun persistCameraPositionAndZoom() = PreferenceManager.getDefaultSharedPreferences(context).edit { putFloat(ZOOM_PROPERTY, mapHolder.zoom) putFloat(LATITUDE_PROPERTY, mapHolder.lastCameraPosition.latitude.toFloat()) putFloat(LONGITUDE_PROPERTY, mapHolder.lastCameraPosition.longitude.toFloat()) } fun ifLocationPermissionGranted(f: () -> Unit) = checkLocationPermission(onGranted = f, onDenied = {}) fun onAddContactClicked() { mapHolder.stopWatchingPeer() if (!isLocationPermissionGranted) { checkLocationPermission() } else if (isLoggedIn) { nav(R.id.action_navigationFragment_to_contactsFragment) } else { showLoginSnackbar() } } fun deleteProfile() { mapHolder.stopWatchingPeer() contacts.clear() contactDao.deleteAll() setShortcuts() fbWriter.deleteMe() logout() } mapHolder = createMapHolder { init(savedInstanceState, root, navigatorModel.contact.value, prefs) checkLocationPermission = ::ifLocationPermissionGranted persistCameraPositionAndZoom = ::persistCameraPositionAndZoom } add_contact_fab.setOnClickListener { onAddContactClicked() } checkLocationPermission() activityRecognition.stateLiveData.observe(this) { state -> when (state) { ActivityRecognitionObservable.STATIONARY -> hud_stationary.visibility = View.VISIBLE ActivityRecognitionObservable.MOVING -> hud_stationary.visibility = View.GONE } } navigatorModel.contact.observe(this) { contact -> mapHolder.contact = contact contact persist prefs } navigatorModel.deleteProfile.observe(this) { result -> if (result) { deleteProfile() navigatorModel.deleteProfile.value = false } } } override fun onDestroy() { super.onDestroy() peerObservable.clearPeerListeners() } override fun onResume() { super.onResume() checkLocationPermission( onGranted = { snackbar?.dismiss() if (!isLoggedIn) { showLoginSnackbar() } }, onDenied = {}) requireActivity().invalidateOptionsMenu() } private inline fun checkLocationPermission( onGranted: () -> Unit = ::onLocationPermissionGranted, onDenied: () -> Unit = ::requestLocationPermission) = if (ContextCompat.checkSelfPermission( requireContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { isLocationPermissionGranted = true onGranted.invoke() } else { onDenied.invoke() } override fun onCreateOptionsMenu(menu: Menu, menuInflater: MenuInflater) = menuInflater.inflate(R.menu.navigation, menu) override fun onPrepareOptionsMenu(menu: Menu) { menu.findItem(R.id.action_help).isVisible = !isLocationPermissionGranted || !isLoggedIn menu.findItem(R.id.action_logout).isVisible = isLoggedIn menu.findItem(R.id.action_delete_user).isVisible = isLoggedIn } override fun onOptionsItemSelected(item: MenuItem): Boolean { fun help(caption: Int, file: String, action: () -> Unit): Boolean { dialog = Dialog(requireContext()).apply { setContentView(R.layout.dialog_help) val web = findViewById<WebView>(R.id.web) web.settings.defaultTextEncodingName = UTF_8 findViewById<Button>(R.id.action_button).setText(caption) val content = requireActivity().assets.open(file).readString() .replace(APP_VERSION_PLACEHOLDER, versionName) .replace(APP_NAME_PLACEHOLDER, getString(R.string.app_name)) web.loadDataWithBaseURL(ASSET_DIR, content, PLAIN_TEXT, UTF_8, null) findViewById<View>(R.id.action_button).setOnClickListener { action() dismiss() } show() } return true } fun showLocationPermissionHelp() = help( R.string.dialog_settings_button, HELP_LOCATION_PERMISSION_EN, action = ::onSettingsClicked) fun showLoginHelp() = help(R.string.dialog_login_button, HELP_LOGIN_EN, action = ::login) return when (item.itemId) { R.id.action_logout -> logout() R.id.action_delete_user -> nav(R.id.action_navigationFragment_to_deleteProfileFragment) R.id.action_help -> if (!isLocationPermissionGranted) showLocationPermissionHelp() else if (!isLoggedIn) { showLoginHelp() } else true R.id.action_settings -> nav(R.id.action_navigationFragment_to_settingsFragmentContainer) R.id.action_credits -> nav(R.id.action_navigationFragment_to_creditsFragment) else -> super.onOptionsItemSelected(item) } } private fun onSettingsClicked() { dialog?.dismiss() val intent = Intent() intent.action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS val uri = Uri.fromParts("package", requireActivity().packageName, null) intent.data = uri startActivity(intent) } private fun requestLocationPermission() { fun showLocationPermissionSnackbar() { snackbar = Snackbar.make( coordinator, R.string.snackbar_permission_request_denied, Snackbar.LENGTH_INDEFINITE) .setAction(R.string.snackbar_retry) { requestLocationPermission() } .apply { show() } } requestPermissions( Permissions.DEFAULT_PERMISSION_REQUEST_ID, arrayOf(Permissions.PermissionRequest( Manifest.permission.ACCESS_FINE_LOCATION, onGranted = ::onLocationPermissionGranted, onDenied = ::showLocationPermissionSnackbar))) } @SuppressLint("MissingPermission") private fun onLocationPermissionGranted() { requireActivity().invalidateOptionsMenu() mapHolder.locationPermissionGranted() if (isLoggedIn) { (requireActivity().application as NavigatorApplication).startService() } } private fun showLoginSnackbar() { snackbar = Snackbar.make( coordinator, R.string.snackbar_please_log_in, Snackbar.LENGTH_INDEFINITE) .setAction(R.string.snackbar_login) { login() } .apply { show() } } override fun onRequestPermissionsResult( requestCode: Int, requests: Array<String>, grantResults: IntArray) = permissions.onRequestPermissionsResult(requestCode, requests, grantResults) private fun login() { dialog?.dismiss() requireActivity().loginActivity(LoginActivity.LOGIN) } private fun logout(): Boolean { null persist prefs mapHolder.stopWatchingPeer() requireActivity().loginActivity(LoginActivity.LOGOUT) return true } override fun onSaveInstanceState(outState: Bundle) { outState.putParcelable(SAVED_PEER_LOCATION, mapHolder.peerLocation) super.onSaveInstanceState(outState) } companion object { private const val UTF_8 = "UTF-8" private const val ASSET_DIR = "file:///android_asset/" private const val PLAIN_TEXT = "text/html" private const val APP_VERSION_PLACEHOLDER = "[app_version]" private const val APP_NAME_PLACEHOLDER = "[app_name]" private const val HELP_LOCATION_PERMISSION_EN = "help_location_permission_en.html" private const val HELP_LOGIN_EN = "help_login_en.html" const val SAVED_PEER_LOCATION = "saved_peer_location" const val ZOOM_PROPERTY = "navigation_map_zoom" const val LATITUDE_PROPERTY = "navigation_map_latitude" const val LONGITUDE_PROPERTY = "navigation_map_longitude" const val DEFAULT_ZOOM = 7.5f } }
navigator/src/main/kotlin/pl/org/seva/navigator/navigation/NavigationFragment.kt
3916907295
package com.orgzly.android.usecase import com.orgzly.android.data.DataRepository import com.orgzly.android.ui.NotePlace class NoteRefile(val noteIds: Set<Long>, val target: NotePlace) : UseCase() { override fun run(dataRepository: DataRepository): UseCaseResult { checkIfValidTarget(dataRepository, target) dataRepository.refileNotes(noteIds, target) val firstRefilledNote = dataRepository.getFirstNote(noteIds) return UseCaseResult( modifiesLocalData = true, triggersSync = SYNC_DATA_MODIFIED, userData = firstRefilledNote ) } /** * Make sure there is no overlap - notes can't be refiled under themselves */ private fun checkIfValidTarget(dataRepository: DataRepository, notePlace: NotePlace) { if (notePlace.noteId != 0L) { val sourceNotes = dataRepository.getNotesAndSubtrees(noteIds) if (sourceNotes.map { it.id }.contains(notePlace.noteId)) { throw TargetInNotesSubtree() } } } class TargetInNotesSubtree : Throwable() }
app/src/main/java/com/orgzly/android/usecase/NoteRefile.kt
3022466683
/* * Copyright 2000-2015 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.debugger.connection import com.intellij.openapi.Disposable import com.intellij.openapi.util.Disposer import com.intellij.util.EventDispatcher import com.intellij.util.io.socketConnection.ConnectionState import com.intellij.util.io.socketConnection.ConnectionStatus import com.intellij.util.io.socketConnection.SocketConnectionListener import org.jetbrains.annotations.TestOnly import org.jetbrains.debugger.DebugEventListener import org.jetbrains.debugger.Vm import org.jetbrains.util.concurrency.AsyncPromise import org.jetbrains.util.concurrency.Promise import org.jetbrains.util.concurrency.ResolvedPromise import org.jetbrains.util.concurrency.isPending import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicReference import javax.swing.event.HyperlinkListener public abstract class VmConnection<T : Vm> : Disposable, BrowserConnection { private val state = AtomicReference(ConnectionState(ConnectionStatus.NOT_CONNECTED)) private val dispatcher = EventDispatcher.create(javaClass<DebugEventListener>()) private val connectionDispatcher = EventDispatcher.create(javaClass<SocketConnectionListener>()) public volatile var vm: T? = null protected set private val opened = AsyncPromise<Any?>() private val closed = AtomicBoolean() override fun getState() = state.get() public fun addDebugListener(listener: DebugEventListener) { dispatcher.addListener(listener) } @TestOnly public fun opened(): Promise<*> = opened override fun executeOnStart(runnable: Runnable) { opened.done { runnable.run() } } protected fun setState(status: ConnectionStatus, message: String? = null, messageLinkListener: HyperlinkListener? = null) { val newState = ConnectionState(status, message, messageLinkListener) val oldState = state.getAndSet(newState) if (oldState == null || oldState.getStatus() != status) { if (status == ConnectionStatus.CONNECTION_FAILED) { opened.setError(newState.getMessage()) } connectionDispatcher.getMulticaster().statusChanged(status) } } override fun addListener(listener: SocketConnectionListener) { connectionDispatcher.addListener(listener) } protected val debugEventListener: DebugEventListener get() = dispatcher.getMulticaster() protected open fun startProcessing() { opened.setResult(null) } public fun close(message: String?, status: ConnectionStatus) { if (!closed.compareAndSet(false, true)) { return } if (opened.isPending) { opened.setError("closed") } setState(status, message) Disposer.dispose(this, false) } override fun dispose() { vm = null } public open fun detachAndClose(): Promise<*> { if (opened.isPending) { opened.setError("detached and closed") } val currentVm = vm val callback: Promise<*> if (currentVm == null) { callback = ResolvedPromise() } else { vm = null callback = currentVm.attachStateManager.detach() } close(null, ConnectionStatus.DISCONNECTED) return callback } }
platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/connection/VmConnection.kt
2310205659
package io.github.adven27.concordion.extensions.exam.ws import io.github.adven27.concordion.extensions.exam.core.ContentTypeConfig import io.github.adven27.concordion.extensions.exam.core.ContentVerifier import io.github.adven27.concordion.extensions.exam.core.ExamExtension.Companion.contentTypeConfig import io.github.adven27.concordion.extensions.exam.core.commands.ExamCommand import io.github.adven27.concordion.extensions.exam.core.commands.ExamVerifyCommand import io.github.adven27.concordion.extensions.exam.core.content import io.github.adven27.concordion.extensions.exam.core.errorMessage import io.github.adven27.concordion.extensions.exam.core.handlebars.matchers.PLACEHOLDER_TYPE import io.github.adven27.concordion.extensions.exam.core.html.Html import io.github.adven27.concordion.extensions.exam.core.html.NAME import io.github.adven27.concordion.extensions.exam.core.html.RowParserEval import io.github.adven27.concordion.extensions.exam.core.html.badge import io.github.adven27.concordion.extensions.exam.core.html.code import io.github.adven27.concordion.extensions.exam.core.html.codeHighlight import io.github.adven27.concordion.extensions.exam.core.html.div import io.github.adven27.concordion.extensions.exam.core.html.html import io.github.adven27.concordion.extensions.exam.core.html.li import io.github.adven27.concordion.extensions.exam.core.html.pill import io.github.adven27.concordion.extensions.exam.core.html.span import io.github.adven27.concordion.extensions.exam.core.html.table import io.github.adven27.concordion.extensions.exam.core.html.tag import io.github.adven27.concordion.extensions.exam.core.html.td import io.github.adven27.concordion.extensions.exam.core.html.th import io.github.adven27.concordion.extensions.exam.core.html.thead import io.github.adven27.concordion.extensions.exam.core.html.tr import io.github.adven27.concordion.extensions.exam.core.html.ul import io.github.adven27.concordion.extensions.exam.core.prettyJson import io.github.adven27.concordion.extensions.exam.core.prettyXml import io.github.adven27.concordion.extensions.exam.core.resolveForContentType import io.github.adven27.concordion.extensions.exam.core.resolveJson import io.github.adven27.concordion.extensions.exam.core.resolveNoType import io.github.adven27.concordion.extensions.exam.core.resolveValues import io.github.adven27.concordion.extensions.exam.core.resolveXml import io.github.adven27.concordion.extensions.exam.core.sameSizeWith import io.github.adven27.concordion.extensions.exam.core.toHtml import io.github.adven27.concordion.extensions.exam.core.toMap import io.github.adven27.concordion.extensions.exam.ws.RequestExecutor.Companion.fromEvaluator import io.restassured.http.ContentType import io.restassured.http.Method import org.concordion.api.CommandCall import org.concordion.api.Element import org.concordion.api.Evaluator import org.concordion.api.Fixture import org.concordion.api.ResultRecorder import java.nio.charset.Charset import java.util.Random private const val HEADERS = "headers" private const val TYPE = "contentType" private const val URL = "url" private const val DESC = "desc" private const val URL_PARAMS = "urlParams" private const val COOKIES = "cookies" private const val VARIABLES = "vars" private const val VALUES = "vals" private const val BODY = "body" private const val MULTI_PART = "multiPart" private const val PART = "part" private const val PART_NAME = "name" private const val FILE_NAME = "fileName" private const val EXPECTED = "expected" private const val WHERE = "where" private const val CASE = "case" private const val VERIFY_AS = "verifyAs" private const val PROTOCOL = "protocol" private const val STATUS_CODE = "statusCode" private const val REASON_PHRASE = "reasonPhrase" private const val FROM = "from" private const val ENDPOINT_HEADER_TMPL = //language=xml """ <div class="input-group input-group-sm"> <span class="input-group-text">%s</span> <span id='%s' class="form-control bg-light text-dark font-weight-light overflow-scroll"/> </div> """ private const val ENDPOINT_TMPL = //language=xml """ <div class="input-group mb-1 mt-1"> <span class="input-group-text %s text-white">%s</span> <span class="form-control bg-light text-primary font-weight-light overflow-scroll" id='%s'/> </div> """ class PutCommand(name: String, tag: String) : RequestCommand(name, tag, Method.PUT) class GetCommand(name: String, tag: String) : RequestCommand(name, tag, Method.GET) class PostCommand(name: String, tag: String) : RequestCommand(name, tag, Method.POST) class DeleteCommand(name: String, tag: String) : RequestCommand(name, tag, Method.DELETE) class SoapCommand(name: String, tag: String) : RequestCommand(name, tag, Method.POST, "application/soap+xml; charset=UTF-8;") sealed class RequestCommand( name: String, tag: String, private val method: Method, private val contentType: String = "application/json" ) : ExamCommand(name, tag) { override fun setUp( commandCall: CommandCall?, evaluator: Evaluator?, resultRecorder: ResultRecorder?, fixture: Fixture ) { val executor = RequestExecutor.newExecutor(evaluator!!).method(method) val root = commandCall.html() val url = attr(root, URL, "/", evaluator) val type = attr(root, TYPE, contentType, evaluator) val cookies = cookies(evaluator, root) val headers = headers(evaluator, root) startTable(root).prependChild( addRequestDescTo(url, type, cookies, headers) ) executor.type(type).url(url).headers(headers).cookies(cookies) } private fun startTable(html: Html): Html = table("class" to "ws-cases")( thead()( th( "Use cases:", "colspan" to "2", "style" to "text-align:center;", "class" to "text-secondary" ) ) ).apply { html.dropAllTo(this) } private fun cookies(eval: Evaluator?, html: Html): String? = html.takeAwayAttr(COOKIES, eval).apply { eval!!.setVariable("#cookies", this) } @Suppress("SpreadOperator") private fun addRequestDescTo(url: String, type: String, cookies: String?, headers: Map<String, String>) = div()( endpoint(url, method), contentType(type), if (cookies != null) cookies(cookies) else null, *headers.map { header(it) }.toTypedArray() ) private fun attr(html: Html, attrName: String, defaultValue: String, eval: Evaluator?): String = html.takeAwayAttr(attrName, defaultValue, eval!!).apply { eval.setVariable("#$attrName", this) } } private fun headers(eval: Evaluator, html: Html): Map<String, String> = html.takeAwayAttr(HEADERS)?.toMap()?.resolveValues(eval) ?: emptyMap() open class RestVerifyCommand(name: String, tag: String) : ExamVerifyCommand(name, tag, RestResultRenderer()) class CaseCheckCommand(name: String, tag: String) : ExamCommand(name, tag) { override fun setUp(cmd: CommandCall?, evaluator: Evaluator?, resultRecorder: ResultRecorder?, fixture: Fixture) { val checkTag = cmd.html() val td = td("colspan" to "2") checkTag.moveChildrenTo(td) checkTag.parent().below(tr()(td)) } } @Suppress("TooManyFunctions") class CaseCommand( tag: String, private val contentTypeConfigs: Map<ContentType, ContentTypeConfig>, private val contentTypeResolver: WsPlugin.ContentTypeResolver ) : RestVerifyCommand(CASE, tag) { private lateinit var contentTypeConfig: ContentTypeConfig private val cases: MutableMap<String, Map<String, Any?>> = LinkedHashMap() private var number = 0 @Suppress("SpreadOperator", "ComplexMethod") override fun setUp(cmd: CommandCall, eval: Evaluator, resultRecorder: ResultRecorder, fixture: Fixture) { val caseRoot = cmd.html() eval.setVariable("#$PLACEHOLDER_TYPE", if (fromEvaluator(eval).xml()) "xml" else "json") cases.clear() caseRoot.firstOptional(WHERE).map { where -> val vars = where.takeAwayAttr(VARIABLES, "", eval).split(",").map { it.trim() } val vals = RowParserEval(where, VALUES, eval).parse() caseRoot.remove(where) cases.putAll( vals.map { it.key to vars.sameSizeWith(it.value).mapIndexed { i, name -> "#$name" to it.value[i] }.toMap() }.toMap() ) }.orElseGet { cases["single"] = HashMap() } val body = caseRoot.first(BODY) val multiPart = caseRoot.first(MULTI_PART) val expected = caseRoot.firstOrThrow(EXPECTED) val contentType = fromEvaluator(eval).contentType() val resolvedType = contentTypeResolver.resolve(contentType) contentTypeConfig = expected.attr(VERIFY_AS)?.let { contentTypeConfig(it) } ?: byContentType(resolvedType) caseRoot.remove(body, expected, multiPart)( cases.map { val expectedToAdd = tag(EXPECTED).text(expected.text()) expected.attr(PROTOCOL)?.let { expectedToAdd.attrs(PROTOCOL to it) } expected.attr(STATUS_CODE)?.let { expectedToAdd.attrs(STATUS_CODE to it) } expected.attr(REASON_PHRASE)?.let { expectedToAdd.attrs(REASON_PHRASE to it) } expected.attr(FROM)?.let { expectedToAdd.attrs(FROM to it) } tag(CASE)( if (body == null) { null } else tag(BODY).text(body.text()).apply { body.attr(FROM)?.let { this.attrs(FROM to it) } }, if (multiPart == null) { null } else { val multiPartArray = multiPart.all(PART).map { html -> tag(PART).text(html.text()).apply { html.attr(NAME)?.let { this.attrs(NAME to it) } html.attr(TYPE)?.let { this.attrs(TYPE to it) } html.attr(FILE_NAME)?.let { this.attrs(FILE_NAME to it) } html.attr(FROM)?.let { this.attrs(FROM to it) } } }.toTypedArray() tag(MULTI_PART)(*multiPartArray) }, expectedToAdd ) } ) } private fun byContentType(resolvedType: ContentType): ContentTypeConfig = contentTypeConfigs[resolvedType] ?: throw IllegalStateException("Content type config for type $resolvedType not found. Provide one through WsPlugin constructor.") override fun execute( commandCall: CommandCall, evaluator: Evaluator, resultRecorder: ResultRecorder, fixture: Fixture ) { val childCommands = commandCall.children val root = commandCall.html() val executor = fromEvaluator(evaluator) val urlParams = root.takeAwayAttr(URL_PARAMS) val cookies = root.takeAwayAttr(COOKIES) val headers = root.takeAwayAttr(HEADERS) for (aCase in cases) { aCase.value.forEach { (key, value) -> evaluator.setVariable(key, value) } cookies?.let { executor.cookies(evaluator.resolveNoType(it)) } headers?.let { executor.headers(headers.toMap().resolveValues(evaluator)) } executor.urlParams(if (urlParams == null) null else evaluator.resolveNoType(urlParams)) val caseTR = tr().insteadOf(root.firstOrThrow(CASE)) val body = caseTR.first(BODY) if (body != null) { val content = body.content(evaluator) val bodyStr = contentTypeConfig.resolver.resolve(content, evaluator) td().insteadOf(body).css(contentTypeConfig.printer.style() + " exp-body") .style("min-width: 20%; width: 50%;") .removeChildren() .text(contentTypeConfig.printer.print(bodyStr)) executor.body(bodyStr) } processMultipart(caseTR, evaluator, executor) childCommands.setUp(evaluator, resultRecorder, fixture) evaluator.setVariable("#exam_response", executor.execute()) childCommands.execute(evaluator, resultRecorder, fixture) childCommands.verify(evaluator, resultRecorder, fixture) val expected = caseTR.firstOrThrow(EXPECTED) val expectedStatus = expectedStatus(expected) val statusEl = span().css("exp-status") check( td("colspan" to (if (body == null) "2" else "1")).css("exp-body").insteadOf(expected), statusEl, evaluator, resultRecorder, executor.contentType(), aCase.key ) if (checkStatusLine(expectedStatus)) { resultRecorder.check(statusEl, executor.statusLine(), statusLine(expectedStatus)) { a, e -> a.trim() == e.trim() } } else { resultRecorder.check(statusEl, executor.statusCode().toString(), expectedStatus.second) { a, e -> a.trim() == e.trim() } } } } private fun statusLine(status: Triple<String?, String, String?>) = "${status.first} ${status.second} ${status.third}" private fun checkStatusLine(status: Triple<String?, String, String?>) = status.third != null private fun processMultipart(caseTR: Html, evaluator: Evaluator, executor: RequestExecutor) { val multiPart = caseTR.first(MULTI_PART) if (multiPart != null) { val table = table() multiPart.all(PART).forEach { val mpType = it.takeAwayAttr(TYPE) val name = it.takeAwayAttr(PART_NAME) val fileName = it.takeAwayAttr(FILE_NAME) val content = it.content(evaluator) table( tr()( td()(badge("Part", "light")), td()( name?.let { badge(name.toString(), "warning") }, mpType?.let { badge(mpType.toString(), "info") }, fileName?.let { code(fileName.toString()) } ) ) ) val mpStr: String if (executor.xml(mpType.toString())) { mpStr = evaluator.resolveXml(content) table( tr()( td()(badge("Content", "dark")), td(mpStr.prettyXml()).css("xml") ) ) } else { mpStr = evaluator.resolveJson(content) table( tr()( td()(badge("Content", "dark")), td(mpStr.prettyJson()).css("json") ) ) } if (mpType == null) { executor.multiPart( name.toString(), fileName.toString(), mpStr.toByteArray(Charset.forName("UTF-8")) ) } else { executor.multiPart(name.toString(), mpType.toString(), mpStr) } } multiPart.removeChildren() td().insteadOf(multiPart)(table) } } private fun expectedStatus(expected: Html) = Triple( expected.takeAwayAttr(PROTOCOL, "HTTP/1.1").trim(), expected.takeAwayAttr(STATUS_CODE, "200").trim(), expected.takeAwayAttr(REASON_PHRASE)?.trim() ) override fun verify(cmd: CommandCall, evaluator: Evaluator, resultRecorder: ResultRecorder, fixture: Fixture) { val rt = cmd.html() val wheres = rt.el.getChildElements("tr") if (wheres.size > 2) { rt.below( tr()( td("colspan" to "2")( whereCaseTemplate( wheres.withIndex().groupBy { it.index / 2 } .map { entry -> tab(System.currentTimeMillis(), entry.value.map { it.value }) } ) ) ) ) } val caseDesc = caseDesc(rt.attr(DESC)) rt.attrs("data-type" to CASE, "id" to caseDesc).prependChild( tr()( td(caseDesc, "colspan" to "2").muted().css("bg-light").style("border-bottom: 1px solid lightgray;") ) ) } private fun caseDesc(desc: String?): String = "${++number}) " + (desc ?: "") @Suppress("LongParameterList") private fun check( root: Html, statusEl: Html, eval: Evaluator, resultRecorder: ResultRecorder, contentType: String, caseTitle: String ) { val executor = fromEvaluator(eval) check( executor.responseBody(), eval.resolveForContentType(root.content(eval), contentType), resultRecorder, root ) val trBodies = root.parent().deepClone() val case = root.parent().parent() case.remove(root.parent()) case()( trCaseDesc(caseTitle, statusEl, executor.hasRequestBody(), executor.responseTime(), executor.httpDesc()), trBodies ) } private fun check(actual: String, expected: String, resultRecorder: ResultRecorder, root: Html) { (contentTypeConfig.verifier to contentTypeConfig.printer).let { (verifier, printer) -> verifier.verify(expected, actual).onFailure { when (it) { is ContentVerifier.Fail -> { val diff = div().css(printer.style()) val (_, errorMsg) = errorMessage(message = it.details, html = diff, type = printer.style()) root.removeChildren()(errorMsg) resultRecorder.failure(diff, printer.print(it.actual), printer.print(it.expected)) } else -> throw it } }.onSuccess { root.removeChildren()( tag("exp").text(printer.print(expected)) css printer.style(), tag("act").text(printer.print(actual)) css printer.style() ) resultRecorder.pass(root) } } } @Suppress("SpreadOperator", "MagicNumber") private fun trCaseDesc(caseTitle: String, statusEl: Html, hasReqBody: Boolean, responseTime: Long, desc: String) = tr("data-case-title" to caseTitle)( td().style("width: ${if (hasReqBody) 50 else 100}%;")( div().css("httpstyle")( codeHighlight(desc, "http") ) ), td("style" to "padding-left: 0;")( tag("small")( statusEl, pill("${responseTime}ms", "light") ) ) ) } private fun endpoint(url: String, method: Method): Html = "endpoint-${Random().nextInt()}".let { id -> String.format(ENDPOINT_TMPL, method.background(), method.name, id).toHtml().apply { findBy(id)?.text(url) } } private fun Method.background() = when (this) { Method.GET -> "bg-primary" Method.POST -> "bg-success" Method.PUT -> "bg-warning" Method.PATCH -> "bg-warning" Method.DELETE -> "bg-danger" else -> "bg-dark" } private fun header(it: Map.Entry<String, String>) = "header-${Random().nextInt()}".let { id -> String.format(ENDPOINT_HEADER_TMPL, it.key, id).toHtml().apply { findBy(id)?.text(it.value) } } private fun cookies(cookies: String) = "header-${Random().nextInt()}".let { id -> String.format(ENDPOINT_HEADER_TMPL, "Cookies", id).toHtml().apply { findBy(id)?.text(cookies) } } private fun contentType(type: String) = "header-${Random().nextInt()}".let { id -> String.format(ENDPOINT_HEADER_TMPL, "Content-Type", id).toHtml().apply { findBy(id)?.text(type) } } private fun whereCaseTemplate(tabs: List<Pair<Html, Html>>): Html = tabs.let { list -> val failed = tabs.indexOfFirst { it.first.attr("class")?.contains("rest-failure") ?: false } val active = if (failed == -1) 0 else failed return div()( tag("nav")( ul("class" to "nav nav-tabs", "role" to "tablist")( list.mapIndexed { i, p -> li().css("nav-item")( p.first.apply { if (i == active) css("active show") } ) } ) ), div()( div("class" to "tab-content")( list.mapIndexed { i, p -> p.second.apply { if (i == active) css("active show") } } ) ) ) } private fun tab(id: Long, trs: List<Element>): Pair<Html, Html> { val cnt = trs.map { Html(it.deepClone()) } val parentElement = trs[0].parentElement parentElement.removeChild(trs[0]) parentElement.removeChild(trs[1]) val fail = cnt.any { it.descendants("fail").isNotEmpty() } val name = Random().nextInt() return Html( "button", cnt[0].attrOrFail("data-case-title"), "id" to "nav-$name-$id-tab", "class" to "nav-link small ${if (fail) "rest-failure" else "text-success"} ", "data-bs-toggle" to "tab", "data-bs-target" to "#nav-$name-$id", "role" to "tab", "aria-controls" to "nav-$name-$id", "aria-selected" to "false", "onclick" to "setTimeout(() => { window.dispatchEvent(new Event('resize')); }, 200)" ) to div( "class" to "tab-pane fade", "id" to "nav-$name-$id", "role" to "tabpanel", "aria-labelledby" to "nav-$name-$id-tab", )(table()(cnt)) }
exam-ws/src/main/java/io/github/adven27/concordion/extensions/exam/ws/RestCommands.kt
2818669054
// automatically generated by the FlatBuffers compiler, do not modify package MyGame.Example import java.nio.* import kotlin.math.sign import com.google.flatbuffers.* /** * an example documentation comment: monster object */ @Suppress("unused") @ExperimentalUnsignedTypes class Monster : Table() { fun __init(_i: Int, _bb: ByteBuffer) { __reset(_i, _bb) } fun __assign(_i: Int, _bb: ByteBuffer) : Monster { __init(_i, _bb) return this } val pos : MyGame.Example.Vec3? get() = pos(MyGame.Example.Vec3()) fun pos(obj: MyGame.Example.Vec3) : MyGame.Example.Vec3? { val o = __offset(4) return if (o != 0) { obj.__assign(o + bb_pos, bb) } else { null } } val mana : Short get() { val o = __offset(6) return if(o != 0) bb.getShort(o + bb_pos) else 150 } fun mutateMana(mana: Short) : Boolean { val o = __offset(6) return if (o != 0) { bb.putShort(o + bb_pos, mana) true } else { false } } val hp : Short get() { val o = __offset(8) return if(o != 0) bb.getShort(o + bb_pos) else 100 } fun mutateHp(hp: Short) : Boolean { val o = __offset(8) return if (o != 0) { bb.putShort(o + bb_pos, hp) true } else { false } } val name : String? get() { val o = __offset(10) return if (o != 0) __string(o + bb_pos) else null } val nameAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(10, 1) fun nameInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 10, 1) fun inventory(j: Int) : UByte { val o = __offset(14) return if (o != 0) { bb.get(__vector(o) + j * 1).toUByte() } else { 0u } } val inventoryLength : Int get() { val o = __offset(14); return if (o != 0) __vector_len(o) else 0 } val inventoryAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(14, 1) fun inventoryInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 14, 1) fun mutateInventory(j: Int, inventory: UByte) : Boolean { val o = __offset(14) return if (o != 0) { bb.put(__vector(o) + j * 1, inventory.toByte()) true } else { false } } val color : UByte get() { val o = __offset(16) return if(o != 0) bb.get(o + bb_pos).toUByte() else 8u } fun mutateColor(color: UByte) : Boolean { val o = __offset(16) return if (o != 0) { bb.put(o + bb_pos, color.toByte()) true } else { false } } val testType : UByte get() { val o = __offset(18) return if(o != 0) bb.get(o + bb_pos).toUByte() else 0u } fun mutateTestType(testType: UByte) : Boolean { val o = __offset(18) return if (o != 0) { bb.put(o + bb_pos, testType.toByte()) true } else { false } } fun test(obj: Table) : Table? { val o = __offset(20); return if (o != 0) __union(obj, o) else null } fun test4(j: Int) : MyGame.Example.Test? = test4(MyGame.Example.Test(), j) fun test4(obj: MyGame.Example.Test, j: Int) : MyGame.Example.Test? { val o = __offset(22) return if (o != 0) { obj.__assign(__vector(o) + j * 4, bb) } else { null } } val test4Length : Int get() { val o = __offset(22); return if (o != 0) __vector_len(o) else 0 } fun testarrayofstring(j: Int) : String? { val o = __offset(24) return if (o != 0) { __string(__vector(o) + j * 4) } else { null } } val testarrayofstringLength : Int get() { val o = __offset(24); return if (o != 0) __vector_len(o) else 0 } /** * an example documentation comment: this will end up in the generated code * multiline too */ fun testarrayoftables(j: Int) : MyGame.Example.Monster? = testarrayoftables(MyGame.Example.Monster(), j) fun testarrayoftables(obj: MyGame.Example.Monster, j: Int) : MyGame.Example.Monster? { val o = __offset(26) return if (o != 0) { obj.__assign(__indirect(__vector(o) + j * 4), bb) } else { null } } val testarrayoftablesLength : Int get() { val o = __offset(26); return if (o != 0) __vector_len(o) else 0 } fun testarrayoftablesByKey(key: String) : MyGame.Example.Monster? { val o = __offset(26) return if (o != 0) { MyGame.Example.Monster.__lookup_by_key(null, __vector(o), key, bb) } else { null } } fun testarrayoftablesByKey(obj: MyGame.Example.Monster, key: String) : MyGame.Example.Monster? { val o = __offset(26) return if (o != 0) { MyGame.Example.Monster.__lookup_by_key(obj, __vector(o), key, bb) } else { null } } val enemy : MyGame.Example.Monster? get() = enemy(MyGame.Example.Monster()) fun enemy(obj: MyGame.Example.Monster) : MyGame.Example.Monster? { val o = __offset(28) return if (o != 0) { obj.__assign(__indirect(o + bb_pos), bb) } else { null } } fun testnestedflatbuffer(j: Int) : UByte { val o = __offset(30) return if (o != 0) { bb.get(__vector(o) + j * 1).toUByte() } else { 0u } } val testnestedflatbufferLength : Int get() { val o = __offset(30); return if (o != 0) __vector_len(o) else 0 } val testnestedflatbufferAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(30, 1) fun testnestedflatbufferInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 30, 1) val testnestedflatbufferAsMonster : MyGame.Example.Monster? get() = testnestedflatbufferAsMonster(MyGame.Example.Monster()) fun testnestedflatbufferAsMonster(obj: MyGame.Example.Monster) : MyGame.Example.Monster? { val o = __offset(30) return if (o != 0) { obj.__assign(__indirect(__vector(o)), bb) } else { null } } fun mutateTestnestedflatbuffer(j: Int, testnestedflatbuffer: UByte) : Boolean { val o = __offset(30) return if (o != 0) { bb.put(__vector(o) + j * 1, testnestedflatbuffer.toByte()) true } else { false } } val testempty : MyGame.Example.Stat? get() = testempty(MyGame.Example.Stat()) fun testempty(obj: MyGame.Example.Stat) : MyGame.Example.Stat? { val o = __offset(32) return if (o != 0) { obj.__assign(__indirect(o + bb_pos), bb) } else { null } } val testbool : Boolean get() { val o = __offset(34) return if(o != 0) 0.toByte() != bb.get(o + bb_pos) else false } fun mutateTestbool(testbool: Boolean) : Boolean { val o = __offset(34) return if (o != 0) { bb.put(o + bb_pos, (if(testbool) 1 else 0).toByte()) true } else { false } } val testhashs32Fnv1 : Int get() { val o = __offset(36) return if(o != 0) bb.getInt(o + bb_pos) else 0 } fun mutateTesthashs32Fnv1(testhashs32Fnv1: Int) : Boolean { val o = __offset(36) return if (o != 0) { bb.putInt(o + bb_pos, testhashs32Fnv1) true } else { false } } val testhashu32Fnv1 : UInt get() { val o = __offset(38) return if(o != 0) bb.getInt(o + bb_pos).toUInt() else 0u } fun mutateTesthashu32Fnv1(testhashu32Fnv1: UInt) : Boolean { val o = __offset(38) return if (o != 0) { bb.putInt(o + bb_pos, testhashu32Fnv1.toInt()) true } else { false } } val testhashs64Fnv1 : Long get() { val o = __offset(40) return if(o != 0) bb.getLong(o + bb_pos) else 0L } fun mutateTesthashs64Fnv1(testhashs64Fnv1: Long) : Boolean { val o = __offset(40) return if (o != 0) { bb.putLong(o + bb_pos, testhashs64Fnv1) true } else { false } } val testhashu64Fnv1 : ULong get() { val o = __offset(42) return if(o != 0) bb.getLong(o + bb_pos).toULong() else 0UL } fun mutateTesthashu64Fnv1(testhashu64Fnv1: ULong) : Boolean { val o = __offset(42) return if (o != 0) { bb.putLong(o + bb_pos, testhashu64Fnv1.toLong()) true } else { false } } val testhashs32Fnv1a : Int get() { val o = __offset(44) return if(o != 0) bb.getInt(o + bb_pos) else 0 } fun mutateTesthashs32Fnv1a(testhashs32Fnv1a: Int) : Boolean { val o = __offset(44) return if (o != 0) { bb.putInt(o + bb_pos, testhashs32Fnv1a) true } else { false } } val testhashu32Fnv1a : UInt get() { val o = __offset(46) return if(o != 0) bb.getInt(o + bb_pos).toUInt() else 0u } fun mutateTesthashu32Fnv1a(testhashu32Fnv1a: UInt) : Boolean { val o = __offset(46) return if (o != 0) { bb.putInt(o + bb_pos, testhashu32Fnv1a.toInt()) true } else { false } } val testhashs64Fnv1a : Long get() { val o = __offset(48) return if(o != 0) bb.getLong(o + bb_pos) else 0L } fun mutateTesthashs64Fnv1a(testhashs64Fnv1a: Long) : Boolean { val o = __offset(48) return if (o != 0) { bb.putLong(o + bb_pos, testhashs64Fnv1a) true } else { false } } val testhashu64Fnv1a : ULong get() { val o = __offset(50) return if(o != 0) bb.getLong(o + bb_pos).toULong() else 0UL } fun mutateTesthashu64Fnv1a(testhashu64Fnv1a: ULong) : Boolean { val o = __offset(50) return if (o != 0) { bb.putLong(o + bb_pos, testhashu64Fnv1a.toLong()) true } else { false } } fun testarrayofbools(j: Int) : Boolean { val o = __offset(52) return if (o != 0) { 0.toByte() != bb.get(__vector(o) + j * 1) } else { false } } val testarrayofboolsLength : Int get() { val o = __offset(52); return if (o != 0) __vector_len(o) else 0 } val testarrayofboolsAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(52, 1) fun testarrayofboolsInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 52, 1) fun mutateTestarrayofbools(j: Int, testarrayofbools: Boolean) : Boolean { val o = __offset(52) return if (o != 0) { bb.put(__vector(o) + j * 1, (if(testarrayofbools) 1 else 0).toByte()) true } else { false } } val testf : Float get() { val o = __offset(54) return if(o != 0) bb.getFloat(o + bb_pos) else 3.14159f } fun mutateTestf(testf: Float) : Boolean { val o = __offset(54) return if (o != 0) { bb.putFloat(o + bb_pos, testf) true } else { false } } val testf2 : Float get() { val o = __offset(56) return if(o != 0) bb.getFloat(o + bb_pos) else 3.0f } fun mutateTestf2(testf2: Float) : Boolean { val o = __offset(56) return if (o != 0) { bb.putFloat(o + bb_pos, testf2) true } else { false } } val testf3 : Float get() { val o = __offset(58) return if(o != 0) bb.getFloat(o + bb_pos) else 0.0f } fun mutateTestf3(testf3: Float) : Boolean { val o = __offset(58) return if (o != 0) { bb.putFloat(o + bb_pos, testf3) true } else { false } } fun testarrayofstring2(j: Int) : String? { val o = __offset(60) return if (o != 0) { __string(__vector(o) + j * 4) } else { null } } val testarrayofstring2Length : Int get() { val o = __offset(60); return if (o != 0) __vector_len(o) else 0 } fun testarrayofsortedstruct(j: Int) : MyGame.Example.Ability? = testarrayofsortedstruct(MyGame.Example.Ability(), j) fun testarrayofsortedstruct(obj: MyGame.Example.Ability, j: Int) : MyGame.Example.Ability? { val o = __offset(62) return if (o != 0) { obj.__assign(__vector(o) + j * 8, bb) } else { null } } val testarrayofsortedstructLength : Int get() { val o = __offset(62); return if (o != 0) __vector_len(o) else 0 } fun flex(j: Int) : UByte { val o = __offset(64) return if (o != 0) { bb.get(__vector(o) + j * 1).toUByte() } else { 0u } } val flexLength : Int get() { val o = __offset(64); return if (o != 0) __vector_len(o) else 0 } val flexAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(64, 1) fun flexInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 64, 1) fun mutateFlex(j: Int, flex: UByte) : Boolean { val o = __offset(64) return if (o != 0) { bb.put(__vector(o) + j * 1, flex.toByte()) true } else { false } } fun test5(j: Int) : MyGame.Example.Test? = test5(MyGame.Example.Test(), j) fun test5(obj: MyGame.Example.Test, j: Int) : MyGame.Example.Test? { val o = __offset(66) return if (o != 0) { obj.__assign(__vector(o) + j * 4, bb) } else { null } } val test5Length : Int get() { val o = __offset(66); return if (o != 0) __vector_len(o) else 0 } fun vectorOfLongs(j: Int) : Long { val o = __offset(68) return if (o != 0) { bb.getLong(__vector(o) + j * 8) } else { 0 } } val vectorOfLongsLength : Int get() { val o = __offset(68); return if (o != 0) __vector_len(o) else 0 } val vectorOfLongsAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(68, 8) fun vectorOfLongsInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 68, 8) fun mutateVectorOfLongs(j: Int, vectorOfLongs: Long) : Boolean { val o = __offset(68) return if (o != 0) { bb.putLong(__vector(o) + j * 8, vectorOfLongs) true } else { false } } fun vectorOfDoubles(j: Int) : Double { val o = __offset(70) return if (o != 0) { bb.getDouble(__vector(o) + j * 8) } else { 0.0 } } val vectorOfDoublesLength : Int get() { val o = __offset(70); return if (o != 0) __vector_len(o) else 0 } val vectorOfDoublesAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(70, 8) fun vectorOfDoublesInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 70, 8) fun mutateVectorOfDoubles(j: Int, vectorOfDoubles: Double) : Boolean { val o = __offset(70) return if (o != 0) { bb.putDouble(__vector(o) + j * 8, vectorOfDoubles) true } else { false } } val parentNamespaceTest : MyGame.InParentNamespace? get() = parentNamespaceTest(MyGame.InParentNamespace()) fun parentNamespaceTest(obj: MyGame.InParentNamespace) : MyGame.InParentNamespace? { val o = __offset(72) return if (o != 0) { obj.__assign(__indirect(o + bb_pos), bb) } else { null } } fun vectorOfReferrables(j: Int) : MyGame.Example.Referrable? = vectorOfReferrables(MyGame.Example.Referrable(), j) fun vectorOfReferrables(obj: MyGame.Example.Referrable, j: Int) : MyGame.Example.Referrable? { val o = __offset(74) return if (o != 0) { obj.__assign(__indirect(__vector(o) + j * 4), bb) } else { null } } val vectorOfReferrablesLength : Int get() { val o = __offset(74); return if (o != 0) __vector_len(o) else 0 } fun vectorOfReferrablesByKey(key: ULong) : MyGame.Example.Referrable? { val o = __offset(74) return if (o != 0) { MyGame.Example.Referrable.__lookup_by_key(null, __vector(o), key, bb) } else { null } } fun vectorOfReferrablesByKey(obj: MyGame.Example.Referrable, key: ULong) : MyGame.Example.Referrable? { val o = __offset(74) return if (o != 0) { MyGame.Example.Referrable.__lookup_by_key(obj, __vector(o), key, bb) } else { null } } val singleWeakReference : ULong get() { val o = __offset(76) return if(o != 0) bb.getLong(o + bb_pos).toULong() else 0UL } fun mutateSingleWeakReference(singleWeakReference: ULong) : Boolean { val o = __offset(76) return if (o != 0) { bb.putLong(o + bb_pos, singleWeakReference.toLong()) true } else { false } } fun vectorOfWeakReferences(j: Int) : ULong { val o = __offset(78) return if (o != 0) { bb.getLong(__vector(o) + j * 8).toULong() } else { 0uL } } val vectorOfWeakReferencesLength : Int get() { val o = __offset(78); return if (o != 0) __vector_len(o) else 0 } val vectorOfWeakReferencesAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(78, 8) fun vectorOfWeakReferencesInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 78, 8) fun mutateVectorOfWeakReferences(j: Int, vectorOfWeakReferences: ULong) : Boolean { val o = __offset(78) return if (o != 0) { bb.putLong(__vector(o) + j * 8, vectorOfWeakReferences.toLong()) true } else { false } } fun vectorOfStrongReferrables(j: Int) : MyGame.Example.Referrable? = vectorOfStrongReferrables(MyGame.Example.Referrable(), j) fun vectorOfStrongReferrables(obj: MyGame.Example.Referrable, j: Int) : MyGame.Example.Referrable? { val o = __offset(80) return if (o != 0) { obj.__assign(__indirect(__vector(o) + j * 4), bb) } else { null } } val vectorOfStrongReferrablesLength : Int get() { val o = __offset(80); return if (o != 0) __vector_len(o) else 0 } fun vectorOfStrongReferrablesByKey(key: ULong) : MyGame.Example.Referrable? { val o = __offset(80) return if (o != 0) { MyGame.Example.Referrable.__lookup_by_key(null, __vector(o), key, bb) } else { null } } fun vectorOfStrongReferrablesByKey(obj: MyGame.Example.Referrable, key: ULong) : MyGame.Example.Referrable? { val o = __offset(80) return if (o != 0) { MyGame.Example.Referrable.__lookup_by_key(obj, __vector(o), key, bb) } else { null } } val coOwningReference : ULong get() { val o = __offset(82) return if(o != 0) bb.getLong(o + bb_pos).toULong() else 0UL } fun mutateCoOwningReference(coOwningReference: ULong) : Boolean { val o = __offset(82) return if (o != 0) { bb.putLong(o + bb_pos, coOwningReference.toLong()) true } else { false } } fun vectorOfCoOwningReferences(j: Int) : ULong { val o = __offset(84) return if (o != 0) { bb.getLong(__vector(o) + j * 8).toULong() } else { 0uL } } val vectorOfCoOwningReferencesLength : Int get() { val o = __offset(84); return if (o != 0) __vector_len(o) else 0 } val vectorOfCoOwningReferencesAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(84, 8) fun vectorOfCoOwningReferencesInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 84, 8) fun mutateVectorOfCoOwningReferences(j: Int, vectorOfCoOwningReferences: ULong) : Boolean { val o = __offset(84) return if (o != 0) { bb.putLong(__vector(o) + j * 8, vectorOfCoOwningReferences.toLong()) true } else { false } } val nonOwningReference : ULong get() { val o = __offset(86) return if(o != 0) bb.getLong(o + bb_pos).toULong() else 0UL } fun mutateNonOwningReference(nonOwningReference: ULong) : Boolean { val o = __offset(86) return if (o != 0) { bb.putLong(o + bb_pos, nonOwningReference.toLong()) true } else { false } } fun vectorOfNonOwningReferences(j: Int) : ULong { val o = __offset(88) return if (o != 0) { bb.getLong(__vector(o) + j * 8).toULong() } else { 0uL } } val vectorOfNonOwningReferencesLength : Int get() { val o = __offset(88); return if (o != 0) __vector_len(o) else 0 } val vectorOfNonOwningReferencesAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(88, 8) fun vectorOfNonOwningReferencesInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 88, 8) fun mutateVectorOfNonOwningReferences(j: Int, vectorOfNonOwningReferences: ULong) : Boolean { val o = __offset(88) return if (o != 0) { bb.putLong(__vector(o) + j * 8, vectorOfNonOwningReferences.toLong()) true } else { false } } val anyUniqueType : UByte get() { val o = __offset(90) return if(o != 0) bb.get(o + bb_pos).toUByte() else 0u } fun mutateAnyUniqueType(anyUniqueType: UByte) : Boolean { val o = __offset(90) return if (o != 0) { bb.put(o + bb_pos, anyUniqueType.toByte()) true } else { false } } fun anyUnique(obj: Table) : Table? { val o = __offset(92); return if (o != 0) __union(obj, o) else null } val anyAmbiguousType : UByte get() { val o = __offset(94) return if(o != 0) bb.get(o + bb_pos).toUByte() else 0u } fun mutateAnyAmbiguousType(anyAmbiguousType: UByte) : Boolean { val o = __offset(94) return if (o != 0) { bb.put(o + bb_pos, anyAmbiguousType.toByte()) true } else { false } } fun anyAmbiguous(obj: Table) : Table? { val o = __offset(96); return if (o != 0) __union(obj, o) else null } fun vectorOfEnums(j: Int) : UByte { val o = __offset(98) return if (o != 0) { bb.get(__vector(o) + j * 1).toUByte() } else { 0u } } val vectorOfEnumsLength : Int get() { val o = __offset(98); return if (o != 0) __vector_len(o) else 0 } val vectorOfEnumsAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(98, 1) fun vectorOfEnumsInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 98, 1) fun mutateVectorOfEnums(j: Int, vectorOfEnums: UByte) : Boolean { val o = __offset(98) return if (o != 0) { bb.put(__vector(o) + j * 1, vectorOfEnums.toByte()) true } else { false } } override fun keysCompare(o1: Int, o2: Int, _bb: ByteBuffer) : Int { return compareStrings(__offset(10, o1, _bb), __offset(10, o2, _bb), _bb) } companion object { fun validateVersion() = Constants.FLATBUFFERS_1_11_1() fun getRootAsMonster(_bb: ByteBuffer): Monster = getRootAsMonster(_bb, Monster()) fun getRootAsMonster(_bb: ByteBuffer, obj: Monster): Monster { _bb.order(ByteOrder.LITTLE_ENDIAN) return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)) } fun MonsterBufferHasIdentifier(_bb: ByteBuffer) : Boolean = __has_identifier(_bb, "MONS") fun startMonster(builder: FlatBufferBuilder) = builder.startTable(48) fun addPos(builder: FlatBufferBuilder, pos: Int) = builder.addStruct(0, pos, 0) fun addMana(builder: FlatBufferBuilder, mana: Short) = builder.addShort(1, mana, 150) fun addHp(builder: FlatBufferBuilder, hp: Short) = builder.addShort(2, hp, 100) fun addName(builder: FlatBufferBuilder, name: Int) = builder.addOffset(3, name, 0) fun addInventory(builder: FlatBufferBuilder, inventory: Int) = builder.addOffset(5, inventory, 0) fun createInventoryVector(builder: FlatBufferBuilder, data: UByteArray) : Int { builder.startVector(1, data.size, 1) for (i in data.size - 1 downTo 0) { builder.addByte(data[i].toByte()) } return builder.endVector() } fun startInventoryVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(1, numElems, 1) fun addColor(builder: FlatBufferBuilder, color: UByte) = builder.addByte(6, color.toByte(), 8) fun addTestType(builder: FlatBufferBuilder, testType: UByte) = builder.addByte(7, testType.toByte(), 0) fun addTest(builder: FlatBufferBuilder, test: Int) = builder.addOffset(8, test, 0) fun addTest4(builder: FlatBufferBuilder, test4: Int) = builder.addOffset(9, test4, 0) fun startTest4Vector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(4, numElems, 2) fun addTestarrayofstring(builder: FlatBufferBuilder, testarrayofstring: Int) = builder.addOffset(10, testarrayofstring, 0) fun createTestarrayofstringVector(builder: FlatBufferBuilder, data: IntArray) : Int { builder.startVector(4, data.size, 4) for (i in data.size - 1 downTo 0) { builder.addOffset(data[i]) } return builder.endVector() } fun startTestarrayofstringVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(4, numElems, 4) fun addTestarrayoftables(builder: FlatBufferBuilder, testarrayoftables: Int) = builder.addOffset(11, testarrayoftables, 0) fun createTestarrayoftablesVector(builder: FlatBufferBuilder, data: IntArray) : Int { builder.startVector(4, data.size, 4) for (i in data.size - 1 downTo 0) { builder.addOffset(data[i]) } return builder.endVector() } fun startTestarrayoftablesVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(4, numElems, 4) fun addEnemy(builder: FlatBufferBuilder, enemy: Int) = builder.addOffset(12, enemy, 0) fun addTestnestedflatbuffer(builder: FlatBufferBuilder, testnestedflatbuffer: Int) = builder.addOffset(13, testnestedflatbuffer, 0) fun createTestnestedflatbufferVector(builder: FlatBufferBuilder, data: UByteArray) : Int { builder.startVector(1, data.size, 1) for (i in data.size - 1 downTo 0) { builder.addByte(data[i].toByte()) } return builder.endVector() } fun startTestnestedflatbufferVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(1, numElems, 1) fun addTestempty(builder: FlatBufferBuilder, testempty: Int) = builder.addOffset(14, testempty, 0) fun addTestbool(builder: FlatBufferBuilder, testbool: Boolean) = builder.addBoolean(15, testbool, false) fun addTesthashs32Fnv1(builder: FlatBufferBuilder, testhashs32Fnv1: Int) = builder.addInt(16, testhashs32Fnv1, 0) fun addTesthashu32Fnv1(builder: FlatBufferBuilder, testhashu32Fnv1: UInt) = builder.addInt(17, testhashu32Fnv1.toInt(), 0) fun addTesthashs64Fnv1(builder: FlatBufferBuilder, testhashs64Fnv1: Long) = builder.addLong(18, testhashs64Fnv1, 0L) fun addTesthashu64Fnv1(builder: FlatBufferBuilder, testhashu64Fnv1: ULong) = builder.addLong(19, testhashu64Fnv1.toLong(), 0) fun addTesthashs32Fnv1a(builder: FlatBufferBuilder, testhashs32Fnv1a: Int) = builder.addInt(20, testhashs32Fnv1a, 0) fun addTesthashu32Fnv1a(builder: FlatBufferBuilder, testhashu32Fnv1a: UInt) = builder.addInt(21, testhashu32Fnv1a.toInt(), 0) fun addTesthashs64Fnv1a(builder: FlatBufferBuilder, testhashs64Fnv1a: Long) = builder.addLong(22, testhashs64Fnv1a, 0L) fun addTesthashu64Fnv1a(builder: FlatBufferBuilder, testhashu64Fnv1a: ULong) = builder.addLong(23, testhashu64Fnv1a.toLong(), 0) fun addTestarrayofbools(builder: FlatBufferBuilder, testarrayofbools: Int) = builder.addOffset(24, testarrayofbools, 0) fun createTestarrayofboolsVector(builder: FlatBufferBuilder, data: BooleanArray) : Int { builder.startVector(1, data.size, 1) for (i in data.size - 1 downTo 0) { builder.addBoolean(data[i]) } return builder.endVector() } fun startTestarrayofboolsVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(1, numElems, 1) fun addTestf(builder: FlatBufferBuilder, testf: Float) = builder.addFloat(25, testf, 3.14159) fun addTestf2(builder: FlatBufferBuilder, testf2: Float) = builder.addFloat(26, testf2, 3.0) fun addTestf3(builder: FlatBufferBuilder, testf3: Float) = builder.addFloat(27, testf3, 0.0) fun addTestarrayofstring2(builder: FlatBufferBuilder, testarrayofstring2: Int) = builder.addOffset(28, testarrayofstring2, 0) fun createTestarrayofstring2Vector(builder: FlatBufferBuilder, data: IntArray) : Int { builder.startVector(4, data.size, 4) for (i in data.size - 1 downTo 0) { builder.addOffset(data[i]) } return builder.endVector() } fun startTestarrayofstring2Vector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(4, numElems, 4) fun addTestarrayofsortedstruct(builder: FlatBufferBuilder, testarrayofsortedstruct: Int) = builder.addOffset(29, testarrayofsortedstruct, 0) fun startTestarrayofsortedstructVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(8, numElems, 4) fun addFlex(builder: FlatBufferBuilder, flex: Int) = builder.addOffset(30, flex, 0) fun createFlexVector(builder: FlatBufferBuilder, data: UByteArray) : Int { builder.startVector(1, data.size, 1) for (i in data.size - 1 downTo 0) { builder.addByte(data[i].toByte()) } return builder.endVector() } fun startFlexVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(1, numElems, 1) fun addTest5(builder: FlatBufferBuilder, test5: Int) = builder.addOffset(31, test5, 0) fun startTest5Vector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(4, numElems, 2) fun addVectorOfLongs(builder: FlatBufferBuilder, vectorOfLongs: Int) = builder.addOffset(32, vectorOfLongs, 0) fun createVectorOfLongsVector(builder: FlatBufferBuilder, data: LongArray) : Int { builder.startVector(8, data.size, 8) for (i in data.size - 1 downTo 0) { builder.addLong(data[i]) } return builder.endVector() } fun startVectorOfLongsVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(8, numElems, 8) fun addVectorOfDoubles(builder: FlatBufferBuilder, vectorOfDoubles: Int) = builder.addOffset(33, vectorOfDoubles, 0) fun createVectorOfDoublesVector(builder: FlatBufferBuilder, data: DoubleArray) : Int { builder.startVector(8, data.size, 8) for (i in data.size - 1 downTo 0) { builder.addDouble(data[i]) } return builder.endVector() } fun startVectorOfDoublesVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(8, numElems, 8) fun addParentNamespaceTest(builder: FlatBufferBuilder, parentNamespaceTest: Int) = builder.addOffset(34, parentNamespaceTest, 0) fun addVectorOfReferrables(builder: FlatBufferBuilder, vectorOfReferrables: Int) = builder.addOffset(35, vectorOfReferrables, 0) fun createVectorOfReferrablesVector(builder: FlatBufferBuilder, data: IntArray) : Int { builder.startVector(4, data.size, 4) for (i in data.size - 1 downTo 0) { builder.addOffset(data[i]) } return builder.endVector() } fun startVectorOfReferrablesVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(4, numElems, 4) fun addSingleWeakReference(builder: FlatBufferBuilder, singleWeakReference: ULong) = builder.addLong(36, singleWeakReference.toLong(), 0) fun addVectorOfWeakReferences(builder: FlatBufferBuilder, vectorOfWeakReferences: Int) = builder.addOffset(37, vectorOfWeakReferences, 0) fun createVectorOfWeakReferencesVector(builder: FlatBufferBuilder, data: ULongArray) : Int { builder.startVector(8, data.size, 8) for (i in data.size - 1 downTo 0) { builder.addLong(data[i].toLong()) } return builder.endVector() } fun startVectorOfWeakReferencesVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(8, numElems, 8) fun addVectorOfStrongReferrables(builder: FlatBufferBuilder, vectorOfStrongReferrables: Int) = builder.addOffset(38, vectorOfStrongReferrables, 0) fun createVectorOfStrongReferrablesVector(builder: FlatBufferBuilder, data: IntArray) : Int { builder.startVector(4, data.size, 4) for (i in data.size - 1 downTo 0) { builder.addOffset(data[i]) } return builder.endVector() } fun startVectorOfStrongReferrablesVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(4, numElems, 4) fun addCoOwningReference(builder: FlatBufferBuilder, coOwningReference: ULong) = builder.addLong(39, coOwningReference.toLong(), 0) fun addVectorOfCoOwningReferences(builder: FlatBufferBuilder, vectorOfCoOwningReferences: Int) = builder.addOffset(40, vectorOfCoOwningReferences, 0) fun createVectorOfCoOwningReferencesVector(builder: FlatBufferBuilder, data: ULongArray) : Int { builder.startVector(8, data.size, 8) for (i in data.size - 1 downTo 0) { builder.addLong(data[i].toLong()) } return builder.endVector() } fun startVectorOfCoOwningReferencesVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(8, numElems, 8) fun addNonOwningReference(builder: FlatBufferBuilder, nonOwningReference: ULong) = builder.addLong(41, nonOwningReference.toLong(), 0) fun addVectorOfNonOwningReferences(builder: FlatBufferBuilder, vectorOfNonOwningReferences: Int) = builder.addOffset(42, vectorOfNonOwningReferences, 0) fun createVectorOfNonOwningReferencesVector(builder: FlatBufferBuilder, data: ULongArray) : Int { builder.startVector(8, data.size, 8) for (i in data.size - 1 downTo 0) { builder.addLong(data[i].toLong()) } return builder.endVector() } fun startVectorOfNonOwningReferencesVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(8, numElems, 8) fun addAnyUniqueType(builder: FlatBufferBuilder, anyUniqueType: UByte) = builder.addByte(43, anyUniqueType.toByte(), 0) fun addAnyUnique(builder: FlatBufferBuilder, anyUnique: Int) = builder.addOffset(44, anyUnique, 0) fun addAnyAmbiguousType(builder: FlatBufferBuilder, anyAmbiguousType: UByte) = builder.addByte(45, anyAmbiguousType.toByte(), 0) fun addAnyAmbiguous(builder: FlatBufferBuilder, anyAmbiguous: Int) = builder.addOffset(46, anyAmbiguous, 0) fun addVectorOfEnums(builder: FlatBufferBuilder, vectorOfEnums: Int) = builder.addOffset(47, vectorOfEnums, 0) fun createVectorOfEnumsVector(builder: FlatBufferBuilder, data: UByteArray) : Int { builder.startVector(1, data.size, 1) for (i in data.size - 1 downTo 0) { builder.addByte(data[i].toByte()) } return builder.endVector() } fun startVectorOfEnumsVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(1, numElems, 1) fun endMonster(builder: FlatBufferBuilder) : Int { val o = builder.endTable() builder.required(o, 10) return o } fun finishMonsterBuffer(builder: FlatBufferBuilder, offset: Int) = builder.finish(offset, "MONS") fun finishSizePrefixedMonsterBuffer(builder: FlatBufferBuilder, offset: Int) = builder.finishSizePrefixed(offset, "MONS") fun __lookup_by_key(obj: Monster?, vectorLocation: Int, key: String, bb: ByteBuffer) : Monster? { val byteKey = key.toByteArray(Table.UTF8_CHARSET.get()!!) var span = bb.getInt(vectorLocation - 4) var start = 0 while (span != 0) { var middle = span / 2 val tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb) val comp = compareStrings(__offset(10, bb.capacity() - tableOffset, bb), byteKey, bb) when { comp > 0 -> span = middle comp < 0 -> { middle++ start += middle span -= middle } else -> { return (obj ?: Monster()).__assign(tableOffset, bb) } } } return null } } }
third_party/flatbuffers/tests/MyGame/Example/Monster.kt
1119049143