Skip to content

Commit 2e1f052

Browse files
committed
Add WASM. prefix; Remove restrictions for C., JS. completions
1 parent ffd5fdc commit 2e1f052

File tree

7 files changed

+655
-633
lines changed

7 files changed

+655
-633
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
- Fix IndexOutOfBoundsException while typing `}` at the end of the document
99
- Change order of default value and attribute. Fixes [#22](https://github.com/vlang/intellij-v/issues/22)
1010
- Builtin functions will not show private members in code completion. Fixes [#9](https://github.com/vlang/intellij-v/issues/9)
11+
- Add WASM. prefix
12+
- Remove restrictions for C., JS. completions
1113
- Refactor RunConfiguration:
1214
- Add validation
1315
- Use relative paths to working directory

src/main/gen/io/vlang/lang/_VlangLexer.java

Lines changed: 629 additions & 623 deletions
Large diffs are not rendered by default.

src/main/kotlin/io/vlang/ide/codeInsight/VlangCodeInsightUtil.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ object VlangCodeInsightUtil {
225225
}
226226

227227
fun nonVlangName(name: String): Boolean {
228-
return name.startsWith("JS.") || name.startsWith("C.")
228+
return name.startsWith("JS.") || name.startsWith("C.") || name.startsWith("WASM.")
229229
}
230230

231231
fun getQualifiedName(context: PsiElement, anchor: PsiElement, name: String): String {

src/main/kotlin/io/vlang/ide/inspections/unused/VlangUnusedBaseInspection.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package io.vlang.ide.inspections.unused
22

33
import com.intellij.codeInspection.ProblemsHolder
44
import com.intellij.psi.search.searches.ReferencesSearch
5+
import com.intellij.rml.dfa.ide.getAttribute
56
import io.vlang.ide.inspections.VlangBaseInspection
67
import io.vlang.lang.psi.VlangFile
8+
import io.vlang.lang.psi.VlangFunctionDeclaration
79
import io.vlang.lang.psi.VlangNamedElement
810

911
abstract class VlangUnusedBaseInspection : VlangBaseInspection() {
@@ -16,7 +18,11 @@ abstract class VlangUnusedBaseInspection : VlangBaseInspection() {
1618
val containingFile = element.containingFile as VlangFile
1719
// for now
1820
if (containingFile.isPlatformSpecificFile()) return
19-
if (element.name == null || element.name!!.startsWith("C.")) return
21+
if (element.name == null
22+
|| element.name!!.startsWith("C.")
23+
|| element.name!!.startsWith("JS.")
24+
|| element.name!!.startsWith("WASM.")
25+
) return
2026

2127
if (!shouldBeCheck(element)) return
2228
if (isUnused(element)) {

src/main/kotlin/io/vlang/lang/completion/providers/ReferenceCompletionProvider.kt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,19 @@ object ReferenceCompletionProvider : CompletionProvider<CompletionParameters>()
250250
return@AcceptPredicate false
251251
}
252252

253-
if (e.name?.startsWith("C.") == true) {
254-
return@AcceptPredicate file.isCFile()
255-
}
256-
257-
if (e.name?.startsWith("JS.") == true) {
258-
return@AcceptPredicate file.isJSFile()
259-
}
253+
// if (e.name?.startsWith("C.") == true) {
254+
//// return@AcceptPredicate file.isCFile()
255+
// return@AcceptPredicate true
256+
// }
257+
//
258+
// if (e.name?.startsWith("JS.") == true) {
259+
//// return@AcceptPredicate file.isJSFile()
260+
// return@AcceptPredicate true
261+
// }
262+
//
263+
// if (e.name?.startsWith("WASM.") == true) {
264+
// return@AcceptPredicate true
265+
// }
260266

261267
// forbid raw map completion
262268
if (e is VlangStructDeclaration && e.name == "map") {

src/main/kotlin/io/vlang/lang/lexer/v.flex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ IDENT = {LETTER} {IDENT_PART}*
111111
IDENT_PART = {LETTER} | {DIGIT}
112112

113113
// JS and C special identifiers like JS.function_name or C.free
114-
SPECIAL_IDENT = ("JS." | "C.") "@"? {LETTER} ({LETTER} | {DIGIT} | "." )*
114+
SPECIAL_IDENT = ("JS." | "C." | "WASM.") "@"? {LETTER} ({LETTER} | {DIGIT} | "." )*
115115

116116
STR_DOUBLE = "\""
117117
STR_SINGLE = "'"

src/test/resources/inspections/namingConventions/non_v_names.v

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ module namingConventions
22

33
fn C.foo() {}
44
fn JS.foo() {}
5+
fn WASM.foo() {}
56

67
struct C.Name {}
78
struct JS.Name {}
9+
struct WASM.Name {}
810

911
type C.void = void

0 commit comments

Comments
 (0)