Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Krotki committed Apr 8, 2024
1 parent a691bbf commit e286fb2
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 74 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pluginVersion = 0.0.1-beta.5

# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
pluginSinceBuild = 2024.1
pluginSinceBuild = 241.14494.240
pluginUntilBuild = 2024.1

# IntelliJ Platform Properties -> https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties
Expand Down
7 changes: 4 additions & 3 deletions src/main/kotlin/org/vlang/ide/VlangPostStartupActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.intellij.ide.util.PropertiesComponent
import com.intellij.openapi.extensions.PluginId
import com.intellij.openapi.options.ShowSettingsUtil
import com.intellij.openapi.project.Project
import com.intellij.openapi.startup.StartupActivity
import com.intellij.openapi.startup.ProjectActivity
import com.intellij.openapi.util.registry.Registry
import com.jetbrains.cidr.execution.debugger.evaluation.CidrValue
import org.vlang.configurations.VlangProjectStructureState.Companion.projectStructure
Expand All @@ -18,8 +18,9 @@ import org.vlang.toolchain.VlangToolchain
import org.vlang.toolchain.VlangToolchainService.Companion.toolchainSettings
import javax.swing.SwingUtilities.invokeLater

class VlangPostStartupActivity : StartupActivity {
override fun runActivity(project: Project) {
class VlangPostStartupActivity : ProjectActivity {

override suspend fun execute(project: Project) {
val knownToolchains = VlangKnownToolchainsState.getInstance().knownToolchains
val toolchainSettings = project.toolchainSettings

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.vlang.ide.hints

import com.intellij.codeInsight.daemon.impl.InlayHintsPassFactoryInternal
import com.intellij.codeInsight.hints.*
import com.intellij.codeInsight.hints.presentation.InlayPresentation
import com.intellij.codeInsight.hints.presentation.InsetPresentation
Expand Down Expand Up @@ -96,7 +95,7 @@ class VlangEnumValuesInlayHintsProvider : InlayHintsProvider<VlangEnumValuesInla

val inlayHintsSettings = InlayHintsSettings.instance()
inlayHintsSettings.storeSettings(key, VlangLanguage, settings)
InlayHintsPassFactoryInternal.forceHintsUpdateOnNextPass()
InlayHintsFactory.forceHintsUpdateOnNextPass()
}
}
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.vlang.ide.hints

import com.intellij.codeInsight.daemon.impl.InlayHintsPassFactoryInternal
import com.intellij.codeInsight.hints.*
import com.intellij.codeInsight.hints.presentation.*
import com.intellij.codeInsight.hints.settings.showInlaySettings
Expand Down Expand Up @@ -225,7 +224,7 @@ class VlangInlayHintsCollector(
val settings = inlayHintsSettings.findSettings(key, VlangLanguage) { VlangInlayHintsProvider.Settings() }
settings.action()
inlayHintsSettings.storeSettings(key, VlangLanguage, settings)
InlayHintsPassFactoryInternal.forceHintsUpdateOnNextPass()
InlayHintsFactory.forceHintsUpdateOnNextPass()
}
},
object : AnAction("Hints Settings...") {
Expand Down
3 changes: 0 additions & 3 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ Provides support for <a href="https://vlang.io/">V</a> language
implementationClass="org.vlang.lang.search.VlangSuperMarkerProvider"/>
<codeInsight.gotoSuper language="vlang"
implementationClass="org.vlang.lang.search.VlangGotoSuperHandler"/>

<psi.referenceContributor language="vlang"
implementation="org.vlang.ide.comments.VlangCommentReferenceContributor"/>
<!-- endregion Searches -->

<!-- region Code Insight -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import com.intellij.codeInsight.documentation.DocumentationManager
import com.intellij.psi.PsiElement
import com.intellij.psi.util.parentOfTypes
import com.intellij.testFramework.fixtures.BasePlatformTestCase
import com.intellij.util.io.readText
import org.vlang.lang.psi.VlangImportName
import org.vlang.lang.psi.VlangNamedElement
import org.vlang.lang.psi.VlangReferenceExpression
import org.vlang.utils.toPath
import java.io.File
import java.nio.file.Files
import kotlin.io.path.readText

@Suppress("DEPRECATION")
abstract class DocumentationTestBase : BasePlatformTestCase() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,4 @@ class VlangCommonProblemsTest : AnnotatorTestBase() {
fun `test attributes for interface members`() = doTest("attributes_for_interface_members.v")
fun `test assign values count mismatch`() = doTest("assign_values_count_mismatch.v")
fun `test it variable inside array init is deprecated`() = doTestQuickFix("it_variable_inside_array_init_is_deprecated.v")
fun `test empty enum`() = doTest("empty_enum.v")
fun `test mut parameter`() = doTest("mut_parameter.v")
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ abstract class InspectionTestBase(private val baseFolder: String = "") : BasePla

val qfFile = fixtureFile.replace(".v", ".after.v")
if (File(myFixture.testDataPath + "/" + qfFile).exists()) {
myFixture.getAllQuickFixes().forEach { myFixture.launchAction(it) }
myFixture.getAllQuickFixes().forEach {
// one fix can affect others - we need to check if the original fix is still available
if (it.isAvailable(myFixture.project, myFixture.editor, myFixture.file)) {
myFixture.launchAction(it)
}
}
myFixture.checkResultByFile(qfFile)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ class VlangGeneralInspectionTest : InspectionTestBase("general") {
doTestQuickFix("non_exhaustive_match_add_else.v", VlangNonExhaustiveMatchInspection(), "Add else branch")

fun `test call arguments count mismatch`() = doTest("call_arguments_count_mismatch.v", VlangCallArgumentsCountMismatchInspection())
fun `test raw result type`() = doTest("raw_result_type.v", VlangRawOptionOrResultTypeUsedInspection())

// TODO: create test file for VlangRawOptionOrResultTypeUsedInspection
//fun `test raw result type`() = doTest("raw_result_type.v", VlangRawOptionOrResultTypeUsedInspection())
}
24 changes: 12 additions & 12 deletions src/test/resources/documentation/function/Doc.expected.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<div class='content'><span class='grayed'>Module: </span><a href="psi_element://#function">function</a></div><div class='definition'><pre><span style="color:#000080;font-weight:bold;">fn</span> <span style="color:#000000;">foo</span>() </pre></div><br><br><br><div class='content'><span class='grayed'>Module: </span><a href="psi_element://#function">function</a></div><div class='definition'><pre><span style="color:#000080;font-weight:bold;">fn</span> <span style="color:#000000;">foo1</span>(<span style="color:#000000;">a</span> <span style="color:#000080;font-weight:bold;">int</span>) </pre></div><br><br><br><div class='content'><span class='grayed'>Module: </span><a href="psi_element://#function">function</a></div><div class='definition'><pre><span style="color:#000080;font-weight:bold;">pub</span> <span style="color:#000080;font-weight:bold;">fn</span> <span style="color:#000000;">foo2</span>(
<span style="">a</span> <span style="color:#000080;font-weight:bold;">int</span>,
<span style="">b</span> <span style="color:#000080;font-weight:bold;">string</span>,
<span style="color:#000000;">a</span> <span style="color:#000080;font-weight:bold;">int</span>,
<span style="color:#000000;">b</span> <span style="color:#000080;font-weight:bold;">string</span>,
) </pre></div><br><br><br><div class='content'><span class='grayed'>Module: </span><a href="psi_element://#function">function</a></div><div class='definition'><pre><span style="color:#000080;font-weight:bold;">fn</span> <span style="color:#000000;">foo3</span>(
<span style="">a</span> <span style="color:#000080;font-weight:bold;">int</span>,
<span style="">b</span> <span style="color:#000080;font-weight:bold;">string</span>,
<span style="">c</span> <span style="color:#000080;font-weight:bold;">f64</span>,
<span style="color:#000000;">a</span> <span style="color:#000080;font-weight:bold;">int</span>,
<span style="color:#000000;">b</span> <span style="color:#000080;font-weight:bold;">string</span>,
<span style="color:#000000;">c</span> <span style="color:#000080;font-weight:bold;">f64</span>,
) <span style="color:#000080;font-weight:bold;">string</span></pre></div><div class='content'><p><a href="psi_element://foo3">foo3</a> is a function with a return value</p>
</div><br><br><br><div class='content'><span class='grayed'>Module: </span><a href="psi_element://#function">function</a></div><div class='definition'><pre><span style="color:#000080;font-weight:bold;">parameter</span> <span style="color:#000000;">c</span> <span style="color:#000080;font-weight:bold;">f64</span></pre></div><br><br><br><div class='content'><span class='grayed'>Module: </span><a href="psi_element://#function">function</a></div><div class='definition'><pre><span style="color:#000080;font-weight:bold;">fn</span> <span style="color:#000000;">foo4</span>[<span style="color:#20999d;">T</span>](<span style="color:#000000;">a</span> <span style="color:#20999d;">T</span>) <span style="color:#20999d;">T</span></pre></div><br><br><br><div class='content'><span class='grayed'>Module: </span><a href="psi_element://#function">function</a></div><div class='definition'><pre><span style="color:#000080;font-weight:bold;">fn</span> <span style="color:#000000;">foo5</span>(<span style="color:#000080;font-weight:bold;">mut</span> <span style="color:#000000;">a</span> <span style="color:#000080;font-weight:bold;">string</span>) <span style="color:#000080;font-weight:bold;">string</span></pre></div><br><br><br><div class='content'><span class='grayed'>Module: </span><a href="psi_element://#function">function</a></div><div class='definition'><pre><span style="color:#000080;font-weight:bold;">pub</span> <span style="color:#000080;font-weight:bold;">fn</span> <span style="color:#000000;">foo6</span>(
<span style="color:#000080;font-weight:bold;">mut</span> <span style="">a</span> <span style="color:#000080;font-weight:bold;">string</span>,
<span style="color:#000080;font-weight:bold;">shared</span> <span style="">b</span> <span style="color:#000080;font-weight:bold;">int</span>,
<span style="color:#000080;font-weight:bold;">mut</span> <span style="color:#000080;font-weight:bold;">shared</span> <span style="">c</span> <span style="color:#000080;font-weight:bold;">string</span>,
<span style="color:#000080;font-weight:bold;">mut</span> <span style="color:#000000;">a</span> <span style="color:#000080;font-weight:bold;">string</span>,
<span style="color:#000080;font-weight:bold;">shared</span> <span style="color:#000000;">b</span> <span style="color:#000080;font-weight:bold;">int</span>,
<span style="color:#000080;font-weight:bold;">mut</span> <span style="color:#000080;font-weight:bold;">shared</span> <span style="color:#000000;">c</span> <span style="color:#000080;font-weight:bold;">string</span>,
) !<span style="color:#000080;font-weight:bold;">string</span></pre></div><div class='content'><p><a href="psi_element://foo6">foo6</a> is a function with a return value
and some
long documentation</p>
</div><br><br><br><div class='content'><span class='grayed'>Module: </span><a href="psi_element://#function">function</a></div><div class='definition'><pre><span style="color:#000080;font-weight:bold;">mut</span> <span style="color:#000080;font-weight:bold;">parameter</span> <span style="color:#000000;">a</span> <span style="color:#000080;font-weight:bold;">string</span></pre></div><br><br><br><div class='content'><span class='grayed'>Module: </span><a href="psi_element://#function">function</a></div><div class='definition'><pre><span style="color:#000080;font-weight:bold;">fn</span> <span style="color:#000000;">foo7</span>(
<span style="color:#000080;font-weight:bold;">mut</span> <span style="">a</span> <span style="color:#000080;font-weight:bold;">string</span>,
<span style="">b</span> <span style="color:#000080;font-weight:bold;">shared </span><span style="color:#000080;font-weight:bold;">int</span>,
<span style="color:#000080;font-weight:bold;">mut</span> <span style="color:#000000;">a</span> <span style="color:#000080;font-weight:bold;">string</span>,
<span style="color:#000000;">b</span> <span style="color:#000080;font-weight:bold;">shared </span><span style="color:#000080;font-weight:bold;">int</span>,
) !<span style="color:#000080;font-weight:bold;">string</span></pre></div><br><br><br><div class='content'><span class='grayed'>Module: </span><a href="psi_element://#function">function</a></div><div class='definition'><pre><span style="color:#000080;font-weight:bold;">parameter</span> <span style="color:#000000;">b</span> <span style="color:#000080;font-weight:bold;">shared </span><span style="color:#000080;font-weight:bold;">int</span></pre></div><br><br><br><div class='content'><span class='grayed'>Module: </span><a href="psi_element://#function">function</a></div><div class='definition'><pre><span style="color:#000080;font-weight:bold;">fn</span> <span style="color:#000000;">foo8</span>() !</pre></div><br><br><br><div class='content'><span class='grayed'>Module: </span><a href="psi_element://#function">function</a></div><div class='definition'><pre><span style="color:#000080;font-weight:bold;">fn</span> <span style="color:#000000;">foo9</span>() (<span style="color:#000080;font-weight:bold;">int</span>, <span style="color:#000080;font-weight:bold;">string</span>)</pre></div><br><br><br><div class='content'><span class='grayed'>Module: </span><a href="psi_element://#function">function</a></div><div class='definition'><pre><span style="color:#000080;font-weight:bold;">fn</span> <span style="color:#000000;">foo10</span>(<span style="color:#000080;font-weight:bold;">mut</span> <span style="color:#000000;">a</span> ...<span style="color:#000080;font-weight:bold;">string</span>) </pre></div><br><br><br><div class='content'><span class='grayed'>Module: </span><a href="psi_element://#function">function</a></div><div class='definition'><pre><span style="color:#000080;font-weight:bold;">mut</span> <span style="color:#000080;font-weight:bold;">parameter</span> <span style="color:#000000;">a</span> ...<span style="color:#000080;font-weight:bold;">string</span></pre></div><br><br><br><div class='content'><span class='grayed'>Module: </span><a href="psi_element://#function">function</a></div><div class='definition'><pre><span style="color:#000080;font-weight:bold;">fn</span> <span style="color:#000000;">foo11</span>(
<span style="">s</span> <span style="color:#000080;font-weight:bold;">int</span>,
<span style="">a</span> ...<span style="color:#000080;font-weight:bold;">string</span>,
<span style="color:#000000;">s</span> <span style="color:#000080;font-weight:bold;">int</span>,
<span style="color:#000000;">a</span> ...<span style="color:#000080;font-weight:bold;">string</span>,
) </pre></div><br><br><br><div class='content'><span class='grayed'>Module: </span><a href="psi_element://#function">function</a></div><div class='definition'><pre><span style="color:#000080;font-weight:bold;">parameter</span> <span style="color:#000000;">a</span> ...<span style="color:#000080;font-weight:bold;">string</span></pre></div>
86 changes: 43 additions & 43 deletions src/test/resources/hints/enum_fields.v.expected
Original file line number Diff line number Diff line change
@@ -1,100 +1,100 @@
module hints

enum Simple {
read<# = 0 #>
write<# = 1 #>
unknown<# = 2 #>
read/*<# = 0 #>*/
write/*<# = 1 #>*/
unknown/*<# = 2 #>*/
}

enum WithCustomValue {
read<# = 0 #>
read/*<# = 0 #>*/
write = 100
unknown<# = 101 #>
unknown/*<# = 101 #>*/
}

enum WithCustomValue2 {
read = 100
write<# = 101 #>
unknown<# = 102 #>
write/*<# = 101 #>*/
unknown/*<# = 102 #>*/
}

enum WithCustomValue3 {
read = 100
write<# = 101 #>
write/*<# = 101 #>*/
other= 105
unknown<# = 106 #>
unknown/*<# = 106 #>*/
}

enum WithComplexValue {
read = 1 << 5
write<# = 33 #>
other<# = 34 #>
unknown<# = 35 #>
write/*<# = 33 #>*/
other/*<# = 34 #>*/
unknown/*<# = 35 #>*/
}

enum WithComplexValue {
read = 1 << 5
write<# = 33 #>
other<# = 34 #>
unknown<# = 35 #>
write/*<# = 33 #>*/
other/*<# = 34 #>*/
unknown/*<# = 35 #>*/
}

enum WithNegativeValue {
read = -5
write<# = -4 #>
other<# = -3 #>
unknown<# = -2 #>
write/*<# = -4 #>*/
other/*<# = -3 #>*/
unknown/*<# = -2 #>*/
}

enum WithNegativeComplexValue {
read = -5 << 3
write<# = -39 #>
other<# = -38 #>
unknown<# = -37 #>
write/*<# = -39 #>*/
other/*<# = -38 #>*/
unknown/*<# = -37 #>*/
}

enum WithBinValue {
read = 0b0010
write<# = 3 #>
other<# = 4 #>
unknown<# = 5 #>
write/*<# = 3 #>*/
other/*<# = 4 #>*/
unknown/*<# = 5 #>*/
}

enum WithOctValue {
read = 0o0010
write<# = 9 #>
other<# = 10 #>
unknown<# = 11 #>
write/*<# = 9 #>*/
other/*<# = 10 #>*/
unknown/*<# = 11 #>*/
}

enum WithHexValue {
read = 0xFFF
write<# = 4096 #>
other<# = 4097 #>
unknown<# = 4098 #>
write/*<# = 4096 #>*/
other/*<# = 4097 #>*/
unknown/*<# = 4098 #>*/
}

enum WithSeveralCustomValue {
file = 0
folder<# = 1 #>
folder/*<# = 1 #>*/
// archive format
zip = 16
archive_file<# = 17 #>
archive_file/*<# = 17 #>*/
// graphic format, MUST stay after the other types!!
bmp = 32
jpg<# = 33 #>
png<# = 34 #>
gif<# = 35 #>
tga<# = 36 #>
ppm<# = 37 #>
pgm<# = 38 #>
pic<# = 39 #>
hdr<# = 40 #>
jpg/*<# = 33 #>*/
png/*<# = 34 #>*/
gif/*<# = 35 #>*/
tga/*<# = 36 #>*/
ppm/*<# = 37 #>*/
pgm/*<# = 38 #>*/
pic/*<# = 39 #>*/
hdr/*<# = 40 #>*/
}

[flag]
enum FlagEnum as u8 {
red<# = 0b1 (1) #>
other<# = 0b10 (2) #>
blue<# = 0b100 (4) #>
red/*<# = 0b1 (1) #>*/
other/*<# = 0b10 (2) #>*/
blue/*<# = 0b100 (4) #>*/
}
6 changes: 3 additions & 3 deletions src/test/resources/hints/enum_fields_2.v.expected
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module hints

[flag]
enum FlagEnum as u8 {
red<# = 1 #>
other<# = 2 #>
blue<# = 4 #>
red/*<# = 1 #>*/
other/*<# = 2 #>*/
blue/*<# = 4 #>*/
}

0 comments on commit e286fb2

Please sign in to comment.