Skip to content

Commit

Permalink
Platform update to 2024.1 (v1.9.0.5)
Browse files Browse the repository at this point in the history
  • Loading branch information
valis committed Jun 17, 2024
1 parent eb537bb commit 117dc42
Show file tree
Hide file tree
Showing 19 changed files with 57 additions and 54 deletions.
34 changes: 17 additions & 17 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ import org.jetbrains.grammarkit.tasks.GenerateLexerTask
import org.jetbrains.grammarkit.tasks.GenerateParserTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.intellij.tasks.PatchPluginXmlTask
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

val projectArend = gradle.includedBuild("Arend")
group = "org.arend.lang"
version = "1.9.0.4"
version = "1.9.0.5"

plugins {
idea
kotlin("jvm") version "1.9.21"
id("org.jetbrains.intellij") version "1.16.1"
id("org.jetbrains.grammarkit") version "2022.3.2"
kotlin("jvm") version "2.0.0"
id("org.jetbrains.intellij") version "1.17.4"
id("org.jetbrains.grammarkit") version "2022.3.2.2"
}

repositories {
Expand Down Expand Up @@ -56,18 +58,18 @@ idea {

tasks {
val test by getting(Test::class) {
setScanForTestClasses(false)
isScanForTestClasses = false
// Only run tests from classes that end with "Test"
include("**/*Test.class")
}
}

intellij {
version.set("2023.3")
version.set("2024.1")
pluginName.set("Arend")
updateSinceUntilBuild.set(true)
instrumentCode.set(true)
plugins.set(listOf("yaml", "java", "IdeaVIM:2.7.5"))
plugins.set(listOf("yaml", "java", "IdeaVIM:2.12.0"))
}

tasks.named<JavaExec>("runIde") {
Expand All @@ -85,16 +87,15 @@ val generateArendLexer = tasks.register<GenerateLexerTask>("genArendLexer") {
description = "Generates lexer"
group = "build setup"
sourceFile.set(file("src/main/grammars/ArendLexer.flex"))
targetDir.set("src/main/lexer/org/arend/lexer")
targetClass.set("ArendLexer")
targetOutputDir.set(file("src/main/lexer/org/arend/lexer"))
purgeOldFiles.set(true)
}

val generateArendParser = tasks.register<GenerateParserTask>("genArendParser") {
description = "Generates parser"
group = "build setup"
sourceFile.set(file("src/main/grammars/ArendParser.bnf"))
targetRoot.set("src/main/parser")
targetRootOutputDir.set(file("src/main/parser"))
pathToParser.set("/org/arend/parser/ArendParser.java")
pathToPsiRoot.set("/org/arend/psi")
purgeOldFiles.set(true)
Expand All @@ -104,17 +105,16 @@ val generateArendDocLexer = tasks.register<GenerateLexerTask>("genArendDocLexer"
description = "Generates doc lexer"
group = "build setup"
sourceFile.set(file("src/main/grammars/ArendDocLexer.flex"))
targetDir.set("src/main/doc-lexer/org/arend/lexer")
targetClass.set("ArendDocLexer")
targetOutputDir.set(file("src/main/doc-lexer/org/arend/lexer"))
purgeOldFiles.set(true)
}

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "17"
languageVersion = "1.9"
apiVersion = "1.9"
freeCompilerArgs = listOf("-Xjvm-default=all")
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
languageVersion.set(KotlinVersion.KOTLIN_2_0)
apiVersion.set(KotlinVersion.KOTLIN_1_9)
freeCompilerArgs.set(listOf("-Xjvm-default=all"))
}
dependsOn(generateArendLexer, generateArendParser, generateArendDocLexer)
}
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
org.gradle.jvmargs=-Xms512M -Xmx6g -XX:MaxMetaspaceSize=1g -Dkotlin.daemon.jvm.options=-Xmx6g
kotlin.stdlib.default.dependency = false
4 changes: 3 additions & 1 deletion src/main/kotlin/org/arend/ArendFileType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.arend
import com.intellij.openapi.fileTypes.LanguageFileType
import org.arend.util.FileUtils

object ArendFileType : LanguageFileType(ArendLanguage.INSTANCE) {
open class ArendFileType : LanguageFileType(ArendLanguage.INSTANCE) {
override fun getName(): String = "Arend"

override fun getDescription(): String = "Arend files"
Expand All @@ -12,3 +12,5 @@ object ArendFileType : LanguageFileType(ArendLanguage.INSTANCE) {

override fun getIcon() = ArendIcons.AREND_FILE
}

object ArendFileTypeInstance : ArendFileType()
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiFile
import org.arend.ArendFileType
import org.arend.ArendFileTypeInstance
import org.arend.util.arendModules
import java.util.Collections.singletonList

Expand All @@ -32,7 +33,7 @@ class SearchArendFilesContributor(val event: AnActionEvent) : AbstractGotoSECont
return super.acceptItem(item)
}
}
model.setFilterItems(singletonList(FileTypeRef.forFileType(ArendFileType)))
model.setFilterItems(singletonList(FileTypeRef.forFileType(ArendFileTypeInstance)))
return model
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.intellij.psi.codeStyle.CodeStyleSettings
import com.intellij.ui.components.JBRadioButton
import com.intellij.ui.dsl.builder.*
import com.intellij.ui.layout.selected
import org.arend.ArendFileType
import org.arend.ArendFileTypeInstance
import org.arend.settings.ArendCustomCodeStyleSettings
import org.arend.settings.ArendCustomCodeStyleSettings.OptimizeImportsPolicy
import org.arend.util.ArendBundle
Expand All @@ -24,7 +24,7 @@ class ArendCodeStyleImportsPanelWrapper(settings: CodeStyleSettings) : CodeStyle

override fun createHighlighter(scheme: EditorColorsScheme): EditorHighlighter? = null

override fun getFileType(): FileType = ArendFileType
override fun getFileType(): FileType = ArendFileTypeInstance

override fun getPreviewText(): String? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.intellij.codeInsight.daemon.impl.HighlightInfo
import com.intellij.codeInsight.daemon.impl.HighlightInfoType
import com.intellij.codeInsight.daemon.impl.UnusedSymbolUtil
import com.intellij.codeInsight.daemon.impl.UpdateHighlightersUtil
import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction
import com.intellij.codeInspection.InspectionManager
import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ex.QuickFixWrapper
Expand Down Expand Up @@ -53,12 +52,13 @@ class ArendUnusedImportHighlightingPass(private val file: ArendFile, private val
val profile = InspectionProjectProfileManager.getInstance(myProject).currentProfile
val key = HighlightDisplayKey.find(ArendUnusedImportInspection.ID)
val highlightInfoType = if (key == null) HighlightInfoType.UNUSED_SYMBOL else HighlightInfoType.HighlightInfoTypeImpl(profile.getErrorLevel(key, element).severity, HighlightInfoType.UNUSED_SYMBOL.attributesKey)
UnusedSymbolUtil.createUnusedSymbolInfo(element, description, highlightInfoType, ArendUnusedImportInspection.ID)?.let {
val actualOptimizationResult = optimizationResult
if (actualOptimizationResult != null) {
val intentionAction = QuickFixWrapper.wrap(InspectionManager.getInstance(element.project).createProblemDescriptor(element, description, ArendOptimizeImportsQuickFix(actualOptimizationResult), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, true), 0)
QuickFixAction.registerQuickFixAction(it, intentionAction)
}
val builder = UnusedSymbolUtil.createUnusedSymbolInfoBuilder(element, description, highlightInfoType, ArendUnusedImportInspection.ID)
val actualOptimizationResult = optimizationResult
if (actualOptimizationResult != null) {
val intentionAction = QuickFixWrapper.wrap(InspectionManager.getInstance(element.project).createProblemDescriptor(element, description, ArendOptimizeImportsQuickFix(actualOptimizationResult), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, true), 0)
builder.registerFix(intentionAction, null, null, null, null)
}
builder.create()?.let {
collector.add(it)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class ArendModuleConfigurationView(project: Project?, root: String?, name: Strin
get() = dualList.selectedList.content
set(value) {
dualList.selectedList.content = value
dualList.availableList.content -= value
dualList.availableList.content = dualList.availableList.content - value
}

override var versionString: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import com.intellij.openapi.roots.libraries.ui.AttachRootButtonDescriptor
import com.intellij.openapi.roots.libraries.ui.DescendentBasedRootFilter
import com.intellij.openapi.roots.libraries.ui.LibraryRootsComponentDescriptor
import com.intellij.openapi.roots.libraries.ui.OrderRootTypePresentation
import org.arend.ArendFileType
import org.arend.ArendFileTypeInstance
import org.arend.util.ArendLibraryChooserDescriptor
import org.arend.util.FileUtils


object ArendLibraryRootsComponentDescriptor : LibraryRootsComponentDescriptor() {
override fun getRootDetectors() = listOf(
ArendConfigRootDetector,
DescendentBasedRootFilter.createFileTypeBasedFilter(OrderRootType.SOURCES, false, ArendFileType, "sources"),
DescendentBasedRootFilter.createFileTypeBasedFilter(OrderRootType.SOURCES, false, ArendFileTypeInstance, "sources"),
DescendentBasedRootFilter(OrderRootType.CLASSES, false, "binaries") {
it.name.endsWith(FileUtils.SERIALIZED_EXTENSION)
},
Expand Down
11 changes: 6 additions & 5 deletions src/main/kotlin/org/arend/psi/ArendFile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import com.intellij.psi.impl.source.resolve.FileContextUtil
import com.intellij.psi.util.CachedValueProvider
import com.intellij.psi.util.CachedValuesManager
import com.intellij.psi.util.PsiModificationTracker
import org.arend.ArendFileType
import org.arend.ArendFileTypeInstance
import org.arend.ArendIcons
import org.arend.ArendLanguage
import org.arend.ext.module.LongName
Expand All @@ -41,6 +41,7 @@ import org.arend.resolving.ArendReference
import org.arend.resolving.DataLocatedReferable
import org.arend.typechecking.BackgroundTypechecker
import org.arend.typechecking.TypeCheckingService
import org.arend.util.FileUtils
import org.arend.util.libraryName
import org.arend.util.mapFirstNotNull
import java.util.concurrent.ConcurrentHashMap
Expand Down Expand Up @@ -116,13 +117,13 @@ class ArendFile(viewProvider: FileViewProvider) : PsiFileBase(viewProvider, Aren
}

fun cleanupTCRefMaps() {
for (refKind in RefKind.values()) {
for (refKind in RefKind.entries) {
getTCRefMap(refKind).cleanup(project)
}
}

override fun setName(name: String): PsiElement =
super.setName(if (name.endsWith('.' + ArendFileType.defaultExtension)) name else name + '.' + ArendFileType.defaultExtension)
super.setName(if (name.endsWith(FileUtils.EXTENSION)) name else name + FileUtils.EXTENSION)

override fun getStub(): ArendFileStub? = super.getStub() as ArendFileStub?

Expand Down Expand Up @@ -228,9 +229,9 @@ class ArendFile(viewProvider: FileViewProvider) : PsiFileBase(viewProvider, Aren

override fun getReference(): ArendReference? = null

override fun getFileType(): FileType = ArendFileType
override fun getFileType(): FileType = ArendFileTypeInstance

override fun textRepresentation(): String = name.removeSuffix("." + ArendFileType.defaultExtension)
override fun textRepresentation(): String = name.removeSuffix(FileUtils.EXTENSION)

override fun getPrecedence(): Precedence = Precedence.DEFAULT

Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/org/arend/psi/ArendPsiFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiFileFactory
import com.intellij.psi.PsiParserFacade
import org.arend.ArendFileType
import org.arend.ArendFileTypeInstance
import org.arend.InjectionTextLanguage
import org.arend.psi.ext.*

Expand Down Expand Up @@ -175,7 +175,7 @@ class ArendPsiFactory(
}

fun createFromText(code: String): ArendFile? =
psiFactory().createFileFromText(fileName, ArendFileType, code) as? ArendFile
psiFactory().createFileFromText(fileName, ArendFileTypeInstance, code) as? ArendFile

private fun psiFactory() = PsiFileFactory.getInstance(project)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import com.intellij.refactoring.changeSignature.*
import com.intellij.refactoring.ui.ComboBoxVisibilityPanel
import com.intellij.ui.treeStructure.Tree
import com.intellij.util.Consumer
import org.arend.ArendFileType
import org.arend.ArendFileTypeInstance
import org.arend.psi.ArendPsiFactory

class ArendChangeSignatureDialog(project: Project, val descriptor: ArendChangeSignatureDescriptor) :
ChangeSignatureDialogBase<ArendParameterInfo, PsiElement, String, ArendChangeSignatureDescriptor, ParameterTableModelItemBase<ArendParameterInfo>, ArendParameterTableModel>(project, descriptor, false, descriptor.method.context) {

override fun getFileType() = ArendFileType
override fun getFileType() = ArendFileTypeInstance

override fun createParametersInfoModel(descriptor: ArendChangeSignatureDescriptor) =
ArendParameterTableModel(descriptor, myDefaultValueContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.intellij.refactoring.changeSignature.ParameterTableModelBase
import com.intellij.refactoring.changeSignature.ParameterTableModelItemBase
import com.intellij.ui.BooleanTableCellEditor
import com.intellij.ui.BooleanTableCellRenderer
import org.arend.ArendFileType
import org.arend.ArendFileTypeInstance
import javax.swing.table.TableCellEditor
import javax.swing.table.TableCellRenderer

Expand Down Expand Up @@ -38,7 +38,6 @@ class ArendParameterTableModel(val descriptor: ArendChangeSignatureDescriptor, d
}
}

@Suppress("UnstableApiUsage")
override fun removeRow(idx: Int) {
super.removeRow(idx)
}
Expand All @@ -65,7 +64,7 @@ class ArendParameterTableModel(val descriptor: ArendChangeSignatureDescriptor, d
private class ArendTypeColumn(descriptor: ArendChangeSignatureDescriptor) :
TypeColumn<ArendParameterInfo, ParameterTableModelItemBase<ArendParameterInfo>>(
descriptor.method.project,
ArendFileType
ArendFileTypeInstance
) {
override fun setValue(item: ParameterTableModelItemBase<ArendParameterInfo>?, value: PsiCodeFragment) {
val fragment = value as? PsiTypeCodeFragment ?: return
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/org/arend/resolving/ArendReference.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.intellij.openapi.components.service
import com.intellij.openapi.util.TextRange
import com.intellij.psi.*
import com.intellij.psi.impl.source.tree.LeafPsiElement
import org.arend.ArendFileType
import org.arend.ArendIcons
import org.arend.codeInsight.completion.ReplaceInsertHandler
import org.arend.core.definition.Definition
Expand All @@ -28,6 +27,7 @@ import org.arend.term.abs.ConcreteBuilder
import org.arend.term.concrete.Concrete
import org.arend.toolWindow.repl.getReplCompletion
import org.arend.typechecking.TypeCheckingService
import org.arend.util.FileUtils

interface ArendReference : PsiReference {
override fun getElement(): ArendReferenceElement
Expand Down Expand Up @@ -239,7 +239,7 @@ open class ArendReferenceImpl<T : ArendReferenceElement>(element: T, private val
}

private fun doRename(oldNameIdentifier: PsiElement, rawName: String) {
val name = rawName.removeSuffix('.' + ArendFileType.defaultExtension)
val name = rawName.removeSuffix(FileUtils.EXTENSION)
if (!ArendNamesValidator.isIdentifier(name, oldNameIdentifier.project)) return
val factory = ArendPsiFactory(oldNameIdentifier.project)
val newNameIdentifier = when (oldNameIdentifier) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/org/arend/tracer/ArendTraceProcess.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import com.intellij.xdebugger.impl.DebuggerSupport
import com.intellij.xdebugger.impl.actions.*
import com.intellij.xdebugger.impl.actions.handlers.XDebuggerActionHandler
import com.intellij.xdebugger.ui.XDebugTabLayouter
import org.arend.ArendFileType
import org.arend.ArendFileTypeInstance
import org.arend.psi.ext.ArendExpr
import org.arend.psi.ArendFile
import org.arend.psi.ArendPsiFactory
Expand Down Expand Up @@ -221,7 +221,7 @@ class ArendTraceProcess(session: XDebugSession, private val tracingData: ArendTr
}

private object EditorsProvider : XDebuggerEditorsProviderBase() {
override fun getFileType(): FileType = ArendFileType
override fun getFileType(): FileType = ArendFileTypeInstance
override fun createExpressionCodeFragment(
project: Project,
text: String,
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/org/arend/ui/ArendEditor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.intellij.openapi.editor.ex.EditorEx
import com.intellij.openapi.editor.highlighter.EditorHighlighterFactory
import com.intellij.openapi.editor.impl.EditorImpl
import com.intellij.openapi.project.Project
import org.arend.ArendFileType
import org.arend.ArendFileTypeInstance
import org.arend.settings.ArendProjectSettings

class ArendEditor(
Expand All @@ -23,7 +23,7 @@ class ArendEditor(
editor.isViewer = readOnly
editor.highlighter = EditorHighlighterFactory
.getInstance()
.createEditorHighlighter(project, ArendFileType)
.createEditorHighlighter(project, ArendFileTypeInstance)
project?.serviceIfCreated<ArendProjectSettings>()?.run {
editor.setFontSize(data.popupFontSize)
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<vendor>JetBrains</vendor>

<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
<idea-version since-build="233.9102.97"/>
<idea-version since-build="233.11799.241"/>

<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
on how to target different products -->
Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/org/arend/FileTree.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fun fileTreeFromText(@Language("Arend") text: String): FileTree {
check(fileNames.size == fileTexts.size) { "Have you placed `-- ! filename.ard` markers?" }
}

val modulePaths = fileNames.map { ModulePath(it.removeSuffix('.' + ArendFileType.defaultExtension).split('/')) }
val modulePaths = fileNames.map { ModulePath(it.removeSuffix(FileUtils.EXTENSION).split('/')) }

fun fill(dir: Entry.Directory, path: List<String>, contents: String) {
val name = path.first()
Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/org/arend/ParsingTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.arend
import com.intellij.testFramework.ParsingTestCase
import org.arend.parser.ArendParserDefinition

class ParsingTest : ParsingTestCase("org/arend/parser/fixtures", ArendFileType.defaultExtension, ArendParserDefinition()) {
class ParsingTest : ParsingTestCase("org/arend/parser/fixtures", ArendFileTypeInstance.defaultExtension, ArendParserDefinition()) {

override fun getTestDataPath() = "src/test/resources"

Expand Down
Loading

0 comments on commit 117dc42

Please sign in to comment.