Skip to content

Commit

Permalink
renaming + fix type checker
Browse files Browse the repository at this point in the history
  • Loading branch information
Peva Blanchard committed Jan 27, 2024
1 parent bdd84ed commit 3f88a14
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.intellij.lang.annotation.AnnotationHolder
import com.intellij.lang.annotation.Annotator
import com.intellij.psi.PsiElement

class LcaTechnoInputExchangeAnnotator : Annotator {
class LcaTerminalTechnoInputExchangeAnnotator : Annotator {
override fun annotate(element: PsiElement, holder: AnnotationHolder) {
if (element !is LcaTerminalTechnoInputExchange) {
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ch.kleis.lcaac.plugin.language.type_checker

import ch.kleis.lcaac.core.lang.dimension.Dimension
import ch.kleis.lcaac.core.lang.type.*
import ch.kleis.lcaac.plugin.language.psi.type.PsiBlockForEach
import ch.kleis.lcaac.plugin.language.psi.type.PsiProcess
import ch.kleis.lcaac.plugin.language.psi.type.ref.PsiDataRef
import ch.kleis.lcaac.plugin.language.psi.type.unit.UnitDefinitionType
Expand All @@ -21,6 +22,13 @@ class PsiLcaTypeChecker {
is LcaTerminalTechnoInputExchange -> checkTerminalTechnoInputExchange(element)
is LcaTechnoProductExchange -> checkTechnoProductExchange(element)
is LcaTerminalBioExchange -> checkTerminalBioExchange(element)

// the following checks the type of the data source expression in the block for each
is PsiBlockForEach -> {
val columns = columnsOf(element.getValue().dataSourceRef)
return TRecord(columns.mapValues { checkDataExpression(it.value) })
}

else -> throw PsiTypeCheckException("Uncheckable type: $element")
}
}
Expand Down Expand Up @@ -210,7 +218,8 @@ class PsiLcaTypeChecker {
is TQuantity -> ty
is TUnit -> TQuantity(ty.dimension)
is TString -> ty
else -> throw PsiTypeCheckException("expected TQuantity, TUnit or TString, found $ty")
is TRecord -> ty
else -> throw PsiTypeCheckException("expected TQuantity, TUnit, TString or TRecord, found $ty")
}
}
?: throw PsiTypeCheckException("unbound reference ${el.name}")
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

<annotator
language="LCA"
implementationClass="ch.kleis.lcaac.plugin.language.ide.insight.LcaTechnoInputExchangeAnnotator"/>
implementationClass="ch.kleis.lcaac.plugin.language.ide.insight.LcaTerminalTechnoInputExchangeAnnotator"/>
<annotator
language="LCA"
implementationClass="ch.kleis.lcaac.plugin.language.ide.insight.LcaProcessAnnotator"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ch.kleis.lcaac.plugin.language.ide.insight

import ch.kleis.lcaac.plugin.language.psi.stub.process.ProcessStubKeyIndex
import ch.kleis.lcaac.plugin.psi.LcaTerminalTechnoInputExchange
import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.lang.annotation.HighlightSeverity
import com.intellij.testFramework.fixtures.BasePlatformTestCase
Expand All @@ -12,7 +11,7 @@ import org.junit.runners.JUnit4

@Suppress("DialogTitleCapitalization")
@RunWith(JUnit4::class)
class LcaTechnoInputExchangeAnnotatorTest : BasePlatformTestCase() {
class LcaTerminalTechnoInputExchangeAnnotatorTest : BasePlatformTestCase() {

override fun getTestDataPath(): String {
return "testdata"
Expand All @@ -36,7 +35,7 @@ class LcaTechnoInputExchangeAnnotatorTest : BasePlatformTestCase() {
val element = ProcessStubKeyIndex.findProcesses(project, "$pkgName.p").first()
.getInputs().first().terminalTechnoInputExchange!!
val mock = AnnotationHolderMock()
val annotator = LcaTechnoInputExchangeAnnotator()
val annotator = LcaTerminalTechnoInputExchangeAnnotator()


// when
Expand Down Expand Up @@ -79,7 +78,7 @@ class LcaTechnoInputExchangeAnnotatorTest : BasePlatformTestCase() {
val element = ProcessStubKeyIndex.findProcesses(project, "$pkgName.p").first()
.getInputs().first().terminalTechnoInputExchange!!
val mock = AnnotationHolderMock()
val annotator = LcaTechnoInputExchangeAnnotator()
val annotator = LcaTerminalTechnoInputExchangeAnnotator()


// when
Expand Down Expand Up @@ -116,7 +115,7 @@ class LcaTechnoInputExchangeAnnotatorTest : BasePlatformTestCase() {
val element = ProcessStubKeyIndex.findProcesses(project, "$pkgName.p").first()
.getInputs().first().terminalTechnoInputExchange!!
val mock = AnnotationHolderMock()
val annotator = LcaTechnoInputExchangeAnnotator()
val annotator = LcaTerminalTechnoInputExchangeAnnotator()


// when
Expand Down Expand Up @@ -156,7 +155,7 @@ class LcaTechnoInputExchangeAnnotatorTest : BasePlatformTestCase() {
val element = ProcessStubKeyIndex.findProcesses(project, "$pkgName.p").first()
.getInputs().first().terminalTechnoInputExchange!!
val mock = AnnotationHolderMock()
val annotator = LcaTechnoInputExchangeAnnotator()
val annotator = LcaTerminalTechnoInputExchangeAnnotator()


// when
Expand Down Expand Up @@ -201,7 +200,7 @@ class LcaTechnoInputExchangeAnnotatorTest : BasePlatformTestCase() {
val element = ProcessStubKeyIndex.findProcesses(project, "$pkgName.p").first()
.getInputs().first().terminalTechnoInputExchange!!
val mock = AnnotationHolderMock()
val annotator = LcaTechnoInputExchangeAnnotator()
val annotator = LcaTerminalTechnoInputExchangeAnnotator()


// when
Expand Down Expand Up @@ -237,7 +236,7 @@ class LcaTechnoInputExchangeAnnotatorTest : BasePlatformTestCase() {
val element = ProcessStubKeyIndex.findProcesses(project, "$pkgName.p").first()
.getInputs().first()
val mock = AnnotationHolderMock()
val annotator = LcaTechnoInputExchangeAnnotator()
val annotator = LcaTerminalTechnoInputExchangeAnnotator()

// when
annotator.annotate(element, mock.holder)
Expand Down

0 comments on commit 3f88a14

Please sign in to comment.