fixed few bugs in compiler and plugin
This commit is contained in:
1 parent
37d093817e
commit
e447c778ed
10 files changed
+243
-45
No files matched your search
+5
-3
@@ -88,9 +88,11 @@ class LyngExternalAnnotator : ExternalAnnotator<LyngExternalAnnotator.Input, Lyn
|
||||
// Imports: each segment as namespace/path
|
||||
mini?.imports?.forEach { imp ->
|
||||
imp.segments.forEach { seg ->
|
||||
val start = analysis.source.offsetOf(seg.range.start)
|
||||
val end = analysis.source.offsetOf(seg.range.end)
|
||||
putRange(start, end, LyngHighlighterColors.NAMESPACE)
|
||||
if (seg.range.start.source === analysis.source && seg.range.end.source === analysis.source) {
|
||||
val start = analysis.source.offsetOf(seg.range.start)
|
||||
val end = analysis.source.offsetOf(seg.range.end)
|
||||
putRange(start, end, LyngHighlighterColors.NAMESPACE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class LyngLexer : LexerBase() {
|
||||
"fun", "val", "var", "class", "interface", "type", "import", "as",
|
||||
"abstract", "closed", "override", "static", "extern", "open", "private", "protected",
|
||||
"if", "else", "for", "while", "return", "true", "false", "null",
|
||||
"when", "in", "is", "break", "continue", "try", "catch", "finally",
|
||||
"when", "in", "is", "break", "continue", "try", "catch", "finally", "void",
|
||||
"get", "set", "object", "enum", "init", "by", "step", "property", "constructor"
|
||||
)
|
||||
|
||||
|
||||
@@ -26,23 +26,16 @@ import com.intellij.psi.search.FilenameIndex
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import net.sergeych.lyng.binding.BindingSnapshot
|
||||
import net.sergeych.lyng.miniast.BuiltinDocRegistry
|
||||
import net.sergeych.lyng.miniast.DocLookupUtils
|
||||
import net.sergeych.lyng.miniast.MiniEnumDecl
|
||||
import net.sergeych.lyng.miniast.MiniRange
|
||||
import net.sergeych.lyng.miniast.MiniScript
|
||||
import net.sergeych.lyng.tools.IdeLenientImportProvider
|
||||
import net.sergeych.lyng.tools.LyngAnalysisRequest
|
||||
import net.sergeych.lyng.tools.LyngAnalysisResult
|
||||
import net.sergeych.lyng.tools.LyngDiagnostic
|
||||
import net.sergeych.lyng.tools.LyngLanguageTools
|
||||
import net.sergeych.lyng.idea.LyngFileType
|
||||
import net.sergeych.lyng.miniast.*
|
||||
import net.sergeych.lyng.tools.*
|
||||
|
||||
object LyngAstManager {
|
||||
private val MINI_KEY = Key.create<MiniScript>("lyng.mini.cache")
|
||||
private val BINDING_KEY = Key.create<BindingSnapshot>("lyng.binding.cache")
|
||||
private val STAMP_KEY = Key.create<Long>("lyng.mini.cache.stamp")
|
||||
private val ANALYSIS_KEY = Key.create<LyngAnalysisResult>("lyng.analysis.cache")
|
||||
private val implicitBuiltinNames = setOf("void")
|
||||
|
||||
fun getMiniAst(file: PsiFile): MiniScript? = runReadAction {
|
||||
getAnalysis(file)?.mini
|
||||
@@ -217,7 +210,7 @@ object LyngAstManager {
|
||||
val msg = diag.message
|
||||
if (msg.startsWith("unresolved name: ")) {
|
||||
val name = msg.removePrefix("unresolved name: ").trim()
|
||||
name in declaredTopLevel || name in builtinTopLevel
|
||||
name in declaredTopLevel || name in builtinTopLevel || name in implicitBuiltinNames
|
||||
} else if (msg.startsWith("unresolved member: ")) {
|
||||
val name = msg.removePrefix("unresolved member: ").trim()
|
||||
val range = diag.range
|
||||
|
||||
+12
@@ -124,4 +124,16 @@ class LyngDefinitionFilesTest : BasePlatformTestCase() {
|
||||
assertTrue("Should not report unresolved name for Declared", messages.none { it.contains("unresolved name: Declared") })
|
||||
assertTrue("Should not report unresolved member for greet", messages.none { it.contains("unresolved member: greet") })
|
||||
}
|
||||
|
||||
fun test_DiagnosticsDoNotReportVoidAsUnresolvedName() {
|
||||
val code = """
|
||||
fun f(): void {
|
||||
return void
|
||||
}
|
||||
""".trimIndent()
|
||||
myFixture.configureByText("main.lyng", code)
|
||||
val analysis = LyngAstManager.getAnalysis(myFixture.file)
|
||||
val messages = analysis?.diagnostics?.map { it.message } ?: emptyList()
|
||||
assertTrue("Should not report unresolved name for void, got=$messages", messages.none { it.contains("unresolved name: void") })
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user