Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@

class ElmExternalFormatAction : AnAction() {

override fun getActionUpdateThread(): ActionUpdateThread {
return ActionUpdateThread.BGT
}

override fun update(e: AnActionEvent) {
super.update(e)

Check warning on line 28 in src/main/kotlin/org/elm/ide/actions/ElmExternalFormatAction.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Method can only be overridden

Method 'update(com.intellij.openapi.actionSystem.@org.jetbrains.annotations.NotNull AnActionEvent)' can only be overridden
e.presentation.isEnabled = getContext(e) != null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.intellij.execution.ExecutionException
import com.intellij.notification.NotificationType
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
Expand All @@ -20,8 +21,12 @@

class ElmExternalReviewAction : AnAction() {

override fun getActionUpdateThread(): ActionUpdateThread {
return ActionUpdateThread.BGT
}

override fun update(e: AnActionEvent) {
super.update(e)

Check warning on line 29 in src/main/kotlin/org/elm/ide/actions/ElmExternalReviewAction.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Method can only be overridden

Method 'update(com.intellij.openapi.actionSystem.@org.jetbrains.annotations.NotNull AnActionEvent)' can only be overridden
e.presentation.isEnabled = e.project != null
}

Expand Down Expand Up @@ -75,7 +80,7 @@
if (compiledSuccessfully) {
elmReviewCLI.runReview(project, elmProject, project.elmToolchain.elmCLI, currentFileInEditor)
}
} catch (e: ExecutionException) {
} catch (_: ExecutionException) {
return showError(
project,
"Failed to 'make' or 'review'. Are the path settings correct ?",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.intellij.execution.ExecutionException
import com.intellij.notification.NotificationType
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
Expand All @@ -20,8 +21,12 @@

class ElmExternalReviewWatchmodeAction : AnAction() {

override fun getActionUpdateThread(): ActionUpdateThread {
return ActionUpdateThread.BGT
}

override fun update(e: AnActionEvent) {
super.update(e)

Check warning on line 29 in src/main/kotlin/org/elm/ide/actions/ElmExternalReviewWatchmodeAction.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Method can only be overridden

Method 'update(com.intellij.openapi.actionSystem.@org.jetbrains.annotations.NotNull AnActionEvent)' can only be overridden
e.presentation.isEnabled = e.project != null
}

Expand Down Expand Up @@ -75,7 +80,7 @@
if (compiledSuccessfully) {
elmReviewCLI.watchReview(project, elmProject, project.elmToolchain.elmCLI)
}
} catch (e: ExecutionException) {
} catch (_: ExecutionException) {
return showError(
project,
"Failed to 'make' or 'review'. Are the path settings correct ?",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ import org.elm.lang.core.psi.elements.ElmTypeAnnotation
import org.elm.lang.core.psi.elements.ElmValueDeclaration

class ElmInspectionSuppressor : InspectionSuppressor {
companion object {
private val SUPPRESS_REGEX = Regex("--" + SuppressionUtil.COMMON_SUPPRESS_REGEXP)
}

override fun getSuppressActions(element: PsiElement?, toolId: String): Array<out SuppressQuickFix> = arrayOf(
SuppressInspectionFix(toolId),
Expand Down Expand Up @@ -68,3 +65,5 @@ class ElmInspectionSuppressor : InspectionSuppressor {
}
}
}

private val SUPPRESS_REGEX = Regex("--" + SuppressionUtil.COMMON_SUPPRESS_REGEXP)
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ abstract class ElmLocalInspection : LocalInspectionTool() {
}
}

@Suppress("unused")
abstract fun visitElement(element: ElmPsiElement, holder: ProblemsHolder, isOnTheFly: Boolean)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ class ElmUnresolvedReferenceInspection : ElmLocalInspection() {
return true
}

private fun handleSafeToIgnore(ref: PsiReference, element: PsiElement, @Suppress("UNUSED_PARAMETER") holder: ProblemsHolder): Boolean {
@Suppress("unused")
private fun handleSafeToIgnore(ref: PsiReference, element: PsiElement, holder: ProblemsHolder): Boolean {
// Ignore refs to Kernel (JavaScript) modules
when {
element is ElmValueExpr && element.qid.isKernelModule -> return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class InlineDebugIntention : ElmAtCaretIntentionActionBase<InlineDebugIntention.
}


@Suppress("unused")
private fun getContext(project: Project, editor: Editor, element: PsiElement): Pair<Context, MessageContext>? {
element.ancestors.forEach { currentExpr ->
when (currentExpr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@

private fun badToolchainPanel(message: String) =
EditorNotificationPanel().apply {
setText(message)

Check notice on line 125 in src/main/kotlin/org/elm/ide/notifications/ElmNeedsConfigNotificationProvider.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Accessor call that can be replaced with property access syntax

Use of setter method instead of property access syntax
createActionLabel("Setup toolchain") {
project.elmWorkspace.showConfigureToolchainUI()
}
Expand All @@ -131,7 +131,7 @@

private fun noElmProjectPanel(message: String) =
EditorNotificationPanel().apply {
setText(message)

Check notice on line 134 in src/main/kotlin/org/elm/ide/notifications/ElmNeedsConfigNotificationProvider.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Accessor call that can be replaced with property access syntax

Use of setter method instead of property access syntax
createActionLabel("Attach elm.json", "Elm.AttachElmProject")
}

Expand All @@ -149,7 +149,7 @@
}
val manifestFileName = elmProject.manifestPath.fileName.toString()
return EditorNotificationPanel().apply {
setText("Your $manifestFileName file requires Elm $expectedVersionText but your Elm compiler is $compilerVersion")

Check notice on line 152 in src/main/kotlin/org/elm/ide/notifications/ElmNeedsConfigNotificationProvider.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Accessor call that can be replaced with property access syntax

Use of setter method instead of property access syntax
createActionLabel("Open $manifestFileName") {
val didNavigate = LocalFileSystem.getInstance().findFileByPath(elmProject.manifestPath)
?.let { OpenFileDescriptor(project, it) }
Expand All @@ -164,8 +164,6 @@
}


companion object {
private val PROVIDER_KEY: Key<EditorNotificationPanel> = Key.create("Setup Elm toolchain")
}

}

private val PROVIDER_KEY: Key<EditorNotificationPanel> = Key.create("Setup Elm toolchain")
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ElmPresentableTreeElement(val element: ElmPsiElement)

}

/** Like [PsiElement.descendants], but stops at any [ElmValueDeclaration]s */
/** Like [PsiElement.directChildren], but stops at any [ElmValueDeclaration]s */
private val PsiElement.directChildDecls: Sequence<ElmValueDeclaration>
get() = directChildren.flatMap {
when (it) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.intellij.openapi.wm.ToolWindowManager
import com.intellij.ui.content.impl.ContentImpl
import com.intellij.util.ui.MessageCategory
import org.elm.workspace.compiler.ELM_BUILD_ACTION_ID
import org.elm.workspace.compiler.ERRORS_TOPIC
import org.elm.workspace.compiler.ElmBuildAction
import org.elm.workspace.compiler.ElmError
import java.nio.file.Path
Expand All @@ -24,7 +25,7 @@ class ElmCompilerToolWindowFactory : ToolWindowFactory {


with(project.messageBus.connect()) {
subscribe(ElmBuildAction.ERRORS_TOPIC, object : ElmBuildAction.ElmErrorsListener {
subscribe(ERRORS_TOPIC, object : ElmBuildAction.ElmErrorsListener {
override fun update(baseDirPath: Path, messages: List<ElmError>, targetPath: String, offset: Int) {
errorTreeViewPanel.clearMessages()

Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/org/elm/ide/toolwindow/ElmWorkspacePanel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.elm.ide.icons.ElmIcons
import org.elm.openapiext.checkIsEventDispatchThread
import org.elm.openapiext.findFileByPath
import org.elm.workspace.ElmDetachProjectAction
import org.elm.workspace.DATA_KEY
import org.elm.workspace.ElmProject
import org.elm.workspace.ElmWorkspaceService
import org.elm.workspace.elmWorkspace
Expand Down Expand Up @@ -65,7 +65,7 @@


init {
setToolbar(createToolbar())

Check notice on line 68 in src/main/kotlin/org/elm/ide/toolwindow/ElmWorkspacePanel.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Accessor call that can be replaced with property access syntax

Use of setter method instead of property access syntax
setContent(ScrollPaneFactory.createScrollPane(projectListUI, 0))

// populate the initial workspace state
Expand Down Expand Up @@ -104,7 +104,7 @@
selectedProject?.manifestPath
?.let { LocalFileSystem.getInstance().findFileByPath(it) }
?.let { OpenFileDescriptor(project, it) }
ElmDetachProjectAction.DATA_KEY.`is`(dataId) ->
DATA_KEY.`is`(dataId) ->
selectedProject
else ->
super.getData(dataId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private abstract class ElmSmartEnterFixer : SmartEnterProcessorWithFixers.Fixer<
final override fun apply(editor: Editor, processor: ElmSmartEnterProcessor, element: PsiElement) {
apply(editor, processor, element, element.indentStyle.oneLevelOfIndentation)
}

@Suppress("unused")
abstract fun apply(editor: Editor, processor: ElmSmartEnterProcessor, element: PsiElement, indent: String)
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/org/elm/lang/core/ElmTextUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ class IndentedTextBuilder(startLevel: Int, private val indentSize: Int) {
*
* @see ElmPsiElement.textWithNormalizedIndents
*/
fun buildIndentedText(element: ElmPsiElement, builder: (IndentedTextBuilder).() -> Unit): String {
@Suppress("unused")
fun buildIndentedText(element: ElmPsiElement, @Suppress("unused") builder: (IndentedTextBuilder).() -> Unit): String {
val doc = PsiDocumentManager.getInstance(element.project).getDocument(element.elmFile)
?: error("Failed to find document for $element")
val existingIndent = doc.getIndent(element.startOffset)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,22 @@ import com.intellij.lang.parser.GeneratedParserUtilBase
*/
object ElmManualParseRules : GeneratedParserUtilBase() {
@JvmStatic
@Suppress("unused")
fun parseTupleOrParenExpr(builder: PsiBuilder, level: Int, exprParser: Parser) =
TupleOrParenExprParser(exprParser).parse(builder, level)

@JvmStatic
@Suppress("unused")
fun parseMinusWithoutTrailingWhitespace(builder: PsiBuilder, level: Int) =
MinusWithoutTrailingWhitespaceParser.parse(builder, level)

@JvmStatic
@Suppress("unused")
fun parseDotWithoutTrailingWhitespace(builder: PsiBuilder, level: Int) =
DotWithoutWhitespaceParser(allowLeadingWs = true, allowTrailingWs = false).parse(builder, level)

@JvmStatic
@Suppress("unused")
fun parseDotWithoutWhitespace(builder: PsiBuilder, level: Int) =
DotWithoutWhitespaceParser(allowLeadingWs = false, allowTrailingWs = false).parse(builder, level)
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ElmPlaceholderStub(
// nothing extra to write
}

@Suppress("unused")
override fun deserialize(dataStream: StubInputStream, parentStub: StubElement<*>?) =
ElmPlaceholderStub(parentStub, this) // nothing extra to read

Expand Down Expand Up @@ -86,4 +87,4 @@ class ElmPlaceholderRefStub(
// no-op
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
// no data to write
}

@Suppress("unused")
override fun deserialize(dataStream: StubInputStream, parentStub: StubElement<*>?): ElmFileStub {
// no data to read
return ElmFileStub(null)
Expand All @@ -47,8 +48,8 @@
- is the element a container with no interesting data of its own,
but which needs to hold stub children? use [ElmPlaceholderStub]
- is it a simple ElmReferenceElement? use [ElmPlaceholderRefStub]
- is it an [ElmNamedElement]? create a custom stub class/type below

Check warning on line 51 in src/main/kotlin/org/elm/lang/core/stubs/StubImplementations.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unresolved reference in KDoc

Cannot resolve symbol 'ElmNamedElement'
and make sure you index it with [ElmNamedElementIndex].

Check warning on line 52 in src/main/kotlin/org/elm/lang/core/stubs/StubImplementations.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unresolved reference in KDoc

Cannot resolve symbol 'ElmNamedElementIndex'
- for all other cases, create a custom stub class and type below.

In all cases, you must also:
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/elm/lang/core/types/Ty.kt
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ data class TyFunction(
}

/** The [Ty] representing `()` */
data class TyUnit(override val alias: AliasInfo? = null) : Ty() {
data class TyUnit(@Suppress("unused") override val alias: AliasInfo? = null) : Ty() {
override fun withAlias(alias: AliasInfo): TyUnit = copy(alias = alias)
override fun toString(): String = javaClass.simpleName
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/org/elm/lang/core/types/TypeInference.kt
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@
return InferenceResult(expressionTypes, diagnostics, recordDiffs, ty)
}

@Suppress("unused")
private inline fun inferChild(
activeScopes: MutableSet<ElmValueDeclaration> = this.activeScopes.toMutableSet(),
recursionAllowed: Boolean = this.recursionAllowed,
Expand Down Expand Up @@ -1123,7 +1124,7 @@
&& allAssignable(ty1.parameters, ty2.parameters)
is TyFunction -> ty2 is TyFunction && funcsAssignable(ty1, ty2)
is TyUnit -> ty2 is TyUnit
is TyUnknown -> true

Check warning on line 1127 in src/main/kotlin/org/elm/lang/core/types/TypeInference.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Constant conditions

'when' branch is never reachable
TyInProgressBinding -> error("should never try to assign $ty1")
}

Expand Down Expand Up @@ -1213,8 +1214,8 @@
!ty2.rigid && typeclassesConstrainToCompappend(tc1, tc2)
}
ty1.rigid && tc1 == null -> !ty2.rigid && tc2 == null
ty1.rigid && tc1 != null && ty2.rigid -> tc1 == tc2

Check warning on line 1217 in src/main/kotlin/org/elm/lang/core/types/TypeInference.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Constant conditions

Condition 'ty1.rigid' is always true

Check warning on line 1217 in src/main/kotlin/org/elm/lang/core/types/TypeInference.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Constant conditions

Condition 'ty1.rigid \&\& tc1 != null' is always true

Check warning on line 1217 in src/main/kotlin/org/elm/lang/core/types/TypeInference.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Constant conditions

Condition 'tc1 != null' is always true when reached
ty1.rigid && tc1 != null && !ty2.rigid -> typeclassesCompatable(tc1, tc2, unconstrainedAllowed = true)

Check warning on line 1218 in src/main/kotlin/org/elm/lang/core/types/TypeInference.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Constant conditions

Condition 'ty1.rigid \&\& tc1 != null' is always true

Check warning on line 1218 in src/main/kotlin/org/elm/lang/core/types/TypeInference.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Constant conditions

Condition 'tc1 != null' is always true when reached

Check warning on line 1218 in src/main/kotlin/org/elm/lang/core/types/TypeInference.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Constant conditions

Condition 'ty1.rigid' is always true
else -> error("impossible")
}
}
Expand Down Expand Up @@ -1426,7 +1427,7 @@

data class Annotated(val ty: Ty, override val count: Int) : ParameterBindingResult()
data class Unannotated(val params: List<Ty>, override val count: Int) : ParameterBindingResult()
data class Other(override val count: Int) : ParameterBindingResult()
data class Other(@Suppress("unused") override val count: Int) : ParameterBindingResult()
}

/** dangerous shallow copy of a mutable record for performance, use `toRecord` if the result isn't discarded. */
Expand Down
6 changes: 2 additions & 4 deletions src/main/kotlin/org/elm/workspace/ElmDetachProjectAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ class ElmDetachProjectAction : AnAction() {
get() = dataContext.getData(DATA_KEY)


companion object {
val DATA_KEY = DataKey.create<ElmProject>("ELM_PROJECT_TO_DETACH")
}

override fun getActionUpdateThread(): ActionUpdateThread {
return ActionUpdateThread.BGT
}
}

val DATA_KEY = DataKey.create<ElmProject>("ELM_PROJECT_TO_DETACH")
1 change: 1 addition & 0 deletions src/main/kotlin/org/elm/workspace/ElmProject.kt
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class LamderaApplicationProject(
/**
* Represents an Elm package/library
*/
@Suppress("unused")
class ElmPackageProject(
manifestPath: Path,
val elmVersion: Constraint,
Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/org/elm/workspace/ElmReviewService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import java.util.concurrent.CompletableFuture

@State(name = "ElmReview", storages = [Storage(StoragePathMacros.WORKSPACE_FILE)])
@Service(Service.Level.PROJECT)
@Suppress("unused")
class ElmReviewService(val intellijProject: Project) : PersistentStateComponent<Element> {

var activeWatchmodeProcess: Process? = null
Expand All @@ -32,7 +33,8 @@ class ElmReviewService(val intellijProject: Project) : PersistentStateComponent<
}

@VisibleForTesting
fun asyncLoadState(@Suppress("UNUSED_PARAMETER") state: Element): CompletableFuture<Unit> {
@Suppress("unused")
fun asyncLoadState(state: Element): CompletableFuture<Unit> {

/*
val settingsElement = state.getChild("settings")
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/org/elm/workspace/commandLineTools/ElmCLI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.elm.openapiext.*
import org.elm.workspace.ElmProject
import org.elm.workspace.ParseException
import org.elm.workspace.Version
import org.elm.workspace.compiler.ElmBuildAction
import org.elm.workspace.compiler.ERRORS_TOPIC
import org.elm.workspace.compiler.ElmError
import org.elm.workspace.compiler.elmJsonToCompilerMessages
import org.elm.workspace.elmCompilerTool
Expand Down Expand Up @@ -55,7 +55,7 @@ class ElmCLI(val elmExecutablePath: Path) {
// TODO Lamdera
// org.elm.workspace.log.error("Failed to install deps: Elm compiler failed: ${output.stderr}")
} else {
fun postErrors() = project.messageBus.syncPublisher(ElmBuildAction.ERRORS_TOPIC).update(elmProject.projectDirPath, messages, targetPath!!, offset)
fun postErrors() = project.messageBus.syncPublisher(ERRORS_TOPIC).update(elmProject.projectDirPath, messages, targetPath!!, offset)
when {
isUnitTestMode -> postErrors()
else -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
.execute(elmFormatTool, project, stdIn = document.text)
}

sealed class ElmFormatResult(val msg: String, val cause: Throwable? = null) {
sealed class ElmFormatResult(val msg: String, @Suppress("unused") val cause: Throwable? = null) {
class Success : ElmFormatResult("ok")
class BadSyntax : ElmFormatResult("elm-format encountered syntax errors that it could not fix")
class FailedToStart : ElmFormatResult("Failed to launch elm-format. Is the path correct?")
Expand All @@ -51,7 +51,7 @@
val processOutput = try {
ProgressManager.getInstance().runProcessWithProgressSynchronously<ProcessOutput, ExecutionException>({
getFormattedContentOfDocument(version, document, project)
}, "Running 'elm-format' On Current File", true, project)

Check warning on line 54 in src/main/kotlin/org/elm/workspace/commandLineTools/ElmFormatCLI.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Incorrect string capitalization

String 'Running 'elm-format' On Current File' is not properly capitalized. It should have title capitalization
} catch (e: ExecutionException) {
val msg = e.message ?: "unknown"
return when {
Expand Down Expand Up @@ -80,7 +80,7 @@

with(CommandProcessor.getInstance()) {
when {
addToUndoStack -> executeCommand(project, action, "Run elm-format on current file", null, document)

Check warning on line 83 in src/main/kotlin/org/elm/workspace/commandLineTools/ElmFormatCLI.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Incorrect string capitalization

String 'Run elm-format on current file' is not properly capitalized. It should have title capitalization
else -> runUndoTransparentAction(action)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,6 @@ fun executeReviewAsync(
val ELM_REVIEW_ERRORS_TOPIC = Topic("elm-review errors", ElmReviewErrorsListener::class.java)

interface ElmReviewErrorsListener {
@Suppress("unused")
fun update(baseDirPath: Path, messages: List<ElmReviewError>, targetPath: String?, offset: Int)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.wm.ToolWindowManager
import org.elm.openapiext.*
import org.elm.workspace.*
import org.elm.workspace.compiler.ElmBuildAction
import org.elm.workspace.compiler.ERRORS_TOPIC
import org.elm.workspace.compiler.ElmError
import org.elm.workspace.compiler.elmJsonToCompilerMessages
import java.nio.file.Path
Expand Down Expand Up @@ -57,7 +57,7 @@ class LamderaCLI(private val lamderaExecutablePath: Path) {
}
return true
} else {
fun postErrors() = project.messageBus.syncPublisher(ElmBuildAction.ERRORS_TOPIC).update(elmProject.projectDirPath, messages, targetPath!!, offset)
fun postErrors() = project.messageBus.syncPublisher(ERRORS_TOPIC).update(elmProject.projectDirPath, messages, targetPath!!, offset)
when {
isUnitTestMode -> postErrors()
else -> {
Expand Down
18 changes: 8 additions & 10 deletions src/main/kotlin/org/elm/workspace/compiler/ElmBuildAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,10 @@ class ElmBuildAction : AnAction() {
?: FileEditorManager.getInstance(project).selectedFiles.firstOrNull { it.fileType == ElmFileType }

interface ElmErrorsListener {
@Suppress("unused")
fun update(baseDirPath: Path, messages: List<ElmError>, targetPath: String, offset: Int)
}

companion object {
val ERRORS_TOPIC = Topic("Elm compiler-messages", ElmErrorsListener::class.java)
val elmMainTypes = setOf(
"Platform" to "Program",
"Html" to "Html",
"VirtualDom" to "Node"
)
}

data class LookupClientLocation(
override val intellijProject: Project,
override val elmProject: ElmProject?,
Expand Down Expand Up @@ -198,7 +190,7 @@ private fun findMainEntryPoint(project: Project, elmProject: ElmProject): List<E
is TyUnknown -> ty.alias?.let { it.module to it.name }
else -> null
}
key != null && key in ElmBuildAction.elmMainTypes && decl.isTopLevel
key != null && key in elmMainTypes && decl.isTopLevel
}
return elmEntries
}
Expand All @@ -219,3 +211,9 @@ private fun showError(project: Project, message: String, includeFixAction: Boole
project.showBalloon(message, NotificationType.ERROR, *actions)
}

val ERRORS_TOPIC = Topic("Elm compiler-messages", ElmBuildAction.ElmErrorsListener::class.java)
val elmMainTypes = setOf(
"Platform" to "Program",
"Html" to "Html",
"VirtualDom" to "Node"
)
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ data class Location(

sealed class Chunk {
data class Unstyled(var str: String) : Chunk()
@Suppress("unused")
data class Styled(var string: String? = null, var bold: Boolean? = null, var underline: Boolean? = null, var color: String? = null, var href: String? = null) : Chunk()
}

Expand Down
Loading
Loading